Check-in [94b31e1ce3]
Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | Generates sitemap.xml from wiki pages, doc files, technotes |
---|---|
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA1: |
94b31e1ce314d8c14be29f78a6825ab0 |
User & Date: | mario 2022-01-29 14:29:57 |
Context
2022-10-17
| ||
14:14 | exempt .not(".line-numbers pre") from syntax highlighting Leaf check-in: 55998a2e19 user: mario tags: trunk | |
2022-01-29
| ||
14:29 | Generates sitemap.xml from wiki pages, doc files, technotes check-in: 94b31e1ce3 user: mario tags: trunk | |
2022-01-21
| ||
21:30 | Support technotes check-in: 18aea61ba2 user: mario tags: trunk | |
Changes
Added extroot/sitemap.
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 | #!/usr/bin/php-cgi -dcgi.force_redirect=0 <?php # encoding: utf-8 # api: cgi # type: output # category: template # title: sitemap.xml # description: Generate indexing list for search engines # version: 0.1 # state: beta # depends: php:sqlite # config: - # access: public # # Crafts a sitemap.xml from wiki page list, document files, # recent changes, etc. # # You might have to set up a RewriteRule or fossil-alias # from sitemap.xml to ext/sitemap (because the ext/ prefix # precludes listing other sections else). # # Then add a `robots.txt` entry like: # Sitemap: /sitemap.xml # # Or a cron job to ping: # wget -S http://duckduckgo.com/ping?sitemap=http://example.org/sitemap.xml # #-- init include("./fossil_common.php"); header("Content-Type: text/xml; inline"); ini_set("display_errors", 1); # head print '<?xml version="1.0" encoding="UTF-8"?> <urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"> '; # pages loop( db(" SELECT SUBSTR(tagname, 6) AS name, DATE(MAX(mtime)) AS datetime FROM tag LEFT JOIN tagxref ON tag.tagid=tagxref.tagid WHERE tagname LIKE 'wiki-%' GROUP BY name ORDER BY datetime DESC; "), "wiki/", "daily", "0.5" ); loop( db(" SELECT SUBSTR(tagname, 7) AS name, DATE(MAX(mtime)) AS datetime FROM tag LEFT JOIN tagxref ON tag.tagid=tagxref.tagid WHERE tagname LIKE 'event-%' GROUP BY name ORDER BY datetime DESC; "), "technote/" , "weekly", "0.2" ); # files *.md loop( db(" SELECT name, DATE(MAX(e.mtime)) AS datetime FROM filename LEFT JOIN mlink m ON m.fnid = filename.fnid LEFT JOIN event e ON e.objid = m.mid WHERE name LIKE '%.md' OR name LIKE '%.wiki' --REGEXP '\.(md|wiki|rst)$' GROUP BY name HAVING fid <> 0 ORDER BY datetime DESC "), "doc/trunk/" , "monthly", "0.3" ); # output function loop($r, $base, $freq="weekly", $prio="0.1") { foreach ($r as $page) { entry($base . $page["name"], $page["datetime"], $freq, $prio); } } function entry($url, $datetime, $freq, $prio) { $url = htmlspecialchars($url, ENT_QUOTES, "utf-8"); print <<<EOT <url> <loc>{$_SERVER["FOSSIL_SELF"]}{$url}</loc> <lastmod>$datetime</lastmod> <changefreq>$freq</changefreq> <priority>$prio</priority> </url>\n EOT; } # end print '</urlset>'; ?> |