Fossil SCM

Allow ad units to be added after the menu bar. Optionally disable ads for logged in users and/or administrators.

drh 2012-06-20 14:14 trunk
Commit e33fc88630c4ac323772d35b9393350f0faac603
2 files changed +40 -2 +17
+40 -2
--- src/setup.c
+++ src/setup.c
@@ -83,10 +83,12 @@
8383
"Edit the Cascading Style Sheet used by all pages of this repository");
8484
setup_menu_entry("Header", "setup_header",
8585
"Edit HTML text inserted at the top of every page");
8686
setup_menu_entry("Footer", "setup_footer",
8787
"Edit HTML text inserted at the bottom of every page");
88
+ setup_menu_entry("Ad-Unit", "setup_adunit",
89
+ "Edit HTML text for an ad unit inserted after the menu bar");
8890
setup_menu_entry("Logo", "setup_logo",
8991
"Change the logo and background images for the server");
9092
setup_menu_entry("Shunned", "shun",
9193
"Show artifacts that are shunned by this repository");
9294
setup_menu_entry("Log", "rcvfromlist",
@@ -1178,13 +1180,15 @@
11781180
}
11791181
}
11801182
@ </td></tr></table>
11811183
@ <p><input type="submit" name="submit" value="Apply Changes" /></p>
11821184
@ </div></form>
1183
- @ <p>Settings marked with (v) are 'versionable' and will be overridden by the contents of files named <tt>.fossil-settings/PROPERTY</tt>.</p>
1185
+ @ <p>Settings marked with (v) are 'versionable' and will be overridden
1186
+ @ by the contents of files named <tt>.fossil-settings/PROPERTY</tt>.</p>
11841187
@ <hr /><p>
1185
- @ These settings work in the same way, as the <kbd>set</kbd> commandline:<br />
1188
+ @ These settings work in the same way, as the <kbd>set</kbd>
1189
+ @ commandline:<br />
11861190
@ </p><pre>%s(zHelp_setting_cmd)</pre>
11871191
db_end_transaction(0);
11881192
style_footer();
11891193
}
11901194
@@ -1365,10 +1369,44 @@
13651369
@ See also the <a href="setup_editcss">CSS</a> and
13661370
@ <a href="setup_header">header</a> editing screens.
13671371
@ <blockquote><pre>
13681372
@ %h(zDefaultFooter)
13691373
@ </pre></blockquote>
1374
+ style_footer();
1375
+ db_end_transaction(0);
1376
+}
1377
+
1378
+/*
1379
+** WEBPAGE: setup_adunit
1380
+*/
1381
+void setup_adunit(void){
1382
+ login_check_credentials();
1383
+ if( !g.perm.Setup ){
1384
+ login_needed();
1385
+ }
1386
+ db_begin_transaction();
1387
+ if( P("clear")!=0 ){
1388
+ db_multi_exec("DELETE FROM config WHERE name GLOB 'adunit*'");
1389
+ }else{
1390
+ textarea_attribute(0, 0, 0, "adunit", "adunit", "");
1391
+ }
1392
+ style_header("Edit Ad Unit");
1393
+ @ <form action="%s(g.zTop)/setup_adunit" method="post"><div>
1394
+ login_insert_csrf_secret();
1395
+ @ <p>Edit HTML text for an ad unit that will be inserted after the
1396
+ @ menu bar and above the content of every page.</p>
1397
+ textarea_attribute("", 20, 80, "adunit", "adunit", "");
1398
+ @ <br />
1399
+ onoff_attribute("Omit ads to administrator",
1400
+ "adunit_omit_if_admin", "adunit_omit_if_admin", 0);
1401
+ @ <br />
1402
+ onoff_attribute("Omit ads to logged-in users",
1403
+ "adunit_omit_if_logged_in", "adunit_omit_if_logged_in", 0);
1404
+ @ <br />
1405
+ @ <input type="submit" name="submit" value="Apply Changes" />
1406
+ @ <input type="submit" name="clear" value="Delete Ad-Unit" />
1407
+ @ </div></form>
13701408
style_footer();
13711409
db_end_transaction(0);
13721410
}
13731411
13741412
/*
13751413
--- src/setup.c
+++ src/setup.c
@@ -83,10 +83,12 @@
83 "Edit the Cascading Style Sheet used by all pages of this repository");
84 setup_menu_entry("Header", "setup_header",
85 "Edit HTML text inserted at the top of every page");
86 setup_menu_entry("Footer", "setup_footer",
87 "Edit HTML text inserted at the bottom of every page");
 
 
88 setup_menu_entry("Logo", "setup_logo",
89 "Change the logo and background images for the server");
90 setup_menu_entry("Shunned", "shun",
91 "Show artifacts that are shunned by this repository");
92 setup_menu_entry("Log", "rcvfromlist",
@@ -1178,13 +1180,15 @@
1178 }
1179 }
1180 @ </td></tr></table>
1181 @ <p><input type="submit" name="submit" value="Apply Changes" /></p>
1182 @ </div></form>
1183 @ <p>Settings marked with (v) are 'versionable' and will be overridden by the contents of files named <tt>.fossil-settings/PROPERTY</tt>.</p>
 
1184 @ <hr /><p>
1185 @ These settings work in the same way, as the <kbd>set</kbd> commandline:<br />
 
1186 @ </p><pre>%s(zHelp_setting_cmd)</pre>
1187 db_end_transaction(0);
1188 style_footer();
1189 }
1190
@@ -1365,10 +1369,44 @@
1365 @ See also the <a href="setup_editcss">CSS</a> and
1366 @ <a href="setup_header">header</a> editing screens.
1367 @ <blockquote><pre>
1368 @ %h(zDefaultFooter)
1369 @ </pre></blockquote>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1370 style_footer();
1371 db_end_transaction(0);
1372 }
1373
1374 /*
1375
--- src/setup.c
+++ src/setup.c
@@ -83,10 +83,12 @@
83 "Edit the Cascading Style Sheet used by all pages of this repository");
84 setup_menu_entry("Header", "setup_header",
85 "Edit HTML text inserted at the top of every page");
86 setup_menu_entry("Footer", "setup_footer",
87 "Edit HTML text inserted at the bottom of every page");
88 setup_menu_entry("Ad-Unit", "setup_adunit",
89 "Edit HTML text for an ad unit inserted after the menu bar");
90 setup_menu_entry("Logo", "setup_logo",
91 "Change the logo and background images for the server");
92 setup_menu_entry("Shunned", "shun",
93 "Show artifacts that are shunned by this repository");
94 setup_menu_entry("Log", "rcvfromlist",
@@ -1178,13 +1180,15 @@
1180 }
1181 }
1182 @ </td></tr></table>
1183 @ <p><input type="submit" name="submit" value="Apply Changes" /></p>
1184 @ </div></form>
1185 @ <p>Settings marked with (v) are 'versionable' and will be overridden
1186 @ by the contents of files named <tt>.fossil-settings/PROPERTY</tt>.</p>
1187 @ <hr /><p>
1188 @ These settings work in the same way, as the <kbd>set</kbd>
1189 @ commandline:<br />
1190 @ </p><pre>%s(zHelp_setting_cmd)</pre>
1191 db_end_transaction(0);
1192 style_footer();
1193 }
1194
@@ -1365,10 +1369,44 @@
1369 @ See also the <a href="setup_editcss">CSS</a> and
1370 @ <a href="setup_header">header</a> editing screens.
1371 @ <blockquote><pre>
1372 @ %h(zDefaultFooter)
1373 @ </pre></blockquote>
1374 style_footer();
1375 db_end_transaction(0);
1376 }
1377
1378 /*
1379 ** WEBPAGE: setup_adunit
1380 */
1381 void setup_adunit(void){
1382 login_check_credentials();
1383 if( !g.perm.Setup ){
1384 login_needed();
1385 }
1386 db_begin_transaction();
1387 if( P("clear")!=0 ){
1388 db_multi_exec("DELETE FROM config WHERE name GLOB 'adunit*'");
1389 }else{
1390 textarea_attribute(0, 0, 0, "adunit", "adunit", "");
1391 }
1392 style_header("Edit Ad Unit");
1393 @ <form action="%s(g.zTop)/setup_adunit" method="post"><div>
1394 login_insert_csrf_secret();
1395 @ <p>Edit HTML text for an ad unit that will be inserted after the
1396 @ menu bar and above the content of every page.</p>
1397 textarea_attribute("", 20, 80, "adunit", "adunit", "");
1398 @ <br />
1399 onoff_attribute("Omit ads to administrator",
1400 "adunit_omit_if_admin", "adunit_omit_if_admin", 0);
1401 @ <br />
1402 onoff_attribute("Omit ads to logged-in users",
1403 "adunit_omit_if_logged_in", "adunit_omit_if_logged_in", 0);
1404 @ <br />
1405 @ <input type="submit" name="submit" value="Apply Changes" />
1406 @ <input type="submit" name="clear" value="Delete Ad-Unit" />
1407 @ </div></form>
1408 style_footer();
1409 db_end_transaction(0);
1410 }
1411
1412 /*
1413
+17
--- src/style.c
+++ src/style.c
@@ -201,10 +201,26 @@
201201
cgi_destination(CGI_BODY);
202202
g.cgiOutput = 1;
203203
headerHasBeenGenerated = 1;
204204
sideboxUsed = 0;
205205
}
206
+
207
+/*
208
+** Append ad unit text if appropriate.
209
+*/
210
+static void style_ad_unit(void){
211
+ const char *zAd;
212
+ if( g.perm.Admin && db_get_boolean("adunit_omit_if_admin",0) ){
213
+ return;
214
+ }
215
+ if( g.zLogin && strcmp(g.zLogin,"anonymous")!=0
216
+ && db_get_boolean("adunit_omit_if_logged_in",0) ){
217
+ return;
218
+ }
219
+ zAd = db_get("adunit", 0);
220
+ if( zAd ) cgi_append_content(zAd, -1);
221
+}
206222
207223
/*
208224
** Draw the footer at the bottom of the page.
209225
*/
210226
void style_footer(void){
@@ -229,10 +245,11 @@
229245
@ <a class="label" href="%s(p->zLink)">%h(p->zLabel)</a>
230246
}
231247
}
232248
@ </div>
233249
}
250
+ style_ad_unit();
234251
@ <div class="content">
235252
cgi_destination(CGI_BODY);
236253
237254
if (sideboxUsed) {
238255
/* Put the footer at the bottom of the page.
239256
--- src/style.c
+++ src/style.c
@@ -201,10 +201,26 @@
201 cgi_destination(CGI_BODY);
202 g.cgiOutput = 1;
203 headerHasBeenGenerated = 1;
204 sideboxUsed = 0;
205 }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
206
207 /*
208 ** Draw the footer at the bottom of the page.
209 */
210 void style_footer(void){
@@ -229,10 +245,11 @@
229 @ <a class="label" href="%s(p->zLink)">%h(p->zLabel)</a>
230 }
231 }
232 @ </div>
233 }
 
