Surplus_Up (2DU) 6 лет назад
Родитель
Сommit
33b1beb768

+ 5 - 3
route/api_w.py

@@ -19,16 +19,18 @@ def api_w_2(conn, name):
                 curs.execute("select data from data where title = ?", [name])
                 data = curs.fetchall()
                 if data:
-                    if flask.request.args.get('include', '1'):
+                    if flask.request.args.get('include', 'include_1'):
                         include_re = re.compile('\[include\(((?:(?!\)\]).)+)\)\]', re.I)
                         category_re = re.compile('\[\[(?:(?:category|분류):(?:(?!\[\[|\]\]).)+)\]\]', re.I)
                         
                         json_data = include_re.sub('', data[0][0])
-                        json_data = category_re.sub('', json_data)
+                        json_data = category_re.sub('', json_data, )
+                        
+                        g_data = render_set(title = name, data = json_data, num = 2, include = flask.request.args.get('include', 'include_1'))
                     else:
                         json_data = g_data[0]
 
-                    g_data = render_set(title = name, data = json_data, num = 2)
+                        g_data = render_set(title = name, data = json_data, num = 2)
 
                     return flask.jsonify({ "title" : name, "data" : g_data[0], "js_data" : g_data[1] })
                 else:

+ 2 - 2
route/tool/func.py

@@ -134,14 +134,14 @@ def last_change(data):
 def easy_minify(data, tool = None):    
     return last_change(data)
 
-def render_set(title = '', data = '', num = 0, s_data = 0):
+def render_set(title = '', data = '', num = 0, s_data = 0, include = None):
     if acl_check(title, 'render') == 1:
         return 'HTTP Request 401.3'
     elif s_data == 1:
         return data
     else:
         if data != None:
-            return namumark(title, data, num)
+            return namumark(title, data, num, include)
         else:
             return 'HTTP Request 404'
 

+ 2 - 2
route/tool/mark.py

@@ -40,11 +40,11 @@ def plusing(data):
         if not curs.fetchall():
             curs.execute("insert into back (title, link, type) values (?, ?, ?)", [data_in[1], data_in[0], data_in[2]])
 
-def namumark(title = '', data = None, num = 0):
+def namumark(title, data, num, include):
     curs.execute('select data from other where name = "markup"')
     rep_data = curs.fetchall()
     if rep_data[0][0] == 'namumark':
-        data = namu(conn, data, title, num)
+        data = namu(conn, data, title, num, include)
     elif rep_data[0][0] == 'markdown':
         data = markdown(conn, data, title, num)
     else:

+ 30 - 6
route/tool/set_mark/namu.py

@@ -350,7 +350,7 @@ def middle_parser(data, fol_num, syntax_num, folding_num):
 
     return [data, [fol_num, syntax_num, folding_num]]
 
-def namu(conn, data, title, main_num):
+def namu(conn, data, title, main_num, include_num):
     curs = conn.cursor()
 
     global plus_data
@@ -873,6 +873,8 @@ def namu(conn, data, title, main_num):
     
     footdata_all = '<hr><ul id="footnote_data">'
     
+    include_num = include_num + '-' if include_num else ''
+    
     re_footnote = re.compile('(?:\[\*((?:(?! |\]).)*)(?: ((?:(?!(?:\[\*|\])).)+))?\]|(\[(?:각주|footnote)\]))')
     while 1:
         footnote = re_footnote.search(data)
@@ -887,7 +889,13 @@ def namu(conn, data, title, main_num):
                     else:
                         footdata_in = footdata[2]
 
-                    footdata_all += '<li><a href="#rfn-' + str(footdata[0]) + '">(' + footdata[1] + ')</a> <span id="fn-' + str(footdata[0]) + '">' + footdata_in + '</span></li>'
+                    footdata_all += '' + \
+                        '<li>' + \
+                            '<a href="#' + include_num + 'rfn-' + str(footdata[0]) + '">' + \
+                                '(' + footdata[1] + ')' + \
+                            '</a> <span id="' + include_num + 'fn-' + str(footdata[0]) + '">' + footdata_in + '</span>' + \
+                        '</li>' + \
+                    ''
                 
                 data = re_footnote.sub(footdata_all + '</ul>', data, 1)
                 
@@ -905,9 +913,15 @@ def namu(conn, data, title, main_num):
 
                         footnote_all += [[float(footshort), footshort, 0]]
 
