Sha256: 4ce43b4640f222bd60c488459ce70cef8596f2b4c20cce3466aa4cbff2a3f53f
Contents?: true
Size: 910 Bytes
Versions: 2
Compression:
Stored size: 910 Bytes
Contents
require 'erb' module Nwiki module Frontend class App def initialize git_repo_path @wiki = Nwiki::Core::Wiki.new git_repo_path raise unless @wiki.exist? end def call env path_info = env["PATH_INFO"] page = @wiki.find path_info case page when Core::Page [200, {"Content-Type" => "text/html; charset=#{page.encoding}"}, [html(page)]] when Core::File [200, {"Content-Type" => page.content_type}, [page.data]] else [404, {"Content-Type" => "text/plane"}, ["not found."]] end end def html page erb = ERB.new <<EOS <!DOCTYPE HTML> <html> <head> <title><%= page.title %> - <%= @wiki.name %></title> </head> <body> <h1><%= @wiki.name %></h1> <%= page.to_html %> </body> </html> EOS erb.result(binding).force_encoding(page.encoding) end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
nwiki-0.0.3 | lib/nwiki/frontend/app.rb |
nwiki-0.0.2 | lib/nwiki/frontend/app.rb |