главная|main page

состояние|status

блог|blog

файлы|files

программы|software

summaryrefslogtreecommitdiff
path: root/bb.sh
diff options
context:
space:
mode:
Diffstat (limited to 'bb.sh')
-rwxr-xr-xbb.sh34
1 files changed, 34 insertions, 0 deletions
diff --git a/bb.sh b/bb.sh
index 9d8e645..7e65925 100755
--- a/bb.sh
+++ b/bb.sh
@@ -73,6 +73,8 @@ global_variables() {
# Add them as a bash array, e.g. non_blogpost_files=("news.html" "test.html")
non_blogpost_files=()
+ # site map file
+ blog_sitemap="sitemap.xml"
# feed file (rss in this case)
blog_feed="feed.rss"
number_of_feed_articles="10"
@@ -145,6 +147,8 @@ global_variables() {
date_format_full="%a, %d %b %Y %H:%M:%S %z"
date_format_timestamp="%Y%m%d%H%M.%S"
date_allposts_header="%B %Y"
+ # Data format for sitemap
+ date_format_sitemap="%Y/%m/%d"
# Perform the post title -> filename conversion
# Experts only. You may need to tune the locales too
@@ -899,6 +903,35 @@ list_posts() {
echo -e "$lines" | column -t -s "#"
}
+
+# generate sitemap
+make_sitemap() {
+ echo -n "Building Sitemap "
+ rm "$blog_sitemap"
+
+ sitemapfile=$blog_sitemap.$RANDOM
+ while [[ -f $blog_sitemap ]]; do sitemapfile=$blog_sitemap.$RANDOM; done
+
+ {
+ echo "<?xml version="1.0" encoding="UTF-8"?>"
+ echo "<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">"
+ echo -n "." 1>&3
+ while IFS='' read -r i; do
+ echo -n "." 1>&3
+ echo "<url>"
+ echo "<loc>$global_url/${i#./}</loc>"
+ echo "<lastmod>$(LC_ALL=C date -r "$i" +"$date_format_sitemap")</lastmod>"
+ echo "</url>"
+ done < <(ls -t ./*.html)
+
+ echo "</urlset>"
+ } 3>&1 >"$sitemapfile"
+ echo ""
+
+ mv "$sitemapfile" "$blog_sitemap"
+ chmod 644 $blog_sitemap
+}
+
# Generate the feed file
make_rss() {
echo -n "Making RSS "
@@ -1192,6 +1225,7 @@ do_main() {
all_posts
all_tags
make_rss
+ make_sitemap
delete_includes
}