manuscript 0.1.6 → 0.1.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/VERSION +1 -1
- data/lib/manuscript/base.rb +5 -4
- data/lib/manuscript/page.rb +3 -2
- data/lib/manuscript/page_template.rb +1 -1
- data/lib/manuscript/user.rb +19 -0
- data/lib/manuscript.rb +1 -0
- data/manuscript.gemspec +5 -2
- data/public/css/base.css +16 -6
- data/spec/manuscript/page_spec.rb +8 -0
- data/spec/manuscript/user_spec.rb +15 -0
- data/views/layout.haml +1 -1
- data/views/menu.haml +12 -3
- data/views/pages.haml +4 -3
- data/views/template_files.haml +1 -1
- data/views/templates.haml +2 -2
- metadata +5 -2
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.1.
|
1
|
+
0.1.7
|
data/lib/manuscript/base.rb
CHANGED
@@ -1,15 +1,16 @@
|
|
1
|
-
module Manuscript
|
2
|
-
class Base < Sinatra::Base
|
1
|
+
module Manuscript
|
2
|
+
class Base < Sinatra::Base
|
3
3
|
get "/:page_name" do
|
4
|
+
@user = session[:sso].nil? ? nil : User.new(session[:sso])
|
4
5
|
@page = Page.find_by_name(params[:page_name])
|
5
6
|
raise Sinatra::NotFound unless @page
|
6
|
-
@page.to_html
|
7
|
+
@page.to_html(@user)
|
7
8
|
end
|
8
9
|
|
9
10
|
get "/" do
|
10
11
|
@page = Page.find_by_name('index')
|
11
12
|
raise Sinatra::NotFound unless @page
|
12
|
-
@page.to_html
|
13
|
+
@page.to_html(@user)
|
13
14
|
end
|
14
15
|
end
|
15
16
|
end
|
data/lib/manuscript/page.rb
CHANGED
@@ -7,10 +7,11 @@ module Manuscript
|
|
7
7
|
|
8
8
|
validates_presence_of :name
|
9
9
|
validates_uniqueness_of :name
|
10
|
+
validates_format_of :name, :with => /^[-a-zA-Z0-9]+$/
|
10
11
|
|
11
|
-
def to_html
|
12
|
+
def to_html(user = nil)
|
12
13
|
if template
|
13
|
-
template.render({'contents' => RDiscount.new(contents).to_html})
|
14
|
+
template.render({'current_user' => user, 'contents' => RDiscount.new(contents).to_html})
|
14
15
|
else
|
15
16
|
RDiscount.new(contents).to_html
|
16
17
|
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
module Manuscript
|
2
|
+
class User
|
3
|
+
def initialize(attributes)
|
4
|
+
@attributes = attributes
|
5
|
+
end
|
6
|
+
|
7
|
+
def id
|
8
|
+
@attributes[:user_id]
|
9
|
+
end
|
10
|
+
|
11
|
+
def email
|
12
|
+
@attributes[:email]
|
13
|
+
end
|
14
|
+
|
15
|
+
def to_liquid
|
16
|
+
{'id' => id, 'email' => email}
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
data/lib/manuscript.rb
CHANGED
data/manuscript.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{manuscript}
|
8
|
-
s.version = "0.1.
|
8
|
+
s.version = "0.1.7"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["hotink"]
|
12
|
-
s.date = %q{2010-01-
|
12
|
+
s.date = %q{2010-01-16}
|
13
13
|
s.description = %q{A gem for publishing a small Hot Ink authenticated site}
|
14
14
|
s.email = %q{chris@hotink.net}
|
15
15
|
s.extra_rdoc_files = [
|
@@ -40,6 +40,7 @@ Gem::Specification.new do |s|
|
|
40
40
|
"lib/manuscript/template_file.rb",
|
41
41
|
"lib/manuscript/template_file_manager.rb",
|
42
42
|
"lib/manuscript/template_manager.rb",
|
43
|
+
"lib/manuscript/user.rb",
|
43
44
|
"manuscript.gemspec",
|
44
45
|
"public/css/base.css",
|
45
46
|
"spec/manuscript/base_spec.rb",
|
@@ -50,6 +51,7 @@ Gem::Specification.new do |s|
|
|
50
51
|
"spec/manuscript/template_file_manager_spec.rb",
|
51
52
|
"spec/manuscript/template_file_spec.rb",
|
52
53
|
"spec/manuscript/template_manager_spec.rb",
|
54
|
+
"spec/manuscript/user_spec.rb",
|
53
55
|
"spec/spec.opts",
|
54
56
|
"spec/spec_helper.rb",
|
55
57
|
"views/edit_template_file.haml",
|
@@ -76,6 +78,7 @@ Gem::Specification.new do |s|
|
|
76
78
|
"spec/manuscript/template_file_manager_spec.rb",
|
77
79
|
"spec/manuscript/template_file_spec.rb",
|
78
80
|
"spec/manuscript/template_manager_spec.rb",
|
81
|
+
"spec/manuscript/user_spec.rb",
|
79
82
|
"spec/spec_helper.rb"
|
80
83
|
]
|
81
84
|
|
data/public/css/base.css
CHANGED
@@ -1,10 +1,20 @@
|
|
1
|
-
body { font-size: 16px; line-height: 1.1em; font-family: "Helvetica Neue", verdana, tahoma, arial, sans-serif; }
|
2
|
-
div#page_container { width: 960px; }
|
1
|
+
body { font-size: 16px; color: #222; line-height: 1.1em; margin:0; font-family: "Helvetica Neue", verdana, tahoma, arial, sans-serif; }
|
2
|
+
div#page_container { width: 960px; margin: 5px 10px; }
|
3
3
|
|
4
|
-
ol.menu { list-style: none; padding-
|
4
|
+
ol.menu { list-style: none; padding: 5px; margin-top: 0; background-color: #FFF6DD; }
|
5
5
|
ol.menu li { display: inline; margin: 0 10px; }
|
6
|
+
ol.menu li a { text-decoration: none; }
|
7
|
+
ol.menu li a.current { font-weight: bold; text-decoration: underline; }
|
8
|
+
|
9
|
+
ol#pages { list-style: none; font-size: 20px; margin: 30px 0; }
|
10
|
+
ol#pages li { margin: 15px 0;}
|
6
11
|
|
7
12
|
form label { display:block; padding: 10px 0; }
|
8
|
-
form input[type="text"] { font-size:
|
9
|
-
form textarea { font-family: "andale mono", courier, tahoma, mono; font-size: 15px; width: 940px; height: 500px; }
|
10
|
-
form input[type="submit"] { float: right; }
|
13
|
+
form input[type="text"] { font-size: 20px; width: 600px; border: 1px solid #AAA; padding: 3px; }
|
14
|
+
form textarea { font-family: "andale mono", courier, tahoma, mono; padding: 5px; font-size: 15px; width: 940px; height: 500px; }
|
15
|
+
form input[type="submit"] { float: right; }
|
16
|
+
|
17
|
+
.button_link { text-decoration: none; outline: none; font-size: 12px; padding: 3px; color: black; background-color: #FFF6DD; border: 1px solid #333;-moz-border-radius: 3px; -webkit-border-radius: 3px; }
|
18
|
+
.button_link:visited { color: black; }
|
19
|
+
.button_link:hover { background-color: #CEE4F3; }
|
20
|
+
.button_link:active { background-color: #EEF4FF; }
|
@@ -8,6 +8,14 @@ describe Manuscript::Page do
|
|
8
8
|
it { should validate_uniqueness_of(:name) }
|
9
9
|
it { should belong_to(:template) }
|
10
10
|
|
11
|
+
it "should restrict names to uri-friendly strings" do
|
12
|
+
should allow_value('page-name').for(:name)
|
13
|
+
should allow_value('page1name').for(:name)
|
14
|
+
should_not allow_value('page#name').for(:name)
|
15
|
+
should_not allow_value('page name').for(:name)
|
16
|
+
should_not allow_value('page/name').for(:name)
|
17
|
+
end
|
18
|
+
|
11
19
|
describe "rendering a page as HTML" do
|
12
20
|
before do
|
13
21
|
@page = Manuscript::Page.create!(:name => 'words', :contents => 'we **got** em')
|
@@ -0,0 +1,15 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
|
2
|
+
|
3
|
+
describe Manuscript::User do
|
4
|
+
|
5
|
+
it "should make options from initialization hash" do
|
6
|
+
user = Manuscript::User.new({:user_id => 2, :email => "test@testaddress.com"})
|
7
|
+
user.id.should == 2
|
8
|
+
user.email.should == "test@testaddress.com"
|
9
|
+
end
|
10
|
+
|
11
|
+
it "should expose it's details to Liquid" do
|
12
|
+
user = Manuscript::User.new({:user_id => 2, :email => "test@testaddress.com"})
|
13
|
+
user.to_liquid.should == {'id' => 2, 'email' => "test@testaddress.com"}
|
14
|
+
end
|
15
|
+
end
|
data/views/layout.haml
CHANGED
data/views/menu.haml
CHANGED
@@ -1,7 +1,16 @@
|
|
1
1
|
%ol.menu
|
2
2
|
%li
|
3
|
-
|
3
|
+
- if request.path_info =~ /^\/admin\/pages/
|
4
|
+
%a.current{:href => "/admin/pages"} Pages
|
5
|
+
- else
|
6
|
+
%a{:href => "/admin/pages"} Pages
|
4
7
|
%li
|
5
|
-
|
8
|
+
- if (request.path_info =~ /^\/admin\/templates/) || (request.path_info =~ /^\/admin\/layouts/)
|
9
|
+
%a.current{:href => "/admin/templates"} Templates
|
10
|
+
- else
|
11
|
+
%a{:href => "/admin/templates"} Templates
|
6
12
|
%li
|
7
|
-
|
13
|
+
- if request.path_info =~ /^\/admin\/template_files/
|
14
|
+
%a.current{:href => "/admin/template_files"} Files
|
15
|
+
- else
|
16
|
+
%a{:href => "/admin/template_files"} Files
|
data/views/pages.haml
CHANGED
data/views/template_files.haml
CHANGED
@@ -6,4 +6,4 @@
|
|
6
6
|
%small
|
7
7
|
%a{:href => "/admin/template_files/#{file.id}/edit"} edit
|
8
8
|
%a{ :onclick => "if(confirm('You are about to delete a template file. Click OK to delete or Cancel to return to the page.')) { var f = document.createElement('form'); f.style.display = 'none'; this.parentNode.appendChild(f); { f.method = 'POST'; f.action = this.href;var m = document.createElement('input'); m.setAttribute('type', 'hidden'); m.setAttribute('name', '_method'); m.setAttribute('value', 'delete'); f.appendChild(m);f.submit(); } } return false;", :href => "/admin/template_files/#{file.id}" } delete
|
9
|
-
%a{ :href => "/admin/template_files/new" } Upload a file
|
9
|
+
%a.button_link{ :href => "/admin/template_files/new" } Upload a file
|
data/views/templates.haml
CHANGED
@@ -4,7 +4,7 @@
|
|
4
4
|
%li
|
5
5
|
%a{:href => "/admin/templates/#{template.id}/edit"}
|
6
6
|
= template.name
|
7
|
-
%a{ :href => "/admin/templates/new" } New template
|
7
|
+
%a.button_link{ :href => "/admin/templates/new" } New template
|
8
8
|
|
9
9
|
%h1 Layouts
|
10
10
|
%ol
|
@@ -12,4 +12,4 @@
|
|
12
12
|
%li
|
13
13
|
%a{:href => "/admin/templates/#{template.id}/edit"}
|
14
14
|
= template.name
|
15
|
-
%a{ :href => "/admin/layouts/new" } New layout
|
15
|
+
%a.button_link{ :href => "/admin/layouts/new" } New layout
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: manuscript
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- hotink
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2010-01-
|
12
|
+
date: 2010-01-16 00:00:00 -05:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
@@ -125,6 +125,7 @@ files:
|
|
125
125
|
- lib/manuscript/template_file.rb
|
126
126
|
- lib/manuscript/template_file_manager.rb
|
127
127
|
- lib/manuscript/template_manager.rb
|
128
|
+
- lib/manuscript/user.rb
|
128
129
|
- manuscript.gemspec
|
129
130
|
- public/css/base.css
|
130
131
|
- spec/manuscript/base_spec.rb
|
@@ -135,6 +136,7 @@ files:
|
|
135
136
|
- spec/manuscript/template_file_manager_spec.rb
|
136
137
|
- spec/manuscript/template_file_spec.rb
|
137
138
|
- spec/manuscript/template_manager_spec.rb
|
139
|
+
- spec/manuscript/user_spec.rb
|
138
140
|
- spec/spec.opts
|
139
141
|
- spec/spec_helper.rb
|
140
142
|
- views/edit_template_file.haml
|
@@ -183,4 +185,5 @@ test_files:
|
|
183
185
|
- spec/manuscript/template_file_manager_spec.rb
|
184
186
|
- spec/manuscript/template_file_spec.rb
|
185
187
|
- spec/manuscript/template_manager_spec.rb
|
188
|
+
- spec/manuscript/user_spec.rb
|
186
189
|
- spec/spec_helper.rb
|