diff --git a/docs/404.html b/docs/404.html new file mode 100644 index 000000000..dfd401c61 --- /dev/null +++ b/docs/404.html @@ -0,0 +1,68 @@ +--- +layout: default +title: 404 - Page not found +permalink: /404.html +nav_exclude: true +search_exclude: true +--- + + + +
+

404

+

Page Not Found

+

The page you're looking for doesn't exist or may have been moved.

+

This could happen if the documentation structure has been reorganized or the page has been renamed.

+ + Go to Home + + +
\ No newline at end of file diff --git a/docs/Gemfile b/docs/Gemfile index 50943fbdc..28b874301 100644 --- a/docs/Gemfile +++ b/docs/Gemfile @@ -6,3 +6,7 @@ gem "just-the-docs" # If you want to use GitHub Pages, remove the "gem "jekyll"" above and # uncomment the line below. To upgrade, run `bundle update github-pages`. gem "github-pages", group: :jekyll_plugins + +group :jekyll_plugins do + gem "jekyll-sitemap" +end diff --git a/docs/Gemfile.lock b/docs/Gemfile.lock index f68708513..a385a6e8f 100644 --- a/docs/Gemfile.lock +++ b/docs/Gemfile.lock @@ -284,6 +284,7 @@ PLATFORMS DEPENDENCIES github-pages + jekyll-sitemap just-the-docs BUNDLED WITH diff --git a/docs/_config.yml b/docs/_config.yml index 49a75843d..19d161758 100644 --- a/docs/_config.yml +++ b/docs/_config.yml @@ -41,3 +41,15 @@ callouts: important: title: Important color: yellow + +# 404 page +defaults: + - scope: + path: "404.html" + values: + sitemap: false + +# Sitemap settings +url: "https://docs.aliasvault.net" +plugins: + - jekyll-sitemap diff --git a/docs/_plugins/404_server.rb b/docs/_plugins/404_server.rb new file mode 100644 index 000000000..032522873 --- /dev/null +++ b/docs/_plugins/404_server.rb @@ -0,0 +1,44 @@ +require 'webrick' + +module Jekyll + class FourOhFourPage < StaticFile + def write(dest) + true + end + end + + class FourOhFourGenerator < Generator + priority :low + + def generate(site) + site.static_files << FourOhFourPage.new(site, site.dest, '/', '404.html') + end + end +end + +# Override WEBrick to serve 404.html for missing files +if defined?(WEBrick) + module WEBrick + class HTTPServlet::FileHandler + alias_method :do_GET_original, :do_GET + + def do_GET(req, res) + do_GET_original(req, res) + rescue HTTPStatus::NotFound => ex + return_404_page(req, res) + rescue => ex + raise ex + end + + def return_404_page(req, res) + path = File.join(@config[:DocumentRoot], '404.html') + if File.exist?(path) + res.body = File.read(path) + res['content-type'] = 'text/html' + else + raise HTTPStatus::NotFound + end + end + end + end +end \ No newline at end of file