Pārlūkot izejas kodu

최근 토론에도 신형 디자인 적용 및 팝업 디자인 변경

https://github.com/openNAMU/openNAMU/issues/2134
잉여개발기 2 gadi atpakaļ
vecāks
revīzija
942e10fddc

+ 5 - 8
app.py

@@ -547,9 +547,8 @@ app.route('/revert/<int:num>/<everything:name>', methods = ['POST', 'GET'])(edit
 app.route('/move/<everything:name>', methods = ['POST', 'GET'])(edit_move)
 
 # Func-topic
-app.route('/recent_discuss', defaults = { 'tool' : 'normal' })(recent_discuss)
-app.route('/recent_discuss/close', defaults = { 'tool' : 'close' })(recent_discuss)
-app.route('/recent_discuss/open', defaults = { 'tool' : 'open' })(recent_discuss)
+app.route('/recent_discuss', defaults = { 'tool' : 'normal' })(list_recent_discuss)
+app.route('/recent_discuss/<tool>')(list_recent_discuss)
 
 app.route('/thread/<int:topic_num>', methods = ['POST', 'GET'])(topic)
 app.route('/thread/0/<everything:doc_name>', defaults = { 'topic_num' : '0' }, methods = ['POST', 'GET'])(topic)
@@ -713,11 +712,9 @@ app.route('/api/history_tool/<int(signed = True):rev>/<everything:name>', defaul
 app.route('/api/recent_edit_request', defaults = { 'db_set' : db_set_str })(api_list_recent_edit_request)
 app.route('/api/recent_edit_request/<int:limit>/<set_type>/<int:num>', defaults = { 'db_set' : db_set_str })(api_list_recent_edit_request)
 
-# 곧 개편 당할 곳
-app.route('/api/recent_discuss/<get_type>/<int:num>')(api_recent_discuss)
-app.route('/api/recent_discuss/<int:num>')(api_recent_discuss)
-app.route('/api/recent_discuss')(api_recent_discuss)
-##
+app.route('/api/recent_discuss/<set_type>/<int:limit>', defaults = { 'db_set' : db_set_str })(api_list_recent_discuss)
+app.route('/api/recent_discuss/<int:limit>', defaults = { 'db_set' : db_set_str })(api_list_recent_discuss)
+app.route('/api/recent_discuss', defaults = { 'db_set' : db_set_str })(api_list_recent_discuss)
 
 app.route('/api/lang', methods = ['POST'], defaults = { 'db_set' : db_set_str })(api_func_language)
 app.route('/api/lang/<data>', defaults = { 'db_set' : db_set_str })(api_func_language)

+ 2 - 1
route/__init__.py

@@ -1,5 +1,4 @@
 from route.api_image_view import api_image_view
-from route.api_recent_discuss import api_recent_discuss
 from route.api_setting import api_setting
 from route.api_skin_info import api_skin_info
 from route.api_user_info import api_user_info
@@ -167,6 +166,7 @@ from route.vote_list import vote_list
 from route.vote_select import vote_select
 
 from route.n_list_recent_change import list_recent_change
+from route.n_list_recent_discuss import list_recent_discuss
 
 from route.n_w_watch_list import w_watch_list
 
@@ -179,6 +179,7 @@ from route.go_api_search import api_search
 
 from route.go_api_list_history_tool import api_list_history_tool
 from route.go_api_list_recent_change import api_list_recent_change
+from route.go_api_list_recent_discuss import api_list_recent_discuss
 from route.go_api_list_recent_edit_request import api_list_recent_edit_request
 
 from route.go_api_bbs import api_bbs

+ 0 - 20
route/api_recent_discuss.py

@@ -1,20 +0,0 @@
-from .tool.func import *
-
-def api_recent_discuss(num = 10, get_type = 'normal'):
-    with get_db_connect() as conn:
-        curs = conn.cursor()
-
-        num = 50 if (1 if not num > 0 else num) > 50 else num
-        data_list = []
-
-        if get_type == 'stop':
-            curs.execute(db_change("select title, sub, date, code, stop from rd where stop = 'O' order by date desc limit ?"), [num])
-        elif get_type == 'all':
-            curs.execute(db_change("select title, sub, date, code, stop from rd order by date desc limit ?"), [num])
-        else:
-            curs.execute(db_change("select title, sub, date, code, stop from rd where not stop = 'O' order by date desc limit ?"), [num])
-
-        for for_a in curs.fetchall():
-            data_list += [for_a]
-
-        return flask.jsonify(data_list if data_list else {}) 

+ 23 - 0
route/go_api_list_recent_discuss.py

@@ -0,0 +1,23 @@
+from .tool.func import *
+
+def api_list_recent_discuss(db_set, set_type = 'normal', limit = 10):
+    other_set = {}
+    other_set["limit"] = str(limit)
+    other_set["set_type"] = set_type
+    other_set["ip"] = ip_check()
+    other_set = json.dumps(other_set)
+
+    if platform.system() == 'Linux':
+        if platform.machine() in ["AMD64", "x86_64"]:
+            data = subprocess.Popen([os.path.join(".", "route_go", "bin", "main.amd64.bin"), sys._getframe().f_code.co_name, db_set, other_set], stdout = subprocess.PIPE).communicate()[0]
+        else:
+            data = subprocess.Popen([os.path.join(".", "route_go", "bin", "main.arm64.bin"), sys._getframe().f_code.co_name, db_set, other_set], stdout = subprocess.PIPE).communicate()[0]
+    else:
+        if platform.machine() in ["AMD64", "x86_64"]:
+            data = subprocess.Popen([os.path.join(".", "route_go", "bin", "main.amd64.exe"), sys._getframe().f_code.co_name, db_set, other_set], stdout = subprocess.PIPE).communicate()[0]
+        else:
+            data = subprocess.Popen([os.path.join(".", "route_go", "bin", "main.arm64.exe"), sys._getframe().f_code.co_name, db_set, other_set], stdout = subprocess.PIPE).communicate()[0]
+
+    data = data.decode('utf8')
+
+    return flask.Response(response = data, status = 200, mimetype = 'application/json')

+ 12 - 3
route/n_list_recent_discuss.py

@@ -1,13 +1,22 @@
 from .tool.func import *
 
-def list_recent_discuss():
+def list_recent_discuss(tool = 'normal'):
     with get_db_connect() as conn:
+        m_sub = 0
+        if tool == 'normal':
+            pass
+        elif tool == 'close':
+            m_sub = '(' + get_lang(conn, 'closed') + ')'
+        else:
+            tool = 'open'
+            m_sub = '(' + get_lang(conn, 'open_discussion_list') + ')'
+
         return easy_minify(conn, flask.render_template(skin_check(conn),
-            imp = [get_lang(conn, 'recent_discuss'), wiki_set(conn), wiki_custom(conn), wiki_css([0, 0])],
+            imp = [get_lang(conn, 'recent_discussion'), wiki_set(conn), wiki_custom(conn), wiki_css([m_sub, 0])],
             data = '' + \
                 '<div id="opennamu_list_recent_discuss"></div>' + \
                 '<script src="/views/main_css/js/route/list_recent_discuss.js' + cache_v() + '"></script>' + \
-                '<script>opennamu_list_recent_discuss();</script>' + \
+                '<script>opennamu_list_recent_discuss("' + tool + '");</script>' + \
             '',
             menu = [['other', get_lang(conn, 'return')]]
         ))

+ 1 - 1
route/tool/func.py

@@ -1043,7 +1043,7 @@ def skin_check(conn, set_n = 0):
         return skin
     
 def cache_v():
-    return '.cache_v223'
+    return '.cache_v224'
 
 def wiki_css(data):
     global global_wiki_set

BIN
route_go/bin/main.amd64.bin


BIN
route_go/bin/main.amd64.exe


BIN
route_go/bin/main.arm64.bin


BIN
route_go/bin/main.arm64.exe


+ 2 - 0
route_go/main.go

@@ -42,5 +42,7 @@ func main() {
 		route.Api_func_language(call_arg[1:])
 	} else if call_arg[0] == "api_list_history_tool" {
 		route.Api_list_history_tool(call_arg[1:])
+	} else if call_arg[0] == "api_list_recent_discuss" {
+		route.Api_list_recent_discuss(call_arg[1:])
 	}
 }

+ 5 - 2
route_go/route/api_list_history_tool.go

@@ -72,7 +72,10 @@ func Api_list_history_tool(call_arg []string) {
 	auth_name := tool.Get_user_auth(db, db_set, other_set["ip"])
 	auth_info := tool.Get_auth_group_info(db, db_set, auth_name)
 
-	if auth_info["hidel"] || auth_info["owner"] {
+	_, ok := auth_info["hidel"]
+	_, ok2 := auth_info["owner"]
+
+	if ok || ok2 {
 		main_dict = append(
 			main_dict,
 			[]string{
@@ -82,7 +85,7 @@ func Api_list_history_tool(call_arg []string) {
 		)
 	}
 
-	if auth_info["owner"] {
+	if ok2 {
 		main_dict = append(
 			main_dict,
 			[]string{

+ 38 - 6
route_go/route/api_list_recent_discuss.go

@@ -3,6 +3,7 @@ package route
 import (
 	"database/sql"
 	"encoding/json"
+	"fmt"
 	"opennamu/route/tool"
 	"strconv"
 )
@@ -33,11 +34,11 @@ func Api_list_recent_discuss(call_arg []string) {
 
 	set_type := other_set["set_type"]
 	if set_type == "normal" {
-		stmt, err = db.Prepare(tool.DB_change(db_set, "select title, sub, date, code from rd where not stop = 'O' order by date desc limit ?"))
+		stmt, err = db.Prepare(tool.DB_change(db_set, "select title, sub, date, code, stop from rd where order by date desc limit ?"))
 	} else if set_type == "close" {
-		stmt, err = db.Prepare(tool.DB_change(db_set, "select title, sub, date, code from rd where stop = 'O' order by date desc limit ?"))
+		stmt, err = db.Prepare(tool.DB_change(db_set, "select title, sub, date, code, stop from rd where stop = 'O' order by date desc limit ?"))
 	} else {
-		stmt, err = db.Prepare(tool.DB_change(db_set, "select title, sub, date, code from rd where stop != 'O' order by date asc limit ?"))
+		stmt, err = db.Prepare(tool.DB_change(db_set, "select title, sub, date, code, stop from rd where stop != 'O' order by date asc limit ?"))
 	}
 
 	if err != nil {
@@ -51,16 +52,17 @@ func Api_list_recent_discuss(call_arg []string) {
 	}
 	defer rows.Close()
 
-	// var data_list [][]string
-	// admin_auth := tool.Get_user_auth(db, db_set, other_set["ip"])
+	var data_list [][]string
+	ip_parser_temp := map[string][]string{}
 
 	for rows.Next() {
 		var title string
 		var sub string
 		var date string
 		var code string
+		var stop string
 
-		err := rows.Scan(&title, &sub, &date, &code)
+		err := rows.Scan(&title, &sub, &date, &code, &stop)
 		if err != nil {
 			return
 		}
@@ -81,5 +83,35 @@ func Api_list_recent_discuss(call_arg []string) {
 				return
 			}
 		}
+
+		var ip_pre string
+		var ip_render string
+
+		if _, ok := ip_parser_temp[ip]; ok {
+			ip_pre = ip_parser_temp[ip][0]
+			ip_render = ip_parser_temp[ip][1]
+		} else {
+			ip_pre = tool.IP_preprocess(db, db_set, ip, other_set["ip"])[0]
+			ip_render = tool.IP_parser(db, db_set, ip, other_set["ip"])
+
+			ip_parser_temp[ip] = []string{ip_pre, ip_render}
+		}
+
+		data_list = append(data_list, []string{
+			title,
+			sub,
+			date,
+			code,
+			stop,
+			ip_pre,
+			ip_render,
+		})
+	}
+
+	if len(data_list) == 0 {
+		fmt.Print("{}")
+	} else {
+		json_data, _ := json.Marshal(data_list)
+		fmt.Print(string(json_data))
 	}
 }

+ 1 - 1
version.json

@@ -1,6 +1,6 @@
 {
     "beta" : {
-        "r_ver" : "v3.5.0-dev68",
+        "r_ver" : "v3.5.0-dev69",
         "c_ver" : "3500376",
         "s_ver" : "3500113"
     }

+ 2 - 1
views/main_css/css/main.css

@@ -263,10 +263,11 @@ code, pre {
 
     padding: 10px;
 
-    background-color: #efefef;
+    background-color: white;
     color: initial;
     
     border: 1px solid #cecece;
+    border-radius: 5px;
 
     font-size: small;
     font-weight: initial;

+ 0 - 14
views/main_css/js/route/list_recent_change.js

@@ -15,20 +15,6 @@ function opennamu_list_recent_change() {
         fetch('/api/recent_change/50').then(function(res) {
             return res.json();
         }).then(function(data) {
-            /*
-                data_list = append(data_list, []string{
-                    id,
-                    title,
-                    date,
-                    tool.IP_preprocess(db, db_set, ip, other_set["ip"])[0],
-                    send,
-                    leng,
-                    hide,
-                    tool.IP_parser(db, db_set, ip, other_set["ip"]),
-                    type_data,
-                })
-            */
-
             let data_html = '';
 
             let option_list = [

+ 48 - 0
views/main_css/js/route/list_recent_discuss.js

@@ -0,0 +1,48 @@
+"use strict";
+
+function opennamu_list_recent_discuss(tool = 'normal') {
+    let lang_data = new FormData();
+    lang_data.append('data', 'tool normal close_discussion open_discussion_list')
+
+    fetch('/api/lang', {
+        method : 'post',
+        body : lang_data,
+    }).then(function(res) {
+        return res.json();
+    }).then(function(lang) {
+        lang = lang["data"];
+
+        fetch('/api/recent_discuss/' + tool + '/50').then(function(res) {
+            return res.json();
+        }).then(function(data) {
+            let data_html = '';
+
+            let option_list = [
+                ['normal', lang[1]],
+                ['close', lang[2]],
+                ['open', lang[3]]
+            ];
+            for(let for_a = 0; for_a < option_list.length; for_a++) {
+                data_html += '<a href="/recent_discuss/' + option_list[for_a][0] + '">(' + option_list[for_a][1] + ')</a> ';
+            }
+
+            data_html += '<hr class="main_hr">'
+
+            for(let for_a = 0; for_a < data.length; for_a++) {
+                let doc_name = opennamu_do_url_encode(data[for_a][0]);
+
+                data_html += '<div class="opennamu_recent_change">';
+                data_html += '<a href="/thread/' + data[for_a][3] + '">' + data[for_a][1] + '</a> ';
+                data_html += '<a href="/w/' + doc_name + '">(' + data[for_a][0] + ')</a> ';
+
+                data_html += '<div style="float: right;">';
+
+                data_html += data[for_a][6];
+
+                data_html += '</div>'
+            }
+
+            document.getElementById('opennamu_list_recent_discuss').innerHTML = data_html;
+        });
+    });
+}

+ 1 - 1
views/ringo/index.html

@@ -11,7 +11,7 @@
         <link href="https://cdn.jsdelivr.net/gh/sun-typeface/SUIT/fonts/static/woff2/SUIT.css" rel="stylesheet">
         <script src="https://code.iconify.design/1/1.0.3/iconify.min.js"></script>
         <script src="/views/ringo/js/main.js.cache_v2"></script>
-        <script src="/views/ringo/js/sidebar.js.cache_v2"></script>
+        <script src="/views/ringo/js/sidebar.js.cache_v3"></script>
         <script src="/views/ringo/js/skin_set.js.cache_v5"></script>
         <link rel="stylesheet" href="/views/ringo/css/main.css.cache_v8">
         {% if request.cookies.get('main_css_darkmode', '') == '1' %}

+ 1 - 1
views/ringo/js/sidebar.js

@@ -47,7 +47,7 @@ function ringo_do_side_button_2() {
             let data = '';
             for(let for_a = 0; for_a < text.length; for_a++) {
                 data += '<a href="/thread/' + ringo_do_url_encode(text[for_a][3]) + '">' + ringo_do_xss_encode(text[for_a][1]) + '</a><br>';
-                data += text[for_a][2] + '<br>';
+                data += text[for_a][2] + ' | ' + text[for_a][5] +'<br>';
             }
 
             document.getElementById('side_content').innerHTML = data;