Fossil SCM

Make the /doc, /uv, and /wiki webpages respond to the "popup" query parameter by omitting the header and footer boilerplate and sending just the page content.

drh 2021-01-28 19:38 trunk
Commit 36a17f36b563c635a1738c3967df62e107e6fe961751354fd8d69703df6da2c8
3 files changed +22 -13 +4 +15 -7
+22 -13
--- src/doc.c
+++ src/doc.c
@@ -767,34 +767,41 @@
767767
const char *zMime, /* MIME-type */
768768
const char *zDefaultTitle, /* Default title */
769769
const char *zFilename /* Name of the file being rendered */
770770
){
771771
Blob title;
772
+ int isPopup = P("popup")!=0;
772773
blob_init(&title,0,0);
773774
if( fossil_strcmp(zMime, "text/x-fossil-wiki")==0 ){
774775
Blob tail;
775776
style_adunit_config(ADUNIT_RIGHT_OK);
776777
if( wiki_find_title(pBody, &title, &tail) ){
777
- style_header("%s", blob_str(&title));
778
+ if( !isPopup ) style_header("%s", blob_str(&title));
778779
wiki_convert(&tail, 0, WIKI_BUTTONS);
779780
}else{
780
- style_header("%s", zDefaultTitle);
781
+ if( !isPopup ) style_header("%s", zDefaultTitle);
781782
wiki_convert(pBody, 0, WIKI_BUTTONS);
782783
}
783
- document_emit_js();
784
- style_finish_page();
784
+ if( !isPopup ){
785
+ document_emit_js();
786
+ style_finish_page();
787
+ }
785788
}else if( fossil_strcmp(zMime, "text/x-markdown")==0 ){
786789
Blob tail = BLOB_INITIALIZER;
787790
markdown_to_html(pBody, &title, &tail);
788
- if( blob_size(&title)>0 ){
789
- style_header("%s", blob_str(&title));
790
- }else{
791
- style_header("%s", zDefaultTitle);
791
+ if( !isPopup ){
792
+ if( blob_size(&title)>0 ){
793
+ style_header("%s", blob_str(&title));
794
+ }else{
795
+ style_header("%s", zDefaultTitle);
796
+ }
792797
}
793798
convert_href_and_output(&tail);
794
- document_emit_js();
795
- style_finish_page();
799
+ if( !isPopup ){
800
+ document_emit_js();
801
+ style_finish_page();
802
+ }
796803
}else if( fossil_strcmp(zMime, "text/plain")==0 ){
797804
style_header("%s", zDefaultTitle);
798805
@ <blockquote><pre>
799806
@ %h(blob_str(pBody))
800807
@ </pre></blockquote>
@@ -801,14 +808,16 @@
801808
document_emit_js();
802809
style_finish_page();
803810
}else if( fossil_strcmp(zMime, "text/html")==0
804811
&& doc_is_embedded_html(pBody, &title) ){
805812
if( blob_size(&title)==0 ) blob_append(&title,zFilename,-1);
806
- style_header("%s", blob_str(&title));
813
+ if( !isPopup ) style_header("%s", blob_str(&title));
807814
convert_href_and_output(pBody);
808
- document_emit_js();
809
- style_finish_page();
815
+ if( !isPopup ){
816
+ document_emit_js();
817
+ style_finish_page();
818
+ }
810819
}else if( fossil_strcmp(zMime, "text/x-pikchr")==0 ){
811820
style_adunit_config(ADUNIT_RIGHT_OK);
812821
style_header("%s", zDefaultTitle);
813822
wiki_render_by_mimetype(pBody, zMime);
814823
style_finish_page();
815824
--- src/doc.c
+++ src/doc.c
@@ -767,34 +767,41 @@
767 const char *zMime, /* MIME-type */
768 const char *zDefaultTitle, /* Default title */
769 const char *zFilename /* Name of the file being rendered */
770 ){
771 Blob title;
 
772 blob_init(&title,0,0);
773 if( fossil_strcmp(zMime, "text/x-fossil-wiki")==0 ){
774 Blob tail;
775 style_adunit_config(ADUNIT_RIGHT_OK);
776 if( wiki_find_title(pBody, &title, &tail) ){
777 style_header("%s", blob_str(&title));
778 wiki_convert(&tail, 0, WIKI_BUTTONS);
779 }else{
780 style_header("%s", zDefaultTitle);
781 wiki_convert(pBody, 0, WIKI_BUTTONS);
782 }
783 document_emit_js();
784 style_finish_page();
 
 
785 }else if( fossil_strcmp(zMime, "text/x-markdown")==0 ){
786 Blob tail = BLOB_INITIALIZER;
787 markdown_to_html(pBody, &title, &tail);
788 if( blob_size(&title)>0 ){
789 style_header("%s", blob_str(&title));
790 }else{
791 style_header("%s", zDefaultTitle);
 
 
792 }
793 convert_href_and_output(&tail);
794 document_emit_js();
795 style_finish_page();
 
 
796 }else if( fossil_strcmp(zMime, "text/plain")==0 ){
797 style_header("%s", zDefaultTitle);
798 @ <blockquote><pre>
799 @ %h(blob_str(pBody))
800 @ </pre></blockquote>
@@ -801,14 +808,16 @@
801 document_emit_js();
802 style_finish_page();
803 }else if( fossil_strcmp(zMime, "text/html")==0
804 && doc_is_embedded_html(pBody, &title) ){
805 if( blob_size(&title)==0 ) blob_append(&title,zFilename,-1);
806 style_header("%s", blob_str(&title));
807 convert_href_and_output(pBody);
808 document_emit_js();
809 style_finish_page();
 
 
810 }else if( fossil_strcmp(zMime, "text/x-pikchr")==0 ){
811 style_adunit_config(ADUNIT_RIGHT_OK);
812 style_header("%s", zDefaultTitle);
813 wiki_render_by_mimetype(pBody, zMime);
814 style_finish_page();
815
--- src/doc.c
+++ src/doc.c
@@ -767,34 +767,41 @@
767 const char *zMime, /* MIME-type */
768 const char *zDefaultTitle, /* Default title */
769 const char *zFilename /* Name of the file being rendered */
770 ){
771 Blob title;
772 int isPopup = P("popup")!=0;
773 blob_init(&title,0,0);
774 if( fossil_strcmp(zMime, "text/x-fossil-wiki")==0 ){
775 Blob tail;
776 style_adunit_config(ADUNIT_RIGHT_OK);
777 if( wiki_find_title(pBody, &title, &tail) ){
778 if( !isPopup ) style_header("%s", blob_str(&title));
779 wiki_convert(&tail, 0, WIKI_BUTTONS);
780 }else{
781 if( !isPopup ) style_header("%s", zDefaultTitle);
782 wiki_convert(pBody, 0, WIKI_BUTTONS);
783 }
784 if( !isPopup ){
785 document_emit_js();
786 style_finish_page();
787 }
788 }else if( fossil_strcmp(zMime, "text/x-markdown")==0 ){
789 Blob tail = BLOB_INITIALIZER;
790 markdown_to_html(pBody, &title, &tail);
791 if( !isPopup ){
792 if( blob_size(&title)>0 ){
793 style_header("%s", blob_str(&title));
794 }else{
795 style_header("%s", zDefaultTitle);
796 }
797 }
798 convert_href_and_output(&tail);
799 if( !isPopup ){
800 document_emit_js();
801 style_finish_page();
802 }
803 }else if( fossil_strcmp(zMime, "text/plain")==0 ){
804 style_header("%s", zDefaultTitle);
805 @ <blockquote><pre>
806 @ %h(blob_str(pBody))
807 @ </pre></blockquote>
@@ -801,14 +808,16 @@
808 document_emit_js();
809 style_finish_page();
810 }else if( fossil_strcmp(zMime, "text/html")==0
811 && doc_is_embedded_html(pBody, &title) ){
812 if( blob_size(&title)==0 ) blob_append(&title,zFilename,-1);
813 if( !isPopup ) style_header("%s", blob_str(&title));
814 convert_href_and_output(pBody);
815 if( !isPopup ){
816 document_emit_js();
817 style_finish_page();
818 }
819 }else if( fossil_strcmp(zMime, "text/x-pikchr")==0 ){
820 style_adunit_config(ADUNIT_RIGHT_OK);
821 style_header("%s", zDefaultTitle);
822 wiki_render_by_mimetype(pBody, zMime);
823 style_finish_page();
824
--- src/hbmenu.js
+++ src/hbmenu.js
@@ -240,10 +240,14 @@
240240
showPanel();
241241
}
242242
}
243243
// else, can't parse response as HTML or XML
244244
}
245
+ // The extra "popup" query parameter is a single to the server that the
246
+ // header and footer boiler-plate can be omitted. The boiler-plate is
247
+ // ignored if it is included. The popup query parameter is just an
248
+ // optimization.
245249
var url = hbButton.href + (hbButton.href.includes("?")?"&popup":"?popup")
246250
xhr.open("GET", url);
247251
xhr.responseType = "document";
248252
xhr.send();
249253
}
250254
--- src/hbmenu.js
+++ src/hbmenu.js
@@ -240,10 +240,14 @@
240 showPanel();
241 }
242 }
243 // else, can't parse response as HTML or XML
244 }
 
 
 
 
245 var url = hbButton.href + (hbButton.href.includes("?")?"&popup":"?popup")
246 xhr.open("GET", url);
247 xhr.responseType = "document";
248 xhr.send();
249 }
250
--- src/hbmenu.js
+++ src/hbmenu.js
@@ -240,10 +240,14 @@
240 showPanel();
241 }
242 }
243 // else, can't parse response as HTML or XML
244 }
245 // The extra "popup" query parameter is a single to the server that the
246 // header and footer boiler-plate can be omitted. The boiler-plate is
247 // ignored if it is included. The popup query parameter is just an
248 // optimization.
249 var url = hbButton.href + (hbButton.href.includes("?")?"&popup":"?popup")
250 xhr.open("GET", url);
251 xhr.responseType = "document";
252 xhr.send();
253 }
254
+15 -7
--- src/wiki.c
+++ src/wiki.c
@@ -528,10 +528,13 @@
528528
** nsm Omit the submenu if present. (Mnemonic: No SubMenu)
529529
** p Always show just the wiki page. For special
530530
** pages for check-ins, branches, or tags, there will
531531
** be a redirect to the associated /info page unless
532532
** this query parameter is present.
533
+** popup Suppress the header and footer and other page
534
+** boilerplate and only return the formatted content
535
+** of the wiki page.
533536
*/
534537
void wiki_page(void){
535538
char *zTag;
536539
int rid = 0;
537540
int isSandbox;
@@ -538,10 +541,11 @@
538541
unsigned submenuFlags = W_HELP;
539542
Blob wiki;
540543
Manifest *pWiki = 0;
541544
const char *zPageName;
542545
const char *zMimetype = 0;
546
+ int isPopup = P("popup")!=0;
543547
char *zBody = mprintf("%s","<i>Empty Page</i>");
544548
int noSubmenu = P("nsm")!=0;
545549
546550
login_check_credentials();
547551
if( !g.perm.RdWiki ){ login_needed(g.anon.RdWiki); return; }
@@ -589,27 +593,31 @@
589593
}
590594
if( g.perm.Hyperlink ){
591595
style_submenu_element("History", "%R/whistory?name=%T", zPageName);
592596
}
593597
}
594
- style_set_current_page("%T?name=%T", g.zPath, zPageName);
595
- wiki_page_header(WIKITYPE_UNKNOWN, zPageName, "");
596
- if( !noSubmenu ){
597
- wiki_standard_submenu(submenuFlags);
598
+ if( !isPopup ){
599
+ style_set_current_page("%T?name=%T", g.zPath, zPageName);
600
+ wiki_page_header(WIKITYPE_UNKNOWN, zPageName, "");
601
+ if( !noSubmenu ){
602
+ wiki_standard_submenu(submenuFlags);
603
+ }
598604
}
599605
if( zBody[0]==0 ){
600606
@ <i>This page has been deleted</i>
601607
}else{
602608
blob_init(&wiki, zBody, -1);
603609
safe_html_context(DOCSRC_WIKI);
604610
wiki_render_by_mimetype(&wiki, zMimetype);
605611
blob_reset(&wiki);
606612
}
607
- attachment_list(zPageName, "<hr /><h2>Attachments:</h2><ul>");
608613
manifest_destroy(pWiki);
609
- document_emit_js(/*for optional pikchr support*/);
610
- style_finish_page();
614
+ if( !isPopup ){
615
+ attachment_list(zPageName, "<hr /><h2>Attachments:</h2><ul>");
616
+ document_emit_js(/*for optional pikchr support*/);
617
+ style_finish_page();
618
+ }
611619
}
612620
613621
/*
614622
** Write a wiki artifact into the repository
615623
*/
616624
--- src/wiki.c
+++ src/wiki.c
@@ -528,10 +528,13 @@
528 ** nsm Omit the submenu if present. (Mnemonic: No SubMenu)
529 ** p Always show just the wiki page. For special
530 ** pages for check-ins, branches, or tags, there will
531 ** be a redirect to the associated /info page unless
532 ** this query parameter is present.
 
 
 
