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

문법 추가, 기본 스킨 다크모드 개편

Surplus_Up (2DU) 6 лет назад
Родитель
Сommit
3d94c04ce8
5 измененных файлов с 118 добавлено и 87 удалено
  1. 1 1
      route/func_upload.py
  2. 26 11
      route/tool/set_mark/namu.py
  3. 24 0
      views/marisa/css/dark.css
  4. 2 7
      views/marisa/css/main.css
  5. 65 68
      views/marisa/js/skin_set.js

+ 1 - 1
route/func_upload.py

@@ -116,7 +116,7 @@ def func_upload_2(conn):
                 <form method="post" enctype="multipart/form-data" accept-charset="utf8">
                     <input type="file" name="f_data">
                     <hr class=\"main_hr\">
-                    <input placeholder="''' + load_lang('file_name') + '''" name="f_name" type="text">
+                    <input placeholder="''' + load_lang('file_name') + '''" name="f_name" type="text" value="''' + flask.request.args.get('name', '') + '''">
                     <hr class=\"main_hr\">
                     <select name="f_lice_sel">
                         ''' + license_list + '''

+ 26 - 11
route/tool/set_mark/namu.py

@@ -781,25 +781,25 @@ def namu(conn, data, title, main_num, include_num):
             if re.search('^((?:file|파일)|(?:out|외부)):', main_link):
                 file_style = ''
 
-                width = re.search('width=((?:(?!&).)+)', see_link)
-                if width:
-                    file_width = width.groups()[0]
+                file_width = re.search('width=((?:(?!&).)+)', see_link)
+                if file_width:
+                    file_width = file_width.groups()[0]
                     if re.search('px$', file_width):
                         file_style += 'width: ' + file_width + ';'
                     else:
                         file_style += 'width: ' + file_width + 'px;'
                 
-                height = re.search('height=((?:(?!&).)+)', see_link)
-                if height:
-                    file_height = height.groups()[0]
+                file_height = re.search('height=((?:(?!&).)+)', see_link)
+                if file_height:
+                    file_height = file_height.groups()[0]
                     if re.search('px$', file_height):
                         file_style += 'height: ' + file_height + ';'
                     else:
                         file_style += 'height: ' + file_height + 'px;'
 
-                align = re.search('align=((?:(?!&).)+)', see_link)
-                if align:
-                    file_align = align.groups()[0]
+                file_align = re.search('align=((?:(?!&).)+)', see_link)
+                if file_align:
+                    file_align = file_align.groups()[0]
                     if file_align == 'center':
                         file_align = 'display: block; text-align: center;'
                     else:
@@ -807,6 +807,12 @@ def namu(conn, data, title, main_num, include_num):
                 else:
                     file_align = ''
 
+                file_color = re.search('bgcolor=((?:(?!&).)+)', see_link)
+                if file_color:
+                    file_color = 'background: ' + file_color.groups()[0] + '; display: inline-block;'
+                else:
+                    file_color = ''
+
                 if re.search('^(?:out|외부):', main_link):
                     file_src = re.sub('^(?:out|외부):', '', main_link)
             
@@ -831,9 +837,18 @@ def namu(conn, data, title, main_num, include_num):
                     exist = curs.fetchall()
                 
                 if exist:
-                    data = re.sub('\[\[((?:(?!\[\[|\]\]).)+)\]\]', '<span style="' + file_align + '"><img style="' + file_style + '" alt="' + file_alt + '" src="' + file_src + '"></span>', data, 1)
+                    data = re.sub(
+                        '\[\[((?:(?!\[\[|\]\]).)+)\]\]', 
+                        '<span style="' + file_align + '">' + \
+                            '<span style="' + file_color + '">' + \
+                                '<img style="' + file_style + '" alt="' + file_alt + '" src="' + file_src + '">' + \
+                            '</span>' + \
+                        '</span>', 
+                        data, 
+                        1
+                    )
                 else:
