Fossil SCM

Added style_emit_script_bundle() to simplify page-level bundle usage a small bit. /forumpost, /wikiedit, /fileedit now use that routine.

stephan 2020-07-31 16:40 ajax-wiki-editor
Commit 0c233bc6974016c57e34545b9c68f8036e9e7af1f1d5bc03c708811f60d9c028
+1 -1
--- src/fileedit.c
+++ src/fileedit.c
@@ -1970,11 +1970,11 @@
19701970
blob_appendf(&endScript,");\n");
19711971
}
19721972
19731973
blob_reset(&err);
19741974
CheckinMiniInfo_cleanup(&cimi);
1975
- style_emit_script_builtin(0, 0, ":fileedit.js");
1975
+ style_emit_script_bundle("fileedit.js");
19761976
if(blob_size(&endScript)>0){
19771977
style_emit_script_tag(0,0);
19781978
CX("\n(function(){\n");
19791979
CX("try{\n%b}\n"
19801980
"catch(e){"
19811981
--- src/fileedit.c
+++ src/fileedit.c
@@ -1970,11 +1970,11 @@
1970 blob_appendf(&endScript,");\n");
1971 }
1972
1973 blob_reset(&err);
1974 CheckinMiniInfo_cleanup(&cimi);
1975 style_emit_script_builtin(0, 0, ":fileedit.js");
1976 if(blob_size(&endScript)>0){
1977 style_emit_script_tag(0,0);
1978 CX("\n(function(){\n");
1979 CX("try{\n%b}\n"
1980 "catch(e){"
1981
--- src/fileedit.c
+++ src/fileedit.c
@@ -1970,11 +1970,11 @@
1970 blob_appendf(&endScript,");\n");
1971 }
1972
1973 blob_reset(&err);
1974 CheckinMiniInfo_cleanup(&cimi);
1975 style_emit_script_bundle("fileedit.js");
1976 if(blob_size(&endScript)>0){
1977 style_emit_script_tag(0,0);
1978 CX("\n(function(){\n");
1979 CX("try{\n%b}\n"
1980 "catch(e){"
1981
+1 -1
--- src/forum.c
+++ src/forum.c
@@ -887,11 +887,11 @@
887887
}else{
888888
style_submenu_element("Chronological", "%R/%s/%s?t=c", g.zPath, zName);
889889
style_submenu_element("Unformatted", "%R/%s/%s?t=r", g.zPath, zName);
890890
forum_display_hierarchical(froot, fpid);
891891
}
892
- style_emit_script_builtin(0, 0, ":forum.js");
892
+ style_emit_script_bundle("forum.js");
893893
style_footer();
894894
}
895895
896896
/*
897897
** Return true if a forum post should be moderated.
898898
--- src/forum.c
+++ src/forum.c
@@ -887,11 +887,11 @@
887 }else{
888 style_submenu_element("Chronological", "%R/%s/%s?t=c", g.zPath, zName);
889 style_submenu_element("Unformatted", "%R/%s/%s?t=r", g.zPath, zName);
890 forum_display_hierarchical(froot, fpid);
891 }
892 style_emit_script_builtin(0, 0, ":forum.js");
893 style_footer();
894 }
895
896 /*
897 ** Return true if a forum post should be moderated.
898
--- src/forum.c
+++ src/forum.c
@@ -887,11 +887,11 @@
887 }else{
888 style_submenu_element("Chronological", "%R/%s/%s?t=c", g.zPath, zName);
889 style_submenu_element("Unformatted", "%R/%s/%s?t=r", g.zPath, zName);
890 forum_display_hierarchical(froot, fpid);
891 }
892 style_emit_script_bundle("forum.js");
893 style_footer();
894 }
895
896 /*
897 ** Return true if a forum post should be moderated.
898
+13
--- src/style.c
+++ src/style.c
@@ -1719,10 +1719,23 @@
17191719
CX("<script src='%R/%T?cache=%.8s'></script>\n",
17201720
zFullName, zHash);
17211721
fossil_free(zFullName);
17221722
}
17231723
}
1724
+
1725
+/*
1726
+** A convenience wrapper arond style_emit_script_builtin() which
1727
+** prepends a ':' to zName and passes (0,0,newName) to that
1728
+** function. i.e. it emits a SCRIPT tag with
1729
+** src=.../builtin/:${zName}?cache=.... The given name is assumed to
1730
+** have been added to the style.c:BundleEmitters map.
1731
+*/
1732
+void style_emit_script_bundle(char const * zName){
1733
+ char *zBundle = mprintf(":%s", zName);
1734
+ style_emit_script_builtin(0, 0, zBundle);
1735
+ fossil_free(zBundle);
1736
+}
17241737
17251738
/*
17261739
** The first time this is called it emits the JS code from the
17271740
** built-in file fossil.fossil.js. Subsequent calls are no-ops.
17281741
**
17291742
--- src/style.c
+++ src/style.c
@@ -1719,10 +1719,23 @@
1719 CX("<script src='%R/%T?cache=%.8s'></script>\n",
1720 zFullName, zHash);
1721 fossil_free(zFullName);
1722 }
1723 }
 
 
 
 
 
 
 
 
 
 
 
 
 
1724
1725 /*
1726 ** The first time this is called it emits the JS code from the
1727 ** built-in file fossil.fossil.js. Subsequent calls are no-ops.
1728 **
1729
--- src/style.c
+++ src/style.c
@@ -1719,10 +1719,23 @@
1719 CX("<script src='%R/%T?cache=%.8s'></script>\n",
1720 zFullName, zHash);
1721 fossil_free(zFullName);
1722 }
1723 }
1724
1725 /*
1726 ** A convenience wrapper arond style_emit_script_builtin() which
1727 ** prepends a ':' to zName and passes (0,0,newName) to that
1728 ** function. i.e. it emits a SCRIPT tag with
1729 ** src=.../builtin/:${zName}?cache=.... The given name is assumed to
1730 ** have been added to the style.c:BundleEmitters map.
1731 */
1732 void style_emit_script_bundle(char const * zName){
1733 char *zBundle = mprintf(":%s", zName);
1734 style_emit_script_builtin(0, 0, zBundle);
1735 fossil_free(zBundle);
1736 }
1737
1738 /*
1739 ** The first time this is called it emits the JS code from the
1740 ** built-in file fossil.fossil.js. Subsequent calls are no-ops.
1741 **
1742
+1 -1
--- src/wiki.c
+++ src/wiki.c
@@ -1259,11 +1259,11 @@
12591259
CX("<hr><h3>Wiki Name Rules</h3>");
12601260
well_formed_wiki_name_rules();
12611261
CX("</div>"/*#wikiedit-tab-save*/);
12621262
}
12631263
1264
- style_emit_script_builtin(0, 0, ":wikiedit.js");
1264
+ style_emit_script_bundle("wikiedit.js");
12651265
12661266
/* Dynamically populate the editor... */
12671267
style_emit_script_tag(0,0);
12681268
CX("\nfossil.onPageLoad(function(){\n");
12691269
CX("const P = fossil.page;\n"
12701270
--- src/wiki.c
+++ src/wiki.c
@@ -1259,11 +1259,11 @@
1259 CX("<hr><h3>Wiki Name Rules</h3>");
1260 well_formed_wiki_name_rules();
1261 CX("</div>"/*#wikiedit-tab-save*/);
1262 }
1263
1264 style_emit_script_builtin(0, 0, ":wikiedit.js");
1265
1266 /* Dynamically populate the editor... */
1267 style_emit_script_tag(0,0);
1268 CX("\nfossil.onPageLoad(function(){\n");
1269 CX("const P = fossil.page;\n"
1270
--- src/wiki.c
+++ src/wiki.c
@@ -1259,11 +1259,11 @@
1259 CX("<hr><h3>Wiki Name Rules</h3>");
1260 well_formed_wiki_name_rules();
1261 CX("</div>"/*#wikiedit-tab-save*/);
1262 }
1263
1264 style_emit_script_bundle("wikiedit.js");
1265
1266 /* Dynamically populate the editor... */
1267 style_emit_script_tag(0,0);
1268 CX("\nfossil.onPageLoad(function(){\n");
1269 CX("const P = fossil.page;\n"
1270

Keyboard Shortcuts

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