533 */
534 void wiki_page(void){
535 char *zTag;
536 int rid = 0;
537 int isSandbox;
@@ -538,10 +541,11 @@
538 unsigned submenuFlags = W_HELP;
539 Blob wiki;
540 Manifest *pWiki = 0;
541 const char *zPageName;
542 const char *zMimetype = 0;
 
543 char *zBody = mprintf("%s","<i>Empty Page</i>");
544 int noSubmenu = P("nsm")!=0;
545
546 login_check_credentials();
547 if( !g.perm.RdWiki ){ login_needed(g.anon.RdWiki); return; }
@@ -589,27 +593,31 @@
589 }
590 if( g.perm.Hyperlink ){
591 style_submenu_element("History", "%R/whistory?name=%T", zPageName);
592 }
593 }
594 style_set_current_page("%T?name=%T", g.zPath, zPageName);
595 wiki_page_header(WIKITYPE_UNKNOWN, zPageName, "");
596 if( !noSubmenu ){
597 wiki_standard_submenu(submenuFlags);
 
 
598 }
599 if( zBody[0]==0 ){
600 @ <i>This page has been deleted</i>
601 }else{
602 blob_init(&wiki, zBody, -1);
603 safe_html_context(DOCSRC_WIKI);
604 wiki_render_by_mimetype(&wiki, zMimetype);
605 blob_reset(&wiki);
606 }
607 attachment_list(zPageName, "<hr /><h2>Attachments:</h2><ul>");
608 manifest_destroy(pWiki);
609 document_emit_js(/*for optional pikchr support*/);
610 style_finish_page();
 
 
 