-                    data = re.sub('\[\[((?:(?!\[\[|\]\]).)+)\]\]', '<a id="not_thing" href="/w/' + tool.url_pas(file_alt) + '">' + file_alt + '</a>', data, 1)
+                    data = re.sub('\[\[((?:(?!\[\[|\]\]).)+)\]\]', '<a id="not_thing" href="/upload?name=' + tool.url_pas(file_name) + '">' + file_alt + '</a>', data, 1)
             elif category_re.search(main_link):
                 main_link = category_re.sub('category:', main_link)
                 

+ 24 - 0
views/marisa/css/dark.css

@@ -0,0 +1,24 @@
+html, #main {
+    background: black;
+    color: white;
+}
+
+.cel_in_cel, #background, div#pre_search, #toc, #cate, #redirect {
+    background: #1f2023;
+    border-color: #1f2023;
+}
+
+#bottom {
+    background: black;
+    color: white;
+}
+
+#top .cel_in_cel a {
+    color: white;
+}
+
+textarea, input, button, select {
+    background: #1f2023;
+    color: white;
+    border-color: #1f2023;
+}

+ 2 - 7
views/marisa/css/main.css

@@ -80,7 +80,7 @@ li {
 
 #bottom_main {
     margin: auto;
-    margin-top: 20px;
+    padding-top: 20px;
 }
 
 #tool {
@@ -347,7 +347,7 @@ input {
     border-radius: 10px;
 }
 
-#cate {
+#cate, #redirect {
     border: 2px solid gainsboro;
     border-radius: 10px;
 }
@@ -356,11 +356,6 @@ input {
     background: transparent;
 }
 
-#redirect {
-    border: 2px solid gainsboro;
-    border-radius: 10px;
-}
-
 #go_toc {
     display: inline-block;
     padding: 10px;

+ 65 - 68
views/marisa/js/skin_set.js

