2
0
Эх сурвалжийг харах

Merge pull request #998 from 2du/dev

Dev
잉여개발기 (SPDV) 5 жил өмнө
parent
commit
415c0528c0

+ 7 - 4
route/api_version.py

@@ -8,21 +8,24 @@ def api_version_2(conn, r_ver, c_ver):
 
 
     curs.execute(db_change('select data from other where name = "update"'))
     curs.execute(db_change('select data from other where name = "update"'))
     up_data = curs.fetchall()
     up_data = curs.fetchall()
-    up_data = up_data[0][0] if up_data else 'stable'
+    up_data = up_data[0][0] if up_data and up_data[0][0] in ['stable', 'beta', 'dev'] else 'stable'
 
 
     try:
     try:
-        data = urllib.request.urlopen('https://raw.githubusercontent.com/2du/openNAMU/beta/version.json')
+        data = urllib.request.urlopen('https://raw.githubusercontent.com/2du/openNAMU/' + up_data + '/version.json')
     except:
     except:
         data = None
         data = None
 
 
     if data and data.getcode() == 200:
     if data and data.getcode() == 200:
         try:
         try:
             json_data = json.loads(data.read().decode())
             json_data = json.loads(data.read().decode())
-            if up_data in json_data:
-                n_ver = json_data[up_data]['r_ver']
         except:
         except:
             pass
             pass
 
 
+        if 'beta' in json_data:
+            n_ver = json_data['beta']['r_ver']
+        elif 'master' in json_data:
+            n_ver = json_data['master']['r_ver']
+
     json_data = { "version" : r_ver, "db_version" : c_ver, "lastest_version" : n_ver  }
     json_data = { "version" : r_ver, "db_version" : c_ver, "lastest_version" : n_ver  }
 
 
     return flask.jsonify(json_data)
     return flask.jsonify(json_data)

+ 1 - 5
route/api_w.py

@@ -20,11 +20,7 @@ def api_w_2(conn, name):
                 data = curs.fetchall()
                 data = curs.fetchall()
                 if data:
                 if data:
                     if flask.request.args.get('include', 'include_1'):
                     if flask.request.args.get('include', 'include_1'):
-                        include_re = re.compile(r'\[include\(((?:(?!\)\]).)+)\)\]', re.I)
-                        category_re = re.compile(r'\[\[(?:(?:category|분류):(?:(?!\[\[|\]\]).)+)\]\]', re.I)
-
-                        json_data = include_re.sub('', data[0][0])
-                        json_data = category_re.sub('', json_data)
+                        json_data = data[0][0]
 
 
                         get_all_change_1 = [('@' + i[0] + '@', i[1]) for i in re.findall(r'@([^=]+)=([^@]+)@', json_data)]
                         get_all_change_1 = [('@' + i[0] + '@', i[1]) for i in re.findall(r'@([^=]+)=([^@]+)@', json_data)]
                         json_data = re.sub(r'@(?P<in>[^=]+)=([^@]+)@', '@\g<in>@', json_data)
                         json_data = re.sub(r'@(?P<in>[^=]+)=([^@]+)@', '@\g<in>@', json_data)

+ 1 - 4
route/server_now_update.py

@@ -11,10 +11,7 @@ def server_now_update_2(conn, r_ver):
 
 
         curs.execute(db_change('select data from other where name = "update"'))
         curs.execute(db_change('select data from other where name = "update"'))
         up_data = curs.fetchall()
         up_data = curs.fetchall()
-        if up_data:
-            up_data = up_data[0][0]
-        else:
-            up_data = 'stable'
+        up_data = up_data[0][0] if up_data and up_data[0][0] in ['stable', 'beta', 'dev'] else 'stable'
 
 
         print('----')
         print('----')
         print('Update')
         print('Update')

+ 7 - 1
route/tool/func.py

@@ -264,7 +264,13 @@ def update(ver_num, set_data):
                 get_data[2]
                 get_data[2]
             ])
             ])
 
 
-    if ver_num < 3202200:
+    if ver_num < 3202400:
+        curs.execute(db_change("select data from other where name = 'update'"))
+        get_data = curs.fetchall()
+        if get_data and get_data[0][0] == 'master':
+            curs.execute(db_change("update other set data = 'beta' where name = 'update'"), [])
+
+    if ver_num < 3202500:
         curs.execute(db_change('delete from cache_data'))
         curs.execute(db_change('delete from cache_data'))
 
 
     conn.commit()
     conn.commit()

+ 75 - 65
route/tool/set_mark/namumark.py

