@@ -3,7 +3,7 @@ use rouille::{post_input, try_or_400, Request, Response};
33
44use crate :: {
55 document,
6- settings:: { Settings , EMBED_EMBEDS , EMBED_IMAGES , FAST_REDIRECT , PROXY_IMAGES , REDIRECT_TIMER } ,
6+ settings:: { Settings , EMBED_EMBEDS , EMBED_IMAGES , FAST_REDIRECT , PROXY_IMAGES , REDIRECT_TIMER , ARTICLE_LIMIT } ,
77} ;
88
99fn render_settings (
@@ -12,6 +12,7 @@ fn render_settings(
1212 proxy_images : bool ,
1313 fast_redirect : bool ,
1414 redirect_timer : u32 ,
15+ article_limit : u32 ,
1516) -> Markup {
1617 document ! (
1718 "Settings" ,
@@ -46,6 +47,11 @@ fn render_settings(
4647 input type ="number" id=( REDIRECT_TIMER ) name=( REDIRECT_TIMER ) value=( redirect_timer) { }
4748 }
4849
50+ label for =( ARTICLE_LIMIT ) {
51+ "Articles to display"
52+ input type ="number" id=( ARTICLE_LIMIT ) name=( ARTICLE_LIMIT ) value=( article_limit) { }
53+ }
54+
4955 button type ="submit" {
5056 "Save"
5157 }
@@ -60,6 +66,7 @@ fn store_settings(
6066 proxy_images : bool ,
6167 fast_redirect : bool ,
6268 redirect_timer : u32 ,
69+ article_limit : u32 ,
6370) -> Response {
6471 Response :: redirect_303 ( "/settings" )
6572 . with_additional_header (
@@ -77,14 +84,21 @@ fn store_settings(
7784 . with_additional_header (
7885 "Set-Cookie" ,
7986 format ! ( "{FAST_REDIRECT}={}; Path=/; SameSite=Strict" , fast_redirect) ,
80- )
87+ )
8188 . with_additional_header (
8289 "Set-Cookie" ,
8390 format ! (
8491 "{REDIRECT_TIMER}={}; Path=/; SameSite=Strict" ,
8592 redirect_timer
8693 ) ,
8794 )
95+ . with_additional_header (
96+ "Set-Cookie" ,
97+ format ! (
98+ "{ARTICLE_LIMIT}={}; Path=/; SameSite=Strict" ,
99+ article_limit
100+ ) ,
101+ )
88102}
89103
90104pub fn handle_settings ( request : & Request , settings : & Settings ) -> Response {
@@ -95,6 +109,7 @@ pub fn handle_settings(request: &Request, settings: &Settings) -> Response {
95109 proxy_images: bool ,
96110 fast_redirect: bool ,
97111 redirect_timer: i32 ,
112+ article_limit: i32 ,
98113 } ) ) ;
99114
100115 store_settings (
@@ -103,6 +118,7 @@ pub fn handle_settings(request: &Request, settings: &Settings) -> Response {
103118 settings. proxy_images ,
104119 settings. fast_redirect ,
105120 settings. redirect_timer . clamp ( 0 , 600 ) as u32 ,
121+ settings. article_limit . clamp ( 0 , 100 ) as u32 ,
106122 )
107123 } else {
108124 let page = render_settings (
@@ -111,6 +127,7 @@ pub fn handle_settings(request: &Request, settings: &Settings) -> Response {
111127 settings. proxy_images ,
112128 settings. fast_redirect ,
113129 settings. redirect_timer ,
130+ settings. article_limit ,
114131 ) ;
115132 Response :: html ( page) . with_status_code ( 200 )
116133 }
0 commit comments