Fossil SCM

/wikiedit and /fileedit now dump all of their common static JS into a single SCRIPT tag instead of making numerous requests, per forum feedback. Fixed/expanded some of the newer script-emitting logic in style.c to handle these. wikiedit no longer mangles the page-level header.

stephan 2020-07-31 14:44 ajax-wiki-editor
Commit a4b73fd081e9bb45d57da293693ca70d25d5a4962985879e63066b328877e00e
+26 -15
--- src/fileedit.c
+++ src/fileedit.c
@@ -1480,10 +1480,35 @@
14801480
fossil_free(zNewUuid);
14811481
blob_reset(&err);
14821482
blob_reset(&manifest);
14831483
CheckinMiniInfo_cleanup(&cimi);
14841484
}
1485
+
1486
+/*
1487
+** Emits all of the "core" static JS needed by /fileedit into a single
1488
+** SCRIPT tag.
1489
+**
1490
+** TODO: a common mechanism which will let us bundle this type of
1491
+** blob into a single cacheable request.
1492
+*/
1493
+static void fileedit_emit_js(void){
1494
+ style_emit_script_tag(0,0);
1495
+ style_emit_script_fossil_bootstrap(1);
1496
+ style_emit_script_builtin(1,0,"sbsdiff.js");
1497
+ style_emit_script_fetch(1,0);
1498
+ style_emit_script_tabs(1,0)/*also emits fossil.dom*/;
1499
+ style_emit_script_confirmer(1,0);
1500
+ style_emit_script_builtin(1, 0, "fossil.storage.js");
1501
+ /*
1502
+ ** Set up a JS-side mapping of the AJAX_RENDER_xyz values. This is
1503
+ ** used for dynamically toggling certain UI components on and off.
1504
+ ** Must come before fossil.page.fileedit.js.
1505
+ */
1506
+ ajax_emit_js_preview_modes(0);
1507
+ style_emit_script_builtin(1, 0, "fossil.page.fileedit.js");
1508
+ style_emit_script_tag(1,0);
1509
+}
14851510
14861511
/*
14871512
** WEBPAGE: fileedit
14881513
**
14891514
** Enables the online editing and committing of individual text files.
@@ -1949,25 +1974,11 @@
19491974
blob_appendf(&endScript,");\n");
19501975
}
19511976
19521977
blob_reset(&err);
19531978
CheckinMiniInfo_cleanup(&cimi);
1954
- style_emit_script_fossil_bootstrap(0);
1955
- append_diff_javascript(1);
1956
- style_emit_script_fetch(0);
1957
- style_emit_script_tabs(0)/*also emits fossil.dom*/;
1958
- style_emit_script_confirmer(0);
1959
- style_emit_script_builtin(0, "fossil.storage.js");
1960
-
1961
- /*
1962
- ** Set up a JS-side mapping of the AJAX_RENDER_xyz values. This is
1963
- ** used for dynamically toggling certain UI components on and off.
1964
- ** Must come before fossil.page.fileedit.js.
1965
- */
1966
- ajax_emit_js_preview_modes(1);
1967
-
1968
- style_emit_script_builtin(0, "fossil.page.fileedit.js");
1979
+ fileedit_emit_js();
19691980
if(blob_size(&endScript)>0){
19701981
style_emit_script_tag(0,0);
19711982
CX("\n(function(){\n");
19721983
CX("try{\n%b}\n"
19731984
"catch(e){"
19741985
--- src/fileedit.c
+++ src/fileedit.c
@@ -1480,10 +1480,35 @@
1480 fossil_free(zNewUuid);
1481 blob_reset(&err);
1482 blob_reset(&manifest);
1483 CheckinMiniInfo_cleanup(&cimi);
1484 }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1485
1486 /*
1487 ** WEBPAGE: fileedit
1488 **
1489 ** Enables the online editing and committing of individual text files.
@@ -1949,25 +1974,11 @@
1949 blob_appendf(&endScript,");\n");
1950 }
1951
1952 blob_reset(&err);
1953 CheckinMiniInfo_cleanup(&cimi);
1954 style_emit_script_fossil_bootstrap(0);
1955 append_diff_javascript(1);
1956 style_emit_script_fetch(0);
1957 style_emit_script_tabs(0)/*also emits fossil.dom*/;
1958 style_emit_script_confirmer(0);
1959 style_emit_script_builtin(0, "fossil.storage.js");
1960
1961 /*
1962 ** Set up a JS-side mapping of the AJAX_RENDER_xyz values. This is
1963 ** used for dynamically toggling certain UI components on and off.
1964 ** Must come before fossil.page.fileedit.js.
1965 */
1966 ajax_emit_js_preview_modes(1);
1967
1968 style_emit_script_builtin(0, "fossil.page.fileedit.js");
1969 if(blob_size(&endScript)>0){
1970 style_emit_script_tag(0,0);
1971 CX("\n(function(){\n");
1972 CX("try{\n%b}\n"
1973 "catch(e){"
1974
--- src/fileedit.c
+++ src/fileedit.c
@@ -1480,10 +1480,35 @@
1480 fossil_free(zNewUuid);
1481 blob_reset(&err);
1482 blob_reset(&manifest);
1483 CheckinMiniInfo_cleanup(&cimi);
1484 }
1485
1486 /*
1487 ** Emits all of the "core" static JS needed by /fileedit into a single
1488 ** SCRIPT tag.
1489 **
1490 ** TODO: a common mechanism which will let us bundle this type of
1491 ** blob into a single cacheable request.
1492 */
1493 static void fileedit_emit_js(void){
1494 style_emit_script_tag(0,0);
1495 style_emit_script_fossil_bootstrap(1);
1496 style_emit_script_builtin(1,0,"sbsdiff.js");
1497 style_emit_script_fetch(1,0);
1498 style_emit_script_tabs(1,0)/*also emits fossil.dom*/;
1499 style_emit_script_confirmer(1,0);
1500 style_emit_script_builtin(1, 0, "fossil.storage.js");
1501 /*
1502 ** Set up a JS-side mapping of the AJAX_RENDER_xyz values. This is
1503 ** used for dynamically toggling certain UI components on and off.
1504 ** Must come before fossil.page.fileedit.js.
1505 */
1506 ajax_emit_js_preview_modes(0);
1507 style_emit_script_builtin(1, 0, "fossil.page.fileedit.js");
1508 style_emit_script_tag(1,0);
1509 }
1510
1511 /*
1512 ** WEBPAGE: fileedit
1513 **
1514 ** Enables the online editing and committing of individual text files.
@@ -1949,25 +1974,11 @@
1974 blob_appendf(&endScript,");\n");
1975 }
1976
1977 blob_reset(&err);
1978 CheckinMiniInfo_cleanup(&cimi);
1979 fileedit_emit_js();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1980 if(blob_size(&endScript)>0){
1981 style_emit_script_tag(0,0);
1982 CX("\n(function(){\n");
1983 CX("try{\n%b}\n"
1984 "catch(e){"
1985
+2 -2
--- src/forum.c
+++ src/forum.c
@@ -761,12 +761,12 @@
761761
static int once = 0;
762762
if(0==once){
763763
once = 1;
764764
style_load_js("forum.js");
765765
style_emit_script_fossil_bootstrap(0);
766
- style_emit_script_dom(0);
767
- style_emit_script_builtin(0, "fossil.page.forumpost.js");
766
+ style_emit_script_dom(0, 1);
767
+ style_emit_script_builtin(0, 1, "fossil.page.forumpost.js");
768768
}
769769
}
770770
771771
/*
772772
** WEBPAGE: forumpost
773773
--- src/forum.c
+++ src/forum.c
@@ -761,12 +761,12 @@
761 static int once = 0;
762 if(0==once){
763 once = 1;
764 style_load_js("forum.js");
765 style_emit_script_fossil_bootstrap(0);
766 style_emit_script_dom(0);
767 style_emit_script_builtin(0, "fossil.page.forumpost.js");
768 }
769 }
770
771 /*
772 ** WEBPAGE: forumpost
773
--- src/forum.c
+++ src/forum.c
@@ -761,12 +761,12 @@
761 static int once = 0;
762 if(0==once){
763 once = 1;
764 style_load_js("forum.js");
765 style_emit_script_fossil_bootstrap(0);
766 style_emit_script_dom(0, 1);
767 style_emit_script_builtin(0, 1, "fossil.page.forumpost.js");
768 }
769 }
770
771 /*
772 ** WEBPAGE: forumpost
773
--- src/fossil.page.wikiedit.js
+++ src/fossil.page.wikiedit.js
@@ -797,24 +797,23 @@
797797
this.winfo. A no-op if this.winfo is not set. Returns this.
798798
*/
799799
P.updatePageTitle = function f(){
800800
if(!f.titleElement){
801801
f.titleElement = document.head.querySelector('title');
802
- f.pageTitleHeader = document.querySelector('div.header .title');
802
+ f.pageTitleHeader = document.querySelector('#wikiedit-page-name > span');
803803
}
804
- var title = ['Wiki Editor:'];
804
+ const title = ['Wiki Editor:'];
805805
const wi = P.winfo;
806806
if(wi){
807807
if(!wi.version && 'sandbox'!==wi.type) title.push(P.config.editStateMarkers.isNew);
808808
else if($stash.getWinfo(wi)) title.push(P.config.editStateMarkers.isModified)
809809
title.push(wi.name);
810810
}else{
811811
title.push('(no page loaded)');
812812
}
813
- title = title.join(' ');
814
- f.titleElement.innerText = title;
815
- f.pageTitleHeader.innerText = title;
813
+ f.pageTitleHeader.innerText = title[1];
814
+ f.titleElement.innerText = title.join(' ');
816815
return this;
817816
};
818817
819818
/**
820819
Change the save button depending on whether we have stuff to save
821820
--- src/fossil.page.wikiedit.js
+++ src/fossil.page.wikiedit.js
@@ -797,24 +797,23 @@
797 this.winfo. A no-op if this.winfo is not set. Returns this.
798 */
799 P.updatePageTitle = function f(){
800 if(!f.titleElement){
801 f.titleElement = document.head.querySelector('title');
802 f.pageTitleHeader = document.querySelector('div.header .title');
803 }
804 var title = ['Wiki Editor:'];
805 const wi = P.winfo;
806 if(wi){
807 if(!wi.version && 'sandbox'!==wi.type) title.push(P.config.editStateMarkers.isNew);
808 else if($stash.getWinfo(wi)) title.push(P.config.editStateMarkers.isModified)
809 title.push(wi.name);
810 }else{
811 title.push('(no page loaded)');
812 }
813 title = title.join(' ');
814 f.titleElement.innerText = title;
815 f.pageTitleHeader.innerText = title;
816 return this;
817 };
818
819 /**
820 Change the save button depending on whether we have stuff to save
821
--- src/fossil.page.wikiedit.js
+++ src/fossil.page.wikiedit.js
@@ -797,24 +797,23 @@
797 this.winfo. A no-op if this.winfo is not set. Returns this.
798 */
799 P.updatePageTitle = function f(){
800 if(!f.titleElement){
801 f.titleElement = document.head.querySelector('title');
802 f.pageTitleHeader = document.querySelector('#wikiedit-page-name > span');
803 }
804 const title = ['Wiki Editor:'];
805 const wi = P.winfo;
806 if(wi){
807 if(!wi.version && 'sandbox'!==wi.type) title.push(P.config.editStateMarkers.isNew);
808 else if($stash.getWinfo(wi)) title.push(P.config.editStateMarkers.isModified)
809 title.push(wi.name);
810 }else{
811 title.push('(no page loaded)');
812 }
813 f.pageTitleHeader.innerText = title[1];
814 f.titleElement.innerText = title.join(' ');
 
815 return this;
816 };
817
818 /**
819 Change the save button depending on whether we have stuff to save
820
+63 -58
--- src/style.c
+++ src/style.c
@@ -1535,24 +1535,30 @@
15351535
** bootstrap the window.fossil object, using the built-in file
15361536
** fossil.bootstrap.js (not to be confused with bootstrap.js).
15371537
**
15381538
** Subsequent calls are no-ops.
15391539
**
1540
-** If passed a true value, it emits the contents directly to the page
1541
-** output, else it emits a script tag with a src=builtin/... to load
1542
-** the script. It always outputs a small pre-bootstrap element in its
1543
-** own script tag to initialize parts which need C-runtime-level
1544
-** information, before loading the main fossil.bootstrap.js either
1545
-** inline or via a <script src=...>, as specified by the first
1546
-** argument.
1540
+** It emits 2 parts:
1541
+**
1542
+** 1) window.fossil core object, some of which depends on C-lelel
1543
+** runtime data. That part of the script is always emitted inline. If
1544
+** addScripTag is true then it is wrapped in its own SCRIPT tag, else
1545
+** it is assumed that the caller already opened a tag.
1546
+**
1547
+** 2) Emits the static fossil.bootstrap.js. If asInline is true then
1548
+** it is emitted inline with the components from (1), else it is
1549
+** emitted as a separate SCRIPT tag with
1550
+** src=/builtin/fossil.bootstrap.js (so causes another HTTP request).
15471551
*/
15481552
void style_emit_script_fossil_bootstrap(int asInline){
15491553
static int once = 0;
15501554
if(0==once++){
15511555
/* Set up the generic/app-agnostic parts of window.fossil
15521556
** which require C-level state... */
1553
- style_emit_script_tag(0,0);
1557
+ if(asInline==0){
1558
+ style_emit_script_tag(0,0);
1559
+ }
15541560
CX("(function(){\n"
15551561
"if(!window.fossil) window.fossil={};\n"
15561562
"window.fossil.version = %!j;\n"
15571563
/* fossil.rootPath is the top-most CGI/server path,
15581564
** including a trailing slash. */
@@ -1579,16 +1585,15 @@
15791585
"name:\"%T\""
15801586
"};\n", g.zPath);
15811587
CX("})();\n");
15821588
/* The remaining fossil object bootstrap code is not dependent on
15831589
** C-runtime state... */
1584
- if(asInline){
1590
+ if(asInline!=0){
15851591
CX("%s\n", builtin_text("fossil.bootstrap.js"));
1586
- }
1587
- style_emit_script_tag(1,0);
1588
- if(asInline==0){
1589
- style_emit_script_builtin(0, "fossil.bootstrap.js");
1592
+ }else{
1593
+ style_emit_script_tag(1,0);
1594
+ style_emit_script_builtin(0,1,"fossil.bootstrap.js");
15901595
}
15911596
}
15921597
}
15931598
15941599
/*
@@ -1622,22 +1627,24 @@
16221627
}
16231628
16241629
/*
16251630
** Emits a script tag which uses content from a builtin script file.
16261631
**
1627
-** If asInline is true, it is emitted directly as an opening tag, the
1628
-** content of the zName builtin file, and a closing tag.
1632
+** If asInline is false, the script is emitted as a SCRIPT tag with a
1633
+** src attribute of /builtin/zName and the 2nd parameter is
1634
+** ignored. If asInline is true then the contents of the script are
1635
+** emitted directly, with a wrapping SCRIPT tag if addScripTag is
1636
+** true, else no wrapping script tag..
16291637
**
16301638
** If it is false, a script tag loading it via
16311639
** src=builtin/{{zName}}?cache=XYZ is emitted, where XYZ is a
16321640
** build-time-dependent cache-buster value.
16331641
*/
1634
-void style_emit_script_builtin(int asInline, char const * zName){
1642
+void style_emit_script_builtin(int asInline, int addScripTag,
1643
+ char const * zName){
16351644
if(asInline){
1636
- style_emit_script_tag(0,0);
16371645
CX("%s", builtin_text(zName));
1638
- style_emit_script_tag(1,0);
16391646
}else{
16401647
char * zFullName = mprintf("builtin/%s",zName);
16411648
const char * zHash = fossil_exe_id();
16421649
CX("<script src='%R/%T?cache=%.8s'></script>\n",
16431650
zFullName, zHash);
@@ -1647,70 +1654,68 @@
16471654
16481655
/*
16491656
** The first time this is called it emits the JS code from the
16501657
** built-in file fossil.fossil.js. Subsequent calls are no-ops.
16511658
**
1652
-** If passed a true value, it emits the contents directly
1659
+** If passed a true first argument, it emits the contents directly
16531660
** to the page output, else it emits a script tag with a
16541661
** src=builtin/... to load the script.
1662
+**
1663
+** If asInline is true and addScripTag is true then the contents
1664
+** are emitted directly but wrapped in a SCRIPT tag. If asInline
1665
+** is false, addScriptTag is ignored.
16551666
**
16561667
** Note that this code relies on that loaded via
16571668
** style_emit_script_fossil_bootstrap() but it does not call that
16581669
** routine.
16591670
*/
1660
-void style_emit_script_fetch(int asInline){
1671
+void style_emit_script_fetch(int asInline, int addScripTag){
16611672
static int once = 0;
16621673
if(0==once++){
1663
- style_emit_script_builtin(asInline, "fossil.fetch.js");
1674
+ style_emit_script_builtin(asInline, addScripTag, "fossil.fetch.js");
16641675
}
16651676
}
16661677
16671678
/*
16681679
** The first time this is called it emits the JS code from the
16691680
** built-in file fossil.dom.js. Subsequent calls are no-ops.
16701681
**
1671
-** If passed a true value, it emits the contents directly
1682
+** If passed a true first argument, it emits the contents directly
16721683
** to the page output, else it emits a script tag with a
16731684
** src=builtin/... to load the script.
1685
+**
1686
+** If asInline is true and addScripTag is true then the contents
1687
+** are emitted directly but wrapped in a SCRIPT tag. If asInline
1688
+** is false, addScriptTag is ignored.
16741689
**
16751690
** Note that this code relies on that loaded via
16761691
** style_emit_script_fossil_bootstrap(), but it does not call that
16771692
** routine.
16781693
*/
1679
-void style_emit_script_dom(int asInline){
1680
- static int once = 0;
1681
- if(0==once++){
1682
- style_emit_script_builtin(asInline, "fossil.dom.js");
1683
- }
1684
-}
1685
-
1686
-/*
1687
-** The first time this is called, it calls style_emit_script_dom(),
1688
-** passing it the given asInline value, and emits the JS code from the
1689
-** built-in file fossil.tabs.js. Subsequent calls are no-ops.
1690
-**
1691
-** If passed a true value, it emits the contents directly
1692
-** to the page output, else it emits a script tag with a
1693
-** src=builtin/... to load the script.
1694
-*/
1695
-void style_emit_script_tabs(int asInline){
1696
- static int once = 0;
1697
- if(0==once++){
1698
- style_emit_script_dom(asInline);
1699
- style_emit_script_builtin(asInline, "fossil.tabs.js");
1700
- }
1701
-}
1702
-
1703
-/*
1704
-** The first time this is called it emits the JS code from the
1705
-** built-in file fossil.confirmer.js. Subsequent calls are no-ops.
1706
-**
1707
-** If passed a true value, it emits the contents directly
1708
-** to the page output, else it emits a script tag with a
1709
-** src=builtin/... to load the script.
1710
-*/
1711
-void style_emit_script_confirmer(int asInline){
1712
- static int once = 0;
1713
- if(0==once++){
1714
- style_emit_script_builtin(asInline, "fossil.confirmer.js");
1694
+void style_emit_script_dom(int asInline, int addScripTag){
1695
+ static int once = 0;
1696
+ if(0==once++){
1697
+ style_emit_script_builtin(asInline, addScripTag, "fossil.dom.js");
1698
+ }
1699
+}
1700
+
1701
+/*
1702
+** The fossil.tabs.js counterpart of style_emit_script_fetch().
1703
+** Also emits fossil.dom.js.
1704
+*/
1705
+void style_emit_script_tabs(int asInline, int addScripTag){
1706
+ static int once = 0;
1707
+ if(0==once++){
1708
+ style_emit_script_dom(asInline, addScripTag);
1709
+ style_emit_script_builtin(asInline, addScripTag, "fossil.tabs.js");
1710
+ }
1711
+}
1712
+
1713
+/*
1714
+** The fossil.confirmer.js counterpart of style_emit_script_fetch().
1715
+*/
1716
+void style_emit_script_confirmer(int asInline, int addScripTag){
1717
+ static int once = 0;
1718
+ if(0==once++){
1719
+ style_emit_script_builtin(asInline, 0, "fossil.confirmer.js");
17151720
}
17161721
}
17171722
--- src/style.c
+++ src/style.c
@@ -1535,24 +1535,30 @@
1535 ** bootstrap the window.fossil object, using the built-in file
1536 ** fossil.bootstrap.js (not to be confused with bootstrap.js).
1537 **
1538 ** Subsequent calls are no-ops.
1539 **
1540 ** If passed a true value, it emits the contents directly to the page
1541 ** output, else it emits a script tag with a src=builtin/... to load
1542 ** the script. It always outputs a small pre-bootstrap element in its
1543 ** own script tag to initialize parts which need C-runtime-level
1544 ** information, before loading the main fossil.bootstrap.js either
1545 ** inline or via a <script src=...>, as specified by the first
1546 ** argument.
 
 
 
 
1547 */
1548 void style_emit_script_fossil_bootstrap(int asInline){
1549 static int once = 0;
1550 if(0==once++){
1551 /* Set up the generic/app-agnostic parts of window.fossil
1552 ** which require C-level state... */
1553 style_emit_script_tag(0,0);
 
 
1554 CX("(function(){\n"
1555 "if(!window.fossil) window.fossil={};\n"
1556 "window.fossil.version = %!j;\n"
1557 /* fossil.rootPath is the top-most CGI/server path,
1558 ** including a trailing slash. */
@@ -1579,16 +1585,15 @@
1579 "name:\"%T\""
1580 "};\n", g.zPath);
1581 CX("})();\n");
1582 /* The remaining fossil object bootstrap code is not dependent on
1583 ** C-runtime state... */
1584 if(asInline){
1585 CX("%s\n", builtin_text("fossil.bootstrap.js"));
1586 }
1587 style_emit_script_tag(1,0);
1588 if(asInline==0){
1589 style_emit_script_builtin(0, "fossil.bootstrap.js");
1590 }
1591 }
1592 }
1593
1594 /*
@@ -1622,22 +1627,24 @@
1622 }
1623
1624 /*
1625 ** Emits a script tag which uses content from a builtin script file.
1626 **
1627 ** If asInline is true, it is emitted directly as an opening tag, the
1628 ** content of the zName builtin file, and a closing tag.
 
 
 
1629 **
1630 ** If it is false, a script tag loading it via
1631 ** src=builtin/{{zName}}?cache=XYZ is emitted, where XYZ is a
1632 ** build-time-dependent cache-buster value.
1633 */
1634 void style_emit_script_builtin(int asInline, char const * zName){
 
1635 if(asInline){
1636 style_emit_script_tag(0,0);
1637 CX("%s", builtin_text(zName));
1638 style_emit_script_tag(1,0);
1639 }else{
1640 char * zFullName = mprintf("builtin/%s",zName);
1641 const char * zHash = fossil_exe_id();
1642 CX("<script src='%R/%T?cache=%.8s'></script>\n",
1643 zFullName, zHash);
@@ -1647,70 +1654,68 @@
1647
1648 /*
1649 ** The first time this is called it emits the JS code from the
1650 ** built-in file fossil.fossil.js. Subsequent calls are no-ops.
1651 **
1652 ** If passed a true value, it emits the contents directly
1653 ** to the page output, else it emits a script tag with a
1654 ** src=builtin/... to load the script.
 
 
 
 
1655 **
1656 ** Note that this code relies on that loaded via
1657 ** style_emit_script_fossil_bootstrap() but it does not call that
1658 ** routine.
1659 */
1660 void style_emit_script_fetch(int asInline){
1661 static int once = 0;
1662 if(0==once++){
1663 style_emit_script_builtin(asInline, "fossil.fetch.js");
1664 }
1665 }
1666
1667 /*
1668 ** The first time this is called it emits the JS code from the
1669 ** built-in file fossil.dom.js. Subsequent calls are no-ops.
1670 **
1671 ** If passed a true value, it emits the contents directly
1672 ** to the page output, else it emits a script tag with a
1673 ** src=builtin/... to load the script.
 
 
 
 
1674 **
1675 ** Note that this code relies on that loaded via
1676 ** style_emit_script_fossil_bootstrap(), but it does not call that
1677 ** routine.
1678 */
1679 void style_emit_script_dom(int asInline){
1680 static int once = 0;
1681 if(0==once++){
1682 style_emit_script_builtin(asInline, "fossil.dom.js");
1683 }
1684 }
1685
1686 /*
1687 ** The first time this is called, it calls style_emit_script_dom(),
1688 ** passing it the given asInline value, and emits the JS code from the
1689 ** built-in file fossil.tabs.js. Subsequent calls are no-ops.
1690 **
1691 ** If passed a true value, it emits the contents directly
1692 ** to the page output, else it emits a script tag with a
1693 ** src=builtin/... to load the script.
1694 */
1695 void style_emit_script_tabs(int asInline){
1696 static int once = 0;
1697 if(0==once++){
1698 style_emit_script_dom(asInline);
1699 style_emit_script_builtin(asInline, "fossil.tabs.js");
1700 }
1701 }
1702
1703 /*
1704 ** The first time this is called it emits the JS code from the
1705 ** built-in file fossil.confirmer.js. Subsequent calls are no-ops.
1706 **
1707 ** If passed a true value, it emits the contents directly
1708 ** to the page output, else it emits a script tag with a
1709 ** src=builtin/... to load the script.
1710 */
1711 void style_emit_script_confirmer(int asInline){
1712 static int once = 0;
1713 if(0==once++){
1714 style_emit_script_builtin(asInline, "fossil.confirmer.js");
1715 }
1716 }
1717
--- src/style.c
+++ src/style.c
@@ -1535,24 +1535,30 @@
1535 ** bootstrap the window.fossil object, using the built-in file
1536 ** fossil.bootstrap.js (not to be confused with bootstrap.js).
1537 **
1538 ** Subsequent calls are no-ops.
1539 **
1540 ** It emits 2 parts:
1541 **
1542 ** 1) window.fossil core object, some of which depends on C-lelel
1543 ** runtime data. That part of the script is always emitted inline. If
1544 ** addScripTag is true then it is wrapped in its own SCRIPT tag, else
1545 ** it is assumed that the caller already opened a tag.
1546 **
1547 ** 2) Emits the static fossil.bootstrap.js. If asInline is true then
1548 ** it is emitted inline with the components from (1), else it is
1549 ** emitted as a separate SCRIPT tag with
1550 ** src=/builtin/fossil.bootstrap.js (so causes another HTTP request).
1551 */
1552 void style_emit_script_fossil_bootstrap(int asInline){
1553 static int once = 0;
1554 if(0==once++){
1555 /* Set up the generic/app-agnostic parts of window.fossil
1556 ** which require C-level state... */
1557 if(asInline==0){
1558 style_emit_script_tag(0,0);
1559 }
1560 CX("(function(){\n"
1561 "if(!window.fossil) window.fossil={};\n"
1562 "window.fossil.version = %!j;\n"
1563 /* fossil.rootPath is the top-most CGI/server path,
1564 ** including a trailing slash. */
@@ -1579,16 +1585,15 @@
1585 "name:\"%T\""
1586 "};\n", g.zPath);
1587 CX("})();\n");
1588 /* The remaining fossil object bootstrap code is not dependent on
1589 ** C-runtime state... */
1590 if(asInline!=0){
1591 CX("%s\n", builtin_text("fossil.bootstrap.js"));
1592 }else{
1593 style_emit_script_tag(1,0);
1594 style_emit_script_builtin(0,1,"fossil.bootstrap.js");
 
1595 }
1596 }
1597 }
1598
1599 /*
@@ -1622,22 +1627,24 @@
1627 }
1628
1629 /*
1630 ** Emits a script tag which uses content from a builtin script file.
1631 **
1632 ** If asInline is false, the script is emitted as a SCRIPT tag with a
1633 ** src attribute of /builtin/zName and the 2nd parameter is
1634 ** ignored. If asInline is true then the contents of the script are
1635 ** emitted directly, with a wrapping SCRIPT tag if addScripTag is
1636 ** true, else no wrapping script tag..
1637 **
1638 ** If it is false, a script tag loading it via
1639 ** src=builtin/{{zName}}?cache=XYZ is emitted, where XYZ is a
1640 ** build-time-dependent cache-buster value.
1641 */
1642 void style_emit_script_builtin(int asInline, int addScripTag,
1643 char const * zName){
1644 if(asInline){
 
1645 CX("%s", builtin_text(zName));
 
1646 }else{
1647 char * zFullName = mprintf("builtin/%s",zName);
1648 const char * zHash = fossil_exe_id();
1649 CX("<script src='%R/%T?cache=%.8s'></script>\n",
1650 zFullName, zHash);
@@ -1647,70 +1654,68 @@
1654
1655 /*
1656 ** The first time this is called it emits the JS code from the
1657 ** built-in file fossil.fossil.js. Subsequent calls are no-ops.
1658 **
1659 ** If passed a true first argument, it emits the contents directly
1660 ** to the page output, else it emits a script tag with a
1661 ** src=builtin/... to load the script.
1662 **
1663 ** If asInline is true and addScripTag is true then the contents
1664 ** are emitted directly but wrapped in a SCRIPT tag. If asInline
1665 ** is false, addScriptTag is ignored.
1666 **
1667 ** Note that this code relies on that loaded via
1668 ** style_emit_script_fossil_bootstrap() but it does not call that
1669 ** routine.
1670 */
1671 void style_emit_script_fetch(int asInline, int addScripTag){
1672 static int once = 0;
1673 if(0==once++){
1674 style_emit_script_builtin(asInline, addScripTag, "fossil.fetch.js");
1675 }
1676 }
1677
1678 /*
1679 ** The first time this is called it emits the JS code from the
1680 ** built-in file fossil.dom.js. Subsequent calls are no-ops.
1681 **
1682 ** If passed a true first argument, it emits the contents directly
1683 ** to the page output, else it emits a script tag with a
1684 ** src=builtin/... to load the script.
1685 **
1686 ** If asInline is true and addScripTag is true then the contents
1687 ** are emitted directly but wrapped in a SCRIPT tag. If asInline
1688 ** is false, addScriptTag is ignored.
1689 **
1690 ** Note that this code relies on that loaded via
1691 ** style_emit_script_fossil_bootstrap(), but it does not call that
1692 ** routine.
1693 */
1694 void style_emit_script_dom(int asInline, int addScripTag){
1695 static int once = 0;
1696 if(0==once++){
1697 style_emit_script_builtin(asInline, addScripTag, "fossil.dom.js");
1698 }
1699 }
1700
1701 /*
1702 ** The fossil.tabs.js counterpart of style_emit_script_fetch().
1703 ** Also emits fossil.dom.js.
1704 */
1705 void style_emit_script_tabs(int asInline, int addScripTag){
1706 static int once = 0;
1707 if(0==once++){
1708 style_emit_script_dom(asInline, addScripTag);
1709 style_emit_script_builtin(asInline, addScripTag, "fossil.tabs.js");
1710 }
1711 }
1712
1713 /*
1714 ** The fossil.confirmer.js counterpart of style_emit_script_fetch().
1715 */
1716 void style_emit_script_confirmer(int asInline, int addScripTag){
1717 static int once = 0;
1718 if(0==once++){
1719 style_emit_script_builtin(asInline, 0, "fossil.confirmer.js");
 
 
 
 
 
 
 
 
 
 
1720 }
1721 }
1722
--- src/style.wikiedit.css
+++ src/style.wikiedit.css
@@ -116,5 +116,9 @@
116116
/* These invisible placeholders mark spots in the UI
117117
(max. 1 per tab) to where the save button gets
118118
relocated as we switch between tabs. */
119119
display: none;
120120
}
121
+
122
+body.wikiedit #wikiedit-page-name > span {
123
+ font-family: monospace;
124
+}
121125
--- src/style.wikiedit.css
+++ src/style.wikiedit.css
@@ -116,5 +116,9 @@
116 /* These invisible placeholders mark spots in the UI
117 (max. 1 per tab) to where the save button gets
118 relocated as we switch between tabs. */
119 display: none;
120 }
 
 
 
 
121
--- src/style.wikiedit.css
+++ src/style.wikiedit.css
@@ -116,5 +116,9 @@
116 /* These invisible placeholders mark spots in the UI
117 (max. 1 per tab) to where the save button gets
118 relocated as we switch between tabs. */
119 display: none;
120 }
121
122 body.wikiedit #wikiedit-page-name > span {
123 font-family: monospace;
124 }
125
+23 -8
--- src/wiki.c
+++ src/wiki.c
@@ -1058,10 +1058,29 @@
10581058
"connections).");
10591059
return;
10601060
}
10611061
pRoute->xCallback();
10621062
}
1063
+
1064
+/*
1065
+** Emits all of the "core" static JS needed by /wikiedit into a single
1066
+** SCRIPT tag.
1067
+**
1068
+** TODO: a common mechanism which will let us bundle this type of
1069
+** blob into a single cacheable request.
1070
+*/
1071
+static void wikiedit_emit_js(void){
1072
+ style_emit_script_tag(0,0);
1073
+ style_emit_script_fossil_bootstrap(1);
1074
+ style_emit_script_builtin(1,0,"sbsdiff.js");
1075
+ style_emit_script_fetch(1, 0);
1076
+ style_emit_script_tabs(1,0)/*also emits fossil.dom*/;
1077
+ style_emit_script_confirmer(1,0);
1078
+ style_emit_script_builtin(1, 0, "fossil.storage.js");
1079
+ style_emit_script_builtin(1, 0, "fossil.page.wikiedit.js");
1080
+ style_emit_script_tag(1,0);
1081
+}
10631082
10641083
/*
10651084
** WEBPAGE: wikiedit
10661085
** URL: /wikedit?name=PAGENAME
10671086
**
@@ -1110,10 +1129,12 @@
11101129
/* Status bar */
11111130
CX("<div id='fossil-status-bar' "
11121131
"title='Status message area. Double-click to clear them.'>"
11131132
"Status messages will go here.</div>\n"
11141133
/* will be moved into the tab container via JS */);
1134
+
1135
+ CX("<div id='wikiedit-page-name'>Editing: <span>(no file loaded)</span></div>");
11151136
11161137
/* Main tab container... */
11171138
CX("<div id='wikiedit-tabs' class='tab-container'>Loading...</div>");
11181139
/* The .hidden class on the following tab elements is to help lessen
11191140
the FOUC effect of the tabs before JS re-assembles them. */
@@ -1241,18 +1262,12 @@
12411262
"sandbox page will fail.</p>");
12421263
CX("<hr><h3>Wiki Name Rules</h3>");
12431264
well_formed_wiki_name_rules();
12441265
CX("</div>"/*#wikiedit-tab-save*/);
12451266
}
1246
-
1247
- style_emit_script_fossil_bootstrap(0);
1248
- append_diff_javascript(1);
1249
- style_emit_script_fetch(0);
1250
- style_emit_script_tabs(0)/*also emits fossil.dom*/;
1251
- style_emit_script_confirmer(0);
1252
- style_emit_script_builtin(0, "fossil.storage.js");
1253
- style_emit_script_builtin(0, "fossil.page.wikiedit.js");
1267
+
1268
+ wikiedit_emit_js();
12541269
12551270
/* Dynamically populate the editor... */
12561271
style_emit_script_tag(0,0);
12571272
CX("\nfossil.onPageLoad(function(){\n");
12581273
CX("const P = fossil.page;\n"
12591274
--- src/wiki.c
+++ src/wiki.c
@@ -1058,10 +1058,29 @@
1058 "connections).");
1059 return;
1060 }
1061 pRoute->xCallback();
1062 }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1063
1064 /*
1065 ** WEBPAGE: wikiedit
1066 ** URL: /wikedit?name=PAGENAME
1067 **
@@ -1110,10 +1129,12 @@
1110 /* Status bar */
1111 CX("<div id='fossil-status-bar' "
1112 "title='Status message area. Double-click to clear them.'>"
1113 "Status messages will go here.</div>\n"
1114 /* will be moved into the tab container via JS */);
 
 
1115
1116 /* Main tab container... */
1117 CX("<div id='wikiedit-tabs' class='tab-container'>Loading...</div>");
1118 /* The .hidden class on the following tab elements is to help lessen
1119 the FOUC effect of the tabs before JS re-assembles them. */
@@ -1241,18 +1262,12 @@
1241 "sandbox page will fail.</p>");
1242 CX("<hr><h3>Wiki Name Rules</h3>");
1243 well_formed_wiki_name_rules();
1244 CX("</div>"/*#wikiedit-tab-save*/);
1245 }
1246
1247 style_emit_script_fossil_bootstrap(0);
1248 append_diff_javascript(1);
1249 style_emit_script_fetch(0);
1250 style_emit_script_tabs(0)/*also emits fossil.dom*/;
1251 style_emit_script_confirmer(0);
1252 style_emit_script_builtin(0, "fossil.storage.js");
1253 style_emit_script_builtin(0, "fossil.page.wikiedit.js");
1254
1255 /* Dynamically populate the editor... */
1256 style_emit_script_tag(0,0);
1257 CX("\nfossil.onPageLoad(function(){\n");
1258 CX("const P = fossil.page;\n"
1259
--- src/wiki.c
+++ src/wiki.c
@@ -1058,10 +1058,29 @@
1058 "connections).");
1059 return;
1060 }
1061 pRoute->xCallback();
1062 }
1063
1064 /*
1065 ** Emits all of the "core" static JS needed by /wikiedit into a single
1066 ** SCRIPT tag.
1067 **
1068 ** TODO: a common mechanism which will let us bundle this type of
1069 ** blob into a single cacheable request.
1070 */
1071 static void wikiedit_emit_js(void){
1072 style_emit_script_tag(0,0);
1073 style_emit_script_fossil_bootstrap(1);
1074 style_emit_script_builtin(1,0,"sbsdiff.js");
1075 style_emit_script_fetch(1, 0);
1076 style_emit_script_tabs(1,0)/*also emits fossil.dom*/;
1077 style_emit_script_confirmer(1,0);
1078 style_emit_script_builtin(1, 0, "fossil.storage.js");
1079 style_emit_script_builtin(1, 0, "fossil.page.wikiedit.js");
1080 style_emit_script_tag(1,0);
1081 }
1082
1083 /*
1084 ** WEBPAGE: wikiedit
1085 ** URL: /wikedit?name=PAGENAME
1086 **
@@ -1110,10 +1129,12 @@
1129 /* Status bar */
1130 CX("<div id='fossil-status-bar' "
1131 "title='Status message area. Double-click to clear them.'>"
1132 "Status messages will go here.</div>\n"
1133 /* will be moved into the tab container via JS */);
1134
1135 CX("<div id='wikiedit-page-name'>Editing: <span>(no file loaded)</span></div>");
1136
1137 /* Main tab container... */
1138 CX("<div id='wikiedit-tabs' class='tab-container'>Loading...</div>");
1139 /* The .hidden class on the following tab elements is to help lessen
1140 the FOUC effect of the tabs before JS re-assembles them. */
@@ -1241,18 +1262,12 @@
1262 "sandbox page will fail.</p>");
1263 CX("<hr><h3>Wiki Name Rules</h3>");
1264 well_formed_wiki_name_rules();
1265 CX("</div>"/*#wikiedit-tab-save*/);
1266 }
1267
1268 wikiedit_emit_js();
 
 
 
 
 
 
1269
1270 /* Dynamically populate the editor... */
1271 style_emit_script_tag(0,0);
1272 CX("\nfossil.onPageLoad(function(){\n");
1273 CX("const P = fossil.page;\n"
1274

Keyboard Shortcuts

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