Procházet zdrojové kódy

Merge pull request #1014 from 2du/dev

Dev
잉여개발기 (SPDV) před 5 roky
rodič
revize
0adef426df

+ 19 - 12
app.py

@@ -1,3 +1,4 @@
+# Load
 import os
 import re
 
@@ -8,7 +9,7 @@ for i_data in os.listdir("route"):
 
         exec("from route." + f_src + " import *")
 
-# DB
+# Version
 version_list = json.loads(open('version.json', encoding = 'utf8').read())
 
 print('Version : ' + version_list['beta']['r_ver'])
@@ -16,6 +17,7 @@ print('DB set version : ' + version_list['beta']['c_ver'])
 print('Skin set version : ' + version_list['beta']['s_ver'])
 print('----')
 
+# DB
 while 1:
     try:
         set_data = json.loads(open('data/set.json', encoding = 'utf8').read())
@@ -79,35 +81,39 @@ if set_data['db_type'] == 'mysql':
     try:
         set_data_mysql = json.loads(open('data/mysql.json', encoding = 'utf8').read())
     except:
-        new_json = ['', '', '']
+        new_json = {}
 
         while 1:
             print('DB user ID : ', end = '')
-            new_json[0] = str(input())
-            if new_json[0] != '':
+            new_json['user'] = str(input())
+            if new_json['user'] != '':
                 break
 
         while 1:
             print('DB password : ', end = '')
-            new_json[1] = str(input())
-            if new_json[1] != '':
+            new_json['password'] = str(input())
+            if new_json['password'] != '':
                 break
                 
         print('DB host (localhost) : ', end = '')
-        new_json[2] = str(input())
-        if new_json[2] == '':
-            new_json[2] == 'localhost'
+        new_json['host'] = str(input())
+        new_json['host'] = 'localhost' if new_json['host'] == '' else new_json['host']
+
+        print('DB port (3306) : ', end = '')
+        new_json['port'] = str(input())
+        new_json['port'] = '3306' if new_json['port'] == '' else new_json['port']
 
         with open('data/mysql.json', 'w', encoding = 'utf8') as f:
-            f.write('{ "user" : "' + new_json[0] + '", "password" : "' + new_json[1] + '", "host" : "' + new_json[2] + '" }')
+            f.write(json.dumps(new_json))
 
-        set_data_mysql = json.loads(open('data/mysql.json', encoding = 'utf8').read())
+        set_data_mysql = new_json
 
     conn = pymysql.connect(
         host = set_data_mysql['host'] if 'host' in set_data_mysql else 'localhost',
         user = set_data_mysql['user'],
         password = set_data_mysql['password'],
-        charset = 'utf8mb4'
+        charset = 'utf8mb4',
+        port = int(set_data_mysql['port']) if 'port' in set_data_mysql else 3306
     )
     curs = conn.cursor()
 
@@ -123,6 +129,7 @@ else:
 
 load_conn(conn)
 
+# DB init
 create_data = {}
 create_data['data'] = ['title', 'data']
 create_data['cache_data'] = ['title', 'data', 'id']

+ 21 - 24
emergency_tool.py

@@ -1,18 +1,11 @@
+# Load
 import time
 from route.tool.func import *
 
-
 # DB
-version_list = json.loads(open('version.json', encoding='utf8').read())
-
-print('Version : ' + version_list['beta']['r_ver'])
-print('DB set version : ' + version_list['beta']['c_ver'])
-print('Skin set version : ' + version_list['beta']['s_ver'])
-print('----')
-
 while 1:
     try:
-        set_data = json.loads(open('data/set.json', encoding='utf8').read())
+        set_data = json.loads(open('data/set.json', encoding = 'utf8').read())
         if not 'db_type' in set_data:
             try:
                 os.remove('data/set.json')
@@ -60,10 +53,10 @@ while 1:
             if new_json[1] == '':
                 new_json[1] = 'data'
 
-            with open('data/set.json', 'w', encoding='utf8') as f:
+            with open('data/set.json', 'w', encoding = 'utf8') as f:
                 f.write('{ "db" : "' + new_json[1] + '", "db_type" : "' + new_json[0] + '" }')
 
-            set_data = json.loads(open('data/set.json', encoding='utf8').read())
+            set_data = json.loads(open('data/set.json', encoding = 'utf8').read())
 
             break
 
