2du 4 лет назад
Родитель
Сommit
e52b742adb
8 измененных файлов с 125 добавлено и 68 удалено
  1. 43 11
      app.py
  2. 7 11
      route/login.py
  3. 4 1
      route/login_2fa.py
  4. 2 2
      route/main_manager.py
  5. 28 24
      route/recent_block.py
  6. 1 1
      route/recent_change.py
  7. 1 1
      version.json
  8. 39 17
      views/main_css/js/render_onmark.js

+ 43 - 11
app.py

@@ -309,7 +309,12 @@ if os.path.exists('custom.py'):
 
 # Func
 # Func-inter_wiki
-@app.route('/<regex("inter_wiki|edit_top|image_license|(?:edit|email|file|name|extension)_filter"):tools>')
+
+# 개편 필요
+@app.route('/<regex("inter_wiki"):tools>')
+@app.route('/<regex("edit_top"):tools>')
+@app.route('/<regex("image_license"):tools>')
+@app.route('/<regex("(?:edit|email|file|name|extension)_filter"):tools>')
 def inter_wiki(tools = None):
     return inter_wiki_2(conn, tools)
 
@@ -430,17 +435,26 @@ def view_read(name = None):
 def recent_discuss():
     return recent_discuss_2(conn)
 
+# ongoing 반영 필요
 @app.route('/block_log')
-@app.route('/<regex("block_user"):tool>/<name>')
-@app.route('/<regex("block_admin"):tool>/<name>')
-def recent_block(name = None, tool = None):
+@app.route('/block_log/<regex("user"):tool>/<name>')
+@app.route('/block_log/<regex("admin"):tool>/<name>')
+def recent_block(name = 'Test', tool = 'all'):
     return recent_block_2(conn, name, tool)
 
+# 이 쪽 분리 필요
+@app.route('/recent_change')
 @app.route('/recent_changes')
-@app.route('/<regex("record"):tool>/<name>')
-@app.route('/<regex("history"):tool>/<everything:name>', methods = ['POST', 'GET'])
-def recent_changes(name = None, tool = 'record'):
-    return recent_changes_2(conn, name, tool)
+def recent_change(name = None):
+    return recent_change_2(conn, name, '')
+
+@app.route('/record/<name>')
+def recent_record(name = None):
+    return recent_change_2(conn, name, 'record')
+
+@app.route('/history/<everything:name>', methods = ['POST', 'GET'])
+def recent_history(name = None):
+    return recent_change_2(conn, name, 'history')
 
 @app.route('/history/tool/<int(signed=True):rev>/<everything:name>')
 def recent_history_tool(name = 'Test', rev = 1):
@@ -603,18 +617,36 @@ def watch_list_name(tool = 'star_doc', name = 'Test'):
 
 # Func-login
 # 개편 예정
+
+# login -> login/2fa -> login/2fa/email with login_id
+# register -> register/email -> regiter/email/check with reg_id
+# pass_find -> passfind/email with find_id
 @app.route('/login', methods = ['POST', 'GET'])
-def login():
-    return login_2(conn)
+def login_login():
+    return login_login_2(conn)
 
 @app.route('/login/2fa', methods = ['POST', 'GET'])
 def login_2fa():
-    return login_2fa_2(conn)
+    return login_login_2fa_2(conn)
+
+'''
+@app.route('/login/2fa/email', methods = ['POST', 'GET'])
+def login_2fa_email():
+    return login_login_2fa_email_2(conn)
 
 @app.route('/register', methods = ['POST', 'GET'])
 def login_register():
     return login_register_2(conn)
 
+@app.route('/register/email', methods = ['POST', 'GET'])
+def login_register_email():
+    return login_register_email_2(conn)
+
+@app.route('/register/email/check', methods = ['POST', 'GET'])
+def login_register_email_check():
+    return login_register_email_check_2(conn)
+'''
+
 @app.route('/<regex("need_email"):tool>', methods = ['POST', 'GET'])
 @app.route('/<regex("pass_find"):tool>', methods = ['POST', 'GET'])
 def login_need_email(tool = 'pass_find'):

+ 7 - 11
route/login.py

@@ -18,14 +18,11 @@ def login_2(conn):
 
         user_agent = flask.request.headers.get('User-Agent', '')
         user_id = flask.request.form.get('id', '')
-
         user_data = {}
-        curs.execute(db_change("" + \
-            "select name, data from user_set " + \
-            "where id = ? and (name = 'pw' or name = 'encode')" + \
-        ""), [
-            user_id
-        ])
+
+        curs.execute(db_change(
+            'select name, data from user_set where id = ? and name = "pw"'
+        ), [user_id])
         sql_data = curs.fetchall()
         if not sql_data:
             return re_error('/error/2')
@@ -33,19 +30,18 @@ def login_2(conn):
             for i in sql_data:
                 user_data[i[0]] = i[1]
 
