Sfoglia il codice sorgente

Merge pull request #511 from 2DU/master

Master
Surplus_Up (2DU) 8 anni fa
parent
commit
28ebbe5647
11 ha cambiato i file con 561 aggiunte e 356 eliminazioni
  1. 2 2
      .gitignore
  2. 3 3
      Readme-Ko.md
  3. 282 142
      app.py
  4. 5 2
      emergency_tool.py
  5. 41 53
      func.py
  6. 20 1
      language/en-US.json
  7. 123 106
      language/ko-KR.json
  8. 33 20
      mark.py
  9. 6 2
      readme.md
  10. 45 24
      set_mark/namu.py
  11. 1 1
      set_mark/tool.py

+ 2 - 2
.gitignore

@@ -5,8 +5,8 @@ set_mark/__pycache__
 /app_session
 .vscode
 
-opennamu.db
-back_opennamu.db
+study.db
+back_test2.db
 Test.db
 Test2.db
 image

+ 3 - 3
Readme-Ko.md

@@ -1,12 +1,12 @@
 ## 개요
-나무마크 기반의 파이썬 위키 엔진. (3.5 이상)
+나무마크 기반의 파이썬 위키 엔진 입니다. (3.5 이상)
 
 ## 클론 명령어
 ### 일반
- * git clone https://github.com/2DU/openNAMU.git
+ * `git clone https://github.com/2DU/openNAMU.git`
 
 ### 베타
