Fossil

Check-in [487aa43f]
Login

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

Overview
Comment:Attempt to add a separate JS file and source it just prior to </body>
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | main.js
Files: files | file ages | folders
SHA3-256:487aa43f424222bd28e09cb7b8cdce4a1c088ae6ea577cb21ab51f7a4429226c
User & Date: drh 2017-12-04 21:08:22
Context
2017-12-05
01:05
Anti-robot defenses are now CSP-safe. check-in: 4f2c9841 user: drh tags: main.js
2017-12-04
21:08
Attempt to add a separate JS file and source it just prior to </body> check-in: 487aa43f user: drh tags: main.js
20:39
Add the "fossil sqlar" command. Like "fossil zip", except generates sqlar archives. check-in: 7eb5b0a2 user: dan tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Added src/main.js.



































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
/* This script is sourced just prior to the </body> in every Fossil webpage */
var pageDataObj = document.getElementById('page-data');
var links = new Array();
if( pageDataObj ){
  var pageData = JSON.parse(pageDataObj.textContent || pageDataObj.innerText);
  var r;
  for(r in pageData){
    switch(r.op){
      "setAllHrefs": {
        links = r.links;
        if(r.mouseMove){
          document.getElementsByTagName("body")[0].onmousemove=function(){
            setTimeout("setAllHrefs();",r.nDelay);
          }
        }else{
          setTimeout("setAllHrefs();",r.nDelay);
        }
        break;
      }
      "no-op": {
        alert('finished processing page-data');
        break;
      }
    }
  }
}
function setAllHrefs(){
  var x;
  for(x in links){
    var y = document.getElementById(x.id);
    if(y) y.href=x.href
  }
}

Changes to src/main.mk.

192
193
194
195
196
197
198

199
200
201
202
203
204
205
  $(SRCDIR)/../skins/rounded1/footer.txt \
  $(SRCDIR)/../skins/rounded1/header.txt \
  $(SRCDIR)/../skins/xekri/css.txt \
  $(SRCDIR)/../skins/xekri/details.txt \
  $(SRCDIR)/../skins/xekri/footer.txt \
  $(SRCDIR)/../skins/xekri/header.txt \
  $(SRCDIR)/diff.tcl \

  $(SRCDIR)/markdown.md \
  $(SRCDIR)/wiki.wiki

TRANS_SRC = \
  $(OBJDIR)/add_.c \
  $(OBJDIR)/allrepo_.c \
  $(OBJDIR)/attach_.c \







>







192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
  $(SRCDIR)/../skins/rounded1/footer.txt \
  $(SRCDIR)/../skins/rounded1/header.txt \
  $(SRCDIR)/../skins/xekri/css.txt \
  $(SRCDIR)/../skins/xekri/details.txt \
  $(SRCDIR)/../skins/xekri/footer.txt \
  $(SRCDIR)/../skins/xekri/header.txt \
  $(SRCDIR)/diff.tcl \
  $(SRCDIR)/main.js \
  $(SRCDIR)/markdown.md \
  $(SRCDIR)/wiki.wiki

TRANS_SRC = \
  $(OBJDIR)/add_.c \
  $(OBJDIR)/allrepo_.c \
  $(OBJDIR)/attach_.c \

Changes to src/makemake.tcl.

158
159
160
161
162
163
164

165
166
167
168
169
170
171

# Additional resource files that get built into the executable.
#
set extra_files {
  diff.tcl
  markdown.md
  wiki.wiki

  ../skins/*/*.txt
}

# Options used to compile the included SQLite library.
#
set SQLITE_OPTIONS {
  -DNDEBUG=1







>







158
159
160
161
162
163
164
165
166
167
168
169
170
171
172

# Additional resource files that get built into the executable.
#
set extra_files {
  diff.tcl
  markdown.md
  wiki.wiki
  main.js
  ../skins/*/*.txt
}

