From 4f49b16079b27d7ce633619e4cddfdf2bffbc952 Mon Sep 17 00:00:00 2001 From: cashmere Date: Fri, 4 Sep 2026 09:05:24 +0200 Subject: initial commit --- src/sitemap.c | 360 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 360 insertions(+) create mode 100644 src/sitemap.c (limited to 'src/sitemap.c') diff --git a/src/sitemap.c b/src/sitemap.c new file mode 100644 index 0000000..35b9490 --- /dev/null +++ b/src/sitemap.c @@ -0,0 +1,360 @@ +/* +** Copyright (c) 2014 D. Richard Hipp +** +** This program is free software; you can redistribute it and/or +** modify it under the terms of the Simplified BSD License (also +** known as the "2-Clause License" or "FreeBSD License".) + +** This program is distributed in the hope that it will be useful, +** but without any warranty; without even the implied warranty of +** merchantability or fitness for a particular purpose. +** +** Author contact information: +** drh@hwaci.com +** http://www.hwaci.com/drh/ +** +******************************************************************************* +** +** This file contains code to implement the sitemap webpage. +*/ +#include "config.h" +#include "sitemap.h" +#include + +/* +** WEBPAGE: sitemap +** +** List some of the web pages offered by the Fossil web engine. This +** page is intended as a supplement to the menu bar on the main screen. +** That is, this page is designed to hold links that are omitted from +** the main menu due to lack of space. +** +** Additional entries defined by the "sitemap-extra" setting are included +** in the sitemap. "sitemap-extra" should be a TCL script with three +** values per entry: +** +** * The displayed text +** +** * The URL +** +** * A "capexpr" expression that determines whether or not to include +** the entry based on user capabilities. "*" means always include +** the entry and "{}" means never. +** +** If the "e=1" query parameter is present, then the standard content +** is omitted and only the sitemap-extra content is shown. If "e=2" is +** present, then only the standard content is shown and sitemap-extra +** content is omitted. +** +** If the "popup" query parameter is present and this is a POST request +** from the same origin, then the normal HTML header and footer information +** is omitted and the HTML text returned is just a raw "". +*/ +void sitemap_page(void){ + int srchFlags; + int inSublist = 0; + int i; + int isPopup = 0; /* This is an XMLHttpRequest() for /sitemap */ + int e = atoi(PD("e","0")); + const char *zExtra; + + login_check_credentials(); + if( P("popup")!=0 ){ + /* The "popup" query parameter + ** then disable anti-robot defenses */ + isPopup = 1; + g.perm.Hyperlink = 1; + g.jsHref = 0; + } + srchFlags = search_restrict(SRCH_ALL); + if( !isPopup ){ + style_header("Site Map"); + style_adunit_config(ADUNIT_RIGHT_OK); + } + + @ + inSublist = 0; + } + @ + if( cgi_is_loopback(g.zIpAddr) && db_open_local(0) ){ + @
  • %z(href("%R/ckout"))Checkout Status
  • + } + if( g.perm.Read ){ + const char *zEditGlob = db_get("fileedit-glob",""); + @
  • %z(href("%R/tree"))File Browser + @
      + @
    • %z(href("%R/tree?type=tree&ci=trunk"))Tree-view, + @ Trunk Check-in
    • + @
    • %z(href("%R/tree?type=flat"))Flat-view
    • + @
    • %z(href("%R/fileage?name=trunk"))File ages for Trunk
    • + @
    • %z(href("%R/uvlist"))Unversioned Files + if( g.perm.Write && zEditGlob[0]!=0 ){ + @
    • %z(href("%R/fileedit"))On-line File Editor
    • + } + @
    + } + if( g.perm.Zip && db_get_boolean("suggested-downloads",0)!=0 ){ + @
  • %z(href("%R/download"))Tarballs and ZIPs + } + if( g.perm.Read ){ + @
  • %z(href("%R/timeline"))Project Timeline + @
      + @
    • %z(href("%R/reports"))Activity Reports
    • + @
    • %z(href("%R/sitemap-timeline"))Other timelines
    • + @
    + @
  • + } + if( g.perm.Read ){ + @
  • %z(href("%R/brlist"))Branches + @
      + @
    • %z(href("%R/taglist"))Tags
    • + @
    • %z(href("%R/leaves"))Leaf Check-ins
    • + @
    + @
  • + } + if( srchFlags ){ + @
  • %z(href("%R/search"))Search
  • + } + if( g.perm.Chat ){ + @
  • %z(href("%R/chat"))Chat
  • + } + if( g.perm.RdForum ){ + const char *zTitle = db_get("forum-title","Forum"); + @
  • %z(href("%R/forum"))%h(zTitle) + @
      + @
    • %z(href("%R/timeline?y=f"))Recent activity
    • + @
    + @
  • + } + if( g.perm.RdTkt ){ + @
  • %z(href("%R/reportlist"))Tickets/Bug Reports + @
      + if( srchFlags & SRCH_TKT ){ + @
    • %z(href("%R/tktsrch"))Ticket Search
    • + } + @
    • %z(href("%R/timeline?y=t"))Recent activity
    • + @
    • %z(href("%R/attachlist"))List of Attachments
    • + @
    + @
  • + } + if( g.perm.RdWiki ){ + @
  • %z(href("%R/wikihelp"))Wiki + @
      + if( srchFlags & SRCH_WIKI ){ + @
    • %z(href("%R/wikisrch"))Wiki Search
    • + } + @
    • %z(href("%R/wcontent"))List of Wiki Pages
    • + @
    • %z(href("%R/timeline?y=w"))Recent activity
    • + @
    • %z(href("%R/wikiedit?name=Sandbox"))Wiki Sandbox
    • + @
    • %z(href("%R/attachlist"))List of Attachments
    • + @
    • %z(href("%R/pikchrshow"))Pikchr Sandbox
    • + @
    + @
  • + } + + if( !g.zLogin ){ + @
  • %z(href("%R/login"))Login + @
      + if( login_self_register_available(0) ){ + @
    • %z(href("%R/register"))Create a new account
    • + } + }else { + @
    • %z(href("%R/logout"))Logout from %h(g.zLogin) + @
        + if( g.perm.Password ){ + @
      • %z(href("%R/logout"))Change Password for %h(g.zLogin)
      • + } + } + if( alert_enabled() && g.perm.EmailAlert ){ + if( login_is_individual() ){ + @
      • %z(href("%R/alerts"))Email Alerts for %h(g.zLogin)
      • + }else{ + @
      • %z(href("%R/subscribe"))Subscribe to Email Alerts
      • + } + } + @
      • %z(href("%R/cookies"))Cookies
      • + @
      + @
    • + + if( g.perm.Read ){ + @
    • %z(href("%R/stat"))Repository Status + @
        + @
      • %z(href("%R/hash-collisions"))Collisions on hash prefixes
      • + if( g.perm.Admin ){ + @
      • %z(href("%R/urllist"))List of URLs used to access + @ this repository
      • + } + @
      • %z(href("%R/bloblist"))List of Artifacts
      • + @
      + @
    • + } + @
    • %z(href("%R/help"))Help + @
        + if( g.perm.Admin || g.perm.Write || + g.perm.WrForum || g.perm.WrTForum || + g.perm.NewWiki || g.perm.ApndWiki || g.perm.WrWiki || g.perm.ModWiki || + g.perm.NewTkt || g.perm.ApndTkt || g.perm.WrTkt || g.perm.ModTkt ){ + @
      • %z(href("%R/wiki_rules"))Wiki Formatting Rules
      • + @
      • %z(href("%R/md_rules"))Markdown Formatting Rules
      • + } + @
      • %z(href("%R/test-all-help"))All "help" text on a single page
      • + if( g.perm.Admin || g.perm.Write || g.perm.WrUnver ){ + @
      • %z(href("%R/mimetype_list"))\ + @ Filename suffix to MIME type map
      • + } + @
    • + if( g.perm.Admin ){ + @
    • Administration Pages + @
    • + } + @
    • %z(href("%R/skins"))Skins
    • + @
    • %z(href("%R/sitemap-test"))Test Pages
    • + if( isPopup ){ + @
    • %z(href("%R/sitemap"))Site Map
    • + } + +end_of_sitemap: + @
    + if( !isPopup ){ + style_finish_page(); + } +} + +/* +** WEBPAGE: sitemap-test +** +** List some of the web pages offered by the Fossil web engine for testing +** purposes. This is similar to /sitemap, but is focused only on showing +** pages associated with testing. +*/ +void sitemap_test_page(void){ + int isPopup = 0; /* This is an XMLHttpRequest() for /sitemap */ + + login_check_credentials(); + style_set_current_feature("sitemap"); + if( P("popup")!=0 && cgi_csrf_safe(0) ){ + /* If this is a POST from the same origin with the popup=1 parameter, + ** then disable anti-robot defenses */ + isPopup = 1; + g.perm.Hyperlink = 1; + g.jsHref = 0; + } + if( !isPopup ){ + style_header("Test Page Map"); + style_adunit_config(ADUNIT_RIGHT_OK); + } + @
      + if( g.perm.Admin || db_get_boolean("test_env_enable",0) ){ + @
    • %z(href("%R/test-env"))CGI Environment Test
    • + } + if( g.perm.Read ){ + @
    • %z(href("%R/test-rename-list"))List of file renames
    • + } + @
    • %z(href("%R/test-builtin-files"))List of built-in files
    • + @
    • %z(href("%R/mimetype_list"))List of MIME types
    • + @
    • %z(href("%R/hash-color-test"))Hash color test + @
    • %z(href("%R/test-bgcolor"))Background color test + if( g.perm.Admin ){ + @
    • %z(href("%R/test-backlinks"))List of backlinks
    • + @
    • %z(href("%R/test-backlink-timeline"))Backlink timeline
    • + @
    • %z(href("%R/phantoms"))List of phantom artifacts
    • + @
    • %z(href("%R/test-warning"))Error Log test page
    • + @
    • %z(href("%R/repo_stat1"))Repository sqlite_stat1 table + @
    • %z(href("%R/repo_schema"))Repository schema
    • + } + if( g.perm.Read && g.perm.Hyperlink ){ + @
    • %z(href("%R/timewarps"))Timeline of timewarps
    • + } + @
    • %z(href("%R/cookies"))Content of display preference cookie
    • + @
    • %z(href("%R/test-captcha"))Random ASCII-art Captcha image
    • + @
    • %z(href("%R/test-piechart"))Pie-Chart generator test
    • + if( !isPopup ){ + style_finish_page(); + } +} + +/* +** WEBPAGE: sitemap-timeline +** +** Generate a list of hyperlinks to various (obscure) variations on +** the /timeline page. +*/ +void sitemap_timeline_page(void){ + int isPopup = 0; /* This is an XMLHttpRequest() for /sitemap */ + + login_check_credentials(); + style_set_current_feature("sitemap"); + if( P("popup")!=0 && cgi_csrf_safe(0) ){ + /* If this is a POST from the same origin with the popup=1 parameter, + ** then disable anti-robot defenses */ + isPopup = 1; + g.perm.Hyperlink = 1; + g.jsHref = 0; + } + if( !isPopup ){ + style_header("Timeline Examples"); + style_adunit_config(ADUNIT_RIGHT_OK); + } + @
        + @
      • %z(href("%R/timeline?ymd"))Current day
      • + @
      • %z(href("%R/timeline?yw"))Current week
      • + @
      • %z(href("%R/timeline?ym"))Current month
      • + @
      • %z(href("%R/thisdayinhistory"))Today in history
      • + @
      • %z(href("%R/timeline?a=1970-01-01&y=ci&n=10"))First 10 + @ check-ins
      • + @
      • %z(href("%R/timeline?namechng"))File name changes
      • + @
      • %z(href("%R/timeline?forks"))Forks
      • + @
      • %z(href("%R/timeline?cherrypicks"))Cherrypick merges
      • + @
      • %z(href("%R/timewarps"))Timewarps
      • + @
      • %z(href("%R/timeline?ubg"))Color-coded by user
      • + @
      • %z(href("%R/timeline?deltabg"))Delta vs. baseline manifests
      • + @
      + if( !isPopup ){ + style_finish_page(); + } +} -- cgit v1.3.1