ソースを参照

멘션 기능 추가, 토론 구동 방식 일부 변경

Surplus_Up (2DU) 6 年 前
コミット
85dcb53da5
5 ファイル変更36 行追加8 行削除
  1. 11 0
      route/api_topic_sub.py
  2. 1 1
      route/tool/func.py
  3. 20 4
      route/topic.py
  4. 1 1
      version.json
  5. 3 2
      views/main_css/js/load_topic.js

+ 11 - 0
route/api_topic_sub.py

@@ -66,6 +66,17 @@ def api_topic_sub_2(conn, topic_num):
                 t_plus_data = t_data_f[1]
                 t_data_f = t_data_f[0]
 
+                t_data_f = re.sub(
+                    r'<topic_a>((?:(?!<\/topic_a>).)+)<\/topic_a>', 
+                    '<a href="\g<1>">\g<1></a>', 
+                    t_data_f
+                )
+                t_data_f = re.sub(
+                    r'&lt;topic_call&gt;@((?:(?!&lt;\/topic_call&gt;).)+)&lt;\/topic_call&gt;', 
+                    '<a href="/w/user:\g<1>">@\g<1></a>', 
+                    t_data_f
+                )
+
                 all_data = '' + \
                     '<table id="toron">' + \
                         '<tbody>' + \

+ 1 - 1
route/tool/func.py

@@ -498,7 +498,7 @@ def other2(data):
         data += ['']
 
     req_list = ''
-    main_css_ver = 37
+    main_css_ver = 38
 
     if not 'main_css_load' in flask.session or not 'main_css_ver' in flask.session or flask.session['main_css_ver'] != main_css_ver:
         for i_data in os.listdir(os.path.join("views", "main_css", "css")):

+ 20 - 4
route/topic.py

@@ -70,7 +70,7 @@ def topic_2(conn, topic_num):
         cate_re = re.compile(r'\[\[((?:분류|category):(?:(?:(?!\]\]).)*))\]\]', re.I)
         data = cate_re.sub('[br]', flask.request.form.get('content', 'Test'))
 
-        for rd_data in re.findall(r"(?:#([0-9]+))", data):
+        for rd_data in re.findall(r"(?: |^)(#(?:[0-9]+))(?: |$)", data):
             curs.execute(db_change("select ip from topic where code = ? and id = ?"), [topic_num, rd_data])
             ip_data = curs.fetchall()
             if ip_data and ip_or_user(ip_data[0][0]) == 0:
@@ -80,7 +80,23 @@ def topic_2(conn, topic_num):
                     today
                 ])
 
-        data = re.sub(r"(?P<in>#(?:[0-9]+))", '[[\g<in>]]', data)
+        for rd_data in re.findall(r"(?: |^)@((?:[^ ]+))(?: |$)", data):
+            curs.execute(db_change("select ip from history where ip = ? limit 1"), [rd_data])
+            ip_data = curs.fetchall()
+            if not ip_data:
+                curs.execute(db_change("select ip from topic where ip = ? limit 1"), [rd_data])
+                ip_data = curs.fetchall()
+
+            print(ip_data)
+            if ip_data and ip_or_user(ip_data[0][0]) == 0:
+                curs.execute(db_change('insert into alarm (name, data, date) values (?, ?, ?)'), [
+                    ip_data[0][0],
+                    ip + ' | <a href="/thread/' + topic_num + '#' + num + '">' + name + ' | ' + sub + ' | #' + num + '</a>',
+                    today
+                ])
+
+        data = re.sub(r"( |^)(#(?:[0-9]+))( |$)", '\g<1><topic_a>\g<2></topic_a>\g<3>', data)
+        data = re.sub(r"( |^)(@(?:[^ ]+))( |$)", '\g<1><topic_call>\g<2></topic_call>\g<3>', data)
 
         rd_plus(topic_num, today, name, sub)
         curs.execute(db_change("insert into topic (id, data, date, ip, code) values (?, ?, ?, ?, ?)"), [
@@ -92,7 +108,7 @@ def topic_2(conn, topic_num):
         ])
         conn.commit()
 
-        return redirect('/thread/' + topic_num + '?where=bottom')
+        return redirect('/thread/' + topic_num + '#' + num)
     else:
         data = ''
 
@@ -114,7 +130,7 @@ def topic_2(conn, topic_num):
                 ''' + captcha_get() + (ip_warring() if display == '' else '') + '''
                 <input style="display: none;" name="topic" value="''' + name + '''">
                 <input style="display: none;" name="title" value="''' + sub + '''">
-                <button type="submit">''' + load_lang('send') + '''</button>
+                <button id="save" type="submit">''' + load_lang('send') + '''</button>
                 <button id="preview" type="button" onclick="load_preview(\'\')">''' + load_lang('preview') + '''</button>
             </form>
             <hr class=\"main_hr\">

+ 1 - 1
version.json

@@ -1,6 +1,6 @@
 {
     "master" : {
-        "r_ver" : "v3.1.8-master-36",
+        "r_ver" : "v3.1.8-master-37",
         "c_ver" : "3183603",
         "s_ver" : "8"
     }, "stable" : {

+ 3 - 2
views/main_css/js/load_topic.js

@@ -81,8 +81,9 @@ function topic_main_load(topic_num, s_num) {
 
             document.getElementById('main_topic').innerHTML = n_data;
             eval(t_plus_data);
-            if(window.location.search === "?where=bottom") {
-                document.getElementById(num).focus();
+
+            if(window.location.hash) {
+                document.getElementById(window.location.hash.replace(/^#/, '')).focus();
             }
             
             if(!s_num) {