# Options used to compile the included SQLite library.
#
set SQLITE_OPTIONS {
  -DNDEBUG=1

Changes to src/style.c.

81
82
83
84
85
86
87





88
89
90
91
92
93
94
...
190
191
192
193
194
195
196













197
198
199
200
201
202
203
...
421
422
423
424
425
426
427


428
429
430
431
432
433
434
435
436
437
438
439
...
722
723
724
725
726
727
728






729

730
731
732
733
734
735
736
...
856
857
858
859
860
861
862













863
864
865
866
867
868
869
static int sideboxUsed = 0;

/*
** Ad-unit styles.
*/
static unsigned adUnitFlags = 0;







/*
** List of hyperlinks and forms that need to be resolved by javascript in
** the footer.
*/
char **aHref = 0;
int nHref = 0;
................................................................................
    int n;
    aFormAction = fossil_realloc(aFormAction, (nFormAction+1)*sizeof(char*));
    aFormAction[nFormAction++] = zLink;
    n = nFormAction;
    @ <form id="form%d(n)" method="POST" action='%R/login' %s(zOtherArgs)>
  }
}














/*
** Generate javascript that will set the href= attribute on all anchors.
*/
void style_resolve_href(void){
  int i;
  int nDelay = db_get_int("auto-hyperlink-delay",10);
................................................................................
** header template lacks a <body> tag, then all of the following is
** prepended.
*/
static char zDfltHeader[] = 
@ <html>
@ <head>
@ <base href="$baseurl/$current_page" />


@ <title>$<project_name>: $<title></title>
@ <link rel="alternate" type="application/rss+xml" title="RSS Feed"
@       href="$home/timeline.rss" />
@ <link rel="stylesheet" href="$stylesheet_url" type="text/css"
@       media="screen" />
@ </head>
@ <body>
;

/*
** Draw the header.
*/
................................................................................
    cgi_append_content("<span class=\"thTrace\"><hr />\n", -1);
    cgi_append_content(blob_str(&g.thLog), blob_size(&g.thLog));
    cgi_append_content("</span>\n", -1);
  }

  /* Add document end mark if it was not in the footer */
  if( sqlite3_strlike("%</body>%", zFooter, 0)!=0 ){






    @ </body></html>

  }
}

/*
** Begin a side-box on the right-hand side of a page.  The title and
** the width of the box are given as arguments.  The width is usually
** a percentage of total screen width.
................................................................................
  image_url_var("logo");
  image_url_var("background");
  Th_Render(blob_str(&css));

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














/*
** WEBPAGE: test_env
**
** Display CGI-variables and other aspects of the run-time
** environment, for debugging and trouble-shooting purposes.
*/







>
>
>
>
>







 







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







 







>
>

|
|
|
|







 







>
>
>
>
>
>
|
>







 







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







81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
...
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
...
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
...
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
...
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
static int sideboxUsed = 0;

/*
** Ad-unit styles.
*/
static unsigned adUnitFlags = 0;

/*
** Page data JSON
*/
static Blob pageDataJson = BLOB_INITIALIZER;


/*
** List of hyperlinks and forms that need to be resolved by javascript in
** the footer.
*/
char **aHref = 0;
int nHref = 0;
................................................................................
    int n;
    aFormAction = fossil_realloc(aFormAction, (nFormAction+1)*sizeof(char*));
    aFormAction[nFormAction++] = zLink;
    n = nFormAction;
    @ <form id="form%d(n)" method="POST" action='%R/login' %s(zOtherArgs)>
  }
}

/*
** Append page-data JSON
*/
void style_pagedata_appendf(const char *zFormat, ...){
  va_list ap;
  if( blob_size(&pageDataJson)==0 ){
    blob_append(&pageDataJson, "[", 1);
  }
  va_start(ap, zFormat);
  blob_vappendf(&pageDataJson, zFormat, ap);
  va_end(ap);
}

/*
** Generate javascript that will set the href= attribute on all anchors.
*/
void style_resolve_href(void){
  int i;
  int nDelay = db_get_int("auto-hyperlink-delay",10);
................................................................................
** header template lacks a <body> tag, then all of the following is
** prepended.
*/
static char zDfltHeader[] = 
@ <html>
@ <head>
@ <base href="$baseurl/$current_page" />
@ <meta http-equiv="Content-Security-Policy-xxx" \
@  content="default-src 'self' 'unsafe-inline'" />
@ <title>$<project_name>: $<title></title>
@ <link rel="alternate" type="application/rss+xml" title="RSS Feed" \
@  href="$home/timeline.rss" />
@ <link rel="stylesheet" href="$stylesheet_url" type="text/css" \
@  media="screen" />
@ </head>
@ <body>
;

/*
** Draw the header.
*/
................................................................................
    cgi_append_content("<span class=\"thTrace\"><hr />\n", -1);
    cgi_append_content(blob_str(&g.thLog), blob_size(&g.thLog));
    cgi_append_content("</span>\n", -1);
  }

  /* Add document end mark if it was not in the footer */
  if( sqlite3_strlike("%</body>%", zFooter, 0)!=0 ){
    style_pagedata_appendf("{'op':'no-op'}]");
    @ <script type='application/json' id='page-data'>
    @ %s(blob_str(&pageDataJson))
    @ </script>
    @ <script src='%s(g.zBaseURL)/main.js' type='application/javascript'>\
    @ <script>
    @ </body>
    @ </html>
  }
}

