Index: src/codecheck1.c ================================================================== --- src/codecheck1.c +++ src/codecheck1.c @@ -312,10 +312,11 @@ { "admin_log", 1, 0 }, { "blob_append_sql", 2, FMT_NO_S }, { "blob_appendf", 2, 0 }, { "cgi_panic", 1, 0 }, { "cgi_redirectf", 1, 0 }, + { "chref", 2, 0 }, { "db_blob", 2, FMT_NO_S }, { "db_double", 2, FMT_NO_S }, { "db_err", 1, 0 }, { "db_exists", 1, FMT_NO_S }, { "db_int", 2, FMT_NO_S }, Index: src/info.c ================================================================== --- src/info.c +++ src/info.c @@ -798,38 +798,38 @@ zPageHide = "vinfo"; } diffFlags = construct_diff_flags(verboseFlag, sideBySide); zW = (diffFlags&DIFF_IGNORE_ALLWS)?"&w":""; if( verboseFlag ){ - @ %z(xhref("class='button'","%R/%s/%T",zPageHide,zName)) + @ %z(chref("button","%R/%s/%T",zPageHide,zName)) @ Hide Diffs if( sideBySide ){ - @ %z(xhref("class='button'","%R/%s/%T?sbs=0%s",zPage,zName,zW)) + @ %z(chref("button","%R/%s/%T?sbs=0%s",zPage,zName,zW)) @ Unified Diffs }else{ - @ %z(xhref("class='button'","%R/%s/%T?sbs=1%s",zPage,zName,zW)) + @ %z(chref("button","%R/%s/%T?sbs=1%s",zPage,zName,zW)) @ Side-by-Side Diffs } if( *zW ){ - @ %z(xhref("class='button'","%R/%s/%T?sbs=%d",zPage,zName,sideBySide)) + @ %z(chref("button","%R/%s/%T?sbs=%d",zPage,zName,sideBySide)) @ Show Whitespace Changes }else{ - @ %z(xhref("class='button'","%R/%s/%T?sbs=%d&w",zPage,zName,sideBySide)) + @ %z(chref("button","%R/%s/%T?sbs=%d&w",zPage,zName,sideBySide)) @ Ignore Whitespace } }else{ - @ %z(xhref("class='button'","%R/%s/%T?sbs=0",zPage,zName)) + @ %z(chref("button","%R/%s/%T?sbs=0",zPage,zName)) @ Show Unified Diffs - @ %z(xhref("class='button'","%R/%s/%T?sbs=1",zPage,zName)) + @ %z(chref("button","%R/%s/%T?sbs=1",zPage,zName)) @ Show Side-by-Side Diffs } if( zParent ){ - @ %z(xhref("class='button'","%R/vpatch?from=%!S&to=%!S",zParent,zUuid)) + @ %z(chref("button","%R/vpatch?from=%!S&to=%!S",zParent,zUuid)) @ Patch } if( g.perm.Admin ){ - @ %z(xhref("class='button'","%R/mlink?ci=%!S",zUuid))MLink Table + @ %z(chref("button","%R/mlink?ci=%!S",zUuid))MLink Table } @ if( pRe ){ @

Only differences that match regular expression "%h(zRe)" @ are shown.

ADDED src/main.js Index: src/main.js ================================================================== --- src/main.js +++ src/main.js @@ -0,0 +1,36 @@ +/* This script is sourced just prior to the in every Fossil webpage */ +var x = document.getElementById("page-data"); +var jx = x.textContent || x.innerText; +var g = JSON.parse(jx); + +/* As an anti-robot defense, elements are initially coded with the +** href= set to the honeypot, and
elements are initialized with +** action= set to the login page. The real values for href= and action= +** are held in data-href= and data-action=. The following code moves +** data-href= into href= and data-action= into action= for all +** and elements, after delay and maybe also after mouse +** movement is seen. +*/ +function setAllHrefs(){ + var anchors = document.getElementsByTagName("a"); + for(var i=0; i ** or @@ -126,12 +116,15 @@ ** ** Note %z format. The string returned by this function is always ** obtained from fossil_malloc() so rendering it with %z will reclaim ** that memory space. ** -** There are two versions of this routine: href() does a plain hyperlink -** and xhref() adds extra attribute text. +** There are three versions of this routine: +** +** (1) href() does a plain hyperlink +** (2) xhref() adds extra attribute text +** (3) chref() adds a class name ** ** g.perm.Hyperlink is true if the user has the Hyperlink (h) property. ** Most logged in users should have this property, since we can assume ** that a logged in user is not a bot. Only "nobody" lacks g.perm.Hyperlink, ** typically. @@ -145,16 +138,26 @@ if( g.perm.Hyperlink && !g.javascriptHyperlink ){ char *zHUrl = mprintf("", zExtra, zUrl); fossil_free(zUrl); return zHUrl; } - if( nHref>=nHrefAlloc ){ - nHrefAlloc = nHrefAlloc*2 + 10; - aHref = fossil_realloc(aHref, nHrefAlloc*sizeof(aHref[0])); + return mprintf("", + zExtra, zUrl); +} +char *chref(const char *zExtra, const char *zFormat, ...){ + char *zUrl; + va_list ap; + va_start(ap, zFormat); + zUrl = vmprintf(zFormat, ap); + va_end(ap); + if( g.perm.Hyperlink && !g.javascriptHyperlink ){ + char *zHUrl = mprintf("", zExtra, zUrl); + fossil_free(zUrl); + return zHUrl; } - aHref[nHref++] = zUrl; - return mprintf("", zExtra, nHref); + return mprintf("", + zExtra, zUrl); } char *href(const char *zFormat, ...){ char *zUrl; va_list ap; va_start(ap, zFormat); @@ -163,16 +166,12 @@ if( g.perm.Hyperlink && !g.javascriptHyperlink ){ char *zHUrl = mprintf("", zUrl); fossil_free(zUrl); return zHUrl; } - if( nHref>=nHrefAlloc ){ - nHrefAlloc = nHrefAlloc*2 + 10; - aHref = fossil_realloc(aHref, nHrefAlloc*sizeof(aHref[0])); - } - aHref[nHref++] = zUrl; - return mprintf("", nHref); + return mprintf("", + zUrl); } /* ** Generate . The ARG value is inserted ** by javascript. @@ -185,59 +184,13 @@ zLink = vmprintf(zAction, ap); va_end(ap); if( g.perm.Hyperlink && !g.javascriptHyperlink ){ @ }else{ - int n; - aFormAction = fossil_realloc(aFormAction, (nFormAction+1)*sizeof(char*)); - aFormAction[nFormAction++] = zLink; - n = nFormAction; - @ - } -} - -/* -** 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); - if( !g.perm.Hyperlink ) return; - if( nHref==0 && nFormAction==0 ) return; - @ + @ + } } /* ** Add a new element to the submenu */ @@ -423,15 +376,17 @@ */ static char zDfltHeader[] = @ @ @ +@ @ $<project_name>: $<title> -@ -@ +@ +@ @ @ ; /* @@ -556,10 +511,11 @@ */ void style_footer(void){ const char *zFooter; const char *zAd = 0; unsigned int mAdFlags = 0; + int bMouseover = 0; /* Active hyperlinks after mouseover */ if( !headerHasBeenGenerated ) return; /* Go back and put the submenu at the top of the page. We delay the ** creation of the submenu until the end so that we can add elements @@ -706,15 +662,38 @@ */ @
} @ +#if 0 /* Set the href= field on hyperlinks. Do this before the footer since ** the footer will be generating */ style_resolve_href(); +#endif + + /* Load up the page data */ + @ + zFooter = skin_get("footer"); + if( sqlite3_strlike("%%", zFooter, 0)==0 ){ + @ + @ + @ } } /* ** Begin a side-box on the right-hand side of a page. The title and @@ -858,10 +840,23 @@ 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 Index: src/tag.c ================================================================== --- src/tag.c +++ src/tag.c @@ -669,11 +669,11 @@ ); @