Overview
SHA1 Hash: | 2b0d4519dc71e17876c4091dbd30af29d3931839 |
---|---|
Date: | 2008-05-05 20:18:32 |
User: | drh |
Comment: | Work toward making the "h" permission mean "hyperlink". Without "h", many pages will display, but there are few hyperlinks. A message invites users to login as anonymous. |
Timelines: | ancestors | descendants | both | trunk |
Other Links: | files | ZIP archive | manifest |
Tags And Properties
- branch=trunk inherited from [a28c83647d]
- sym-trunk inherited from [a28c83647d]
Changes
[hide diffs]Modified src/diff.c from [a8aca97812] to [626c13bd4e].
@@ -709,12 +709,16 @@ while( db_step(&q)==SQLITE_ROW ){ int pid = db_column_int(&q, 0); const char *zUuid = db_column_text(&q, 1); const char *zDate = db_column_text(&q, 2); const char *zUser = db_column_text(&q, 3); - zLabel = mprintf("<a href='%s/info/%s'>%.10s</a> %s %9.9s", - g.zBaseURL, zUuid, zUuid, zDate, zUser); + if( g.okHistory ){ + zLabel = mprintf("<a href='%s/info/%s'>%.10s</a> %s %9.9s", + g.zBaseURL, zUuid, zUuid, zDate, zUser); + }else{ + zLabel = mprintf("%.10s %s %9.9s", zUuid, zDate, zUser); + } content_get(pid, &step); annotation_step(p, &step, zLabel); blob_reset(&step); } db_finalize(&q); @@ -733,11 +737,11 @@ int fnid = atoi(PD("fnid","0")); int i; Annotator ann; login_check_credentials(); - if( !g.okHistory ){ login_needed(); return; } + if( !g.okRead ){ login_needed(); return; } if( mid==0 || fnid==0 ){ cgi_redirect("index"); } if( !db_exists("SELECT 1 FROM mlink WHERE mid=%d AND fnid=%d",mid,fnid) ){ cgi_redirect("index"); } style_header("File Annotation");
Modified src/info.c from [54715d1400] to [1846288242].
@@ -299,11 +299,11 @@ Stmt q; int rid; int isLeaf; login_check_credentials(); - if( !g.okHistory ){ login_needed(); return; } + if( !g.okRead ){ login_needed(); return; } rid = name_to_rid(PD("name","0")); if( rid==0 ){ style_header("Version Information Error"); @ No such object: %h(g.argv[2]) style_footer(); @@ -319,10 +319,11 @@ ); if( db_step(&q)==SQLITE_ROW ){ const char *zUuid = db_column_text(&q, 0); char *zTitle = mprintf("Baseline [%.10s]", zUuid); style_header(zTitle); + login_anonymous_available(); free(zTitle); /*@ <h2>Version %s(zUuid)</h2>*/ @ <div class="section">Overview</div> @ <p><table class="label-value"> @ <tr><th>Version:</th><td>%s(zUuid)</td></tr> @@ -331,25 +332,28 @@ @ <tr><th>Record ID:</th><td>%d(rid)</td></tr> } @ <tr><th>Original User:</th><td>%h(db_column_text(&q, 2))</td></tr> @ <tr><th>Original Comment:</th><td>%w(db_column_text(&q,3))</td></tr> @ </td></tr> - @ <tr><th>Timelines:</th><td> - @ <a href="%s(g.zBaseURL)/timeline?p=%d(rid)">ancestors</a> - @ | <a href="%s(g.zBaseURL)/timeline?d=%d(rid)">descendents</a> - @ | <a href="%s(g.zBaseURL)/timeline?d=%d(rid)&p=%d(rid)">both</a> - @ </td></tr> - @ <tr><th>Commands:</th> - @ <td> - @ <a href="%s(g.zBaseURL)/vdiff/%d(rid)">diff</a> - @ | <a href="%s(g.zBaseURL)/zip/%s(zUuid).zip">ZIP archive</a> - @ | <a href="%s(g.zBaseURL)/artifact/%d(rid)">manifest</a> - @ </td> - @ </tr> + if( g.okHistory ){ + @ <tr><th>Timelines:</th><td> + @ <a href="%s(g.zBaseURL)/timeline?p=%d(rid)">ancestors</a> + @ | <a href="%s(g.zBaseURL)/timeline?d=%d(rid)">descendents</a> + @ | <a href="%s(g.zBaseURL)/timeline?d=%d(rid)&p=%d(rid)">both</a> + @ </td></tr> + @ <tr><th>Commands:</th> + @ <td> + @ <a href="%s(g.zBaseURL)/vdiff/%d(rid)">diff</a> + @ | <a href="%s(g.zBaseURL)/zip/%s(zUuid).zip">ZIP archive</a> + @ | <a href="%s(g.zBaseURL)/artifact/%d(rid)">manifest</a> + @ </td> + @ </tr> + } @ </table></p> }else{ style_header("Baseline Information"); + login_anonymous_available(); } db_finalize(&q); showTags(rid, ""); @ <div class="section">Changes</div> @ <ul> @@ -370,11 +374,15 @@ }else if( fid ){ @ <b>Added:</b> }else{ @ <b>Deleted:</b> } - @ <a href="%s(g.zBaseURL)/finfo?name=%T(zName)">%h(zName)</a></li> + if( g.okHistory ){ + @ <a href="%s(g.zBaseURL)/finfo?name=%T(zName)">%h(zName)</a></li> + }else{ + @ %h(zName)</li> + } } @ </ul> compute_leaves(rid); showDescendents(rid, 2, "Descendents"); showLeaves(); @@ -391,11 +399,11 @@ void winfo_page(void){ Stmt q; int rid; login_check_credentials(); - if( !g.okHistory ){ login_needed(); return; } + if( !g.okRdWiki ){ login_needed(); return; } rid = name_to_rid(PD("name","0")); if( rid==0 ){ style_header("Wiki Page Information Error"); @ No such object: %h(g.argv[2]) style_footer(); @@ -416,25 +424,28 @@ const char *zName = db_column_text(&q, 0); const char *zUuid = db_column_text(&q, 1); char *zTitle = mprintf("Wiki Page %s", zName); style_header(zTitle); free(zTitle); + login_anonymous_available(); @ <div class="section">Overview</div> @ <p><table class="label-value"> @ <tr><th>Version:</th><td>%s(zUuid)</td></tr> @ <tr><th>Date:</th><td>%s(db_column_text(&q, 2))</td></tr> if( g.okSetup ){ @ <tr><th>Record ID:</th><td>%d(rid)</td></tr> } @ <tr><th>Original User:</th><td>%s(db_column_text(&q, 3))</td></tr> - @ <tr><th>Commands:</th> - @ <td> -/* @ <a href="%s(g.zBaseURL)/wdiff/%d(rid)">diff</a> | */ - @ <a href="%s(g.zBaseURL)/whistory?name=%t(zName)">history</a> - @ | <a href="%s(g.zBaseURL)/artifact/%d(rid)">raw-text</a> - @ </td> - @ </tr> + if( g.okHistory ){ + @ <tr><th>Commands:</th> + @ <td> + /* @ <a href="%s(g.zBaseURL)/wdiff/%d(rid)">diff</a> | */ + @ <a href="%s(g.zBaseURL)/whistory?name=%t(zName)">history</a> + @ | <a href="%s(g.zBaseURL)/artifact/%d(rid)">raw-text</a> + @ </td> + @ </tr> + } @ </table></p> }else{ style_header("Wiki Information"); rid = 0; } @@ -470,12 +481,13 @@ const char *zFilename; char zPrevDate[20]; Blob title; login_check_credentials(); - if( !g.okHistory ){ login_needed(); return; } + if( !g.okRead ){ login_needed(); return; } style_header("File History"); + login_anonymous_available(); zPrevDate[0] = 0; zFilename = PD("name",""); db_prepare(&q, "SELECT a.uuid, substr(b.uuid,1,10), datetime(event.mtime,'localtime')," @@ -521,17 +533,19 @@ @ <td width="20"></td> @ <td valign="top" align="left"> hyperlink_to_uuid(zVers); @ %h(zCom) (By: %h(zUser)) @ Id: %s(zUuid)/%d(frid) - @ <a href="%s(g.zBaseURL)/artifact/%d(frid)">[view]</a> - if( fpid ){ - @ <a href="%s(g.zBaseURL)/fdiff?v1=%d(fpid)&v2=%d(frid)">[diff]</a> - } - @ <a href="%s(g.zBaseURL)/annotate?mid=%d(mid)&fnid=%d(fnid)"> - @ [annotate]</a> - @ </td> + if( g.okHistory ){ + @ <a href="%s(g.zBaseURL)/artifact/%d(frid)">[view]</a> + if( fpid ){ + @ <a href="%s(g.zBaseURL)/fdiff?v1=%d(fpid)&v2=%d(frid)">[diff]</a> + } + @ <a href="%s(g.zBaseURL)/annotate?mid=%d(mid)&fnid=%d(fnid)"> + @ [annotate]</a> + @ </td> + } } db_finalize(&q); @ </table> style_footer(); } @@ -562,12 +576,13 @@ int rid; Stmt q; char *zUuid; login_check_credentials(); - if( !g.okHistory ){ login_needed(); return; } + if( !g.okRead ){ login_needed(); return; } style_header("Baseline Changes"); + login_anonymous_available(); rid = name_to_rid(PD("name","")); if( rid==0 ){ cgi_redirect("index"); } @@ -713,11 +728,11 @@ int v1 = name_to_rid(PD("v1","0")); int v2 = name_to_rid(PD("v2","0")); Blob c1, c2, diff; login_check_credentials(); - if( !g.okHistory ){ login_needed(); return; } + if( !g.okRead ){ login_needed(); return; } style_header("Diff"); @ <h2>Differences From:</h2> @ <blockquote> object_description(v1, 1); @ </blockquote> @@ -750,11 +765,11 @@ int rid; Blob content; rid = name_to_rid(PD("name","0")); login_check_credentials(); - if( !g.okHistory ){ login_needed(); return; } + if( !g.okRead ){ login_needed(); return; } if( g.zPath[0]=='i' ){ if( db_exists("SELECT 1 FROM tagxref JOIN tag USING(tagid)" " WHERE rid=%d AND tagname LIKE 'wiki-%%'", rid) ){ winfo_page(); return;
Modified src/login.c from [619dd24338] to [b58f50fb1a].
@@ -368,6 +368,24 @@ void login_needed(void){ const char *zUrl = PD("REQUEST_URI", "index"); cgi_redirect(mprintf("login?g=%T", zUrl)); /* NOTREACHED */ assert(0); +} + +/* +** Call this routine if the user lacks okHistory permission. If +** the anonymous user has okHistory permission, then paint a mesage +** to inform the user that much more information is available by +** logging in as anonymous. +*/ +void login_anonymous_available(void){ + if( !g.okHistory && + db_exists("SELECT 1 FROM user" + " WHERE login='anonymous'" + " AND cap LIKE '%%h%%'") ){ + @ <p><b>Note:</b> Many hyperlinks are omitted from this page to discourage + @ <a href="http://en.wikipedia.org/wiki/Web_crawler">spiders</a>. + @ You will be able to access information more easily if you + @ <a href="%s(g.zTop)/login">login</a> as user "anonymous".</p> + } }
Modified src/timeline.c from [b5fdec786b] to [2c67ece757].
@@ -250,17 +250,11 @@ */ login_check_credentials(); if( !g.okRead ){ login_needed(); return; } style_header("Timeline"); - if( !g.okHistory && - db_exists("SELECT 1 FROM user" - " WHERE login='anonymous'" - " AND cap LIKE '%%h%%'") ){ - @ <p><b>Note:</b> You will be able to access <u>much</u> more - @ historical information if you <a href="%s(g.zTop)/login">login</a>.</p> - } + login_anonymous_available(); timeline_temp_table(); blob_zero(&sql); blob_zero(&desc); blob_append(&sql, "INSERT OR IGNORE INTO timeline ", -1); blob_append(&sql, timeline_query_for_www(), -1); @@ -293,12 +287,16 @@ if( nd>0 ) blob_appendf(&desc, " and "); blob_appendf(&desc, "%d ancestors", np); db_multi_exec("%s", blob_str(&sql)); } } - blob_appendf(&desc, " of <a href='%s/info/%s'>[%.10s]</a>", - g.zBaseURL, zUuid, zUuid); + if( g.okHistory ){ + blob_appendf(&desc, " of <a href='%s/info/%s'>[%.10s]</a>", + g.zBaseURL, zUuid, zUuid); + }else{ + blob_appendf(&desc, " of [%.10s]", zUuid); + } db_prepare(&q, "SELECT * FROM timeline ORDER BY timestamp DESC"); }else{ int n; Blob url; const char *zEType = "event"; @@ -357,17 +355,19 @@ if( zAfter ){ blob_appendf(&desc, " occurring on or after %h.<br>", zAfter); }else if( zBefore ){ blob_appendf(&desc, " occurring on or before %h.<br>", zBefore); } - if( zAfter || n==nEntry ){ - zDate = db_text(0, "SELECT min(timestamp) FROM timeline"); - blob_appendf(&desc, " <a href='%b&b=%s'>[older]</a>", &url, zDate); - } - if( zBefore || (zAfter && n==nEntry) ){ - zDate = db_text(0, "SELECT max(timestamp) FROM timeline"); - blob_appendf(&desc, " <a href='%b&a=%s'>[more recent]</a>", &url, zDate); + if( g.okHistory ){ + if( zAfter || n==nEntry ){ + zDate = db_text(0, "SELECT min(timestamp) FROM timeline"); + blob_appendf(&desc, " <a href='%b&b=%s'>[older]</a>", &url, zDate); + } + if( zBefore || (zAfter && n==nEntry) ){ + zDate = db_text(0, "SELECT max(timestamp) FROM timeline"); + blob_appendf(&desc, " <a href='%b&a=%s'>[more recent]</a>", &url,zDate); + } } } blob_zero(&sql); db_prepare(&q, "SELECT * FROM timeline ORDER BY timestamp DESC"); @ <h2>%b(&desc)</h2>