Sha256: 76a8b67e4563716fed95e68c059c7bbd194f0df278a3ee5843ab3b18f127038d
Contents?: true
Size: 1.7 KB
Versions: 1
Compression:
Stored size: 1.7 KB
Contents
require 'erb' module Nwiki module Frontend class Html def initialize git_repo_path @wiki = Nwiki::Core::Wiki.new git_repo_path end def call env path_info = env["PATH_INFO"] page = @wiki.find path_info case page when Core::Page, Core::Directory [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/plain"}, ["not found."]] end end def html page erb = ERB.new <<EOS <!DOCTYPE HTML> <html> <head> <title><%= page.title %> - <%= @wiki.title %></title> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <link rel="alternate" type="application/atom+xml" title="ATOM Feed" href="/articles.xml"> <link rel="stylesheet" href="//netdna.bootstrapcdn.com/bootstrap/3.0.0/css/bootstrap.min.css"> <link rel="stylesheet" href="//netdna.bootstrapcdn.com/bootstrap/3.0.0/css/bootstrap-theme.min.css"> </head> <body> <div class="container"> <div class="row"> <div class="col-md-8"><h1><a href="/articles/"><%= @wiki.title %></a></h1></div> <div class="col-md-4"><h2 class="text-right"><small><%= @wiki.subtitle %></small></h2></div> </div> <div class="row"> <div class="col-md-12"> <%= page.to_html %> </div> </div> </div> <script src="//ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script> <script src="//netdna.bootstrapcdn.com/bootstrap/3.0.0/js/bootstrap.min.js"></script> </body> </html> EOS erb.result(binding).force_encoding(page.encoding) end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
nwiki-0.1.4 | lib/nwiki/frontend/app/html.rb |