Fossil SCM

Improved title on on the /forum page.

drh 2018-08-15 20:50 trunk
Commit dbd96b2c74520c21d39e31a96c07b287ef4d4e24c17b9b5ce3a4a937932178af
1 file changed +24 -13
+24 -13
--- src/forum.c
+++ src/forum.c
@@ -933,14 +933,13 @@
933933
style_footer();
934934
return;
935935
}
936936
iLimit = atoi(PD("n","25"));
937937
iOfst = atoi(PD("x","0"));
938
- @ <h1>Recent Threads</h1>
939
- @ <div class='fileage'><table width="100%%">
938
+ iCnt = 0;
940939
if( db_table_exists("repository","forumpost") ){
941
- db_prepare(&q,
940
+ db_prepare(&q,
942941
"SELECT"
943942
" julianday('now') - max(fmtime) AS a," /* 0 */
944943
" max(fmtime) - min(fmtime) AS b," /* 1 */
945944
" sum(fprev IS NULL) AS c," /* 2 */
946945
" (SELECT substr(uuid,1,10) FROM blob WHERE rid=froot)," /* 3 */
@@ -950,35 +949,43 @@
950949
" ORDER BY fmtime DESC LIMIT 1))"
951950
" FROM forumpost AS x"
952951
" GROUP BY froot ORDER BY 1 LIMIT %d OFFSET %d;",
953952
iLimit+1, iOfst
954953
);
955
- iCnt = 0;
956954
while( db_step(&q)==SQLITE_ROW ){
957955
char *zAge = 0;
958956
char *zDuration = 0;
959957
int nMsg = db_column_int(&q, 2);
960958
const char *zUuid = db_column_text(&q, 3);
961959
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
- @ &uarr; Newer...</a></td></tr>
960
+ zAge = human_readable_age(db_column_double(&q,0));
961
+ if( iCnt==0 ){
962
+ if( iOfst>0 ){
963
+ @ <h1>Threads at least %s(zAge) old</h1>
967964
}else{
968
- @ <tr><td colspan="3">%z(href("%R/forum?n=%d",iLimit))\
969
- @ &uarr; Newer...</a></td></tr>
965
+ @ <h1>Most recent threads</h1>
966
+ }
967
+ @ <div class='fileage'><table width="100%%">
968
+ if( iOfst>0 ){
969
+ if( iOfst>iLimit ){
970
+ @ <tr><td colspan="3">\
971
+ @ %z(href("%R/forum?x=%d&n=%d",iOfst-iLimit,iLimit))\
972
+ @ &uarr; Newer...</a></td></tr>
973
+ }else{
974
+ @ <tr><td colspan="3">%z(href("%R/forum?n=%d",iLimit))\
975
+ @ &uarr; Newer...</a></td></tr>
976
+ }
970977
}
971978
}
972979
iCnt++;
973980
if( iCnt>iLimit ){
974981
@ <tr><td colspan="3">\
975982
@ %z(href("%R/forum?x=%d&n=%d",iOfst+iLimit,iLimit))\
976983
@ &darr; Older...</a></td></tr>
984
+ fossil_free(zAge);
977985
break;
978986
}
979
- zAge = human_readable_age(db_column_double(&q,0));
980987
@ <tr><td>%h(zAge) ago</td>
981988
@ <td>%z(href("%R/forumpost/%S",zUuid))%h(zTitle)</a></td>
982989
if( nMsg<2 ){
983990
@ <td>no replies</td>
984991
}else{
@@ -989,8 +996,12 @@
989996
fossil_free(zAge);
990997
fossil_free(zDuration);
991998
}
992999
db_finalize(&q);
9931000
}
994
- @ </table></div>
1001
+ if( iCnt>0 ){
1002
+ @ </table></div>
1003
+ }else{
1004
+ @ <h1>No forum posts found</h1>
1005
+ }
9951006
style_footer();
9961007
}
9971008
--- src/forum.c
+++ src/forum.c
@@ -933,14 +933,13 @@
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 " julianday('now') - max(fmtime) AS a," /* 0 */
944 " max(fmtime) - min(fmtime) AS b," /* 1 */
945 " sum(fprev IS NULL) AS c," /* 2 */
946 " (SELECT substr(uuid,1,10) FROM blob WHERE rid=froot)," /* 3 */
@@ -950,35 +949,43 @@
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 @ &uarr; Newer...</a></td></tr>
967 }else{
968 @ <tr><td colspan="3">%z(href("%R/forum?n=%d",iLimit))\
969 @ &uarr; 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 @ &darr; 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{
@@ -989,8 +996,12 @@
989 fossil_free(zAge);
990 fossil_free(zDuration);
991 }
992 db_finalize(&q);
993 }
994 @ </table></div>
 
 
 
 
995 style_footer();
996 }
997
--- src/forum.c
+++ src/forum.c
@@ -933,14 +933,13 @@
933 style_footer();
934 return;
935 }
936 iLimit = atoi(PD("n","25"));
937 iOfst = atoi(PD("x","0"));
938 iCnt = 0;
 