@@ -39,11 +39,11 @@ def link_fix(main_link, no_change = 0):
     main_link = main_link.replace("<link_comma>", "&#x27;")
     main_link = main_link.replace("<link_comma>", "&#x27;")
     main_link = main_link.replace('\\#', '%23')
     main_link = main_link.replace('\\#', '%23')
 
 
-    find_data = re.findall(r'<span id="(nowiki_[0-9]+)">', main_link)
+    find_data = re.findall(r'<span id="((?:include_(?:[0-9]+)_)?(?:nowiki_[0-9]+))">', main_link)
     for i in find_data:
     for i in find_data:
         main_link = main_link.replace('<span id="' + i + '"></span>', end_data[i])
         main_link = main_link.replace('<span id="' + i + '"></span>', end_data[i])
 
 
-    find_data = re.findall(r'<span id="(nowiki_[0-9]+)">', other_link)
+    find_data = re.findall(r'<span id="((?:include_(?:[0-9]+)_)?(?:nowiki_[0-9]+))">', other_link)
     for i in find_data:
     for i in find_data:
         other_link = other_link.replace('<span id="' + i + '"></span>', end_data[i])
         other_link = other_link.replace('<span id="' + i + '"></span>', end_data[i])
 
 
@@ -536,18 +536,23 @@ def namumark(conn, data, title, include_num):
 
 
     nowiki_num = 0
     nowiki_num = 0
     data = '\n' + data + '\n'
     data = '\n' + data + '\n'
-    include_name = include_num + '_' if include_num else ''
+    include_name = (include_num + '_') if include_num else ''
+    now_time = tool.get_time().split()[0]
     plus_data = ''
     plus_data = ''
 
 
     backlink = []
     backlink = []
     end_data = {}
     end_data = {}
 
 
-    data = re.sub(r'@([^=@]+)=(?P<in>[^=@]+)@', '\g<in>', data)
+    data = re.sub(r'@((?:(?!(?:=|{{{|}}}|\[\[|\]\]|@)).)+)=(?P<in>(?:(?!(?:=|{{{|}}}|\[\[|\]\]|@)).)+)@', '\g<in>', data)
     data = re.sub(r'<math>(?P<in>(?:(?!<\/math>).)+)<\/math>', '[math(\g<in>)]', data)
     data = re.sub(r'<math>(?P<in>(?:(?!<\/math>).)+)<\/math>', '[math(\g<in>)]', data)
 
 
     data = html.escape(data)
     data = html.escape(data)
     data = data.replace('\r\n', '\n')
     data = data.replace('\r\n', '\n')
 
 
+    # 테이블 앞에 공백 있는 경우 처리 필요
+    # 테이블 col 옵션 적용시 셀 병합 고려 필요
+    data = re.sub(r'\n +\|\|', '\n||', data)
+
     math_re = re.compile(r'\[math\(((?:(?!\)\]).)+)\)\]', re.I)
     math_re = re.compile(r'\[math\(((?:(?!\)\]).)+)\)\]', re.I)
     while 1:
     while 1:
         math = math_re.search(data)
         math = math_re.search(data)
@@ -607,48 +612,51 @@ def namumark(conn, data, title, include_num):
             break
             break
 
 
     include_re = re.compile(r'\[include\(((?:(?!\)\]).)+)\)\]', re.I)
     include_re = re.compile(r'\[include\(((?:(?!\)\]).)+)\)\]', re.I)
