Explorar o código

버그 수정 파서 수정

2DU %!s(int64=8) %!d(string=hai) anos
pai
achega
35795de153
Modificáronse 2 ficheiros con 99 adicións e 112 borrados
  1. 32 36
      app.py
  2. 67 76
      mark.py

+ 32 - 36
app.py

@@ -221,7 +221,7 @@ def update(num = 1):
                 html_minify(
                     template('index', 
                         imp = ['업데이트 목록', wiki_set(1), wiki_set(3), login_check(), custom_css(), custom_js(), 0, 0],
-                        data = '<li><a href="/update/2">2.2.1</a></li>',
+                        data = '<ul><li><a href="/update/2">2.2.1</a></li></ul>',
                         menu = [['manager', '관리자']]
                     )
                 )
@@ -239,7 +239,7 @@ def update(num = 1):
 
 @route('/not_close_topic')
 def not_close_topic():
-    div = ''
+    div = '<ul>'
     i = 1
 
     curs.execute('select title, sub from rd order by date desc')
@@ -250,6 +250,8 @@ def not_close_topic():
         if(not is_close):
             div += '<li>' + str(i) + '. <a href="/topic/' + url_pas(data[0]) + '/sub/' + url_pas(data[1]) + '">' + data[0] + ' (' + data[1] + ')</a></li>'
             i += 1