-        pw_check_d = pw_check(
+        if pw_check(
             flask.request.form.get('pw', ''),
             user_data['pw'],
             user_data['encode'],
             user_id
-        )
-        if pw_check_d != 1:
+        ) != 1:
             return re_error('/error/10')
 
         curs.execute(db_change('select data from user_set where name = "2fa" and id = ?'), [user_id])
         fa_data = curs.fetchall()
         if fa_data and fa_data[0][0] != '':
-            flask.session['b_id'] = user_id
+            flask.session['login_id'] = user_id
 
             return redirect('/login/2fa')
         else:

+ 4 - 1
route/login_2fa.py

@@ -3,7 +3,10 @@ from .tool.func import *
 def login_2fa_2(conn):
     curs = conn.cursor()
 
-    if not (flask.session and 'b_id' in flask.session):
+    # email 2fa
+    # pw 2fa
+    # q_a 2fa
+    if not (flask.session and 'login_id' in flask.session):
         return redirect('/user')
 
     ip = ip_check()

+ 2 - 2
route/main_manager.py

@@ -13,8 +13,8 @@ def main_manager_2(conn, num, r_ver):
         6 : [load_lang('name'), 'admin_plus', load_lang('add_admin_group')],
         7 : [load_lang('name'), 'plus_edit_filter', load_lang('edit_filter_add')],
         8 : [load_lang('document_name'), 'search', load_lang('search')],
-        9 : [0, 'block_user', load_lang('blocked_user')],
-        10 : [0, 'block_admin', load_lang('blocked_admin')],
+        9 : [0, 'block_log/user', load_lang('blocked_user')],
+        10 : [0, 'block_log/admin', load_lang('blocked_admin')],
         11 : [load_lang('document_name'), 'watch_list', load_lang('add_watchlist')],
         12 : [load_lang('compare_target'), 'check', load_lang('compare_target')],
         13 : [load_lang('document_name'), 'edit', load_lang('load')],

+ 28 - 24
route/recent_block.py

@@ -21,10 +21,10 @@ def recent_block_2(conn, name, tool):
 
     get_type = flask.request.args.get('type', '')
     sub_type = flask.request.args.get('s_type', '')
-    if not name:
+    if tool == 'all':
         if get_type == 'ongoing':
             sub = ' (' + load_lang('in_progress') + ')'
-           
+
             if sub_type == '':
                 div = '' + \
                     '<a href="?type=ongoing&s_type=regex">(' + load_lang('regex') + ')</a> ' + \
@@ -66,29 +66,28 @@ def recent_block_2(conn, name, tool):
                 "select why, block, blocker, end, today, band, ongoing " + \
                 "from rb order by today desc limit ?, 50" + \
             ""), [sql_num])
-    else:
+    elif tool == 'user':
+        sub = ' (' + load_lang('blocked') + ')'
         menu = [['block_log', load_lang('normal')]]
 
-        if tool == 'block_user':
-            sub = ' (' + load_lang('blocked') + ')'
-
-            curs.execute(db_change("" + \
-                "select why, block, blocker, end, today, band, ongoing " + \
-                "from rb where block = ? order by today desc limit ?, 50" + \
-            ""), [
-                name, 
-                sql_num
-            ])
-        else:
-            sub = ' (' + load_lang('admin') + ')'
+        curs.execute(db_change("" + \
+            "select why, block, blocker, end, today, band, ongoing " + \
+            "from rb where block = ? order by today desc limit ?, 50" + \
+        ""), [
+            name, 
+            sql_num
+        ])
+    else:
+        sub = ' (' + load_lang('admin') + ')'
+        menu = [['block_log', load_lang('normal')]]
 
-            curs.execute(db_change("" + \
-                "select why, block, blocker, end, today, band, ongoing " + \
-                "from rb where blocker = ? order by today desc limit ?, 50" + \
-            ""), [
-                name, 
-                sql_num
-            ])
+        curs.execute(db_change("" + \
+            "select why, block, blocker, end, today, band, ongoing " + \
+            "from rb where blocker = ? order by today desc limit ?, 50" + \
+        ""), [
+            name, 
+            sql_num
+        ])
 
     data_list = curs.fetchall()
     all_ip = ip_pas([i[1] for i in data_list] + [i[2] for i in data_list])