- * git clone -b master https://github.com/2DU/openNAMU.git
+ * `git clone -b master https://github.com/2DU/openNAMU.git`
 
 ## 설치법
  * [참조](http://namu.ml/w/오픈나무%2F설치법)

File diff suppressed because it is too large
+ 282 - 142
app.py


+ 5 - 2
emergency_tool.py

@@ -5,7 +5,7 @@ import threading
 
 # 기타 코드 불러옴
 from func import *
-from mark import namumark
+from mark import load_conn2, namumark
 
 # JSON 불러옴
 json_data = open('set.json').read()
@@ -15,6 +15,9 @@ set_data = json.loads(json_data)
 conn = sqlite3.connect(set_data['db'] + '.db', check_same_thread = False)
 curs = conn.cursor()
 
+# 연결 전달
+load_conn2(conn)
+
 print('1. BackLink ReSet')
 print('2. ReCaptcha Delete')
 print('3. Ban Delete')
@@ -26,7 +29,7 @@ what_i_do = input()
 if what_i_do == '1':
     # 파싱 해주는 함수
     def parser(data):
-        namumark(conn, data[0], data[1], 1)
+        namumark(data[0], data[1], 1)
 
     # 역링크 전부 삭제
     curs.execute("delete from back")

+ 41 - 53
func.py

@@ -1,5 +1,22 @@
-# 모듈들 불러옴
-import css_html_js_minify
+# 모듈들 불러옴
+try:
+    import css_html_js_minify
+except:
+    def easy_minify(data):
+        data = re.sub('\n +', '\n', data)
+        
+        return data
+    
+    class css_html_js_minify:
+        def html_minify(data):
+            return easy_minify(data)
+            
+        def css_minify(data):
+            return easy_minify(data)
+            
+        def js_minify(data):
+            return easy_minify(data)
+    
 import flask
 import json
 import sqlite3
@@ -44,9 +61,7 @@ def captcha_get():
 
 def update():
     # 호환성 설정
-    try:
-        curs.execute("alter table history add hide text default ''")
-        
+    try:        
         curs.execute('select title, re from hidhi')
         for rep in curs.fetchall():
             curs.execute("update history set hide = 'O' where title = ? and id = ?", [rep[0], rep[1]])
@@ -57,27 +72,6 @@ def update():
     except:
         pass
 
-    try:
-        curs.execute("alter table user add date text default ''")
-
-        print('user table add column date')
-    except:
-        pass
-
-    try:
-        curs.execute("alter table rb add band text default ''")
-
-        print('rb table add column band')
-    except:
-        pass
-
-    try:
-        curs.execute("alter table ban add login text default ''")
-
-        print('ban table add column login')
-    except:
-        pass
-
     try:
         curs.execute("select title, acl from data where acl != ''")
         for rep in curs.fetchall():
@@ -89,13 +83,6 @@ def update():
     except:
         pass
 
-    try:
-        curs.execute("alter table user add email text default ''")
-
-        print('user table add column email')
-    except:
-        pass
-
     try:
         curs.execute('select name, sub from filter where sub != "X" and sub != ""')
         filter_name = curs.fetchall()
@@ -108,18 +95,13 @@ def update():
     except:
         pass
 
-    try:
-        curs.execute("alter table user add skin text default ''")
-
-        print('user table add column skin')
-    except:
-        pass
-
     # 3.0.5 사용자 문서, 파일 문서, 분류 문서 영어화
     try:
         all_rep = [['사용자:', 'user:'], ['파일:', 'file:'], ['분류:', 'category:']]
         all_rep2 = ['data', 'history', 'acl', 'topic', 'back']
 
+        test = 0
+
         for i in range(3):
             for j in range(6):
                 if not j == 5:
@@ -129,6 +111,8 @@ def update():
 
                 user_rep = curs.fetchall()
                 for user_rep2 in user_rep:
+                    test = 1
+
                     first = re.sub('^' + all_rep[i][0], all_rep[i][1], user_rep2[0])
 
                     if j == 0:
@@ -144,12 +128,11 @@ def update():
                     elif j == 5:
                         curs.execute("update back set link = ? where link = ?", [first, user_rep2[0]])
 
-        print('사용자 to user, 파일 to file, 분류 to category')
+        if test == 1:
+            print('사용자 to user, 파일 to file, 분류 to category')
     except:
         pass
 
-    conn.commit()
-
 def captcha_post(re_data, num = 1):
     if num == 1:
         if custom()[2] == 0 and captcha_get() != '':
@@ -172,7 +155,7 @@ def captcha_post(re_data, num = 1):
     else:
         pass
 
-def load_lang(data):
+def load_lang(data, num = 0):
     global lang
 
     try:
@@ -191,7 +174,10 @@ def load_lang(data):
         if data in lang:
             return lang[data]
         else:
-            return else_lang[data]
+            if data in else_lang:
+                return else_lang[data]
+            else:
+                return data + ' (Missing)'
             
 def ip_or_user(data):
     if re.search('(\.|:)', data):
@@ -201,8 +187,8 @@ def ip_or_user(data):
 
 def edit_help_button():
     # https://stackoverflow.com/questions/11076975/insert-text-into-textarea-at-cursor-position-javascript
-    '''
-    <script>
+    js_data = '''
+        <script>
         function insertAtCursor(myField, myValue) {
             if (document.selection) { 
                 document.getElementById(myField).focus();
@@ -221,11 +207,13 @@ def edit_help_button():
     </script>
     '''
 
-    insert_list = [['[[]]', '링크'], ['[()]', '매크로'], ['{{{#!}}}', '중괄호']]
+    insert_list = [['[[|]]', 'Link'], ['[()]', 'Macro'], ['{{{#!}}}', 'Middle'], ['||<>||', 'table']]
 
-    '<a href="javascript:void(0);" onclick="insertAtCursor(\'content\', \'B\');">(A)</a>'
+    data = ''
+    for insert_data in insert_list:
+        data += '<a href="javascript:void(0);" onclick="insertAtCursor(\'content\', \'' + insert_data[0] + '\');">(' + insert_data[1] + ')</a>'
 
-    return ['', '']
+    return [js_data, data + '<hr>']
 
 def ip_warring():
     if custom()[2] == 0:    
@@ -384,7 +372,7 @@ def ip_pas(raw_ip):
     hide = 0
 
     if re.search("(\.|:)", raw_ip):
-        if not re.search("^" + load_lang('tool') + ":", raw_ip):    
+        if not re.search("^" + load_lang('tool', 1) + ":", raw_ip):    
             curs.execute("select data from other where name = 'ip_view'")
             data = curs.fetchall()
             if data and data[0][0] != '':
@@ -567,7 +555,7 @@ def ban_insert(name, end, why, login, blocker):
 
     curs.execute("select block from ban where block = ?", [name])
     if curs.fetchall():
-        curs.execute("insert into rb (block, end, today, blocker, why, band) values (?, ?, ?, ?, ?, ?)", [name, load_lang('release'), time, blocker, '', band])
+        curs.execute("insert into rb (block, end, today, blocker, why, band) values (?, ?, ?, ?, ?, ?)", [name, load_lang('release', 1), time, blocker, '', band])
         curs.execute("delete from ban where block = ?", [name])
     else:
         if login != '':
@@ -596,7 +584,7 @@ def history_plus(title, data, date, ip, send, leng):
     if id_data:
         curs.execute("insert into history (id, title, data, date, ip, send, leng) values (?, ?, ?, ?, ?, ?, ?)", [str(int(id_data[0][0]) + 1), title, data, date, ip, send, leng])
     else:
-        curs.execute("insert into history (id, title, data, date, ip, send, leng) values ('1', ?, ?, ?, ?, ?, ?)", [title, data, date, ip, send + ' (' + load_lang('new') + ' ' + load_lang('document') + ')', leng])
+        curs.execute("insert into history (id, title, data, date, ip, send, leng) values ('1', ?, ?, ?, ?, ?, ?)", [title, data, date, ip, send + ' (' + load_lang('new', 1) + ' ' + load_lang('document', 1) + ')', leng])
 
 def leng_check(first, second):
     if first < second:

+ 20 - 1
language/en-US.json

@@ -1,10 +1,26 @@
 {
     "edit" : "Edit",
+    "raw" : "Raw",
     "history" : "History",
     "delete" : "Delete",
+    "logo" : "Logo",
+    "frontpage" : "Main Page",
+    "max_file_size" : "Max File Size",
+    "back_up_interval" : "Back Up Interval",
+    "default_acl" : "Default ACL",
+    "port" : "Port",
+    "secret_key" : "Secret Key",
+    "update_branch" : "Update Branch",
+    "main" : "Main",
+    "set_text" : "Set up notices",
+    "main_head" : "Global HEAD",
+    "indexing" : "Indexing",
+    "ip_hidden" : "Hide IP",
+    "need_to_restart" : "Restart required",
+    "unable_register" : "Unable to register",
     "easy" : "Easy",
     "server" : "Server",
-    "edit_filter" : "Edit Filtering",
+    "skin" : "Skin",
     "template" : "Template",
     "move" : "Move",
     "hide" : "Hide",
@@ -83,9 +99,12 @@
     "under" : "Under",
     "pass" : "Pass",
     "category" : "Category",
+    "filter" : "Filter",
+
     "user_css_warring" : "User's CSS will deleted if you close the browser or when you are editting as guest",
     "http_warring" : "Warning : If you are not on HTTPS connection, your information can be leaked. We won't response to that.",
     "no_login_warring" : "Non-login status. IP is logged when working with non-login.",
+    
     "authority_error" : "Insufficient privileges.",
     "no_login_error" : "Non-login status.",
     "no_exist_user_error" : "Account does not exist.",

+ 123 - 106
language/ko-KR.json

@@ -1,108 +1,125 @@
 {
-    "edit" : "편집",
-    "history" : "역사",
-    "easy" : "간단",
-    "delete" : "삭제",
-    "server" : "서버",
-    "edit_filter" : "편집 필터",
-    "move" : "이동",
-    "hide" : "숨김",
-    "list" : "목록",
-    "revert" : "되돌리기",
-    "version" : "판",
-    "normal_version" : "버전",
-    "document" : "문서",
-    "all" : "모든",
-    "ban" : "차단",
-    "release" : "해제",
-    "save" : "저장",
-    "other" : "기타",
-    "tool" : "도구",
-    "plus" : "추가",
-    "open" : "열린",
-    "search" : "검색",
-    "user" : "사용자",
-    "alarm" : "알림",
-    "watchlist" : "주시 문서",
-    "my_info" : "내 정보",
-    "recent" : "최근",
-    "recent_changes" : "최근 변경",
-    "discussion" : "토론",
-    "login" : "로그인",
-    "logout" : "로그아웃",
-    "register" : "회원가입",
-    "no_alarm" : " 알림이 없습니다.",
-    "able" : "가능",
-    "year" : "년",
-    "month" : "월",
-    "day" : "일",
-    "normal" : "일반",
-    "subscriber" : "가입자",
-    "admin" : "관리자",
-    "owner" : "소유자",
-    "admin_group" : "관리 그룹",
-    "user_css_warring" : "비 로그인의 경우에는 사용자 CSS가 로그인하거나 브라우저 닫으면 날아갑니다.",
-    "http_warring" : "주의 : 만약 HTTPS 연결이 아닌 경우 데이터가 유출될 가능성이 있습니다. 이에 대해 책임지지 않습니다.",
-    "new" : "새",
-    "need" : "필요한",
-    "upload" : "파일 올리기",
-    "record" : "기록",
-    "name" : "이름",
-    "license" : "라이선스",
-    "interwiki" : "인터위키",
-    "update" : "업데이트",
-    "setting" : "설정",
-    "create" : "생성",
-    "editor" : "수정자",
-    "hour" : "시간",
-    "time" : "시각",
-    "close" : "닫기",
-    "stop" : "정지",
-    "restart" : "재시작",
-    "agreement" : "합의",
-    "backlink" : "역링크",
-    "why" : "사유",
-    "random" : "무작위",
-    "authority" : "권한",
-    "file" : "파일",
-    "change" : "변경",
-    "compare" : "비교",
-    "count" : "횟수",
-    "check" : "검사",
-    "preview" : "미리보기",
-    "next" : "다음",
-    "previous" : "이전",
-    "no_login_warring" : "비 로그인 상태로 진행 시 IP가 기록될 수 있습니다.",
-    "state" : "상태",
-    "limitless" : "무기한",
-    "period" : "기간",
-    "now" : "현재",
-    "blocked" : "차단자",
-    "band" : "대역",
-    "notice" : "공지",
-    "writer" : "작성자",
-    "upper" : "상위",
-    "under" : "하위",
-    "pass" : "통과",
-    "category" : "분류",
-    "authority_error" : "권한이 부족합니다.",
-    "no_login_error" : "비 로그인 상태 입니다.",
-    "no_exist_user_error" : "계정이 없습니다.",
-    "no_admin_block_error" : "관리자는 차단, 검사 할 수 없습니다.",
-    "same_id_exist_error" : "동일한 아이디의 사용자가 있습니다.",
-    "long_id_error" : "아이디는 20글자보다 짧아야 합니다.",
-    "id_char_error" : "아이디에는 한글과 알파벳과 공백만 허용 됩니다.",
-    "file_exist_error" : "파일이 없습니다.",
-    "password_error" : "비밀번호가 다릅니다.",
-    "recaptcha_error" : "리캡차를 통과하세요.",
-    "file_extension_error" : "jpg, gif, jpeg, png, webp만 가능 합니다.",
-    "edit_record_error" : "편집 기록은 500자를 넘을 수 없습니다.",
-    "same_file_error" : "동일한 이름의 파일이 있습니다.",
-    "file_capacity_error" : "파일 최대 용량 (MB) :",
-    "decument_exist_error" : "내용이 원래 문서와 동일 합니다.",
-    "password_diffrent_error" : "재 확인 비밀번호와 입력 비밀번호가 다릅니다.",
-    "edit_filter_error" : "편집 필터에 의해 검열 되었습니다.",
-    "file_name_error" : "파일 이름은 알파벳, 한글, 띄어쓰기, 언더바, 빼기표만 허용 됩니다.",
-    "template" : "틀",
-    "out" : "외부"
+    "edit": "편집",
+    "raw" : "원본",
+    "history": "역사",
+    "easy": "간단",
+    "skin": "스킨",
+    "delete": "삭제",
+    "server": "서버",
+    "filter": "필터",
+    "move": "이동",
+    "hide": "숨김",
+    "list": "목록",
+    "revert": "되돌리기",
+    "version": "판",
+    "normal_version": "버전",
+    "document": "문서",
+    "all": "모든",
+    "ban": "차단",
+    "release": "해제",
+    "save": "저장",
+    "other": "기타",
+    "tool": " 도구",
+    "plus": "추가",
+    "open": "열린",
+    "search": "검색",
+    "user": "사용자",
+    "alarm": "알림",
+    "watchlist": "주시 문서",
+    "my_info": "내 정보",
+    "recent": "최근",
+    "recent_changes": "최근 변경",
+    "discussion": "토론",
+    "login": "로그인",
+    "logout": "로그아웃",
+    "register": "회원가입",
+    "no_alarm": " 알림이 없습니다.",
+    "able": "가능",
+    "year": "년",
+    "month": "월",
+    "day": "일",
+    "normal": "일반",
+    "subscriber": "가입자",
+    "admin": "관리자",
+    "owner": "소유자",
+    "admin_group": "관리 그룹",
+    "user_css_warring": "비 로그인의 경우에는 사용자 CSS가 로그인하거나 브라우저 닫으면 날아갑니다.",
+    "http_warring": "주의 : 만 약 HTTPS 연결이 아닌 경우 데이터가 유출될 가능성이 있습니다. 이에 대해 책임지지 않습니다.",
+    "new": "새",
+    "need": "필요한",
+    "upload": "파일 올리기",
+    "record": "기록",
+    "name": "이름",
+    "license": "라이선스",
+    "interwiki": "인터위키",
+    "update": "업데이트",
+    "setting": "설정",
+    "create": "생성",
+    "editor": "수정자",
+    "hour": "시간",
+    "time": "시각",
+    "close": "닫기",
+    "stop": "정지",
+    "restart": "재시작",
+    "agreement": "합의",
+    "backlink": "역링크",
+    "why": "사유",
+    "random": "무작위",
+    "authority": "권한",
+    "file": "파일",
+    "change": "변경",
+    "compare": "비교",
+    "count": "횟수",
+    "check": "검사",
+    "preview": "미리보기",
+    "next": "다음",
+    "previous": "이전",
+    "no_login_warring": "비 로그인 상태로 진행 시 IP가 기록될 수 있습니다.",
+    "state": "상태",
+    "limitless": "무기한",
+    "period": "기간",
+    "now": "현재",
+    "blocked": "차단자",
+    "band": "대역",
+    "notice": "공지",
+    "writer": "작성자",
+    "upper": "상위",
+    "under": "하위",
+    "pass": "통과",
+    "category": "분류",
+    "authority_error": "권한이  부족합니다.",
+    "no_login_error": "비 로그인 상태 입니다.",
+    "no_exist_user_error": "계정이 없습니다.",
+    "no_admin_block_error": "관리자는 차단, 검사 할 수 없습니다.",
+    "same_id_exist_error": "동일한 아이디의 사용자가 있습니다.",
+    "long_id_error": "아이디는 20글자보다 짧아야 합니다.",
+    "id_char_error": "아이디에는 한글과 알파벳과 공백만 허용 됩니다.",
+    "file_exist_error": "파일이 없습니다.",
+    "password_error": "비밀번호가 다릅니다.",
+    "recaptcha_error": "리캡차를 통과하세요.",
+    "file_extension_error": "jpg, gif, jpeg, png, webp만 가능 합니다.",
+    "edit_record_error": "편집 기록은 500자를 넘을 수 없습니다.",
+    "same_file_error": "동일한 이름의 파일이 있습니다.",
+    "file_capacity_error": "파일 최대 용량 (MB) :",
+    "decument_exist_error": "내용이 원래 문서와 동일 합니다.",
+    "password_diffrent_error": "재 확인 비밀번호와 입력 비밀번호가 다릅니다.",
+    "edit_filter_error": "편집 필터에 의해 검열 되었습니다.",
+    "file_name_error": "파일 이름은 알파벳, 한글, 띄어쓰기, 언더바,  빼기표만 허용 됩니다.",
+    "template": "틀",
+    "out": "외부",
+    "logo": "로고",
+    "frontpage": "메인 문서",
+    "max_file_size": "최대 파일 크기",
+    "back_up_interval": "백업 간격",
+    "default_acl": "기본 ACL",
+    "port": "포트",
+    "secret_key": "비밀키",
+    "update_branch": "업데이트 브랜치",
+    "main": "메인",
+    "set_text": "안내문 설정",
+    "main_head": "메인 HEAD",
+    "indexing" : "인덱싱",
+    "unable_register" : "가입 방지",
+    "ip_hidden" : "IP 숨기기",
+    "need_to_restart" : "재시작 필요"
 }

+ 33 - 20
mark.py

@@ -3,9 +3,10 @@ from set_mark.namu import namu
 import re
 import html
 import sqlite3
-from urllib import parse
+import urllib.parse
 import time
 import threading
+import multiprocessing
 
 def load_conn2(data):
     global conn
@@ -21,34 +22,46 @@ def send_parser(data):
         javascript = re.compile('javascript:', re.I)
         
         data = javascript.sub('', data)
-        data = re.sub('&lt;a href=&quot;(?:(?:(?!&quot;).)*)&quot;&gt;(?P<in>(?:(?!&lt;).)*)&lt;\/a&gt;', '<a href="' + parse.quote('\g<in>').replace('/','%2F') + '">\g<in></a>', data)
-    
+
+        while 1:
+            re_data = re.search('&lt;a(?: (?:(?:(?!&gt;).)*))?&gt;(?P<in>(?:(?!&lt;).)*)&lt;\/a&gt;', data)
+            if re_data:
+                re_data = re_data.groups()[0]
+
+                data = re.sub('&lt;a(?: (?:(?:(?!&gt;).)*))?&gt;(?P<in>(?:(?!&lt;).)*)&lt;\/a&gt;', '<a href="/w/' + urllib.parse.quote(re_data).replace('/','%2F') + '">' + re_data + '</a>', data, 1)
+            else:
+                break
+        
     return data
     
-def plusing(name, link, backtype):
-    curs.execute("select title from back where title = ? and link = ? and type = ?", [link, name, backtype])
-    if not curs.fetchall():
-        curs.execute("insert into back (title, link, type) values (?, ?, ?)", [link, name, backtype])
+def plusing(data):
+    for data_in in data:
+        curs.execute("select title from back where title = ? and link = ? and type = ?", [data_in[1], data_in[0], data_in[2]])
+        if not curs.fetchall():
+            curs.execute("insert into back (title, link, type) values (?, ?, ?)", [data_in[1], data_in[0], data_in[2]])
 
 def namumark(title = '', data = '', num = 0):
     if not data == '':
-        data = namu(conn, data, title)
+        data = namu(conn, data, title, num)
+
         if num == 1:
-            i = 0
-            while 1:
-                try:
-                    _ = data[2][i][0]
-                except:
-                    break
-
-                thread_start = threading.Thread(target = plusing, args = [data[2][i][0], data[2][i][1], data[2][i][2]])
-                thread_start.start()
-                thread_start.join()
+            data_num = len(data[2]) 
+            data_in_num = int(data_num / 8)
+            data_in = []
 
-                i += 1
+            for i in range(8):
+                if not i == 7:
+                    data_in += [data[2][data_in_num * i:data_in_num * (i + 1)]]
+                else:
+                    data_in += [data[2][data_in_num * i:]]
 
+            for data_in_for in data_in:
+                thread_start = threading.Thread(target = plusing, args = [data_in_for])
+                thread_start.start()
+                thread_start.join()
+            
             conn.commit()
             
         return data[0] + data[1]
     else:
-        return '404 Not Found.'
+        return '404'

+ 6 - 2
readme.md

@@ -3,10 +3,10 @@ NamuMark based wiki engine returns to Python. (3.5 and above)
 
 ## Clone command
 ### Stable
- * git clone https://github.com/2DU/openNAMU.git
+ * `git clone https://github.com/2DU/openNAMU.git`
 
 ### Master
- * git clone -b master https://github.com/2DU/openNAMU.git
+ * `git clone -b master https://github.com/2DU/openNAMU.git`
 
 ## Install
  * [Reference](https://en.namu.ml/w/openNAMU%2FInstall)
@@ -18,4 +18,8 @@ You can create a new set.json by deleting it.
 
 ## Other
  * [Test Server (Ko)](http://namu.ml/)
+ * [Test Server (En)](http://en.namu.ml/)
  * The first registor is granted owner privileges.
+
+## 한국어
+ * [참조](https://github.com/2DU/openNAMU/blob/master/Readme-Ko.md)

+ 45 - 24
set_mark/namu.py

@@ -181,7 +181,7 @@ def link_fix(main_link):
         
     return [main_link, other_link]
 
-def namu(conn, data, title,):
+def namu(conn, data, title, main_num):
     # DB 지정
     curs = conn.cursor()
 
@@ -595,7 +595,13 @@ def namu(conn, data, title,):
             for i in range(0, 6):
                 all_stack += str(toc_stack[i]) + '.'
 
-            all_stack = re.sub('0.', '', all_stack)
+            while 1:
+                if re.search('[^0-9]0\.', all_stack):
+                    all_stack = re.sub('[^0-9]0\.', '.', all_stack)
+                else:
+                    break
+
+            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) + '">(Edit)</a></span></h' + toc_number + '>\n', data, 1)
             
@@ -622,6 +628,9 @@ def namu(conn, data, title,):
     data = re.sub("\[anchor\((?P<in>(?:(?!\)\]).)+)\)\]", '<span id="\g<in>"></span>', data)          
     data = re.sub('\[ruby\((?P<in>(?:(?!,).)+)\, ?(?P<out>(?:(?!\)\]).)+)\)\]', '<ruby>\g<in><rp>(</rp><rt>\g<out></rt><rp>)</rp></ruby>', data)
 
+    # 글 상자 끼어들기
+    data = re.sub('{{\|(?P<in>(?:(?:(?!\|}}).)*\n*)+)\|}}', '<table><tbody><tr><td>\g<in></td></tbody></table>', data)
+
     # 원래 코드 재탕
     now_time = tool.get_time()
 
@@ -761,28 +770,6 @@ def namu(conn, data, title,):
     # 표 처리
     data = table_start(data)
 
-    # 하위 문서
-    while 1:
-        under_link = re.search('\[\[\.\.\/(?:\|((?:(?!]]).)+))?]]', data)
-        if under_link:
-            under_link = under_link.groups()
-
-            title_data = re.search('^(.+)\/(?:(?:(?!\/).)+)$', title)
-            if title_data:
-                title_data = title_data.groups()[0]
-
-                if under_link[0]:
-                    data = re.sub('\[\[\.\.\/(?:\|((?:(?!]]).)+))?]]', '[[' + title_data + '|' + under_link[0] + ']]', data, 1)
-                else:
-                    data = re.sub('\[\[\.\.\/(?:\|((?:(?!]]).)+))?]]', '[[' + title_data + ']]', data, 1)
-            else:
-                if under_link[0]:
-                    data = re.sub('\[\[\.\.\/(?:\|((?:(?!]]).)+))?]]', '[[' + title + '|' + under_link[0] + ']]', data, 1)
-                else:
-                    data = re.sub('\[\[\.\.\/(?:\|((?:(?!]]).)+))?]]', '[[' + title + ']]', data, 1)
-        else:
-            break
-
     # 링크 관련 문법 구현
     category = '\n<hr><div id="cate">Category : '
     while 1:
@@ -901,6 +888,13 @@ def namu(conn, data, title,):
                 return_link = link_fix(main_link)
                 main_link = return_link[0]
                 other_link = return_link[1]
+
+                if re.search('^\/', main_link):
+                    main_link = re.sub('^\/', title + '/', main_link)
+                elif re.search('\.\.\/\/', main_link):
+                    main_link = re.sub('\.\.\/\/', '/', main_link)
+                elif re.search('^\.\.\/', main_link):
+                    main_link = re.sub('^\.\.\/', re.sub('(?P<in>.+)\/.*$', '\g<in>', title), main_link)
                 
                 if not re.search('^\|', main_link):
                     if main_link != title:
@@ -1032,6 +1026,33 @@ def namu(conn, data, title,):
                 data = data.replace('<span id="' + end_data[i][0] + '"></span>', '<code>' + end_data[i][1] + '</code>')
 
         i += 1
+
+    if main_num == 1:
+        # 역링크에도
+        i = 0
+        while 1:
+            try:
+                _ = backlink[i][0]
+            except:
+                break
+
+            find_data = re.search('<span id="(one_nowiki_[0-9]+)">', backlink[i][1])
+            if find_data:
+                j = 0
+                find_data = find_data.groups()[0]
+
+                while 1:
+                    try:
+                        _ = end_data[j][0]
+                    except:
+                        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])
+
+                    j += 1
+
+            i += 1
     
     # 마지막 처리
     data = re.sub('<\/td_end>', '</td>', data)

+ 1 - 1
set_mark/tool.py

@@ -26,7 +26,7 @@ def savemark(data):
     
     ip = ip_check()
     if not re.search("\.", ip):
-        name = '[[사용자:' + ip + '|' + ip + ']]'
+        name = '[[user:' + ip + '|' + ip + ']]'
     else:
         name = ip
         

Some files were not shown because too many files changed in this diff