Răsfoiți Sursa

편집 요청 기능 제거

코드 전반적으로 변경할 예정 현재 구조로는 너무 어설프며 코드 안정성을 떨어트림
Surplus_Up (2DU) 6 ani în urmă
părinte
comite
0513ea7080
7 a modificat fișierele cu 38 adăugiri și 237 ștergeri
  1. 0 4
      app.py
  2. 24 27
      route/edit.py
  3. 0 174
      route/edit_req.py
  4. 3 11
      route/recent_changes.py
  5. 0 5
      route/setting.py
  6. 2 7
      route/tool/func.py
  7. 9 9
      views/main_css/js/do_editor.js

+ 0 - 4
app.py

@@ -462,10 +462,6 @@ def edit_revert(name = None):
 def edit(name = 'Test'):
     return edit_2(conn, name)
 
-@app.route('/edit_req/<everything:name>', methods=['POST', 'GET'])
-def edit_req(name = 'Test'):
-    return edit_req_2(conn, name)
-
 @app.route('/backlink_reset/<everything:name>')
 def edit_backlink_reset(name = 'Test'):
     return edit_backlink_reset_2(conn, name)

+ 24 - 27
route/edit.py

@@ -8,11 +8,8 @@ def edit_2(conn, name):
     if section:
         section = int(number_check(section))
 
-    curs.execute(db_change("select data from data where title = ?"), [name])
-    old = curs.fetchall()
-
     if acl_check(name) == 1:
-        return redirect('/edit_req/' + url_pas(name))
+        return re_error('/ban')
     
     if flask.request.method == 'POST':
         if captcha_post(flask.request.form.get('g-recaptcha-response', flask.request.form.get('g-recaptcha', ''))) == 1:
@@ -38,6 +35,8 @@ def edit_2(conn, name):
         if copyright_checkbox_text_d and copyright_checkbox_text_d[0][0] != '' and flask.request.form.get('copyright_agreement', '') != 'yes':
             return re_error('/error/29')
         
+        curs.execute(db_change("select data from data where title = ?"), [name])
+        old = curs.fetchall()
         if old:  
             o_data = old[0][0].replace('\r\n', '\n')
 
@@ -51,7 +50,7 @@ def edit_2(conn, name):
                         self.counter -= 1
 
                         if self.counter == 0:
-                            return '\n' + self.change
+                            return '\n' + self.change + '\n'
                         else:
                             return '\n' + match[1]
 
@@ -107,10 +106,11 @@ def edit_2(conn, name):
         
         return redirect('/w/' + url_pas(name))
     else:
+        curs.execute(db_change("select data from data where title = ?"), [name])
+        old = curs.fetchall()
         if old:
             if section:
                 data = html.escape('\n' + old[0][0].replace('\r\n', '\n'))
-                
                 data = re.sub(r'\n(?P<in>={1,6})', '<br>\g<in>', data)
 
                 section_data = re.findall(r'<br>((?:(?:(?!<br>).)*\n*)*)', data)
@@ -122,21 +122,20 @@ def edit_2(conn, name):
                 data = old[0][0].replace('\r\n', '\n')
         else:
             data = ''
-
+            
         data_old = data
 
-        if section:
-            get_name = '' + \
-                '<a href="/edit_filter">(' + load_lang('edit_filter_rule') + ')</a>' + \
-                '<hr class=\"main_hr\">' + \
-            ''
-        else:
-            get_name = '' + \
+        get_name = ''
+        if not section and not flask.request.args.get('plus', None):
+            get_name += '' + \
                 '<a href="/manager/15?plus=' + url_pas(name) + '">(' + load_lang('load') + ')</a> ' + \
-                '<a href="/edit_filter">(' + load_lang('edit_filter_rule') + ')</a>' + \
-                '<hr class=\"main_hr\">' + \
             ''
             
+        get_name += '' + \
+            '<a href="/edit_filter">(' + load_lang('edit_filter_rule') + ')</a>' + \
+            '<hr class=\"main_hr\">' + \
+        ''
+            
         if flask.request.args.get('plus', None):
             curs.execute(db_change("select data from data where title = ?"), [flask.request.args.get('plus', 'test')])
             get_data = curs.fetchall()
@@ -153,10 +152,7 @@ def edit_2(conn, name):
 
         curs.execute(db_change('select data from other where name = "edit_bottom_text"'))
         sql_d = curs.fetchall()
