Kaynağa Gözat

코드 일부 수정

Surplus_Up (2DU) 8 yıl önce
ebeveyn
işleme
1caa55b335
4 değiştirilmiş dosya ile 27 ekleme ve 30 silme
  1. 12 12
      app.py
  2. 0 3
      func.py
  3. 3 3
      mark.py
  4. 12 12
      set_mark/namu.py

+ 12 - 12
app.py

@@ -1447,10 +1447,10 @@ def revert(name = None):
                 curs.execute("insert into data (title, data) values (?, ?)", [name, data[0][0]])
                 
             history_plus(name, data[0][0], get_time(), ip_check(), flask.request.form.get('send', None) + ' (' + str(num) + load_lang('version') + ')', leng)
-            namumark_re(
-                name = name,
+            namumark(
+                title = name,
                 data = data[0][0],
-                set_num = 1
+                num = 1
             )
             
             conn.commit()
@@ -1655,10 +1655,10 @@ def edit(name = None):
         curs.execute("delete from back where link = ?", [name])
         curs.execute("delete from back where title = ? and type = 'no'", [name])
         
-        namumark_re(
-            name = name,
+        namumark(
+            title = name,
             data = content,
-            set_num = 1
+            num = 1
         )
         
         conn.commit()
@@ -1734,8 +1734,8 @@ def preview(name = None):
     new_data = re.sub('^\r\n', '', new_data)
     new_data = re.sub('\r\n$', '', new_data)
     
-    end_data = namumark_re(
-        name = name,
+    end_data = namumark(
+        title = name,
         data = new_data
     )
     
@@ -2275,7 +2275,7 @@ def topic(name = None, sub = None):
                                 
             all_data += '<table id="toron"><tbody><tr><td id="toron_color_red">'
             all_data += '<a href="#' + topic_data[1] + '">#' + topic_data[1] + '</a> ' + ip_pas(topic_data[3]) + who_plus + ' <span style="float: right;">' + topic_data[2] + '</span>'
-            all_data += '</td></tr><tr><td>' + namumark_re(data = topic_data[0]) + '</td></tr></tbody></table><br>'    
+            all_data += '</td></tr><tr><td>' + namumark(data = topic_data[0]) + '</td></tr></tbody></table><br>'    
 
         for topic_data in topic:
             if number == 1:
@@ -2294,7 +2294,7 @@ def topic(name = None, sub = None):
             else:
                 blind_data = ''
 
-            user_write = namumark_re(data = topic_data[0])
+            user_write = namumark(data = topic_data[0])
             ip = ip_pas(topic_data[3])
             
             curs.execute('select acl from user where id = ?', [topic_data[3]])
@@ -3147,8 +3147,8 @@ def read_view(name = None):
         else_data = re.sub('^\r\n', '', else_data)
         else_data = re.sub('\r\n$', '', else_data)
             
-    end_data = namumark_re(
-        name = name,
+    end_data = namumark(
+        title = name,
         data = else_data
     )
     

+ 0 - 3
func.py

@@ -91,9 +91,6 @@ def ip_or_user(data):
     else:
         return 0
 
-def namumark_re(name = '', data = '', set_num = 0):
-    return namumark(name, data, set_num, load_lang('please_all'))
-
 def edit_help_button():
     # https://stackoverflow.com/questions/11076975/insert-text-into-textarea-at-cursor-position-javascript
     '''

+ 3 - 3
mark.py

@@ -1,4 +1,4 @@
-from set_mark.start import start
+from set_mark.namu import namu
 
 import re
 import html
@@ -30,8 +30,8 @@ def plusing(name, link, backtype):
     if not curs.fetchall():
         curs.execute("insert into back (title, link, type) values (?, ?, ?)", [link, name, backtype])
 
-def namumark(title, data, num, lang):
-    data = start(conn, data, title, lang)
+def namumark(title = '', data = '', num = 0):
+    data = namu(conn, data, title)
     if num == 1:
         i = 0
         while 1:

+ 12 - 12
set_mark/start.py → set_mark/namu.py

@@ -177,7 +177,7 @@ def link_fix(main_link):
         
     return [main_link, other_link]
 
-def start(conn, data, title, lang):
+def namu(conn, data, title,):
     # DB 지정
     curs = conn.cursor()
 
@@ -256,7 +256,7 @@ def start(conn, data, title, lang):
                     else:
                         break
 
-                include_parser = re.sub('\[\[' + lang['template'] + ':(((?!\]\]|#include).)+)\]\]', '', include_parser)
+                include_parser = re.sub('\[\[(?:category|분류):(((?!\]\]|#include).)+)\]\]', '', include_parser)
                 include_parser = html.escape(include_parser)
 
                 data = re.sub('\[include\(((?:(?!\)\]).)+)\)\]', '<include>\n<a id="include_link" href="/w/' + tool.url_pas(include_link) + '">[' + include_link + ']</a>\n' + include_parser + '\n</include>', data, 1)
@@ -593,7 +593,7 @@ def start(conn, data, title, lang):
 
             all_stack = re.sub('0.', '', all_stack)
             
-            data = re.sub('\n(={1,6}) ?((?:(?!\n).)+) ?\n', '\n<h' + toc_number + ' id="s-' + re.sub('\.$', '', all_stack) + '"><a href="#toc">' + all_stack + '</a> ' + re.sub('=*$', '', toc[1]) + ' <span style="font-size: 12px"><a href="/edit/' + tool.url_pas(title) + '?section=' + str(edit_number) + '">(' + lang['edit'] + ')</a></span></h' + toc_number + '>\n', data, 1)
+            data = re.sub('\n(={1,6}) ?((?:(?!\n).)+) ?\n', '\n<h' + toc_number + ' id="s-' + re.sub('\.$', '', all_stack) + '"><a href="#toc">' + all_stack + '</a> ' + re.sub('=*$', '', toc[1]) + ' <span style="font-size: 12px"><a href="/edit/' + tool.url_pas(title) + '?section=' + str(edit_number) + '">(Edit)</a></span></h' + toc_number + '>\n', data, 1)
             
             toc_data += '<span style="margin-left: ' + str((toc_full - toc_top_stack) * 10) + 'px;"><a href="#s-' + re.sub('\.$', '', all_stack) + '">' + all_stack + '</a> ' + re.sub('\[\*((?:(?! |\]).)*)(?: ((?:(?!\]).)+))?\]', '', re.sub('=*$', '', toc[1])) + '</span>\n'
         else:
@@ -780,7 +780,7 @@ def start(conn, data, title, lang):
             break
 
     # 링크 관련 문법 구현
-    category = '\n<hr><div id="cate">' + lang['category'] + ': '
+    category = '\n<hr><div id="cate">Category : '
     while 1:
         link = re.search('\[\[((?:(?!\[\[|\]\]).)+)\]\]', data)
         if link:
@@ -796,7 +796,7 @@ def start(conn, data, title, lang):
                 main_link = link
                 see_link = link
 
-            if re.search('^(' + lang['file'] + '|' + lang['out'] + '):', main_link):
+            if re.search('^((?:file|파일)|(?:out|외부)):', main_link):
                 file_style = ''
 
                 width = re.search('width=((?:(?!&).)+)', see_link)
@@ -825,13 +825,13 @@ def start(conn, data, title, lang):
                 else:
                     file_align = ''
 
-                if re.search('^' + lang['out'] + ':', main_link):
-                    file_src = re.sub('^' + lang['out'] + ':', '', main_link)
+                if re.search('^(?:out|외부):', main_link):
+                    file_src = re.sub('^(?:out|외부):', '', main_link)
             
                     file_alt = main_link
                     exist = 'Yes'
                 else:
-                    file_data = re.search('^' + lang['file'] + ':((?:(?!\.).)+)\.(.+)$', main_link)
+                    file_data = re.search('^(?:file|파일):((?:(?!\.).)+)\.(.+)$', main_link)
                     if file_data:
                         file_data = file_data.groups()
                         file_name = file_data[0]
@@ -843,7 +843,7 @@ def start(conn, data, title, lang):
                         file_end = 'jpg'
 
                     file_src = '/image/' + tool.sha224(file_name) + '.' + file_end
-                    file_alt = '' + lang['file'] + ':' + file_name + '.' + file_end
+                    file_alt = 'File:' + file_name + '.' + file_end
 
                     curs.execute("select title from data where title = ?", [file_alt])
                     exist = curs.fetchall()
@@ -852,7 +852,7 @@ def start(conn, data, title, lang):
                     data = re.sub('\[\[((?:(?!\[\[|\]\]).)+)\]\]', '<span style="' + file_align + '"><img style="' + file_style + '" alt="' + file_alt + '" src="' + file_src + '"></span>', data, 1)
                 else:
                     data = re.sub('\[\[((?:(?!\[\[|\]\]).)+)\]\]', '<a id="not_thing" href="/w/' + tool.url_pas(file_alt) + '">' + file_alt + '</a>', data, 1)
-            elif re.search('^' + lang['category'] + ':', main_link):
+            elif re.search('^(?:category|분류):', main_link):
                 see_link = re.sub('#include', '', see_link)
                 main_link = re.sub('#include', '', main_link)
 
@@ -866,7 +866,7 @@ def start(conn, data, title, lang):
 
                 backlink += [[title, main_link, 'cat']]
 
-                category += '<a ' + link_id + ' href="' + tool.url_pas(main_link) + '">' + re.sub('^' + lang['category'] + ':', '', see_link) + '</a> / '
+                category += '<a ' + link_id + ' href="' + tool.url_pas(main_link) + '">' + re.sub('^(?:category|분류):', '', see_link) + '</a> / '
                 data = re.sub('\[\[((?:(?!\[\[|\]\]).)+)\]\]', '', data, 1)
             elif re.search('^wiki:', main_link):
                 data = re.sub('\[\[((?:(?!\[\[|\]\]).)+)\]\]', '<a id="inside" href="/' + tool.url_pas(re.sub('^wiki:', '', main_link)) + '">' + see_link + '</a>', data, 1)
@@ -1005,7 +1005,7 @@ def start(conn, data, title, lang):
     category += '</div>'
     category = re.sub(' / <\/div>$', '</div>', category)
 
-    if category == '\n<hr><div id="cate">' + lang['category'] + ': </div>':
+    if category == '\n<hr><div id="cate">Category : </div>':
         category = ''
 
     data += category