/*
** Begin a side-box on the right-hand side of a page.  The title and
** the width of the box are given as arguments.  The width is usually
** a percentage of total screen width.
................................................................................
  image_url_var("logo");
  image_url_var("background");
  Th_Render(blob_str(&css));

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

/*
** WEBPAGE: main.js
**
** Return the javascript
*/
void page_main_js(void){
  Blob mainjs;
  cgi_set_content_type("application/javascript");
  blob_init(&mainjs, builtin_text("main.js"), -1);
  cgi_set_content(&mainjs);
}


/*
** WEBPAGE: test_env
**
** Display CGI-variables and other aspects of the run-time
** environment, for debugging and trouble-shooting purposes.
*/

Changes to win/Makefile.mingw.

601
602
603
604
605
606
607

608
609
610
611
612
613
614
  $(SRCDIR)/../skins/rounded1/footer.txt \
  $(SRCDIR)/../skins/rounded1/header.txt \
  $(SRCDIR)/../skins/xekri/css.txt \
  $(SRCDIR)/../skins/xekri/details.txt \
  $(SRCDIR)/../skins/xekri/footer.txt \
  $(SRCDIR)/../skins/xekri/header.txt \
  $(SRCDIR)/diff.tcl \

  $(SRCDIR)/markdown.md \
  $(SRCDIR)/wiki.wiki

TRANS_SRC = \
  $(OBJDIR)/add_.c \
  $(OBJDIR)/allrepo_.c \
  $(OBJDIR)/attach_.c \







>







601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
  $(SRCDIR)/../skins/rounded1/footer.txt \
  $(SRCDIR)/../skins/rounded1/header.txt \
  $(SRCDIR)/../skins/xekri/css.txt \
  $(SRCDIR)/../skins/xekri/details.txt \
  $(SRCDIR)/../skins/xekri/footer.txt \
  $(SRCDIR)/../skins/xekri/header.txt \
  $(SRCDIR)/diff.tcl \
  $(SRCDIR)/main.js \
  $(SRCDIR)/markdown.md \
  $(SRCDIR)/wiki.wiki

TRANS_SRC = \
  $(OBJDIR)/add_.c \
  $(OBJDIR)/allrepo_.c \
  $(OBJDIR)/attach_.c \

Changes to win/Makefile.msc.

527
528
529
530
531
532
533

534
535
536
537
538
539
540
        $(SRCDIR)\../skins/rounded1/footer.txt \
        $(SRCDIR)\../skins/rounded1/header.txt \
        $(SRCDIR)\../skins/xekri/css.txt \
        $(SRCDIR)\../skins/xekri/details.txt \
        $(SRCDIR)\../skins/xekri/footer.txt \
        $(SRCDIR)\../skins/xekri/header.txt \
        $(SRCDIR)\diff.tcl \

        $(SRCDIR)\markdown.md \
        $(SRCDIR)\wiki.wiki

OBJ   = $(OX)\add$O \
        $(OX)\allrepo$O \
        $(OX)\attach$O \
        $(OX)\bag$O \







>







527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
        $(SRCDIR)\../skins/rounded1/footer.txt \
        $(SRCDIR)\../skins/rounded1/header.txt \
        $(SRCDIR)\../skins/xekri/css.txt \
        $(SRCDIR)\../skins/xekri/details.txt \
        $(SRCDIR)\../skins/xekri/footer.txt \
        $(SRCDIR)\../skins/xekri/header.txt \
        $(SRCDIR)\diff.tcl \
        $(SRCDIR)\main.js \
        $(SRCDIR)\markdown.md \
        $(SRCDIR)\wiki.wiki

OBJ   = $(OX)\add$O \
        $(OX)\allrepo$O \
        $(OX)\attach$O \
        $(OX)\bag$O \