Fossil SCM

Enhance the Ad-Unit processing to allow a choice of two different ad-units. A tall skinny ad-unit can be placed at the right (or left) margin on some pages in place of the banner ad-unit beneath the menu bars. Ad-Units are now configurable using CSS. <b>Note:</b> Legacy ad-unit configurations might need to adjust their CSS.

drh 2015-01-21 21:33 trunk merge
Commit ff78d6d5ef2043d6b209fd8015dbdc14492429db
--- src/branch.c
+++ src/branch.c
@@ -341,10 +341,11 @@
341341
Stmt q;
342342
double rNow;
343343
login_check_credentials();
344344
if( !g.perm.Read ){ login_needed(); return; }
345345
style_header("Branches");
346
+ style_adunit_config(ADUNIT_RIGHT_OK);
346347
login_anonymous_available();
347348
348349
db_prepare(&q, brlistQuery/*works-like:""*/);
349350
rNow = db_double(0.0, "SELECT julianday('now')");
350351
@ <div class="brlist"><table id="branchlisttable">
351352
--- src/branch.c
+++ src/branch.c
@@ -341,10 +341,11 @@
341 Stmt q;
342 double rNow;
343 login_check_credentials();
344 if( !g.perm.Read ){ login_needed(); return; }
345 style_header("Branches");
 
346 login_anonymous_available();
347
348 db_prepare(&q, brlistQuery/*works-like:""*/);
349 rNow = db_double(0.0, "SELECT julianday('now')");
350 @ <div class="brlist"><table id="branchlisttable">
351
--- src/branch.c
+++ src/branch.c
@@ -341,10 +341,11 @@
341 Stmt q;
342 double rNow;
343 login_check_credentials();
344 if( !g.perm.Read ){ login_needed(); return; }
345 style_header("Branches");
346 style_adunit_config(ADUNIT_RIGHT_OK);
347 login_anonymous_available();
348
349 db_prepare(&q, brlistQuery/*works-like:""*/);
350 rNow = db_double(0.0, "SELECT julianday('now')");
351 @ <div class="brlist"><table id="branchlisttable">
352
--- src/browse.c
+++ src/browse.c
@@ -133,10 +133,11 @@
133133
if( strcmp(PD("type",""),"tree")==0 ){ page_tree(); return; }
134134
login_check_credentials();
135135
if( !g.perm.Read ){ login_needed(); return; }
136136
while( nD>1 && zD[nD-2]=='/' ){ zD[(--nD)-1] = 0; }
137137
style_header("File List");
138
+ style_adunit_config(ADUNIT_RIGHT_OK);
138139
sqlite3_create_function(g.db, "pathelement", 2, SQLITE_UTF8, 0,
139140
pathelementFunc, 0, 0);
140141
url_initialize(&sURI, "dir");
141142
142143
/* If the name= parameter is an empty string, make it a NULL pointer */
@@ -555,10 +556,11 @@
555556
style_header("Folder Hierarchy");
556557
}else{
557558
showDirOnly = 0;
558559
style_header("File Tree");
559560
}
561
+ style_adunit_config(ADUNIT_RIGHT_OK);
560562
if( P("expand")!=0 ){
561563
startExpanded = 1;
562564
url_add_parameter(&sURI, "expand", "1");
563565
}else{
564566
startExpanded = 0;
565567
--- src/browse.c
+++ src/browse.c
@@ -133,10 +133,11 @@
133 if( strcmp(PD("type",""),"tree")==0 ){ page_tree(); return; }
134 login_check_credentials();
135 if( !g.perm.Read ){ login_needed(); return; }
136 while( nD>1 && zD[nD-2]=='/' ){ zD[(--nD)-1] = 0; }
137 style_header("File List");
 
138 sqlite3_create_function(g.db, "pathelement", 2, SQLITE_UTF8, 0,
139 pathelementFunc, 0, 0);
140 url_initialize(&sURI, "dir");
141
142 /* If the name= parameter is an empty string, make it a NULL pointer */
@@ -555,10 +556,11 @@
555 style_header("Folder Hierarchy");
556 }else{
557 showDirOnly = 0;
558 style_header("File Tree");
559 }
 