@@ -71,37 +64,41 @@ db_data_get(set_data['db_type'])
 
 if set_data['db_type'] == 'mysql':
     try:
-        set_data_mysql = json.loads(open('data/mysql.json', encoding='utf8').read())
+        set_data_mysql = json.loads(open('data/mysql.json', encoding = 'utf8').read())
     except:
-        new_json = ['', '', '']
+        new_json = {}
 
         while 1:
             print('DB user ID : ', end = '')
-            new_json[0] = str(input())
-            if new_json[0] != '':
+            new_json['user'] = str(input())
+            if new_json['user'] != '':
                 break
 
         while 1:
             print('DB password : ', end = '')
-            new_json[1] = str(input())
-            if new_json[1] != '':
+            new_json['password'] = str(input())
+            if new_json['password'] != '':
                 break
                 
         print('DB host (localhost) : ', end = '')
-        new_json[2] = str(input())
-        if new_json[2] == '':
-            new_json[2] == 'localhost'
+        new_json['host'] = str(input())
+        new_json['host'] = 'localhost' if new_json['host'] == '' else new_json['host']
+
+        print('DB port (3306) : ', end = '')
+        new_json['port'] = str(input())
+        new_json['port'] = '3306' if new_json['port'] == '' else new_json['port']
 
-        with open('data/mysql.json', 'w', encoding='utf8') as f:
-            f.write('{ "user" : "' + new_json[0] + '", "password" : "' + new_json[1] + '", "host" : "' + new_json[2] + '" }')
+        with open('data/mysql.json', 'w', encoding = 'utf8') as f:
+            f.write(json.dumps(new_json))
 
-        set_data_mysql = json.loads(open('data/mysql.json', encoding='utf8').read())
+        set_data_mysql = new_json
 
     conn = pymysql.connect(
         host = set_data_mysql['host'] if 'host' in set_data_mysql else 'localhost',
         user = set_data_mysql['user'],
         password = set_data_mysql['password'],
-        charset = 'utf8mb4'
+        charset = 'utf8mb4',
+        port = int(set_data_mysql['port']) if 'port' in set_data_mysql else 3306
     )
     curs = conn.cursor()
 

+ 2 - 1
language/en-US.json

@@ -281,6 +281,7 @@
                 "error_401" : "ACL view limited document notice",
                 "error_404" : "Missing document notice",
                 "edit_help" : "Editing textarea phrase",
+                "upload_help" : "File upload phrase",
             "_comment_2.2.4_" : "Google",
                 "recaptcha" : "reCAPTCHA",
                 "smtp_setting" : "Email SMTP setting",
@@ -395,7 +396,7 @@
             "skin_error" : "This skin is not support settings.",
             "same_id_exist_error" : "There are users with the same username.",
             "long_id_error" : "Username must be shorter than 20 characters.",
-            "id_char_error" : "Only Korean letters, alphabets and spaces are allowed for Username.",
+            "id_char_error" : "Only Korean letters, alphabets are allowed for Username.",
             "file_exist_error" : "The file does not exist.",
             "password_error" : "The password is different.",
             "recaptcha_error" : "Go through the reCAPTCHA.",

+ 7 - 6
language/ko-KR.json

@@ -84,7 +84,7 @@
     "all_acl": "모든 사용자",
     "send": "전송",
     "not_sure": "확실하지 않음",
-    "file_name_error": "파일 이름에는 알파벳, 한글, 공백, 밑줄 및 빼기 기호만 사용할 수 있습니다.",
+    "file_name_error": "파일에는 알파벳, 한글, 공백, 밑줄 및 빼기 기호만 사용할 수 있습니다.",
     "pass": "넘기기",
     "recaptcha_error": "'로봇이 아닙니다'를 통해 reCAPTCHA를 통과하세요.",
     "file_capacity_error": "최대 파일 크기 (MB): ",
@@ -145,7 +145,7 @@
     "pinned": "고정",
     "edit_filter_add": "편집 필터 추가",
     "ban_authority": "차단 권한",
-    "file_extension_error": "지정된 확장자의 파일만 업로드 할 수 있습니다.",
+    "file_extension_error": "지정된 확장자의 파일만 올릴 수 있습니다.",
     "host": "호스트",
     "email_text": "이메일 내용",
     "recent": "최근",
@@ -241,7 +241,7 @@
     "file_name": "파일명",
     "close_discussion": "닫힌 토론",
     "language": "언어",