@@ -1,83 +1,80 @@
-function skin_set() {
-    function get_post() {
-        check = document.getElementById('strike');
-        if(check.value === 'normal') {
-            document.cookie = 'del_strike=0;';
-        } else if(check.value === 'change') {
-            document.cookie = 'del_strike=1;';
-        } else {
-            document.cookie = 'del_strike=2;';
-        }
-
-        check = document.getElementById('bold');
-        if(check.value === 'normal') {
-            document.cookie = 'del_bold=0;';
-        } else if(check.value === 'change') {
-            document.cookie = 'del_bold=1;';
-        } else {
-            document.cookie = 'del_bold=2;';
-        }
-
-        check = document.getElementById('include');
-        if(check.checked === true) {
-            document.cookie = 'include_link=1;';
-        } else {
-            document.cookie = 'include_link=0;';
-        }
-
-        check = document.getElementById('invert');
-        if(check.checked === true) {
-            document.cookie = 'invert=1;';
-        } else {
-            document.cookie = 'invert=0;';
-        }
+function get_post() {
+    check = document.getElementById('strike');
+    if(check.value === 'normal') {
+        document.cookie = 'del_strike=0;';
+    } else if(check.value === 'change') {
+        document.cookie = 'del_strike=1;';
+    } else {
+        document.cookie = 'del_strike=2;';
+    }
 
-        history.go(0);
+    check = document.getElementById('bold');
+    if(check.value === 'normal') {
+        document.cookie = 'del_bold=0;';
+    } else if(check.value === 'change') {
+        document.cookie = 'del_bold=1;';
+    } else {
+        document.cookie = 'del_bold=2;';
     }
 
-    function regex_data(data) {
-        r_data = new RegExp('(?:^|; )' + data + '=([^;]*)')
+    check = document.getElementById('include');
+    if(check.checked === true) {
+        document.cookie = 'include_link=1;';
+    } else {
+        document.cookie = 'include_link=0;';
+    }
 
-        return r_data;
+    check = document.getElementById('invert');
+    if(check.checked === true) {
+        document.cookie = 'invert=1;';
+    } else {
+        document.cookie = 'invert=0;';
     }
 
-    cookies = document.cookie;
+    history.go(0);
+}
 
-    function main_load() {
-        head_data = document.querySelector('head');
-        if(cookies.match(regex_data('del_strike'))) {
-            if(cookies.match(regex_data('del_strike'))[1] === '1') {
-                head_data.innerHTML += '<style>s { text-decoration: none; } s:hover { background-color: transparent; }</style>';
-            } else if(cookies.match(regex_data('del_strike'))[1] === '2') {
-                head_data.innerHTML += '<style>s { display: none; }</style>';
-            }
+function main_load() {
+    head_data = document.querySelector('head');
+    if(cookies.match(regex_data('del_strike'))) {
+        if(cookies.match(regex_data('del_strike'))[1] === '1') {
+            head_data.innerHTML += '<style>s { text-decoration: none; } s:hover { background-color: transparent; }</style>';
+        } else if(cookies.match(regex_data('del_strike'))[1] === '2') {
+            head_data.innerHTML += '<style>s { display: none; }</style>';
         }
+    }
 
-        if(cookies.match(regex_data('del_bold'))) {
-            if(cookies.match(regex_data('del_bold'))[1] === '1') {
-                head_data.innerHTML += '<style>b { font-weight: normal; }</style>';
-            } else if(cookies.match(regex_data('del_bold'))[1] === '2') {
-                head_data.innerHTML += '<style>b { display: none; }</style>';
-            }
+    if(cookies.match(regex_data('del_bold'))) {
+        if(cookies.match(regex_data('del_bold'))[1] === '1') {
+            head_data.innerHTML += '<style>b { font-weight: normal; }</style>';
+        } else if(cookies.match(regex_data('del_bold'))[1] === '2') {
+            head_data.innerHTML += '<style>b { display: none; }</style>';
         }
+    }
 
-        if(
-            cookies.match(regex_data('include_link')) &&
-            cookies.match(regex_data('include_link'))[1] === '1'
-        ) {
-            head_data.innerHTML += '<style>#include_link { display: inline; }</style>';
-        }
+    if(
+        cookies.match(regex_data('include_link')) &&
+        cookies.match(regex_data('include_link'))[1] === '1'
+    ) {
+        head_data.innerHTML += '<style>#include_link { display: inline; }</style>';
+    }
 
-        if(
-            cookies.match(regex_data('invert')) &&
-            cookies.match(regex_data('invert'))[1] === '1'
-        ) {
-            head_data.innerHTML += '<style>body { -webkit-filter: invert(100%); filter: invert(100%); background: black; }</style>';
-        }
+    if(
+        cookies.match(regex_data('invert')) &&
+        cookies.match(regex_data('invert'))[1] === '1'
+    ) {
+        head_data.innerHTML += '<link rel="stylesheet" href="/views/marisa/css/dark.css?ver=1">';
     }
+}
 
-    main_load();
+function regex_data(data) {
+    return new RegExp('(?:^|; )' + data + '=([^;]*)');
+}
 
+cookies = document.cookie;
+main_load();
+
+function skin_set() {
     if(window.location.pathname === '/skin_set') {
         set_language = {
             "en-US" : {
@@ -90,7 +87,7 @@ function skin_set() {
                 "strike" : "Strike",
                 "bold" : "Bold",
                 "other" : "Other",
-                "invert" : "Reversal of color"
+                "darkmode" : "Darkmode"
             }, "ko-KR" : {
                 "default" : "기본값",
                 "change_to_normal" : "일반 텍스트로 변경",
@@ -101,7 +98,7 @@ function skin_set() {
                 "strike" : "취소선",
                 "bold" : "볼드체",
                 "other" : "기타",
-                "invert" : "색 반전"
+                "darkmode" : "다크모드"
             }
         }
 
@@ -204,7 +201,7 @@ function skin_set() {
             <h2>' + set_language[language]['other'] + '</h2> \
             <input ' + set_data["include"] + ' type="checkbox" id="include" name="include" value="include"> ' + set_language[language]['include_link'] + ' \
             <hr class="main_hr"> \
-            <input ' + set_data["invert"] + ' type="checkbox" id="invert" name="invert" value="invert"> ' + set_language[language]['invert'] + ' \
+            <input ' + set_data["invert"] + ' type="checkbox" id="invert" name="invert" value="invert"> ' + set_language[language]['darkmode'] + ' \
             <hr class="main_hr"> \
             <button onclick="get_post();">' + set_language[language]['save'] + '</button> \
         ';