-    i = 0
-    while 1:
-        i += 1
-
-        include = include_re.search(data)
-        if include:
-            include = include.group(1)
-
-            include_data = re.search(r'^((?:(?!,).)+)', include)
-            if include_data:
-                include_data = include_data.group(1)
-            else:
-                include_data = 'Test'
+    if include_name == '':
+        i = 0
+        while 1:
+            i += 1
+
+            include = include_re.search(data)
+            if include:
+                include = include.group(1)
+
+                include_data = re.search(r'^((?:(?!,).)+)', include)
+                if include_data:
+                    include_data = include_data.group(1)
+                else:
+                    include_data = 'Test'
 
 
-            include_link = include_data
-            backlink += [[title, include_link, 'include']]
+                include_link = include_data
+                backlink += [[title, include_link, 'include']]
 
 
-            data = include_re.sub('' + \
-                '<a id="' + include_name + 'include_link" class="include_' + str(i) + '" href="/w/' + tool.url_pas(include_link) + '">(' + include_link + ')</a>' + \
-                '<div id="' + include_name + 'include_' + str(i) + '"></div>' + \
-            '', data, 1)
+                data = include_re.sub('' + \
+                    '<a id="' + include_name + 'include_link" class="include_' + str(i) + '" href="/w/' + tool.url_pas(include_link) + '">(' + include_link + ')</a>' + \
+                    '<div id="' + include_name + 'include_' + str(i) + '"></div>' + \
+                '', data, 1)
 
 
-            include_plus_data = []
-            while 1:
-                include_plus = re.search(r', ?((?:(?!=).)+)=((?:(?!,).)+)', include)
-                if include_plus:
-                    include_plus = include_plus.groups()
+                include_plus_data = []
+                while 1:
+                    include_plus = re.search(r', ?((?:(?!=).)+)=((?:(?!,).)+)', include)
+                    if include_plus:
+                        include_plus = include_plus.groups()
 
 
-                    include_data_set = include_plus[1]
-                    find_data = re.findall(r'<span id="(nowiki_[0-9]+)">', include_data_set)
-                    for j in find_data:
-                        include_data_set = include_data_set.replace('<span id="' + j + '"></span>', end_data[j])
+                        include_data_set = include_plus[1]
+                        find_data = re.findall(r'<span id="((?:include_(?:[0-9]+)_)?(?:nowiki_[0-9]+))">', include_data_set)
+                        for j in find_data:
+                            include_data_set = include_data_set.replace('<span id="' + j + '"></span>', end_data[j])
 
 
-                    include_plus_data += [[include_plus[0], include_data_set]]
+                        include_plus_data += [[include_plus[0], include_data_set]]
 
 
-                    include = re.sub(r', ?((?:(?!=).)+)=((?:(?!,).)+)', '', include, 1)
-                else:
-                    break
+                        include = re.sub(r', ?((?:(?!=).)+)=((?:(?!,).)+)', '', include, 1)
+                    else:
+                        break
 
 
-            plus_data += 'load_include("' + include_link + '", "' + include_name + 'include_' + str(i) + '", ' + str(include_plus_data) + ');\n'
-        else:
-            break
+                plus_data += 'load_include("' + include_link + '", "' + include_name + 'include_' + str(i) + '", ' + str(include_plus_data) + ');\n'
+            else:
+                break
+    else:
+        data = include_re.sub('', data)
 
 
     data = data.replace('&amp;', '&')
     data = data.replace('&amp;', '&')
     data = re.sub(r'\n##[^\n]+', '', data)
     data = re.sub(r'\n##[^\n]+', '', data)
@@ -685,14 +693,15 @@ def namumark(conn, data, title, include_num):
         other_link = return_link[1]
         other_link = return_link[1]
 
 
         backlink += [[title, main_link, 'redirect']]
         backlink += [[title, main_link, 'redirect']]
-
+        
         plus_data += '' + \
         plus_data += '' + \
             'var get_link = window.location.search.match(/(?:\?|&)from=([^&]+)/);\n' + \
             'var get_link = window.location.search.match(/(?:\?|&)from=([^&]+)/);\n' + \
-            'if(!get_link) {\n' + \
-                'window.location.href = "/w/' + tool.url_pas(main_link) + other_link + '?from=' + tool.url_pas(title) + '";\n' + \
+            'var get_link_2 = window.location.pathname.match(/^\/w\//);' + \
+            'if(!get_link && get_link_2) {\n' + \
+                'window.location.href = "/w/' + tool.url_pas(main_link) + '?from=' + tool.url_pas(title) + other_link + '";\n' + \
             '}\n' + \
             '}\n' + \
         ''
         ''
-        data = redirect_re.sub('', data, 1)
+        data = redirect_re.sub('\nredirect to ' + html.escape(main_link) + other_link, data, 1)
 
 
     no_toc_re = re.compile(r'\[(?:목차|toc)\((?:no)\)\]\n', re.I)
     no_toc_re = re.compile(r'\[(?:목차|toc)\((?:no)\)\]\n', re.I)
     toc_re = re.compile(r'\[(?:목차|toc)\]', re.I)
     toc_re = re.compile(r'\[(?:목차|toc)\]', re.I)
@@ -850,7 +859,7 @@ def namumark(conn, data, title, include_num):
             data = macro_re.sub(ruby_data, data, 1)
             data = macro_re.sub(ruby_data, data, 1)
         elif macro_name == 'age' or macro_name == 'dday':
         elif macro_name == 'age' or macro_name == 'dday':
             try:
             try:
-                old = datetime.datetime.strptime(time, '%Y-%m-%d')
+                old = datetime.datetime.strptime(now_time, '%Y-%m-%d')
                 will = datetime.datetime.strptime(i[1], '%Y-%m-%d')
                 will = datetime.datetime.strptime(i[1], '%Y-%m-%d')
 
 
                 e_data = old - will
                 e_data = old - will