-    "id_char_error": "오직 한글과 알파벳, 공백만 사용 가능합니다.",
+    "id_char_error": "오직 한글과 알파벳만 사용 가능합니다.",
     "id_filter_add": "ID 필터 추가",
     "skin": "스킨",
     "user_head": "사용자 <HEAD>",
@@ -309,7 +309,7 @@
     "many_delete": "문서 대량 삭제",
     "many_delete_help": "한 줄에 문서명을 한 개씩 적어주세요.",
     "content": "내용",
-    "upload_acl": "파일 업로드 ACL",
+    "upload_acl": "파일 올리기 ACL",
     "topic_delete": "토론 삭제",
     "edit_req": "편집 요청",
     "edit_req_check": "편집 요청 검사",
@@ -359,7 +359,7 @@
     "topic_acl": "토론 ACL",
     "main_skin_set": "기본 스킨 설정",
     "image_file_list": "이미지 파일 목록",
-    "many_upload_acl": "다중 파일 업로드 ACL",
+    "many_upload_acl": "다중 파일 올리기 ACL",
     "reset_backlink": "역링크 초기화",
     "link_in_this": "이 문서의 링크",
     "star_doc": "관심 문서",
@@ -393,5 +393,6 @@
     "2fa" : "2차 인증",
     "2fa_password" : "2차 비밀번호",
     "2fa_password_change" : "2차 비밀번호 변경",
-    "vote_acl" : "투표 ACL"
+    "vote_acl" : "투표 ACL",
+    "upload_help" : "파일 올리기 문구"
 }

+ 1 - 1
readme-en.md

@@ -17,7 +17,7 @@ openNAMU is a Python-based wiki engine. You can use openNAMU by installing Pytho
 ## Getting Started
 openNAMU is based upon Python, and it requires a Python environment.
 
