Fossil SCM

fossil-scm / src / sitemap.c
Source Blame History 360 lines
8432443… drh 1 /*
8432443… drh 2 ** Copyright (c) 2014 D. Richard Hipp
8432443… drh 3 **
8432443… drh 4 ** This program is free software; you can redistribute it and/or
8432443… drh 5 ** modify it under the terms of the Simplified BSD License (also
8432443… drh 6 ** known as the "2-Clause License" or "FreeBSD License".)
8432443… drh 7
8432443… drh 8 ** This program is distributed in the hope that it will be useful,
8432443… drh 9 ** but without any warranty; without even the implied warranty of
8432443… drh 10 ** merchantability or fitness for a particular purpose.
8432443… drh 11 **
8432443… drh 12 ** Author contact information:
8432443… drh 13 ** [email protected]
8432443… drh 14 ** http://www.hwaci.com/drh/
8432443… drh 15 **
8432443… drh 16 *******************************************************************************
8432443… drh 17 **
8432443… drh 18 ** This file contains code to implement the sitemap webpage.
8432443… drh 19 */
8432443… drh 20 #include "config.h"
8432443… drh 21 #include "sitemap.h"
8432443… drh 22 #include <assert.h>
8432443… drh 23
8432443… drh 24 /*
26eef7f… rberteig 25 ** WEBPAGE: sitemap
7ab0328… drh 26 **
7ab0328… drh 27 ** List some of the web pages offered by the Fossil web engine. This
26eef7f… rberteig 28 ** page is intended as a supplement to the menu bar on the main screen.
7ab0328… drh 29 ** That is, this page is designed to hold links that are omitted from
7ab0328… drh 30 ** the main menu due to lack of space.
5f36ec7… drh 31 **
5f36ec7… drh 32 ** Additional entries defined by the "sitemap-extra" setting are included
5f36ec7… drh 33 ** in the sitemap. "sitemap-extra" should be a TCL script with three
5f36ec7… drh 34 ** values per entry:
5f36ec7… drh 35 **
5f36ec7… drh 36 ** * The displayed text
5f36ec7… drh 37 **
5f36ec7… drh 38 ** * The URL
5f36ec7… drh 39 **
5f36ec7… drh 40 ** * A "capexpr" expression that determines whether or not to include
5f36ec7… drh 41 ** the entry based on user capabilities. "*" means always include
5f36ec7… drh 42 ** the entry and "{}" means never.
5f36ec7… drh 43 **
635a8b2… drh 44 ** If the "e=1" query parameter is present, then the standard content
635a8b2… drh 45 ** is omitted and only the sitemap-extra content is shown. If "e=2" is
635a8b2… drh 46 ** present, then only the standard content is shown and sitemap-extra
635a8b2… drh 47 ** content is omitted.
5f36ec7… drh 48 **
5f36ec7… drh 49 ** If the "popup" query parameter is present and this is a POST request
5f36ec7… drh 50 ** from the same origin, then the normal HTML header and footer information
5f36ec7… drh 51 ** is omitted and the HTML text returned is just a raw "<ul>...</ul>".
8432443… drh 52 */
8432443… drh 53 void sitemap_page(void){
9fa6808… drh 54 int srchFlags;
6898b3e… drh 55 int inSublist = 0;
6898b3e… drh 56 int i;
c22b71d… drh 57 int isPopup = 0; /* This is an XMLHttpRequest() for /sitemap */
635a8b2… drh 58 int e = atoi(PD("e","0"));
aa5beb8… drh 59 const char *zExtra;
6898b3e… drh 60
9fa6808… drh 61 login_check_credentials();
635a8b2… drh 62 if( P("popup")!=0 ){
635a8b2… drh 63 /* The "popup" query parameter
c22b71d… drh 64 ** then disable anti-robot defenses */
c22b71d… drh 65 isPopup = 1;
c22b71d… drh 66 g.perm.Hyperlink = 1;
df337eb… drh 67 g.jsHref = 0;
c22b71d… drh 68 }
2e9e369… drh 69 srchFlags = search_restrict(SRCH_ALL);
c22b71d… drh 70 if( !isPopup ){
c22b71d… drh 71 style_header("Site Map");
c22b71d… drh 72 style_adunit_config(ADUNIT_RIGHT_OK);
c22b71d… drh 73 }
275da70… danield 74
9c88799… drh 75 @ <ul id="sitemap" class="columns" style="column-width:20em">
635a8b2… drh 76 if( (e&1)==0 ){
5f36ec7… drh 77 @ <li>%z(href("%R/home"))Home Page</a>
5f36ec7… drh 78 }
aa5beb8… drh 79
aa5beb8… drh 80 zExtra = db_get("sitemap-extra",0);
635a8b2… drh 81 if( zExtra && (e&2)==0 ){
aa5beb8… drh 82 int rc;
aa5beb8… drh 83 char **azExtra = 0;
aa5beb8… drh 84 int *anExtra;
aa5beb8… drh 85 int nExtra = 0;
aa5beb8… drh 86 if( isPopup ) Th_FossilInit(0);
635a8b2… drh 87 if( (e&1)!=0 ) inSublist = 1;
aa5beb8… drh 88 rc = Th_SplitList(g.interp, zExtra, (int)strlen(zExtra),
aa5beb8… drh 89 &azExtra, &anExtra, &nExtra);
aa5beb8… drh 90 if( rc==TH_OK && nExtra ){
aa5beb8… drh 91 for(i=0; i+2<nExtra; i+=3){
aa5beb8… drh 92 int nResult = 0;
aa5beb8… drh 93 const char *zResult;
aa5beb8… drh 94 int iCond = 0;
aa5beb8… drh 95 rc = capexprCmd(g.interp, 0, 2,
aa5beb8… drh 96 (const char**)&azExtra[i+1], (int*)&anExtra[i+1]);
aa5beb8… drh 97 if( rc!=TH_OK ) continue;
aa5beb8… drh 98 zResult = Th_GetResult(g.interp, &nResult);
aa5beb8… drh 99 Th_ToInt(g.interp, zResult, nResult, &iCond);
aa5beb8… drh 100 if( iCond==0 ) continue;
aa5beb8… drh 101 if( !inSublist ){
aa5beb8… drh 102 @ <ul>
aa5beb8… drh 103 inSublist = 1;
aa5beb8… drh 104 }
aa5beb8… drh 105 if( azExtra[i+1][0]=='/' ){
aa5beb8… drh 106 @ <li>%z(href("%R%s",azExtra[i+1]))%h(azExtra[i])</a></li>
aa5beb8… drh 107 }else{
aa5beb8… drh 108 @ <li>%z(href("%s",azExtra[i+1]))%s(azExtra[i])</a></li>
aa5beb8… drh 109 }
aa5beb8… drh 110 }
aa5beb8… drh 111 }
aa5beb8… drh 112 Th_Free(g.interp, azExtra);
aa5beb8… drh 113 }
635a8b2… drh 114 if( (e&1)!=0 ) goto end_of_sitemap;
22fb2de… drh 115
6898b3e… drh 116 if( inSublist ){
6898b3e… drh 117 @ </ul>
275da70… danield 118 inSublist = 0;
9fa6808… drh 119 }
9fa6808… drh 120 @ </li>
2dda151… florian 121 if( cgi_is_loopback(g.zIpAddr) && db_open_local(0) ){
3f6a7e5… drh 122 @ <li>%z(href("%R/ckout"))Checkout Status</a></li>
3f6a7e5… drh 123 }
9fa6808… drh 124 if( g.perm.Read ){
cc17add… drh 125 const char *zEditGlob = db_get("fileedit-glob","");
dc5e06f… drh 126 @ <li>%z(href("%R/tree"))File Browser</a>
9fa6808… drh 127 @ <ul>
9fa6808… drh 128 @ <li>%z(href("%R/tree?type=tree&ci=trunk"))Tree-view,
9fa6808… drh 129 @ Trunk Check-in</a></li>
9fa6808… drh 130 @ <li>%z(href("%R/tree?type=flat"))Flat-view</a></li>
9fa6808… drh 131 @ <li>%z(href("%R/fileage?name=trunk"))File ages for Trunk</a></li>
6898b3e… drh 132 @ <li>%z(href("%R/uvlist"))Unversioned Files</a>
f6ac4fa… drh 133 if( g.perm.Write && zEditGlob[0]!=0 ){
cc17add… drh 134 @ <li>%z(href("%R/fileedit"))On-line File Editor</li>
cc17add… drh 135 }
6898b3e… drh 136 @ </ul>
9cc36d2… drh 137 }
6ce705b… drh 138 if( g.perm.Zip && db_get_boolean("suggested-downloads",0)!=0 ){
6ce705b… drh 139 @ <li>%z(href("%R/download"))Tarballs and ZIPs</a>
caf286d… drh 140 }
6898b3e… drh 141 if( g.perm.Read ){
dc5e06f… drh 142 @ <li>%z(href("%R/timeline"))Project Timeline</a>
6898b3e… drh 143 @ <ul>
6898b3e… drh 144 @ <li>%z(href("%R/reports"))Activity Reports</a></li>
79f7808… drh 145 @ <li>%z(href("%R/sitemap-timeline"))Other timelines</a></li>
6898b3e… drh 146 @ </ul>
dc5e06f… drh 147 @ </li>
6898b3e… drh 148 }
6898b3e… drh 149 if( g.perm.Read ){
dc5e06f… drh 150 @ <li>%z(href("%R/brlist"))Branches</a>
6898b3e… drh 151 @ <ul>
6898b3e… drh 152 @ <li>%z(href("%R/taglist"))Tags</a></li>
6898b3e… drh 153 @ <li>%z(href("%R/leaves"))Leaf Check-ins</a></li>
6898b3e… drh 154 @ </ul>
6898b3e… drh 155 @ </li>
6898b3e… drh 156 }
6898b3e… drh 157 if( srchFlags ){
6898b3e… drh 158 @ <li>%z(href("%R/search"))Search</a></li>
6898b3e… drh 159 }
e8ba89b… drh 160 if( g.perm.Chat ){
e8ba89b… drh 161 @ <li>%z(href("%R/chat"))Chat</a></li>
e8ba89b… drh 162 }
6898b3e… drh 163 if( g.perm.RdForum ){
f646537… drh 164 const char *zTitle = db_get("forum-title","Forum");
f646537… drh 165 @ <li>%z(href("%R/forum"))%h(zTitle)</a>
6898b3e… drh 166 @ <ul>
6898b3e… drh 167 @ <li>%z(href("%R/timeline?y=f"))Recent activity</a></li>
6898b3e… drh 168 @ </ul>
dc5e06f… drh 169 @ </li>
6898b3e… drh 170 }
6898b3e… drh 171 if( g.perm.RdTkt ){
35da20b… drh 172 @ <li>%z(href("%R/reportlist"))Tickets/Bug Reports</a>
6898b3e… drh 173 @ <ul>
6898b3e… drh 174 if( srchFlags & SRCH_TKT ){
6898b3e… drh 175 @ <li>%z(href("%R/tktsrch"))Ticket Search</a></li>
6898b3e… drh 176 }
6898b3e… drh 177 @ <li>%z(href("%R/timeline?y=t"))Recent activity</a></li>
6898b3e… drh 178 @ <li>%z(href("%R/attachlist"))List of Attachments</a></li>
6898b3e… drh 179 @ </ul>
9fa6808… drh 180 @ </li>
9fa6808… drh 181 }
9fa6808… drh 182 if( g.perm.RdWiki ){
9fa6808… drh 183 @ <li>%z(href("%R/wikihelp"))Wiki</a>
9fa6808… drh 184 @ <ul>
9fa6808… drh 185 if( srchFlags & SRCH_WIKI ){
9fa6808… drh 186 @ <li>%z(href("%R/wikisrch"))Wiki Search</a></li>
9fa6808… drh 187 }
9fa6808… drh 188 @ <li>%z(href("%R/wcontent"))List of Wiki Pages</a></li>
9fa6808… drh 189 @ <li>%z(href("%R/timeline?y=w"))Recent activity</a></li>
27a26bb… stephan 190 @ <li>%z(href("%R/wikiedit?name=Sandbox"))Wiki Sandbox</a></li>
6898b3e… drh 191 @ <li>%z(href("%R/attachlist"))List of Attachments</a></li>
27a26bb… stephan 192 @ <li>%z(href("%R/pikchrshow"))Pikchr Sandbox</a></li>
6898b3e… drh 193 @ </ul>
6898b3e… drh 194 @ </li>
6898b3e… drh 195 }
6898b3e… drh 196
6898b3e… drh 197 if( !g.zLogin ){
6898b3e… drh 198 @ <li>%z(href("%R/login"))Login</a>
7b00def… drh 199 @ <ul>
6898b3e… drh 200 if( login_self_register_available(0) ){
6898b3e… drh 201 @ <li>%z(href("%R/register"))Create a new account</a></li>
6898b3e… drh 202 }
6898b3e… drh 203 }else {
480aa68… drh 204 @ <li>%z(href("%R/logout"))Logout from %h(g.zLogin)</a>
7b00def… drh 205 @ <ul>
6898b3e… drh 206 if( g.perm.Password ){
480aa68… drh 207 @ <li>%z(href("%R/logout"))Change Password for %h(g.zLogin)</a></li>
6898b3e… drh 208 }
6898b3e… drh 209 }
6898b3e… drh 210 if( alert_enabled() && g.perm.EmailAlert ){
6898b3e… drh 211 if( login_is_individual() ){
480aa68… drh 212 @ <li>%z(href("%R/alerts"))Email Alerts for %h(g.zLogin)</a></li>
6898b3e… drh 213 }else{
6898b3e… drh 214 @ <li>%z(href("%R/subscribe"))Subscribe to Email Alerts</a></li>
6898b3e… drh 215 }
6898b3e… drh 216 }
7b00def… drh 217 @ <li>%z(href("%R/cookies"))Cookies</a></li>
7b00def… drh 218 @ </ul>
6898b3e… drh 219 @ </li>
6898b3e… drh 220
fd9b7bd… drh 221 if( g.perm.Read ){
fd9b7bd… drh 222 @ <li>%z(href("%R/stat"))Repository Status</a>
fd9b7bd… drh 223 @ <ul>
fd9b7bd… drh 224 @ <li>%z(href("%R/hash-collisions"))Collisions on hash prefixes</a></li>
9fa6808… drh 225 if( g.perm.Admin ){
9fa6808… drh 226 @ <li>%z(href("%R/urllist"))List of URLs used to access
9fa6808… drh 227 @ this repository</a></li>
9fa6808… drh 228 }
9fa6808… drh 229 @ <li>%z(href("%R/bloblist"))List of Artifacts</a></li>
9fa6808… drh 230 @ </ul>
9fa6808… drh 231 @ </li>
9fa6808… drh 232 }
35da20b… drh 233 @ <li>%z(href("%R/help"))Help</a>
7ff6d5b… wyoung 234 @ <ul>
7ff6d5b… wyoung 235 if( g.perm.Admin || g.perm.Write ||
7ff6d5b… wyoung 236 g.perm.WrForum || g.perm.WrTForum ||
7ff6d5b… wyoung 237 g.perm.NewWiki || g.perm.ApndWiki || g.perm.WrWiki || g.perm.ModWiki ||
7ff6d5b… wyoung 238 g.perm.NewTkt || g.perm.ApndTkt || g.perm.WrTkt || g.perm.ModTkt ){
7ff6d5b… wyoung 239 @ <li>%z(href("%R/wiki_rules"))Wiki Formatting Rules</a></li>
7ff6d5b… wyoung 240 @ <li>%z(href("%R/md_rules"))Markdown Formatting Rules</a></li>
7ff6d5b… wyoung 241 }
71d6628… wyoung 242 @ <li>%z(href("%R/test-all-help"))All "help" text on a single page</a></li>
71d6628… wyoung 243 if( g.perm.Admin || g.perm.Write || g.perm.WrUnver ){
35da20b… drh 244 @ <li>%z(href("%R/mimetype_list"))\
35da20b… drh 245 @ Filename suffix to MIME type map</a></li>
71d6628… wyoung 246 }
71d6628… wyoung 247 @ </ul></li>
71d6628… wyoung 248 if( g.perm.Admin ){
22fb2de… drh 249 @ <li><a href="%R/setup">Administration Pages</a>
86737df… drh 250 @ <ul>
22fb2de… drh 251 @ <li><a href="%R/secaudit0">Security Audit</a></li>
22fb2de… drh 252 @ <li><a href="%R/modreq">Pending Moderation Requests</a></li>
86737df… drh 253 @ </ul></li>
86737df… drh 254 }
685c7d0… drh 255 @ <li>%z(href("%R/skins"))Skins</a></li>
86737df… drh 256 @ <li>%z(href("%R/sitemap-test"))Test Pages</a></li>
86737df… drh 257 if( isPopup ){
86737df… drh 258 @ <li>%z(href("%R/sitemap"))Site Map</a></li>
86737df… drh 259 }
5f36ec7… drh 260
5f36ec7… drh 261 end_of_sitemap:
86737df… drh 262 @ </ul>
86737df… drh 263 if( !isPopup ){
112c713… drh 264 style_finish_page();
86737df… drh 265 }
86737df… drh 266 }
86737df… drh 267
86737df… drh 268 /*
86737df… drh 269 ** WEBPAGE: sitemap-test
86737df… drh 270 **
86737df… drh 271 ** List some of the web pages offered by the Fossil web engine for testing
86737df… drh 272 ** purposes. This is similar to /sitemap, but is focused only on showing
86737df… drh 273 ** pages associated with testing.
86737df… drh 274 */
86737df… drh 275 void sitemap_test_page(void){
86737df… drh 276 int isPopup = 0; /* This is an XMLHttpRequest() for /sitemap */
86737df… drh 277
86737df… drh 278 login_check_credentials();
112c713… drh 279 style_set_current_feature("sitemap");
86737df… drh 280 if( P("popup")!=0 && cgi_csrf_safe(0) ){
86737df… drh 281 /* If this is a POST from the same origin with the popup=1 parameter,
86737df… drh 282 ** then disable anti-robot defenses */
86737df… drh 283 isPopup = 1;
86737df… drh 284 g.perm.Hyperlink = 1;
df337eb… drh 285 g.jsHref = 0;
86737df… drh 286 }
86737df… drh 287 if( !isPopup ){
86737df… drh 288 style_header("Test Page Map");
86737df… drh 289 style_adunit_config(ADUNIT_RIGHT_OK);
86737df… drh 290 }
86737df… drh 291 @ <ul id="sitemap" class="columns" style="column-width:20em">
86737df… drh 292 if( g.perm.Admin || db_get_boolean("test_env_enable",0) ){
caf286d… drh 293 @ <li>%z(href("%R/test-env"))CGI Environment Test</a></li>
86737df… drh 294 }
86737df… drh 295 if( g.perm.Read ){
86737df… drh 296 @ <li>%z(href("%R/test-rename-list"))List of file renames</a></li>
86737df… drh 297 }
86737df… drh 298 @ <li>%z(href("%R/test-builtin-files"))List of built-in files</a></li>
86737df… drh 299 @ <li>%z(href("%R/mimetype_list"))List of MIME types</a></li>
1979956… drh 300 @ <li>%z(href("%R/hash-color-test"))Hash color test</a>
7ee4e5c… drh 301 @ <li>%z(href("%R/test-bgcolor"))Background color test</a>
86737df… drh 302 if( g.perm.Admin ){
86737df… drh 303 @ <li>%z(href("%R/test-backlinks"))List of backlinks</a></li>
86737df… drh 304 @ <li>%z(href("%R/test-backlink-timeline"))Backlink timeline</a></li>
86737df… drh 305 @ <li>%z(href("%R/phantoms"))List of phantom artifacts</a></li>
86737df… drh 306 @ <li>%z(href("%R/test-warning"))Error Log test page</a></li>
86737df… drh 307 @ <li>%z(href("%R/repo_stat1"))Repository <tt>sqlite_stat1</tt> table</a>
86737df… drh 308 @ <li>%z(href("%R/repo_schema"))Repository schema</a></li>
86737df… drh 309 }
86737df… drh 310 if( g.perm.Read && g.perm.Hyperlink ){
86737df… drh 311 @ <li>%z(href("%R/timewarps"))Timeline of timewarps</a></li>
86737df… drh 312 }
86737df… drh 313 @ <li>%z(href("%R/cookies"))Content of display preference cookie</a></li>
86737df… drh 314 @ <li>%z(href("%R/test-captcha"))Random ASCII-art Captcha image</a></li>
86737df… drh 315 @ <li>%z(href("%R/test-piechart"))Pie-Chart generator test</a></li>
86737df… drh 316 if( !isPopup ){
112c713… drh 317 style_finish_page();
79f7808… drh 318 }
79f7808… drh 319 }
79f7808… drh 320
79f7808… drh 321 /*
79f7808… drh 322 ** WEBPAGE: sitemap-timeline
79f7808… drh 323 **
79f7808… drh 324 ** Generate a list of hyperlinks to various (obscure) variations on
79f7808… drh 325 ** the /timeline page.
79f7808… drh 326 */
79f7808… drh 327 void sitemap_timeline_page(void){
79f7808… drh 328 int isPopup = 0; /* This is an XMLHttpRequest() for /sitemap */
79f7808… drh 329
79f7808… drh 330 login_check_credentials();
112c713… drh 331 style_set_current_feature("sitemap");
79f7808… drh 332 if( P("popup")!=0 && cgi_csrf_safe(0) ){
79f7808… drh 333 /* If this is a POST from the same origin with the popup=1 parameter,
79f7808… drh 334 ** then disable anti-robot defenses */
79f7808… drh 335 isPopup = 1;
79f7808… drh 336 g.perm.Hyperlink = 1;
df337eb… drh 337 g.jsHref = 0;
79f7808… drh 338 }
79f7808… drh 339 if( !isPopup ){
79f7808… drh 340 style_header("Timeline Examples");
79f7808… drh 341 style_adunit_config(ADUNIT_RIGHT_OK);
79f7808… drh 342 }
79f7808… drh 343 @ <ul id="sitemap" class="columns" style="column-width:20em">
79f7808… drh 344 @ <li>%z(href("%R/timeline?ymd"))Current day</a></li>
79f7808… drh 345 @ <li>%z(href("%R/timeline?yw"))Current week</a></li>
79f7808… drh 346 @ <li>%z(href("%R/timeline?ym"))Current month</a></li>
79f7808… drh 347 @ <li>%z(href("%R/thisdayinhistory"))Today in history</a></li>
79f7808… drh 348 @ <li>%z(href("%R/timeline?a=1970-01-01&y=ci&n=10"))First 10
79f7808… drh 349 @ check-ins</a></li>
79f7808… drh 350 @ <li>%z(href("%R/timeline?namechng"))File name changes</a></li>
79f7808… drh 351 @ <li>%z(href("%R/timeline?forks"))Forks</a></li>
79f7808… drh 352 @ <li>%z(href("%R/timeline?cherrypicks"))Cherrypick merges</a></li>
79f7808… drh 353 @ <li>%z(href("%R/timewarps"))Timewarps</a></li>
79f7808… drh 354 @ <li>%z(href("%R/timeline?ubg"))Color-coded by user</a></li>
79f7808… drh 355 @ <li>%z(href("%R/timeline?deltabg"))Delta vs. baseline manifests</a></li>
79f7808… drh 356 @ </ul>
79f7808… drh 357 if( !isPopup ){
112c713… drh 358 style_finish_page();
c22b71d… drh 359 }
8432443… drh 360 }

Keyboard Shortcuts

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