ソースを参照

Merge pull request #1694 from openNAMU/dev

Dev
잉여개발기 (SPDV) 3 年 前
コミット
2105d44299

+ 2 - 2
app.py

@@ -308,7 +308,8 @@ app.route('/extension_filter/add', methods = ['POST', 'GET'], defaults = { 'tool
 
 # Func-list
 # /list/document/old
-app.route('/old_page')(list_old_page)
+app.route('/list/document/old')(list_old_page)
+app.route('/list/document/old/<int:num>')(list_old_page)
 
 # /list/document/acl
 @app.route('/acl_list')
@@ -471,7 +472,6 @@ app.route('/move/<everything:name>', methods = ['POST', 'GET'])(edit_move)
 app.route('/recent_discuss', defaults = { 'tool' : 'normal' })(recent_discuss)
 app.route('/recent_discuss/close', defaults = { 'tool' : 'close' })(recent_discuss)
 app.route('/recent_discuss/open', defaults = { 'tool' : 'open' })(recent_discuss)
-app.route('/recent_discuss/delete')(recent_discuss_delete)
 
 app.route('/thread/<int:topic_num>', methods = ['POST', 'GET'])(topic)
 app.route('/thread/0/<everything:doc_name>', defaults = { 'topic_num' : '0' }, methods = ['POST', 'GET'])(topic)

+ 1 - 2
emergency_tool.py

@@ -99,8 +99,7 @@ if what_i_do == '1':
         curs.execute(db_change("select data from data where title = ?"), [name[0]])
         data = curs.fetchall()
 
-        get_class_render = class_do_render(conn)
-        get_class_render.do_render(name[0], data[0][0], 'backlink', '')
+        class_do_render(conn).do_render(name[0], data[0][0], 'backlink', '')
 elif what_i_do == '2':
     curs.execute(db_change("delete from other where name = 'recaptcha'"))
     curs.execute(db_change("delete from other where name = 'sec_re'"))

+ 62 - 13
route/give_acl.py

@@ -5,10 +5,11 @@ def give_acl_2(name):
         curs = conn.cursor()
 
         check_ok = ''
+        user_page = 0
         ip = ip_check()
 
         if flask.request.method == 'POST':
-            check_data = 'acl (' + name + ')'
+            check_data = 'document_set (' + name + ')'
         else:
             check_data = None
 
@@ -17,12 +18,14 @@ def give_acl_2(name):
             if check_data and ip_or_user(ip) != 0:
                 return redirect('/login')
 
-            if user_data.group(1) != ip_check():
+            if user_data.group(1) != ip:
                 if admin_check(5) != 1:
                     if check_data:
                         return re_error('/error/3')
                     else:
                         check_ok = 'disabled'
+            else:
+                user_page = 1
         else:
             if admin_check(5) != 1:
                 if check_data:
@@ -57,26 +60,52 @@ def give_acl_2(name):
                     if i != 'view':
                         all_d += ' | '
 
-            admin_check(5, check_data + ' (' + all_d + ')')
+            markup_data = flask.request.form.get('document_markup', '')
+
+            curs.execute(db_change("select set_data from data_set where doc_name = ? and set_name = 'document_markup'"), [name])
+            db_data = curs.fetchall()
+            if db_data:
+                curs.execute(db_change("update data_set set set_data = ? where doc_name = ? and set_name = 'document_markup'"), [
+                    markup_data, name
+                ])
+            else:
+                curs.execute(db_change("insert into data_set (doc_name, doc_rev, set_name, set_data) values (?, '', 'document_markup', ?)"), [
+                    name, markup_data
+                ])
+
+            if db_data[0][0] != markup_data:
+                curs.execute(db_change("select data from data where title = ?"), [name])
+                db_data_2 = curs.fetchall()
+                if db_data_2:
+                    render_set(
+                        doc_name = name,
+                        doc_data = db_data_2[0][0],
+                        data_type = 'backlink'
+                    )
+
+            markup_data = markup_data if markup_data != '' else 'default'
+
+            if user_page == 1:
+                admin_check(5, check_data + ' (' + all_d + ')' + ' (' + markup_data + ')')
 
             conn.commit()
 
             return redirect('/acl/' + url_pas(name))
         else:
-            data = ''
+            data = '<h2>' + load_lang('acl') + '</h2>'
             acl_list = get_acl_list('user') if re.search(r'^user:', name) else get_acl_list()
             if not re.search(r'^user:', name):
                 acl_get_list = [
-                    [load_lang('view_acl'), 'view', '2', '1.'],
-                    [load_lang('document_acl'), 'decu', '3', '1.1.'],
-                    [load_lang('document_edit_acl'), 'document_edit_acl', '4', '1.1.1.'],
-                    [load_lang('document_move_acl'), 'document_move_acl', '4', '1.1.2.'],
-                    [load_lang('document_delete_acl'), 'document_delete_acl', '4', '1.1.3.'],
-                    [load_lang('discussion_acl'), 'dis', '2', '2.'],
+                    [load_lang('view_acl'), 'view', '3'],
+                    [load_lang('document_acl'), 'decu', '4'],
+                    [load_lang('document_edit_acl'), 'document_edit_acl', '5'],
+                    [load_lang('document_move_acl'), 'document_move_acl', '5'],
+                    [load_lang('document_delete_acl'), 'document_delete_acl', '5'],
+                    [load_lang('discussion_acl'), 'dis', '3'],
                 ]
             else:
                 acl_get_list = [
-                    [load_lang('document_acl'), 'decu', '2', '1.']
+                    [load_lang('document_acl'), 'decu', '2']
                 ]
 
             for i in acl_get_list:
@@ -99,13 +128,13 @@ def give_acl_2(name):
             acl_data = curs.fetchall()
             acl_why = html.escape(acl_data[0][0]) if acl_data else ''
             data += '' + \
-                '<h2>' + load_lang('why') + '</h2>' + \
+                '<h3>' + load_lang('why') + '</h3>' + \
                 '<input value="' + acl_why + '" placeholder="' + load_lang('why') + '" name="why" ' + check_ok + '>' + \
                 '<hr class="main_hr">' + \
             ''
 
             data += '''
-                <h2>''' + load_lang('explanation') + '''</h2>
+                <h3>''' + load_lang('explanation') + '''</h3>
                 <span id="exp"></span>
                 <ul class="opennamu_ul">
                     <li>normal : ''' + load_lang('unset') + '''</li>
@@ -121,8 +150,28 @@ def give_acl_2(name):
                     <li>ban_admin : ''' + load_lang('ban_admin_acl') + '''</li>
                     <li>not_all : ''' + load_lang('not_all_acl') + '''</li>
                 </ul>
+                <hr class="main_hr">
+                <h2>''' + load_lang('markup') + '''</h2>
             '''
 
+
+            curs.execute(db_change("select set_data from data_set where doc_name = ? and set_name = 'document_markup'"), [name])
+            db_data = curs.fetchall()
+            markup_load = db_data[0][0] if db_data and db_data[0][0] != '' else ''
+
+            markup_list = ['default'] + get_init_set_list('markup')['list']
+            markup_html = ''
+            for for_a in markup_list:
+                if markup_load == for_a:
+                    markup_html = '<option value="' + (for_a if for_a != 'default' else '') + '">' + for_a + '</option>' + markup_html
+                else:
+                    markup_html += '<option value="' + (for_a if for_a != 'default' else '') + '">' + for_a + '</option>'
+            
+            markup_html = '<select name="document_markup" ' + check_ok + '>' + markup_html + '</select>'
+
+            data += markup_html
+            data += '<hr class="main_hr">'
+
             return easy_minify(flask.render_template(skin_check(),
                 imp = [name, wiki_set(), wiki_custom(), wiki_css(['(' + load_lang('acl') + ')', 0])],
                 data = '''

+ 3 - 7
route/list_old_page.py

@@ -1,11 +1,9 @@
 from .tool.func import *
 
-def list_old_page():
+def list_old_page(num = 1):
     with get_db_connect() as conn:
         curs = conn.cursor()
         
-        num = flask.request.args.get('num', '1')
-        num = int(number_check(num))
         sql_num = (num * 50 - 50) if num * 50 > 0 else 0
         
         curs.execute(db_change('select data from other where name = "count_all_title"'))
@@ -14,14 +12,12 @@ def list_old_page():
         
         div = '<ul class="opennamu_ul">'
         
-        curs.execute(db_change('' + \
-            'select h.title, max(h.date) from history as h where not (title like "user:%" or title like "category:%" or title like "file:%") and exists (select title from data where title = h.title) and not exists (select title from back where link = h.title and type = "redirect") group by h.title order by h.date asc limit ?, 50' + \
-        ''), [sql_num])
+        curs.execute(db_change("select doc_name, set_data from data_set where set_name = 'last_edit' order by set_data asc"))
         n_list = curs.fetchall()
         for data in n_list:
             div += '<li>' + data[1] + ' | <a href="/w/' + url_pas(data[0]) + '">' + html.escape(data[0]) + '</a></li>'
         
-        div += '</ul>' + next_fix('/old_page?num=', num, n_list)
+        div += '</ul>' + next_fix('/list/document/old/', num, n_list)
         
         return easy_minify(flask.render_template(skin_check(),
             imp = [load_lang('old_page'), wiki_set(), wiki_custom(), wiki_css([0, 0])],

+ 1 - 1
route/main_sys_shutdown.py

@@ -13,7 +13,7 @@ def main_sys_shutdown():
             print('----')
             print('Shutdown')
 
-            os._exit(os.EX_OK)
+            os._exit(0)
         else:
             return easy_minify(flask.render_template(skin_check(),
                 imp = [load_lang('wiki_shutdown'), wiki_set(), wiki_custom(), wiki_css([0, 0])],

+ 1 - 1
route/main_tool_other.py

@@ -28,7 +28,7 @@ def main_tool_other():
                     <li><a href="/please">''' + load_lang('need_document') + '''</a></li>
                     <li><a href="/long_page">''' + load_lang('long_page') + '''</a></li>
                     <li><a href="/short_page">''' + load_lang('short_page') + '''</a></li>
-                    <li><a href="/old_page">''' + load_lang('old_page') + '''</a></li>
+                    <li><a href="/list/document/old">''' + load_lang('old_page') + '''</a></li>
                 </ul>
                 <h3>''' + load_lang('user') + '''</h3>
                 <ul class="opennamu_ul">

+ 2 - 2
route/recent_discuss.py

@@ -5,12 +5,11 @@ def recent_discuss(tool):
         curs = conn.cursor()
 
         div = ''
+        admin_auth = admin_check(3)
 
         if tool == 'normal':
             div += '<a href="/recent_discuss/close">(' + load_lang('close_discussion') + ')</a> '
             div += '<a href="/recent_discuss/open">(' + load_lang('open_discussion_list') + ')</a>'
-            if admin_check() == 1:
-                div += ' <a href="/recent_discuss/delete">(' + load_lang('delete') + ')</a>'
 
             m_sub = 0
         elif tool == 'close':
@@ -60,6 +59,7 @@ def recent_discuss(tool):
                     '<td>' + \
                         '<a href="/thread/' + data[3] + '">' + html.escape(data[1]) + '</a> ' + \
                         '<a href="/topic/' + url_pas(data[0]) + '">(' + html.escape(data[0]) + ')</a>' + \
+                        (' <a href="/thread/' + data[3] + '/tool">(' + load_lang('tool') + ')</a>' if admin_auth == 1 else '') + \
                     '</td>' + \
                     '<td>' + last_editor_ip_pas[last_editor[count]] + '</td>' + \
                     '<td>' + data[2] + '</td>' + \

+ 0 - 35
route/recent_discuss_delete.py

@@ -1,35 +0,0 @@
-from .tool.func import *
-
-def recent_discuss_delete():
-    with get_db_connect() as conn:
-        curs = conn.cursor()
-        
-        data_html = '' + \
-            '<a href="/recent_discuss">(' + load_lang('normal') + ')</a>' + \
-            '<ul id="opennamu_ul">' + \
-        ''
-        count = 0
-        
-        curs.execute(db_change("select title, sub, date, code, stop from rd order by date desc limit 50"))
-        for data in curs.fetchall():
-            if data[4] == '':
-                stop_code = ''
-            elif data[4] == 'O':
-                stop_code = ' (' + load_lang('close') + ')'
-            else:
-                stop_code = ' (' + load_lang('stop') + ')'
-
-            data_html += '' + \
-                '<li>' + \
-                    '<input type="checkbox" name="checkbox_' + str(count) + '"> ' + \
-                    html.escape(data[1]) + ' (' + html.escape(data[0]) + ')' + stop_code + \
-                '</li>' + \
-            ''
-            
-            count += 1
-            
-        return easy_minify(flask.render_template(skin_check(),
-            imp = [load_lang('recent_discussion'), wiki_set(), wiki_custom(), wiki_css(['(' + load_lang('delete') + ') (' + load_lang('not_working') + ')', 0])],
-            data = data_html,
-            menu = 0
-        ))

+ 25 - 2
route/tool/func.py

@@ -134,7 +134,10 @@ def get_init_set_list(need = 'all'):
         }
     }
     
-    return init_set_list
+    if need == 'all':
+        return init_set_list
+    else:
+        return init_set_list[need]
 
 class get_db_connect:
     # 임시 DB 커넥션 동작 구조
@@ -305,6 +308,8 @@ class class_check_json:
 
 def get_db_table_list():
     # Init-Create_DB
+    # DB 테이블 구조
+    
     # --이거 개편한다더니 도대체 언제?--
     create_data = {}
 
@@ -634,6 +639,21 @@ def update(ver_num, set_data):
         curs.execute(db_change("drop index history_index"))
         curs.execute(db_change("create index history_index on history (title, ip)"))
 
+    if ver_num < 3500359:
+        # 마지막 편집 따로 기록하도록
+        # create_data['data_set'] = ['doc_name', 'doc_rev', 'set_name', 'set_data']
+        print("Update 3500359...")
+
+        curs.execute(db_change("select title from data"))
+        db_data = curs.fetchall()
+        for for_a in db_data:
+            curs.execute(db_change("select date from history where title = ? order by date desc limit 1"), [for_a[0]])
+            db_data_2 = curs.fetchall()
+            if db_data_2:
+                curs.execute(db_change("insert into data_set (doc_name, doc_rev, set_name, set_data) values (?, '', 'last_edit', ?)"), [for_a[0], db_data_2[0][0]])
+
+        print("Update 3500359 complete")
+
     conn.commit()
     
     # 아이피 상태인 이메일 제거 예정
@@ -2003,7 +2023,10 @@ def ip_pas(raw_ip, type_data = 0):
                 else:
                     ip = ip.exploded
                     ip = re.sub(r'\.([^.]*)\.([^.]*)$', '.*.*', ip)
-                    
+                
+                # ip = hashlib.sha3_224(bytes(raw_ip, 'utf-8')).hexdigest()
+                # ip = ip[0:4] + '-' + ip[4:8] + '-' + ip[8:12] + '-' + ip[12:16]
+
                 change_ip = 1
             except:
                 ip = raw_ip

+ 21 - 3
route/tool/func_render.py

@@ -3,9 +3,15 @@ from .func_render_namumark import *
 # 커스텀 마크 언젠간 다시 추가 예정
 
 class class_do_render:
-    def __init__(self, conn, lang_data):
+    def __init__(self, conn, lang_data = {}):
         self.conn = conn
 
+        if lang_data == '{}':
+            lang_data = {
+                'toc' : 'toc',
+                'category' : 'category'
+            }
+
         self.lang_data = lang_data
 
     def do_render(self, doc_name, doc_data, data_type, data_in):
@@ -19,9 +25,15 @@ class class_do_render:
         data_in = (data_in + '_') if data_in != '' else ''
         doc_set['doc_include'] = data_in
 
-        curs.execute(db_change('select data from other where name = "markup"'))
+        curs.execute(db_change("select set_data from data_set where doc_name = ? and set_name = 'document_markup'"), [doc_name])
         rep_data = curs.fetchall()
-        rep_data = rep_data[0][0] if rep_data else 'namumark'
+        if rep_data and rep_data[0][0] != '':
+            rep_data = rep_data[0][0]
+        else:
+            curs.execute(db_change('select data from other where name = "markup"'))
+            rep_data = curs.fetchall()
+            rep_data = rep_data[0][0] if rep_data else 'namumark'
+
         if rep_data == 'namumark' or rep_data == 'namumark_beta':
             data_end = class_do_render_namumark(
                 curs,
@@ -30,6 +42,12 @@ class class_do_render:
                 doc_set,
                 self.lang_data
             )()
+        elif rep_data == 'raw':
+            data_end = [
+                html.escape(doc_data).replace('\n', '<br>'), 
+                '', 
+                {}
+            ]
         else:
             data_end = [
                 doc_data, 

+ 26 - 9
route/tool/func_render_namumark.py

@@ -10,7 +10,24 @@ class class_do_render_namumark:
         self.doc_include = self.doc_set['doc_include'] if 'doc_include' in self.doc_set else ''
 
         self.lang_data = lang_data
-        self.ip = ip_check()
+        try:
+            self.ip = ip_check()
+        except:
+            self.ip = '0.0.0.0'
+
+        try:
+            if 'main_css_bold' in self.flask_session:
+                pass    
+                
+            self.flask_session = flask.session
+        except:
+            self.flask_session = ''
+
+        try:
+            self.darkmode = flask.request.cookies.get('main_css_darkmode', '0')
+        except:
+            self.darkmode = '0'
+
 
         self.data_temp_storage = {}
         self.data_temp_storage_count = 0
@@ -164,7 +181,7 @@ class class_do_render_namumark:
         if len(data) == 1:
             return data[0]
         else:
-            if flask.request.cookies.get('main_css_darkmode', '0') == '0':
+            if self.darkmode == '0':
                 return data[0]
             else:
                 return data[1]
@@ -176,7 +193,7 @@ class class_do_render_namumark:
             db_data = self.curs.fetchall()
             bold_user_set = db_data[0][0] if db_data else 'normal'
         else:
-            bold_user_set = flask.session['main_css_bold'] if 'main_css_bold' in flask.session else 'normal'
+            bold_user_set = self.flask_session['main_css_bold'] if 'main_css_bold' in self.flask_session else 'normal'
 
         def do_render_text_bold(match):
             data = match.group(1)
@@ -242,7 +259,7 @@ class class_do_render_namumark:
             db_data = self.curs.fetchall()
             strike_user_set = db_data[0][0] if db_data else 'normal'
         else:
-            strike_user_set = flask.session['main_css_strike'] if 'main_css_strike' in flask.session else 'normal'
+            strike_user_set = self.flask_session['main_css_strike'] if 'main_css_strike' in self.flask_session else 'normal'
 
         def do_render_text_strike(match):
             data = match.group(1)
@@ -787,9 +804,9 @@ class class_do_render_namumark:
                     else:
                         file_pass = 0
                         if file_turn != '':
-                            if file_turn == 'dark' and flask.request.cookies.get('main_css_darkmode', '0') == '1':
+                            if file_turn == 'dark' and self.darkmode == '1':
                                 file_pass = 1
-                            elif file_turn == 'light' and flask.request.cookies.get('main_css_darkmode', '0') == '0':
+                            elif file_turn == 'light' and self.darkmode == '0':
                                 file_pass = 1
                         else:
                             file_pass = 1
@@ -1110,7 +1127,7 @@ class class_do_render_namumark:
                             db_data = self.curs.fetchall()
                             include_set_data = db_data[0][0] if db_data else 'normal'
                         else:
-                            include_set_data = flask.session['main_css_include_link'] if 'main_css_include_link' in flask.session else 'normal'
+                            include_set_data = self.flask_session['main_css_include_link'] if 'main_css_include_link' in self.flask_session else 'normal'
 
                         include_link = ''
                         if include_set_data == 'use':
@@ -1761,7 +1778,7 @@ class class_do_render_namumark:
                     db_data = self.curs.fetchall()
                     category_set_data = db_data[0][0] if db_data else 'normal'
                 else:
-                    category_set_data = flask.session['main_css_category_set'] if 'main_css_category_set' in flask.session else 'normal'
+                    category_set_data = self.flask_session['main_css_category_set'] if 'main_css_category_set' in self.flask_session else 'normal'
 
                 if category_set_data == 'normal':
                     if re.search(r'<footnote_category>', self.render_data):
@@ -1843,7 +1860,7 @@ class class_do_render_namumark:
                 db_data = self.curs.fetchall()
                 toc_set_data = db_data[0][0] if db_data else 'normal'
             else:
-                toc_set_data = flask.session['main_css_toc_set'] if 'main_css_toc_set' in flask.session else 'normal'
+                toc_set_data = self.flask_session['main_css_toc_set'] if 'main_css_toc_set' in self.flask_session else 'normal'
 
             self.render_data = re.sub(toc_search_regex, '', self.render_data)
             if toc_set_data != 'off':

+ 14 - 14
route/view_read.py

@@ -8,7 +8,7 @@ def view_read(name = 'Test', doc_rev = '', doc_from = '', do_type = ''):
         menu = []
 
         user_doc = ''
-        category_doc = ''
+        category_total = ''
         file_data = ''
 
         ip = ip_check()
@@ -49,23 +49,23 @@ def view_read(name = 'Test', doc_rev = '', doc_from = '', do_type = ''):
 
                     count_category += 1
 
-            if category_doc != '':
-                category_doc = '' + \
-                    '<h2 id="cate_normal">' + load_lang('category_title') + '</h2>' + \
-                    '<ul class="opennamu_ul">' + \
-                        '<li>' + load_lang('all') + ' : ' + str(count_category) + '</li>' + \
-                        category_doc + \
-                    '</ul>' + \
-                ''
-
             if category_sub != '':
-                category_doc += '' + \
+                category_total += '' + \
                     '<h2 id="cate_under">' + load_lang('under_category') + '</h2>' + \
                     '<ul class="opennamu_ul">' + \
                         '<li>' + load_lang('all') + ' : ' + str(count_sub_category) + '</li>' + \
                         category_sub + \
                     '</ul>' + \
                 ''
+
+            if category_doc != '':
+                category_total += '' + \
+                    '<h2 id="cate_normal">' + load_lang('category_title') + '</h2>' + \
+                    '<ul class="opennamu_ul">' + \
+                        '<li>' + load_lang('all') + ' : ' + str(count_category) + '</li>' + \
+                        category_doc + \
+                    '</ul>' + \
+                ''
         elif re.search(r"^user:([^/]*)", name):
             name_view = name
 
@@ -205,7 +205,7 @@ def view_read(name = 'Test', doc_rev = '', doc_from = '', do_type = ''):
                 ['topic/' + url_pas(name), load_lang('discussion'), topic], 
                 ['history/' + url_pas(name), load_lang('history')], 
                 ['xref/' + url_pas(name), load_lang('backlink')], 
-                ['acl/' + url_pas(name), load_lang('acl'), acl],
+                ['acl/' + url_pas(name), load_lang('setting'), acl],
             ]
 
             if do_type == 'from':
@@ -228,11 +228,11 @@ def view_read(name = 'Test', doc_rev = '', doc_from = '', do_type = ''):
             if down:
                 menu += [['down/' + url_pas(name), load_lang('sub')]]
 
-            curs.execute(db_change("select date from history where title = ? order by date desc limit 1"), [name])
+            curs.execute(db_change("select set_data from data_set where doc_name = ? and set_name = 'last_edit'"), [name])
             r_date = curs.fetchall()
             r_date = r_date[0][0] if r_date else 0
 
-        div = file_data + user_doc + end_data + category_doc
+        div = file_data + user_doc + end_data + category_total
 
         if num != '':
             curs.execute(db_change('select data from other where name = "phrase_old_page_warring"'))

+ 2 - 2
version.json

@@ -1,7 +1,7 @@
 {
     "beta" : {
-        "r_ver" : "v3.4.6-RC2-dev131",
-        "c_ver" : "3500358",
+        "r_ver" : "v3.4.6-RC3-dev138",
+        "c_ver" : "3500359",
         "s_ver" : "3500111"
     }
 }