浏览代码

스킨별 전역 세팅 변경

Surplus_Up (2DU) 7 年之前
父节点
当前提交
7fce024fff
共有 3 个文件被更改,包括 85 次插入43 次删除
  1. 3 3
      app.py
  2. 34 20
      route/setting.py
  3. 48 20
      route/tool/func.py

+ 3 - 3
app.py

@@ -8,8 +8,8 @@ for i_data in os.listdir("route"):
 
         exec("from route." + f_src + " import *")
 
-r_ver = 'v3.1.0-master-05'
-c_ver = '400000'
+r_ver = 'v3.1.0-master-06'
+c_ver = '400001'
 s_ver = '1'
 
 print('Version : ' + r_ver)
@@ -147,7 +147,7 @@ if setup_tool != 0:
     create_data['rb'] = ['block', 'end', 'today', 'blocker', 'why', 'band']
     create_data['back'] = ['title', 'link', 'type']
     create_data['custom'] = ['user', 'css']
-    create_data['other'] = ['name', 'data']
+    create_data['other'] = ['name', 'data', 'coverage']
     create_data['alist'] = ['name', 'acl']
     create_data['re_admin'] = ['who', 'what', 'time']
     create_data['alarm'] = ['name', 'data', 'date']

+ 34 - 20
route/setting.py

@@ -196,8 +196,8 @@ def setting_2(conn, num):
             ))
     elif num == 2:
         if flask.request.method == 'POST':
-            curs.execute("update other set data = ? where name = ?", [flask.request.form.get('contract', None), 'contract'])
-            curs.execute("update other set data = ? where name = ?", [flask.request.form.get('no_login_warring', None), 'no_login_warring'])
+            curs.execute("update other set data = ? where name = ?", [flask.request.form.get('contract', ''), 'contract'])
+            curs.execute("update other set data = ? where name = ?", [flask.request.form.get('no_login_warring', ''), 'no_login_warring'])
             conn.commit()
             
             admin_check(None, 'edit_set')
@@ -248,30 +248,44 @@ def setting_2(conn, num):
             if num == 4:
                 info_d = 'body'
                 end_r = '4'
+                coverage = ''
             else:
                 info_d = 'head'
                 end_r = '3'
-            
-            curs.execute("select name from other where name = ?", [info_d])
+                if flask.request.args.get('skin', '') == '':
+                    coverage = ''
+                else:
+                    coverage = flask.request.args.get('skin', '')
+                
+            curs.execute("select name from other where name = ? and coverage = ?", [info_d, coverage])
             if curs.fetchall():
-                curs.execute("update other set data = ? where name = ?", [flask.request.form.get('content', ''), info_d])
+                curs.execute("update other set data = ?, coverage = ? where name = ?", [
+                    flask.request.form.get('content', ''),
+                    coverage,
+                    info_d
+                ])
             else:
-                curs.execute("insert into other (name, data) values (?, ?)", [info_d, flask.request.form.get('content', '')])
+                curs.execute("insert into other (name, data, coverage) values (?, ?, ?)", [info_d, flask.request.form.get('content', ''), coverage])
             
             conn.commit()
 
             admin_check(None, 'edit_set')
 
-            return redirect('/setting/' + end_r)
+            return redirect('/setting/' + end_r + '?skin=' + flask.request.args.get('skin', ''))
         else:
             if num == 4:
                 curs.execute("select data from other where name = 'body'")
                 title = '_body'
                 start = ''
             else:
-                curs.execute("select data from other where name = 'head'")
+                curs.execute("select data from other where name = 'head' and coverage = ?", [flask.request.args.get('skin', '')])
                 title = '_head'
-                start = '<span>&lt;style&gt;CSS&lt;/style&gt;<br>&lt;script&gt;JS&lt;/script&gt;</span><hr class=\"main_hr\">'
+                start = '<a href="?">(' + load_lang('all') + ')</a> ' + \
+                        ' '.join(['<a href="?skin=' + i + '">(' + i + ')</a>' for i in load_skin('', 1)]) + \
+                        '''
+                            <hr class=\"main_hr\">
+                            <span>&lt;style&gt;CSS&lt;/style&gt;<br>&lt;script&gt;JS&lt;/script&gt;</span><hr class=\"main_hr\">
+                        '''
                 
             head = curs.fetchall()
             if head:
@@ -281,28 +295,28 @@ def setting_2(conn, num):
 
             return easy_minify(flask.render_template(skin_check(), 
                 imp = [load_lang(data = 'main' + title, safe = 1), wiki_set(), custom(), other2([0, 0])],
-                data =  '''
-                        <form method="post">
-                            ''' + start + '''
-                            <textarea rows="25" name="content">''' + html.escape(data) + '''</textarea>
-                            <hr class=\"main_hr\">
-                            <button id="save" type="submit">''' + load_lang('save') + '''</button>
-                        </form>
-                        ''',
+                data = '''
+                    <form method="post">
+                        ''' + start + '''
+                        <textarea rows="25" name="content">''' + html.escape(data) + '''</textarea>
+                        <hr class=\"main_hr\">
+                        <button id="save" type="submit">''' + load_lang('save') + '''</button>
+                    </form>
+                ''',
                 menu = [['setting', load_lang('return')]]
             ))
     elif num == 5:
         if flask.request.method == 'POST':
             curs.execute("select name from other where name = 'robot'")
             if curs.fetchall():
