소스 검색

샵 관련 버그 수정

Surplus_Up (2DU) 6 년 전
부모
커밋
73157d840f
6개의 변경된 파일29개의 추가작업 그리고 7개의 파일을 삭제
  1. 1 1
      route/api_search.py
  2. 8 1
      route/tool/set_mark/namu.py
  3. 3 1
      route/tool/set_mark/tool.py
  4. 14 1
      route/view_xref.py
  5. 1 1
      version.json
  6. 2 2
      views/marisa/js/search.js

+ 1 - 1
route/api_search.py

@@ -3,7 +3,7 @@ from .tool.func import *
 def api_search_2(conn, name):
     curs = conn.cursor()
 
-    num = int(number_check(flask.request.args.get('num', '1')))
+    num = int(number_check(flask.request.args.get('num', '10')))
     if not num > 0:
         num = 1
 

+ 8 - 1
route/tool/set_mark/namu.py

@@ -533,10 +533,14 @@ def namu(conn, data, title, main_num, include_num):
     redirect = redirect_re.search(data)
     if redirect:
         redirect = redirect.groups()[0]
+        print(redirect)
         
         return_link = tool.link_fix(redirect)
         main_link = return_link[0]
         other_link = return_link[1]
+
+        print(main_link)
+        print(other_link)
         
         backlink += [[title, main_link + other_link, 'redirect']]
         
@@ -1103,7 +1107,10 @@ def namu(conn, data, title, main_num, include_num):
                         break
 
                     if end_data[j][0] == find_data:
-                        backlink[i][1] = backlink[i][1].replace('<span id="' + end_data[j][0] + '"></span>', end_data[j][1])
+                        if backlink[i][2] != 'redirect':
+                            backlink[i][1] = backlink[i][1].replace('<span id="' + end_data[j][0] + '"></span>', end_data[j][1])
+                        else:
+                            backlink[i][1] = backlink[i][1].replace('<span id="' + end_data[j][0] + '"></span>', '\\' + end_data[j][1])
 
                     j += 1
 

+ 3 - 1
route/tool/set_mark/tool.py

@@ -38,13 +38,15 @@ def link_fix(main_link):
     main_link = re.sub('^파일:', 'file:', main_link)
     main_link = re.sub('^분류:', 'category:', main_link)
 
-    other_link = re.search('(#.+)$', main_link)
+    other_link = re.search('[^\\\\](#.+)$', main_link)
     if other_link:
         other_link = other_link.groups()[0]
 
         main_link = re.sub('(#.+)$', '', main_link)
     else:
         other_link = ''
+
+    main_link = re.sub('\\\\#', '%23', main_link)
         
     return [main_link, other_link]
 

+ 14 - 1
route/view_xref.py

@@ -13,8 +13,21 @@ def view_xref_2(conn, name):
         sql_num = 0
         
     div = '<ul>'
+
+    if re.search('#', name):
+        name = re.sub('#', '\\\\#', name)
+
+    print(name + '#s-%')
     
-    curs.execute("select link, type from back where title = ? and not type = 'cat' and not type = 'no' order by link asc limit ?, '50'", [name, str(sql_num)])
+    curs.execute("" + \
+        "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-%',
+        str(sql_num)
+    ])
     data_list = curs.fetchall()
     for data in data_list:
         div += '<li><a href="/w/' + url_pas(data[0]) + '">' + data[0] + '</a>'

+ 1 - 1
version.json

@@ -1,6 +1,6 @@
 {
     "master" : {
-        "r_ver" : "v3.1.4-master-07",
+        "r_ver" : "v3.1.4-master-08",
         "c_ver" : "400004",
         "s_ver" : "3"
     }, "stable" : {

+ 2 - 2
views/marisa/js/search.js

@@ -3,7 +3,7 @@ function search_do() {
         var data = document.getElementById("search_input").value;
         if(before !== data && data !== '') {
             before = data;
-            var url = "/api/search/" + encodeURI(data) + "?num=10";
+            var url = "/api/search/" + encodeURI(data);
         
             var xhr = new XMLHttpRequest();
             xhr.open("GET", url, true);
@@ -18,7 +18,7 @@ function search_do() {
 
                     if(this.responseText !== "{}\n") {
                         for(key in get_data) {
-                            document.getElementById("pre_search").innerHTML += '<a href="/w/' + encodeURI(get_data[key][0]) + '">' + get_data[key][0] + '</a><br>';
+                            document.getElementById("pre_search").innerHTML += '<a href="/w/' + encodeURI(get_data[key][0]).replace('#', '%23') + '">' + get_data[key][0] + '</a><br>';
                         }
                     } else {
                         document.getElementById("pre_search").style.display = 'none';