@@ -136,8 +135,13 @@ def recent_block_2(conn, name, tool):
             </tr>
         '''
 
-    div += '</tbody></table>'
-    div += next_fix('/block_log?num=', num, data_list) if not name else next_fix('/' + url_pas(tool) + '/' + url_pas(name) + '?num=', num, data_list)
+    div += '</tbody>'
+    div += '</table>'
+    
+    if tool == 'all':
+        div += next_fix('/block_log?num=', num, data_list)
+    else:
+        div += next_fix('/block_log/' + url_pas(tool) + '/' + url_pas(name) + '?num=', num, data_list)
 
     return easy_minify(flask.render_template(skin_check(),
         imp = [load_lang('recent_ban'), wiki_set(), wiki_custom(), wiki_css([sub, 0])],

+ 1 - 1
route/recent_changes.py → route/recent_change.py

@@ -1,6 +1,6 @@
 from .tool.func import *
 
-def recent_changes_2(conn, name, tool):
+def recent_change_2(conn, name, tool):
     curs = conn.cursor()
 
     if flask.request.method == 'POST':

+ 1 - 1
version.json

@@ -1,6 +1,6 @@
 {
     "beta" : {
-        "r_ver" : "v3.4.0-stable-01b (beta-01b) (dev-21.08.21-01)",
+        "r_ver" : "v3.4.0-stable-01b (beta-01b) (dev-21.08.22-01)",
         "c_ver" : "3400101",
         "s_ver" : "12"
     }

+ 39 - 17
views/main_css/js/render_onmark.js

@@ -60,6 +60,14 @@ function do_data_try_insert(name_ob, data) {
     ''
 }
 
+function do_all_try(data) {
+    return '' +
+        'try {\n'
+            + data + 
+        '} catch {}\n' +
+    ''
+}
+
 function do_px_add(data) {
     return data.match(/^[0-9]+$/) ? (data + 'px') : data;
 }
@@ -280,7 +288,6 @@ function do_onmark_link_render(data, data_js, name_doc, name_include, data_nowik
                     '\n' +
                 '';
 
-                category_data = (category_data === '' ? '<div id="cate_all"><div id="cate">Category : ' : category_data);
                 category_data += '' +
                     '<a class="' + name_include + 'link_finder" ' +
                         'name="' + name_include + 'set_link_' + num_link_str + '" ' +
@@ -357,9 +364,15 @@ function do_onmark_link_render(data, data_js, name_doc, name_include, data_nowik
             }
         });
     }
-    
-    if(name_include === '') {
-        data += (category_data === '' ? '' : (category_data.replace(/\| $/, '') + '</div></div>'));
+
+    if(category_data !== '') {
+        if(name_include === '') {
+            category_data = '<div id="cate_all"><div id="cate">Category : ' + category_data;
+        } else {
+            category_data = '<div style="display: none;" id="cate_all"><div id="cate">Category : ' + category_data;
+        }
+        
+        data += category_data.replace(/\| $/, '') + '</div></div>';
     }
     
     return [data, data_js];
@@ -958,18 +971,7 @@ function do_onmark_table_render(data) {
     return data;
 }
 
-function do_onmark_list_render(data) {
-    var wiki_re = /<wiki_s_2 ([^>]+)>((?:(?!<wiki_s_2 |<wiki_e_2>).)+)<wiki_e_2>/s;
-    while(1) {
-        if(!data.match(wiki_re)) {
-            break;
-        }
-
-        data = data.replace(wiki_re, function(x, x_1, x_2) {
-            return '<wiki_s_3 ' + x_1 + '>' + x_2.replace(/\n/g, '<t_br>') + '<wiki_e_3>';
-        });
-    }
-    
+function do_onmark_list_sub_render(data) {
     var quote_re = /\n((?:(?:(?:&gt;)+) ?(?:(?:(?!\n).)*)\n)+)/;
     var quote_short_re = /((?:&gt;)+) ?((?:(?!\n).)*)\n/g;
     var quote_leng = 1;
@@ -1017,14 +1019,32 @@ function do_onmark_list_render(data) {
         
         var list_end_data = list_data[1].replace(list_short_re, function(x, x_1, x_2) {
             var list_leng = x_1.length;
+            
             list_leng = list_leng > 0 ? list_leng : 1;
             
-            return '<li style="margin-left: ' + String((list_leng - 1) * 20) + 'px">' + x_2 + '</li>';
+            return '<li style="margin-left: ' + String(list_leng * 20) + 'px">' + x_2 + '</li>';
         });
 
         data = data.replace(list_re, '\n<start_point><ul>' + list_end_data + '</ul><end_point>\n');
     }
     
+    return data;
+}
+
+function do_onmark_list_render(data) {
+    var wiki_re = /<wiki_s_2 ([^>]+)>((?:(?!<wiki_s_2 |<wiki_e_2>).)+)<wiki_e_2>/s;
+    while(1) {
+        if(!data.match(wiki_re)) {
+            break;
+        }
+
+        data = data.replace(wiki_re, function(x, x_1, x_2) {
+            return '<wiki_s_3 ' + x_1 + '>' + x_2.replace(/\n/g, '<t_br>') + '<wiki_e_3>';
+        });
+    }
+    
+    data = do_onmark_list_sub_render(data);
+    
     var wiki_re = /<wiki_s_3 ([^>]+)>((?:(?!<wiki_s_3 |<wiki_e_3>).)+)<wiki_e_3>/s;
     while(1) {
         if(!data.match(wiki_re)) {
@@ -1036,6 +1056,8 @@ function do_onmark_list_render(data) {
         });
     }
     
+    data = do_onmark_list_sub_render(data);
+    
     return data;
 }