Minimal working frontend.
This commit is contained in:
@@ -0,0 +1,62 @@
|
||||
require 'rubygems'
|
||||
|
||||
require 'sinatra'
|
||||
require 'gollum'
|
||||
require 'mustache/sinatra'
|
||||
|
||||
require 'gollum/frontend/views/layout'
|
||||
|
||||
$path = "~/dev/mojombo/gollum/test/examples/lotr.git"
|
||||
|
||||
module Precious
|
||||
class App < Sinatra::Base
|
||||
register Mustache::Sinatra
|
||||
|
||||
dir = File.dirname(File.expand_path(__FILE__))
|
||||
|
||||
# We want to serve public assets for now
|
||||
set :public, "#{dir}/public"
|
||||
set :static, true
|
||||
|
||||
set :mustache, {
|
||||
# Tell mustache where the Views constant lives
|
||||
:namespace => Precious,
|
||||
|
||||
# Mustache templates live here
|
||||
:templates => "#{dir}/templates",
|
||||
|
||||
# Tell mustache where the views are
|
||||
:views => "#{dir}/views"
|
||||
}
|
||||
|
||||
# Sinatra error handling
|
||||
configure :development, :staging do
|
||||
set :raise_errors, false
|
||||
set :show_exceptions, true
|
||||
set :dump_errors, true
|
||||
set :clean_trace, false
|
||||
end
|
||||
|
||||
get '/' do
|
||||
show_page_or_file('Home')
|
||||
end
|
||||
|
||||
get '/*' do
|
||||
show_page_or_file(params[:splat].first)
|
||||
end
|
||||
|
||||
def show_page_or_file(name)
|
||||
wiki = Gollum::Wiki.new($path)
|
||||
if page = wiki.page(name)
|
||||
@content = page.formatted_data
|
||||
mustache :page
|
||||
elsif file = wiki.file(name)
|
||||
file.raw_data
|
||||
else
|
||||
halt 404
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Precious::App.run!
|
||||
@@ -0,0 +1,93 @@
|
||||
h1, h2, h3, h4, h5, h6 {
|
||||
color: #f90;
|
||||
font-weight: bold;
|
||||
font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
|
||||
}
|
||||
|
||||
h1 {
|
||||
font-size: 36pt;
|
||||
}
|
||||
|
||||
h2 {
|
||||
font-size: 32pt;
|
||||
}
|
||||
|
||||
h3 {
|
||||
font-size: 28pt;
|
||||
}
|
||||
|
||||
h4 {
|
||||
font-size: 24pt;
|
||||
}
|
||||
|
||||
h5 {
|
||||
font-size: 20pt;
|
||||
}
|
||||
|
||||
h6 {
|
||||
font-size: 16pt;
|
||||
}
|
||||
|
||||
p {
|
||||
font-family: Georgia, serif;
|
||||
font-size: 14pt;
|
||||
line-height: 22pt;
|
||||
}
|
||||
|
||||
#content {
|
||||
width: 60em;
|
||||
margin: 0 auto;
|
||||
color: #666;
|
||||
}
|
||||
|
||||
/***********************/
|
||||
|
||||
.frame {
|
||||
margin: 1em 0;
|
||||
display: inline-block;
|
||||
}
|
||||
|
||||
.frame img {
|
||||
display: block;
|
||||
}
|
||||
|
||||
.frame > span {
|
||||
display: block;
|
||||
border: 1px solid #aaa;
|
||||
padding: 4px;
|
||||
}
|
||||
|
||||
.frame span span {
|
||||
display: block;
|
||||
font-size: 10pt;
|
||||
margin: 0;
|
||||
padding: 4px 0 2px 0;
|
||||
text-align: center;
|
||||
line-height: 10pt;
|
||||
font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
|
||||
}
|
||||
|
||||
.float-left {
|
||||
float: left;
|
||||
padding: .5em 1em .25em 0;
|
||||
}
|
||||
|
||||
.float-right {
|
||||
float: right;
|
||||
padding: .5em 0 .25em 1em;
|
||||
}
|
||||
|
||||
.align-left {
|
||||
display: block;
|
||||
text-align: left;
|
||||
}
|
||||
|
||||
.align-center {
|
||||
display: block;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.align-right {
|
||||
display: block;
|
||||
text-align: right;
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
<!DOCTYPE html>
|
||||
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
|
||||
<title>Gollum - {{title}}</title>
|
||||
<link rel="stylesheet" href="/css/global.css" type="text/css" charset="utf-8" />
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div id="content">
|
||||
{{{yield}}}
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1 @@
|
||||
{{{content}}}
|
||||
@@ -0,0 +1,12 @@
|
||||
module Precious
|
||||
module Views
|
||||
class Layout < Mustache
|
||||
include Rack::Utils
|
||||
alias_method :h, :escape_html
|
||||
|
||||
def title
|
||||
"Home"
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,11 @@
|
||||
module Precious
|
||||
module Views
|
||||
class Page < Layout
|
||||
attr_reader :content
|
||||
|
||||
def title
|
||||
"A Page"
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -100,7 +100,7 @@ module Gollum
|
||||
containered = true
|
||||
align ||= 'left'
|
||||
if %w{left right}.include?(align)
|
||||
classes << "float-#{align};"
|
||||
classes << "float-#{align}"
|
||||
end
|
||||
elsif %w{top texttop middle absmiddle bottom absbottom baseline}.include?(align)
|
||||
attrs << %{align="#{align}"}
|
||||
@@ -136,12 +136,12 @@ module Gollum
|
||||
|
||||
if opts['frame'] || containered
|
||||
classes << 'frame' if opts['frame']
|
||||
%{<div class="#{classes.join(' ')}">} +
|
||||
%{<div>} +
|
||||
%{<span class="#{classes.join(' ')}">} +
|
||||
%{<span>} +
|
||||
%{<img src="/#{file.path}"#{style_string} #{attr_string}/>} +
|
||||
(alt ? %{<p>#{alt}</p>} : '') +
|
||||
%{</div>} +
|
||||
%{</div>}
|
||||
(alt ? %{<span>#{alt}</span>} : '') +
|
||||
%{</span>} +
|
||||
%{</span>}
|
||||
else
|
||||
%{<img src="/#{file.path}"#{style_string} #{attr_string}/>}
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user