Selaa lähdekoodia

일부 역링크 구조 변경

Surplus_Up (2DU) 6 vuotta sitten
vanhempi
sitoutus
1e50fd4fad

+ 4 - 0
app.py

@@ -470,6 +470,10 @@ def edit(name = 'Test'):
 def edit_req(name = 'Test'):
 def edit_req(name = 'Test'):
     return edit_req_2(conn, name)
     return edit_req_2(conn, name)
 
 
+@app.route('/backlink_reset/<everything:name>')
+def edit_backlink_reset(name = 'Test'):
+    return edit_backlink_reset_2(conn, name)
+
 @app.route('/delete/<everything:name>', methods=['POST', 'GET'])
 @app.route('/delete/<everything:name>', methods=['POST', 'GET'])
 def edit_delete(name = None):
 def edit_delete(name = None):
     return edit_delete_2(conn, name, app_var)
     return edit_delete_2(conn, name, app_var)

+ 2 - 0
language/en-US.json

@@ -202,6 +202,8 @@
         "topic_acl" : "Discussion ACL",
         "topic_acl" : "Discussion ACL",
         "delete_admin_group": "Delete admin group",
         "delete_admin_group": "Delete admin group",
         "main_skin_set" : "Main skin setting(s)",
         "main_skin_set" : "Main skin setting(s)",
+        "reset_backlink" : "Reset backlink",
+        "link_in_this" : "Links in this document",
         "_comment_2.1_" : "Filter",
         "_comment_2.1_" : "Filter",
             "_comment_2.1.1_" : "List",
             "_comment_2.1.1_" : "List",
                 "interwiki_list" : "Interwiki(s) list",
                 "interwiki_list" : "Interwiki(s) list",

+ 3 - 1
language/ko-KR.json

@@ -359,5 +359,7 @@
     "topic_acl" : "토론 ACL",
     "topic_acl" : "토론 ACL",
     "main_skin_set" : "기본 스킨 설정",
     "main_skin_set" : "기본 스킨 설정",
     "image_file_list" : "이미지 파일 목록",
     "image_file_list" : "이미지 파일 목록",
-    "many_upload_acl" : "다중 파일 업로드 ACL"
+    "many_upload_acl" : "다중 파일 업로드 ACL",
+    "reset_backlink" : "역링크 초기화",
+    "link_in_this" : "이 문서의 링크"
 }
 }

+ 18 - 0
route/edit_backlink_reset.py

@@ -0,0 +1,18 @@
+from .tool.func import *
+
+def edit_backlink_reset_2(conn, name):
+    curs = conn.cursor()
+
+    curs.execute(db_change("select data from data where title = ?"), [name])
+    old = curs.fetchall()
+    if old:
+        curs.execute(db_change("delete from back where link = ?"), [name])
+        curs.execute(db_change("delete from back where title = ? and type = 'no'"), [name])
+        
+        render_set(
+            title = name,
+            data = old[0][0],
+            num = 1
+        )
+
+    return redirect('/xref/' + url_pas(name))

+ 2 - 2
route/tool/func.py

@@ -204,7 +204,7 @@ def update(ver_num, set_data):
         with open('data/mysql.json', 'w') as f:
         with open('data/mysql.json', 'w') as f:
             f.write('{ "user" : "' + get_data_mysql['user'] + '", "password" : "' + get_data_mysql['password'] + '", "host" : "localhost" }')
             f.write('{ "user" : "' + get_data_mysql['user'] + '", "password" : "' + get_data_mysql['password'] + '", "host" : "localhost" }')
             
             
-    if ver_num < 3180200:
+    if ver_num < 3182000:
         curs.execute(db_change('delete from cache_data'))
         curs.execute(db_change('delete from cache_data'))
 
 
     conn.commit()
     conn.commit()
@@ -499,7 +499,7 @@ def other2(data):
         data += ['']
         data += ['']
 
 
     req_list = ''
     req_list = ''
-    main_css_ver = 30
+    main_css_ver = 31
 
 
     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:
     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")):
         for i_data in os.listdir(os.path.join("views", "main_css", "css")):

+ 20 - 5
route/tool/set_mark/namumark.py

@@ -447,7 +447,12 @@ def middle_parser(data, include_num):
 
 
             nowiki_num += 1
             nowiki_num += 1
             end_data['nowiki_' + str(nowiki_num)] = nowiki_data[0]
             end_data['nowiki_' + str(nowiki_num)] = nowiki_data[0]
