Explorar el Código

더 오래된 토론도 볼 수 있도록 변경

잉여개발기 (SPDV) hace 2 años
padre
commit
e02553cf87

+ 9 - 7
app.py

@@ -468,11 +468,14 @@ app.route('/block_log/regex/<int:num>', defaults = { 'tool' : 'regex' })(recent_
 app.route('/block_log/ongoing', defaults = { 'tool' : 'ongoing' })(recent_block)
 app.route('/block_log/ongoing/<int:num>', defaults = { 'tool' : 'ongoing' })(recent_block)
 
-# Func-history
 app.route('/recent_change')(list_recent_change)
 app.route('/recent_changes')(list_recent_change)
 app.route('/recent_change/<int:num>/<set_type>')(list_recent_change)
 
+app.route('/recent_discuss', defaults = { 'tool' : 'normal' })(list_recent_discuss)
+app.route('/recent_discuss/<int:num>/<tool>')(list_recent_discuss)
+
+# Func-history
 app.route('/recent_edit_request', defaults = { 'db_set' : db_set_str })(recent_edit_request)
 
 app.route('/record/<name>', defaults = { 'tool' : 'record' })(recent_change)
@@ -542,9 +545,6 @@ 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' })(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)
 app.route('/topic/<everything:name>', methods = ['POST', 'GET'])(topic_list)
@@ -722,9 +722,11 @@ app.route('/api/ip/<everything:data>', defaults = { 'db_set' : db_set_str })(api
 app.route('/api/image/<everything:name>')(api_image_view)
 
 ## v2 API
-app.route('/api/v2/recent_edit_request/<int:limit>/<set_type>/<int:num>', defaults = { 'db_set' : db_set_str })(api_list_recent_edit_request)
-app.route('/api/v2/recent_change/<int:limit>/<set_type>/<int:num>', defaults = { 'db_set' : db_set_str, 'legacy' : '' })(api_list_recent_change)
-app.route('/api/v2/recent_discuss/<set_type>/<int:limit>', defaults = { 'db_set' : db_set_str, 'legacy' : '' })(api_list_recent_discuss)
+app.route('/api/v2/recent_edit_request/<set_type>/<int:num>', defaults = { 'db_set' : db_set_str, 'limit' : 50 })(api_list_recent_edit_request)
+app.route('/api/v2/recent_change/<set_type>/<int:num>', defaults = { 'db_set' : db_set_str, 'legacy' : '', 'limit' : 50 })(api_list_recent_change)
+app.route('/api/v2/recent_discuss/<set_type>/<int:num>', defaults = { 'db_set' : db_set_str, 'legacy' : '', 'limit' : 50 })(api_list_recent_discuss)
+app.route('/api/v2/old_page/<int:num>', defaults = { 'db_set' : db_set_str })(api_list_recent_change)
+app.route('/api/v2/new_page/<int:num>', defaults = { 'db_set' : db_set_str })(api_list_recent_discuss)
 
 # Func-main
 # 여기도 전반적인 조정 시행 예정

+ 2 - 1
route/go_api_list_recent_discuss.py

@@ -1,7 +1,8 @@
 from .tool.func import *
 
-def api_list_recent_discuss(db_set, set_type = 'normal', limit = 10, legacy = 'on'):
+def api_list_recent_discuss(db_set, num = 1, set_type = 'normal', limit = 10, legacy = 'on'):
     other_set = {}
+    other_set["num"] = str(num)
     other_set["limit"] = str(limit)
     other_set["set_type"] = set_type
     other_set["legacy"] = legacy

+ 4 - 7
route/n_list_recent_discuss.py

@@ -1,14 +1,11 @@
 from .tool.func import *
 
-def list_recent_discuss(tool = 'normal'):
+def list_recent_discuss(num = 1, tool = 'normal'):
     with get_db_connect() as conn:
         m_sub = 0
-        if tool == 'normal':
-            pass
-        elif tool == 'close':
+        if tool == 'close':
             m_sub = '(' + get_lang(conn, 'close_discussion') + ')'
-        else:
-            tool = 'open'
+        elif tool == 'open':
             m_sub = '(' + get_lang(conn, 'open_discussion') + ')'
 
         return easy_minify(conn, flask.render_template(skin_check(conn),
@@ -16,7 +13,7 @@ def list_recent_discuss(tool = 'normal'):
             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("' + tool + '");</script>' + \
+                '<script>opennamu_list_recent_discuss();</script>' + \
             '',
             menu = [['other', get_lang(conn, 'return')]]
         ))

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


+ 62 - 0
route_go/route/api_list_old_page.go

@@ -0,0 +1,62 @@
+package route
+
+import (
+	"database/sql"
+	"encoding/json"
+	"log"
+	"opennamu/route/tool"
+	"strconv"
+)
+
+func Api_list_old_page(call_arg []string) {
+	db_set := map[string]string{}
+	json.Unmarshal([]byte(call_arg[0]), &db_set)
+
+	other_set := map[string]string{}
+	json.Unmarshal([]byte(call_arg[1]), &other_set)
+
+	db := tool.DB_connect(db_set)
+	if db == nil {
+		return
+	}
+	defer db.Close()
+
+	limit_int, err := strconv.Atoi(other_set["limit"])
+	if err != nil {
+		log.Fatal(err)
+	}
+
+	if limit_int > 50 || limit_int < 0 {
+		limit_int = 50
+	}
+
+	page_int, err := strconv.Atoi(other_set["num"])
+	if err != nil {
+		log.Fatal(err)
+	}
+
+	if page_int > 0 {
+		page_int = (page_int * limit_int) - limit_int
+	} else {
+		page_int = 0
+	}
+
+	var stmt *sql.Stmt
+
+	if other_set["set_type"] == "old" {
+		stmt, err = db.Prepare(tool.DB_change(db_set, "select doc_name, set_data from data_set where set_name = 'last_edit' and doc_rev = '' order by set_data desc limit ?, 50"))
+	} else {
+		stmt, err = db.Prepare(tool.DB_change(db_set, "select doc_name, set_data from data_set where set_name = 'last_edit' and doc_rev = '' order by set_data asc limit ?, 50"))
+	}
+
+	if err != nil {
+		log.Fatal(err)
+	}
+	defer stmt.Close()
+
+	rows, err := stmt.Query(page_int, limit_int)
+	if err != nil {
+		log.Fatal(err)
+	}
+	defer rows.Close()
+}

+ 15 - 4
route_go/route/api_list_recent_discuss.go

@@ -31,15 +31,26 @@ func Api_list_recent_discuss(call_arg []string) {
 		limit_int = 50
 	}
 
+	page_int, err := strconv.Atoi(other_set["num"])
+	if err != nil {
+		log.Fatal(err)
+	}
+
+	if page_int > 0 {
+		page_int = (page_int * limit_int) - limit_int
+	} else {
+		page_int = 0
+	}
+
 	var stmt *sql.Stmt
 
 	set_type := other_set["set_type"]
 	if set_type == "normal" {
-		stmt, err = db.Prepare(tool.DB_change(db_set, "select title, sub, date, code, stop from rd order by date desc limit ?"))
+		stmt, err = db.Prepare(tool.DB_change(db_set, "select title, sub, date, code, stop from rd order by date desc limit ?, ?"))
 	} else if set_type == "close" {
-		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 ?"))
+		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, stop 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 ?, ?"))
 	}
 
 	if err != nil {
@@ -47,7 +58,7 @@ func Api_list_recent_discuss(call_arg []string) {
 	}
 	defer stmt.Close()
 
-	rows, err := stmt.Query(limit_int)
+	rows, err := stmt.Query(page_int, limit_int)
 	if err != nil {
 		log.Fatal(err)
 	}

+ 1 - 1
version.json

@@ -1,6 +1,6 @@
 {
     "beta" : {
-        "r_ver" : "v3.5.0-dev82",
+        "r_ver" : "v3.5.0-dev83",
         "c_ver" : "3500377",
         "s_ver" : "3500113"
     }

+ 1 - 1
views/main_css/js/route/list_recent_change.js

@@ -14,7 +14,7 @@ function opennamu_list_recent_change() {
         num = url_split[2];
     }
 
-    fetch('/api/v2/recent_change/50/' + set_type + '/' + num).then(function(res) {
+    fetch('/api/v2/recent_change/' + set_type + '/' + num).then(function(res) {
         return res.json();
     }).then(function(data) {
         let lang = data["language"];

+ 18 - 3
views/main_css/js/route/list_recent_discuss.js

@@ -1,7 +1,20 @@
 "use strict";
 
-function opennamu_list_recent_discuss(tool = 'normal') {
-    fetch('/api/v2/recent_discuss/' + tool + '/50').then(function(res) {
+function opennamu_list_recent_discuss() {
+    const url = window.location.pathname;
+    const url_split = url.split('/')
+    
+    let set_type = '';
+    let num = '';
+    if(url_split.length == 2) {
+        set_type = 'normal';
+        num = '1';
+    } else {
+        set_type = url_split[3];
+        num = url_split[2];
+    }
+
+    fetch('/api/v2/recent_discuss/' + set_type + '/' + num).then(function(res) {
         return res.json();
     }).then(function(data) {
         let lang = data["language"];
@@ -15,7 +28,7 @@ function opennamu_list_recent_discuss(tool = 'normal') {
             ['open', lang['open_discussion']]
         ];
         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 += '<a href="/recent_discuss/1/' + option_list[for_a][0] + '">(' + option_list[for_a][1] + ')</a> ';
         }
 
         data_html += '<hr class="main_hr">'
@@ -44,6 +57,8 @@ function opennamu_list_recent_discuss(tool = 'normal') {
             data_html += '<hr class="main_hr">';
         }
 
+        data_html += opennamu_page_control('/recent_discuss/{}/' + set_type, Number(num), data.length);
+
         document.getElementById('opennamu_list_recent_discuss').innerHTML = data_html;
     });
 }