Browse Source

임시로 추가

잉여개발기 (SPDV) 2 years ago
parent
commit
c37ead7838
4 changed files with 22 additions and 14 deletions
  1. 6 1
      app.py
  2. 6 3
      route/filter_all.py
  3. 9 10
      route/filter_all_add.py
  4. 1 0
      route/main_tool_admin.py

+ 6 - 1
app.py

@@ -273,9 +273,14 @@ app.route('/filter/inter_wiki/add', methods = ['POST', 'GET'], defaults = { 'too
 app.route('/filter/inter_wiki/add/<everything:name>', methods = ['POST', 'GET'], defaults = { 'tool' : 'inter_wiki' })(filter_all_add)
 app.route('/filter/inter_wiki/del/<everything:name>', defaults = { 'tool' : 'inter_wiki' })(filter_all_delete)
 
+app.route('/filter/outer_link', defaults = { 'tool' : 'outer_link' })(filter_all)
+app.route('/filter/outer_link/add', methods = ['POST', 'GET'], defaults = { 'tool' : 'outer_link' })(filter_all_add)
+app.route('/filter/outer_link/add/<everything:name>', methods = ['POST', 'GET'], defaults = { 'tool' : 'outer_link' })(filter_all_add)
+app.route('/filter/outer_link/del/<everything:name>', defaults = { 'tool' : 'outer_link' })(filter_all_delete)
+
 app.route('/filter/document', defaults = { 'tool' : 'document' })(filter_all)
-app.route('/filter/document/add/<everything:name>', methods = ['POST', 'GET'], defaults = { 'tool' : 'document' })(filter_all_add)
 app.route('/filter/document/add', methods = ['POST', 'GET'], defaults = { 'tool' : 'document' })(filter_all_add)
+app.route('/filter/document/add/<everything:name>', methods = ['POST', 'GET'], defaults = { 'tool' : 'document' })(filter_all_add)
 app.route('/filter/document/del/<everything:name>', defaults = { 'tool' : 'document' })(filter_all_delete)
 
 app.route('/filter/edit_top', defaults = { 'tool' : 'edit_top' })(filter_all)

+ 6 - 3
route/filter_all.py

@@ -39,6 +39,9 @@ def filter_all(tool):
         elif tool == 'document':
             title = load_lang('document_filter_list')
             curs.execute(db_change("select html, plus, plus_t from html_filter where kind = 'document'"))
+        elif tool == 'outer_link':
+            title = load_lang('outer_link_filter_list')
+            curs.execute(db_change("select html, plus, plus_t from html_filter where kind = 'outer_link'"))
         else:
             title = load_lang('edit_tool_list')
             curs.execute(db_change("select html, plus, plus_t from html_filter where kind = 'edit_top'"))
@@ -50,14 +53,14 @@ def filter_all(tool):
 
             div += html.escape(data[0])
             if admin == 1:
-                if tool in ('inter_wiki', 'edit_filter', 'document'):
+                if tool in ('inter_wiki', 'outer_link', 'edit_filter', 'document'):
                     div += ' <a href="/filter/' + tool + '/add/' + url_pas(data[0]) + '">(' + load_lang('edit') + ')</a>'
                     
                 div += ' <a href="/filter/' + tool + '/del/' + url_pas(data[0]) + '">(' + load_lang('delete') + ')</a>'
 
             div += '</td>'
 
-            if tool == 'inter_wiki':
+            if tool in ('inter_wiki', 'outer_link'):
                 div += '<td><a class="opennamu_link_out" href="' + html.escape(data[1]) + '">' + html.escape(data[1]) + '</a></td>'
                 div += '<td>' + data[2] + '</td>'
             else:
@@ -70,7 +73,7 @@ def filter_all(tool):
 
         if admin == 1:
             div += '<hr class="main_hr">'
-            div += '<a href="/' + tool + '/add">(' + load_lang('add') + ')</a>'
+            div += '<a href="/filter/' + tool + '/add">(' + load_lang('add') + ')</a>'
 
         return easy_minify(flask.render_template(skin_check(),
             imp = [title, wiki_set(), wiki_custom(), wiki_css([0, 0])],

+ 9 - 10
route/filter_all_add.py

@@ -12,17 +12,14 @@ def filter_all_add(tool, name = None):
                 return re_error('/error/3')
 
             title = flask.request.form.get('title', 'test')
-            if tool == 'inter_wiki':
+            if tool in ('inter_wiki', 'outer_link'):
                 link = flask.request.form.get('link', 'test')
                 icon = flask.request.form.get('icon', '')
 
-                curs.execute(db_change("delete from html_filter where html = ? and kind = 'inter_wiki'"), [title])
-                curs.execute(db_change('insert into html_filter (html, plus, plus_t, kind) values (?, ?, ?, "inter_wiki")'), [title, link, icon])
-                admin_check(None, 'inter_wiki_plus')
+                curs.execute(db_change("delete from html_filter where html = ? and kind = ?"), [title, tool])
+                curs.execute(db_change('insert into html_filter (html, plus, plus_t, kind) values (?, ?, ?, ?)'), [title, link, icon, tool])
+                admin_check(None, tool + ' edit')
             elif tool == 'edit_filter':
-                if admin_check(None, 'edit_filter edit') != 1:
-                    return re_error('/error/3')
-
                 sec = flask.request.form.get('second', '0')
                 end = 'X' if sec == '0' else sec
 
@@ -34,6 +31,7 @@ def filter_all_add(tool, name = None):
                 
                 curs.execute(db_change("delete from html_filter where html = ? and kind = 'regex_filter'"), [name])
                 curs.execute(db_change("insert into html_filter (html, plus, plus_t, kind) values (?, ?, ?, 'regex_filter')"), [name, content, end])
+                admin_check(None, 'edit_filter edit')
             elif tool == 'document':
                 post_name = flask.request.form.get('name', '')
                 if post_name == '':
@@ -47,6 +45,7 @@ def filter_all_add(tool, name = None):
                     return re_error('/error/23')
                 
                 curs.execute(db_change('insert into html_filter (html, kind, plus, plus_t) values (?, "document", ?, ?)'), [post_name, post_regex, post_acl])
+                admin_check(None, 'document_filter edit')
             else:
                 plus_d = ''
                 if tool == 'name_filter':
@@ -92,14 +91,14 @@ def filter_all_add(tool, name = None):
             stat = 'disabled' if admin_check() != 1 else ''
             name = name if name else ''
 
-            if tool == 'inter_wiki':
+            if tool in ('inter_wiki', 'outer_link'):
                 value = ['', '', '']
                 if name != '':
-                    curs.execute(db_change("select html, plus, plus_t from html_filter where html = ? and kind = 'inter_wiki'"), [name])
+                    curs.execute(db_change("select html, plus, plus_t from html_filter where html = ? and kind = ?"), [name, tool])
                     exist = curs.fetchall()
                     value = exist[0] if exist else value
 
-                title = load_lang('interwiki_add')
+                title = load_lang('interwiki_add') if tool == 'inter_wiki' else load_lang('outer_link_add')
                 form_data = '''
                     ''' + load_lang('name') + '''
                     <hr class="main_hr">

+ 1 - 0
route/main_tool_admin.py

@@ -34,6 +34,7 @@ def main_tool_admin():
                     <li><a href="/filter/file_filter">''' + load_lang('file_filter_list') + '''</a></li>
                     <li><a href="/filter/extension_filter">''' + load_lang('extension_filter_list') + '''</a></li>
                     <li><a href="/filter/document">''' + load_lang('document_filter_list') + '''</a></li>
+                    <li><a href="/filter/outer_link">''' + load_lang('outer_link_filter_list') + '''</a> (''' + load_lang('beta') + ''')
                 </ul>
                 <h3>''' + load_lang('server') + '''</h2>
                 <ul class="opennamu_ul">