-            plus_data += 'document.getElementById("nowiki_' + str(nowiki_num) + '").innerHTML = "' + nowiki_js(nowiki_data[0]) + '";\n'
+            plus_data += '' + \
+                'if(document.getElementById("nowiki_' + str(nowiki_num) + '")) { ' + \
+                    'document.getElementById("nowiki_' + str(nowiki_num) + '").innerHTML = "' + nowiki_js(nowiki_data[0]) + '"; ' + \
+                '}' + \
+                '\n' + \
+            ''
 
 
             data = re.sub(
             data = re.sub(
                 '<code>((?:(?:(?!<\/code>).)*\n*)*)<\/code>',
                 '<code>((?:(?:(?!<\/code>).)*\n*)*)<\/code>',
@@ -465,7 +470,12 @@ def middle_parser(data, include_num):
 
 
             nowiki_num += 1
             nowiki_num += 1
             end_data['nowiki_' + str(nowiki_num)] = syntax_data[1]
             end_data['nowiki_' + str(nowiki_num)] = syntax_data[1]
-            plus_data += 'document.getElementById("nowiki_' + str(nowiki_num) + '").innerHTML = "' + nowiki_js(syntax_data[1]) + '";\n'
+            plus_data += '' + \
+                'if(document.getElementById("nowiki_' + str(nowiki_num) + '")) { ' + \
+                    'document.getElementById("nowiki_' + str(nowiki_num) + '").innerHTML = "' + nowiki_js(syntax_data[1]) + '"; ' + \
+                '}' + \
+                '\n' + \
+            ''
 
 
             data = re.sub(
             data = re.sub(
                 '<code class="((?:(?!"|>|<).)+)">((?:\n*(?:(?:(?!<\/code>|<span id="syntax_).)+)\n*)+)<\/code>',
                 '<code class="((?:(?!"|>|<).)+)">((?:\n*(?:(?:(?!<\/code>|<span id="syntax_).)+)\n*)+)<\/code>',
@@ -549,7 +559,12 @@ def namumark(conn, data, title, include_num):
 
 
             nowiki_num += 1
             nowiki_num += 1
             end_data['nowiki_' + str(nowiki_num)] = one_nowiki[0]
             end_data['nowiki_' + str(nowiki_num)] = one_nowiki[0]
-            plus_data += 'document.getElementById("nowiki_' + str(nowiki_num) + '").innerHTML = "' + nowiki_js(one_nowiki[0]) + '";\n'
+            plus_data += '' + \
+                'if(document.getElementById("nowiki_' + str(nowiki_num) + '")) { ' + \
+                    'document.getElementById("nowiki_' + str(nowiki_num) + '").innerHTML = "' + nowiki_js(one_nowiki[0]) + '"; ' + \
+                '}' + \
+                '\n' + \
+            ''
 
 
             data = re.sub('(?:\\\\)(.)', '<span id="nowiki_' + str(nowiki_num) + '"></span>', data, 1)
             data = re.sub('(?:\\\\)(.)', '<span id="nowiki_' + str(nowiki_num) + '"></span>', data, 1)
         else:
         else:
@@ -641,13 +656,13 @@ def namumark(conn, data, title, include_num):
         main_link = html.unescape(return_link[0])
         main_link = html.unescape(return_link[0])
         other_link = return_link[1]
         other_link = return_link[1]
 
 
-        backlink += [[title, main_link + other_link, 'redirect']]
+        backlink += [[title, main_link, 'redirect']]
 
 
         data = redirect_re.sub(
         data = redirect_re.sub(
             '\n' + \
             '\n' + \
                 '<ul>' + \
                 '<ul>' + \
                     '<li>' + \
                     '<li>' + \
-                        '<a href="' + tool.url_pas(main_link) + other_link + '">' + main_link + other_link + '</a>' + \
+                        '<a id="go_redirect_link" href="/w/' + tool.url_pas(main_link) + other_link + '">' + main_link + other_link + '</a>' + \
                     '</li>' + \
                     '</li>' + \
                 '</ul>' + \
                 '</ul>' + \
             '\n',
             '\n',

+ 4 - 6
route/view_read.py

@@ -7,18 +7,14 @@ def view_read_2(conn, name):
     acl = 0
     acl = 0
     div = ''
     div = ''
     ip = ip_check()
     ip = ip_check()
+    run_redirect = ''
 
 
     num = flask.request.args.get('num', None)
     num = flask.request.args.get('num', None)
     if num:
     if num:
         num = int(number_check(num))
         num = int(number_check(num))
     else:
     else:
         if not flask.request.args.get('from', None):
         if not flask.request.args.get('from', None):
-            curs.execute(db_change("select title from back where link = ? and type = 'redirect'"), [name])
-            r_db = curs.fetchall()
-            if r_db:
-                r_data = link_fix(r_db[0][0])
-
-                return redirect('/w/' + url_pas(r_data[0]) + '?from=' + name + r_data[1])
+            run_redirect = '<script>not_from_exist();</script>'
 
 
     curs.execute(db_change("select sub from rd where title = ? and not stop = 'O' order by date desc"), [name])
     curs.execute(db_change("select sub from rd where title = ? and not stop = 'O' order by date desc"), [name])
     if curs.fetchall():
     if curs.fetchall():
@@ -232,6 +228,8 @@ def view_read_2(conn, name):
     else:
     else:
         watch_list = 0
         watch_list = 0
 
 
+    div += run_redirect
+
     return easy_minify(flask.render_template(skin_check(),
     return easy_minify(flask.render_template(skin_check(),
         imp = [flask.request.args.get('show', name), wiki_set(), custom(), other2([sub, r_date, watch_list])],
         imp = [flask.request.args.get('show', name), wiki_set(), custom(), other2([sub, r_date, watch_list])],
         data = div,
         data = div,

+ 27 - 15
route/view_xref.py

@@ -12,20 +12,32 @@ def view_xref_2(conn, name):
     else:
     else:
         sql_num = 0
         sql_num = 0
 
 
-    div = '<ul>'
-
-    if re.search('#', name):
-        name = re.sub('#', '\\\\#', name)
-
-    curs.execute(db_change("" + \
-        "select link, type from back " + \
-        "where (title = ? and not type = 'cat' and not type = 'no') or (title like ? and type = 'redirect')" + \
-        "order by link asc limit ?, 50" + \
-    ""), [
-        name,
-        name + '#s-%',
-        sql_num
-    ])
+    if flask.request.args.get('change', '1') == '1':
+        div = '<a href="?change=2">(' + load_lang('link_in_this') + ')</a><hr class="main_hr">'
+    else:
+        div = '<a href="?change=1">(' + load_lang('normal') + ')</a><hr class="main_hr">'
+
+    div += '<ul>'
+
+    if flask.request.args.get('change', '1') == '1':
+        curs.execute(db_change("" + \
+            "select link, type from back " + \
+            "where title = ? and not type = 'cat' and not type = 'no'" + \
+            "order by link asc limit ?, 50" + \
+        ""), [
+            name,
+            sql_num
+        ])
+    else:
+        curs.execute(db_change("" + \
+            "select title, type from back " + \
+            "where link = ? and not type = 'cat' and not type = 'no'" + \
+            "order by link asc limit ?, 50" + \
+        ""), [
+            name,
+            sql_num
+        ])
+
     data_list = curs.fetchall()
     data_list = curs.fetchall()
     for data in data_list:
     for data in data_list:
         div += '<li><a href="/w/' + url_pas(data[0]) + '">' + data[0] + '</a>'
         div += '<li><a href="/w/' + url_pas(data[0]) + '">' + data[0] + '</a>'
@@ -45,5 +57,5 @@ def view_xref_2(conn, name):
     return easy_minify(flask.render_template(skin_check(),
     return easy_minify(flask.render_template(skin_check(),
         imp = [name, wiki_set(), custom(), other2([' (' + load_lang('backlink') + ')', 0])],
         imp = [name, wiki_set(), custom(), other2([' (' + load_lang('backlink') + ')', 0])],
         data = div,
         data = div,
-        menu = [['w/' + url_pas(name), load_lang('return')]]
+        menu = [['w/' + url_pas(name), load_lang('return')], ['backlink_reset/' + url_pas(name), load_lang('reset_backlink')]]
     ))
     ))

+ 2 - 2
version.json

@@ -1,7 +1,7 @@
 {
 {
     "master" : {
     "master" : {
-        "r_ver" : "v3.1.8-master-19",
-        "c_ver" : "3180200",
+        "r_ver" : "v3.1.8-master-20",
+        "c_ver" : "3182000",
         "s_ver" : "8"
         "s_ver" : "8"
     }, "stable" : {
     }, "stable" : {
         "r_ver" : "v3.1.7-stable-04",
         "r_ver" : "v3.1.7-stable-04",

+ 8 - 0
views/main_css/js/load_namumark.js

@@ -96,4 +96,12 @@ function page_count() {
             }
             }
         }
         }
     }
     }
+}
+
+function not_from_exist() {
+    window.addEventListener('DOMContentLoaded', function() {
+        if(document.getElementById('go_redirect_link')) {
+            window.location.href = document.getElementById('go_redirect_link').href + '?from=' + location.pathname.replace(/^\/w\//, '');
+        }
+    });
 }
 }