-                curs.execute("update other set data = ? where name = 'robot'", [flask.request.form.get('content', None)])
+                curs.execute("update other set data = ? where name = 'robot'", [flask.request.form.get('content', '')])
             else:
-                curs.execute("insert into other (name, data) values ('robot', ?)", [flask.request.form.get('content', None)])
+                curs.execute("insert into other (name, data) values ('robot', ?)", [flask.request.form.get('content', '')])
             
             conn.commit()
             
             fw = open('./robots.txt', 'w')
-            fw.write(re.sub('\r\n', '\n', flask.request.form.get('content', None)))
+            fw.write(re.sub('\r\n', '\n', flask.request.form.get('content', '')))
             fw.close()
             
             admin_check(None, 'edit_set')

+ 48 - 20
route/tool/func.py

@@ -379,22 +379,25 @@ def ip_warring():
 
     return text_data
 
-def skin_check():
-    skin = './views/neo_yousoro/'
+def skin_check(set_n = 0):
+    skin = 'neo_yousoro'
 
     curs.execute('select data from other where name = "skin"')
     skin_exist = curs.fetchall()
     if skin_exist and skin_exist[0][0] != '':
         if os.path.exists(os.path.abspath('./views/' + skin_exist[0][0] + '/index.html')) == 1:
-            skin = './views/' + skin_exist[0][0] + '/'
+            skin = skin_exist[0][0]
     
     curs.execute('select data from user_set where name = "skin" and id = ?', [ip_check()])
     skin_exist = curs.fetchall()
     if skin_exist and skin_exist[0][0] != '':
         if os.path.exists(os.path.abspath('./views/' + skin_exist[0][0] + '/index.html')) == 1:
-            skin = './views/' + skin_exist[0][0] + '/'
+            skin = skin_exist[0][0]
 
-    return skin + 'index.html'
+    if set_n == 0:
+        return './views/' + skin + '/index.html'
+    else:
+        return skin
 
 def next_fix(link, num, page, end = 50):
     list_data = ''
@@ -459,12 +462,18 @@ def wiki_set(num = 1):
         else:
             data_list += [data_list[0]]
             
-        curs.execute("select data from other where name = 'head'")
+        curs.execute("select data from other where name = 'head' and coverage = ?", [skin_check(1)])
         db_data = curs.fetchall()
         if db_data and db_data[0][0] != '':
             data_list += [db_data[0][0]]
         else:
-            data_list += ['']
+            curs.execute("select data from other where name = 'head' and coverage = ''")
+            db_data = curs.fetchall()
+            if db_data and db_data[0][0] != '':
+                data_list += [db_data[0][0]]
+            else:
+                data_list += ['']
+
         return data_list
 
     if num == 2:
@@ -631,8 +640,9 @@ def custom():
 
     return ['', '', user_icon, user_head, email, user_name]
 
-def load_skin(data = ''):
+def load_skin(data = '', set_n = 0):
     div2 = ''
+    div3 = []
     system_file = ['main_css', 'easter_egg.html']
 
     if data == '':
@@ -647,19 +657,37 @@ def load_skin(data = ''):
             if not data:
                 data = [['neo_yousoro']]
 
-        for skin_data in os.listdir(os.path.abspath('views')):
-            if not skin_data in system_file:
-                if data[0][0] == skin_data:
-                    div2 = '<option value="' + skin_data + '">' + skin_data + '</option>' + div2
-                else:
-                    div2 += '<option value="' + skin_data + '">' + skin_data + '</option>'
+        if set_n == 0:
+            for skin_data in os.listdir(os.path.abspath('views')):
+                if not skin_data in system_file:
+                    if data[0][0] == skin_data:
+                        div2 = '<option value="' + skin_data + '">' + skin_data + '</option>' + div2
+                    else:
+                        div2 += '<option value="' + skin_data + '">' + skin_data + '</option>'
+        else:
+            div2 = []
+            for skin_data in os.listdir(os.path.abspath('views')):
+                if not skin_data in system_file:
+                    if data[0][0] == skin_data:
+                        div2 = [skin_data] + div2
+                    else:
+                        div2 += [skin_data]
     else:
-        for skin_data in os.listdir(os.path.abspath('views')):
-            if not skin_data in system_file:
-                if data == skin_data:
-                    div2 = '<option value="' + skin_data + '">' + skin_data + '</option>' + div2
-                else:
-                    div2 += '<option value="' + skin_data + '">' + skin_data + '</option>'
+        if set_n == 0:
+            for skin_data in os.listdir(os.path.abspath('views')):
+                if not skin_data in system_file:
+                    if data == skin_data:
+                        div2 = '<option value="' + skin_data + '">' + skin_data + '</option>' + div2
+                    else:
+                        div2 += '<option value="' + skin_data + '">' + skin_data + '</option>'
+        else:
+            div2 = []
+            for skin_data in os.listdir(os.path.abspath('views')):
+                if not skin_data in system_file:
+                    if data == skin_data:
+                        div2 = [skin_data] + div2
+                    else:
+                        div2 += [skin_data]
 
     return div2