611 }
612
613 /*
614 ** Write a wiki artifact into the repository
615 */
616
--- src/wiki.c
+++ src/wiki.c
@@ -528,10 +528,13 @@
528 ** nsm Omit the submenu if present. (Mnemonic: No SubMenu)
529 ** p Always show just the wiki page. For special
530 ** pages for check-ins, branches, or tags, there will
531 ** be a redirect to the associated /info page unless
532 ** this query parameter is present.
533 ** popup Suppress the header and footer and other page
534 ** boilerplate and only return the formatted content
535 ** of the wiki page.
536 */
537 void wiki_page(void){
538 char *zTag;
539 int rid = 0;
540 int isSandbox;
@@ -538,10 +541,11 @@
541 unsigned submenuFlags = W_HELP;
542 Blob wiki;
543 Manifest *pWiki = 0;
544 const char *zPageName;
545 const char *zMimetype = 0;
546 int isPopup = P("popup")!=0;
547 char *zBody = mprintf("%s","<i>Empty Page</i>");
548 int noSubmenu = P("nsm")!=0;
549
550 login_check_credentials();
551 if( !g.perm.RdWiki ){ login_needed(g.anon.RdWiki); return; }
@@ -589,27 +593,31 @@
593 }
594 if( g.perm.Hyperlink ){
595 style_submenu_element("History", "%R/whistory?name=%T", zPageName);
596 }
597 }
598 if( !isPopup ){
599 style_set_current_page("%T?name=%T", g.zPath, zPageName);
600 wiki_page_header(WIKITYPE_UNKNOWN, zPageName, "");
601 if( !noSubmenu ){
602 wiki_standard_submenu(submenuFlags);
603 }
604 }
605 if( zBody[0]==0 ){
606 @ <i>This page has been deleted</i>
607 }else{
608 blob_init(&wiki, zBody, -1);
609 safe_html_context(DOCSRC_WIKI);
610 wiki_render_by_mimetype(&wiki, zMimetype);
611 blob_reset(&wiki);
612 }
 
613 manifest_destroy(pWiki);
614 if( !isPopup ){
615 attachment_list(zPageName, "<hr /><h2>Attachments:</h2><ul>");
616 document_emit_js(/*for optional pikchr support*/);
617 style_finish_page();
618 }
619 }
620
621 /*
622 ** Write a wiki artifact into the repository
623 */
624

Keyboard Shortcuts

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