Fossil SCM

A couple of minor fixes for (not) showing associated wikis. This amends [25f43cc634].

george 2025-03-13 00:45 trunk
Commit 3c2aba79a72f3df7bd8afff4740d4b9add29d584a3bdac86e094cc724f501941
1 file changed +19 -13
+19 -13
--- src/wiki.c
+++ src/wiki.c
@@ -21,10 +21,13 @@
2121
#include "config.h"
2222
#include <assert.h>
2323
#include <ctype.h>
2424
#include "wiki.h"
2525
26
+#define has_prefix(literal_prfx, zStr) \
27
+ (fossil_strncmp((zStr), "" literal_prfx, (sizeof literal_prfx)-1)==0)
28
+
2629
/*
2730
** Return true if the input string is a well-formed wiki page name.
2831
**
2932
** Well-formed wiki page names do not begin or end with whitespace,
3033
** and do not contain tabs or other control characters and do not
@@ -420,22 +423,22 @@
420423
*/
421424
int wiki_page_type(const char *zPageName){
422425
if( db_get_boolean("wiki-about",1)==0 ){
423426
return WIKITYPE_NORMAL;
424427
}else
425
- if( sqlite3_strglob("checkin/*", zPageName)==0
428
+ if( has_prefix("checkin/", zPageName)
426429
&& db_exists("SELECT 1 FROM blob WHERE uuid=%Q",zPageName+8)
427430
){
428431
return WIKITYPE_CHECKIN;
429432
}else
430
- if( sqlite3_strglob("branch/*", zPageName)==0 ){
433
+ if( has_prefix("branch/", zPageName) ){
431434
return WIKITYPE_BRANCH;
432435
}else
433
- if( sqlite3_strglob("tag/*", zPageName)==0 ){
436
+ if( has_prefix("tag/", zPageName) ){
434437
return WIKITYPE_TAG;
435438
}else
436
- if( sqlite3_strglob("ticket/*", zPageName)==0 ){
439
+ if( has_prefix("ticket/", zPageName) ){
437440
return WIKITYPE_TICKET;
438441
}
439442
return WIKITYPE_NORMAL;
440443
}
441444
@@ -1987,11 +1990,12 @@
19871990
style_submenu_element("All", "%R/wcontent?all=1");
19881991
}
19891992
cgi_check_for_malice();
19901993
showCkBr = db_exists(
19911994
"SELECT tag.tagname AS tn FROM tag JOIN tagxref USING(tagid) "
1992
- "WHERE ( tn GLOB 'wiki-checkin/*' OR tn GLOB 'wiki-branch/*' ) "
1995
+ "WHERE ( tn GLOB 'wiki-checkin/*' OR tn GLOB 'wiki-branch/*' OR "
1996
+ " tn GLOB 'wiki-tag/*' OR tn GLOB 'wiki-ticket/*' ) "
19931997
" AND TYPEOF(tagxref.value+0)='integer'" );
19941998
if( showCkBr ){
19951999
showCkBr = P("showckbr")!=0;
19962000
style_submenu_checkbox("showckbr", "Show associated wikis", 0, 0);
19972001
}
@@ -2017,20 +2021,20 @@
20172021
char *zAge;
20182022
int wcnt = db_column_int(&q, 4);
20192023
char *zWDisplayName;
20202024
20212025
if( !showCkBr &&
2022
- (sqlite3_strglob("checkin/*", zWName)==0 ||
2023
- sqlite3_strglob("branch/*", zWName)==0 ||
2024
- sqlite3_strglob("tag/*", zWName)==0 ||
2025
- sqlite3_strglob("ticket/*", zWName)==0) ){
2026
+ (has_prefix("checkin/", zWName) ||
2027
+ has_prefix("branch/", zWName) ||
2028
+ has_prefix("tag/", zWName) ||
2029
+ has_prefix("ticket/", zWName) )){
20262030
continue;
20272031
}
2028
- if( sqlite3_strglob("checkin/*", zWName)==0 ){
2032
+ if( has_prefix("checkin/",zWName) || has_prefix("ticket/",zWName) ){
20292033
zWDisplayName = mprintf("%.25s...", zWName);
20302034
}else{
2031
- zWDisplayName = mprintf("%s", zWName);
2035
+ zWDisplayName = fossil_strdup(zWName);
20322036
}
20332037
if( wrid==0 ){
20342038
if( !showAll ) continue;
20352039
@ <tr><td data-sortkey="%h(zSort)">\
20362040
@ %z(href("%R/whistory?name=%T",zWName))<s>%h(zWDisplayName)</s></a></td>
@@ -2522,12 +2526,14 @@
25222526
const int wrid = db_column_int(&q, 2);
25232527
if(!showAll && !wrid){
25242528
continue;
25252529
}
25262530
if( !showCkBr &&
2527
- (sqlite3_strglob("checkin/*", zName)==0 ||
2528
- sqlite3_strglob("branch/*", zName)==0) ){
2531
+ (has_prefix("checkin/", zName) ||
2532
+ has_prefix("branch/", zName) ||
2533
+ has_prefix("tag/", zName) ||
2534
+ has_prefix("ticket/", zName) ) ){
25292535
continue;
25302536
}
25312537
if( showIds ){
25322538
const char *zUuid = db_column_text(&q, 1);
25332539
fossil_print("%s ",zUuid);
25342540
--- src/wiki.c
+++ src/wiki.c
@@ -21,10 +21,13 @@
21 #include "config.h"
22 #include <assert.h>
23 #include <ctype.h>
24 #include "wiki.h"
25
 
 
 
26 /*
27 ** Return true if the input string is a well-formed wiki page name.
28 **
29 ** Well-formed wiki page names do not begin or end with whitespace,
30 ** and do not contain tabs or other control characters and do not
@@ -420,22 +423,22 @@
420 */
421 int wiki_page_type(const char *zPageName){
422 if( db_get_boolean("wiki-about",1)==0 ){
423 return WIKITYPE_NORMAL;
424 }else
425 if( sqlite3_strglob("checkin/*", zPageName)==0
426 && db_exists("SELECT 1 FROM blob WHERE uuid=%Q",zPageName+8)
427 ){
428 return WIKITYPE_CHECKIN;
429 }else
430 if( sqlite3_strglob("branch/*", zPageName)==0 ){
431 return WIKITYPE_BRANCH;
432 }else
433 if( sqlite3_strglob("tag/*", zPageName)==0 ){
434 return WIKITYPE_TAG;
435 }else
436 if( sqlite3_strglob("ticket/*", zPageName)==0 ){
437 return WIKITYPE_TICKET;
438 }
439 return WIKITYPE_NORMAL;
440 }
441
@@ -1987,11 +1990,12 @@
1987 style_submenu_element("All", "%R/wcontent?all=1");
1988 }
1989 cgi_check_for_malice();
1990 showCkBr = db_exists(
1991 "SELECT tag.tagname AS tn FROM tag JOIN tagxref USING(tagid) "
1992 "WHERE ( tn GLOB 'wiki-checkin/*' OR tn GLOB 'wiki-branch/*' ) "
 
1993 " AND TYPEOF(tagxref.value+0)='integer'" );
1994 if( showCkBr ){
1995 showCkBr = P("showckbr")!=0;
1996 style_submenu_checkbox("showckbr", "Show associated wikis", 0, 0);
1997 }
@@ -2017,20 +2021,20 @@
2017 char *zAge;
2018 int wcnt = db_column_int(&q, 4);
2019 char *zWDisplayName;
2020
2021 if( !showCkBr &&
2022 (sqlite3_strglob("checkin/*", zWName)==0 ||
2023 sqlite3_strglob("branch/*", zWName)==0 ||
2024 sqlite3_strglob("tag/*", zWName)==0 ||
2025 sqlite3_strglob("ticket/*", zWName)==0) ){
2026 continue;
2027 }
2028 if( sqlite3_strglob("checkin/*", zWName)==0 ){
2029 zWDisplayName = mprintf("%.25s...", zWName);
2030 }else{
2031 zWDisplayName = mprintf("%s", zWName);
2032 }
2033 if( wrid==0 ){
2034 if( !showAll ) continue;
2035 @ <tr><td data-sortkey="%h(zSort)">\
2036 @ %z(href("%R/whistory?name=%T",zWName))<s>%h(zWDisplayName)</s></a></td>
@@ -2522,12 +2526,14 @@
2522 const int wrid = db_column_int(&q, 2);
2523 if(!showAll && !wrid){
2524 continue;
2525 }
2526 if( !showCkBr &&
2527 (sqlite3_strglob("checkin/*", zName)==0 ||
2528 sqlite3_strglob("branch/*", zName)==0) ){
 
 
2529 continue;
2530 }
2531 if( showIds ){
2532 const char *zUuid = db_column_text(&q, 1);
2533 fossil_print("%s ",zUuid);
2534
--- src/wiki.c
+++ src/wiki.c
@@ -21,10 +21,13 @@
21 #include "config.h"
22 #include <assert.h>
23 #include <ctype.h>
24 #include "wiki.h"
25
26 #define has_prefix(literal_prfx, zStr) \
27 (fossil_strncmp((zStr), "" literal_prfx, (sizeof literal_prfx)-1)==0)
28
29 /*
30 ** Return true if the input string is a well-formed wiki page name.
31 **
32 ** Well-formed wiki page names do not begin or end with whitespace,
33 ** and do not contain tabs or other control characters and do not
@@ -420,22 +423,22 @@
423 */
424 int wiki_page_type(const char *zPageName){
425 if( db_get_boolean("wiki-about",1)==0 ){
426 return WIKITYPE_NORMAL;
427 }else
428 if( has_prefix("checkin/", zPageName)
429 && db_exists("SELECT 1 FROM blob WHERE uuid=%Q",zPageName+8)
430 ){
431 return WIKITYPE_CHECKIN;
432 }else
433 if( has_prefix("branch/", zPageName) ){
434 return WIKITYPE_BRANCH;
435 }else
436 if( has_prefix("tag/", zPageName) ){
437 return WIKITYPE_TAG;
438 }else
439 if( has_prefix("ticket/", zPageName) ){
440 return WIKITYPE_TICKET;
441 }
442 return WIKITYPE_NORMAL;
443 }
444
@@ -1987,11 +1990,12 @@
1990 style_submenu_element("All", "%R/wcontent?all=1");
1991 }
1992 cgi_check_for_malice();
1993 showCkBr = db_exists(
1994 "SELECT tag.tagname AS tn FROM tag JOIN tagxref USING(tagid) "
1995 "WHERE ( tn GLOB 'wiki-checkin/*' OR tn GLOB 'wiki-branch/*' OR "
1996 " tn GLOB 'wiki-tag/*' OR tn GLOB 'wiki-ticket/*' ) "
1997 " AND TYPEOF(tagxref.value+0)='integer'" );
1998 if( showCkBr ){
1999 showCkBr = P("showckbr")!=0;
2000 style_submenu_checkbox("showckbr", "Show associated wikis", 0, 0);
2001 }
@@ -2017,20 +2021,20 @@
2021 char *zAge;
2022 int wcnt = db_column_int(&q, 4);
2023 char *zWDisplayName;
2024
2025 if( !showCkBr &&
2026 (has_prefix("checkin/", zWName) ||
2027 has_prefix("branch/", zWName) ||
2028 has_prefix("tag/", zWName) ||
2029 has_prefix("ticket/", zWName) )){
2030 continue;
2031 }
2032 if( has_prefix("checkin/",zWName) || has_prefix("ticket/",zWName) ){
2033 zWDisplayName = mprintf("%.25s...", zWName);
2034 }else{
2035 zWDisplayName = fossil_strdup(zWName);
2036 }
2037 if( wrid==0 ){
2038 if( !showAll ) continue;
2039 @ <tr><td data-sortkey="%h(zSort)">\
2040 @ %z(href("%R/whistory?name=%T",zWName))<s>%h(zWDisplayName)</s></a></td>
@@ -2522,12 +2526,14 @@
2526 const int wrid = db_column_int(&q, 2);
2527 if(!showAll && !wrid){
2528 continue;
2529 }
2530 if( !showCkBr &&
2531 (has_prefix("checkin/", zName) ||
2532 has_prefix("branch/", zName) ||
2533 has_prefix("tag/", zName) ||
2534 has_prefix("ticket/", zName) ) ){
2535 continue;
2536 }
2537 if( showIds ){
2538 const char *zUuid = db_column_text(&q, 1);
2539 fossil_print("%s ",zUuid);
2540

Keyboard Shortcuts

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