560 if( P("expand")!=0 ){
561 startExpanded = 1;
562 url_add_parameter(&sURI, "expand", "1");
563 }else{
564 startExpanded = 0;
565
--- src/browse.c
+++ src/browse.c
@@ -133,10 +133,11 @@
133 if( strcmp(PD("type",""),"tree")==0 ){ page_tree(); return; }
134 login_check_credentials();
135 if( !g.perm.Read ){ login_needed(); return; }
136 while( nD>1 && zD[nD-2]=='/' ){ zD[(--nD)-1] = 0; }
137 style_header("File List");
138 style_adunit_config(ADUNIT_RIGHT_OK);
139 sqlite3_create_function(g.db, "pathelement", 2, SQLITE_UTF8, 0,
140 pathelementFunc, 0, 0);
141 url_initialize(&sURI, "dir");
142
143 /* If the name= parameter is an empty string, make it a NULL pointer */
@@ -555,10 +556,11 @@
556 style_header("Folder Hierarchy");
557 }else{
558 showDirOnly = 0;
559 style_header("File Tree");
560 }
561 style_adunit_config(ADUNIT_RIGHT_OK);
562 if( P("expand")!=0 ){
563 startExpanded = 1;
564 url_add_parameter(&sURI, "expand", "1");
565 }else{
566 startExpanded = 0;
567
--- src/browse.c
+++ src/browse.c
@@ -133,10 +133,11 @@
133133
if( strcmp(PD("type",""),"tree")==0 ){ page_tree(); return; }
134134
login_check_credentials();
135135
if( !g.perm.Read ){ login_needed(); return; }
136136
while( nD>1 && zD[nD-2]=='/' ){ zD[(--nD)-1] = 0; }
137137
style_header("File List");
138
+ style_adunit_config(ADUNIT_RIGHT_OK);
138139
sqlite3_create_function(g.db, "pathelement", 2, SQLITE_UTF8, 0,
139140
pathelementFunc, 0, 0);
140141
url_initialize(&sURI, "dir");
141142
142143
/* If the name= parameter is an empty string, make it a NULL pointer */
@@ -555,10 +556,11 @@
555556
style_header("Folder Hierarchy");
556557
}else{
557558
showDirOnly = 0;
558559
style_header("File Tree");
559560
}
561
+ style_adunit_config(ADUNIT_RIGHT_OK);
560562
if( P("expand")!=0 ){
561563
startExpanded = 1;
562564
url_add_parameter(&sURI, "expand", "1");
563565
}else{
564566
startExpanded = 0;
565567
--- src/browse.c
+++ src/browse.c
@@ -133,10 +133,11 @@
133 if( strcmp(PD("type",""),"tree")==0 ){ page_tree(); return; }
134 login_check_credentials();
135 if( !g.perm.Read ){ login_needed(); return; }
136 while( nD>1 && zD[nD-2]=='/' ){ zD[(--nD)-1] = 0; }
137 style_header("File List");
 
138 sqlite3_create_function(g.db, "pathelement", 2, SQLITE_UTF8, 0,
139 pathelementFunc, 0, 0);
140 url_initialize(&sURI, "dir");
141
142 /* If the name= parameter is an empty string, make it a NULL pointer */
@@ -555,10 +556,11 @@
555 style_header("Folder Hierarchy");
556 }else{
557 showDirOnly = 0;
558 style_header("File Tree");
559 }
 
560 if( P("expand")!=0 ){
561 startExpanded = 1;
562 url_add_parameter(&sURI, "expand", "1");
563 }else{
564 startExpanded = 0;
565
--- src/browse.c
+++ src/browse.c
@@ -133,10 +133,11 @@
133 if( strcmp(PD("type",""),"tree")==0 ){ page_tree(); return; }
134 login_check_credentials();
135 if( !g.perm.Read ){ login_needed(); return; }
136 while( nD>1 && zD[nD-2]=='/' ){ zD[(--nD)-1] = 0; }
137 style_header("File List");
138 style_adunit_config(ADUNIT_RIGHT_OK);
139 sqlite3_create_function(g.db, "pathelement", 2, SQLITE_UTF8, 0,
140 pathelementFunc, 0, 0);
141 url_initialize(&sURI, "dir");
142
143 /* If the name= parameter is an empty string, make it a NULL pointer */
@@ -555,10 +556,11 @@
556 style_header("Folder Hierarchy");
557 }else{
558 showDirOnly = 0;
559 style_header("File Tree");
560 }
561 style_adunit_config(ADUNIT_RIGHT_OK);
562 if( P("expand")!=0 ){
563 startExpanded = 1;
564 url_add_parameter(&sURI, "expand", "1");
565 }else{
566 startExpanded = 0;
567
+3
--- src/cgi.c
+++ src/cgi.c
@@ -108,10 +108,13 @@
108108
** if it does and false if it does not.
109109
*/
110110
int cgi_header_contains(const char *zNeedle){
111111
return strstr(blob_str(&cgiContent[0]), zNeedle)!=0;
112112
}
113
+int cgi_body_contains(const char *zNeedle){
114
+ return strstr(blob_str(&cgiContent[1]), zNeedle)!=0;
115
+}
113116
114117
/*
115118
** Append reply content to what already exists.
116119
*/
117120
void cgi_append_content(const char *zData, int nAmt){
118121
--- src/cgi.c
+++ src/cgi.c
@@ -108,10 +108,13 @@
108 ** if it does and false if it does not.
109 */
110 int cgi_header_contains(const char *zNeedle){
111 return strstr(blob_str(&cgiContent[0]), zNeedle)!=0;
112 }
 
 
 
113
114 /*
115 ** Append reply content to what already exists.
116 */
117 void cgi_append_content(const char *zData, int nAmt){
118
--- src/cgi.c
+++ src/cgi.c
@@ -108,10 +108,13 @@
108 ** if it does and false if it does not.
109 */
110 int cgi_header_contains(const char *zNeedle){
111 return strstr(blob_str(&cgiContent[0]), zNeedle)!=0;
112 }
113 int cgi_body_contains(const char *zNeedle){
114 return strstr(blob_str(&cgiContent[1]), zNeedle)!=0;
115 }
116
117 /*
118 ** Append reply content to what already exists.
119 */
120 void cgi_append_content(const char *zData, int nAmt){
121
+1
--- src/doc.c
+++ src/doc.c
@@ -500,10 +500,11 @@
500500
" FROM blob WHERE rid=%d", vid));
501501
Th_Store("doc_date", db_text(0, "SELECT datetime(mtime) FROM event"
502502
" WHERE objid=%d AND type='ci'", vid));
503503
if( fossil_strcmp(zMime, "text/x-fossil-wiki")==0 ){
504504
Blob title, tail;
505
+ style_adunit_config(ADUNIT_RIGHT_OK);
505506
if( wiki_find_title(&filebody, &title, &tail) ){
506507
style_header("%s", blob_str(&title));
507508
wiki_convert(&tail, 0, WIKI_BUTTONS);
508509
}else{
509510
style_header("Documentation");
510511
--- src/doc.c
+++ src/doc.c
@@ -500,10 +500,11 @@
500 " FROM blob WHERE rid=%d", vid));
501 Th_Store("doc_date", db_text(0, "SELECT datetime(mtime) FROM event"
502 " WHERE objid=%d AND type='ci'", vid));
503 if( fossil_strcmp(zMime, "text/x-fossil-wiki")==0 ){
504 Blob title, tail;
 
505 if( wiki_find_title(&filebody, &title, &tail) ){
506 style_header("%s", blob_str(&title));
507 wiki_convert(&tail, 0, WIKI_BUTTONS);
508 }else{
509 style_header("Documentation");
510
--- src/doc.c
+++ src/doc.c
@@ -500,10 +500,11 @@
500 " FROM blob WHERE rid=%d", vid));
501 Th_Store("doc_date", db_text(0, "SELECT datetime(mtime) FROM event"
502 " WHERE objid=%d AND type='ci'", vid));
503 if( fossil_strcmp(zMime, "text/x-fossil-wiki")==0 ){
504 Blob title, tail;
505 style_adunit_config(ADUNIT_RIGHT_OK);
506 if( wiki_find_title(&filebody, &title, &tail) ){
507 style_header("%s", blob_str(&title));
508 wiki_convert(&tail, 0, WIKI_BUTTONS);
509 }else{
510 style_header("Documentation");
511
--- src/login.c
+++ src/login.c
@@ -575,10 +575,11 @@
575575
login_set_user_cookie(zUsername, uid, NULL);
576576
redirect_to_g();
577577
}
578578
}
579579
style_header("Login/Logout");
580
+ style_adunit_config(ADUNIT_OFF);
580581
@ %s(zErrMsg)
581582
if( zGoto && P("anon")==0 ){
582583
@ <p>A login is required for <a href="%h(zGoto)">%h(zGoto)</a>.</p>
583584
}
584585
form_begin(0, "%R/login");
585586
--- src/login.c
+++ src/login.c
@@ -575,10 +575,11 @@
575 login_set_user_cookie(zUsername, uid, NULL);
576 redirect_to_g();
577 }
578 }
579 style_header("Login/Logout");
 
