Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Changes In Branch ad-unit-enhancement Excluding Merge-Ins
This is equivalent to a diff from 0438d06635 to 7d79460479
|
2015-01-21
| ||
| 21:33 | 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. check-in: ff78d6d5ef user: drh tags: trunk | |
| 21:19 | Do not attempt to use the Right-Column Ad-Unit if the content contains a <table> element. Closed-Leaf check-in: 7d79460479 user: drh tags: ad-unit-enhancement | |
| 20:45 | Add a "Flat-View" button to the /tree page when in tree-view mode. check-in: 2ee1815918 user: drh tags: trunk | |
| 18:55 | Enhance the ad-unit processing to allow for tall right-side column ads as an alternative to banner ads. check-in: 4bc5b6cf9b user: drh tags: ad-unit-enhancement | |
| 17:38 | Fix internal links on the 'attachlist' page. Reported via the mailing list. Ticket [c899dd567b0dc871d] check-in: 0438d06635 user: mistachkin tags: trunk | |
| 00:17 | Manually merge the blob leak fixes corrected on the 'cgiSetEnv' branch. check-in: 1829fa8845 user: mistachkin tags: trunk | |
Changes to src/branch.c.
| ︙ | ︙ | |||
339 340 341 342 343 344 345 346 347 348 349 350 351 352 |
*/
static void new_brlist_page(void){
Stmt q;
double rNow;
login_check_credentials();
if( !g.perm.Read ){ login_needed(); return; }
style_header("Branches");
login_anonymous_available();
db_prepare(&q, brlistQuery/*works-like:""*/);
rNow = db_double(0.0, "SELECT julianday('now')");
@ <div class="brlist"><table id="branchlisttable">
@ <thead><tr>
@ <th>Branch Name</th>
| > | 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 |
*/
static void new_brlist_page(void){
Stmt q;
double rNow;
login_check_credentials();
if( !g.perm.Read ){ login_needed(); return; }
style_header("Branches");
style_adunit_config(ADUNIT_RIGHT_OK);
login_anonymous_available();
db_prepare(&q, brlistQuery/*works-like:""*/);
rNow = db_double(0.0, "SELECT julianday('now')");
@ <div class="brlist"><table id="branchlisttable">
@ <thead><tr>
@ <th>Branch Name</th>
|
| ︙ | ︙ |
Changes to src/browse.c.
| ︙ | ︙ | |||
131 132 133 134 135 136 137 138 139 140 141 142 143 144 |
HQuery sURI;
if( strcmp(PD("type",""),"tree")==0 ){ page_tree(); return; }
login_check_credentials();
if( !g.perm.Read ){ login_needed(); return; }
while( nD>1 && zD[nD-2]=='/' ){ zD[(--nD)-1] = 0; }
style_header("File List");
sqlite3_create_function(g.db, "pathelement", 2, SQLITE_UTF8, 0,
pathelementFunc, 0, 0);
url_initialize(&sURI, "dir");
/* If the name= parameter is an empty string, make it a NULL pointer */
if( zD && strlen(zD)==0 ){ zD = 0; }
| > | 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 |
HQuery sURI;
if( strcmp(PD("type",""),"tree")==0 ){ page_tree(); return; }
login_check_credentials();
if( !g.perm.Read ){ login_needed(); return; }
while( nD>1 && zD[nD-2]=='/' ){ zD[(--nD)-1] = 0; }
style_header("File List");
style_adunit_config(ADUNIT_RIGHT_OK);
sqlite3_create_function(g.db, "pathelement", 2, SQLITE_UTF8, 0,
pathelementFunc, 0, 0);
url_initialize(&sURI, "dir");
/* If the name= parameter is an empty string, make it a NULL pointer */
if( zD && strlen(zD)==0 ){ zD = 0; }
|
| ︙ | ︙ | |||
553 554 555 556 557 558 559 560 561 562 563 564 565 566 |
showDirOnly = 1;
url_add_parameter(&sURI, "nofiles", "1");
style_header("Folder Hierarchy");
}else{
showDirOnly = 0;
style_header("File Tree");
}
if( P("expand")!=0 ){
startExpanded = 1;
url_add_parameter(&sURI, "expand", "1");
}else{
startExpanded = 0;
}
| > | 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 |
showDirOnly = 1;
url_add_parameter(&sURI, "nofiles", "1");
style_header("Folder Hierarchy");
}else{
showDirOnly = 0;
style_header("File Tree");
}
style_adunit_config(ADUNIT_RIGHT_OK);
if( P("expand")!=0 ){
startExpanded = 1;
url_add_parameter(&sURI, "expand", "1");
}else{
startExpanded = 0;
}
|
| ︙ | ︙ |
Changes to src/cgi.c.
| ︙ | ︙ | |||
106 107 108 109 110 111 112 113 114 115 116 117 118 119 |
/*
** Check to see if the header contains the zNeedle string. Return true
** if it does and false if it does not.
*/
int cgi_header_contains(const char *zNeedle){
return strstr(blob_str(&cgiContent[0]), zNeedle)!=0;
}
/*
** Append reply content to what already exists.
*/
void cgi_append_content(const char *zData, int nAmt){
blob_append(pContent, zData, nAmt);
}
| > > > | 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 |
/*
** Check to see if the header contains the zNeedle string. Return true
** if it does and false if it does not.
*/
int cgi_header_contains(const char *zNeedle){
return strstr(blob_str(&cgiContent[0]), zNeedle)!=0;
}
int cgi_body_contains(const char *zNeedle){
return strstr(blob_str(&cgiContent[1]), zNeedle)!=0;
}
/*
** Append reply content to what already exists.
*/
void cgi_append_content(const char *zData, int nAmt){
blob_append(pContent, zData, nAmt);
}
|
| ︙ | ︙ |
Changes to src/doc.c.
| ︙ | ︙ | |||
498 499 500 501 502 503 504 505 506 507 508 509 510 511 |
Th_Store("doc_name", zName);
Th_Store("doc_version", db_text(0, "SELECT '[' || substr(uuid,1,10) || ']'"
" FROM blob WHERE rid=%d", vid));
Th_Store("doc_date", db_text(0, "SELECT datetime(mtime) FROM event"
" WHERE objid=%d AND type='ci'", vid));
if( fossil_strcmp(zMime, "text/x-fossil-wiki")==0 ){
Blob title, tail;
if( wiki_find_title(&filebody, &title, &tail) ){
style_header("%s", blob_str(&title));
wiki_convert(&tail, 0, WIKI_BUTTONS);
}else{
style_header("Documentation");
wiki_convert(&filebody, 0, WIKI_BUTTONS);
}
| > | 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 |
Th_Store("doc_name", zName);
Th_Store("doc_version", db_text(0, "SELECT '[' || substr(uuid,1,10) || ']'"
" FROM blob WHERE rid=%d", vid));
Th_Store("doc_date", db_text(0, "SELECT datetime(mtime) FROM event"
" WHERE objid=%d AND type='ci'", vid));
if( fossil_strcmp(zMime, "text/x-fossil-wiki")==0 ){
Blob title, tail;
style_adunit_config(ADUNIT_RIGHT_OK);
if( wiki_find_title(&filebody, &title, &tail) ){
style_header("%s", blob_str(&title));
wiki_convert(&tail, 0, WIKI_BUTTONS);
}else{
style_header("Documentation");
wiki_convert(&filebody, 0, WIKI_BUTTONS);
}
|
| ︙ | ︙ |
Changes to src/login.c.
| ︙ | ︙ | |||
573 574 575 576 577 578 579 580 581 582 583 584 585 586 |
** code prefix, and LOGIN is the user name.
*/
login_set_user_cookie(zUsername, uid, NULL);
redirect_to_g();
}
}
style_header("Login/Logout");
@ %s(zErrMsg)
if( zGoto && P("anon")==0 ){
@ <p>A login is required for <a href="%h(zGoto)">%h(zGoto)</a>.</p>
}
form_begin(0, "%R/login");
if( zGoto ){
@ <input type="hidden" name="g" value="%h(zGoto)" />
| > | 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 |
** code prefix, and LOGIN is the user name.
*/
login_set_user_cookie(zUsername, uid, NULL);
redirect_to_g();
}
}
style_header("Login/Logout");
style_adunit_config(ADUNIT_OFF);
@ %s(zErrMsg)
if( zGoto && P("anon")==0 ){
@ <p>A login is required for <a href="%h(zGoto)">%h(zGoto)</a>.</p>
}
form_begin(0, "%R/login");
if( zGoto ){
@ <input type="hidden" name="g" value="%h(zGoto)" />
|
| ︙ | ︙ |
Changes to src/setup.c.
| ︙ | ︙ | |||
1713 1714 1715 1716 1717 1718 1719 |
db_multi_exec("DELETE FROM config WHERE name GLOB 'adunit*'");
cgi_replace_parameter("adunit","");
}
style_header("Edit Ad Unit");
@ <form action="%s(g.zTop)/setup_adunit" method="post"><div>
login_insert_csrf_secret();
| | < | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 |
db_multi_exec("DELETE FROM config WHERE name GLOB 'adunit*'");
cgi_replace_parameter("adunit","");
}
style_header("Edit Ad Unit");
@ <form action="%s(g.zTop)/setup_adunit" method="post"><div>
login_insert_csrf_secret();
@ <b>Banner Ad-Unit:</b><br />
textarea_attribute("", 6, 80, "adunit", "adunit", "", 0);
@ <br />
@ <b>Right-Column Ad-Unit:</b><br />
textarea_attribute("", 6, 80, "adunit-right", "adright", "", 0);
@ <br />
onoff_attribute("Omit ads to administrator",
"adunit-omit-if-admin", "oia", 0, 0);
@ <br />
onoff_attribute("Omit ads to logged-in users",
"adunit-omit-if-user", "oiu", 0, 0);
@ <br />
@ <input type="submit" name="submit" value="Apply Changes" />
@ <input type="submit" name="clear" value="Delete Ad-Unit" />
@ </div></form>
@ <hr />
@ <b>Ad-Unit Notes:</b><ul>
@ <li>Leave both Ad-Units blank to disable all advertising.
@ <li>The "Banner Ad-Unit" is used for wide pages.
@ <li>The "Right-Column Ad-Unit" is used on pages with tall, narrow content.
@ <li>If the "Right-Column Ad-Unit" is blank, the "Banner Ad-Unit" is used on all pages.
@ <li>Suggested <a href="setup_editcss">CSS</a> changes:
@ <blockquote><pre>
@ div.adunit_banner {
@ margin: auto;
@ width: 100%;
@ }
@ div.adunit_right {
@ float: right;
@ }
@ div.adunit_right_container {
@ min-height: <i>height-of-right-column-ad-unit</i>;
@ }
@ </pre></blockquote>
@ <li>For a place-holder Ad-Unit for testing, Copy/Paste the following
@ with appropriate adjustments to "width:" and "height:".
@ <blockquote><pre>
@ <div style='
@ margin: 0 auto;
@ width: 600px;
@ height: 90px;
@ border: 1px solid #f11;
@ background-color: #fcc;
@ '>Demo Ad</div>
@ </pre></blockquote>
@ </li>
style_footer();
db_end_transaction(0);
}
/*
** WEBPAGE: setup_logo
*/
|
| ︙ | ︙ |
Changes to src/sitemap.c.
| ︙ | ︙ | |||
25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
** WEBPAGE: sitemap
**
** Show an incomplete list of web pages offered by the Fossil web engine.
*/
void sitemap_page(void){
login_check_credentials();
style_header("Site Map");
@ <p>
@ The following links are just a few of the many web-pages available for
@ this Fossil repository:
@ </p>
@
@ <ul>
@ <li>%z(href("%R/home"))Home Page</a></li>
| > | 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
** WEBPAGE: sitemap
**
** Show an incomplete list of web pages offered by the Fossil web engine.
*/
void sitemap_page(void){
login_check_credentials();
style_header("Site Map");
style_adunit_config(ADUNIT_RIGHT_OK);
@ <p>
@ The following links are just a few of the many web-pages available for
@ this Fossil repository:
@ </p>
@
@ <ul>
@ <li>%z(href("%R/home"))Home Page</a></li>
|
| ︙ | ︙ |
Changes to src/stat.c.
| ︙ | ︙ | |||
53 54 55 56 57 58 59 60 61 62 63 64 65 66 |
char zBuf[100];
const char *p;
login_check_credentials();
if( !g.perm.Read ){ login_needed(); return; }
brief = P("brief")!=0;
style_header("Repository Statistics");
if( g.perm.Admin ){
style_submenu_element("URLs", "URLs and Checkouts", "urllist");
style_submenu_element("Schema", "Repository Schema", "repo_schema");
style_submenu_element("Web-Cache", "Web-Cache Stats", "cachestat");
}
@ <table class="label-value">
@ <tr><th>Repository Size:</th><td>
| > | 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 |
char zBuf[100];
const char *p;
login_check_credentials();
if( !g.perm.Read ){ login_needed(); return; }
brief = P("brief")!=0;
style_header("Repository Statistics");
style_adunit_config(ADUNIT_RIGHT_OK);
if( g.perm.Admin ){
style_submenu_element("URLs", "URLs and Checkouts", "urllist");
style_submenu_element("Schema", "Repository Schema", "repo_schema");
style_submenu_element("Web-Cache", "Web-Cache Stats", "cachestat");
}
@ <table class="label-value">
@ <tr><th>Repository Size:</th><td>
|
| ︙ | ︙ | |||
288 289 290 291 292 293 294 295 296 297 298 299 300 301 |
void urllist_page(void){
Stmt q;
int cnt;
login_check_credentials();
if( !g.perm.Admin ){ login_needed(); return; }
style_header("URLs and Checkouts");
style_submenu_element("Stat", "Repository Stats", "stat");
style_submenu_element("Schema", "Repository Schema", "repo_schema");
@ <div class="section">URLs</div>
@ <table border="0" width='100%%'>
db_prepare(&q, "SELECT substr(name,9), datetime(mtime,'unixepoch')"
" FROM config WHERE name GLOB 'baseurl:*' ORDER BY 2 DESC");
cnt = 0;
| > | 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 |
void urllist_page(void){
Stmt q;
int cnt;
login_check_credentials();
if( !g.perm.Admin ){ login_needed(); return; }
style_header("URLs and Checkouts");
style_adunit_config(ADUNIT_RIGHT_OK);
style_submenu_element("Stat", "Repository Stats", "stat");
style_submenu_element("Schema", "Repository Schema", "repo_schema");
@ <div class="section">URLs</div>
@ <table border="0" width='100%%'>
db_prepare(&q, "SELECT substr(name,9), datetime(mtime,'unixepoch')"
" FROM config WHERE name GLOB 'baseurl:*' ORDER BY 2 DESC");
cnt = 0;
|
| ︙ | ︙ | |||
334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 |
*/
void repo_schema_page(void){
Stmt q;
login_check_credentials();
if( !g.perm.Admin ){ login_needed(); return; }
style_header("Repository Schema");
style_submenu_element("Stat", "Repository Stats", "stat");
style_submenu_element("URLs", "URLs and Checkouts", "urllist");
db_prepare(&q, "SELECT sql FROM %s.sqlite_master WHERE sql IS NOT NULL",
db_name("repository"));
@ <pre>
while( db_step(&q)==SQLITE_ROW ){
@ %h(db_column_text(&q, 0));
}
@ </pre>
db_finalize(&q);
style_footer();
}
| > | 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 |
*/
void repo_schema_page(void){
Stmt q;
login_check_credentials();
if( !g.perm.Admin ){ login_needed(); return; }
style_header("Repository Schema");
style_adunit_config(ADUNIT_RIGHT_OK);
style_submenu_element("Stat", "Repository Stats", "stat");
style_submenu_element("URLs", "URLs and Checkouts", "urllist");
db_prepare(&q, "SELECT sql FROM %s.sqlite_master WHERE sql IS NOT NULL",
db_name("repository"));
@ <pre>
while( db_step(&q)==SQLITE_ROW ){
@ %h(db_column_text(&q, 0));
}
@ </pre>
db_finalize(&q);
style_footer();
}
|
Changes to src/style.c.
| ︙ | ︙ | |||
44 45 46 47 48 49 50 51 52 53 54 55 56 57 | static int headerHasBeenGenerated = 0; /* ** remember, if a sidebox was used */ static int sideboxUsed = 0; /* ** List of hyperlinks and forms that need to be resolved by javascript in ** the footer. */ char **aHref = 0; int nHref = 0; | > > > > > | 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 | static int headerHasBeenGenerated = 0; /* ** remember, if a sidebox was used */ 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; |
| ︙ | ︙ | |||
341 342 343 344 345 346 347 348 349 |
@ function gebi(x){
@ if(/^#/.test(x)) x = x.substr(1);
@ var e = document.getElementById(x);
@ if(!e) throw new Error("Expecting element with ID "+x);
@ else return e;}
@ </script>
}
/*
| > > > > > > > | | > > > > > > > > > > > | > > | | > > > > > > | | > > > > | 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 |
@ function gebi(x){
@ if(/^#/.test(x)) x = x.substr(1);
@ var e = document.getElementById(x);
@ if(!e) throw new Error("Expecting element with ID "+x);
@ else return e;}
@ </script>
}
#if INTERFACE
/* Allowed parameters for style_adunit() */
#define ADUNIT_OFF 0x0001 /* Do not allow ads on this page */
#define ADUNIT_RIGHT_OK 0x0002 /* Right-side vertical ads ok here */
#endif
/*
** Various page implementations can invoke this interface to let the
** style manager know what kinds of ads are appropriate for this page.
*/
void style_adunit_config(unsigned int mFlags){
adUnitFlags = mFlags;
}
/*
** Return the text of an ad-unit, if one should be rendered. Return
** NULL if no ad-unit is desired.
**
** The *pAdFlag value might be set to ADUNIT_RIGHT_OK if this is
** a right-hand vertical ad.
*/
static const char *style_adunit_text(unsigned int *pAdFlag){
const char *zAd = 0;
*pAdFlag = 0;
if( adUnitFlags & ADUNIT_OFF ) return 0; /* Disallow ads on this page */
if( g.perm.Admin && db_get_boolean("adunit-omit-if-admin",0) ){
return 0;
}
if( !login_is_nobody()
&& fossil_strcmp(g.zLogin,"anonymous")!=0
&& db_get_boolean("adunit-omit-if-user",0)
){
return 0;
}
if( (adUnitFlags & ADUNIT_RIGHT_OK)!=0
&& !fossil_all_whitespace(zAd = db_get("adunit-right", 0))
&& !cgi_body_contains("<table")
){
*pAdFlag = ADUNIT_RIGHT_OK;
return zAd;
}else if( !fossil_all_whitespace(zAd = db_get("adunit",0)) ){
return zAd;
}
return 0;
}
/*
** Draw the footer at the bottom of the page.
*/
void style_footer(void){
const char *zFooter;
const char *zAd = 0;
unsigned int mAdFlags = 0;
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
** to the submenu while generating page text.
*/
|
| ︙ | ︙ | |||
387 388 389 390 391 392 393 |
@ <span class="label">%h(p->zLabel)</span>
}else{
@ <a class="label" href="%h(p->zLink)">%h(p->zLabel)</a>
}
}
@ </div>
}
| | > > > > > > > > > > > > | > | 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 |
@ <span class="label">%h(p->zLabel)</span>
}else{
@ <a class="label" href="%h(p->zLink)">%h(p->zLabel)</a>
}
}
@ </div>
}
zAd = style_adunit_text(&mAdFlags);
if( (mAdFlags & ADUNIT_RIGHT_OK)!=0 ){
@ <div class="content adunit_right_container">
@ <div class="adunit_right">
cgi_append_content(zAd, -1);
@ </div>
}else{
if( zAd ){
@ <div class="adunit_banner">
cgi_append_content(zAd, -1);
@ </div>
}
@ <div class="content">
}
cgi_destination(CGI_BODY);
if( sideboxUsed ){
/* Put the footer at the bottom of the page.
** the additional clear/both is needed to extend the content
** part to the end of an optional sidebox.
*/
|
| ︙ | ︙ |
Changes to src/tag.c.
| ︙ | ︙ | |||
533 534 535 536 537 538 539 |
return;
tag_cmd_usage:
usage("add|cancel|find|list ...");
}
/*
| | > | 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 |
return;
tag_cmd_usage:
usage("add|cancel|find|list ...");
}
/*
** WEBPAGE: taglist
*/
void taglist_page(void){
Stmt q;
login_check_credentials();
if( !g.perm.Read ){
login_needed();
}
login_anonymous_available();
style_header("Tags");
style_adunit_config(ADUNIT_RIGHT_OK);
style_submenu_element("Timeline", "Timeline", "tagtimeline");
@ <h2>Non-propagating tags:</h2>
db_prepare(&q,
"SELECT substr(tagname,5)"
" FROM tag"
" WHERE EXISTS(SELECT 1 FROM tagxref"
" WHERE tagid=tag.tagid"
|
| ︙ | ︙ |
Changes to src/util.c.
| ︙ | ︙ | |||
329 330 331 332 333 334 335 |
** only lower-case ASCII hexadecimal values.
*/
int fossil_is_uuid(const char *zSym){
return zSym
&& (UUID_SIZE==strlen(zSym))
&& validate16(zSym, UUID_SIZE);
}
| > > > > > > > > > > | 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 |
** only lower-case ASCII hexadecimal values.
*/
int fossil_is_uuid(const char *zSym){
return zSym
&& (UUID_SIZE==strlen(zSym))
&& validate16(zSym, UUID_SIZE);
}
/*
** Return true if the input string is NULL or all whitespace.
** Return false if the input string contains text.
*/
int fossil_all_whitespace(const char *z){
if( z==0 ) return 1;
while( fossil_isspace(z[0]) ){ z++; }
return z[0]==0;
}
|