Fossil SCM

Understand files ending in ".pikchr" to be Pikchr source text and render them appropriately.

drh 2020-10-11 01:19 trunk
Commit e32214a40901de44c99e2eafb00cd2dcf47761c56219944357ee6363282fee9b
+6
--- src/doc.c
+++ src/doc.c
@@ -190,10 +190,11 @@
190190
{ "pdb", 3, "chemical/x-pdb" },
191191
{ "pdf", 3, "application/pdf" },
192192
{ "pgm", 3, "image/x-portable-graymap" },
193193
{ "pgn", 3, "application/x-chess-pgn" },
194194
{ "pgp", 3, "application/pgp" },
195
+ { "pikchr", 6, "text/x-pikchr" },
195196
{ "pl", 2, "application/x-perl" },
196197
{ "pm", 2, "application/x-perl" },
197198
{ "png", 3, "image/png" },
198199
{ "pnm", 3, "image/x-portable-anymap" },
199200
{ "pot", 3, "application/mspowerpoint" },
@@ -794,10 +795,15 @@
794795
&& doc_is_embedded_html(pBody, &title) ){
795796
if( blob_size(&title)==0 ) blob_append(&title,zFilename,-1);
796797
style_header("%s", blob_str(&title));
797798
convert_href_and_output(pBody);
798799
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);
799805
style_footer();
800806
#ifdef FOSSIL_ENABLE_TH1_DOCS
801807
}else if( Th_AreDocsEnabled() &&
802808
fossil_strcmp(zMime, "application/x-th1")==0 ){
803809
int raw = P("raw")!=0;
804810
--- 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 @@
24122412
}else{
24132413
renderAsHtml = 1;
24142414
style_submenu_element("Text", "%s", url_render(&url, "txt", "1", 0, 0));
24152415
}
24162416
}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 ){
24182419
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));
24202422
}else{
24212423
renderAsWiki = 1;
24222424
style_submenu_element("Text", "%s", url_render(&url, "txt", "1", 0, 0));
24232425
}
24242426
}else if( fossil_strcmp(zMime, "image/svg+xml")==0 ){
24252427
--- 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 @@
186186
/*
187187
** Render wiki text according to its mimetype.
188188
**
189189
** text/x-fossil-wiki Fossil wiki
190190
** text/x-markdown Markdown
191
+** text/x-pikchr Pikchr
191192
** anything else... Plain text
192193
**
193194
** If zMimetype is a null pointer, then use "text/x-fossil-wiki".
194195
*/
195196
void wiki_render_by_mimetype(Blob *pWiki, const char *zMimetype){
@@ -199,10 +200,24 @@
199200
Blob tail = BLOB_INITIALIZER;
200201
markdown_to_html(pWiki, 0, &tail);
201202
safe_html(&tail);
202203
@ %s(blob_str(&tail))
203204
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);
204219
}else{
205220
@ <pre class='textPlain'>
206221
@ %h(blob_str(pWiki))
207222
@ </pre>
208223
}
209224
--- 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

Keyboard Shortcuts

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