+            
+    div += '</ul>'
 
     return(
         html_minify(
@@ -270,7 +272,7 @@ def static(name = None):
 
 @route('/acl_list')
 def acl_list():
-    div = ''
+    div = '<ul>'
     i = 0
 
     curs.execute("select title, acl from data where acl = 'admin' or acl = 'user' order by acl desc")
@@ -284,6 +286,8 @@ def acl_list():
         div += '<li>' + str(i + 1) + '. <a href="/w/' + url_pas(data[0]) + '">' + data[0] + '</a> (' + acl + ')</li>'
         
         i += 1
+        
+    div += '</ul>'
     
     return(
         html_minify(
@@ -297,7 +301,7 @@ def acl_list():
     
 @route('/list_acl')
 def list_acl():
-    div = ''
+    div = '<ul>'
     i = 0
 
     curs.execute("select name, acl from alist order by name desc")
@@ -322,8 +326,7 @@ def list_acl():
         
         i += 1
     else:        
-        div +=  '<br> \
-                <a href="/manager/8">(생성)</a>'
+        div += '</ul><br><a href="/manager/8">(생성)</a>'
 
     return(
         html_minify(
@@ -369,7 +372,7 @@ def admin_plus(name = None):
             curs.execute('select acl from alist where name = ?', [name])
             test = curs.fetchall()
             
-            data = ''
+            data = '<ul>'
             exist_list = ['', '', '', '', '', '', '']
 
             for go in test:
@@ -394,7 +397,7 @@ def admin_plus(name = None):
             data += '<li><input type="checkbox" name="check" ' + exist_list[3] + '> 사용자 검사</li>'
             data += '<li><input type="checkbox" name="acl" ' + exist_list[4] + '> 문서 ACL</li>'
             data += '<li><input type="checkbox" name="hidel" ' + exist_list[5] + '> 역사 숨김</li>'
-            data += '<li><input type="checkbox" name="owner" ' + exist_list[6] + '> 소유자</li>'
+            data += '<li><input type="checkbox" name="owner" ' + exist_list[6] + '> 소유자</li></ul>'
 
             return(
                 html_minify(
@@ -416,7 +419,7 @@ def admin_plus(name = None):
 @route('/admin_list')
 def admin_list():
     i = 1
-    div = ''
+    div = '<ul>'
     
     curs.execute("select id, acl from user where not acl = 'user'")
     user_data = curs.fetchall()
@@ -427,6 +430,8 @@ def admin_list():
         div += '<li>' + str(i) + '. ' + name + '</li>'
         
         i += 1
+        
+    div += '</ul>'
                 
     return(
         html_minify(
@@ -581,7 +586,7 @@ def user_log(num = 1):
         i = num * 50
         
     j = i - 50
-    list_data = ''
+    list_data = '<ul>'
     ydmin = admin_check(1, None)
     
     curs.execute("select id from user limit ?, ?", [str(j), str(i)])
@@ -603,8 +608,7 @@ def user_log(num = 1):
         
         j += 1
     else:
-        list_data +=    '<br> \
-                        <a href="/user_log/n/' + str(num - 1) + '">(이전)</a> <a href="/user_log/n/' + str(num + 1) + '">(이후)</a>'
+        list_data += '</ul><br><a href="/user_log/n/' + str(num - 1) + '">(이전)</a> <a href="/user_log/n/' + str(num + 1) + '">(이후)</a>'
 
     return(
         html_minify(
@@ -625,7 +629,7 @@ def user_log(num = 1):
         i = num * 50
         
     j = i - 50
-    list_data = ''
+    list_data = '<ul>'
     
     curs.execute("select who, what, time from re_admin order by time desc limit ?, ?", [str(j), str(i)])
     get_list = curs.fetchall()
@@ -636,7 +640,7 @@ def user_log(num = 1):
         
         j += 1
     else:
-        list_data +=    '<br> \
+        list_data +=    '</ul><br> \
                         <span>주의 : 권한 사용 안하고 열람만 해도 기록되는 경우도 있습니다.</span> \
                         <br> \
                         <br> \
@@ -661,7 +665,7 @@ def give_log(num = 1):
         i = num * 50
         
     j = i - 50
-    list_data = ''
+    list_data = '<ul>'
     back = ''
 
     curs.execute("select name, acl from alist order by name asc limit ?, ?", [str(j), str(i)])
@@ -673,7 +677,7 @@ def give_log(num = 1):
 
         list_data += '<li>' + str(j) + '. ' + data[0] + ' (' + data[1] + ')</li>'
     else:
-        list_data += '<br><a href="/give_log/n/' + str(num - 1) + '">(이전)</a> <a href="/give_log/n/' + str(num + 1) + '">(이후)</a>'
+        list_data += '</ul><br><a href="/give_log/n/' + str(num - 1) + '">(이전)</a> <a href="/give_log/n/' + str(num + 1) + '">(이후)</a>'
 
     return(
         html_minify(
@@ -731,7 +735,7 @@ def xref(name = None, num = 1):
         v = num * 50
         
     i = v - 50
-    div = ''
+    div = '<ul>'
     
     curs.execute("delete from back where title = ? and link = ''", [name])
     conn.commit()
@@ -744,10 +748,9 @@ def xref(name = None, num = 1):
         if(data[1]):
             div += ' (' + data[1] + ')'
         
-        div += '</li>'
+        div += '</li></ul>'
     else:        
-        div += '<br> \
-                <a href="/xref/' + url_pas(name) + '/n/' + str(num - 1) + '">(이전)</a> <a href="/xref/' + url_pas(name) + '/n/' + str(num + 1) + '">(이후)</a>'
+        div += '<br><a href="/xref/' + url_pas(name) + '/n/' + str(num - 1) + '">(이전)</a> <a href="/xref/' + url_pas(name) + '/n/' + str(num + 1) + '">(이후)</a>'
     
     return(
         html_minify(
@@ -1021,7 +1024,7 @@ def deep_search(name = None, num = 1):
 
     i = v - 50
 
-    div = ''
+    div = '<ul>'
     div_plus = ''
     end = ''
 
@@ -1034,13 +1037,9 @@ def deep_search(name = None, num = 1):
     curs.execute("select title from data where title = ?", [name])
     exist = curs.fetchall()
     if(exist):
-        div =   '<li>문서로 <a href="/w/' + url_pas(name) + '">바로가기</a></li> \
-                <br> \
-                <br>'
+        div = '<ul><li>문서로 <a href="/w/' + url_pas(name) + '">바로가기</a></li><br><br>'
     else:
-        div =   '<li>문서가 없습니다. <a class="not_thing" href="/w/' + url_pas(name) + '">바로가기</a></li> \
-                <br> \
-                <br>'
+        div = '<ul><li>문서가 없습니다. <a class="not_thing" href="/w/' + url_pas(name) + '">바로가기</a></li><br><br>'
 
     if(title_list):
         no = 0
@@ -1078,9 +1077,7 @@ def deep_search(name = None, num = 1):
 
     div += div_plus + end
 
-    div += '<br> \
-            <br> \
-            <a href="/search/' + url_pas(name) + '/n/' + str(num - 1) + '">(이전)</a> <a href="/search/' + url_pas(name) + '/n/' + str(num + 1) + '">(이후)</a>'
+    div += '</ul><br><a href="/search/' + url_pas(name) + '/n/' + str(num - 1) + '">(이전)</a> <a href="/search/' + url_pas(name) + '/n/' + str(num + 1) + '">(이후)</a>'
     
     return(
         html_minify(
@@ -1835,9 +1832,7 @@ def title_index(num = 1000, page = 1):
     else:
         i = [1, 0, 0, 0, 0, 0]
 
-    data = '<a href="/title_index/0/1">(전체)</a> <a href="/title_index/500/1">(500)</a> <a href="/title_index/5000/1">(5000개)</a> <a href="/title_index/10000/1">(10000개)</a> <a href="/title_index/50000/1">(50000개)</a> \
-            <br> \
-            <br>'
+    data = '<ul><a href="/title_index/0/1">(전체)</a> <a href="/title_index/500/1">(500)</a> <a href="/title_index/5000/1">(5000개)</a> <a href="/title_index/10000/1">(10000개)</a> <a href="/title_index/50000/1">(50000개)</a><br><br>'
 
     if(num == 0):
         curs.execute("select title from data order by title asc")
@@ -1873,8 +1868,7 @@ def title_index(num = 1000, page = 1):
                     <li>파일 문서는 총 ' + str(i[4]) + '개의 문서가 있습니다.</li> \
                     <li>나머지 문서는 총 ' + str(i[5]) + '개의 문서가 있습니다.</li>'
     else:
-        data += '<br> \
-                <a href="/title_index/' + str(num) + '/' + str(page - 1) + '">(이전)</a> <a href="/title_index/' + str(num) + '/' + str(page + 1) + '">(이후)</a>'
+        data += '</ul><br><a href="/title_index/' + str(num) + '/' + str(page - 1) + '">(이전)</a> <a href="/title_index/' + str(num) + '/' + str(page + 1) + '">(이후)</a>'
     
     return(
         html_minify(
@@ -2828,12 +2822,14 @@ def down(name = None):
     curs.execute("select title from data where title like ?", ['%' + name + '/%'])
     under = curs.fetchall()
     
-    div = ''
+    div = '<ul>'
     i = 0
 
     for data in under:
         div += '<li>' + str(i + 1) + '. <a href="/w/' + url_pas(data[0]) + '">' + data[0] + '</a></li>'
         i += 1
+        
+    div += '</ul>'
     
     return(
         html_minify(

+ 67 - 76
mark.py

@@ -492,7 +492,7 @@ def namumark(title, data, num, in_c):
         else:
             break
 
-    data = re.sub("##\s?([^\n]*)\r\n", "", data)
+    data = re.sub("\r\n##\s?([^\n]*)\r\n", "\r\n", data)
     
     data = re.sub("\[anchor\((?P<in>[^\[\]]*)\)\]", '<span id="\g<in>"></span>', data)
     data = savemark(data)
@@ -606,40 +606,6 @@ def namumark(title, data, num, in_c):
             else:
                 data = re.sub('\[\[wiki:([^|\]]+)(?:\|([^\]]+))?\]\]', '<a id="inside" href="/' + wiki[0] + '">' + wiki[0] + '</a>', data, 1)
     
-    while(1):
-        m = re.search("\[\[(파일|외부):((?:(?!\]\]|\|).)*)(?:\|((?:(?!\]\]).)*))?\]\]", data)
-        if(m):
-            img_d = m.groups()
-
-            if(img_d):
-                if(img_d[0] == '파일' and not re.search("^파일:([^\n]*)", title)):
-                    backlink_plus(title, '파일:' + img_d[1], 'file', num)
-
-                width = ''
-                height = ''
-                if(img_d[2]):
-                    width_r = re.search("width=([^ \n&]*)", img_d[2])
-                    height_r = re.search("height=([^ \n&]*)", img_d[2])
-
-                    if(width_r):
-                        width_d = width_r.groups()
-                        width = width_d[0]
-
-                    if(height_r):
-                        height_d = height_r.groups()
-                        height = height_d[0]
-
-                if(img_d[0] == '파일'):
-                    img_e = re.search('^(.+)(\.(?:.+))$', img_d[1]).groups()
-                    
-                    data = re.sub("\[\[(파일|외부):((?:(?!\]\]|\|).)*)(?:\|((?:(?!\]\]).)*))?\]\]", '<a href="/w/파일:' + img_d[1] + '"><img src="/image/' + sha224(img_e[0]) + img_e[1] + '" width="' + width + '" height="' + height + '"></a>', data, 1)
-                else:
-                    data = re.sub("\[\[(파일|외부):((?:(?!\]\]|\|).)*)(?:\|((?:(?!\]\]).)*))?\]\]", '<img src="' + img_d[1] + '" width="' + width + '" height="' + height + '">', data, 1)
-            else:
-                break            
-        else:
-            break
-    
     data = re.sub("\[br\]",'<br>', data)
     
     while(1):
@@ -700,54 +666,79 @@ def namumark(title, data, num, in_c):
 
     data = re.sub('\[\[(?P<in>\/[^\]|]*)(?P<out>\|(?:[^\]]*))?\]\]', '[[' + title + '\g<in>\g<out>]]', data)
                 
-    while(1):
-        m = re.search("\[\[(((?!\]\]).)*)\]\]", data)
-        if(m):
-            result = m.groups()
-            rep = result[0]
-            rep = re.sub("\\\#", "<sharp>", rep)
-            a = re.search("^((?:(?!\|).)*)(?:\|(.*))?$", rep)
-            
-            results = a.groups()
+    link = re.compile('\[\[((?:(?!\]\]|\|).)*)(?:\|((?:(?!\]\]).)*))?\]\]')
+    d_da = link.findall(data)
+    for d in d_da:
+        if(re.search('^(?:파일|외부):', d[0])):
+            width = ''
+            height = ''
+            align = ''
             
-            aa = re.search("^([^#]*)(#(?:.*))?$", results[0])
-            if(results[1]):
-                g = re.sub("<sharp>", "#", results[1])
+            try:        
+                w_d = re.search('width=([0-9]+(?:[a-z%]+)?)', d[1])
+                if(w_d):
+                    width = 'width: ' + w_d.groups()[0] + ';'
+                
+                h_d = re.search('height=([0-9]+(?:[a-z%]+)?)', d[1])
+                if(h_d):
+                    height = 'height: ' + h_d.groups()[0] + ';'
+                    
+                a_d = re.search('align=(left|center|right)', d[1])
+                if(a_d):
+                    align = 'align: ' + a_d.groups()[0] + ';'
+            except:
+                pass
+                
+            f_d = re.search('^파일:([^.]+)\.(.+)$', d[0])
+            if(f_d):
+                if(not re.search("^파일:([^\n]*)", title)):
+                    backlink_plus(title, d[0], 'file', num)
+                    
+                img = '<img src="/image/' + sha224(f_d.groups()[0]) + '.' + f_d.groups()[1] + '" style="' + width + height + align + '">'
+                data = link.sub(img, data, 1)
             else:
-                g = re.sub("<sharp>", "#", results[0])
-            
-            results = aa.groups()
+                img = '<img src="' + d[0] + '" style="' + width + height + align + '">'
+                data = link.sub(img, data, 1)
+                                
+        elif(re.search('^https?:\/\/', d[0])):
+            view = d[0]
+            try:
+                if(re.search('(.+)', d[1])):
+                    view = d[1]
+            except:
+                pass
             
-            if(not results[1]):
-                sharp = ''
+            data = link.sub('<a class="out_link" rel="nofollow" href="' + d[0] + '">' + view + '</a>', data, 1)
+        else:
+            view = d[0].replace('\\', '')
+            try:
+                if(re.search('(.+)', d[1])):
+                    view = d[1]
+            except:
+                pass        
+                
+            sh = ''
+            s_d = re.search('#([^#]+)$', d[0])
+            if(s_d):
+                href = re.sub('#([^#]+)$', '', d[0])
+                sh = '#' + s_d.groups()[0]
             else:
-                sharp = results[1]
+                href = d[0]
                 
-            b = re.search("^http(?:s)?:\/\/", results[0])
-            if(b):
-                data = re.sub('\[\[(((?!\]\]).)*)\]\]', '<a class="out_link" rel="nofollow" target="_blank" href="' + results[0] + sharp + '">' + g + '</a>', data, 1)
+            if(d[0] == title):
+                data = link.sub('<b>' + view + '</b>', data, 1)
+            elif(re.search('^#', d[0])):
+                data = link.sub('<a href="' + url_pas(href.replace('\\', '')) + sh + '">' + view + '</a>', data, 1)
             else:
-                if(results[0] == title):
-                    data = re.sub('\[\[(((?!\]\]).)*)\]\]', '<b>' + g + '</b>', data, 1)
+                backlink_plus(title, href.replace('\\', ''), '', num)
+                
+                curs.execute("select title from data where title = ?", [href.replace('\\', '')])
+                if(not curs.fetchall()):
+                    no = 'class="not_thing"'
                 else:
-                    nosharp = re.sub("<sharp>", "#", results[0])
-                    
-                    curs.execute("select title from data where title = ?", [nosharp])
-                    y = curs.fetchall()
-                    if(y):
-                        clas = ''
-                    else:
-                        clas = 'not_thing'
-
-                    if(re.search('<', nosharp)):
-                        nosharp = ''
-                        sharp = ''
-                    
-                    data = re.sub('\[\[(((?!\]\]).)*)\]\]', '<a title="' + re.sub('#', '\#', nosharp) + sharp + '" class="' + clas + '" href="/w/' + url_pas(nosharp) + sharp + '">' + re.sub('(?:<a ([^>]*)>|<\/a>)', '', g) + '</a>', data, 1)
-
-                    backlink_plus(title, results[0], '', num)
-        else:
-            break
+                    no = ''
+                
+                data = link.sub('<a ' + no + ' href="/w/' + url_pas(href.replace('\\', '')) + sh + '">' + view + '</a>', data, 1)
             
     while(1):
         m = re.search("((?:(?:( +)\*\s(?:[^\n]*))\n?)+)", data)