]> git.mdlowis.com Git - projs/awiki.git/commitdiff
added tag search to sitemap
authorMichael D. Lowis <mike@mdlowis.com>
Mon, 15 Jun 2020 00:07:35 +0000 (20:07 -0400)
committerMichael D. Lowis <mike@mdlowis.com>
Mon, 15 Jun 2020 00:07:35 +0000 (20:07 -0400)
awiki.rb

index b15015fa39d0867f49ec2b56d3c1eede0d25821a..0141ca406d8fcddc924adaef4200510e084d26d0 100755 (executable)
--- a/awiki.rb
+++ b/awiki.rb
@@ -178,13 +178,20 @@ def gensitemap()
   File.open("#{PAGES_DIR}/sitemap.md", "w") do |f|
     f.puts "<!-- WARNING: This page autogenerated. Manual changes will be lost -->"
     f.puts "# Sitemap\n\n"
-    f.puts "\n\n<p><label>Search:</label><input id=\"search\" type=\"text\"/></p>\n\n"
+    f.puts "<p>\n<label>Search Title:</label><input id=\"search\"/>"
+    f.puts "<label>Search Tags:</label><input id=\"filterTags\" list=\"allTags\"/>"
+    f.puts "<div id=\"activeTags\"></div></p>"
     f.puts "<ul id=\"pages\">"
+    tags = []
     $db[:pages].values.sort_by{|h| h[:title] }.each do |p|
-      f.puts "<li><a href=\"#{web_path(p[:path])}\" tags=\"#{p[:tags].join(" ")}\">#{p[:title]}</a></li>"
+      tags += p[:tags]
+      f.puts "<li><a href=\"#{web_path(p[:path])}\" data-tags=\"#{p[:tags].join(" ")}\">#{p[:title]}</a></li>"
     end
     f.puts "</ul>"
     f.puts "\n\n<p>#{SEARCH_SCRIPT}</p>"
+    f.puts "<p><datalist id =\"allTags\">"
+    tags.sort.uniq.each {|t| f.puts "<option value=\"#{t}\"/>" }
+    f.puts "</datalist></p>"
   end
 end