Fossil SCM
Add the name= query parameter to the <base> for wiki pages, so that hyperlinks to fragments work correctly.
Commit
a116d974b4afede259125d6e695661ce32e9a28c
Parent
ac2d29326be52d3…
2 files changed
+21
-1
+5
-6
+21
-1
| --- src/style.c | ||
| +++ src/style.c | ||
| @@ -159,10 +159,30 @@ | ||
| 159 | 159 | static int submenuCompare(const void *a, const void *b){ |
| 160 | 160 | const struct Submenu *A = (const struct Submenu*)a; |
| 161 | 161 | const struct Submenu *B = (const struct Submenu*)b; |
| 162 | 162 | return fossil_strcmp(A->zLabel, B->zLabel); |
| 163 | 163 | } |
| 164 | + | |
| 165 | +/* Use this for the $current_page variable if it is not NULL. If it is | |
| 166 | +** NULL then use g.zPath. | |
| 167 | +*/ | |
| 168 | +static char *local_zCurrentPage = 0; | |
| 169 | + | |
| 170 | +/* | |
| 171 | +** Set the desired $current_page to something other than g.zPath | |
| 172 | +*/ | |
| 173 | +void style_set_current_page(const char *zFormat, ...){ | |
| 174 | + fossil_free(local_zCurrentPage); | |
| 175 | + if( zFormat==0 ){ | |
| 176 | + local_zCurrentPage = 0; | |
| 177 | + }else{ | |
| 178 | + va_list ap; | |
| 179 | + va_start(ap, zFormat); | |
| 180 | + local_zCurrentPage = vmprintf(zFormat, ap); | |
| 181 | + va_end(ap); | |
| 182 | + } | |
| 183 | +} | |
| 164 | 184 | |
| 165 | 185 | /* |
| 166 | 186 | ** Draw the header. |
| 167 | 187 | */ |
| 168 | 188 | void style_header(const char *zTitleFormat, ...){ |
| @@ -185,11 +205,11 @@ | ||
| 185 | 205 | Th_Store("project_name", db_get("project-name","Unnamed Fossil Project")); |
| 186 | 206 | Th_Store("title", zTitle); |
| 187 | 207 | Th_Store("baseurl", g.zBaseURL); |
| 188 | 208 | Th_Store("home", g.zTop); |
| 189 | 209 | Th_Store("index_page", db_get("index-page","/home")); |
| 190 | - Th_Store("current_page", g.zPath); | |
| 210 | + Th_Store("current_page", local_zCurrentPage ? local_zCurrentPage : g.zPath); | |
| 191 | 211 | Th_Store("release_version", RELEASE_VERSION); |
| 192 | 212 | Th_Store("manifest_version", MANIFEST_VERSION); |
| 193 | 213 | Th_Store("manifest_date", MANIFEST_DATE); |
| 194 | 214 | Th_Store("compiler_name", COMPILER_NAME); |
| 195 | 215 | if( g.zLogin ){ |
| 196 | 216 |
| --- src/style.c | |
| +++ src/style.c | |
| @@ -159,10 +159,30 @@ | |
| 159 | static int submenuCompare(const void *a, const void *b){ |
| 160 | const struct Submenu *A = (const struct Submenu*)a; |
| 161 | const struct Submenu *B = (const struct Submenu*)b; |
| 162 | return fossil_strcmp(A->zLabel, B->zLabel); |
| 163 | } |
| 164 | |
| 165 | /* |
| 166 | ** Draw the header. |
| 167 | */ |
| 168 | void style_header(const char *zTitleFormat, ...){ |
| @@ -185,11 +205,11 @@ | |
| 185 | Th_Store("project_name", db_get("project-name","Unnamed Fossil Project")); |
| 186 | Th_Store("title", zTitle); |
| 187 | Th_Store("baseurl", g.zBaseURL); |
| 188 | Th_Store("home", g.zTop); |
| 189 | Th_Store("index_page", db_get("index-page","/home")); |
| 190 | Th_Store("current_page", g.zPath); |
| 191 | Th_Store("release_version", RELEASE_VERSION); |
| 192 | Th_Store("manifest_version", MANIFEST_VERSION); |
| 193 | Th_Store("manifest_date", MANIFEST_DATE); |
| 194 | Th_Store("compiler_name", COMPILER_NAME); |
| 195 | if( g.zLogin ){ |
| 196 |
| --- src/style.c | |
| +++ src/style.c | |
| @@ -159,10 +159,30 @@ | |
| 159 | static int submenuCompare(const void *a, const void *b){ |
| 160 | const struct Submenu *A = (const struct Submenu*)a; |
| 161 | const struct Submenu *B = (const struct Submenu*)b; |
| 162 | return fossil_strcmp(A->zLabel, B->zLabel); |
| 163 | } |
| 164 | |
| 165 | /* Use this for the $current_page variable if it is not NULL. If it is |
| 166 | ** NULL then use g.zPath. |
| 167 | */ |
| 168 | static char *local_zCurrentPage = 0; |
| 169 | |
| 170 | /* |
| 171 | ** Set the desired $current_page to something other than g.zPath |
| 172 | */ |
| 173 | void style_set_current_page(const char *zFormat, ...){ |
| 174 | fossil_free(local_zCurrentPage); |
| 175 | if( zFormat==0 ){ |
| 176 | local_zCurrentPage = 0; |
| 177 | }else{ |
| 178 | va_list ap; |
| 179 | va_start(ap, zFormat); |
| 180 | local_zCurrentPage = vmprintf(zFormat, ap); |
| 181 | va_end(ap); |
| 182 | } |
| 183 | } |
| 184 | |
| 185 | /* |
| 186 | ** Draw the header. |
| 187 | */ |
| 188 | void style_header(const char *zTitleFormat, ...){ |
| @@ -185,11 +205,11 @@ | |
| 205 | Th_Store("project_name", db_get("project-name","Unnamed Fossil Project")); |
| 206 | Th_Store("title", zTitle); |
| 207 | Th_Store("baseurl", g.zBaseURL); |
| 208 | Th_Store("home", g.zTop); |
| 209 | Th_Store("index_page", db_get("index-page","/home")); |
| 210 | Th_Store("current_page", local_zCurrentPage ? local_zCurrentPage : g.zPath); |
| 211 | Th_Store("release_version", RELEASE_VERSION); |
| 212 | Th_Store("manifest_version", MANIFEST_VERSION); |
| 213 | Th_Store("manifest_date", MANIFEST_DATE); |
| 214 | Th_Store("compiler_name", COMPILER_NAME); |
| 215 | if( g.zLogin ){ |
| 216 |
+5
-6
| --- src/wiki.c | ||
| +++ src/wiki.c | ||
| @@ -209,10 +209,11 @@ | ||
| 209 | 209 | if( g.perm.Hyperlink ){ |
| 210 | 210 | style_submenu_element("History", "History", "%s/whistory?name=%T", |
| 211 | 211 | g.zTop, zPageName); |
| 212 | 212 | } |
| 213 | 213 | } |
| 214 | + style_set_current_page("%s?name=%T", g.zPath, zPageName); | |
| 214 | 215 | style_header(zPageName); |
| 215 | 216 | blob_init(&wiki, zBody, -1); |
| 216 | 217 | wiki_convert(&wiki, 0, 0); |
| 217 | 218 | blob_reset(&wiki); |
| 218 | 219 | |
| @@ -263,11 +264,10 @@ | ||
| 263 | 264 | int rid = 0; |
| 264 | 265 | int isSandbox; |
| 265 | 266 | Blob wiki; |
| 266 | 267 | Manifest *pWiki = 0; |
| 267 | 268 | const char *zPageName; |
| 268 | - char *zHtmlPageName; | |
| 269 | 269 | int n; |
| 270 | 270 | const char *z; |
| 271 | 271 | char *zBody = (char*)P("w"); |
| 272 | 272 | int isWysiwyg = P("wysiwyg")!=0; |
| 273 | 273 | |
| @@ -351,12 +351,12 @@ | ||
| 351 | 351 | return; |
| 352 | 352 | } |
| 353 | 353 | if( zBody==0 ){ |
| 354 | 354 | zBody = mprintf("<i>Empty Page</i>"); |
| 355 | 355 | } |
| 356 | - zHtmlPageName = mprintf("Edit: %s", zPageName); | |
| 357 | - style_header(zHtmlPageName); | |
| 356 | + style_set_current_page("%s?name=%T", g.zPath, zPageName); | |
| 357 | + style_header("Edit: %s", zPageName); | |
| 358 | 358 | blob_zero(&wiki); |
| 359 | 359 | blob_append(&wiki, zBody, -1); |
| 360 | 360 | if( P("preview")!=0 ){ |
| 361 | 361 | @ Preview:<hr /> |
| 362 | 362 | wiki_convert(&wiki, 0, 0); |
| @@ -474,11 +474,10 @@ | ||
| 474 | 474 | void wikiappend_page(void){ |
| 475 | 475 | char *zTag; |
| 476 | 476 | int rid = 0; |
| 477 | 477 | int isSandbox; |
| 478 | 478 | const char *zPageName; |
| 479 | - char *zHtmlPageName; | |
| 480 | 479 | const char *zUser; |
| 481 | 480 | |
| 482 | 481 | login_check_credentials(); |
| 483 | 482 | zPageName = PD("name",""); |
| 484 | 483 | if( check_name(zPageName) ) return; |
| @@ -549,12 +548,12 @@ | ||
| 549 | 548 | } |
| 550 | 549 | if( P("cancel")!=0 ){ |
| 551 | 550 | cgi_redirectf("wiki?name=%T", zPageName); |
| 552 | 551 | return; |
| 553 | 552 | } |
| 554 | - zHtmlPageName = mprintf("Append Comment To: %s", zPageName); | |
| 555 | - style_header(zHtmlPageName); | |
| 553 | + style_set_current_page("%s?name=%T", g.zPath, zPageName); | |
| 554 | + style_header("Append Comment To: %s", zPageName); | |
| 556 | 555 | if( P("preview")!=0 ){ |
| 557 | 556 | Blob preview; |
| 558 | 557 | blob_zero(&preview); |
| 559 | 558 | appendRemark(&preview); |
| 560 | 559 | @ Preview:<hr> |
| 561 | 560 |
| --- src/wiki.c | |
| +++ src/wiki.c | |
| @@ -209,10 +209,11 @@ | |
| 209 | if( g.perm.Hyperlink ){ |
| 210 | style_submenu_element("History", "History", "%s/whistory?name=%T", |
| 211 | g.zTop, zPageName); |
| 212 | } |
| 213 | } |
| 214 | style_header(zPageName); |
| 215 | blob_init(&wiki, zBody, -1); |
| 216 | wiki_convert(&wiki, 0, 0); |
| 217 | blob_reset(&wiki); |
| 218 | |
| @@ -263,11 +264,10 @@ | |
| 263 | int rid = 0; |
| 264 | int isSandbox; |
| 265 | Blob wiki; |
| 266 | Manifest *pWiki = 0; |
| 267 | const char *zPageName; |
| 268 | char *zHtmlPageName; |
| 269 | int n; |
| 270 | const char *z; |
| 271 | char *zBody = (char*)P("w"); |
| 272 | int isWysiwyg = P("wysiwyg")!=0; |
| 273 | |
| @@ -351,12 +351,12 @@ | |
| 351 | return; |
| 352 | } |
| 353 | if( zBody==0 ){ |
| 354 | zBody = mprintf("<i>Empty Page</i>"); |
| 355 | } |
| 356 | zHtmlPageName = mprintf("Edit: %s", zPageName); |
| 357 | style_header(zHtmlPageName); |
| 358 | blob_zero(&wiki); |
| 359 | blob_append(&wiki, zBody, -1); |
| 360 | if( P("preview")!=0 ){ |
| 361 | @ Preview:<hr /> |
| 362 | wiki_convert(&wiki, 0, 0); |
| @@ -474,11 +474,10 @@ | |
| 474 | void wikiappend_page(void){ |
| 475 | char *zTag; |
| 476 | int rid = 0; |
| 477 | int isSandbox; |
| 478 | const char *zPageName; |
| 479 | char *zHtmlPageName; |
| 480 | const char *zUser; |
| 481 | |
| 482 | login_check_credentials(); |
| 483 | zPageName = PD("name",""); |
| 484 | if( check_name(zPageName) ) return; |
| @@ -549,12 +548,12 @@ | |
| 549 | } |
| 550 | if( P("cancel")!=0 ){ |
| 551 | cgi_redirectf("wiki?name=%T", zPageName); |
| 552 | return; |
| 553 | } |
| 554 | zHtmlPageName = mprintf("Append Comment To: %s", zPageName); |
| 555 | style_header(zHtmlPageName); |
| 556 | if( P("preview")!=0 ){ |
| 557 | Blob preview; |
| 558 | blob_zero(&preview); |
| 559 | appendRemark(&preview); |
| 560 | @ Preview:<hr> |
| 561 |
| --- src/wiki.c | |
| +++ src/wiki.c | |
| @@ -209,10 +209,11 @@ | |
| 209 | if( g.perm.Hyperlink ){ |
| 210 | style_submenu_element("History", "History", "%s/whistory?name=%T", |
| 211 | g.zTop, zPageName); |
| 212 | } |
| 213 | } |
| 214 | style_set_current_page("%s?name=%T", g.zPath, zPageName); |
| 215 | style_header(zPageName); |
| 216 | blob_init(&wiki, zBody, -1); |
| 217 | wiki_convert(&wiki, 0, 0); |
| 218 | blob_reset(&wiki); |
| 219 | |
| @@ -263,11 +264,10 @@ | |
| 264 | int rid = 0; |
| 265 | int isSandbox; |
| 266 | Blob wiki; |
| 267 | Manifest *pWiki = 0; |
| 268 | const char *zPageName; |
| 269 | int n; |
| 270 | const char *z; |
| 271 | char *zBody = (char*)P("w"); |
| 272 | int isWysiwyg = P("wysiwyg")!=0; |
| 273 | |
| @@ -351,12 +351,12 @@ | |
| 351 | return; |
| 352 | } |
| 353 | if( zBody==0 ){ |
| 354 | zBody = mprintf("<i>Empty Page</i>"); |
| 355 | } |
| 356 | style_set_current_page("%s?name=%T", g.zPath, zPageName); |
| 357 | style_header("Edit: %s", zPageName); |
| 358 | blob_zero(&wiki); |
| 359 | blob_append(&wiki, zBody, -1); |
| 360 | if( P("preview")!=0 ){ |
| 361 | @ Preview:<hr /> |
| 362 | wiki_convert(&wiki, 0, 0); |
| @@ -474,11 +474,10 @@ | |
| 474 | void wikiappend_page(void){ |
| 475 | char *zTag; |
| 476 | int rid = 0; |
| 477 | int isSandbox; |
| 478 | const char *zPageName; |
| 479 | const char *zUser; |
| 480 | |
| 481 | login_check_credentials(); |
| 482 | zPageName = PD("name",""); |
| 483 | if( check_name(zPageName) ) return; |
| @@ -549,12 +548,12 @@ | |
| 548 | } |
| 549 | if( P("cancel")!=0 ){ |
| 550 | cgi_redirectf("wiki?name=%T", zPageName); |
| 551 | return; |
| 552 | } |
| 553 | style_set_current_page("%s?name=%T", g.zPath, zPageName); |
| 554 | style_header("Append Comment To: %s", zPageName); |
| 555 | if( P("preview")!=0 ){ |
| 556 | Blob preview; |
| 557 | blob_zero(&preview); |
| 558 | appendRemark(&preview); |
| 559 | @ Preview:<hr> |
| 560 |