-                        data = re_footnote.sub('<sup><a href="javascript:do_open_foot(\'fn-' + footshort + '\')" id="rfn-' + footshort + '">(' + footnote_name + ')</a></sup><span class="foot_plus" id="cfn-' + footshort + '"></span>', data, 1)
+                        data = re_footnote.sub('' + \
+                            '<sup>' + \
+                                '<a href="javascript:do_open_foot(\'' + include_num + 'fn-' + footshort + '\')" id="' + include_num + 'rfn-' + footshort + '">' + \
+                                    '(' + footnote_name + ')' + \
+                                '</a>' + \
+                            '</sup> <div class="foot_plus" id="' + include_num + 'cfn-' + footshort + '"></div>' + \
+                        '', data, 1)
                     else:
-                        data = re_footnote.sub('<sup><a href="#">(' + footnote_name + ')</a></sup>', data, 1)
+                        data = re_footnote.sub('<sup><a href="javascript:void(0);">(' + footnote_name + ')</a></sup>', data, 1)
                 else:
                     footnote_number += 1
 
@@ -923,7 +937,13 @@ def namu(conn, data, title, main_num):
 
                     footnote_all += [[footnote_number, footnote_name, footnote]]
                     
-                    data = re_footnote.sub('<sup><a href="javascript:do_open_foot(\'fn-' + str(footnote_number) + '\')" id="rfn-' + str(footnote_number) + '">(' + footnote_name + ')</a></sup><div class="foot_plus" id="cfn-' + str(footnote_number) + '"></div>', data, 1)
+                    data = re_footnote.sub('' + \
+                        '<sup>' + \
+                            '<a href="javascript:do_open_foot(\'' + include_num + 'fn-' + str(footnote_number) + '\')" id="' + include_num + 'rfn-' + str(footnote_number) + '">' + \
+                                '(' + footnote_name + ')' + \
+                            '</a>' + \
+                        '</sup> <div class="foot_plus" id="' + include_num + 'cfn-' + str(footnote_number) + '"></div>' + \
+                    '', data, 1)
         else:
             break
 
@@ -937,7 +957,11 @@ def namu(conn, data, title, main_num):
         else:
             footdata_in = footdata[2]
 
-        footdata_all += '<li><a href="#rfn-' + str(footdata[0]) + '">(' + footdata[1] + ')</a> <span id="fn-' + str(footdata[0]) + '">' + footdata_in + '</span></li>'
+        footdata_all += '' + \
+            '<li>' + \
+                '<a href="#' + include_num + 'rfn-' + str(footdata[0]) + '">(' + footdata[1] + ')</a> <span id="' + include_num + 'fn-' + str(footdata[0]) + '">' + footdata_in + '</span>' + \
+            '</li>' + \
+        ''
 
     footdata_all += '</ul>'
     if footdata_all == '<hr><ul id="footnote_data"></ul>':

+ 12 - 2
views/main_css/js/do_open_foot.js

@@ -1,10 +1,20 @@
 function do_open_foot(name) {
-    var o_data = document.getElementById('c' + name);
+    var found_include = name.match(/^(include_(?:[0-9]+)\-)/);
+    if(found_include) {
+        var o_data = document.getElementById(found_include[1] + 'c' + name.replace(/^(?:include_(?:[0-9]+)\-)/, ''));
+    } else {
+        var o_data = document.getElementById('c' + name);
+    }
+    
     var g_data = document.getElementById(name.replace(/\.([0-9]+)$/, ''));
 
     if(o_data.innerHTML === '') {
         o_data.style.display = 'block';
-        o_data.innerHTML += '<div class="foot_in"><a onclick="do_open_foot(\'' + name + '\')" href="#' + name + '">(Go)</a> ' + g_data.innerHTML + '</div><a class="foot_close" onclick="do_open_foot(\'' + name + '\')" href="javascript:void();">(X)</a>';
+        o_data.innerHTML += '' + 
+            '<div class="foot_in">' + 
+                '<a onclick="do_open_foot(\'' + name + '\')" href="#' + name + '">(Go)</a> ' + g_data.innerHTML + 
+            '</div> <a class="foot_close" onclick="do_open_foot(\'' + name + '\')" href="javascript:void(0);">(X)</a>' + 
+        '';
     } else {
         o_data.style.display = 'none';
         o_data.innerHTML = '';

+ 1 - 1
views/main_css/js/load_include.js

@@ -1,7 +1,7 @@
 function load_include(title, name, p_data) {
     var o_data = document.getElementById(name);
 
-    var url = "/api/w/" + encodeURI(title) + "?include=1";
+    var url = "/api/w/" + encodeURI(title) + "?include=" + name;
     
     var xhr = new XMLHttpRequest();
     xhr.open("GET", url, true);