580 @ %s(zErrMsg)
581 if( zGoto && P("anon")==0 ){
582 @ <p>A login is required for <a href="%h(zGoto)">%h(zGoto)</a>.</p>
583 }
584 form_begin(0, "%R/login");
585
--- src/login.c
+++ src/login.c
@@ -575,10 +575,11 @@
575 login_set_user_cookie(zUsername, uid, NULL);
576 redirect_to_g();
577 }
578 }
579 style_header("Login/Logout");
580 style_adunit_config(ADUNIT_OFF);
581 @ %s(zErrMsg)
582 if( zGoto && P("anon")==0 ){
583 @ <p>A login is required for <a href="%h(zGoto)">%h(zGoto)</a>.</p>
584 }
585 form_begin(0, "%R/login");
586
+36 -3
--- src/setup.c
+++ src/setup.c
@@ -1715,13 +1715,15 @@
17151715
}
17161716
17171717
style_header("Edit Ad Unit");
17181718
@ <form action="%s(g.zTop)/setup_adunit" method="post"><div>
17191719
login_insert_csrf_secret();
1720
- @ <p>Edit HTML text for an ad unit that will be inserted after the
1721
- @ menu bar and above the content of every page.</p>
1722
- textarea_attribute("", 20, 80, "adunit", "adunit", "", 0);
1720
+ @ <b>Banner Ad-Unit:</b><br />
1721
+ textarea_attribute("", 6, 80, "adunit", "adunit", "", 0);
1722
+ @ <br />
1723
+ @ <b>Right-Column Ad-Unit:</b><br />
1724
+ textarea_attribute("", 6, 80, "adunit-right", "adright", "", 0);
17231725
@ <br />
17241726
onoff_attribute("Omit ads to administrator",
17251727
"adunit-omit-if-admin", "oia", 0, 0);
17261728
@ <br />
17271729
onoff_attribute("Omit ads to logged-in users",
@@ -1728,10 +1730,41 @@
17281730
"adunit-omit-if-user", "oiu", 0, 0);
17291731
@ <br />
17301732
@ <input type="submit" name="submit" value="Apply Changes" />
17311733
@ <input type="submit" name="clear" value="Delete Ad-Unit" />
17321734
@ </div></form>
1735
+ @ <hr />
1736
+ @ <b>Ad-Unit Notes:</b><ul>
1737
+ @ <li>Leave both Ad-Units blank to disable all advertising.
1738
+ @ <li>The "Banner Ad-Unit" is used for wide pages.
1739
+ @ <li>The "Right-Column Ad-Unit" is used on pages with tall, narrow content.
1740
+ @ <li>If the "Right-Column Ad-Unit" is blank, the "Banner Ad-Unit" is used on all pages.
1741
+ @ <li>Suggested <a href="setup_editcss">CSS</a> changes:
1742
+ @ <blockquote><pre>
1743
+ @ div.adunit_banner {
1744
+ @ margin: auto;
1745
+ @ width: 100%;
1746
+ @ }
1747
+ @ div.adunit_right {
1748
+ @ float: right;
1749
+ @ }
1750
+ @ div.adunit_right_container {
1751
+ @ min-height: <i>height-of-right-column-ad-unit</i>;
1752
+ @ }
1753
+ @ </pre></blockquote>
1754
+ @ <li>For a place-holder Ad-Unit for testing, Copy/Paste the following
1755
+ @ with appropriate adjustments to "width:" and "height:".
1756
+ @ <blockquote><pre>
1757
+ @ &lt;div style='
1758
+ @ margin: 0 auto;
1759
+ @ width: 600px;
1760
+ @ height: 90px;
1761
+ @ border: 1px solid #f11;
1762
+ @ background-color: #fcc;
1763
+ @ '&gt;Demo Ad&lt;/div&gt;
1764
+ @ </pre></blockquote>
1765
+ @ </li>
17331766
style_footer();
17341767
db_end_transaction(0);
17351768
}
17361769
17371770
/*
17381771
--- src/setup.c
+++ src/setup.c
@@ -1715,13 +1715,15 @@
1715 }
1716
1717 style_header("Edit Ad Unit");
1718 @ <form action="%s(g.zTop)/setup_adunit" method="post"><div>
1719 login_insert_csrf_secret();
1720 @ <p>Edit HTML text for an ad unit that will be inserted after the
1721 @ menu bar and above the content of every page.</p>
1722 textarea_attribute("", 20, 80, "adunit", "adunit", "", 0);
 
 
1723 @ <br />
1724 onoff_attribute("Omit ads to administrator",
1725 "adunit-omit-if-admin", "oia", 0, 0);
1726 @ <br />
1727 onoff_attribute("Omit ads to logged-in users",
@@ -1728,10 +1730,41 @@
1728 "adunit-omit-if-user", "oiu", 0, 0);
1729 @ <br />
1730 @ <input type="submit" name="submit" value="Apply Changes" />
1731 @ <input type="submit" name="clear" value="Delete Ad-Unit" />
1732 @ </div></form>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1733 style_footer();
1734 db_end_transaction(0);
1735 }
1736
1737 /*
1738
--- src/setup.c
+++ src/setup.c
@@ -1715,13 +1715,15 @@
1715 }
1716
1717 style_header("Edit Ad Unit");
1718 @ <form action="%s(g.zTop)/setup_adunit" method="post"><div>
1719 login_insert_csrf_secret();
1720 @ <b>Banner Ad-Unit:</b><br />
1721 textarea_attribute("", 6, 80, "adunit", "adunit", "", 0);
1722 @ <br />
1723 @ <b>Right-Column Ad-Unit:</b><br />
1724 textarea_attribute("", 6, 80, "adunit-right", "adright", "", 0);
1725 @ <br />
1726 onoff_attribute("Omit ads to administrator",
1727 "adunit-omit-if-admin", "oia", 0, 0);
1728 @ <br />
1729 onoff_attribute("Omit ads to logged-in users",
@@ -1728,10 +1730,41 @@
1730 "adunit-omit-if-user", "oiu", 0, 0);
1731 @ <br />
1732 @ <input type="submit" name="submit" value="Apply Changes" />
1733 @ <input type="submit" name="clear" value="Delete Ad-Unit" />
1734 @ </div></form>
1735 @ <hr />
1736 @ <b>Ad-Unit Notes:</b><ul>
1737 @ <li>Leave both Ad-Units blank to disable all advertising.
1738 @ <li>The "Banner Ad-Unit" is used for wide pages.
1739 @ <li>The "Right-Column Ad-Unit" is used on pages with tall, narrow content.
1740 @ <li>If the "Right-Column Ad-Unit" is blank, the "Banner Ad-Unit" is used on all pages.
1741 @ <li>Suggested <a href="setup_editcss">CSS</a> changes:
1742 @ <blockquote><pre>
1743 @ div.adunit_banner {
1744 @ margin: auto;
1745 @ width: 100%;
1746 @ }
1747 @ div.adunit_right {
1748 @ float: right;
1749 @ }
1750 @ div.adunit_right_container {
1751 @ min-height: <i>height-of-right-column-ad-unit</i>;
1752 @ }
1753 @ </pre></blockquote>
1754 @ <li>For a place-holder Ad-Unit for testing, Copy/Paste the following
1755 @ with appropriate adjustments to "width:" and "height:".
1756 @ <blockquote><pre>
1757 @ &lt;div style='
1758 @ margin: 0 auto;
1759 @ width: 600px;
1760 @ height: 90px;
1761 @ border: 1px solid #f11;
1762 @ background-color: #fcc;
1763 @ '&gt;Demo Ad&lt;/div&gt;
1764 @ </pre></blockquote>
1765 @ </li>
1766 style_footer();
1767 db_end_transaction(0);
1768 }
1769
1770 /*
1771
--- src/sitemap.c
+++ src/sitemap.c
@@ -27,10 +27,11 @@
2727
** Show an incomplete list of web pages offered by the Fossil web engine.
2828
*/
2929
void sitemap_page(void){
3030
login_check_credentials();
3131
style_header("Site Map");
32
+ style_adunit_config(ADUNIT_RIGHT_OK);
3233
@ <p>
3334
@ The following links are just a few of the many web-pages available for
3435
@ this Fossil repository:
3536
@ </p>
3637
@
3738
--- src/sitemap.c
+++ src/sitemap.c
@@ -27,10 +27,11 @@
27 ** Show an incomplete list of web pages offered by the Fossil web engine.
28 */
29 void sitemap_page(void){
30 login_check_credentials();
31 style_header("Site Map");
 
32 @ <p>
33 @ The following links are just a few of the many web-pages available for
34 @ this Fossil repository:
35 @ </p>
36 @
37
--- src/sitemap.c
+++ src/sitemap.c
@@ -27,10 +27,11 @@
27 ** Show an incomplete list of web pages offered by the Fossil web engine.
28 */
29 void sitemap_page(void){
30 login_check_credentials();
31 style_header("Site Map");
32 style_adunit_config(ADUNIT_RIGHT_OK);
33 @ <p>
34 @ The following links are just a few of the many web-pages available for
35 @ this Fossil repository:
36 @ </p>
37 @
38
+3
--- src/stat.c
+++ src/stat.c
@@ -55,10 +55,11 @@
5555
5656
login_check_credentials();
5757
if( !g.perm.Read ){ login_needed(); return; }
5858
brief = P("brief")!=0;
5959
style_header("Repository Statistics");
60
+ style_adunit_config(ADUNIT_RIGHT_OK);
6061
if( g.perm.Admin ){
6162
style_submenu_element("URLs", "URLs and Checkouts", "urllist");
6263
style_submenu_element("Schema", "Repository Schema", "repo_schema");
6364
style_submenu_element("Web-Cache", "Web-Cache Stats", "cachestat");
6465
}
@@ -290,10 +291,11 @@
290291
int cnt;
291292
login_check_credentials();
292293
if( !g.perm.Admin ){ login_needed(); return; }
293294
294295
style_header("URLs and Checkouts");
296
+ style_adunit_config(ADUNIT_RIGHT_OK);
295297
style_submenu_element("Stat", "Repository Stats", "stat");
296298
style_submenu_element("Schema", "Repository Schema", "repo_schema");
297299
@ <div class="section">URLs</div>
298300
@ <table border="0" width='100%%'>
299301
db_prepare(&q, "SELECT substr(name,9), datetime(mtime,'unixepoch')"
@@ -336,10 +338,11 @@
336338
Stmt q;
337339
login_check_credentials();
338340
if( !g.perm.Admin ){ login_needed(); return; }
339341
340342
style_header("Repository Schema");
343
+ style_adunit_config(ADUNIT_RIGHT_OK);
341344
style_submenu_element("Stat", "Repository Stats", "stat");
342345
style_submenu_element("URLs", "URLs and Checkouts", "urllist");
343346
db_prepare(&q, "SELECT sql FROM %s.sqlite_master WHERE sql IS NOT NULL",
344347
db_name("repository"));
345348
@ <pre>
346349
--- src/stat.c
+++ src/stat.c
@@ -55,10 +55,11 @@
55
56 login_check_credentials();
57 if( !g.perm.Read ){ login_needed(); return; }
58 brief = P("brief")!=0;
59 style_header("Repository Statistics");
 
60 if( g.perm.Admin ){
61 style_submenu_element("URLs", "URLs and Checkouts", "urllist");
62 style_submenu_element("Schema", "Repository Schema", "repo_schema");
63 style_submenu_element("Web-Cache", "Web-Cache Stats", "cachestat");
64 }
@@ -290,10 +291,11 @@
290 int cnt;
291 login_check_credentials();
292 if( !g.perm.Admin ){ login_needed(); return; }
293
294 style_header("URLs and Checkouts");
 
295 style_submenu_element("Stat", "Repository Stats", "stat");
296 style_submenu_element("Schema", "Repository Schema", "repo_schema");
297 @ <div class="section">URLs</div>
298 @ <table border="0" width='100%%'>
299 db_prepare(&q, "SELECT substr(name,9), datetime(mtime,'unixepoch')"
@@ -336,10 +338,11 @@
336 Stmt q;
337 login_check_credentials();
338 if( !g.perm.Admin ){ login_needed(); return; }
339
340 style_header("Repository Schema");
 
341 style_submenu_element("Stat", "Repository Stats", "stat");
342 style_submenu_element("URLs", "URLs and Checkouts", "urllist");
343 db_prepare(&q, "SELECT sql FROM %s.sqlite_master WHERE sql IS NOT NULL",
344 db_name("repository"));
345 @ <pre>
346
--- src/stat.c
+++ src/stat.c
@@ -55,10 +55,11 @@
55
56 login_check_credentials();
57 if( !g.perm.Read ){ login_needed(); return; }
58 brief = P("brief")!=0;
59 style_header("Repository Statistics");
60 style_adunit_config(ADUNIT_RIGHT_OK);
61 if( g.perm.Admin ){
62 style_submenu_element("URLs", "URLs and Checkouts", "urllist");
63 style_submenu_element("Schema", "Repository Schema", "repo_schema");
64 style_submenu_element("Web-Cache", "Web-Cache Stats", "cachestat");
65 }
@@ -290,10 +291,11 @@
291 int cnt;
292 login_check_credentials();
293 if( !g.perm.Admin ){ login_needed(); return; }
294
295 style_header("URLs and Checkouts");
296 style_adunit_config(ADUNIT_RIGHT_OK);
297 style_submenu_element("Stat", "Repository Stats", "stat");
298 style_submenu_element("Schema", "Repository Schema", "repo_schema");
299 @ <div class="section">URLs</div>
300 @ <table border="0" width='100%%'>
301 db_prepare(&q, "SELECT substr(name,9), datetime(mtime,'unixepoch')"
@@ -336,10 +338,11 @@
338 Stmt q;
339 login_check_credentials();
340 if( !g.perm.Admin ){ login_needed(); return; }
341
342 style_header("Repository Schema");
343 style_adunit_config(ADUNIT_RIGHT_OK);
344 style_submenu_element("Stat", "Repository Stats", "stat");
345 style_submenu_element("URLs", "URLs and Checkouts", "urllist");
346 db_prepare(&q, "SELECT sql FROM %s.sqlite_master WHERE sql IS NOT NULL",
347 db_name("repository"));
348 @ <pre>
349
+57 -9
--- src/style.c
+++ src/style.c
@@ -46,10 +46,15 @@
4646
/*
4747
** remember, if a sidebox was used
4848
*/
4949
static int sideboxUsed = 0;
5050
51
+/*
52
+** Ad-unit styles.
53
+*/
54
+static unsigned adUnitFlags = 0;
55
+
5156
5257
/*
5358
** List of hyperlinks and forms that need to be resolved by javascript in
5459
** the footer.
5560
*/
@@ -343,34 +348,64 @@
343348
@ var e = document.getElementById(x);
344349
@ if(!e) throw new Error("Expecting element with ID "+x);
345350
@ else return e;}
346351
@ </script>
347352
}
353
+
354
+#if INTERFACE
355
+/* Allowed parameters for style_adunit() */
356
+#define ADUNIT_OFF 0x0001 /* Do not allow ads on this page */
357
+#define ADUNIT_RIGHT_OK 0x0002 /* Right-side vertical ads ok here */
358
+#endif
359
+
360
+/*
361
+** Various page implementations can invoke this interface to let the
362
+** style manager know what kinds of ads are appropriate for this page.
363
+*/
364
+void style_adunit_config(unsigned int mFlags){
365
+ adUnitFlags = mFlags;
366
+}
348367
349368
/*
350
-** Append ad unit text if appropriate.
369
+** Return the text of an ad-unit, if one should be rendered. Return
370
+** NULL if no ad-unit is desired.
371
+**
372
+** The *pAdFlag value might be set to ADUNIT_RIGHT_OK if this is
373
+** a right-hand vertical ad.
351374
*/
352
-static void style_ad_unit(void){
353
- const char *zAd;
375
+static const char *style_adunit_text(unsigned int *pAdFlag){
376
+ const char *zAd = 0;
377
+ *pAdFlag = 0;
378
+ if( adUnitFlags & ADUNIT_OFF ) return 0; /* Disallow ads on this page */
354379
if( g.perm.Admin && db_get_boolean("adunit-omit-if-admin",0) ){
355
- return;
380
+ return 0;
356381
}
357382
if( !login_is_nobody()
358383
&& fossil_strcmp(g.zLogin,"anonymous")!=0
359384
&& db_get_boolean("adunit-omit-if-user",0)
360385
){
361
- return;
386
+ return 0;
387
+ }
388
+ if( (adUnitFlags & ADUNIT_RIGHT_OK)!=0
389
+ && !fossil_all_whitespace(zAd = db_get("adunit-right", 0))
390
+ && !cgi_body_contains("<table")
391
+ ){
392
+ *pAdFlag = ADUNIT_RIGHT_OK;
393
+ return zAd;
394
+ }else if( !fossil_all_whitespace(zAd = db_get("adunit",0)) ){
395
+ return zAd;
362396
}
363
- zAd = db_get("adunit", 0);
364
- if( zAd ) cgi_append_content(zAd, -1);
397
+ return 0;
365398
}
366399
367400
/*
368401
** Draw the footer at the bottom of the page.
369402
*/
370403
void style_footer(void){
371404
const char *zFooter;
405
+ const char *zAd = 0;
406
+ unsigned int mAdFlags = 0;
372407
373408
if( !headerHasBeenGenerated ) return;
374409
375410
/* Go back and put the submenu at the top of the page. We delay the
376411
** creation of the submenu until the end so that we can add elements
@@ -389,12 +424,25 @@
389424
@ <a class="label" href="%h(p->zLink)">%h(p->zLabel)</a>
390425
}
391426
}
392427
@ </div>
393428
}
394
- style_ad_unit();
395
- @ <div class="content">
429
+
430
+ zAd = style_adunit_text(&mAdFlags);
431
+ if( (mAdFlags & ADUNIT_RIGHT_OK)!=0 ){
432
+ @ <div class="content adunit_right_container">
433
+ @ <div class="adunit_right">
434
+ cgi_append_content(zAd, -1);
435
+ @ </div>
436
+ }else{
437
+ if( zAd ){
438
+ @ <div class="adunit_banner">
439
+ cgi_append_content(zAd, -1);
440
+ @ </div>
441
+ }
442
+ @ <div class="content">
443
+ }
396444
cgi_destination(CGI_BODY);
397445
398446
if( sideboxUsed ){
399447
/* Put the footer at the bottom of the page.
400448
** the additional clear/both is needed to extend the content
401449
--- src/style.c
+++ src/style.c
@@ -46,10 +46,15 @@
46 /*
47 ** remember, if a sidebox was used
48 */
49 static int sideboxUsed = 0;
50
 
 
 
 
 
51
52 /*
53 ** List of hyperlinks and forms that need to be resolved by javascript in
54 ** the footer.
55 */
@@ -343,34 +348,64 @@
343 @ var e = document.getElementById(x);
344 @ if(!e) throw new Error("Expecting element with ID "+x);
345 @ else return e;}
346 @ </script>
347 }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
348
349 /*
350 ** Append ad unit text if appropriate.
 
 
 
 
351 */
352 static void style_ad_unit(void){
353 const char *zAd;
 
 
354 if( g.perm.Admin && db_get_boolean("adunit-omit-if-admin",0) ){
355 return;
356 }
357 if( !login_is_nobody()
358 && fossil_strcmp(g.zLogin,"anonymous")!=0
359 && db_get_boolean("adunit-omit-if-user",0)
360 ){
361 return;
 
 
 
 
 
 
 
 
 
362 }
363 zAd = db_get("adunit", 0);
364 if( zAd ) cgi_append_content(zAd, -1);
365 }
366
367 /*
368 ** Draw the footer at the bottom of the page.
369 */
370 void style_footer(void){
371 const char *zFooter;
 
 
372
373 if( !headerHasBeenGenerated ) return;
374
375 /* Go back and put the submenu at the top of the page. We delay the
376 ** creation of the submenu until the end so that we can add elements
@@ -389,12 +424,25 @@
389 @ <a class="label" href="%h(p->zLink)">%h(p->zLabel)</a>
390 }
391 }
392 @ </div>
393 }
394 style_ad_unit();
395 @ <div class="content">
 
 
 
 
 
 
 
 
 
 
 
 
 
396 cgi_destination(CGI_BODY);
397
398 if( sideboxUsed ){
399 /* Put the footer at the bottom of the page.
400 ** the additional clear/both is needed to extend the content
401
--- src/style.c
+++ src/style.c
@@ -46,10 +46,15 @@
46 /*
47 ** remember, if a sidebox was used
48 */
49 static int sideboxUsed = 0;
50
51 /*
52 ** Ad-unit styles.
53 */
54 static unsigned adUnitFlags = 0;
55
56
57 /*
58 ** List of hyperlinks and forms that need to be resolved by javascript in
59 ** the footer.
60 */
@@ -343,34 +348,64 @@
348 @ var e = document.getElementById(x);
349 @ if(!e) throw new Error("Expecting element with ID "+x);
350 @ else return e;}
351 @ </script>
352 }
353
354 #if INTERFACE
355 /* Allowed parameters for style_adunit() */
356 #define ADUNIT_OFF 0x0001 /* Do not allow ads on this page */
357 #define ADUNIT_RIGHT_OK 0x0002 /* Right-side vertical ads ok here */
358 #endif
359
360 /*
361 ** Various page implementations can invoke this interface to let the
362 ** style manager know what kinds of ads are appropriate for this page.
363 */
364 void style_adunit_config(unsigned int mFlags){
365 adUnitFlags = mFlags;
366 }
367
368 /*
369 ** Return the text of an ad-unit, if one should be rendered. Return
370 ** NULL if no ad-unit is desired.
371 **
372 ** The *pAdFlag value might be set to ADUNIT_RIGHT_OK if this is
373 ** a right-hand vertical ad.
374 */
375 static const char *style_adunit_text(unsigned int *pAdFlag){
376 const char *zAd = 0;
377 *pAdFlag = 0;
378 if( adUnitFlags & ADUNIT_OFF ) return 0; /* Disallow ads on this page */
379 if( g.perm.Admin && db_get_boolean("adunit-omit-if-admin",0) ){
380 return 0;
381 }
382 if( !login_is_nobody()
383 && fossil_strcmp(g.zLogin,"anonymous")!=0
384 && db_get_boolean("adunit-omit-if-user",0)
385 ){
386 return 0;
387 }
388 if( (adUnitFlags & ADUNIT_RIGHT_OK)!=0
389 && !fossil_all_whitespace(zAd = db_get("adunit-right", 0))
390 && !cgi_body_contains("<table")
391 ){
392 *pAdFlag = ADUNIT_RIGHT_OK;
393 return zAd;
394 }else if( !fossil_all_whitespace(zAd = db_get("adunit",0)) ){
395 return zAd;
396 }
397 return 0;
 
398 }
399
400 /*
401 ** Draw the footer at the bottom of the page.
402 */
403 void style_footer(void){
404 const char *zFooter;
405 const char *zAd = 0;
406 unsigned int mAdFlags = 0;
407
408 if( !headerHasBeenGenerated ) return;
409
410 /* Go back and put the submenu at the top of the page. We delay the
411 ** creation of the submenu until the end so that we can add elements
@@ -389,12 +424,25 @@
424 @ <a class="label" href="%h(p->zLink)">%h(p->zLabel)</a>
425 }
426 }
427 @ </div>
428 }
429
430 zAd = style_adunit_text(&mAdFlags);
431 if( (mAdFlags & ADUNIT_RIGHT_OK)!=0 ){
432 @ <div class="content adunit_right_container">
433 @ <div class="adunit_right">
434 cgi_append_content(zAd, -1);
435 @ </div>
436 }else{
437 if( zAd ){
438 @ <div class="adunit_banner">
439 cgi_append_content(zAd, -1);
440 @ </div>
441 }
442 @ <div class="content">
443 }
444 cgi_destination(CGI_BODY);
445
446 if( sideboxUsed ){
447 /* Put the footer at the bottom of the page.
448 ** the additional clear/both is needed to extend the content
449
+2 -1
--- src/tag.c
+++ src/tag.c
@@ -535,11 +535,11 @@
535535
tag_cmd_usage:
536536
usage("add|cancel|find|list ...");
537537
}
538538
539539
/*
540
-** WEBPAGE: /taglist
540
+** WEBPAGE: taglist
541541
*/
542542
void taglist_page(void){
543543
Stmt q;
544544
545545
login_check_credentials();
@@ -546,10 +546,11 @@
546546
if( !g.perm.Read ){
547547
login_needed();
548548
}
549549
login_anonymous_available();
550550
style_header("Tags");
551
+ style_adunit_config(ADUNIT_RIGHT_OK);
551552
style_submenu_element("Timeline", "Timeline", "tagtimeline");
552553
@ <h2>Non-propagating tags:</h2>
553554
db_prepare(&q,
554555
"SELECT substr(tagname,5)"
555556
" FROM tag"
556557
--- src/tag.c
+++ src/tag.c
@@ -535,11 +535,11 @@
535 tag_cmd_usage:
536 usage("add|cancel|find|list ...");
537 }
538
539 /*
540 ** WEBPAGE: /taglist
541 */
542 void taglist_page(void){
543 Stmt q;
544
545 login_check_credentials();
@@ -546,10 +546,11 @@
546 if( !g.perm.Read ){
547 login_needed();
548 }
549 login_anonymous_available();
550 style_header("Tags");
 
551 style_submenu_element("Timeline", "Timeline", "tagtimeline");
552 @ <h2>Non-propagating tags:</h2>
553 db_prepare(&q,
554 "SELECT substr(tagname,5)"
555 " FROM tag"
556
--- src/tag.c
+++ src/tag.c
@@ -535,11 +535,11 @@
535 tag_cmd_usage:
536 usage("add|cancel|find|list ...");
537 }
538
539 /*
540 ** WEBPAGE: taglist
541 */
542 void taglist_page(void){
543 Stmt q;
544
545 login_check_credentials();
@@ -546,10 +546,11 @@
546 if( !g.perm.Read ){
547 login_needed();
548 }
549 login_anonymous_available();
550 style_header("Tags");
551 style_adunit_config(ADUNIT_RIGHT_OK);
552 style_submenu_element("Timeline", "Timeline", "tagtimeline");
553 @ <h2>Non-propagating tags:</h2>
554 db_prepare(&q,
555 "SELECT substr(tagname,5)"
556 " FROM tag"
557
+10
--- src/util.c
+++ src/util.c
@@ -331,5 +331,15 @@
331331
int fossil_is_uuid(const char *zSym){
332332
return zSym
333333
&& (UUID_SIZE==strlen(zSym))
334334
&& validate16(zSym, UUID_SIZE);
335335
}
336
+
337
+/*
338
+** Return true if the input string is NULL or all whitespace.
339
+** Return false if the input string contains text.
340
+*/
341
+int fossil_all_whitespace(const char *z){
342
+ if( z==0 ) return 1;
343
+ while( fossil_isspace(z[0]) ){ z++; }
344
+ return z[0]==0;
345
+}
336346
--- src/util.c
+++ src/util.c
@@ -331,5 +331,15 @@
331 int fossil_is_uuid(const char *zSym){
332 return zSym
333 && (UUID_SIZE==strlen(zSym))
334 && validate16(zSym, UUID_SIZE);
335 }
 
 
 
 
 
 
 
 
 
 
336
--- src/util.c
+++ src/util.c
@@ -331,5 +331,15 @@
331 int fossil_is_uuid(const char *zSym){
332 return zSym
333 && (UUID_SIZE==strlen(zSym))
334 && validate16(zSym, UUID_SIZE);
335 }
336
337 /*
338 ** Return true if the input string is NULL or all whitespace.
339 ** Return false if the input string contains text.
340 */
341 int fossil_all_whitespace(const char *z){
342 if( z==0 ) return 1;
343 while( fossil_isspace(z[0]) ){ z++; }
344 return z[0]==0;
345 }
346

Keyboard Shortcuts

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