Просмотр исходного кода

가로줄 제거 및 시스템 다크모드 설정 사용 기능

https://github.com/openNAMU/openNAMU/issues/1562
잉여개발기 (SPDV) 2 лет назад
Родитель
Сommit
21ee611465
8 измененных файлов с 35 добавлено и 57 удалено
  1. 0 6
      app.py
  2. 1 29
      emergency_tool.py
  3. 0 1
      route/main_sys_restart.py
  4. 0 1
      route/main_sys_shutdown.py
  5. 1 2
      route/main_sys_update.py
  6. 0 6
      route/tool/func.py
  7. 0 4
      test_tool.py
  8. 33 8
      views/ringo/js/skin_set.js

+ 0 - 6
app.py

@@ -176,8 +176,6 @@ with get_db_connect() as conn:
     sql_data = curs.fetchall()
     app.secret_key = sql_data[0][0]
 
-    print('----')
-
     # Init-DB_Data
     server_set = {}
     server_set_var = get_init_set_list()
@@ -216,13 +214,9 @@ with get_db_connect() as conn:
 
         server_set[i] = server_set_val
 
-    print('----')
-
     # Init-DB_care
     if data_db_set['type'] == 'sqlite':
         def back_up(back_time, back_up_where):
-            print('----')
-
             try:
                 shutil.copyfile(
                     data_db_set['name'] + '.db', 

+ 1 - 29
emergency_tool.py

@@ -25,11 +25,9 @@ if data_db_load == 'Y':
     conn = load_db.__enter__()
     curs = conn.cursor()
 else:
-    print('----')
     print('You can use [9, 11, 19]')
 
 # Main
-print('----')
 print('1. Backlink reset')
 print('2. reCAPTCHA delete')
 print('3. Ban delete')
@@ -54,17 +52,13 @@ print('22. Delete body top')
 print('23. Delete body bottom')
 print('24. SQLite to MySQL')
 
-print('----')
 what_i_do = input('Select : ')
-
 if what_i_do == '1':
-    print('----')
     go_num = input('All delete (Y) [Y, N] : ')
     if not go_num == 'N':
         curs.execute(db_change("delete from back"))
         conn.commit()
 
-    print('----')
     try:
         go_num = int(input('Count (100) : '))
     except ValueError:
@@ -72,7 +66,6 @@ if what_i_do == '1':
 
     num = 0
 
-    print('----')
     print('Load...')
 
     curs.execute(
@@ -86,11 +79,9 @@ if what_i_do == '1':
     )
     title = curs.fetchall()
 
-    print('----')
     print('Rest : ' + str(len(title)))
     print('Start : ' + title[0][0])
     time.sleep(1)
-    print('----')
 
     for name in title:
         num += 1
@@ -108,7 +99,6 @@ elif what_i_do == '2':
     curs.execute(db_change("delete from other where name = 'recaptcha'"))
     curs.execute(db_change("delete from other where name = 'sec_re'"))
 elif what_i_do == '3':
-    print('----')
     user_data = input('IP or Name : ')
 
     curs.execute(
@@ -128,34 +118,27 @@ elif what_i_do == '3':
 
     curs.execute(db_change("update rb set ongoing = '' where block = ?"), [user_data])
 elif what_i_do == '4':
-    print('----')
     host = input('Host : ')
 
     curs.execute(db_change("update other set data = ? where name = 'host'"), [host])
 elif what_i_do == '5':
-    print('----')
     port = int(input('Port : '))
 
     curs.execute(db_change("update other set data = ? where name = 'port'"), [port])
 elif what_i_do == '6':
-    print('----')
     skin = input('Skin name : ')
 
     curs.execute(db_change("update other set data = ? where name = 'skin'"), [skin])
 elif what_i_do == '7':
-    print('----')
     user_name = input('User name : ')
-
-    print('----')
     user_pw = input('User password : ')
-    hashed = pw_encode(user_pw)
 
+    hashed = pw_encode(user_pw)
     curs.execute(db_change("update user_set set data = ? where id = ? and name = 'pw'"), [
         hashed,
         user_name
     ])
 elif what_i_do == '8':
-    print('----')
     new_ver = input('Insert version (0000000) : ')
 
     if new_ver == '':
@@ -166,10 +149,7 @@ elif what_i_do == '9':
     if os.path.exists(os.path.join('data', 'set.json')):
         os.remove(os.path.join('data', 'set.json'))
 elif what_i_do == '10':
-    print('----')
     user_name = input('User name : ')
-
-    print('----')
     new_name = input('New name : ')
 
     curs.execute(
@@ -192,29 +172,24 @@ elif what_i_do == '12':
 elif what_i_do == '14':
     curs.execute(db_change('delete from other where name = "head"'))
 elif what_i_do == '15':
-    print('----')
     user_name = input('User name : ')
 
     curs.execute(db_change("update user_set set data = 'owner' where id = ? and name = 'acl'"), [user_name])
 elif what_i_do == '16':
-    print('----')
     user_name = input('User name : ')
 
     curs.execute(db_change('select data from user_set where name = "2fa" and id = ?'), [user_name])
     if curs.fetchall():
         curs.execute(db_change("update user_set set data = '' where name = '2fa' and id = ?"), [user_name])
 elif what_i_do == '17':
-    print('----')
     markup = input('Markup name : ')
 
     curs.execute(db_change("update other set data = ? where name = 'markup'"), [markup])
 elif what_i_do == '18':
-    print('----')
     wiki_access_password = input('Password : ')
 
     curs.execute(db_change("update other set data = ? where name = 'wiki_access_password'"), [wiki_access_password])
 elif what_i_do == '19':
-    print('----')
     up_data = input('Insert branch (beta) [stable, beta, dev] : ')
 
     if not up_data in ['stable', 'beta', 'dev']:
@@ -240,13 +215,11 @@ elif what_i_do == '19':
         else:
             print('Error : update failed')
 elif what_i_do == '20':
-    print('----')
     domain = input('Domain (EX : 2du.pythonanywhere.com) : ')
 
     curs.execute(db_change('delete from other where name = "domain"'))
     curs.execute(db_change('insert into other (name, data, coverage) values ("domain", ?, "")'), [domain])
 elif what_i_do == '21':
-    print('----')
     tls_v = input('TLS (http) [http, https] : ')
     if not tls_v in ['http', 'https']:
         tls_v = 'http'
@@ -288,5 +261,4 @@ if data_db_load == 'Y':
     except:
         pass
 
-print('----')
 print('OK')

+ 0 - 1
route/main_sys_restart.py

@@ -8,7 +8,6 @@ def main_sys_restart():
         if flask.request.method == 'POST':
             admin_check(None, 'restart')
 
-            print('----')
             print('Restart')
 
             python_ver = ''

+ 0 - 1
route/main_sys_shutdown.py

@@ -10,7 +10,6 @@ def main_sys_shutdown():
 
             conn.commit()
 
-            print('----')
             print('Shutdown')
 
             os._exit(0)

+ 1 - 2
route/main_sys_update.py

@@ -17,9 +17,8 @@ def main_sys_update():
             up_data = curs.fetchall()
             up_data = up_data[0][0] if up_data and up_data[0][0] in ['stable', 'beta', 'dev'] else 'stable'
 
-            print('----')
             print('Update')
-            print('----')
+            
             if platform.system() == 'Linux':
                 ok = []
 

+ 0 - 6
route/tool/func.py

@@ -19,7 +19,6 @@ with open('version.json', encoding = 'utf8') as file_data:
 print('Version : ' + version_list['beta']['r_ver'])
 print('DB set version : ' + version_list['beta']['c_ver'])
 print('Skin set version : ' + version_list['beta']['s_ver'])
-print('----')
 
 # Init-PIP_Install
 data_up_date = 1
@@ -67,8 +66,6 @@ if data_up_date == 1:
         print('Help : try "python3 -m pip install -r requirements.txt"')
 else:
     print('PIP check pass')
-    
-print('----')
 
 # Init-Load
 from .func_tool import *
@@ -352,9 +349,7 @@ def update(ver_num, set_data):
     with get_db_connect() as conn:
         curs = conn.cursor()
 
-        print('----')
         # 업데이트 하위 호환 유지 함수
-
         if ver_num < 3160027:
             print('Add init set')
             set_init()
@@ -1530,7 +1525,6 @@ def send_email(who, title, data):
 
             return 1
         except Exception as e:
-            print('----')
             print('Error : email send error')
             print(e)
 

+ 0 - 4
test_tool.py

@@ -17,14 +17,10 @@ load_db = get_db_connect()
 conn = load_db.__enter__()
 curs = conn.cursor()
 
-print('----')
 print('1. Add virtual doc')
 
-print('----')
 what_i_do = input('Select : ')
-
 if what_i_do == '1':
-    print('----')
     doc_count = int(input('Count : '))
     
     for for_a in range(doc_count):

+ 33 - 8
views/ringo/js/skin_set.js

@@ -3,27 +3,48 @@ function ringo_do_regex_data(data) {
 }
 
 function ringo_get_post() {
-    check = document.getElementById('invert');
+    const check = document.getElementById('invert');
     if(check.checked === true) {
         document.cookie = 'main_css_darkmode=1; path=/';
     } else {
         document.cookie = 'main_css_darkmode=0; path=/';
     }
 
+    const check_2 = document.getElementById('use_sys_darkmode');
+    if(check_2.checked === true) {
+        document.cookie = 'main_css_use_sys_darkmode=1; path=/';
+    } else {
+        document.cookie = 'main_css_use_sys_darkmode=0; path=/';
+    }
+
     history.go(0);
 }
 
 function ringo_do_skin_set() {
     let cookies = document.cookie;
+    if(!cookies.match(ringo_do_regex_data('main_css_use_sys_darkmode')) || (cookies.match(ringo_do_regex_data('main_css_use_sys_darkmode')) && cookies.match(ringo_do_regex_data('main_css_use_sys_darkmode'))[1] === '1')) {
+        console.log('test');
+        if(window.matchMedia('(prefers-color-scheme: dark)').matches) {
+            document.cookie = 'main_css_darkmode=1; path=/';
+        } else {
+            document.cookie = 'main_css_darkmode=0; path=/';
+        }
+    }
+}
+
+function ringo_load_skin_set() {
+    let cookies = document.cookie;
     
     if(window.location.pathname === '/change/skin_set') {
         let set_language = {
             "en-US" : {
                 "save" : "Save",
-                "darkmode" : "Darkmode"
+                "darkmode" : "Darkmode",
+                "use_sys_darkmode" : "Use system darkmode set",
             }, "ko-KR" : {
                 "save" : "저장",
-                "darkmode" : "다크모드"
+                "darkmode" : "다크모드",
+                "use_sys_darkmode" : "시스템 다크모드 설정 사용",
             }
         }
 
@@ -39,14 +60,17 @@ function ringo_do_skin_set() {
 
         let set_data = {};
 
-        if(
-            cookies.match(ringo_do_regex_data('main_css_darkmode')) &&
-            cookies.match(ringo_do_regex_data('main_css_darkmode'))[1] === '1'
-        ) {
+        if(cookies.match(ringo_do_regex_data('main_css_darkmode')) && cookies.match(ringo_do_regex_data('main_css_darkmode'))[1] === '1') {
             set_data["invert"] = "checked";
         }
 
+        if(!cookies.match(ringo_do_regex_data('main_css_use_sys_darkmode')) || (cookies.match(ringo_do_regex_data('main_css_use_sys_darkmode')) && cookies.match(ringo_do_regex_data('main_css_use_sys_darkmode'))[1] === '1')) {
+            set_data["use_sys_darkmode"] = "checked";
+        }
+
         document.getElementById("main_skin_set").innerHTML = ' \
+            <input ' + set_data["use_sys_darkmode"] + ' type="checkbox" id="use_sys_darkmode" name="use_sys_darkmode" value="use_sys_darkmode"> ' + set_language[language]['use_sys_darkmode'] + ' \
+            <hr class="main_hr"> \
             <input ' + set_data["invert"] + ' type="checkbox" id="invert" name="invert" value="invert"> ' + set_language[language]['darkmode'] + ' \
             <hr class="main_hr"> \
             <button onclick="ringo_get_post();">' + set_language[language]['save'] + '</button> \
@@ -54,4 +78,5 @@ function ringo_do_skin_set() {
     }
 }
 
-window.addEventListener('DOMContentLoaded', ringo_do_skin_set);
+window.addEventListener('DOMContentLoaded', ringo_do_skin_set);
+window.addEventListener('DOMContentLoaded', ringo_load_skin_set);