Selaa lähdekoodia

include JS 안 쓰게 수정, 버그 수정

https://github.com/openNAMU/openNAMU/issues/2321
잉여개발기 1 vuosi sitten
vanhempi
sitoutus
810801012f

+ 4 - 4
app.py

@@ -800,8 +800,8 @@ app.route('/bbs/delete/<int:bbs_num>/<int:post_num>/<comment_num>', methods = ['
 
 # Func-api
 ## v1 API
-app.route('/api/render', methods = ['POST'])(api_w_render)
-app.route('/api/render/<tool>', methods = ['POST'])(api_w_render)
+app.route('/api/render', methods = ['POST'])(api_w_render_exter)
+app.route('/api/render/<tool>', methods = ['POST'])(api_w_render_exter)
 
 app.route('/api/raw_exist/<everything:name>', defaults = { 'exist_check' : 'on' })(api_w_raw)
 app.route('/api/raw_rev/<int(signed = True):rev>/<everything:name>')(api_w_raw)
@@ -835,8 +835,8 @@ app.route('/api/recent_changes')(api_list_recent_change_exter)
 app.route('/api/recent_change/<int:limit>')(api_list_recent_change_exter)
 app.route('/api/recent_change/<int:limit>/<set_type>/<int:num>')(api_list_recent_change_exter)
 
-app.route('/api/recent_edit_request')(api_list_recent_edit_request)
-app.route('/api/recent_edit_request/<int:limit>/<set_type>/<int:num>')(api_list_recent_edit_request)
+app.route('/api/recent_edit_request')(api_list_recent_edit_request_exter)
+app.route('/api/recent_edit_request/<int:limit>/<set_type>/<int:num>')(api_list_recent_edit_request_exter)
 
 app.route('/api/recent_discuss/<set_type>/<int:limit>')(api_list_recent_discuss)
 app.route('/api/recent_discuss/<int:limit>')(api_list_recent_discuss)

+ 2 - 0
route/go_api_w_render.py

@@ -1,5 +1,7 @@
 from .tool.func import *
 
+from .go_api_w_raw import api_w_raw
+
 async def api_w_render(name = '', tool = '', request_method = '', request_data = {}):
     with get_db_connect() as conn:
         curs = conn.cursor()

+ 2 - 0
route/list_history.py

@@ -63,6 +63,8 @@ async def list_history(tool = 'history', num = 1, set_type = 'normal', doc_name
                     data_html += await opennamu_make_list('----', '', '', '')
                     continue
 
+                doc_name = url_pas(data[for_a][1])
+
                 left = '<a href="/w/' + doc_name + '">' + html.escape(data[for_a][1]) + '</a> '
                 rev = ''
 

+ 11 - 1
route/tool/func.py

@@ -1509,7 +1509,17 @@ def render_set(conn, doc_name = '', doc_data = '', data_type = 'view', markup =
     if db_data and db_data[0][0] != '':
         render_lang_data['category'] = db_data[0][0]
 
-    get_class_render = class_do_render(conn, render_lang_data, markup, parameter).do_render(doc_name, doc_data, data_type)
+    get_class_render = class_do_render(
+        conn,
+        render_lang_data,
+        markup,
+        parameter,
+        render_set
+    ).do_render(
+        doc_name,
+        doc_data,
+        data_type
+    )
     if data_type == 'backlink':
         return ''
 

+ 11 - 2
route/tool/func_render.py

@@ -5,7 +5,7 @@ from .func_render_namumark import class_do_render_namumark
 # 커스텀 마크 언젠간 다시 추가 예정
 
 class class_do_render:
-    def __init__(self, conn, lang_data = {}, markup = '', parameter = {}):
+    def __init__(self, conn, lang_data = {}, markup = '', parameter = {}, parent = None):
         self.conn = conn
 
         if lang_data == '{}':
@@ -17,6 +17,7 @@ class class_do_render:
         self.lang_data = lang_data
         self.markup = markup
         self.parameter = parameter
+        self.parent = parent
 
     def generate_random_string(self, length = 32):
         characters = string.ascii_letters + string.digits
@@ -54,7 +55,15 @@ class class_do_render:
             rep_data = db_data[0][0] if db_data else 'namumark'
 
         if rep_data == 'namumark' or rep_data == 'namumark_beta':
-            data_end = class_do_render_namumark(self.conn, doc_name, doc_data, doc_set, self.lang_data, parameter = self.parameter)()
+            data_end = class_do_render_namumark(
+                self.conn,
+                doc_name,
+                doc_data,
+                doc_set,
+                self.lang_data,
+                parameter = self.parameter,
+                parent = self.parent
+            )()
         elif rep_data == 'raw':
             data_end = [html.escape(doc_data).replace('\n', '<br>'), '', {}]
         else:

+ 26 - 7
route/tool/func_render_namumark.py

@@ -3,7 +3,17 @@ from .func_tool import *
 from typing import Any
 
 class class_do_render_namumark:
-    def __init__(self, conn, doc_name, doc_data, doc_set, lang_data, do_type = 'exter', parameter = {}):
+    def __init__(
+        self,
+        conn,
+        doc_name,
+        doc_data,
+        doc_set,
+        lang_data,
+        do_type = 'exter',
+        parameter = {},
+        parent = None
+    ):
         self.conn = conn
         self.curs = self.conn.cursor()
 
@@ -13,6 +23,7 @@ class class_do_render_namumark:
 
         self.do_type = do_type
         self.parameter = parameter
+        self.parent = parent
 
         self.lang_data = lang_data
         try:
@@ -1401,7 +1412,7 @@ class class_do_render_namumark:
                     self.data_backlink[include_name]['include'] = ''
 
                     # load include db data
-                    self.curs.execute(db_change("select title from data where title = ?"), [include_name])
+                    self.curs.execute(db_change("select data from data where title = ?"), [include_name])
                     db_data = self.curs.fetchall()
                     if db_data:
                         # include link func
@@ -1409,14 +1420,22 @@ class class_do_render_namumark:
                         if include_set_data == 'use':
                             include_link = '<div><a href="/w/' + url_pas(include_name) + '">(' + include_name_org + ')</a></div>'
 
+                        include_data = ''
+                        if self.parent:
+                            include_data_tmp = self.parent(
+                                self.conn,
+                                doc_data = db_data[0][0], 
+                                data_type = 'api_include',
+                                parameter = include_change_list
+                            )
+
+                            include_data = include_data_tmp[0] + '<script>window.addEventListener("DOMContentLoaded", function() {' + include_data_tmp[1] + '});</script>'
+
                         include_sub_name = self.doc_set['doc_include'] + 'opennamu_include_' + str(include_num)
-                        self.render_data_js += '''
-                            opennamu_do_include("''' + self.get_tool_js_safe(include_name) + '''", "''' + self.get_tool_js_safe(self.doc_name) + '''", "''' + self.get_tool_js_safe(include_sub_name) + '''", "''' + self.get_tool_js_safe(include_sub_name) + '''");\n
-                        '''
                         data_name = self.get_tool_data_storage('' + \
                             include_link + \
-                            '<div id="' + include_sub_name + '" style="display: none;">' + urllib.parse.quote(json.dumps(include_change_list)) + '</div>' + \
-                        '', '', match_org)
+                            '<div id="' + include_sub_name + '"></div>' + \
+                        '', include_data, match_org)
                     else:
                         self.data_backlink[include_name]['no'] = ''
 

+ 1 - 1
version.json

@@ -1,5 +1,5 @@
 {
-    "r_ver" : "v3.6.0-v8",
+    "r_ver" : "v3.6.0-v9",
     "c_ver" : "20250323",
     "s_ver" : "20240426",
     "bin_link" : "https://github.com/openNAMU/GopenNAMU/releases/download/v2025-03-21-v2/"

+ 0 - 20
views/main_css/js/func/render.js

@@ -195,26 +195,6 @@ function opennamu_do_category_spread() {
     }
 }
 
-function opennamu_do_include(name, render_name, to_obj, option_obj) {
-    let option = {};
-    if(option_obj !== '') {
-        if(document.getElementById(option_obj)) {
-            option = document.getElementById(option_obj).innerHTML;
-            option = decodeURIComponent(option);
-        }
-    }
-
-    fetch("/api/raw/" + opennamu_do_url_encode(name)).then(function(res) {
-        return res.json();
-    }).then(function(data) {
-        if(data["data"]) {
-            opennamu_do_render(to_obj, data["data"], render_name, 'include', option, function() {
-                document.getElementById(option_obj).style.display = "inline";
-            });
-        }
-    });
-}
-
 function opennamu_do_toc() {
     let data = document.getElementById('opennamu_render_complete');
     let h_tag = data.querySelectorAll("h1, h2, h3, h4, h5, h6");