@@ -901,7 +910,7 @@ def namumark(conn, data, title, include_num):
             for i in sub_li:
             for i in sub_li:
                 li_end_data += '<li style="margin-left: ' + str(20 if len(i[0]) == 0 else (len(i[0]) * 20)) + 'px;">' + i[1] + '</li>'
                 li_end_data += '<li style="margin-left: ' + str(20 if len(i[0]) == 0 else (len(i[0]) * 20)) + 'px;">' + i[1] + '</li>'
 
 
-            data = li_re.sub('\n<ul>' + li_end_data + '</ul>\n', data, 1)
+            data = li_re.sub('\n\n<ul>' + li_end_data + '</ul>\n', data, 1)
         else:
         else:
             break
             break
 
 
@@ -1017,25 +1026,26 @@ def namumark(conn, data, title, include_num):
                     1
                     1
                 )
                 )
             elif category_re.search(main_link):
             elif category_re.search(main_link):
-                if category == '':
-                    category += '<div id="cate_all"><div id="cate">Category : '
-
-                main_link = category_re.sub('category:', main_link)
-                link_id = ''
-
-                curs.execute(tool.db_change("select title from data where title = ?"), [main_link])
-                if re.search(r'#blur', main_link):
-                    link_id = ' hidden_link'
-                    main_link = main_link.replace('#blur', '')
-                    see_link = see_link.replace('#blur', '')
-
-                backlink += [[title, main_link, 'cat']]
-                category += '' + \
-                    '<a class="' + include_name + 'link_finder' + link_id + '" ' + \
-                        'href="/w/' + tool.url_pas(main_link) + '">' + \
-                        category_re.sub('', see_link) + \
-                    '</a> | ' + \
-                ''
+                if include_name == '':
+                    if category == '':
+                        category += '<div id="cate_all"><div id="cate">Category : '
+
+                    main_link = category_re.sub('category:', main_link)
+                    link_id = ''
+
+                    curs.execute(tool.db_change("select title from data where title = ?"), [main_link])
+                    if re.search(r'#blur', main_link):
+                        link_id = ' hidden_link'
+                        main_link = main_link.replace('#blur', '')
+                        see_link = see_link.replace('#blur', '')
+
+                    backlink += [[title, main_link, 'cat']]
+                    category += '' + \
+                        '<a class="' + include_name + 'link_finder' + link_id + '" ' + \
+                            'href="/w/' + tool.url_pas(main_link) + '">' + \
+                            category_re.sub('', see_link) + \
+                        '</a> | ' + \
+                    ''
 
 
                 data = link_re.sub('', data, 1)
                 data = link_re.sub('', data, 1)
             elif re.search(r'^inter:((?:(?!:).)+):', main_link):
             elif re.search(r'^inter:((?:(?!:).)+):', main_link):
@@ -1163,7 +1173,7 @@ def namumark(conn, data, title, include_num):
         plus_data += 'page_count();\n'
         plus_data += 'page_count();\n'
         data = re.sub(r'\[pagecount\]', '<span class="all_page_count"></span>', data, flags = re.I)
         data = re.sub(r'\[pagecount\]', '<span class="all_page_count"></span>', data, flags = re.I)
 
 
-    data = re.sub(r'\[date\]', tool.get_time().split()[0], data, flags = re.I)
+    data = re.sub(r'\[date\]', now_time, data, flags = re.I)
     data = re.sub(r'\[clearfix\]', '<div style="clear:both"></div>', data, flags = re.I)
     data = re.sub(r'\[clearfix\]', '<div style="clear:both"></div>', data, flags = re.I)
     data = re.sub(r'\[br\]', '<br>', data, flags = re.I)
     data = re.sub(r'\[br\]', '<br>', data, flags = re.I)
 
 

+ 2 - 6
version.json

@@ -1,11 +1,7 @@
 {
 {
     "beta" : {
     "beta" : {
-        "r_ver" : "v3.2.0-beta-24 (v3.2.0-dev-202008013-01)",
-        "c_ver" : "3202200",
-        "s_ver" : "9"
-    }, "stable" : {
-        "r_ver" : "v3.2.0-stable-11",
-        "c_ver" : "3200900",
+        "r_ver" : "v3.2.0-beta-25 (v3.2.0-dev-202008016-01)",
+        "c_ver" : "3202500",
         "s_ver" : "9"
         "s_ver" : "9"
     }
     }
 }
 }