diff --git a/README.md b/README.md
index 2783097..ed6c91c 100644
--- a/README.md
+++ b/README.md
@@ -88,6 +88,9 @@ Included are the following 3rd party software:
* Magnific Popup - http://dimsemenov.com/plugins/magnific-popup/ -
Copyright (c) 2014-2016 Dmitry Semenov, provided under the MIT license
+* lunr - https://lunrjs.com - Copyright (c) 2013 by Oliver Nightingale,
+ provided under the MIT license
+
* Favicons have been processed by https://realfavicongenerator.net
* IRC contact page is provided by https://kiwiirc.com
diff --git a/Rules b/Rules
index 590a7e7..175d452 100644
--- a/Rules
+++ b/Rules
@@ -17,9 +17,9 @@ compile '/**/*.scss' do
write item.identifier.without_ext + '.css'
end
-compile '/sitemap.xml' do
+compile '/{sitemap.xml,js/search-index.js}' do
filter :erb
- write '/sitemap.xml'
+ write item.identifier
end
compile '/htaccess.txt' do
diff --git a/content/about/index.md b/content/about/index.md
index ef8e394..b4873e5 100644
--- a/content/about/index.md
+++ b/content/about/index.md
@@ -1,7 +1,7 @@
---
title: About EasyRPG
priority: 0.8
-menu_weight: 5
+menu_weight: 10
---
<% end %>
+ <% if @item.identifier.components[0] != "search" %>
+
+ <% end %>
+ <% if @item.identifier.components[0] != "search" %>
+
+
+
+ <%= render '/searchform.*' %>
+
+
+ <% end %>
<% end %>
diff --git a/layouts/searchform.html b/layouts/searchform.html
new file mode 100644
index 0000000..0ca5f72
--- /dev/null
+++ b/layouts/searchform.html
@@ -0,0 +1,4 @@
+
\ No newline at end of file
diff --git a/lib/tidy_filter.rb b/lib/filters/tidy.rb
similarity index 100%
rename from lib/tidy_filter.rb
rename to lib/filters/tidy.rb
diff --git a/lib/helpers.rb b/lib/helpers/links.rb
similarity index 100%
rename from lib/helpers.rb
rename to lib/helpers/links.rb
diff --git a/lib/navigation.rb b/lib/helpers/navigation.rb
similarity index 86%
rename from lib/navigation.rb
rename to lib/helpers/navigation.rb
index f8fadfa..7c8c3fa 100644
--- a/lib/navigation.rb
+++ b/lib/helpers/navigation.rb
@@ -1,9 +1,4 @@
-# allow partial layouts (menu/submenu)
-include Nanoc::Helpers::Rendering
-# generate links to specific items
-include Nanoc::Helpers::LinkTo
-
def link_to_upper_page(attributes = {})
p = @item_rep.path
@@ -45,7 +40,8 @@ def navigation_for(item)
next if not it.identifier.to_s.end_with?(".html", ".md")
next if it[:is_hidden] # e.g. 404
next if it[:no_menu] # e.g. contact
- next if it.identifier.to_s == "/index.html" # homepage
+ next if it.identifier =~ "/index.*" # homepage
+ next if it.identifier =~ '/search/*' # search
# defaults
subsection = it.identifier.components[part].split(".")[0]
@@ -55,7 +51,7 @@ def navigation_for(item)
# special case subsection index
if subsection == "index"
- menu_name = "Overview"
+ menu_name = it[:title].include?(":") ? it[:title].split(":")[1].strip : "Start"
link = section
menu_weight = 100
end
diff --git a/lib/helpers/searchindex.rb b/lib/helpers/searchindex.rb
new file mode 100644
index 0000000..7aafa05
--- /dev/null
+++ b/lib/helpers/searchindex.rb
@@ -0,0 +1,66 @@
+require 'json'
+
+module CreateSearchIndex
+ COMMON_WORDS = %w{ a able about across after all almost also am among an and
+ any are as at be because been but by can cannot could dear did do does
+ either else ever every for from get got had has have he her hers him his
+ how however i if in into is it its just least let like likely may me might
+ most must my neither no nor not of off often on only or other our own
+ rather said say says she should since so some than that the their them then
+ there these they this tis to too twas us wants was we were what when where
+ which while who whom why will with would yet you your' }
+ EASYRPG_SPECIALS = %w{ div class info markdown }
+
+ def make_search_index
+ a = Array.new
+
+ @items.each do |item|
+ next if item.binary?
+ next if item[:is_hidden]
+ next unless ["html", "md"].include? item.identifier.ext
+
+ words = item.raw_content.downcase.split(/\W+/)
+ keywords = words.uniq - COMMON_WORDS - EASYRPG_SPECIALS
+ a << {
+ id: item.path,
+ title: item[:title],
+ tags: item[:tags] ? item[:tags].join(" ") : "",
+ body: keywords.join(" ")
+ }
+ end
+
+ # add some static items for content not managed by nanoc
+ a << {
+ id: "/player/manual/",
+ title: "Player manual page",
+ tags: "player manual linux",
+ body: "command line options environment variables"
+ }
+ a << {
+ id: "/player/doxydoc/",
+ title: "Player source documentation",
+ tags: "player doxygen source",
+ body: "doxygen lcf struct scenes engine"
+ }
+ a << {
+ id: "https://blog.easyrpg.org",
+ title: "Blog",
+ tags: "player editor",
+ body: ""
+ }
+ a << {
+ id: "https://wiki.easyrpg.org",
+ title: "Wiki",
+ tags: "player wiki dokuwiki documentation",
+ body: "users"
+ }
+ a << {
+ id: "https://community.easyrpg.org",
+ title: "Community",
+ tags: "forums discourse communication",
+ body: "users"
+ }
+
+ JSON.pretty_generate(a)
+ end
+end
diff --git a/lib/sitemap.rb b/lib/helpers/sitemap.rb
similarity index 100%
rename from lib/sitemap.rb
rename to lib/helpers/sitemap.rb
diff --git a/lib/helpers_.rb b/lib/helpers_.rb
new file mode 100644
index 0000000..ecca3ab
--- /dev/null
+++ b/lib/helpers_.rb
@@ -0,0 +1,3 @@
+use_helper CreateSearchIndex
+use_helper Nanoc::Helpers::Rendering
+use_helper Nanoc::Helpers::LinkTo