잉여개발기 (SPDV) 5 лет назад
Родитель
Сommit
138a0be10d
4 измененных файлов с 16 добавлено и 16 удалено
  1. 6 3
      route/api_version.py
  2. 3 3
      route/tool/func.py
  3. 5 4
      route/tool/set_mark/namumark.py
  4. 2 6
      version.json

+ 6 - 3
route/api_version.py

@@ -11,18 +11,21 @@ def api_version_2(conn, r_ver, c_ver):
     up_data = up_data[0][0] if up_data and up_data[0][0] in ['stable', 'beta', 'dev'] else 'stable'
 
     try:
-        data = urllib.request.urlopen('https://raw.githubusercontent.com/2du/openNAMU/beta/version.json')
+        data = urllib.request.urlopen('https://raw.githubusercontent.com/2du/openNAMU/' + up_data + '/version.json')
     except:
         data = None
 
     if data and data.getcode() == 200:
         try:
             json_data = json.loads(data.read().decode())
-            if up_data in json_data:
-                n_ver = json_data[up_data]['r_ver']
         except:
             pass
 
+        if 'beta' in json_data:
+            n_ver = json_data['beta']['r_ver']
+        elif 'master' in json_data:
+            n_ver = json_data['master']['r_ver']
+
     json_data = { "version" : r_ver, "db_version" : c_ver, "lastest_version" : n_ver  }
 
     return flask.jsonify(json_data)

+ 3 - 3
route/tool/func.py

@@ -264,15 +264,15 @@ def update(ver_num, set_data):
                 get_data[2]
             ])
 
-    if ver_num < 3202200:
-        curs.execute(db_change('delete from cache_data'))
-
     if ver_num < 3202400:
         curs.execute(db_change("select data from other where name = 'update'"))
         get_data = curs.fetchall()
         if get_data and get_data[0][0] == 'master':
             curs.execute(db_change("update other set data = 'beta' where name = 'update'"), [])
 
+    if ver_num < 3202500:
+        curs.execute(db_change('delete from cache_data'))
+
     conn.commit()
 
     print('Update pass')

+ 5 - 4
route/tool/set_mark/namumark.py

@@ -693,14 +693,15 @@ def namumark(conn, data, title, include_num):
         other_link = return_link[1]
 
         backlink += [[title, main_link, 'redirect']]
-
+        
         plus_data += '' + \
             'var get_link = window.location.search.match(/(?:\?|&)from=([^&]+)/);\n' + \
-            'if(!get_link) {\n' + \
-                'window.location.href = "/w/' + tool.url_pas(main_link) + other_link + '?from=' + tool.url_pas(title) + '";\n' + \
+            'var get_link_2 = window.location.pathname.match(/^\/w\//);' + \
+            'if(!get_link && get_link_2) {\n' + \
+                'window.location.href = "/w/' + tool.url_pas(main_link) + '?from=' + tool.url_pas(title) + other_link + '";\n' + \
             '}\n' + \
         ''
-        data = redirect_re.sub('', data, 1)
+        data = redirect_re.sub('\nredirect to ' + html.escape(main_link) + other_link, data, 1)
 
     no_toc_re = re.compile(r'\[(?:목차|toc)\((?:no)\)\]\n', re.I)
     toc_re = re.compile(r'\[(?:목차|toc)\]', re.I)

+ 2 - 6
version.json

@@ -1,11 +1,7 @@
 {
     "beta" : {
-        "r_ver" : "v3.2.0-beta-25 (v3.2.0-dev-202008013-04)",
-        "c_ver" : "3202400",
-        "s_ver" : "9"
-    }, "stable" : {
-        "r_ver" : "v3.2.0-stable-11",
-        "c_ver" : "3200900",
+        "r_ver" : "v3.2.0-beta-25 (v3.2.0-dev-202008016-01)",
+        "c_ver" : "3202500",
         "s_ver" : "9"
     }
 }