Fossil

Check-in [cee662d9]
Login

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

Overview
Comment:Add the "/test-builtin-files" webpage.
Downloads: Tarball | ZIP archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: cee662d96ed9c49abce31665c4fbfc866c30eeb551a819d5643dd4df3ae8dc25
User & Date: drh 2017-12-05 15:21:49.910
Context
2017-12-05
15:48
Tolerate "[...]" delimiters enclosing hash identifiers. ... (check-in: 537b498e user: drh tags: trunk)
15:21
Add the "/test-builtin-files" webpage. ... (check-in: cee662d9 user: drh tags: trunk)
15:09
Change the name of "main.js" to "href.js". Rework the javascript code so that there can be multiple javascript files sourced on an as-needed basis. ... (check-in: 09494b02 user: drh tags: trunk)
Changes
Unified Diff Ignore Whitespace Patch
Changes to src/builtin.c.
62
63
64
65
66
67
68

















69
70
71
72
73
74
75
*/
void test_builtin_list(void){
  int i;
  for(i=0; i<count(aBuiltinFiles); i++){
    fossil_print("%-30s %6d\n", aBuiltinFiles[i].zName,aBuiltinFiles[i].nByte);
  }
}


















/*
** COMMAND: test-builtin-get
**
** Usage: %fossil test-builtin-get NAME ?OUTPUT-FILE?
*/
void test_builtin_get(void){







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







62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
*/
void test_builtin_list(void){
  int i;
  for(i=0; i<count(aBuiltinFiles); i++){
    fossil_print("%-30s %6d\n", aBuiltinFiles[i].zName,aBuiltinFiles[i].nByte);
  }
}

/*
** WEBPAGE: test-builtin-files
**
** Show all built-in text files.
*/
void test_builtin_list_page(void){
  int i;
  style_header("Built-in Text Files");
  @ <ul>
  for(i=0; i<count(aBuiltinFiles); i++){
    const char *z = aBuiltinFiles[i].zName;
    @ <li>%z(href("%R/builtin?name=%T&id=%S",z,MANIFEST_UUID))%h(z)</a>
  }
  @ </ul>
  style_footer();
}

/*
** COMMAND: test-builtin-get
**
** Usage: %fossil test-builtin-get NAME ?OUTPUT-FILE?
*/
void test_builtin_get(void){
Changes to src/style.c.
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
  return 0;
}

/*
** Generate code to load a single javascript file
*/
static void style_load_one_js_file(const char *zFile){
  @ <script src='%R/builtin/%s(zFile)/%S(MANIFEST_UUID)'></script>
}

/*
** Generate code to load all required javascript files.
*/
static void style_load_all_js_files(void){
  if( needHrefJs ){







|







515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
  return 0;
}

/*
** Generate code to load a single javascript file
*/
static void style_load_one_js_file(const char *zFile){
  @ <script src='%R/builtin/%s(zFile)?id=%S(MANIFEST_UUID)'></script>
}

/*
** Generate code to load all required javascript files.
*/
static void style_load_all_js_files(void){
  if( needHrefJs ){
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887

  /* Tell CGI that the content returned by this page is considered cacheable */
  g.isConst = 1;
}

/*
** WEBPAGE: builtin
** URL:  builtin/FILENAME/VERSION
**
** Return the built-in text given by FILENAME.  This is used internally 
** by many Fossil web pages to load built-in javascript files.
**
** The VERSION string at the end is ignored.  Fossil web pages will
** typically put the current Fossil check-in hash as VERSION, to cause
** javascript files to be reloaded rather than sourcing a stale javascript
** file from cache.
*/
void page_builtin_text(void){
  Blob out;
  const char *zName = P("name");
  const char *zTxt = 0;
  if( zName ){
    int i;
    for(i=0; zName[i]; i++){
      if( zName[i]=='/' ){
        zName = mprintf("%.*s", i, zName);
        break;
      }
    }
    zTxt = builtin_text(zName);
  }
  if( zTxt==0 ){
    cgi_set_status(404, "Not Found");
    @ File \"%h(zName)\" not found
    return;
  }
  if( sqlite3_strglob("*.js", zName)==0 ){
    cgi_set_content_type("application/javascript");







|



<
<
<
<
<





<
<
<
<
<
<
<
<
|
<







850
851
852
853
854
855
856
857
858
859
860





861
862
863
864
865








866

867
868
869
870
871
872
873

  /* Tell CGI that the content returned by this page is considered cacheable */
  g.isConst = 1;
}

/*
** WEBPAGE: builtin
** URL:  builtin/FILENAME
**
** Return the built-in text given by FILENAME.  This is used internally 
** by many Fossil web pages to load built-in javascript files.





*/
void page_builtin_text(void){
  Blob out;
  const char *zName = P("name");
  const char *zTxt = 0;








  if( zName ) zTxt = builtin_text(zName);

  if( zTxt==0 ){
    cgi_set_status(404, "Not Found");
    @ File \"%h(zName)\" not found
    return;
  }
  if( sqlite3_strglob("*.js", zName)==0 ){
    cgi_set_content_type("application/javascript");