surplus-dev 4 anni fa
parent
commit
91d261052c
3 ha cambiato i file con 34 aggiunte e 43 eliminazioni
  1. 1 3
      app.py
  2. 5 5
      route/filter_inter_wiki.py
  3. 28 35
      route/list_old_page.py

+ 1 - 3
app.py

@@ -388,9 +388,7 @@ app.route('/extension_filter/add', methods = ['POST', 'GET'], defaults = { 'tool
 
 # Func-list
 # /list/document/old
-@app.route('/old_page')
-def list_old_page():
-    return list_old_page_2(load_db.db_get())
+app.route('/old_page')(list_old_page)
 
 # /list/document/acl
 @app.route('/acl_list')

+ 5 - 5
route/filter_inter_wiki.py

@@ -34,10 +34,6 @@ def inter_wiki(tool):
         elif tool == 'file_filter':
             title = load_lang('file_filter_list')
 
-            curs.execute(db_change("select html, plus, plus_t from html_filter where kind = 'file'"))
-        elif tool == 'file_filter':
-            title = load_lang('file_filter_list')
-
             curs.execute(db_change("select html, plus, plus_t from html_filter where kind = 'file'"))
         elif tool == 'image_license':
             title = load_lang('image_license_list')
@@ -69,7 +65,11 @@ def inter_wiki(tool):
             else:
                 div += '<td>' + html.escape(data[1]) + '</td>'
 
-            div += '<td>' + html.escape(data[2]) + '</td>'
+            if tool == 'inter_wiki':
+                div += '<td>' + data[2] + '</td>'
+            else:
+                div += '<td>' + html.escape(data[2]) + '</td>'
+            
             div += '</tr>'
 
         div += '</table>'

+ 28 - 35
route/list_old_page.py

@@ -1,37 +1,30 @@
 from .tool.func import *
 
-def list_old_page_2(conn):
-    curs = conn.cursor()
-
-    num = int(number_check(flask.request.args.get('num', '1')))
-    if num * 50 > 0:
-        sql_num = num * 50 - 50
-    else:
-        sql_num = 0
-
-    curs.execute(db_change('select data from other where name = "count_all_title"'))
-    if int(curs.fetchall()[0][0]) > 30000:
-        return re_error('/error/25')
-
-    div = '<ul class="inside_ul">'
-
-    curs.execute(db_change('' + \
-        'select title, date from history h ' + \
-        "where title not like 'user:%' and title not like 'category:%' and title not 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 title ' + \
-        'order by date asc ' + \
-        'limit ?, 50' + \
-    ''), [sql_num])
-    n_list = curs.fetchall()
-    for data in n_list:
-        div += '<li><a href="/w/' + url_pas(data[0]) + '">' + html.escape(data[0]) + '</a> (' + re.sub(r' .*$', '', data[1]) + ')</li>'
-
-    div += '</ul>' + next_fix('/old_page?num=', num, n_list)
-
-    return easy_minify(flask.render_template(skin_check(),
-        imp = [load_lang('old_page'), wiki_set(), wiki_custom(), wiki_css([0, 0])],
-        data = div,
-        menu = [['other', load_lang('return')]]
-    ))
+def list_old_page():
+    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"'))
+        if int(curs.fetchall()[0][0]) > 30000:
+            return re_error('/error/25')
+        
+        div = '<ul class="inside_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])
+        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)
+        
+        return easy_minify(flask.render_template(skin_check(),
+            imp = [load_lang('old_page'), wiki_set(), wiki_custom(), wiki_css([0, 0])],
+            data = div,
+            menu = [['other', load_lang('return')]]
+        ))