Fossil SCM
Allow ad units to be added after the menu bar. Optionally disable ads for logged in users and/or administrators.
Commit
e33fc88630c4ac323772d35b9393350f0faac603
Parent
c2b681e63532712…
2 files changed
+40
-2
+17
+40
-2
| --- src/setup.c | ||
| +++ src/setup.c | ||
| @@ -83,10 +83,12 @@ | ||
| 83 | 83 | "Edit the Cascading Style Sheet used by all pages of this repository"); |
| 84 | 84 | setup_menu_entry("Header", "setup_header", |
| 85 | 85 | "Edit HTML text inserted at the top of every page"); |
| 86 | 86 | setup_menu_entry("Footer", "setup_footer", |
| 87 | 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"); | |
| 88 | 90 | setup_menu_entry("Logo", "setup_logo", |
| 89 | 91 | "Change the logo and background images for the server"); |
| 90 | 92 | setup_menu_entry("Shunned", "shun", |
| 91 | 93 | "Show artifacts that are shunned by this repository"); |
| 92 | 94 | setup_menu_entry("Log", "rcvfromlist", |
| @@ -1178,13 +1180,15 @@ | ||
| 1178 | 1180 | } |
| 1179 | 1181 | } |
| 1180 | 1182 | @ </td></tr></table> |
| 1181 | 1183 | @ <p><input type="submit" name="submit" value="Apply Changes" /></p> |
| 1182 | 1184 | @ </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> | |
| 1184 | 1187 | @ <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 /> | |
| 1186 | 1190 | @ </p><pre>%s(zHelp_setting_cmd)</pre> |
| 1187 | 1191 | db_end_transaction(0); |
| 1188 | 1192 | style_footer(); |
| 1189 | 1193 | } |
| 1190 | 1194 | |
| @@ -1365,10 +1369,44 @@ | ||
| 1365 | 1369 | @ See also the <a href="setup_editcss">CSS</a> and |
| 1366 | 1370 | @ <a href="setup_header">header</a> editing screens. |
| 1367 | 1371 | @ <blockquote><pre> |
| 1368 | 1372 | @ %h(zDefaultFooter) |
| 1369 | 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> | |
| 1370 | 1408 | style_footer(); |
| 1371 | 1409 | db_end_transaction(0); |
| 1372 | 1410 | } |
| 1373 | 1411 | |
| 1374 | 1412 | /* |
| 1375 | 1413 |
| --- 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 @@ | ||
| 201 | 201 | cgi_destination(CGI_BODY); |
| 202 | 202 | g.cgiOutput = 1; |
| 203 | 203 | headerHasBeenGenerated = 1; |
| 204 | 204 | sideboxUsed = 0; |
| 205 | 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 | +} | |
| 206 | 222 | |
| 207 | 223 | /* |
| 208 | 224 | ** Draw the footer at the bottom of the page. |
| 209 | 225 | */ |
| 210 | 226 | void style_footer(void){ |
| @@ -229,10 +245,11 @@ | ||
| 229 | 245 | @ <a class="label" href="%s(p->zLink)">%h(p->zLabel)</a> |
| 230 | 246 | } |
| 231 | 247 | } |
| 232 | 248 | @ </div> |
| 233 | 249 | } |
| 250 | + style_ad_unit(); | |
| 234 | 251 | @ <div class="content"> |
| 235 | 252 | cgi_destination(CGI_BODY); |
| 236 | 253 | |
| 237 | 254 | if (sideboxUsed) { |
| 238 | 255 | /* Put the footer at the bottom of the page. |
| 239 | 256 |
| --- 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 |