-[Here](http://2du.pythonanywhere.com) you can see the guide.
+[Here](https://2du.pythonanywhere.com/w/en%3AInstall) you can see the guide.
 
 ## Clone
 You can clone this repository by entering the following command at the terminal (command prompt):

+ 13 - 13
route/func_upload.py

@@ -116,35 +116,35 @@ def func_upload_2(conn, app_var):
 
         return redirect('/w/file:' + name)
     else:
-        license_list = '''
-            <option value="direct_input">''' + load_lang('direct_input') + '''</option>
-        '''
+        license_list = '<option value="direct_input">' + load_lang('direct_input') + '</option>'
 
         curs.execute(db_change("select html from html_filter where kind = 'image_license'"))
         db_data = curs.fetchall()
-        for i in db_data:
-            license_list += '''
-                <option value="''' + i[0] + '''">''' + i[0] + '''</option>
-            '''
+        license_list += ''.join(['<option value="' + i[0] + '">' + i[0] + '</option>' for i in db_data])
+
+        curs.execute(db_change("select data from other where name = 'upload_help'"))
+        db_data = curs.fetchall()
+        upload_help = ('<hr class="main_hr">' + db_data[0][0]) if db_data and db_data[0][0] != '' else ''
 
         return easy_minify(flask.render_template(skin_check(),
             imp = [load_lang('upload'), wiki_set(), custom(), other2([0, 0])],
             data = '''
                 <a href="/file_filter">(''' + load_lang('file_filter_list') + ''')</a>
-                <hr class=\"main_hr\">
+                ''' + upload_help + '''
+                <hr class="main_hr">
                 ''' + load_lang('max_file_size') + ''' : ''' + wiki_set(3) + '''MB
-                <hr class=\"main_hr\">
+                <hr class="main_hr">
                 <form method="post" enctype="multipart/form-data" accept-charset="utf8">
                     <input multiple="multiple" type="file" name="f_data[]">
-                    <hr class=\"main_hr\">
+                    <hr class="main_hr">
                     <input placeholder="''' + load_lang('file_name') + '''" name="f_name" value="''' + flask.request.args.get('name', '') + '''">
-                    <hr class=\"main_hr\">
+                    <hr class="main_hr">
                     <select name="f_lice_sel">
                         ''' + license_list + '''
                     </select>
-                    <hr class=\"main_hr\">
+                    <hr class="main_hr">
                     <textarea rows="10" placeholder="''' + load_lang('other') + '''" name="f_lice"></textarea>
-                    <hr class=\"main_hr\">
+                    <hr class="main_hr">
                     ''' + captcha_get() + '''
                     <button id="save" type="submit">''' + load_lang('save') + '''</button>
                 </form>

+ 1 - 1
route/login_register.py

@@ -29,7 +29,7 @@ def login_register_2(conn):
         if flask.request.form.get('pw', None) != flask.request.form.get('pw2', None):
             return re_error('/error/20')
 
-        if re.search(r'(?:[^A-Za-zㄱ-힣0-9 ])', flask.request.form.get('id', None)):
+        if re.search(r'(?:[^A-Za-zㄱ-힣0-9])', flask.request.form.get('id', None)):
             return re_error('/error/8')
 
         curs.execute(db_change('select html from html_filter where kind = "name"'))

+ 7 - 2
route/setting.py

@@ -169,7 +169,7 @@ def setting_2(conn, num, db_set):
                         </span>
                         <span>''' + load_lang('wiki_skin') + '''</span>
                         <hr class="main_hr">
-                        <select name="skin">''' + load_skin(d_list[5]) + '''</select>
+                        <select name="skin">''' + load_skin(d_list[5] if d_list[5] != '' else 'marisa') + '''</select>
                         <hr class="main_hr">
                         <input type="checkbox" name="reg" ''' + check_box_div[0] + '''> ''' + load_lang('no_register') + '''
                         <hr class="main_hr">
@@ -227,7 +227,8 @@ def setting_2(conn, num, db_set):
             'error_401',
             'error_404',
             'approval_question',
-            'edit_help'
+            'edit_help',
+            'upload_help'
         ]
         if flask.request.method == 'POST':
             for i in i_list:
@@ -316,6 +317,10 @@ def setting_2(conn, num, db_set):
                         <hr class="main_hr">
                         <textarea rows="3" name="''' + i_list[13] + '''">''' + html.escape(d_list[13]) + '''</textarea>
                         <hr class="main_hr">
+                        <span>''' + load_lang('upload_help') + '''</span>
+                        <hr class="main_hr">
+                        <textarea rows="3" name="''' + i_list[14] + '''">''' + html.escape(d_list[14]) + '''</textarea>
+                        <hr class="main_hr">
                         <button id="save" type="submit">''' + load_lang('save') + '''</button>
                         <hr class="main_hr">
                         <ul>

+ 5 - 3
route/tool/func.py

@@ -532,15 +532,17 @@ def next_fix(link, num, page, end = 50):
 
 def other2(data):
     global req_list
-    main_css_ver = '52'
+    main_css_ver = '53'
     data += ['' for _ in range(0, 3 - len(data))]
 
     if req_list == '':
         for i_data in os.listdir(os.path.join("views", "main_css", "css")):
-            req_list += '<link rel="stylesheet" href="/views/main_css/css/' + i_data + '?ver=' + main_css_ver + '">'
+            if i_data != 'sub':
+                req_list += '<link rel="stylesheet" href="/views/main_css/css/' + i_data + '?ver=' + main_css_ver + '">'
 
         for i_data in os.listdir(os.path.join("views", "main_css", "js")):
-            req_list += '<script src="/views/main_css/js/' + i_data + '?ver=' + main_css_ver + '"></script>'
+            if i_data != 'sub':
+                req_list += '<script src="/views/main_css/js/' + i_data + '?ver=' + main_css_ver + '"></script>'
 
     data = data[0:2] + ['', '''
         <link   rel="stylesheet"

+ 3 - 3
route/tool/set_mark/namumark.py

@@ -358,7 +358,8 @@ def middle_parser(data):
                             1
                         )
                     elif re.search(r'^#!syntax', middle_data[0]):
-                        middle_data_2 = re.search(r'{{{#!syntax ((?:(?!\n|{{{).)+)\n?', data)
+                        syntax_re = re.compile(r'{{{#!syntax ?((?:(?!\n|{{{|}}}).)*)\n?')
+                        middle_data_2 = syntax_re.search(data)
                         if middle_data_2:
                             middle_data_2 = middle_data_2.groups()
                         else:
@@ -371,8 +372,7 @@ def middle_parser(data):
 
                         middle_list += ['pre']
 
-                        data = re.sub(
-                            r'{{{#!syntax ?((?:(?!\n|{{{).)*)\n?',
+                        data = syntax_re.sub(
                             '<pre id="syntax"><code class="' + middle_data_2[0] + '">',
                             data,
                             1

+ 2 - 2
version.json

@@ -1,7 +1,7 @@
 {
     "beta" : {
-        "r_ver" : "v3.2.0-beta-29 (v3.2.0-dev-2020-08-27-02)",
+        "r_ver" : "v3.2.0-beta-30 (v3.2.0-dev-2020-08-31-02)",
         "c_ver" : "3202600",
-        "s_ver" : "9"
+        "s_ver" : "10"
     }
 }

+ 2 - 1
views/main_css/css/main.css

@@ -49,4 +49,5 @@ blockquote { background-image: url(/views/main_css/file/quote.png); background-p
 .content { height: 500px; }
 .topic_content { height: 200px; }
 .spead_footnote { background-color: #efefef; color: #555; border: 1px solid #cecece; }
-#footnote_data { border-top: 1px solid gainsboro; padding-top: 10px; }
+#footnote_data { border-top: 1px solid gainsboro; padding-top: 10px; }
+a { color: dodgerblue; }

+ 12 - 0
views/main_css/css/sub/dark.css

@@ -0,0 +1,12 @@
+html { background: black; color: white; }
+textarea, input, button, select { background: #1f2023; color: white; }
+input::placeholder, textarea::placeholder, select::placeholder { color: white; }
+#toc, #cate, #redirect { background: #1f2023; }
+#toron_color_grey { background: #4a4a4a; }
+#toron_color_green { background: #2e4a2e; }
+#toron_color_red { background: #803737; }
+#toron_color_blue { background: #314c56; }
+pre#syntax, pre#syntax code { background: black; }
+.hljs, .hljs-subst { color: white; }
+blockquote { background-color: black; border-left: 5px solid #eee; }
+.spead_footnote { background-color: black; color: white; }

+ 4 - 31
views/marisa/css/dark.css

@@ -17,46 +17,19 @@ html, #main {
     color: white;
 }
 
-textarea, input, button, select {
-    background: #1f2023;
-    color: white;
-    border-color: #1f2023;
-}
-
 #mobile_search_input, #mobile_search_input::placeholder {
     background: gray;
     color: white;
 }
 
-#toron_color_grey {
-    background: #4a4a4a;
-}
-
-#toron_color_green {
-    background: #2e4a2e;
-}
-
-#toron_color_red {
-    background: #803737;
-}
-
-#toron_color_blue {
-    background: #314c56;
-}
-
-pre#syntax {
-    background: black;
-}
-
 a#titlt_a {
     color: white;
 }
 
-button#save {
-    background: #083808;
+textarea, input, button, select, #toc, #cate, #redirect { 
+    border-color: #1f2023; 
 }
 
