Fossil SCM

If embedded wiki documentation begins with <title>...</title> then use the text within the markup as the title of the document.

drh 2009-06-07 17:27 trunk
Commit f88e2e7a131d4aa0bf20ced6597b326f08000b7f
+8 -2
--- src/doc.c
+++ src/doc.c
@@ -437,12 +437,18 @@
437437
/* The file is now contained in the filebody blob. Deliver the
438438
** file to the user
439439
*/
440440
zMime = mimetype_from_name(zName);
441441
if( strcmp(zMime, "application/x-fossil-wiki")==0 ){
442
- style_header("Documentation");
443
- wiki_convert(&filebody, 0, 0);
442
+ Blob title, tail;
443
+ if( wiki_find_title(&filebody, &title, &tail) ){
444
+ style_header(blob_str(&title));
445
+ wiki_convert(&tail, 0, 0);
446
+ }else{
447
+ style_header("Documentation");
448
+ wiki_convert(&filebody, 0, 0);
449
+ }
444450
style_footer();
445451
}else if( strcmp(zMime, "text/plain")==0 ){
446452
style_header("Documentation");
447453
@ <blockquote><pre>
448454
@ %h(blob_str(&filebody))
449455
--- src/doc.c
+++ src/doc.c
@@ -437,12 +437,18 @@
437 /* The file is now contained in the filebody blob. Deliver the
438 ** file to the user
439 */
440 zMime = mimetype_from_name(zName);
441 if( strcmp(zMime, "application/x-fossil-wiki")==0 ){
442 style_header("Documentation");
443 wiki_convert(&filebody, 0, 0);
 
 
 
 
 
 
444 style_footer();
445 }else if( strcmp(zMime, "text/plain")==0 ){
446 style_header("Documentation");
447 @ <blockquote><pre>
448 @ %h(blob_str(&filebody))
449
--- src/doc.c
+++ src/doc.c
@@ -437,12 +437,18 @@
437 /* The file is now contained in the filebody blob. Deliver the
438 ** file to the user
439 */
440 zMime = mimetype_from_name(zName);
441 if( strcmp(zMime, "application/x-fossil-wiki")==0 ){
442 Blob title, tail;
443 if( wiki_find_title(&filebody, &title, &tail) ){
444 style_header(blob_str(&title));
445 wiki_convert(&tail, 0, 0);
446 }else{
447 style_header("Documentation");
448 wiki_convert(&filebody, 0, 0);
449 }
450 style_footer();
451 }else if( strcmp(zMime, "text/plain")==0 ){
452 style_header("Documentation");
453 @ <blockquote><pre>
454 @ %h(blob_str(&filebody))
455
--- src/wikiformat.c
+++ src/wikiformat.c
@@ -1336,5 +1336,31 @@
13361336
blob_zero(&out);
13371337
blob_read_from_file(&in, g.argv[2]);
13381338
wiki_convert(&in, &out, 0);
13391339
blob_write_to_file(&out, "-");
13401340
}
1341
+
1342
+/*
1343
+** Search for a <title>...</title> at the beginning of a wiki page.
1344
+** Return true (nonzero) if a title is found. Return zero if there is
1345
+** not title.
1346
+**
1347
+** If a title is found, initialize the pTitle blob to be the content
1348
+** of the title and initialize pTail to be the text that follows the
1349
+** title.
1350
+*/
1351
+int wiki_find_title(Blob *pIn, Blob *pTitle, Blob *pTail){
1352
+ char *z;
1353
+ int i;
1354
+ int iStart;
1355
+ z = blob_str(pIn);
1356
+ for(i=0; isspace(z[i]); i++){}
1357
+ if( z[i]!='<' ) return 0;
1358
+ i++;
1359
+ if( strncmp(&z[i],"title>", 6)!=0 ) return 0;
1360
+ iStart = i+6;
1361
+ for(i=iStart; z[i] && (z[i]!='<' || strncmp(&z[i],"</title>",8)!=0); i++){}
1362
+ if( z[i]!='<' ) return 0;
1363
+ blob_init(pTitle, &z[iStart], i-iStart);
1364
+ blob_init(pTail, &z[i+8], -1);
1365
+ return 1;
1366
+}
13411367
--- src/wikiformat.c
+++ src/wikiformat.c
@@ -1336,5 +1336,31 @@
1336 blob_zero(&out);
1337 blob_read_from_file(&in, g.argv[2]);
1338 wiki_convert(&in, &out, 0);
1339 blob_write_to_file(&out, "-");
1340 }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1341
--- src/wikiformat.c
+++ src/wikiformat.c
@@ -1336,5 +1336,31 @@
1336 blob_zero(&out);
1337 blob_read_from_file(&in, g.argv[2]);
1338 wiki_convert(&in, &out, 0);
1339 blob_write_to_file(&out, "-");
1340 }
1341
1342 /*
1343 ** Search for a <title>...</title> at the beginning of a wiki page.
1344 ** Return true (nonzero) if a title is found. Return zero if there is
1345 ** not title.
1346 **
1347 ** If a title is found, initialize the pTitle blob to be the content
1348 ** of the title and initialize pTail to be the text that follows the
1349 ** title.
1350 */
1351 int wiki_find_title(Blob *pIn, Blob *pTitle, Blob *pTail){
1352 char *z;
1353 int i;
1354 int iStart;
1355 z = blob_str(pIn);
1356 for(i=0; isspace(z[i]); i++){}
1357 if( z[i]!='<' ) return 0;
1358 i++;
1359 if( strncmp(&z[i],"title>", 6)!=0 ) return 0;
1360 iStart = i+6;
1361 for(i=iStart; z[i] && (z[i]!='<' || strncmp(&z[i],"</title>",8)!=0); i++){}
1362 if( z[i]!='<' ) return 0;
1363 blob_init(pTitle, &z[iStart], i-iStart);
1364 blob_init(pTail, &z[i+8], -1);
1365 return 1;
1366 }
1367
--- www/index.wiki
+++ www/index.wiki
@@ -1,5 +1,6 @@
1
+<title>Fossil Home Page</title>
12
<h1>Fossil: Distributed Revision Control, Wiki, and Bug-Tracking</h1>
23
34
Fossil is a
45
[http://en.wikipedia.org/wiki/Revision_control | distributed software version control system]
56
that includes an integrated
67
--- www/index.wiki
+++ www/index.wiki
@@ -1,5 +1,6 @@
 
1 <h1>Fossil: Distributed Revision Control, Wiki, and Bug-Tracking</h1>
2
3 Fossil is a
4 [http://en.wikipedia.org/wiki/Revision_control | distributed software version control system]
5 that includes an integrated
6
--- www/index.wiki
+++ www/index.wiki
@@ -1,5 +1,6 @@
1 <title>Fossil Home Page</title>
2 <h1>Fossil: Distributed Revision Control, Wiki, and Bug-Tracking</h1>
3
4 Fossil is a
5 [http://en.wikipedia.org/wiki/Revision_control | distributed software version control system]
6 that includes an integrated
7

Keyboard Shortcuts

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