잉여개발기 (SPDV) пре 3 година
родитељ
комит
a83443cbea

+ 2 - 1
route/edit.py

@@ -157,7 +157,7 @@ def edit(name = 'Test', section = 0, do_type = ''):
                     require.config({ paths: { 'vs': 'https://cdnjs.cloudflare.com/ajax/libs/monaco-editor/0.20.0/min/vs' }});
                     require(["vs/editor/editor.main"], function () {
                         window.editor = monaco.editor.create(document.getElementById('monaco_editor'), {
-                            value: document.getElementById('textarea_edit_view').value,
+                            value: document.getElementById('opennamu_js_edit_textarea_view').value,
                             language: 'plaintext',
                             wordWrap: true,
                             theme: \'''' + monaco_thema + '''\',
@@ -201,6 +201,7 @@ def edit(name = 'Test', section = 0, do_type = ''):
                         do_paste_image();
                         ''' + add_script + '''
                     </script>
+                    <!-- JS : edit.js -->
                 ''',
                 menu = [
                     ['w/' + url_pas(name), load_lang('return')],

+ 4 - 4
route/main_func_setting_head.py

@@ -48,18 +48,18 @@ def main_func_setting_head(num, skin_name = ''):
                 title = '_body'
                 start = ''
                 plus = '''
-                    <button id="opennamu_js_preview" type="button" onclick="load_raw_preview(\'content\', \'see_preview\')">''' + load_lang('preview') + '''</button>
+                    <button id="opennamu_js_preview" type="button" onclick="load_raw_preview(\'content\', \'opennamu_js_preview_area\')">''' + load_lang('preview') + '''</button>
                     <hr class="main_hr">
-                    <div id="see_preview"></div>
+                    <div id="opennamu_js_preview_area"></div>
                 '''
             elif num == 7:
                 curs.execute(db_change("select data from other where name = 'bottom_body'"))
                 title = '_bottom_body'
                 start = ''
                 plus = '''
-                    <button id="opennamu_js_preview" type="button" onclick="load_raw_preview(\'content\', \'see_preview\')">''' + load_lang('preview') + '''</button>
+                    <button id="opennamu_js_preview" type="button" onclick="load_raw_preview(\'content\', \'opennamu_js_preview_area\')">''' + load_lang('preview') + '''</button>
                     <hr class="main_hr">
-                    <div id="see_preview"></div>
+                    <div id="opennamu_js_preview_area"></div>
                 '''
             else:
                 curs.execute(db_change("select data from other where name = 'head' and coverage = ?"), [skin_name])

+ 1 - 1
route/tool/func.py

@@ -826,7 +826,7 @@ def edit_button(editor_display = '0'):
     for insert_data in insert_list:
         data += '' + \
             '<a href="' + \
-                'javascript:do_insert_data(\'textarea_edit_view\', \'' + insert_data[0] + '\', ' + editor_display + ')' + \
+                'javascript:do_insert_data(\'opennamu_js_edit_textarea_view\', \'' + insert_data[0] + '\', ' + editor_display + ')' + \
             '">(' + insert_data[1] + ')</a> ' + \
         ''
 

+ 44 - 18
route/topic.py

@@ -82,24 +82,49 @@ def topic(topic_num = 0):
             cate_re = re.compile(r'\[\[((?:분류|category):(?:(?:(?!\]\]).)*))\]\]', re.I)
             data = cate_re.sub('[br]', flask.request.form.get('content', 'Test').replace('\r', ''))
 
-            for rd_data in re.findall(r"(?: |\n|^)(#(?:[0-9]+))(?: |\n|$)", 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:
-                    add_alarm(ip_data[0][0], ip + ' | <a href="/thread/' + topic_num + '#' + num + '">' + name + ' | ' + sub + ' | #' + num + '</a>')
-
-            for rd_data in re.findall(r"(?: |\n|^)@((?:[^ ]+))(?: |\n|$)", 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])
+            call_thread_regex = r"( |\n|^)(?:#([0-9]+))( |\n|$)"
+            call_thread_count = len(re.findall(call_thread_regex, data)) * 3
+            while 1:
+                rd_data = re.search(call_thread_regex, data)
+                if call_thread_count < 0:
+                    break
+                elif not rd_data:
+                    break
+                else:
+                    rd_data = rd_data.groups()
+
+                    curs.execute(db_change("select ip from topic where code = ? and id = ?"), [topic_num, rd_data[1]])
                     ip_data = curs.fetchall()
+                    if ip_data and ip_or_user(ip_data[0][0]) == 0 and ip != ip_data[0][0]:
+                        add_alarm(ip_data[0][0], ip + ' | <a href="/thread/' + topic_num + '#' + num + '">' + name + ' | ' + sub + ' | #' + num + '</a>')
+
+                    data = re.sub(call_thread_regex, rd_data[0] + '<topic_a>#' + rd_data[1] + '</topic_a>' + rd_data[2], data, 1)
+
+                call_thread_count -= 1
+
+            call_user_regex = r"( |\n|^)(?:@([^ ]+))( |\n|$)"
+            call_user_count = len(re.findall(call_user_regex, data)) * 3
+            while 1:
+                rd_data = re.search(call_user_regex, data)
+                if call_user_count < 0:
+                    break
+                elif not rd_data:
+                    break
+                else:
+                    rd_data = rd_data.groups()
+
+                    curs.execute(db_change("select ip from history where ip = ? limit 1"), [rd_data[1]])
+                    ip_data = curs.fetchall()
+                    if not ip_data:
+                        curs.execute(db_change("select ip from topic where ip = ? limit 1"), [rd_data[1]])
+                        ip_data = curs.fetchall()
+
+                    if ip_data and ip_or_user(ip_data[0][0]) == 0 and ip != ip_data[0][0]:
+                        add_alarm(ip_data[0][0], ip + ' | <a href="/thread/' + topic_num + '#' + num + '">' + name + ' | ' + sub + ' | #' + num + '</a>')
 
-                if ip_data and ip_or_user(ip_data[0][0]) == 0:
-                    add_alarm(ip_data[0][0], ip + ' | <a href="/thread/' + topic_num + '#' + num + '">' + name + ' | ' + sub + ' | #' + num + '</a>')
+                    data = re.sub(call_user_regex, rd_data[0] + '<topic_call>@' + rd_data[1] + '</topic_call>' + rd_data[2], data, 1)
 
-            data = re.sub(r"( |\n|^)(#(?:[0-9]+))( |\n|$)", '\g<1><topic_a>\g<2></topic_a>\g<3>', data)
-            data = re.sub(r"( |\n|^)(@(?:[^ ]+))( |\n|$)", '\g<1><topic_call>\g<2></topic_call>\g<3>', data)
+                call_user_count -= 1
 
             do_add_thread(
             	topic_num,
@@ -143,17 +168,18 @@ def topic(topic_num = 0):
                     <hr class="main_hr">
                     <form style="''' + display + '''" method="post">
                         ''' + data_input_topic_name + '''
-                        <textarea id="textarea_edit_view" class="opennamu_comment_textarea" placeholder="''' + topic_text + '''" name="content"></textarea>
+                        <textarea id="opennamu_js_edit_textarea" class="opennamu_comment_textarea" placeholder="''' + topic_text + '''" name="content"></textarea>
                         <hr class="main_hr">
                         ''' + captcha_get() + (ip_warning() if display == '' else '') + '''
                         <input style="display: none;" name="topic" value="''' + name + '''">
                         <input style="display: none;" name="title" value="''' + sub + '''">
                         <button id="opennamu_js_save" type="submit">''' + load_lang('send') + '''</button>
-                        <button id="opennamu_js_preview" type="button" onclick="load_preview(\'\')">''' + load_lang('preview') + '''</button>
+                        <button id="opennamu_js_preview" type="button">''' + load_lang('preview') + '''</button>
                     </form>
                     <hr class="main_hr">
-                    <div id="see_preview"></div>
+                    <div id="opennamu_js_preview_area"></div>
                     <!-- JS : opennamu_do_thread_make -->
+                    <!-- JS : edit.js -->
                 ''',
                 menu = [['topic/' + url_pas(name), load_lang('list')]]
             ))

+ 1 - 1
version.json

@@ -1,6 +1,6 @@
 {
     "beta" : {
-        "r_ver" : "v3.4.5 (stable2) (beta3) (dev48)",
+        "r_ver" : "v3.4.5 (stable2) (beta3) (dev49)",
         "c_ver" : "3500113",
         "s_ver" : "3500110"
     }

+ 7 - 3
views/main_css/js/route/edit.js

@@ -42,8 +42,6 @@ function do_insert_preview() {
         if(xhr.readyState === 4 && xhr.status === 200) {
             let o_p_data = JSON.parse(xhr.responseText);
             
-            console.log(o_p_data);
-            
             document.getElementById('opennamu_js_preview_area').innerHTML = o_p_data['data'];
             eval(o_p_data['js_data'])
         }
@@ -51,7 +49,7 @@ function do_insert_preview() {
 }
 
 
-if(document.getElementById('opennamu_js_save')) {
+if(window.location.pathname.match(/^\/(edit|edit_from|edit_section)\//)) {
     do_stop_exit();
     
     document.getElementById('opennamu_js_save').onclick = function() {
@@ -62,4 +60,10 @@ if(document.getElementById('opennamu_js_save')) {
         do_insert_edit_data();
         do_insert_preview();
     };
+}
+
+if(window.location.pathname.match(/^\/(thread)\//)) {
+    document.getElementById('opennamu_js_preview').onclick = function() {
+        do_insert_preview();
+    };
 }

+ 8 - 10
views/main_css/js/route/thread.js

@@ -50,18 +50,17 @@ function opennamu_do_thread_make(topic_num, type_do = 'top', some = '', where =
                 let ip_o = data_t[key]['ip'];
                 let blind = data_t[key]['blind'];
                 let data_i_pas = data_t[key]['data_pas'][0];
-                
+                let data_get_list = [];
+
                 if(data_i_pas === '') {
                     data_i_pas = '<br>';
                 } else {
-                    data_i_pas = data_i_pas.replace(
-                        /&lt;topic_a&gt;((?:(?!&lt;\/topic_a&gt;).)+)&lt;\/topic_a&gt;/g,
-                        '<a href="$1">$1</a>'
-                    );
-                    data_i_pas = data_i_pas.replace(
-                        /&lt;topic_call&gt;@((?:(?!&lt;\/topic_call&gt;).)+)&lt;\/topic_call&gt;/g,
-                        '<a href="/w/user:$1">@$1</a>', 
-                    );
+                    let load_thread_regex = /&lt;topic_a&gt;((?:(?!&lt;\/topic_a&gt;).)+)&lt;\/topic_a&gt;/g;
+
+                    data_get_list = data_i_pas.match(load_thread_regex);
+
+                    data_i_pas = data_i_pas.replace(load_thread_regex, '<a href="$1">$1</a>');
+                    data_i_pas = data_i_pas.replace(/&lt;topic_call&gt;@((?:(?!&lt;\/topic_call&gt;).)+)&lt;\/topic_call&gt;/g, '<a href="/w/user:$1">@$1</a>');
                 }
                 
                 if(blind === 'O') {
@@ -112,7 +111,6 @@ function opennamu_do_thread_make(topic_num, type_do = 'top', some = '', where =
                     '<hr class="main_hr">' + 
                 ''
 
-                console.log(where);
                 document.getElementById(where).innerHTML += data_a;
                 
                 count += 1;