Fossil SCM

Enhance the /wcontent page to show a sortable list of wiki pages together with the number of versions and the time of last change.

drh 2018-12-11 16:28 trunk
Commit 81c22bc6b8605da5cb8aa113c6f9605e2fd9b2cbe174576bbbac8b8b7642c420
2 files changed +2 -2 +57 -25
+2 -2
--- src/branch.c
+++ src/branch.c
@@ -20,11 +20,11 @@
2020
#include "config.h"
2121
#include "branch.h"
2222
#include <assert.h>
2323
2424
/*
25
-** fossil branch new NAME BASIS ?OPTIONS?
25
+** fossil branch new NAME BASIS ?OPTIONS?
2626
** argv0 argv1 argv2 argv3 argv4
2727
*/
2828
void branch_new(void){
2929
int rootid; /* RID of the root check-in - what we branch off of */
3030
int brid; /* RID of the branch check-in */
@@ -435,11 +435,11 @@
435435
rNow = db_double(0.0, "SELECT julianday('now')");
436436
@ <div class="brlist">
437437
@ <table class='sortable' data-column-types='tkNtt' data-init-sort='2'>
438438
@ <thead><tr>
439439
@ <th>Branch Name</th>
440
- @ <th>Age</th>
440
+ @ <th>Last Change</th>
441441
@ <th>Check-ins</th>
442442
@ <th>Status</th>
443443
@ <th>Resolution</th>
444444
@ </tr></thead><tbody>
445445
while( db_step(&q)==SQLITE_ROW ){
446446
--- src/branch.c
+++ src/branch.c
@@ -20,11 +20,11 @@
20 #include "config.h"
21 #include "branch.h"
22 #include <assert.h>
23
24 /*
25 ** fossil branch new NAME BASIS ?OPTIONS?
26 ** argv0 argv1 argv2 argv3 argv4
27 */
28 void branch_new(void){
29 int rootid; /* RID of the root check-in - what we branch off of */
30 int brid; /* RID of the branch check-in */
@@ -435,11 +435,11 @@
435 rNow = db_double(0.0, "SELECT julianday('now')");
436 @ <div class="brlist">
437 @ <table class='sortable' data-column-types='tkNtt' data-init-sort='2'>
438 @ <thead><tr>
439 @ <th>Branch Name</th>
440 @ <th>Age</th>
441 @ <th>Check-ins</th>
442 @ <th>Status</th>
443 @ <th>Resolution</th>
444 @ </tr></thead><tbody>
445 while( db_step(&q)==SQLITE_ROW ){
446
--- src/branch.c
+++ src/branch.c
@@ -20,11 +20,11 @@
20 #include "config.h"
21 #include "branch.h"
22 #include <assert.h>
23
24 /*
25 ** fossil branch new NAME BASIS ?OPTIONS?
26 ** argv0 argv1 argv2 argv3 argv4
27 */
28 void branch_new(void){
29 int rootid; /* RID of the root check-in - what we branch off of */
30 int brid; /* RID of the branch check-in */
@@ -435,11 +435,11 @@
435 rNow = db_double(0.0, "SELECT julianday('now')");
436 @ <div class="brlist">
437 @ <table class='sortable' data-column-types='tkNtt' data-init-sort='2'>
438 @ <thead><tr>
439 @ <th>Branch Name</th>
440 @ <th>Last Change</th>
441 @ <th>Check-ins</th>
442 @ <th>Status</th>
443 @ <th>Resolution</th>
444 @ </tr></thead><tbody>
445 while( db_step(&q)==SQLITE_ROW ){
446
+57 -25
--- src/wiki.c
+++ src/wiki.c
@@ -934,36 +934,47 @@
934934
manifest_destroy(pW2);
935935
style_footer();
936936
}
937937
938938
/*
939
-** prepare()s pStmt with a query requesting:
939
+** A query that returns information about all wiki pages.
940940
**
941
-** - wiki page name
942
-** - tagxref (whatever that really is!)
941
+** wname Name of the wiki page
942
+** wsort Sort names by this label
943
+** wrid rid of the most recent version of the page
944
+** wmtime time most recent version was created
945
+** wcnt Number of versions of this wiki page
943946
**
944
-** Used by wcontent_page() and the JSON wiki code.
947
+** The wrid value is zero for deleted wiki pages.
945948
*/
946
-void wiki_prepare_page_list( Stmt * pStmt ){
947
- db_prepare(pStmt,
948
- "SELECT"
949
- " substr(tagname, 6) as name,"
950
- " (SELECT value FROM tagxref WHERE tagid=tag.tagid"
951
- " ORDER BY mtime DESC) as tagXref"
952
- " FROM tag WHERE tagname GLOB 'wiki-*'"
953
- " ORDER BY lower(tagname) /*sort*/"
954
- );
955
-}
949
+static const char listAllWikiPages[] =
950
+@ SELECT
951
+@ substr(tag.tagname, 6) AS wname,
952
+@ lower(substr(tag.tagname, 6)) AS sortname,
953
+@ tagxref.value+0 AS wrid,
954
+@ max(tagxref.mtime) AS wmtime,
955
+@ count(*) AS wcnt
956
+@ FROM
957
+@ tag,
958
+@ tagxref
959
+@ WHERE
960
+@ tag.tagname GLOB 'wiki-*'
961
+@ AND tagxref.tagid=tag.tagid
962
+@ GROUP BY 1
963
+@ ORDER BY 2;
964
+;
965
+
956966
/*
957967
** WEBPAGE: wcontent
958968
**
959969
** all=1 Show deleted pages
960970
**
961971
** List all available wiki pages with date created and last modified.
962972
*/
963973
void wcontent_page(void){
964974
Stmt q;
975
+ double rNow;
965976
int showAll = P("all")!=0;
966977
967978
login_check_credentials();
968979
if( !g.perm.RdWiki ){ login_needed(g.anon.RdWiki); return; }
969980
style_header("Available Wiki Pages");
@@ -971,23 +982,44 @@
971982
style_submenu_element("Active", "%s/wcontent", g.zTop);
972983
}else{
973984
style_submenu_element("All", "%s/wcontent?all=1", g.zTop);
974985
}
975986
wiki_standard_submenu(W_ALL_BUT(W_LIST));
976
- @ <ul>
977
- wiki_prepare_page_list(&q);
987
+ db_prepare(&q, listAllWikiPages/*works-like:""*/);
988
+ @ <div class="brlist">
989
+ @ <table class='sortable' data-column-types='tKN' data-init-sort='1'>
990
+ @ <thead><tr>
991
+ @ <th>Name</th>
992
+ @ <th>Last Change</th>
993
+ @ <th>Versions</th>
994
+ @ </tr></thead><tbody>
995
+ rNow = db_double(0.0, "SELECT julianday('now')");
978996
while( db_step(&q)==SQLITE_ROW ){
979
- const char *zName = db_column_text(&q, 0);
980
- int size = db_column_int(&q, 1);
981
- if( size>0 ){
982
- @ <li>%z(href("%R/wiki?name=%T",zName))%h(zName)</a></li>
983
- }else if( showAll ){
984
- @ <li>%z(href("%R/wiki?name=%T",zName))<s>%h(zName)</s></a></li>
985
- }
986
- }
997
+ const char *zWName = db_column_text(&q, 0);
998
+ const char *zSort = db_column_text(&q, 1);
999
+ int wrid = db_column_int(&q, 2);
1000
+ double rWmtime = db_column_double(&q, 3);
1001
+ sqlite3_int64 iMtime = (sqlite3_int64)(rWmtime*86400.0);
1002
+ char *zAge;
1003
+ int wcnt = db_column_int(&q, 4);
1004
+ if( wrid==0 ){
1005
+ if( !showAll ) continue;
1006
+ @ <tr><td data-sortkey="%h(zSort)">\
1007
+ @ %z(href("%R/whistory?name=%T",zWName))<s>%h(zWName)</s></a></td>
1008
+ }else{
1009
+ @ <tr><td data=sortkey='%h(zSort)">\
1010
+ @ %z(href("%R/wiki?name=%T",zWName))%h(zWName)</a></td>
1011
+ }
1012
+ zAge = human_readable_age(rNow - rWmtime);
1013
+ @ <td data-sortkey="%016llx(iMtime)">%s(zAge)</td>
1014
+ fossil_free(zAge);
1015
+ @ <td>%z(href("%R/whistory?name=%T",zWName))%d(wcnt)</a></td>
1016
+ @ </tr>
1017
+ }
1018
+ @ </tbody></table></div>
9871019
db_finalize(&q);
988
- @ </ul>
1020
+ style_table_sorter();
9891021
style_footer();
9901022
}
9911023
9921024
/*
9931025
** WEBPAGE: wfind
9941026
--- src/wiki.c
+++ src/wiki.c
@@ -934,36 +934,47 @@
934 manifest_destroy(pW2);
935 style_footer();
936 }
937
938 /*
939 ** prepare()s pStmt with a query requesting:
940 **
941 ** - wiki page name
942 ** - tagxref (whatever that really is!)
 
 
 
943 **
944 ** Used by wcontent_page() and the JSON wiki code.
945 */
946 void wiki_prepare_page_list( Stmt * pStmt ){
947 db_prepare(pStmt,
948 "SELECT"
949 " substr(tagname, 6) as name,"
950 " (SELECT value FROM tagxref WHERE tagid=tag.tagid"
951 " ORDER BY mtime DESC) as tagXref"
952 " FROM tag WHERE tagname GLOB 'wiki-*'"
953 " ORDER BY lower(tagname) /*sort*/"
954 );
955 }
 
 
 
 
 
 
 
956 /*
957 ** WEBPAGE: wcontent
958 **
959 ** all=1 Show deleted pages
960 **
961 ** List all available wiki pages with date created and last modified.
962 */
963 void wcontent_page(void){
964 Stmt q;
 
965 int showAll = P("all")!=0;
966
967 login_check_credentials();
968 if( !g.perm.RdWiki ){ login_needed(g.anon.RdWiki); return; }
969 style_header("Available Wiki Pages");
@@ -971,23 +982,44 @@
971 style_submenu_element("Active", "%s/wcontent", g.zTop);
972 }else{
973 style_submenu_element("All", "%s/wcontent?all=1", g.zTop);
974 }
975 wiki_standard_submenu(W_ALL_BUT(W_LIST));
976 @ <ul>
977 wiki_prepare_page_list(&q);
 
 
 
 
 
 
 
978 while( db_step(&q)==SQLITE_ROW ){
979 const char *zName = db_column_text(&q, 0);
980 int size = db_column_int(&q, 1);
981 if( size>0 ){
982 @ <li>%z(href("%R/wiki?name=%T",zName))%h(zName)</a></li>
983 }else if( showAll ){
984 @ <li>%z(href("%R/wiki?name=%T",zName))<s>%h(zName)</s></a></li>
985 }
986 }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
987 db_finalize(&q);
988 @ </ul>
989 style_footer();
990 }
991
992 /*
993 ** WEBPAGE: wfind
994
--- src/wiki.c
+++ src/wiki.c
@@ -934,36 +934,47 @@
934 manifest_destroy(pW2);
935 style_footer();
936 }
937
938 /*
939 ** A query that returns information about all wiki pages.
940 **
941 ** wname Name of the wiki page
942 ** wsort Sort names by this label
943 ** wrid rid of the most recent version of the page
944 ** wmtime time most recent version was created
945 ** wcnt Number of versions of this wiki page
946 **
947 ** The wrid value is zero for deleted wiki pages.
948 */
949 static const char listAllWikiPages[] =
950 @ SELECT
951 @ substr(tag.tagname, 6) AS wname,
952 @ lower(substr(tag.tagname, 6)) AS sortname,
953 @ tagxref.value+0 AS wrid,
954 @ max(tagxref.mtime) AS wmtime,
955 @ count(*) AS wcnt
956 @ FROM
957 @ tag,
958 @ tagxref
959 @ WHERE
960 @ tag.tagname GLOB 'wiki-*'
961 @ AND tagxref.tagid=tag.tagid
962 @ GROUP BY 1
963 @ ORDER BY 2;
964 ;
965
966 /*
967 ** WEBPAGE: wcontent
968 **
969 ** all=1 Show deleted pages
970 **
971 ** List all available wiki pages with date created and last modified.
972 */
973 void wcontent_page(void){
974 Stmt q;
975 double rNow;
976 int showAll = P("all")!=0;
977
978 login_check_credentials();
979 if( !g.perm.RdWiki ){ login_needed(g.anon.RdWiki); return; }
980 style_header("Available Wiki Pages");
@@ -971,23 +982,44 @@
982 style_submenu_element("Active", "%s/wcontent", g.zTop);
983 }else{
984 style_submenu_element("All", "%s/wcontent?all=1", g.zTop);
985 }
986 wiki_standard_submenu(W_ALL_BUT(W_LIST));
987 db_prepare(&q, listAllWikiPages/*works-like:""*/);
988 @ <div class="brlist">
989 @ <table class='sortable' data-column-types='tKN' data-init-sort='1'>
990 @ <thead><tr>
991 @ <th>Name</th>
992 @ <th>Last Change</th>
993 @ <th>Versions</th>
994 @ </tr></thead><tbody>
995 rNow = db_double(0.0, "SELECT julianday('now')");
996 while( db_step(&q)==SQLITE_ROW ){
997 const char *zWName = db_column_text(&q, 0);
998 const char *zSort = db_column_text(&q, 1);
999 int wrid = db_column_int(&q, 2);
1000 double rWmtime = db_column_double(&q, 3);
1001 sqlite3_int64 iMtime = (sqlite3_int64)(rWmtime*86400.0);
1002 char *zAge;
1003 int wcnt = db_column_int(&q, 4);
1004 if( wrid==0 ){
1005 if( !showAll ) continue;
1006 @ <tr><td data-sortkey="%h(zSort)">\
1007 @ %z(href("%R/whistory?name=%T",zWName))<s>%h(zWName)</s></a></td>
1008 }else{
1009 @ <tr><td data=sortkey='%h(zSort)">\
1010 @ %z(href("%R/wiki?name=%T",zWName))%h(zWName)</a></td>
1011 }
1012 zAge = human_readable_age(rNow - rWmtime);
1013 @ <td data-sortkey="%016llx(iMtime)">%s(zAge)</td>
1014 fossil_free(zAge);
1015 @ <td>%z(href("%R/whistory?name=%T",zWName))%d(wcnt)</a></td>
1016 @ </tr>
1017 }
1018 @ </tbody></table></div>
1019 db_finalize(&q);
1020 style_table_sorter();
1021 style_footer();
1022 }
1023
1024 /*
1025 ** WEBPAGE: wfind
1026

Keyboard Shortcuts

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