-        if sql_d and sql_d[0][0] != '':
-            b_text = '<hr class=\"main_hr\">' + sql_d[0][0]
-        else:
-            b_text = ''
+        b_text = ('<hr class=\"main_hr\">' + sql_d[0][0]) if sql_d and sql_d[0][0] != '' else ''
         
         curs.execute(db_change('select data from other where name = "copyright_checkbox_text"'))
         sql_d = curs.fetchall()
@@ -171,19 +167,20 @@ def edit_2(conn, name):
 
         curs.execute(db_change('select data from other where name = "edit_help"'))
         sql_d = curs.fetchall()
-        if sql_d and sql_d[0][0] != '':
-            p_text = sql_d[0][0]
-        else:
-            p_text = load_lang('defalut_edit_help')
+        p_text = sql_d[0][0] if sql_d and sql_d[0][0] != '' else load_lang('defalut_edit_help')
 
-        data = re.sub(r'\n$', '', data)
-        data_old = re.sub(r'\n$', '', data_old)
+        data = re.sub(r'\n+$', '', data)
+        data_old = re.sub(r'\n+$', '', data_old)
 
         return easy_minify(flask.render_template(skin_check(), 
             imp = [name, wiki_set(), custom(), other2([' (' + sub + ')', 0])],
             data =  get_name + '''
                 <form method="post">
-                    <script>do_paste_image();</script>
+                    <script>
+                        do_paste_image();
+                        do_not_out();
+                    </script>
+                    <div class="get_is_recently"></div>
                     ''' + edit_button() + '''
                     <textarea id="content" class="content" placeholder="''' + p_text + '''" name="content">''' + html.escape(data) + '''</textarea>
                     <textarea id="origin" name="o_content">''' + html.escape(data_old) + '''</textarea>

+ 0 - 174
route/edit_req.py

@@ -1,174 +0,0 @@
-from .tool.func import *
-
-def edit_req_2(conn, name):
-    curs = conn.cursor()
-
-    ip = ip_check()
-    get_ver = flask.request.args.get('r', None)
-    if get_ver:
-        section = None
-    else:
-        section = flask.request.args.get('section', None)
-
-    if acl_check(name) == 1:
-        if acl_check(name, 'edit_req') == 1 or re.search(r'^user:', name) or get_ver:
-            return re_error('/ban')
-    else:
-        if not get_ver:
-            return redirect('/edit/' + url_pas(name))
-        else:
-            get_ver = int(number_check(get_ver))
-
-    if not get_ver:
-        curs.execute(db_change("select data from data where title = ?"), [name])
-        old = curs.fetchall()
-        if not old:
-            return redirect('/ban')
-    else:
-        curs.execute(db_change("select data, send, ip, date from history where title = ? and id = ? and type = 'req'"), [name, str(get_ver)])
-        old = curs.fetchall()
-        if not old:
-            return redirect('/w/' + url_pas(name))
-
-    if flask.request.method == 'POST':
-        if captcha_post(flask.request.form.get('g-recaptcha-response', flask.request.form.get('g-recaptcha', ''))) == 1:
-            return re_error('/error/13')
-        else:
-            captcha_post('', 0)
-
-        if slow_edit_check() == 1:
-            return re_error('/error/24')
-
-        today = get_time()
-        if get_ver:
-            content = old[0][0]
-        else:
-            content = flask.request.form.get('content', '')
-
-            if flask.request.form.get('otent', '') == content:
-                return redirect('/w/' + url_pas(name))
-
-            if edit_filter_do(content) == 1:
-                return re_error('/error/21')
-
-        curs.execute(db_change('select data from other where name = "copyright_checkbox_text"'))
-        copyright_checkbox_text_d = curs.fetchall()
-        if copyright_checkbox_text_d and copyright_checkbox_text_d[0][0] != '' and flask.request.form.get('copyright_agreement', '') != 'yes':
-            return re_error('/error/29')
-
-        if old:
-            leng = leng_check(len(flask.request.form.get('otent', '')), len(content))
-
-            if section:
-                content = old[0][0].replace(
-                    flask.request.form.get('otent', '').replace('\r\n', '\n'), 
-                    content.replace('\r\n', '\n')
-                )
-        else:
-            leng = '+' + str(len(content))
-
-        if get_ver:
-            if old:
-                curs.execute(db_change("update data set data = ? where title = ?"), [content, name])
-            else:
-                curs.execute(db_change("insert into data (title, data) values (?, ?)"), [name, content])
-
-                curs.execute(db_change('select data from other where name = "count_all_title"'))
-                curs.execute(db_change("update other set data = ? where name = 'count_all_title'"), [str(int(curs.fetchall()[0][0]) + 1)])
-
-            curs.execute(db_change("select user from scan where title = ? and type = ''"), [name])
-            for scan_user in curs.fetchall():
-                curs.execute(db_change("insert into alarm (name, data, date) values (?, ?, ?)"), [
-                    scan_user[0],
-                    ip + ' | <a href="/w/' + url_pas(name) + '">' + name + '</a> | Edit',
-                    today
-                ])
-
-            curs.execute(db_change("update history set type = '', send = ? where title = ? and id = ? and ip = ? and date = ? and type = 'req'"), [
-                old[0][1] + ' (' + ip + ' pass)',
-                name,
-                str(get_ver),
-                old[0][2],
-                old[0][3]
-            ])
-
-            curs.execute(db_change("delete from back where link = ?"), [name])
-            curs.execute(db_change("delete from back where title = ? and type = 'no'"), [name])
-
-            render_set(
-                title = name,
-                data = content,
-                num = 1
-            )
-        else:
-            history_plus(
-                name,
-                content,
-                today,
-                ip,
-                flask.request.form.get('send', ''),
-                leng,
-                '',
-                'req'
-            )
-
-        conn.commit()
-
-        if get_ver:
-            return redirect('/w/' + url_pas(name))
-        else:
-            return redirect('/recent_changes?set=req')
-    else:
-        if old:
-            data = old[0][0]
-        else:
-            data = ''
-
-        data_old = data
-        get_name = ''
-
-        save_button = load_lang('edit_req') if not get_ver else load_lang('accept_edit_request')
-        sub = load_lang('edit_req')
-        disable = '' if not get_ver else 'disabled'
-
-        curs.execute(db_change('select data from other where name = "edit_bottom_text"'))
-        sql_d = curs.fetchall()
-        if sql_d and sql_d[0][0] != '':
-            b_text = '<hr class=\"main_hr\">' + sql_d[0][0]
-        else:
-            b_text = ''
-            
-        cccb_text = ''
-        curs.execute(db_change('select data from other where name = "copyright_checkbox_text"'))
-        sql_d = curs.fetchall()
-        if sql_d and sql_d[0][0] != '':
-            cccb_text = '<hr class=\"wmain_hr\"><input type="checkbox" name="copyright_agreement" value="yes">' + sql_d[0][0] + '<hr class=\"main_hr\">'
-
-        curs.execute(db_change('select data from other where name = "edit_help"'))
-        sql_d = curs.fetchall()
-        if sql_d and sql_d[0][0] != '':
-            p_text = sql_d[0][0]
-        else:
-            p_text = load_lang('defalut_edit_help')
-
-        return easy_minify(flask.render_template(skin_check(),
-            imp = [name, wiki_set(), custom(), other2([' (' + sub + ')', 0])],
-            data =  get_name + '''
-                <form method="post">
-                    <script>do_stop_exit();</script>
-                    ''' + edit_button() + '''
-                    <textarea rows="25" ''' + disable + ''' id="content" placeholder="''' + p_text + '''" name="content">''' + html.escape(re.sub('\n$', '', data)) + '''</textarea>
-                    <textarea id="origin" name="otent">''' + html.escape(re.sub('\n$', '', data_old)) + '''</textarea>
-                    <hr class=\"main_hr\">
-                    <input ''' + disable + ''' placeholder="''' + load_lang('why') + '''" name="send" type="text">
-                    <hr class=\"main_hr\">
-                    ''' + captcha_get() + ip_warring() + cccb_text + '''
-                    <button id="save" type="submit" onclick="go_save_zone = 1;">''' + save_button + '''</button>
-                    <button id="preview" type="button" onclick="load_preview(\'''' + url_pas(name) + '\')">' + load_lang('preview') + '''</button>
-                </form>
-                ''' + b_text + '''
-                <hr class=\"main_hr\">
-                <div id="see_preview"></div>
-            ''',
-            menu = [['w/' + url_pas(name), load_lang('return')]]
-        ))

+ 3 - 11
route/recent_changes.py

@@ -93,11 +93,7 @@ def recent_changes_2(conn, name, tool):
             else:
                 plus_sql = 'where '
 
-            if set_type == 'req':
-                plus_sql = 'where type = "req" '
-                sub += ' (' + load_lang('edit_req') + ')'
-            else:
-                plus_sql += 'type = "" '
+            plus_sql += 'type = "" '
             
             if set_type == 'user':
                 plus_sql = 'where title like "user:%" '
@@ -158,11 +154,8 @@ def recent_changes_2(conn, name, tool):
             if tool == 'history':
                 title = '<a href="/w/' + url_pas(name) + '?num=' + data[0] + '">r' + data[0] + '</a> '
             else:
-                if not name and set_type == 'req':
-                    title = '<a href="/edit_req/' + url_pas(data[1]) + '?r=' + data[0] + '">' + html.escape(data[1]) + ' (r' + data[0] + ')</a> '
-                else:
-                    title = '<a href="/w/' + url_pas(data[1]) + '">' + html.escape(data[1]) + '</a> '
-                    title += '<a href="/history/' + url_pas(data[1]) + '">(r' + data[0] + ')</a> '
+                title = '<a href="/w/' + url_pas(data[1]) + '">' + html.escape(data[1]) + '</a> '
+                title += '<a href="/history/' + url_pas(data[1]) + '">(r' + data[0] + ')</a> '
 
             div += '''
                 <tr ''' + style[0] + '''>
@@ -215,7 +208,6 @@ def recent_changes_2(conn, name, tool):
             div = '' + \
                 '<a href="?set=normal">(' + load_lang('normal') + ')</a> ' + \
                 '<a href="?set=user">(' + load_lang('user_document') + ')</a> ' + \
-                '<a href="?set=req">(' + load_lang('edit_req') + ')</a> ' + \
                 '<a href="?set=move">(' + load_lang('move') + ')</a> ' + \
                 '<a href="?set=delete">(' + load_lang('delete') + ')</a> ' + \
                 '<a href="?set=revert">(' + load_lang('revert') + ')</a>' + \

+ 0 - 5
route/setting.py

@@ -559,7 +559,6 @@ def setting_2(conn, num):
             2 : 'discussion',
             3 : 'upload_acl',
             4 : 'all_view_acl',
-            5 : 'edit_req_acl',
             6 : 'many_upload_acl'
         }
 
@@ -632,10 +631,6 @@ def setting_2(conn, num):
                         <hr class="main_hr">
                         <select ''' + disable + ''' name="all_view_acl">''' + acl_div[3] + '''</select>
                         <hr class="main_hr">
-                        <span>''' + load_lang('edit_req_acl') + '''</span>
-                        <hr class="main_hr">
-                        <select ''' + disable + ''' name="edit_req_acl">''' + acl_div[4] + '''</select>
-                        <hr class="main_hr">
                         <span>''' + load_lang('many_upload_acl') + '''</span>
                         <hr class="main_hr">
                         <select ''' + disable + ''' name="many_upload_acl">''' + acl_div[5] + '''</select>

+ 2 - 7
route/tool/func.py

@@ -871,9 +871,8 @@ def acl_check(name = 'test', tool = '', topic_num = '1'):
 
         return 1
 
-    if tool == '' or tool == 'edit_req':
-        if acl_check(name, 'render') == 1:
-            return 1
+    if tool == '' and acl_check(name, 'render') == 1:
+        return 1
     
     if tool == '':
         end = 3
@@ -918,10 +917,6 @@ def acl_check(name = 'test', tool = '', topic_num = '1'):
         elif tool == 'many_upload':
             curs.execute(db_change("select data from other where name = 'many_upload_acl'"))
 
-            num = 5
-        elif tool == 'edit_req':
-            curs.execute(db_change("select data from other where name = 'edit_req_acl'"))
-
             num = 5
         else:
             if i == 0:

+ 9 - 9
views/main_css/js/do_editor.js

@@ -17,23 +17,23 @@ function do_insert_data(name, data) {
 }
 
 function do_not_out() {
-    window.onbeforeunload = function() {
-        data = document.getElementById('content').value;
-        origin = document.getElementById('origin').value;
-        if(data !== origin) {
-            return '';
+    window.addEventListener('DOMContentLoaded', function() {
+        window.onbeforeunload = function() {
+            data = document.getElementById('content').value;
+            origin = document.getElementById('origin').value;
+            if(data !== origin) {
+                return '';
+            }
         }
-    }
+    });
 }
 
 function save_stop_exit() {
-    window.onbeforeunload = function () { }
+    window.onbeforeunload = function () {}
 }
 
 function do_paste_image() {
     window.addEventListener('DOMContentLoaded', function() {
-        do_not_out();
-
         if(
             document.cookie.match(main_css_regex_data('main_css_image_paste')) &&
             document.cookie.match(main_css_regex_data('main_css_image_paste'))[1] === '1'