234 @ <div class="content">
235 cgi_destination(CGI_BODY);
236
237 if (sideboxUsed) {
238 /* Put the footer at the bottom of the page.
239
--- src/style.c
+++ src/style.c
@@ -201,10 +201,26 @@
201 cgi_destination(CGI_BODY);
202 g.cgiOutput = 1;
203 headerHasBeenGenerated = 1;
204 sideboxUsed = 0;
205 }
206
207 /*
208 ** Append ad unit text if appropriate.
209 */
210 static void style_ad_unit(void){
211 const char *zAd;
212 if( g.perm.Admin && db_get_boolean("adunit_omit_if_admin",0) ){
213 return;
214 }
215 if( g.zLogin && strcmp(g.zLogin,"anonymous")!=0
216 && db_get_boolean("adunit_omit_if_logged_in",0) ){
217 return;
218 }
219 zAd = db_get("adunit", 0);
220 if( zAd ) cgi_append_content(zAd, -1);
221 }
222
223 /*
224 ** Draw the footer at the bottom of the page.
225 */
226 void style_footer(void){
@@ -229,10 +245,11 @@
245 @ <a class="label" href="%s(p->zLink)">%h(p->zLabel)</a>
246 }
247 }
248 @ </div>
249 }
250 style_ad_unit();
251 @ <div class="content">
252 cgi_destination(CGI_BODY);
253
254 if (sideboxUsed) {
255 /* Put the footer at the bottom of the page.
256

Keyboard Shortcuts

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