Fossil

Check-in [0c233bc697]
Login

Check-in [0c233bc697]

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Added style_emit_script_bundle() to simplify page-level bundle usage a small bit. /forumpost, /wikiedit, /fileedit now use that routine.
Downloads: Tarball | ZIP archive
Timelines: family | ancestors | descendants | both | ajax-wiki-editor
Files: files | file ages | folders
SHA3-256: 0c233bc6974016c57e34545b9c68f8036e9e7af1f1d5bc03c708811f60d9c028
User & Date: stephan 2020-07-31 16:40:04.432
Context
2020-07-31
16:44
Corrected doc falsehoods. ... (check-in: 1f0a3354aa user: stephan tags: ajax-wiki-editor)
16:40
Added style_emit_script_bundle() to simplify page-level bundle usage a small bit. /forumpost, /wikiedit, /fileedit now use that routine. ... (check-in: 0c233bc697 user: stephan tags: ajax-wiki-editor)
16:14
Extended /builtin/filename to support /builtin/:filename for packing up cacheable bundles of page-specific code. /wikiedit, /fileedit, and /forumpost now serve their JS that way. ... (check-in: 18da05b903 user: stephan tags: ajax-wiki-editor)
Changes
Unified Diff Ignore Whitespace Patch
Changes to src/fileedit.c.
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
      blob_appendf(&endScript,"}");
    }
    blob_appendf(&endScript,");\n");
  }

  blob_reset(&err);
  CheckinMiniInfo_cleanup(&cimi);
  style_emit_script_builtin(0, 0, ":fileedit.js");
  if(blob_size(&endScript)>0){
    style_emit_script_tag(0,0);
    CX("\n(function(){\n");
    CX("try{\n%b}\n"
       "catch(e){"
       "fossil.error(e); console.error('Exception:',e);"
       "}\n",







|







1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
      blob_appendf(&endScript,"}");
    }
    blob_appendf(&endScript,");\n");
  }

  blob_reset(&err);
  CheckinMiniInfo_cleanup(&cimi);
  style_emit_script_bundle("fileedit.js");
  if(blob_size(&endScript)>0){
    style_emit_script_tag(0,0);
    CX("\n(function(){\n");
    CX("try{\n%b}\n"
       "catch(e){"
       "fossil.error(e); console.error('Exception:',e);"
       "}\n",
Changes to src/forum.c.
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
    style_submenu_element("Complete Thread", "%R/%s/%s?t=a", g.zPath, zName);
    forum_display_history(froot, fpid, 1);
  }else{
    style_submenu_element("Chronological", "%R/%s/%s?t=c", g.zPath, zName);
    style_submenu_element("Unformatted", "%R/%s/%s?t=r", g.zPath, zName);
    forum_display_hierarchical(froot, fpid);
  }
  style_emit_script_builtin(0, 0, ":forum.js");
  style_footer();
}

/*
** Return true if a forum post should be moderated.
*/
static int forum_need_moderation(void){







|







885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
    style_submenu_element("Complete Thread", "%R/%s/%s?t=a", g.zPath, zName);
    forum_display_history(froot, fpid, 1);
  }else{
    style_submenu_element("Chronological", "%R/%s/%s?t=c", g.zPath, zName);
    style_submenu_element("Unformatted", "%R/%s/%s?t=r", g.zPath, zName);
    forum_display_hierarchical(froot, fpid);
  }
  style_emit_script_bundle("forum.js");
  style_footer();
}

/*
** Return true if a forum post should be moderated.
*/
static int forum_need_moderation(void){
Changes to src/style.c.
1717
1718
1719
1720
1721
1722
1723













1724
1725
1726
1727
1728
1729
1730
    char * zFullName = mprintf("builtin/%s",zName);
    const char * zHash = fossil_exe_id();
    CX("<script src='%R/%T?cache=%.8s'></script>\n",
       zFullName, zHash);
    fossil_free(zFullName);
  }
}














/*
** The first time this is called it emits the JS code from the
** built-in file fossil.fossil.js. Subsequent calls are no-ops.
**
** If passed a true first argument, it emits the contents directly
** to the page output, else it emits a script tag with a







>
>
>
>
>
>
>
>
>
>
>
>
>







1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
    char * zFullName = mprintf("builtin/%s",zName);
    const char * zHash = fossil_exe_id();
    CX("<script src='%R/%T?cache=%.8s'></script>\n",
       zFullName, zHash);
    fossil_free(zFullName);
  }
}

/*
** A convenience wrapper arond style_emit_script_builtin() which
** prepends a ':' to zName and passes (0,0,newName) to that
** function. i.e. it emits a SCRIPT tag with
** src=.../builtin/:${zName}?cache=.... The given name is assumed to
** have been added to the style.c:BundleEmitters map.
*/
void style_emit_script_bundle(char const * zName){
  char *zBundle = mprintf(":%s", zName);
  style_emit_script_builtin(0, 0, zBundle);
  fossil_free(zBundle);
}

/*
** The first time this is called it emits the JS code from the
** built-in file fossil.fossil.js. Subsequent calls are no-ops.
**
** If passed a true first argument, it emits the contents directly
** to the page output, else it emits a script tag with a
Changes to src/wiki.c.
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
       "the repo with endless test runs. Any attempt to save the "
       "sandbox page will fail.</p>");
    CX("<hr><h3>Wiki Name Rules</h3>");
    well_formed_wiki_name_rules();
    CX("</div>"/*#wikiedit-tab-save*/);
  }

  style_emit_script_builtin(0, 0, ":wikiedit.js");

  /* Dynamically populate the editor... */
  style_emit_script_tag(0,0);
  CX("\nfossil.onPageLoad(function(){\n");
  CX("const P = fossil.page;\n"
     "try{\n");
  if(found){







|







1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
       "the repo with endless test runs. Any attempt to save the "
       "sandbox page will fail.</p>");
    CX("<hr><h3>Wiki Name Rules</h3>");
    well_formed_wiki_name_rules();
    CX("</div>"/*#wikiedit-tab-save*/);
  }

  style_emit_script_bundle("wikiedit.js");

  /* Dynamically populate the editor... */
  style_emit_script_tag(0,0);
  CX("\nfossil.onPageLoad(function(){\n");
  CX("const P = fossil.page;\n"
     "try{\n");
  if(found){