939 if( db_table_exists("repository","forumpost") ){
940 db_prepare(&q,
941 "SELECT"
942 " julianday('now') - max(fmtime) AS a," /* 0 */
943 " max(fmtime) - min(fmtime) AS b," /* 1 */
944 " sum(fprev IS NULL) AS c," /* 2 */
945 " (SELECT substr(uuid,1,10) FROM blob WHERE rid=froot)," /* 3 */
@@ -950,35 +949,43 @@
949 " ORDER BY fmtime DESC LIMIT 1))"
950 " FROM forumpost AS x"
951 " GROUP BY froot ORDER BY 1 LIMIT %d OFFSET %d;",
952 iLimit+1, iOfst
953 );
 
954 while( db_step(&q)==SQLITE_ROW ){
955 char *zAge = 0;
956 char *zDuration = 0;
957 int nMsg = db_column_int(&q, 2);
958 const char *zUuid = db_column_text(&q, 3);
959 const char *zTitle = db_column_text(&q, 4);
960 zAge = human_readable_age(db_column_double(&q,0));
961 if( iCnt==0 ){
962 if( iOfst>0 ){
963 @ <h1>Threads at least %s(zAge) old</h1>
 
964 }else{
965 @ <h1>Most recent threads</h1>
966 }
967 @ <div class='fileage'><table width="100%%">
968 if( iOfst>0 ){
969 if( iOfst>iLimit ){
970 @ <tr><td colspan="3">\
971 @ %z(href("%R/forum?x=%d&n=%d",iOfst-iLimit,iLimit))\
972 @ &uarr; Newer...</a></td></tr>
973 }else{
974 @ <tr><td colspan="3">%z(href("%R/forum?n=%d",iLimit))\
975 @ &uarr; Newer...</a></td></tr>
976 }
977 }
978 }
979 iCnt++;
980 if( iCnt>iLimit ){
981 @ <tr><td colspan="3">\
982 @ %z(href("%R/forum?x=%d&n=%d",iOfst+iLimit,iLimit))\
983 @ &darr; Older...</a></td></tr>
984 fossil_free(zAge);
985 break;
986 }
 
987 @ <tr><td>%h(zAge) ago</td>
988 @ <td>%z(href("%R/forumpost/%S",zUuid))%h(zTitle)</a></td>
989 if( nMsg<2 ){
990 @ <td>no replies</td>
991 }else{
@@ -989,8 +996,12 @@
996 fossil_free(zAge);
997 fossil_free(zDuration);
998 }
999 db_finalize(&q);
1000 }
1001 if( iCnt>0 ){
1002 @ </table></div>
1003 }else{
1004 @ <h1>No forum posts found</h1>
1005 }
1006 style_footer();
1007 }
1008

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button