spirit 0.1.0.pre

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,32 @@
1
+ # ~*~ encoding: utf-8 ~*~
2
+ module Spirit
3
+
4
+ module Render
5
+
6
+ # Base class for all templates. Child classes should provide a +TEMPLATE+
7
+ # string constant that contains the path to the relevant HAML file.
8
+ class Template
9
+
10
+ # Renders the given problem using {#view}.
11
+ # @param [Hash] locals local variables to pass to the template
12
+ def render(locals={})
13
+ view.render Object.new, locals
14
+ end
15
+
16
+ private
17
+
18
+ # Retrieves the +view+ singleton. If it is nil, initializes it from
19
+ # +self.class.TEMPLATE+. Note that this is reloaded with every refresh so
20
+ # I can edit the templates without refreshing.
21
+ # @return [Haml::Engine] haml engine
22
+ def view
23
+ return @view unless @view.nil?
24
+ file = File.join Spirit::VIEWS, self.class::TEMPLATE
25
+ @view = Haml::Engine.new(File.read file, escape_html: true, format: :html5)
26
+ end
27
+
28
+ end
29
+
30
+ end
31
+
32
+ end
@@ -0,0 +1,35 @@
1
+ # ~*~ encoding: utf-8 ~*~
2
+ require 'tilt/template'
3
+ require 'spirit/constants'
4
+
5
+ module Spirit
6
+
7
+ module Tilt
8
+
9
+ # Template adapter for Tilt. This class depends on the tilt gem.
10
+ class Template < ::Tilt::Template
11
+
12
+ self.default_mime_type = 'text/html'
13
+
14
+ def self.engine_initialized?
15
+ defined? Spirit::Render and defined? Spirit::Render::HTML
16
+ end
17
+
18
+ def prepare
19
+ @engine = Spirit::Document.new data, options
20
+ @output = nil
21
+ end
22
+
23
+ def evaluate(scope, locals, &block)
24
+ @output ||= @engine.render
25
+ end
26
+
27
+ def allows_script?
28
+ false
29
+ end
30
+
31
+ end
32
+
33
+ end
34
+
35
+ end
@@ -0,0 +1,4 @@
1
+ # ~*~ encoding: utf-8 ~*~
2
+ module Spirit
3
+ VERSION = '0.1.0.pre'
4
+ end
@@ -0,0 +1,5 @@
1
+ -# coding: UTF-8
2
+ %form{id: id}
3
+ %input.ex-raw{type: 'hidden', value: raw}
4
+ %input.ex-id{type: 'hidden', value: id}
5
+ %a.button.run{href: "#"} Run
@@ -0,0 +1,5 @@
1
+ -# coding: UTF-8
2
+ -haml_tag ('h%d' % level).to_sym do
3
+ %a.anchor{name: name, href: '#' + name, 'data-magellan-destination' => name}
4
+ %i.foundicon-paper-clip
5
+ =text
@@ -0,0 +1,6 @@
1
+ -# coding: UTF-8
2
+ .block-image
3
+ = img
4
+ %p
5
+ %strong Figure #{index}:
6
+ = caption
@@ -0,0 +1,16 @@
1
+ -# coding: UTF-8
2
+ %form.problem{action: 'verify/problem/' + id, 'accept-charset' => 'UTF-8', id: "problem_#{id}", method: 'post'}
3
+ %fieldset
4
+
5
+ %legend Problem #{index}
6
+ %p= question
7
+
8
+ .row.collapse
9
+ .ten.mobile-three.columns
10
+ -options.each do |value, label|
11
+ %label{for: 'answer'}
12
+ %input{name: 'answer', type: 'radio', value: value}
13
+ = label
14
+ .two.mobile-one.columns
15
+ %a.button.submit.small.expand.postfix.radius{href: '#'} Submit
16
+
@@ -0,0 +1,5 @@
1
+ -# coding: UTF-8
2
+ %dl#sections.sub-nav{'data-magellan-expedition' => 'fixed'}
3
+ -sections.each do |name, heading|
4
+ %dd{'data-magellan-arrival' => name}
5
+ %a{href: '#' + name}= heading
@@ -0,0 +1,12 @@
1
+ -# coding: UTF-8
2
+ %form.problem{action: 'verify/problem/' + id, 'accept-charset' => 'UTF-8', id: "problem_#{id}", method: 'post'}
3
+ %fieldset
4
+
5
+ %legend Problem #{index}
6
+ %p= question
7
+
8
+ .row.collapse
9
+ .ten.mobile-three.columns
10
+ %input{name: 'answer', type: 'text'}
11
+ .two.mobile-one.columns
12
+ %a.button.small.submit.expand.postfix.radius{href: '#'} Submit
@@ -0,0 +1,28 @@
1
+ -# coding: UTF-8
2
+ %form.problem{action: 'verify/problem/' + id, 'accept-charset' => 'UTF-8', id: "problem_#{id}", method: 'post'}
3
+ %fieldset
4
+
5
+ %legend Problem #{index}
6
+ %p= question
7
+
8
+ .row
9
+ .twelve.columns
10
+ %table
11
+ %thead
12
+ -if headings
13
+ %tr
14
+ -headings.each do |heading|
15
+ %th= heading
16
+
17
+ %tbody
18
+ -grid.each_with_index do |row, i|
19
+ %tr
20
+ -row.each_with_index do |cell, j|
21
+ %td
22
+ - if Spirit::Render::Table.input? cell
23
+ %input{name: "answer[#{i}][#{j}]", type: 'text'}
24
+ - else
25
+ = cell
26
+ .row
27
+ .two.columns.mobile-one
28
+ %a.button.small.submit.radius{href: '#'} Submit
metadata ADDED
@@ -0,0 +1,256 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: spirit
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0.pre
5
+ prerelease: 6
6
+ platform: ruby
7
+ authors:
8
+ - Jiunn Haur Lim
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2013-01-19 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: haml
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ~>
20
+ - !ruby/object:Gem::Version
21
+ version: '3.1'
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ~>
28
+ - !ruby/object:Gem::Version
29
+ version: '3.1'
30
+ - !ruby/object:Gem::Dependency
31
+ name: redcarpet
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ~>
36
+ - !ruby/object:Gem::Version
37
+ version: '2.2'
38
+ type: :runtime
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ~>
44
+ - !ruby/object:Gem::Version
45
+ version: '2.2'
46
+ - !ruby/object:Gem::Dependency
47
+ name: albino
48
+ requirement: !ruby/object:Gem::Requirement
49
+ none: false
50
+ requirements:
51
+ - - ~>
52
+ - !ruby/object:Gem::Version
53
+ version: '1.3'
54
+ type: :runtime
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ~>
60
+ - !ruby/object:Gem::Version
61
+ version: '1.3'
62
+ - !ruby/object:Gem::Dependency
63
+ name: sanitize
64
+ requirement: !ruby/object:Gem::Requirement
65
+ none: false
66
+ requirements:
67
+ - - ~>
68
+ - !ruby/object:Gem::Version
69
+ version: 2.0.3
70
+ type: :runtime
71
+ prerelease: false
72
+ version_requirements: !ruby/object:Gem::Requirement
73
+ none: false
74
+ requirements:
75
+ - - ~>
76
+ - !ruby/object:Gem::Version
77
+ version: 2.0.3
78
+ - !ruby/object:Gem::Dependency
79
+ name: activesupport
80
+ requirement: !ruby/object:Gem::Requirement
81
+ none: false
82
+ requirements:
83
+ - - ~>
84
+ - !ruby/object:Gem::Version
85
+ version: 3.2.9
86
+ type: :runtime
87
+ prerelease: false
88
+ version_requirements: !ruby/object:Gem::Requirement
89
+ none: false
90
+ requirements:
91
+ - - ~>
92
+ - !ruby/object:Gem::Version
93
+ version: 3.2.9
94
+ - !ruby/object:Gem::Dependency
95
+ name: yard
96
+ requirement: !ruby/object:Gem::Requirement
97
+ none: false
98
+ requirements:
99
+ - - ~>
100
+ - !ruby/object:Gem::Version
101
+ version: 0.8.3
102
+ type: :development
103
+ prerelease: false
104
+ version_requirements: !ruby/object:Gem::Requirement
105
+ none: false
106
+ requirements:
107
+ - - ~>
108
+ - !ruby/object:Gem::Version
109
+ version: 0.8.3
110
+ - !ruby/object:Gem::Dependency
111
+ name: debugger-pry
112
+ requirement: !ruby/object:Gem::Requirement
113
+ none: false
114
+ requirements:
115
+ - - ~>
116
+ - !ruby/object:Gem::Version
117
+ version: 0.1.1
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ none: false
122
+ requirements:
123
+ - - ~>
124
+ - !ruby/object:Gem::Version
125
+ version: 0.1.1
126
+ - !ruby/object:Gem::Dependency
127
+ name: rspec
128
+ requirement: !ruby/object:Gem::Requirement
129
+ none: false
130
+ requirements:
131
+ - - ~>
132
+ - !ruby/object:Gem::Version
133
+ version: 2.12.0
134
+ type: :development
135
+ prerelease: false
136
+ version_requirements: !ruby/object:Gem::Requirement
137
+ none: false
138
+ requirements:
139
+ - - ~>
140
+ - !ruby/object:Gem::Version
141
+ version: 2.12.0
142
+ - !ruby/object:Gem::Dependency
143
+ name: rake
144
+ requirement: !ruby/object:Gem::Requirement
145
+ none: false
146
+ requirements:
147
+ - - ~>
148
+ - !ruby/object:Gem::Version
149
+ version: 10.0.0
150
+ type: :development
151
+ prerelease: false
152
+ version_requirements: !ruby/object:Gem::Requirement
153
+ none: false
154
+ requirements:
155
+ - - ~>
156
+ - !ruby/object:Gem::Version
157
+ version: 10.0.0
158
+ - !ruby/object:Gem::Dependency
159
+ name: factory_girl
160
+ requirement: !ruby/object:Gem::Requirement
161
+ none: false
162
+ requirements:
163
+ - - ~>
164
+ - !ruby/object:Gem::Version
165
+ version: 4.1.0
166
+ type: :development
167
+ prerelease: false
168
+ version_requirements: !ruby/object:Gem::Requirement
169
+ none: false
170
+ requirements:
171
+ - - ~>
172
+ - !ruby/object:Gem::Version
173
+ version: 4.1.0
174
+ - !ruby/object:Gem::Dependency
175
+ name: faker
176
+ requirement: !ruby/object:Gem::Requirement
177
+ none: false
178
+ requirements:
179
+ - - '='
180
+ - !ruby/object:Gem::Version
181
+ version: 1.1.2
182
+ type: :development
183
+ prerelease: false
184
+ version_requirements: !ruby/object:Gem::Requirement
185
+ none: false
186
+ requirements:
187
+ - - '='
188
+ - !ruby/object:Gem::Version
189
+ version: 1.1.2
190
+ description: Parses Genie Markup Language
191
+ email:
192
+ - codex.is.poetry@gmail.com
193
+ executables: []
194
+ extensions: []
195
+ extra_rdoc_files: []
196
+ files:
197
+ - LICENSE
198
+ - README.md
199
+ - lib/spirit/constants.rb
200
+ - lib/spirit/document.rb
201
+ - lib/spirit/errors.rb
202
+ - lib/spirit/logger.rb
203
+ - lib/spirit/manifest.rb
204
+ - lib/spirit/render/errors.rb
205
+ - lib/spirit/render/html.rb
206
+ - lib/spirit/render/sanitize.rb
207
+ - lib/spirit/render/templates/header.rb
208
+ - lib/spirit/render/templates/image.rb
209
+ - lib/spirit/render/templates/multi.rb
210
+ - lib/spirit/render/templates/navigation.rb
211
+ - lib/spirit/render/templates/problem.rb
212
+ - lib/spirit/render/templates/short.rb
213
+ - lib/spirit/render/templates/table.rb
214
+ - lib/spirit/render/templates/template.rb
215
+ - lib/spirit/render/templates.rb
216
+ - lib/spirit/render.rb
217
+ - lib/spirit/tilt/template.rb
218
+ - lib/spirit/version.rb
219
+ - lib/spirit.rb
220
+ - views/exe.haml
221
+ - views/header.haml
222
+ - views/img.haml
223
+ - views/multi.haml
224
+ - views/nav.haml
225
+ - views/short.haml
226
+ - views/table.haml
227
+ homepage: https://github.com/jimjh/genie-parser
228
+ licenses:
229
+ - MIT
230
+ post_install_message:
231
+ rdoc_options: []
232
+ require_paths:
233
+ - lib
234
+ required_ruby_version: !ruby/object:Gem::Requirement
235
+ none: false
236
+ requirements:
237
+ - - ! '>='
238
+ - !ruby/object:Gem::Version
239
+ version: '0'
240
+ segments:
241
+ - 0
242
+ hash: 4141328948887272079
243
+ required_rubygems_version: !ruby/object:Gem::Requirement
244
+ none: false
245
+ requirements:
246
+ - - ! '>'
247
+ - !ruby/object:Gem::Version
248
+ version: 1.3.1
249
+ requirements: []
250
+ rubyforge_project:
251
+ rubygems_version: 1.8.24
252
+ signing_key:
253
+ specification_version: 3
254
+ summary: Parses Genie Markup Language
255
+ test_files: []
256
+ has_rdoc: