starapor-slippers 0.0.3 → 0.0.5
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.yml +1 -1
- data/examples/blog/blog.db +0 -0
- data/examples/blog/controller/main.rb +2 -1
- data/examples/blog/model/entry.rb +1 -0
- data/examples/blog/view/edit.st +2 -0
- data/examples/blog/view/entry.st +2 -2
- data/examples/forms/controller/registration.rb +1 -1
- data/examples/forms/forms.db +0 -0
- data/examples/todolist/{src/controller → controller}/main.rb +2 -2
- data/examples/todolist/{src/element → layout}/page.rb +0 -0
- data/examples/todolist/{src/model.rb → model/tasks.rb} +0 -0
- data/examples/todolist/start.rb +3 -3
- data/examples/todolist/todolist.db +6 -2
- data/examples/todolist/{template → view}/index.st +0 -0
- data/examples/todolist/{template → view}/index.xhtml +0 -0
- data/examples/todolist/{template → view}/new.st +0 -0
- data/examples/todolist/{template → view}/new.xhtml +0 -0
- data/examples/todolist/{template → view}/tasks.st +0 -0
- data/lib/engine/binding_wrapper.rb +4 -0
- data/lib/engine/slippers.treetop +2 -2
- data/lib/engine/template_group.rb +4 -0
- data/lib/ramazeTemplates/slippers.rb +14 -17
- data/spec/parser.rb +6 -0
- metadata +18 -20
- data/examples/todolist/spec/todolist.rb +0 -133
- data/lib/ramazeTemplates/0001-SarahTaraporewalla-adding-new-template-file-for-sli.patch +0 -58
data/VERSION.yml
CHANGED
data/examples/blog/blog.db
CHANGED
Binary file
|
data/examples/blog/view/edit.st
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
<h2>Editing entry</h2>
|
2
2
|
<div id="entries">
|
3
3
|
<div class="entry">
|
4
|
+
$entry:{
|
4
5
|
<form method="post" action="/save">
|
5
6
|
<input name="id" type="hidden" value="$id$"/>
|
6
7
|
<div class="header">
|
@@ -13,5 +14,6 @@
|
|
13
14
|
</div>
|
14
15
|
<input type="submit" value="Update Entry"/>
|
15
16
|
</form>
|
17
|
+
}$
|
16
18
|
</div>
|
17
19
|
</div>
|
data/examples/blog/view/entry.st
CHANGED
@@ -3,8 +3,8 @@
|
|
3
3
|
<div class="title">$title$</div>
|
4
4
|
<div class="created">Created: $created$</div>
|
5
5
|
<ul>
|
6
|
-
<li><a href='/edit/$id$'>edit</li>
|
7
|
-
<li><a href='/delete/$id$'>delete</li>
|
6
|
+
<li><a href='/edit/$id$'>edit</a></li>
|
7
|
+
<li><a href='/delete/$id$'>delete</a></li>
|
8
8
|
</ul>
|
9
9
|
</div>
|
10
10
|
<div class="content">$content$</div>
|
data/examples/forms/forms.db
CHANGED
Binary file
|
@@ -20,7 +20,6 @@ class MainController < Ramaze::Controller
|
|
20
20
|
status = 'not done'
|
21
21
|
toggle = 'close'
|
22
22
|
end
|
23
|
-
delete = A('Delete', :href => Rs(:delete, title))
|
24
23
|
@tasks << {:title => title, :status => status, :resource => title, :toggle => toggle}
|
25
24
|
end
|
26
25
|
@heading = "TodoList"
|
@@ -35,6 +34,7 @@ class MainController < Ramaze::Controller
|
|
35
34
|
redirect '/new'
|
36
35
|
end
|
37
36
|
TodoList[title] = {:done => false}
|
37
|
+
redirect route('/', :title => title)
|
38
38
|
end
|
39
39
|
end
|
40
40
|
|
@@ -51,7 +51,7 @@ class MainController < Ramaze::Controller
|
|
51
51
|
end
|
52
52
|
|
53
53
|
helper :aspect
|
54
|
-
after(:create, :open, :close, :delete){
|
54
|
+
after(:create, :open, :close, :delete){ redirect_referrer }
|
55
55
|
|
56
56
|
private
|
57
57
|
|
File without changes
|
File without changes
|
data/examples/todolist/start.rb
CHANGED
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
data/lib/engine/slippers.treetop
CHANGED
@@ -1,25 +1,22 @@
|
|
1
1
|
require 'slippers'
|
2
2
|
|
3
3
|
module Ramaze
|
4
|
-
module
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
template_group_directory = ::Slippers::TemplateGroupDirectory.new(Global.view_root)
|
4
|
+
module View
|
5
|
+
module Slippers
|
6
|
+
def self.call(action, string)
|
7
|
+
slippers = View.compile(string){|s| ::Slippers::Engine.new(s, :template_group => template_group(action)) }
|
8
|
+
object_to_render = ::Slippers::BindingWrapper.new(action.instance.binding)
|
9
|
+
html = slippers.render(object_to_render)
|
10
|
+
return html, 'text/html'
|
11
|
+
end
|
12
|
+
|
13
|
+
private
|
14
|
+
def self.template_group(action)
|
15
|
+
subtemplates = action.instance.ancestral_trait[:slippers_options] || {}
|
16
|
+
view_root = "#{action.instance.options[:roots]}/#{action.instance.options[:views]}"
|
17
|
+
template_group_directory = ::Slippers::TemplateGroupDirectory.new(view_root)
|
19
18
|
template_group = ::Slippers::TemplateGroup.new(:super_group => template_group_directory, :templates => subtemplates)
|
20
|
-
::Slippers::Engine.new(template, :template_group => template_group)
|
21
19
|
end
|
22
|
-
end
|
23
20
|
end
|
24
21
|
end
|
25
22
|
end
|
data/spec/parser.rb
CHANGED
@@ -57,6 +57,12 @@ describe SlippersParser do
|
|
57
57
|
@parser.parse('${template for this $name$}$').eval(:name => 'fred').should eql('template for this fred')
|
58
58
|
end
|
59
59
|
|
60
|
+
it 'should parse an anonymous subtemplate within an anonymous subtemplate' do
|
61
|
+
stuff = @parser.parse('$cars:{I really like $types:{toyota}$ }$')
|
62
|
+
stuff.eval(:cars => {:types => 'toyota'}) if stuff
|
63
|
+
#.should eql('template for this')
|
64
|
+
end
|
65
|
+
|
60
66
|
it 'should apply the attribute to a subtemplate when parsing it' do
|
61
67
|
subtemplate = Slippers::Engine.new('Hello $first$ $last$')
|
62
68
|
template_group = Slippers::TemplateGroup.new(:templates => {:person => subtemplate})
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: starapor-slippers
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sarah Taraporewalla
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-
|
12
|
+
date: 2009-09-13 00:00:00 -07:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
@@ -55,7 +55,6 @@ files:
|
|
55
55
|
- lib/engine/template_group.rb
|
56
56
|
- lib/engine/template_group_directory.rb
|
57
57
|
- lib/ramazeTemplates
|
58
|
-
- lib/ramazeTemplates/0001-SarahTaraporewalla-adding-new-template-file-for-sli.patch
|
59
58
|
- lib/ramazeTemplates/slippers.rb
|
60
59
|
- lib/slippers.rb
|
61
60
|
- spec/binding_wrapper.rb
|
@@ -146,28 +145,26 @@ files:
|
|
146
145
|
- examples/main_controller.rb
|
147
146
|
- examples/start.rb
|
148
147
|
- examples/todolist
|
148
|
+
- examples/todolist/controller
|
149
|
+
- examples/todolist/controller/main.rb
|
150
|
+
- examples/todolist/layout
|
151
|
+
- examples/todolist/layout/page.rb
|
152
|
+
- examples/todolist/model
|
153
|
+
- examples/todolist/model/tasks.rb
|
149
154
|
- examples/todolist/public
|
150
155
|
- examples/todolist/public/favicon.ico
|
151
156
|
- examples/todolist/public/js
|
152
157
|
- examples/todolist/public/js/jquery.js
|
153
158
|
- examples/todolist/public/ramaze.png
|
154
159
|
- examples/todolist/README
|
155
|
-
- examples/todolist/spec
|
156
|
-
- examples/todolist/spec/todolist.rb
|
157
|
-
- examples/todolist/src
|
158
|
-
- examples/todolist/src/controller
|
159
|
-
- examples/todolist/src/controller/main.rb
|
160
|
-
- examples/todolist/src/element
|
161
|
-
- examples/todolist/src/element/page.rb
|
162
|
-
- examples/todolist/src/model.rb
|
163
160
|
- examples/todolist/start.rb
|
164
|
-
- examples/todolist/template
|
165
|
-
- examples/todolist/template/index.st
|
166
|
-
- examples/todolist/template/index.xhtml
|
167
|
-
- examples/todolist/template/new.st
|
168
|
-
- examples/todolist/template/new.xhtml
|
169
|
-
- examples/todolist/template/tasks.st
|
170
161
|
- examples/todolist/todolist.db
|
162
|
+
- examples/todolist/view
|
163
|
+
- examples/todolist/view/index.st
|
164
|
+
- examples/todolist/view/index.xhtml
|
165
|
+
- examples/todolist/view/new.st
|
166
|
+
- examples/todolist/view/new.xhtml
|
167
|
+
- examples/todolist/view/tasks.st
|
171
168
|
- examples/todolist.db
|
172
169
|
- examples/view
|
173
170
|
- examples/view/index.st
|
@@ -175,8 +172,9 @@ files:
|
|
175
172
|
- examples/view/person/age.st
|
176
173
|
- examples/view/person/index.st
|
177
174
|
- examples/view/person/name.st
|
178
|
-
has_rdoc:
|
175
|
+
has_rdoc: false
|
179
176
|
homepage: http://github.com/starapor/slippers
|
177
|
+
licenses:
|
180
178
|
post_install_message:
|
181
179
|
rdoc_options:
|
182
180
|
- --inline-source
|
@@ -198,9 +196,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
198
196
|
requirements: []
|
199
197
|
|
200
198
|
rubyforge_project:
|
201
|
-
rubygems_version: 1.
|
199
|
+
rubygems_version: 1.3.5
|
202
200
|
signing_key:
|
203
|
-
specification_version:
|
201
|
+
specification_version: 3
|
204
202
|
summary: A strict templating library for Ruby
|
205
203
|
test_files: []
|
206
204
|
|
@@ -1,133 +0,0 @@
|
|
1
|
-
require 'rubygems'
|
2
|
-
require 'ramaze'
|
3
|
-
require 'ramaze/spec/helper'
|
4
|
-
|
5
|
-
spec_require 'hpricot'
|
6
|
-
|
7
|
-
$LOAD_PATH.unshift base = __DIR__('..')
|
8
|
-
require 'start'
|
9
|
-
|
10
|
-
describe 'todolist' do
|
11
|
-
behaves_like 'http'
|
12
|
-
|
13
|
-
def h_get(*args)
|
14
|
-
Hpricot(get(*args).body)
|
15
|
-
end
|
16
|
-
|
17
|
-
def task_titles
|
18
|
-
doc = h_get('/')
|
19
|
-
doc.search("td[@class='title']").
|
20
|
-
map{|t| t.inner_html.strip}.sort
|
21
|
-
end
|
22
|
-
|
23
|
-
def tasks
|
24
|
-
(h_get('/')/:tr)
|
25
|
-
end
|
26
|
-
|
27
|
-
def task(name)
|
28
|
-
tasks.find do |task|
|
29
|
-
(task/:td).find do |td|
|
30
|
-
td['class'] == 'title' and
|
31
|
-
td.inner_html.strip == name
|
32
|
-
end
|
33
|
-
end
|
34
|
-
end
|
35
|
-
|
36
|
-
def spectask
|
37
|
-
task('spectask')
|
38
|
-
end
|
39
|
-
|
40
|
-
def spectask_status
|
41
|
-
spectask.search("td[@class='status']").inner_html.strip
|
42
|
-
end
|
43
|
-
|
44
|
-
def error_on_page(url, response)
|
45
|
-
doc = h_get(url, :cookie => response.headers['Set-Cookie'])
|
46
|
-
|
47
|
-
error = doc.search("div[@class='error']")
|
48
|
-
error.inner_html.strip
|
49
|
-
end
|
50
|
-
|
51
|
-
it 'should start' do
|
52
|
-
ramaze :public_root => base/:public,
|
53
|
-
:view_root => base/:template
|
54
|
-
get('/').status.should == 200
|
55
|
-
end
|
56
|
-
|
57
|
-
it 'should have no empty mainpage' do
|
58
|
-
get('/').body.should.not == nil
|
59
|
-
end
|
60
|
-
|
61
|
-
it 'should have two preset tasks' do
|
62
|
-
task_titles.should == %w[Laundry Wash\ dishes]
|
63
|
-
end
|
64
|
-
|
65
|
-
it 'should have a link to new tasks' do
|
66
|
-
doc = h_get('/')
|
67
|
-
link = (doc/:a).find{|a| a.inner_html == 'New Task'}
|
68
|
-
link['href'].should == '/new'
|
69
|
-
end
|
70
|
-
|
71
|
-
it 'should have a page to create new tasks' do
|
72
|
-
get('/new').body.should.not == nil
|
73
|
-
end
|
74
|
-
|
75
|
-
it 'should have a form to create a tasks on the /new page' do
|
76
|
-
doc = h_get('/new')
|
77
|
-
form = doc.at :form
|
78
|
-
form.should.not == nil
|
79
|
-
input = form.at(:input)
|
80
|
-
input['type'].should == 'text'
|
81
|
-
input['name'].should == 'title'
|
82
|
-
end
|
83
|
-
|
84
|
-
it 'should POST new task and redirect to /' do
|
85
|
-
result = post('/create', 'title' => 'spectask')
|
86
|
-
result.status.should == 302
|
87
|
-
end
|
88
|
-
|
89
|
-
it 'should show have the new task' do
|
90
|
-
task_titles.should.include('spectask')
|
91
|
-
end
|
92
|
-
|
93
|
-
it 'should toggle the spectask' do
|
94
|
-
get('/close/spectask').status.should == 302
|
95
|
-
spectask.should.not == nil
|
96
|
-
spectask_status.should == 'done'
|
97
|
-
get('/open/spectask').status.should == 302
|
98
|
-
spectask.should.not == nil
|
99
|
-
spectask_status.should == 'not done'
|
100
|
-
end
|
101
|
-
|
102
|
-
it 'should raise on modifying a not existing task' do
|
103
|
-
%w[open close].each do |action|
|
104
|
-
response = get("/#{action}/nothere", :referrer => "/")
|
105
|
-
response.status.should == 302
|
106
|
-
response.original_headers['Location'].should == '/'
|
107
|
-
error_on_page('/', response).should == "No such Task: `nothere'"
|
108
|
-
end
|
109
|
-
end
|
110
|
-
|
111
|
-
it 'should delete the new task' do
|
112
|
-
get('/delete/spectask').status.should == 302
|
113
|
-
task_titles.should.not.include('spectask')
|
114
|
-
end
|
115
|
-
|
116
|
-
it 'should not create empty tasks but show a subtle error message' do
|
117
|
-
response = post('/create', 'title' => '', :referrer => "/new")
|
118
|
-
|
119
|
-
response.status.should == 302
|
120
|
-
response.original_headers['Location'].should == '/new'
|
121
|
-
|
122
|
-
error_on_page('/new', response).should == 'Please enter a title'
|
123
|
-
end
|
124
|
-
|
125
|
-
it 'should escape harmful titles' do
|
126
|
-
response = post('/create', 'title' => '#{puts "gotcha"}')
|
127
|
-
|
128
|
-
task('#{puts "gotcha"}').should.be.nil
|
129
|
-
task('#{puts "gotcha"}').should.not.be.nil
|
130
|
-
end
|
131
|
-
|
132
|
-
FileUtils.rm('todolist.db') rescue nil
|
133
|
-
end
|
@@ -1,58 +0,0 @@
|
|
1
|
-
From 5a6c869d4709ce84d7c07b5dd33cf06e39c0111e Mon Sep 17 00:00:00 2001
|
2
|
-
From: Sarah Taraporewalla <sarah.tarap@gmail.com>
|
3
|
-
Date: Mon, 16 Feb 2009 20:44:08 +0000
|
4
|
-
Subject: [PATCH 1] SarahTaraporewalla: adding new template file for slippers template engine
|
5
|
-
|
6
|
-
---
|
7
|
-
lib/ramaze/template.rb | 2 +-
|
8
|
-
2 files changed, 26 insertions(+), 1 deletions(-)
|
9
|
-
|
10
|
-
diff --git a/lib/ramaze/template.rb b/lib/ramaze/template.rb
|
11
|
-
index 096816b..99f1f94 100644
|
12
|
-
--- a/lib/ramaze/template.rb
|
13
|
-
+++ b/lib/ramaze/template.rb
|
14
|
-
@@ -18,7 +18,7 @@ module Ramaze
|
15
|
-
|
16
|
-
AVAILABLE_ENGINES = %w[
|
17
|
-
Amrita2 Builder Erubis Haml Liquid Markaby Maruku Nagoro None RedCloth
|
18
|
-
- Remarkably Sass Tagz Tenjin XSLT
|
19
|
-
+ Remarkably Sass Slippers Tagz Tenjin XSLT
|
20
|
-
]
|
21
|
-
|
22
|
-
AVAILABLE_ENGINES.each do |const|
|
23
|
-
--
|
24
|
-
|
25
|
-
diff --git a/lib/ramaze/template/slippers.rb b/lib/ramaze/template/slippers.rb
|
26
|
-
new file mode 100755
|
27
|
-
index 0000000..e9981b4
|
28
|
-
--- /dev/null
|
29
|
-
+++ b/lib/ramaze/template/slippers.rb
|
30
|
-
@@ -0,0 +1,25 @@
|
31
|
-
+require 'slippers'
|
32
|
-
+
|
33
|
-
+module Ramaze
|
34
|
-
+ module Template
|
35
|
-
+ class Slippers < Template
|
36
|
-
+
|
37
|
-
+ ENGINES[self] = %w[ st ]
|
38
|
-
+ class << self
|
39
|
-
+ def transform(action)
|
40
|
-
+ slippers = wrap_compile(action)
|
41
|
-
+ object_to_render = ::Slippers::BindingWrapper.new(action.binding)
|
42
|
-
+ slippers.render(object_to_render)
|
43
|
-
+ end
|
44
|
-
+
|
45
|
-
+ def compile(action, template)
|
46
|
-
+ subtemplates = action.controller.trait[:slippers_options] || {}
|
47
|
-
+
|
48
|
-
+ template_group_directory = ::Slippers::TemplateGroupDirectory.new(Global.view_root)
|
49
|
-
+ template_group = ::Slippers::TemplateGroup.new(:super_group => template_group_directory, :templates => subtemplates)
|
50
|
-
+ ::Slippers::Engine.new(template, :template_group => template_group)
|
51
|
-
+ end
|
52
|
-
+ end
|
53
|
-
+ end
|
54
|
-
+ end
|
55
|
-
+end
|
56
|
-
--
|
57
|
-
1.6.1
|
58
|
-
|