module Utopia::Wiki

Constants

PAGES_ROOT
PUBLIC_ROOT
SITE_ROOT
VERSION

Public Class Methods

call(builder, root = Dir.pwd, locales: nil) click to toggle source
# File lib/utopia/wiki.rb, line 38
def self.call(builder, root = Dir.pwd, locales: nil)
        if UTOPIA.production?
                # Handle exceptions in production with a error page and send an email notification:
                builder.use Utopia::Exceptions::Handler
                builder.use Utopia::Exceptions::Mailer
        else
                # We want to propate exceptions up when running tests:
                builder.use Rack::ShowExceptions unless UTOPIA.testing?
        end
        
        public_root = File.expand_path("public", root)
        builder.use Utopia::Static, root: public_root
        
        builder.use Utopia::Static, root: PUBLIC_ROOT
        
        builder.use Utopia::Redirection::Rewrite, {
                '/' => '/index'
        }
        
        builder.use Utopia::Redirection::DirectoryIndex
        
        builder.use Utopia::Redirection::Errors, {
                404 => '/errors/file-not-found'
        }
        
        if locales
                builder.use Utopia::Localization,
                        default_locale: locales.first,
                        locales: locales
        end
        
        builder.use Utopia::Controller, root: PAGES_ROOT
        
        cache_root = File.expand_path("_gallery", root)
        
        builder.use Utopia::Content, root: PAGES_ROOT, namespaces: {
                'gallery' => Utopia::Gallery::Tags.new
        }
        
        builder.run lambda { |env| [404, {}, []] }
end