Jelajahi Sumber

분류 구조 수정

ect (or 2du) 8 tahun lalu
induk
melakukan
37b3e9fad8
3 mengubah file dengan 25 tambahan dan 31 penghapusan
  1. 2 1
      app.py
  2. 3 2
      set_mark/include_pas.py
  3. 20 28
      set_mark/link.py

+ 2 - 1
app.py

@@ -2737,7 +2737,8 @@ def read_view(name = None):
                     curs.execute("select data from data where title = ?", [data[0]])
                     db_data = curs.fetchall()
                     if(db_data):
-                        if(re.search('\[\[' + name + ']]', mid_pas(db_data[0][0], 0, 1, 0, 0)[0])):
+                        cat_data = re.sub("\[\[(분류:(?:(?:(?!\]\]|\|).)+))(?!\|include)\]\]", "", mid_pas(db_data[0][0], 0, 1, 0, 0)[0])
+                        if(re.search('\[\[' + name + '|include]]', cat_data)):
                             div += ' * [[' + data[0] + ']]\r\n * [[wiki:xref/' + url_pas(data[0]) + '|' + data[0] + ']] (역링크)\r\n'
                         else:
                             div += ' * [[' + data[0] + ']]\r\n'

+ 3 - 2
set_mark/include_pas.py

@@ -21,13 +21,14 @@ def include_pas(conn, data, title, in_c, num, toc_y, fol_num):
         if(results[0] == title):
             data = include.sub("<b>" + results[0] + "</b>", data, 1)
         else:
+            backlink += [[title, results[0], 'include']]
+
             curs.execute("select data from data where title = ?", [results[0]])
             in_con = curs.fetchall()
-            
-            backlink += [[title, results[0], 'include']]
             if(in_con):                        
                 in_data = in_con[0][0]
                 in_data = include.sub("", in_data)
+                in_data = re.sub("\[\[(분류:(?:(?:(?!\]\]|\|).)+))(?!\|include)\]\]", "", in_data)
                 in_data = re.sub("\n", "\r\n", re.sub("\r\n", "\n", in_data))
                 in_data = html_pas.html_pas(in_data)
                 

+ 20 - 28
set_mark/link.py

@@ -11,43 +11,35 @@ def sha224(data):
 
 def link(conn, title, data, num, category, backlink):
     curs = conn.cursor()
-
     data = data.replace('&#92;', '\\')
     
-    m = re.findall("\[\[(분류:(?:(?:(?!\]\]).)*))\]\]", data)
+    m = re.findall("\[\[(분류:(?:(?:(?!\]\]|\|).)+))(?:\|((?:(?!\]\]).)+))?\]\]", data)
     for g in m:
-        if(title != g):
+        if(title != g[0]):
             if(num == 1):
-                backlink += [[title, g, 'cat']]
+                backlink += [[title, g[0], 'cat']]
                 
-            if(category == ''):
-                curs.execute("select title from data where title = ?", [g])
-                exists = curs.fetchall()
-                if(exists):
-                    red = ""
-                else:
-                    red = 'class="not_thing"'
-                    
-                category += '<a ' + red + ' href="/w/' + url_pas(g) + '">' + re.sub("분류:", "", g) + '</a>'
+            curs.execute("select title from data where title = ?", [g[0]])
+            if(curs.fetchall()):
+                red = ""
             else:
-                curs.execute("select title from data where title = ?", [g])
-                exists = curs.fetchall()
-                if(exists):
-                    red = ""
-                else:
-                    red = 'class="not_thing"'
-                    
-                category += ' / ' + '<a ' + red + ' href="/w/' + url_pas(g) + '">' + re.sub("분류:", "", g) + '</a>'
+                red = 'class="not_thing"'
+
+            if(category != ''):    
+                category += ' / '                
+                
+            category += '<a ' + red + ' href="/w/' + url_pas(g[0]) + '">' + re.sub("분류:", "", g[0]) + '</a>'
         
-        data = re.sub("\[\[(분류:(?:(?:(?!\]\]).)*))\]\]", '', data, 1)
+        data = re.sub("\[\[(분류:(?:(?:(?!\]\]|\|).)+))(?:\|((?:(?!\]\]).)+))?\]\]", '', data, 1)
     
     test = re.findall('\[\[wiki:([^|\]]+)(?:\|([^\]]+))?\]\]', data)
-    if(test):
-        for wiki in test:
-            if(wiki[1]):
-                data = re.sub('\[\[wiki:([^|\]]+)(?:\|([^\]]+))?\]\]', '<a id="inside" href="/' + wiki[0] + '">' + wiki[1] + '</a>', data, 1)
-            else:
-                data = re.sub('\[\[wiki:([^|\]]+)(?:\|([^\]]+))?\]\]', '<a id="inside" href="/' + wiki[0] + '">' + wiki[0] + '</a>', data, 1)
+    for wiki in test:
+        if(wiki[1]):
+            out = wiki[1]
+        else:
+            out = wiki[0]
+
+        data = re.sub('\[\[wiki:([^|\]]+)(?:\|([^\]]+))?\]\]', '<a id="inside" href="/' + wiki[0] + '">' + out + '</a>', data, 1)
      
     data = re.sub("\[\[(?::(?P<in>(?:분류|파일):(?:(?:(?!\]\]).)*)))\]\]", "[[\g<in>]]", data)