-blockquote {
-    background-color: black;
-    border-left: 5px solid #eee;
+button#save {
+    background: #083808;
 }

+ 1 - 1
views/marisa/index.html

@@ -9,7 +9,7 @@
         {% endif %}
         {{imp[3][3]|safe}}
         <link rel="stylesheet" href="/views/marisa/css/main.css?ver=16">
-        <script src="/views/marisa/js/skin_set.js?ver=4"></script>
+        <script src="/views/marisa/js/skin_set.js?ver=5"></script>
         <script src="/views/marisa/js/main.js?ver=3"></script>
         <script>main_load(); window.addEventListener('DOMContentLoaded', function() { skin_set(); });</script>
         <script src="https://code.iconify.design/1/1.0.3/iconify.min.js"></script>

+ 2 - 2
views/marisa/info.json

@@ -1,5 +1,5 @@
 {
     "name" : "Marisa",
-    "skin_ver" : "v1.2.7",
-    "require_ver" : "9"
+    "skin_ver" : "v1.2.8",
+    "require_ver" : "10"
 }

+ 4 - 1
views/marisa/js/skin_set.js

@@ -15,7 +15,10 @@ function main_load() {
         cookies.match(regex_data('invert')) &&
         cookies.match(regex_data('invert'))[1] === '1'
     ) {
-        head_data.innerHTML += '<link rel="stylesheet" href="/views/marisa/css/dark.css?ver=6">';
+        head_data.innerHTML += '' +
+            '<link rel="stylesheet" href="/views/main_css/css/sub/dark.css?ver=1">' +
+            '<link rel="stylesheet" href="/views/marisa/css/dark.css?ver=6">' +
+        '';
     }
 }