Fossil SCM
Understand files ending in ".pikchr" to be Pikchr source text and render them appropriately.
Commit
e32214a40901de44c99e2eafb00cd2dcf47761c56219944357ee6363282fee9b
Parent
0ec09ea894906b6…
3 files changed
+6
+4
-2
+15
+6
| --- src/doc.c | ||
| +++ src/doc.c | ||
| @@ -190,10 +190,11 @@ | ||
| 190 | 190 | { "pdb", 3, "chemical/x-pdb" }, |
| 191 | 191 | { "pdf", 3, "application/pdf" }, |
| 192 | 192 | { "pgm", 3, "image/x-portable-graymap" }, |
| 193 | 193 | { "pgn", 3, "application/x-chess-pgn" }, |
| 194 | 194 | { "pgp", 3, "application/pgp" }, |
| 195 | + { "pikchr", 6, "text/x-pikchr" }, | |
| 195 | 196 | { "pl", 2, "application/x-perl" }, |
| 196 | 197 | { "pm", 2, "application/x-perl" }, |
| 197 | 198 | { "png", 3, "image/png" }, |
| 198 | 199 | { "pnm", 3, "image/x-portable-anymap" }, |
| 199 | 200 | { "pot", 3, "application/mspowerpoint" }, |
| @@ -794,10 +795,15 @@ | ||
| 794 | 795 | && doc_is_embedded_html(pBody, &title) ){ |
| 795 | 796 | if( blob_size(&title)==0 ) blob_append(&title,zFilename,-1); |
| 796 | 797 | style_header("%s", blob_str(&title)); |
| 797 | 798 | convert_href_and_output(pBody); |
| 798 | 799 | document_emit_js(); |
| 800 | + style_footer(); | |
| 801 | + }else if( fossil_strcmp(zMime, "text/x-pikchr")==0 ){ | |
| 802 | + style_adunit_config(ADUNIT_RIGHT_OK); | |
| 803 | + style_header("%s", zDefaultTitle); | |
| 804 | + wiki_render_by_mimetype(pBody, zMime); | |
| 799 | 805 | style_footer(); |
| 800 | 806 | #ifdef FOSSIL_ENABLE_TH1_DOCS |
| 801 | 807 | }else if( Th_AreDocsEnabled() && |
| 802 | 808 | fossil_strcmp(zMime, "application/x-th1")==0 ){ |
| 803 | 809 | int raw = P("raw")!=0; |
| 804 | 810 |
| --- src/doc.c | |
| +++ src/doc.c | |
| @@ -190,10 +190,11 @@ | |
| 190 | { "pdb", 3, "chemical/x-pdb" }, |
| 191 | { "pdf", 3, "application/pdf" }, |
| 192 | { "pgm", 3, "image/x-portable-graymap" }, |
| 193 | { "pgn", 3, "application/x-chess-pgn" }, |
| 194 | { "pgp", 3, "application/pgp" }, |
| 195 | { "pl", 2, "application/x-perl" }, |
| 196 | { "pm", 2, "application/x-perl" }, |
| 197 | { "png", 3, "image/png" }, |
| 198 | { "pnm", 3, "image/x-portable-anymap" }, |
| 199 | { "pot", 3, "application/mspowerpoint" }, |
| @@ -794,10 +795,15 @@ | |
| 794 | && doc_is_embedded_html(pBody, &title) ){ |
| 795 | if( blob_size(&title)==0 ) blob_append(&title,zFilename,-1); |
| 796 | style_header("%s", blob_str(&title)); |
| 797 | convert_href_and_output(pBody); |
| 798 | document_emit_js(); |
| 799 | style_footer(); |
| 800 | #ifdef FOSSIL_ENABLE_TH1_DOCS |
| 801 | }else if( Th_AreDocsEnabled() && |
| 802 | fossil_strcmp(zMime, "application/x-th1")==0 ){ |
| 803 | int raw = P("raw")!=0; |
| 804 |
| --- src/doc.c | |
| +++ src/doc.c | |
| @@ -190,10 +190,11 @@ | |
| 190 | { "pdb", 3, "chemical/x-pdb" }, |
| 191 | { "pdf", 3, "application/pdf" }, |
| 192 | { "pgm", 3, "image/x-portable-graymap" }, |
| 193 | { "pgn", 3, "application/x-chess-pgn" }, |
| 194 | { "pgp", 3, "application/pgp" }, |
| 195 | { "pikchr", 6, "text/x-pikchr" }, |
| 196 | { "pl", 2, "application/x-perl" }, |
| 197 | { "pm", 2, "application/x-perl" }, |
| 198 | { "png", 3, "image/png" }, |
| 199 | { "pnm", 3, "image/x-portable-anymap" }, |
| 200 | { "pot", 3, "application/mspowerpoint" }, |
| @@ -794,10 +795,15 @@ | |
| 795 | && doc_is_embedded_html(pBody, &title) ){ |
| 796 | if( blob_size(&title)==0 ) blob_append(&title,zFilename,-1); |
| 797 | style_header("%s", blob_str(&title)); |
| 798 | convert_href_and_output(pBody); |
| 799 | document_emit_js(); |
| 800 | style_footer(); |
| 801 | }else if( fossil_strcmp(zMime, "text/x-pikchr")==0 ){ |
| 802 | style_adunit_config(ADUNIT_RIGHT_OK); |
| 803 | style_header("%s", zDefaultTitle); |
| 804 | wiki_render_by_mimetype(pBody, zMime); |
| 805 | style_footer(); |
| 806 | #ifdef FOSSIL_ENABLE_TH1_DOCS |
| 807 | }else if( Th_AreDocsEnabled() && |
| 808 | fossil_strcmp(zMime, "application/x-th1")==0 ){ |
| 809 | int raw = P("raw")!=0; |
| 810 |
+4
-2
| --- src/info.c | ||
| +++ src/info.c | ||
| @@ -2412,13 +2412,15 @@ | ||
| 2412 | 2412 | }else{ |
| 2413 | 2413 | renderAsHtml = 1; |
| 2414 | 2414 | style_submenu_element("Text", "%s", url_render(&url, "txt", "1", 0, 0)); |
| 2415 | 2415 | } |
| 2416 | 2416 | }else if( fossil_strcmp(zMime, "text/x-fossil-wiki")==0 |
| 2417 | - || fossil_strcmp(zMime, "text/x-markdown")==0 ){ | |
| 2417 | + || fossil_strcmp(zMime, "text/x-markdown")==0 | |
| 2418 | + || fossil_strcmp(zMime, "text/x-pikchr")==0 ){ | |
| 2418 | 2419 | if( asText ){ |
| 2419 | - style_submenu_element("Wiki", "%s", url_render(&url, "txt", 0, 0, 0)); | |
| 2420 | + style_submenu_element(zMime[7]=='p' ? "Pikchr" : "Wiki", | |
| 2421 | + "%s", url_render(&url, "txt", 0, 0, 0)); | |
| 2420 | 2422 | }else{ |
| 2421 | 2423 | renderAsWiki = 1; |
| 2422 | 2424 | style_submenu_element("Text", "%s", url_render(&url, "txt", "1", 0, 0)); |
| 2423 | 2425 | } |
| 2424 | 2426 | }else if( fossil_strcmp(zMime, "image/svg+xml")==0 ){ |
| 2425 | 2427 |
| --- src/info.c | |
| +++ src/info.c | |
| @@ -2412,13 +2412,15 @@ | |
| 2412 | }else{ |
| 2413 | renderAsHtml = 1; |
| 2414 | style_submenu_element("Text", "%s", url_render(&url, "txt", "1", 0, 0)); |
| 2415 | } |
| 2416 | }else if( fossil_strcmp(zMime, "text/x-fossil-wiki")==0 |
| 2417 | || fossil_strcmp(zMime, "text/x-markdown")==0 ){ |
| 2418 | if( asText ){ |
| 2419 | style_submenu_element("Wiki", "%s", url_render(&url, "txt", 0, 0, 0)); |
| 2420 | }else{ |
| 2421 | renderAsWiki = 1; |
| 2422 | style_submenu_element("Text", "%s", url_render(&url, "txt", "1", 0, 0)); |
| 2423 | } |
| 2424 | }else if( fossil_strcmp(zMime, "image/svg+xml")==0 ){ |
| 2425 |
| --- src/info.c | |
| +++ src/info.c | |
| @@ -2412,13 +2412,15 @@ | |
| 2412 | }else{ |
| 2413 | renderAsHtml = 1; |
| 2414 | style_submenu_element("Text", "%s", url_render(&url, "txt", "1", 0, 0)); |
| 2415 | } |
| 2416 | }else if( fossil_strcmp(zMime, "text/x-fossil-wiki")==0 |
| 2417 | || fossil_strcmp(zMime, "text/x-markdown")==0 |
| 2418 | || fossil_strcmp(zMime, "text/x-pikchr")==0 ){ |
| 2419 | if( asText ){ |
| 2420 | style_submenu_element(zMime[7]=='p' ? "Pikchr" : "Wiki", |
| 2421 | "%s", url_render(&url, "txt", 0, 0, 0)); |
| 2422 | }else{ |
| 2423 | renderAsWiki = 1; |
| 2424 | style_submenu_element("Text", "%s", url_render(&url, "txt", "1", 0, 0)); |
| 2425 | } |
| 2426 | }else if( fossil_strcmp(zMime, "image/svg+xml")==0 ){ |
| 2427 |
+15
| --- src/wiki.c | ||
| +++ src/wiki.c | ||
| @@ -186,10 +186,11 @@ | ||
| 186 | 186 | /* |
| 187 | 187 | ** Render wiki text according to its mimetype. |
| 188 | 188 | ** |
| 189 | 189 | ** text/x-fossil-wiki Fossil wiki |
| 190 | 190 | ** text/x-markdown Markdown |
| 191 | +** text/x-pikchr Pikchr | |
| 191 | 192 | ** anything else... Plain text |
| 192 | 193 | ** |
| 193 | 194 | ** If zMimetype is a null pointer, then use "text/x-fossil-wiki". |
| 194 | 195 | */ |
| 195 | 196 | void wiki_render_by_mimetype(Blob *pWiki, const char *zMimetype){ |
| @@ -199,10 +200,24 @@ | ||
| 199 | 200 | Blob tail = BLOB_INITIALIZER; |
| 200 | 201 | markdown_to_html(pWiki, 0, &tail); |
| 201 | 202 | safe_html(&tail); |
| 202 | 203 | @ %s(blob_str(&tail)) |
| 203 | 204 | blob_reset(&tail); |
| 205 | + }else if( fossil_strcmp(zMimetype, "text/x-pikchr")==0 ){ | |
| 206 | + const char *zPikchr = blob_str(pWiki); | |
| 207 | + int w, h; | |
| 208 | + char *zOut = pikchr(zPikchr, "pikchr", 0, &w, &h); | |
| 209 | + if( w>0 ){ | |
| 210 | + @ <div class="pikchr-svg" style="max-width:%d(w)px"> | |
| 211 | + @ %s(zOut) | |
| 212 | + @ </div> | |
| 213 | + }else{ | |
| 214 | + @ <pre class='error'>\n"> | |
| 215 | + @ %s(zOut); | |
| 216 | + @ </pre> | |
| 217 | + } | |
| 218 | + free(zOut); | |
| 204 | 219 | }else{ |
| 205 | 220 | @ <pre class='textPlain'> |
| 206 | 221 | @ %h(blob_str(pWiki)) |
| 207 | 222 | @ </pre> |
| 208 | 223 | } |
| 209 | 224 |
| --- src/wiki.c | |
| +++ src/wiki.c | |
| @@ -186,10 +186,11 @@ | |
| 186 | /* |
| 187 | ** Render wiki text according to its mimetype. |
| 188 | ** |
| 189 | ** text/x-fossil-wiki Fossil wiki |
| 190 | ** text/x-markdown Markdown |
| 191 | ** anything else... Plain text |
| 192 | ** |
| 193 | ** If zMimetype is a null pointer, then use "text/x-fossil-wiki". |
| 194 | */ |
| 195 | void wiki_render_by_mimetype(Blob *pWiki, const char *zMimetype){ |
| @@ -199,10 +200,24 @@ | |
| 199 | Blob tail = BLOB_INITIALIZER; |
| 200 | markdown_to_html(pWiki, 0, &tail); |
| 201 | safe_html(&tail); |
| 202 | @ %s(blob_str(&tail)) |
| 203 | blob_reset(&tail); |
| 204 | }else{ |
| 205 | @ <pre class='textPlain'> |
| 206 | @ %h(blob_str(pWiki)) |
| 207 | @ </pre> |
| 208 | } |
| 209 |
| --- src/wiki.c | |
| +++ src/wiki.c | |
| @@ -186,10 +186,11 @@ | |
| 186 | /* |
| 187 | ** Render wiki text according to its mimetype. |
| 188 | ** |
| 189 | ** text/x-fossil-wiki Fossil wiki |
| 190 | ** text/x-markdown Markdown |
| 191 | ** text/x-pikchr Pikchr |
| 192 | ** anything else... Plain text |
| 193 | ** |
| 194 | ** If zMimetype is a null pointer, then use "text/x-fossil-wiki". |
| 195 | */ |
| 196 | void wiki_render_by_mimetype(Blob *pWiki, const char *zMimetype){ |
| @@ -199,10 +200,24 @@ | |
| 200 | Blob tail = BLOB_INITIALIZER; |
| 201 | markdown_to_html(pWiki, 0, &tail); |
| 202 | safe_html(&tail); |
| 203 | @ %s(blob_str(&tail)) |
| 204 | blob_reset(&tail); |
| 205 | }else if( fossil_strcmp(zMimetype, "text/x-pikchr")==0 ){ |
| 206 | const char *zPikchr = blob_str(pWiki); |
| 207 | int w, h; |
| 208 | char *zOut = pikchr(zPikchr, "pikchr", 0, &w, &h); |
| 209 | if( w>0 ){ |
| 210 | @ <div class="pikchr-svg" style="max-width:%d(w)px"> |
| 211 | @ %s(zOut) |
| 212 | @ </div> |
| 213 | }else{ |
| 214 | @ <pre class='error'>\n"> |
| 215 | @ %s(zOut); |
| 216 | @ </pre> |
| 217 | } |
| 218 | free(zOut); |
| 219 | }else{ |
| 220 | @ <pre class='textPlain'> |
| 221 | @ %h(blob_str(pWiki)) |
| 222 | @ </pre> |
| 223 | } |
| 224 |