Fossil SCM

Add the name= query parameter to the <base> for wiki pages, so that hyperlinks to fragments work correctly.

drh 2012-09-18 15:37 trunk
Commit a116d974b4afede259125d6e695661ce32e9a28c
2 files changed +21 -1 +5 -6
+21 -1
--- src/style.c
+++ src/style.c
@@ -159,10 +159,30 @@
159159
static int submenuCompare(const void *a, const void *b){
160160
const struct Submenu *A = (const struct Submenu*)a;
161161
const struct Submenu *B = (const struct Submenu*)b;
162162
return fossil_strcmp(A->zLabel, B->zLabel);
163163
}
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
+}
164184
165185
/*
166186
** Draw the header.
167187
*/
168188
void style_header(const char *zTitleFormat, ...){
@@ -185,11 +205,11 @@
185205
Th_Store("project_name", db_get("project-name","Unnamed Fossil Project"));
186206
Th_Store("title", zTitle);
187207
Th_Store("baseurl", g.zBaseURL);
188208
Th_Store("home", g.zTop);
189209
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);
191211
Th_Store("release_version", RELEASE_VERSION);
192212
Th_Store("manifest_version", MANIFEST_VERSION);
193213
Th_Store("manifest_date", MANIFEST_DATE);
194214
Th_Store("compiler_name", COMPILER_NAME);
195215
if( g.zLogin ){
196216
--- 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 @@
209209
if( g.perm.Hyperlink ){
210210
style_submenu_element("History", "History", "%s/whistory?name=%T",
211211
g.zTop, zPageName);
212212
}
213213
}
214
+ style_set_current_page("%s?name=%T", g.zPath, zPageName);
214215
style_header(zPageName);
215216
blob_init(&wiki, zBody, -1);
216217
wiki_convert(&wiki, 0, 0);
217218
blob_reset(&wiki);
218219
@@ -263,11 +264,10 @@
263264
int rid = 0;
264265
int isSandbox;
265266
Blob wiki;
266267
Manifest *pWiki = 0;
267268
const char *zPageName;
268
- char *zHtmlPageName;
269269
int n;
270270
const char *z;
271271
char *zBody = (char*)P("w");
272272
int isWysiwyg = P("wysiwyg")!=0;
273273
@@ -351,12 +351,12 @@
351351
return;
352352
}
353353
if( zBody==0 ){
354354
zBody = mprintf("<i>Empty Page</i>");
355355
}
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);
358358
blob_zero(&wiki);
359359
blob_append(&wiki, zBody, -1);
360360
if( P("preview")!=0 ){
361361
@ Preview:<hr />
362362
wiki_convert(&wiki, 0, 0);
@@ -474,11 +474,10 @@
474474
void wikiappend_page(void){
475475
char *zTag;
476476
int rid = 0;
477477
int isSandbox;
478478
const char *zPageName;
479
- char *zHtmlPageName;
480479
const char *zUser;
481480
482481
login_check_credentials();
483482
zPageName = PD("name","");
484483
if( check_name(zPageName) ) return;
@@ -549,12 +548,12 @@
549548
}
550549
if( P("cancel")!=0 ){
551550
cgi_redirectf("wiki?name=%T", zPageName);
552551
return;
553552
}
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);
556555
if( P("preview")!=0 ){
557556
Blob preview;
558557
blob_zero(&preview);
559558
appendRemark(&preview);
560559
@ Preview:<hr>
561560
--- 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

Keyboard Shortcuts

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