Overview
SHA1 Hash: | f88e2e7a131d4aa0bf20ced6597b326f08000b7f |
---|---|
Date: | 2009-06-07 17:27:45 |
User: | drh |
Comment: | If embedded wiki documentation begins with <title>...</title> then use the text within the markup as the title of the document. |
Timelines: | ancestors | descendants | both | trunk |
Other Links: | files | ZIP archive | manifest |
Tags And Properties
- branch=trunk inherited from [a28c83647d]
- sym-trunk inherited from [a28c83647d]
Changes
[hide diffs]Modified src/doc.c from [b634a7084a] to [682899f6dc].
@@ -437,12 +437,18 @@ /* The file is now contained in the filebody blob. Deliver the ** file to the user */ zMime = mimetype_from_name(zName); if( strcmp(zMime, "application/x-fossil-wiki")==0 ){ - style_header("Documentation"); - wiki_convert(&filebody, 0, 0); + Blob title, tail; + if( wiki_find_title(&filebody, &title, &tail) ){ + style_header(blob_str(&title)); + wiki_convert(&tail, 0, 0); + }else{ + style_header("Documentation"); + wiki_convert(&filebody, 0, 0); + } style_footer(); }else if( strcmp(zMime, "text/plain")==0 ){ style_header("Documentation"); @ <blockquote><pre> @ %h(blob_str(&filebody))
Modified src/wikiformat.c from [0350f3f946] to [fc0e3fb84e].
@@ -1335,6 +1335,32 @@ if( g.argc!=3 ) usage("FILE"); blob_zero(&out); blob_read_from_file(&in, g.argv[2]); wiki_convert(&in, &out, 0); blob_write_to_file(&out, "-"); +} + +/* +** Search for a <title>...</title> at the beginning of a wiki page. +** Return true (nonzero) if a title is found. Return zero if there is +** not title. +** +** If a title is found, initialize the pTitle blob to be the content +** of the title and initialize pTail to be the text that follows the +** title. +*/ +int wiki_find_title(Blob *pIn, Blob *pTitle, Blob *pTail){ + char *z; + int i; + int iStart; + z = blob_str(pIn); + for(i=0; isspace(z[i]); i++){} + if( z[i]!='<' ) return 0; + i++; + if( strncmp(&z[i],"title>", 6)!=0 ) return 0; + iStart = i+6; + for(i=iStart; z[i] && (z[i]!='<' || strncmp(&z[i],"</title>",8)!=0); i++){} + if( z[i]!='<' ) return 0; + blob_init(pTitle, &z[iStart], i-iStart); + blob_init(pTail, &z[i+8], -1); + return 1; }
Modified www/index.wiki from [7ee83e7ec9] to [b8d2de2cae].
@@ -1,5 +1,6 @@ +<title>Fossil Home Page</title> <h1>Fossil: Distributed Revision Control, Wiki, and Bug-Tracking</h1> Fossil is a [http://en.wikipedia.org/wiki/Revision_control | distributed software version control system] that includes an integrated