amiba 1.0.1 → 1.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/amiba/frontend/app.rb +21 -114
- metadata +28 -28
data/lib/amiba/frontend/app.rb
CHANGED
@@ -40,19 +40,6 @@ module Protozoa
|
|
40
40
|
enable :logging, :raise_errors, :dump_errors
|
41
41
|
end
|
42
42
|
|
43
|
-
helpers do
|
44
|
-
def all_pages
|
45
|
-
Dir.glob('pages/**/[^_]*').inject([]) do |acc, page_file|
|
46
|
-
if !File.directory? page_file
|
47
|
-
page = Amiba::Source::Page.new(File.relpath(page_file, "pages"))
|
48
|
-
ent = Amiba::Source::PageEntry.new(page)
|
49
|
-
acc << page unless ent.new?
|
50
|
-
end
|
51
|
-
acc
|
52
|
-
end
|
53
|
-
end
|
54
|
-
end
|
55
|
-
|
56
43
|
get '/' do
|
57
44
|
pull
|
58
45
|
@entries = Amiba::Source::Entry.any.all.sort {|a,b| a.category <=> b.category }
|
@@ -102,7 +89,7 @@ module Protozoa
|
|
102
89
|
@entry.save do |filename, file_data|
|
103
90
|
File.open(filename, 'w') { |f| f.write(file_data) }
|
104
91
|
end
|
105
|
-
|
92
|
+
commit @entry.filename
|
106
93
|
push
|
107
94
|
redirect "/pages#{@page.link}"
|
108
95
|
end
|
@@ -115,7 +102,7 @@ module Protozoa
|
|
115
102
|
@page.save do |filename, file_data|
|
116
103
|
File.open(filename, 'w') { |f| f.write(file_data) }
|
117
104
|
end
|
118
|
-
|
105
|
+
commit @page.filename
|
119
106
|
push
|
120
107
|
redirect "/entries#{@page.link}"
|
121
108
|
end
|
@@ -144,120 +131,40 @@ module Protozoa
|
|
144
131
|
@page.save do |filename, file_data|
|
145
132
|
File.open(filename, 'w') { |f| f.write(file_data) }
|
146
133
|
end
|
147
|
-
|
134
|
+
commit @page.filename
|
148
135
|
push
|
149
136
|
redirect "/entries#{@page.link}"
|
150
137
|
end
|
151
138
|
|
152
|
-
# post '/revert/:page/*' do
|
153
|
-
# wiki = Gollum::Wiki.new(settings.gollum_path, settings.wiki_options)
|
154
|
-
# @name = params[:page]
|
155
|
-
# @page = wiki.page(@name)
|
156
|
-
# shas = params[:splat].first.split("/")
|
157
|
-
# sha1 = shas.shift
|
158
|
-
# sha2 = shas.shift
|
159
|
-
|
160
|
-
# if wiki.revert_page(@page, sha1, sha2, commit_message)
|
161
|
-
# redirect "/#{CGI.escape(@name)}"
|
162
|
-
# else
|
163
|
-
# sha2, sha1 = sha1, "#{sha1}^" if !sha2
|
164
|
-
# @versions = [sha1, sha2]
|
165
|
-
# diffs = wiki.repo.diff(@versions.first, @versions.last, @page.path)
|
166
|
-
# @diff = diffs.first
|
167
|
-
# @message = "The patch does not apply."
|
168
|
-
# mustache :compare
|
169
|
-
# end
|
170
|
-
# end
|
171
|
-
|
172
|
-
# get '/history/:name' do
|
173
|
-
# @name = params[:name]
|
174
|
-
# wiki = Gollum::Wiki.new(settings.gollum_path, settings.wiki_options)
|
175
|
-
# @page = wiki.page(@name)
|
176
|
-
# @page_num = [params[:page].to_i, 1].max
|
177
|
-
# @versions = @page.versions :page => @page_num
|
178
|
-
# mustache :history
|
179
|
-
# end
|
180
|
-
|
181
|
-
# post '/compare/:name' do
|
182
|
-
# @versions = params[:versions] || []
|
183
|
-
# if @versions.size < 2
|
184
|
-
# redirect "/history/#{CGI.escape(params[:name])}"
|
185
|
-
# else
|
186
|
-
# redirect "/compare/%s/%s...%s" % [
|
187
|
-
# CGI.escape(params[:name]),
|
188
|
-
# @versions.last,
|
189
|
-
# @versions.first]
|
190
|
-
# end
|
191
|
-
# end
|
192
|
-
|
193
|
-
# get '/compare/:name/:version_list' do
|
194
|
-
# @name = params[:name]
|
195
|
-
# @versions = params[:version_list].split(/\.{2,3}/)
|
196
|
-
# wiki = Gollum::Wiki.new(settings.gollum_path, settings.wiki_options)
|
197
|
-
# @page = wiki.page(@name)
|
198
|
-
# diffs = wiki.repo.diff(@versions.first, @versions.last, @page.path)
|
199
|
-
# @diff = diffs.first
|
200
|
-
# mustache :compare
|
201
|
-
# end
|
202
|
-
|
203
139
|
get %r{^/(javascript|css|images)} do
|
204
140
|
halt 404
|
205
141
|
end
|
206
142
|
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
mustache :page
|
216
|
-
else
|
217
|
-
halt 404
|
143
|
+
def all_pages
|
144
|
+
Dir.glob('pages/**/[^_]*').inject([]) do |acc, page_file|
|
145
|
+
if !File.directory? page_file
|
146
|
+
page = Amiba::Source::Page.new(File.relpath(page_file, "pages"))
|
147
|
+
ent = Amiba::Source::PageEntry.new(page)
|
148
|
+
acc << page unless ent.new?
|
149
|
+
end
|
150
|
+
acc
|
218
151
|
end
|
219
152
|
end
|
220
153
|
|
221
|
-
|
222
|
-
|
223
|
-
# wiki = Gollum::Wiki.new(settings.gollum_path, settings.wiki_options)
|
224
|
-
# @results = wiki.search @query
|
225
|
-
# @name = @query
|
226
|
-
# mustache :search
|
227
|
-
# end
|
228
|
-
|
229
|
-
# get '/*' do
|
230
|
-
# show_page_or_file(params[:splat].first)
|
231
|
-
# end
|
232
|
-
|
233
|
-
def show_page_or_file(name)
|
234
|
-
wiki = Gollum::Wiki.new(settings.gollum_path, settings.wiki_options)
|
235
|
-
if page = wiki.page(name)
|
236
|
-
@page = page
|
237
|
-
@name = name
|
238
|
-
@content = page.formatted_data
|
239
|
-
@editable = true
|
240
|
-
mustache :page
|
241
|
-
elsif file = wiki.file(name)
|
242
|
-
content_type file.mime_type
|
243
|
-
file.raw_data
|
244
|
-
else
|
245
|
-
@name = name
|
246
|
-
mustache :create
|
247
|
-
end
|
154
|
+
def commit_message
|
155
|
+
{ :message => params[:message] }
|
248
156
|
end
|
249
157
|
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
name ||= page.name
|
254
|
-
format = (format || page.format).to_sym
|
255
|
-
content ||= page.raw_data
|
256
|
-
wiki.update_page(page, name, format, content.to_s, commit_message)
|
158
|
+
# dsci specific
|
159
|
+
def actor
|
160
|
+
Grit::Actor.new(env["X-DSCI-USER"],env["X-DSCI-EMAIL"])
|
257
161
|
end
|
258
162
|
|
259
|
-
def
|
260
|
-
|
163
|
+
def commit(filename)
|
164
|
+
r = Grit::Repo.new(Dir.pwd)
|
165
|
+
r.add(filename)
|
166
|
+
r.index.commit(commit_message, nil, actor)
|
261
167
|
end
|
168
|
+
|
262
169
|
end
|
263
170
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: amiba
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -10,11 +10,11 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2011-08-
|
13
|
+
date: 2011-08-24 00:00:00.000000000Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: thor
|
17
|
-
requirement: &
|
17
|
+
requirement: &70301715141680 !ruby/object:Gem::Requirement
|
18
18
|
none: false
|
19
19
|
requirements:
|
20
20
|
- - ~>
|
@@ -22,10 +22,10 @@ dependencies:
|
|
22
22
|
version: 0.14.6
|
23
23
|
type: :runtime
|
24
24
|
prerelease: false
|
25
|
-
version_requirements: *
|
25
|
+
version_requirements: *70301715141680
|
26
26
|
- !ruby/object:Gem::Dependency
|
27
27
|
name: tilt
|
28
|
-
requirement: &
|
28
|
+
requirement: &70301715171080 !ruby/object:Gem::Requirement
|
29
29
|
none: false
|
30
30
|
requirements:
|
31
31
|
- - ~>
|
@@ -33,10 +33,10 @@ dependencies:
|
|
33
33
|
version: 1.3.2
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
|
-
version_requirements: *
|
36
|
+
version_requirements: *70301715171080
|
37
37
|
- !ruby/object:Gem::Dependency
|
38
38
|
name: haml
|
39
|
-
requirement: &
|
39
|
+
requirement: &70301715187960 !ruby/object:Gem::Requirement
|
40
40
|
none: false
|
41
41
|
requirements:
|
42
42
|
- - ~>
|
@@ -44,10 +44,10 @@ dependencies:
|
|
44
44
|
version: 3.0.25
|
45
45
|
type: :runtime
|
46
46
|
prerelease: false
|
47
|
-
version_requirements: *
|
47
|
+
version_requirements: *70301715187960
|
48
48
|
- !ruby/object:Gem::Dependency
|
49
49
|
name: activemodel
|
50
|
-
requirement: &
|
50
|
+
requirement: &70301715197140 !ruby/object:Gem::Requirement
|
51
51
|
none: false
|
52
52
|
requirements:
|
53
53
|
- - ~>
|
@@ -55,10 +55,10 @@ dependencies:
|
|
55
55
|
version: 3.0.4
|
56
56
|
type: :runtime
|
57
57
|
prerelease: false
|
58
|
-
version_requirements: *
|
58
|
+
version_requirements: *70301715197140
|
59
59
|
- !ruby/object:Gem::Dependency
|
60
60
|
name: i18n
|
61
|
-
requirement: &
|
61
|
+
requirement: &70301715202580 !ruby/object:Gem::Requirement
|
62
62
|
none: false
|
63
63
|
requirements:
|
64
64
|
- - ~>
|
@@ -66,10 +66,10 @@ dependencies:
|
|
66
66
|
version: 0.5.0
|
67
67
|
type: :runtime
|
68
68
|
prerelease: false
|
69
|
-
version_requirements: *
|
69
|
+
version_requirements: *70301715202580
|
70
70
|
- !ruby/object:Gem::Dependency
|
71
71
|
name: redcarpet
|
72
|
-
requirement: &
|
72
|
+
requirement: &70301715210920 !ruby/object:Gem::Requirement
|
73
73
|
none: false
|
74
74
|
requirements:
|
75
75
|
- - ! '>='
|
@@ -77,10 +77,10 @@ dependencies:
|
|
77
77
|
version: '0'
|
78
78
|
type: :runtime
|
79
79
|
prerelease: false
|
80
|
-
version_requirements: *
|
80
|
+
version_requirements: *70301715210920
|
81
81
|
- !ruby/object:Gem::Dependency
|
82
82
|
name: rdiscount
|
83
|
-
requirement: &
|
83
|
+
requirement: &70301715406280 !ruby/object:Gem::Requirement
|
84
84
|
none: false
|
85
85
|
requirements:
|
86
86
|
- - ! '>='
|
@@ -88,10 +88,10 @@ dependencies:
|
|
88
88
|
version: '0'
|
89
89
|
type: :runtime
|
90
90
|
prerelease: false
|
91
|
-
version_requirements: *
|
91
|
+
version_requirements: *70301715406280
|
92
92
|
- !ruby/object:Gem::Dependency
|
93
93
|
name: fog
|
94
|
-
requirement: &
|
94
|
+
requirement: &70301715535740 !ruby/object:Gem::Requirement
|
95
95
|
none: false
|
96
96
|
requirements:
|
97
97
|
- - ! '>='
|
@@ -99,10 +99,10 @@ dependencies:
|
|
99
99
|
version: 0.7.0
|
100
100
|
type: :runtime
|
101
101
|
prerelease: false
|
102
|
-
version_requirements: *
|
102
|
+
version_requirements: *70301715535740
|
103
103
|
- !ruby/object:Gem::Dependency
|
104
104
|
name: grit
|
105
|
-
requirement: &
|
105
|
+
requirement: &70301715686320 !ruby/object:Gem::Requirement
|
106
106
|
none: false
|
107
107
|
requirements:
|
108
108
|
- - ~>
|
@@ -110,10 +110,10 @@ dependencies:
|
|
110
110
|
version: 2.4.1
|
111
111
|
type: :runtime
|
112
112
|
prerelease: false
|
113
|
-
version_requirements: *
|
113
|
+
version_requirements: *70301715686320
|
114
114
|
- !ruby/object:Gem::Dependency
|
115
115
|
name: rspec
|
116
|
-
requirement: &
|
116
|
+
requirement: &70301715791360 !ruby/object:Gem::Requirement
|
117
117
|
none: false
|
118
118
|
requirements:
|
119
119
|
- - ! '>='
|
@@ -121,10 +121,10 @@ dependencies:
|
|
121
121
|
version: '0'
|
122
122
|
type: :development
|
123
123
|
prerelease: false
|
124
|
-
version_requirements: *
|
124
|
+
version_requirements: *70301715791360
|
125
125
|
- !ruby/object:Gem::Dependency
|
126
126
|
name: rspec_tag_matchers
|
127
|
-
requirement: &
|
127
|
+
requirement: &70301715878280 !ruby/object:Gem::Requirement
|
128
128
|
none: false
|
129
129
|
requirements:
|
130
130
|
- - ! '>='
|
@@ -132,10 +132,10 @@ dependencies:
|
|
132
132
|
version: '0'
|
133
133
|
type: :development
|
134
134
|
prerelease: false
|
135
|
-
version_requirements: *
|
135
|
+
version_requirements: *70301715878280
|
136
136
|
- !ruby/object:Gem::Dependency
|
137
137
|
name: autotest
|
138
|
-
requirement: &
|
138
|
+
requirement: &70301715937820 !ruby/object:Gem::Requirement
|
139
139
|
none: false
|
140
140
|
requirements:
|
141
141
|
- - ! '>='
|
@@ -143,10 +143,10 @@ dependencies:
|
|
143
143
|
version: '0'
|
144
144
|
type: :development
|
145
145
|
prerelease: false
|
146
|
-
version_requirements: *
|
146
|
+
version_requirements: *70301715937820
|
147
147
|
- !ruby/object:Gem::Dependency
|
148
148
|
name: factory_girl
|
149
|
-
requirement: &
|
149
|
+
requirement: &70301719523980 !ruby/object:Gem::Requirement
|
150
150
|
none: false
|
151
151
|
requirements:
|
152
152
|
- - ! '>='
|
@@ -154,7 +154,7 @@ dependencies:
|
|
154
154
|
version: 2.0.0.beta1
|
155
155
|
type: :development
|
156
156
|
prerelease: false
|
157
|
-
version_requirements: *
|
157
|
+
version_requirements: *70301719523980
|
158
158
|
description: Description TBD
|
159
159
|
email:
|
160
160
|
- s.mohapi-banks@digital-science.com
|