2DU před 9 roky
rodič
revize
71d85c95e8
2 změnil soubory, kde provedl 12 přidání a 10 odebrání
  1. 4 2
      main.py
  2. 8 8
      mark.py

+ 4 - 2
main.py

@@ -488,7 +488,7 @@ def backlink(name = None, num = None):
                 
                 break
                 
-            if(rows[i]['type'] == 'include'):
+            if(rows[i]['type'] == 'include' or rows[i]['type'] == 'file'):
                 db_ex("select * from back where title = '" + db_pas(name) + "' and link = '" + db_pas(rows[i]['link']) + "' and type = ''")
                 test = db_get()
                 if(test):
@@ -503,8 +503,10 @@ def backlink(name = None, num = None):
                 if(row):
                     data = row[0]['data']
                     data = re.sub("(?P<in>\[include\((?P<out>(?:(?!\)\]|,).)*)((?:,\s?(?:[^)]*))+)?\)\])", "\g<in>\n\n[[\g<out>]]\n\n", data)
+                    data = re.sub("\[\[파일:(?P<in>(?:(?!\]\]|\|).)*)(?:\|((?:(?!\]\]).)*))?\]\]", "\n\n[[:파일:\g<in>]]\n\n", data)
                     data = re.sub('^#(?:redirect|넘겨주기)\s(?P<in>[^\n]*)', '[[\g<in>]]', data)
-                    data = namumark('', data)
+                    print(data)
+                    data = namumark('', data)                    
                     
                     if(re.search("<a(?:(?:(?!href=).)*)?href=\"\/w\/" + url_pas(name) + "(?:\#[^\"]*)?\"(?:(?:(?!>).)*)?>([^<]*)<\/a>", data)):
                         div = div + '<li><a href="/w/' + url_pas(rows[i]['link']) + '">' + rows[i]['link'] + '</a>'

+ 8 - 8
mark.py

@@ -188,11 +188,11 @@ def mid_pas(data, fol_num, include):
             
     return (data, fol_num)
 
-def backlink_plus(name, link, type):
-    db_ex("select title from back where title = '" + db_pas(link) + "' and link = '" + db_pas(name) + "' and type = '" + type + "'")
+def backlink_plus(name, link, backtype):
+    db_ex("select title from back where title = '" + db_pas(link) + "' and link = '" + db_pas(name) + "' and type = '" + backtype + "'")
     y = db_get()
     if(not y):
-        db_ex("insert into back (title, link, type) value ('" + db_pas(link) + "', '" + db_pas(name) + "',  '" + type + "')")
+        db_ex("insert into back (title, link, type) value ('" + db_pas(link) + "', '" + db_pas(name) + "',  '" + backtype + "')")
         db_com()
 
 def cat_plus(name, link):
@@ -408,6 +408,10 @@ def namumark(title, data):
             c = m.groups()
 
             if(c):
+                if(not re.search("^파일:([^\n]*)", title)):
+                    print(c[0])
+                    backlink_plus(title, '파일:' + c[0], 'file')
+
                 if(c[1]):
                     n = re.search("width=([^ \n&]*)", c[1])
                     e = re.search("height=([^ \n&]*)", c[1])
@@ -429,11 +433,7 @@ def namumark(title, data):
                     img = re.sub("\.(?P<in>[Jj][Pp][Gg]|[Pp][Nn][Gg]|[Gg][Ii][Ff]|[Jj][Pp][Ee][Gg])", "#\g<in>#", c[0])
                     data = re.sub("\[\[파일:((?:(?!\]\]|\?).)*)(?:\?((?:(?!\]\]).)*))?\]\]", "<a href='/w/파일:" + img + "'><img src='/image/" + img + "'></a>", data, 1)
             else:
-                img = re.sub("\.(?P<in>[Jj][Pp][Gg]|[Pp][Nn][Gg]|[Gg][Ii][Ff]|[Jj][Pp][Ee][Gg])", "#\g<in>#", c[0])
-                data = re.sub("\[\[파일:((?:(?!\]\]|\?).)*)(?:\?((?:(?!\]\]).)*))?\]\]", "<a href='/w/파일:" + img + "'><img src='/image/" + img + "'></a>", data, 1)
-
-            if(not re.search("^파일:([^\n]*)", title)):
-                backlink_plus(title, '파일:' + c[0], 'file')            
+                break            
         else:
             break