Fossil SCM
On the main /forum screen, provide the new n= and x= query parameters to enable access to older threads.
Commit
aff20904fad05b078dfe5470686d106247fcffd3decf326bfb5a82e74e2c1c76
Parent
a50dfe6fae55b58…
1 file changed
+31
-6
+31
-6
| --- src/forum.c | ||
| +++ src/forum.c | ||
| @@ -905,14 +905,19 @@ | ||
| 905 | 905 | ** WEBPAGE: forum |
| 906 | 906 | ** |
| 907 | 907 | ** The main page for the forum feature. Show a list of recent forum |
| 908 | 908 | ** threads. Also show a search box at the top if search is enabled, |
| 909 | 909 | ** and a button for creating a new thread, if enabled. |
| 910 | +** | |
| 911 | +** Query parameters: | |
| 912 | +** | |
| 913 | +** n=N The number of threads to show on each page | |
| 914 | +** x=X Skip the first X threads | |
| 910 | 915 | */ |
| 911 | 916 | void forum_main_page(void){ |
| 912 | 917 | Stmt q; |
| 913 | - int iLimit, iOfst; | |
| 918 | + int iLimit, iOfst, iCnt; | |
| 914 | 919 | login_check_credentials(); |
| 915 | 920 | if( !g.perm.RdForum ){ |
| 916 | 921 | login_needed(g.anon.RdForum); |
| 917 | 922 | return; |
| 918 | 923 | } |
| @@ -926,12 +931,12 @@ | ||
| 926 | 931 | if( search_screen(SRCH_FORUM, 0) ){ |
| 927 | 932 | style_submenu_element("Recent Threads","%R/forum"); |
| 928 | 933 | style_footer(); |
| 929 | 934 | return; |
| 930 | 935 | } |
| 931 | - iLimit = 50; | |
| 932 | - iOfst = 0; | |
| 936 | + iLimit = atoi(PD("n","25")); | |
| 937 | + iOfst = atoi(PD("x","0")); | |
| 933 | 938 | @ <h1>Recent Threads</h1> |
| 934 | 939 | @ <div class='fileage'><table width="100%%"> |
| 935 | 940 | if( db_table_exists("repository","forumpost") ){ |
| 936 | 941 | db_prepare(&q, |
| 937 | 942 | "SELECT" |
| @@ -943,23 +948,43 @@ | ||
| 943 | 948 | " FROM event WHERE objid=(SELECT fpid FROM forumpost AS y" |
| 944 | 949 | " WHERE y.froot=x.froot" |
| 945 | 950 | " ORDER BY fmtime DESC LIMIT 1))" |
| 946 | 951 | " FROM forumpost AS x" |
| 947 | 952 | " GROUP BY froot ORDER BY 1 LIMIT %d OFFSET %d;", |
| 948 | - iLimit, iOfst | |
| 953 | + iLimit+1, iOfst | |
| 949 | 954 | ); |
| 955 | + iCnt = 0; | |
| 950 | 956 | while( db_step(&q)==SQLITE_ROW ){ |
| 951 | - char *zAge = human_readable_age(db_column_double(&q,0)); | |
| 952 | - char *zDuration = human_readable_age(db_column_double(&q,1)); | |
| 957 | + char *zAge = 0; | |
| 958 | + char *zDuration = 0; | |
| 953 | 959 | int nMsg = db_column_int(&q, 2); |
| 954 | 960 | const char *zUuid = db_column_text(&q, 3); |
| 955 | 961 | const char *zTitle = db_column_text(&q, 4); |
| 962 | + if( iCnt==0 && iOfst>0 ){ | |
| 963 | + if( iOfst>iLimit ){ | |
| 964 | + @ <tr><td colspan="3">\ | |
| 965 | + @ %z(href("%R/forum?x=%d&n=%d",iOfst-iLimit,iLimit))\ | |
| 966 | + @ ↑ Newer...</a></td></tr> | |
| 967 | + }else{ | |
| 968 | + @ <tr><td colspan="3">%z(href("%R/forum?n=%d",iLimit))\ | |
| 969 | + @ ↑ Newer...</a></td></tr> | |
| 970 | + } | |
| 971 | + } | |
| 972 | + iCnt++; | |
| 973 | + if( iCnt>iLimit ){ | |
| 974 | + @ <tr><td colspan="3">\ | |
| 975 | + @ %z(href("%R/forum?x=%d&n=%d",iOfst+iLimit,iLimit))\ | |
| 976 | + @ ↓ Older...</a></td></tr> | |
| 977 | + break; | |
| 978 | + } | |
| 979 | + zAge = human_readable_age(db_column_double(&q,0)); | |
| 956 | 980 | @ <tr><td>%h(zAge) ago</td> |
| 957 | 981 | @ <td>%z(href("%R/forumpost/%S",zUuid))%h(zTitle)</a></td> |
| 958 | 982 | if( nMsg<2 ){ |
| 959 | 983 | @ <td>no replies</td> |
| 960 | 984 | }else{ |
| 985 | + zDuration = human_readable_age(db_column_double(&q,1)); | |
| 961 | 986 | @ <td>%d(nMsg) posts spanning %h(zDuration)</td> |
| 962 | 987 | } |
| 963 | 988 | @ </tr> |
| 964 | 989 | fossil_free(zAge); |
| 965 | 990 | fossil_free(zDuration); |
| 966 | 991 |
| --- src/forum.c | |
| +++ src/forum.c | |
| @@ -905,14 +905,19 @@ | |
| 905 | ** WEBPAGE: forum |
| 906 | ** |
| 907 | ** The main page for the forum feature. Show a list of recent forum |
| 908 | ** threads. Also show a search box at the top if search is enabled, |
| 909 | ** and a button for creating a new thread, if enabled. |
| 910 | */ |
| 911 | void forum_main_page(void){ |
| 912 | Stmt q; |
| 913 | int iLimit, iOfst; |
| 914 | login_check_credentials(); |
| 915 | if( !g.perm.RdForum ){ |
| 916 | login_needed(g.anon.RdForum); |
| 917 | return; |
| 918 | } |
| @@ -926,12 +931,12 @@ | |
| 926 | if( search_screen(SRCH_FORUM, 0) ){ |
| 927 | style_submenu_element("Recent Threads","%R/forum"); |
| 928 | style_footer(); |
| 929 | return; |
| 930 | } |
| 931 | iLimit = 50; |
| 932 | iOfst = 0; |
| 933 | @ <h1>Recent Threads</h1> |
| 934 | @ <div class='fileage'><table width="100%%"> |
| 935 | if( db_table_exists("repository","forumpost") ){ |
| 936 | db_prepare(&q, |
| 937 | "SELECT" |
| @@ -943,23 +948,43 @@ | |
| 943 | " FROM event WHERE objid=(SELECT fpid FROM forumpost AS y" |
| 944 | " WHERE y.froot=x.froot" |
| 945 | " ORDER BY fmtime DESC LIMIT 1))" |
| 946 | " FROM forumpost AS x" |
| 947 | " GROUP BY froot ORDER BY 1 LIMIT %d OFFSET %d;", |
| 948 | iLimit, iOfst |
| 949 | ); |
| 950 | while( db_step(&q)==SQLITE_ROW ){ |
| 951 | char *zAge = human_readable_age(db_column_double(&q,0)); |
| 952 | char *zDuration = human_readable_age(db_column_double(&q,1)); |
| 953 | int nMsg = db_column_int(&q, 2); |
| 954 | const char *zUuid = db_column_text(&q, 3); |
| 955 | const char *zTitle = db_column_text(&q, 4); |
| 956 | @ <tr><td>%h(zAge) ago</td> |
| 957 | @ <td>%z(href("%R/forumpost/%S",zUuid))%h(zTitle)</a></td> |
| 958 | if( nMsg<2 ){ |
| 959 | @ <td>no replies</td> |
| 960 | }else{ |
| 961 | @ <td>%d(nMsg) posts spanning %h(zDuration)</td> |
| 962 | } |
| 963 | @ </tr> |
| 964 | fossil_free(zAge); |
| 965 | fossil_free(zDuration); |
| 966 |
| --- src/forum.c | |
| +++ src/forum.c | |
| @@ -905,14 +905,19 @@ | |
| 905 | ** WEBPAGE: forum |
| 906 | ** |
| 907 | ** The main page for the forum feature. Show a list of recent forum |
| 908 | ** threads. Also show a search box at the top if search is enabled, |
| 909 | ** and a button for creating a new thread, if enabled. |
| 910 | ** |
| 911 | ** Query parameters: |
| 912 | ** |
| 913 | ** n=N The number of threads to show on each page |
| 914 | ** x=X Skip the first X threads |
| 915 | */ |
| 916 | void forum_main_page(void){ |
| 917 | Stmt q; |
| 918 | int iLimit, iOfst, iCnt; |
| 919 | login_check_credentials(); |
| 920 | if( !g.perm.RdForum ){ |
| 921 | login_needed(g.anon.RdForum); |
| 922 | return; |
| 923 | } |
| @@ -926,12 +931,12 @@ | |
| 931 | if( search_screen(SRCH_FORUM, 0) ){ |
| 932 | style_submenu_element("Recent Threads","%R/forum"); |
| 933 | style_footer(); |
| 934 | return; |
| 935 | } |
| 936 | iLimit = atoi(PD("n","25")); |
| 937 | iOfst = atoi(PD("x","0")); |
| 938 | @ <h1>Recent Threads</h1> |
| 939 | @ <div class='fileage'><table width="100%%"> |
| 940 | if( db_table_exists("repository","forumpost") ){ |
| 941 | db_prepare(&q, |
| 942 | "SELECT" |
| @@ -943,23 +948,43 @@ | |
| 948 | " FROM event WHERE objid=(SELECT fpid FROM forumpost AS y" |
| 949 | " WHERE y.froot=x.froot" |
| 950 | " ORDER BY fmtime DESC LIMIT 1))" |
| 951 | " FROM forumpost AS x" |
| 952 | " GROUP BY froot ORDER BY 1 LIMIT %d OFFSET %d;", |
| 953 | iLimit+1, iOfst |
| 954 | ); |
| 955 | iCnt = 0; |
| 956 | while( db_step(&q)==SQLITE_ROW ){ |
| 957 | char *zAge = 0; |
| 958 | char *zDuration = 0; |
| 959 | int nMsg = db_column_int(&q, 2); |
| 960 | const char *zUuid = db_column_text(&q, 3); |
| 961 | const char *zTitle = db_column_text(&q, 4); |
| 962 | if( iCnt==0 && iOfst>0 ){ |
| 963 | if( iOfst>iLimit ){ |
| 964 | @ <tr><td colspan="3">\ |
| 965 | @ %z(href("%R/forum?x=%d&n=%d",iOfst-iLimit,iLimit))\ |
| 966 | @ ↑ Newer...</a></td></tr> |
| 967 | }else{ |
| 968 | @ <tr><td colspan="3">%z(href("%R/forum?n=%d",iLimit))\ |
| 969 | @ ↑ Newer...</a></td></tr> |
| 970 | } |
| 971 | } |
| 972 | iCnt++; |
| 973 | if( iCnt>iLimit ){ |
| 974 | @ <tr><td colspan="3">\ |
| 975 | @ %z(href("%R/forum?x=%d&n=%d",iOfst+iLimit,iLimit))\ |
| 976 | @ ↓ Older...</a></td></tr> |
| 977 | break; |
| 978 | } |
| 979 | zAge = human_readable_age(db_column_double(&q,0)); |
| 980 | @ <tr><td>%h(zAge) ago</td> |
| 981 | @ <td>%z(href("%R/forumpost/%S",zUuid))%h(zTitle)</a></td> |
| 982 | if( nMsg<2 ){ |
| 983 | @ <td>no replies</td> |
| 984 | }else{ |
| 985 | zDuration = human_readable_age(db_column_double(&q,1)); |
| 986 | @ <td>%d(nMsg) posts spanning %h(zDuration)</td> |
| 987 | } |
| 988 | @ </tr> |
| 989 | fossil_free(zAge); |
| 990 | fossil_free(zDuration); |
| 991 |