olelo 0.9.3 → 0.9.4
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/.travis.yml +4 -0
- data/Rakefile +6 -12
- data/bin/olelo +13 -8
- data/config.ru +21 -15
- data/config/aspects.rb +45 -32
- data/config/config.yml.default +1 -0
- data/config/initializers/00-mime_types.rb +22 -17
- data/config/initializers/01-slim.rb +2 -2
- data/lib/olelo.rb +1 -8
- data/lib/olelo/application.rb +33 -34
- data/lib/olelo/attributes.rb +4 -4
- data/lib/olelo/extensions.rb +0 -7
- data/lib/olelo/helper.rb +13 -25
- data/lib/olelo/html_safe.rb +0 -4
- data/lib/olelo/locale.yml +6 -3
- data/lib/olelo/menu.rb +1 -1
- data/lib/olelo/page.rb +21 -18
- data/lib/olelo/version.rb +1 -1
- data/olelo.gemspec +5 -3
- data/plugins/aspects/changelog.rb +5 -5
- data/plugins/aspects/documentbrowser.rb +5 -5
- data/plugins/{gallery → aspects/gallery}/gallery.css +0 -0
- data/plugins/{gallery → aspects/gallery}/gallery.scss +0 -0
- data/plugins/{gallery → aspects/gallery}/main.rb +3 -3
- data/plugins/aspects/highlight.rb +1 -1
- data/plugins/aspects/image.rb +1 -1
- data/plugins/aspects/imageinfo.rb +3 -3
- data/plugins/aspects/main.rb +21 -21
- data/plugins/aspects/pageinfo.rb +2 -2
- data/plugins/aspects/source.rb +1 -1
- data/plugins/aspects/subpages.rb +7 -7
- data/plugins/aspects/text.rb +1 -1
- data/plugins/authentication/portal.rb +2 -2
- data/plugins/authentication/yamlfile.rb +1 -1
- data/plugins/blog/main.rb +10 -10
- data/plugins/editor/preview.rb +3 -3
- data/plugins/filters/creole.rb +1 -1
- data/plugins/filters/editsection.rb +2 -2
- data/plugins/filters/html2xml.rb +6 -0
- data/plugins/filters/main.rb +1 -1
- data/plugins/filters/remind/main.rb +15 -0
- data/plugins/filters/remind/rem2html +562 -0
- data/plugins/filters/s5/main.rb +1 -1
- data/plugins/login/persistent.rb +1 -1
- data/plugins/misc/system.rb +4 -0
- data/plugins/misc/variables.rb +1 -1
- data/plugins/misc/webdav.rb +10 -10
- data/plugins/repositories/git_grep.rb +2 -2
- data/plugins/repositories/gitrb_repository.rb +10 -10
- data/plugins/repositories/rugged_repository.rb +7 -7
- data/plugins/tags/code.rb +1 -1
- data/plugins/tags/footnotes.rb +4 -3
- data/plugins/tags/gist.rb +2 -2
- data/plugins/tags/html.rb +11 -11
- data/plugins/tags/include.rb +6 -6
- data/plugins/tags/main.rb +10 -10
- data/plugins/tags/math.rb +2 -2
- data/plugins/tags/redirect.rb +3 -3
- data/plugins/tags/scripting.rb +12 -12
- data/plugins/tags/sort.rb +1 -1
- data/plugins/tags/tabs.rb +1 -1
- data/plugins/treeview/main.rb +3 -3
- data/plugins/treeview/script.js +5 -5
- data/plugins/treeview/script/00-jquery.treeview.js +6 -6
- data/plugins/treeview/script/init.js +1 -1
- data/plugins/utils/assets.rb +4 -4
- data/plugins/utils/cache.rb +10 -6
- data/plugins/utils/store.rb +4 -4
- data/static/script.js +124 -126
- data/static/script/{02-jquery.js → 01-jquery.js} +0 -0
- data/static/script/02-olelo.storage.js +54 -0
- data/static/script/10-olelo.historytable.js +2 -2
- data/static/script/13-olelo.tabwidget.js +2 -2
- data/test/helper.rb +5 -4
- data/test/page_test.rb +1 -1
- data/test/request_test.rb +42 -38
- data/test/string_extensions_test.rb +0 -6
- data/test/templates_test.rb +1 -1
- data/test/util_test.rb +1 -1
- data/views/changes.slim +2 -2
- data/views/compare.slim +4 -4
- data/views/delete.slim +2 -2
- data/views/deleted.slim +1 -1
- data/views/edit.slim +31 -26
- data/views/history.slim +5 -5
- data/views/layout.slim +1 -1
- data/views/login.slim +30 -32
- data/views/move.slim +3 -3
- data/views/profile.slim +2 -2
- data/views/show.slim +1 -1
- metadata +43 -104
- data/static/script/01-jstorage.js +0 -217
data/lib/olelo/application.rb
CHANGED
@@ -7,7 +7,7 @@ module Olelo
|
|
7
7
|
include Routing
|
8
8
|
include ApplicationHelper
|
9
9
|
|
10
|
-
patterns :
|
10
|
+
patterns path: Page::PATH_PATTERN
|
11
11
|
attr_reader :page
|
12
12
|
attr_setter :on_error
|
13
13
|
|
@@ -31,8 +31,6 @@ module Olelo
|
|
31
31
|
|
32
32
|
# Executed before each request
|
33
33
|
before :routing do
|
34
|
-
Olelo.logger.debug env
|
35
|
-
|
36
34
|
User.current = User.find(session[:olelo_user])
|
37
35
|
if !User.current
|
38
36
|
invoke_hook(:auto_login)
|
@@ -54,23 +52,23 @@ module Olelo
|
|
54
52
|
|
55
53
|
hook :menu do |menu|
|
56
54
|
if menu.name == :actions && page && !page.new?
|
57
|
-
menu.item(:view, :
|
58
|
-
edit_menu = menu.item(:edit, :
|
59
|
-
edit_menu.item(:new, :
|
55
|
+
menu.item(:view, href: build_path(page.path), accesskey: 'v')
|
56
|
+
edit_menu = menu.item(:edit, href: build_path(page, action: :edit), accesskey: 'e', rel: 'nofollow')
|
57
|
+
edit_menu.item(:new, href: build_path(page, action: :new), accesskey: 'n', rel: 'nofollow')
|
60
58
|
if !page.root?
|
61
|
-
edit_menu.item(:move, :
|
62
|
-
edit_menu.item(:delete, :
|
59
|
+
edit_menu.item(:move, href: build_path(page, action: :move), rel: 'nofollow')
|
60
|
+
edit_menu.item(:delete, href: build_path(page, action: :delete), rel: 'nofollow')
|
63
61
|
end
|
64
|
-
history_menu = menu.item(:history, :
|
62
|
+
history_menu = menu.item(:history, href: build_path(page, action: :history), accesskey: 'h')
|
65
63
|
|
66
64
|
if @menu_versions
|
67
65
|
head = !page.head? && (Olelo::Page.find(page.path) rescue nil)
|
68
66
|
if page.previous_version || head || page.next_version
|
69
|
-
history_menu.item(:older, :
|
70
|
-
:
|
71
|
-
history_menu.item(:head, :
|
72
|
-
history_menu.item(:newer, :
|
73
|
-
:
|
67
|
+
history_menu.item(:older, href: build_path(page, original_params.merge(version: page.previous_version)),
|
68
|
+
accesskey: 'o') if page.previous_version
|
69
|
+
history_menu.item(:head, href: build_path(page.path, original_params), accesskey: 'c') if head
|
70
|
+
history_menu.item(:newer, href: build_path(page, original_params.merge(version: page.next_version)),
|
71
|
+
accesskey: 'n') if page.next_version
|
74
72
|
end
|
75
73
|
end
|
76
74
|
end
|
@@ -79,8 +77,8 @@ module Olelo
|
|
79
77
|
# Handle 404s
|
80
78
|
error NotFound do |error|
|
81
79
|
Olelo.logger.debug(error)
|
82
|
-
cache_control :
|
83
|
-
halt render(:not_found, :
|
80
|
+
cache_control no_cache: true
|
81
|
+
halt render(:not_found, locals: {error: error})
|
84
82
|
end
|
85
83
|
|
86
84
|
error StandardError do |error|
|
@@ -94,8 +92,8 @@ module Olelo
|
|
94
92
|
# Show wiki error page
|
95
93
|
error Exception do |error|
|
96
94
|
Olelo.logger.error(error)
|
97
|
-
cache_control :
|
98
|
-
halt render(:error, :
|
95
|
+
cache_control no_cache: true
|
96
|
+
halt render(:error, locals: {error: error})
|
99
97
|
end
|
100
98
|
|
101
99
|
get '/login' do
|
@@ -150,7 +148,7 @@ module Olelo
|
|
150
148
|
raise NotFound
|
151
149
|
end
|
152
150
|
@version = @diff.to
|
153
|
-
cache_control :
|
151
|
+
cache_control version: @version
|
154
152
|
render :changes
|
155
153
|
end
|
156
154
|
|
@@ -162,7 +160,7 @@ module Olelo
|
|
162
160
|
@history = page.history((@page_nr - 1) * per_page, limit)
|
163
161
|
@page_count = @page_nr + @history.length / per_page
|
164
162
|
@history = @history[0...per_page]
|
165
|
-
cache_control :
|
163
|
+
cache_control version: page.version
|
166
164
|
render :history
|
167
165
|
end
|
168
166
|
|
@@ -183,12 +181,12 @@ module Olelo
|
|
183
181
|
destination = params[:destination].cleanpath
|
184
182
|
raise :reserved_path.t if self.class.reserved_path?(destination)
|
185
183
|
page.move(destination)
|
186
|
-
Page.commit(:page_moved.t(:
|
184
|
+
Page.commit(:page_moved.t(page: page.path, destination: destination))
|
187
185
|
redirect build_path(page.path)
|
188
186
|
end
|
189
187
|
end
|
190
188
|
|
191
|
-
get '/compare/:versions(/:path)', :
|
189
|
+
get '/compare/:versions(/:path)', versions: '(?:\w+)\.{2,3}(?:\w+)' do
|
192
190
|
@page = Page.find!(params[:path])
|
193
191
|
versions = params[:versions].split(/\.{2,3}/)
|
194
192
|
begin
|
@@ -202,11 +200,12 @@ module Olelo
|
|
202
200
|
|
203
201
|
get '/compare(/:path)' do
|
204
202
|
versions = params[:versions] || []
|
205
|
-
redirect build_path(params[:path], :
|
203
|
+
redirect build_path(params[:path], action: versions.size < 2 ? :history : "compare/#{versions.first}...#{versions.last}")
|
206
204
|
end
|
207
205
|
|
208
206
|
get '/edit(/:path)' do
|
209
207
|
@page = Page.find!(params[:path])
|
208
|
+
flash.info!(:info_binary.t(page: page.title, type: "#{page.mime.comment} (#{page.mime})")) unless page.mime.text?
|
210
209
|
render :edit
|
211
210
|
end
|
212
211
|
|
@@ -220,7 +219,7 @@ module Olelo
|
|
220
219
|
def post_edit
|
221
220
|
raise 'No content' if !params[:content]
|
222
221
|
params[:content].gsub!("\r\n", "\n")
|
223
|
-
message = :page_edited.t(:
|
222
|
+
message = :page_edited.t(page: page.title)
|
224
223
|
message << " - #{params[:comment]}" if !params[:comment].blank?
|
225
224
|
|
226
225
|
page.content = if params[:pos]
|
@@ -249,7 +248,7 @@ module Olelo
|
|
249
248
|
errors << :no_changes.t if !page.modified?
|
250
249
|
end
|
251
250
|
page.save
|
252
|
-
Page.commit(:page_uploaded.t(:
|
251
|
+
Page.commit(:page_uploaded.t(page: page.title))
|
253
252
|
end
|
254
253
|
|
255
254
|
def post_attributes
|
@@ -260,31 +259,31 @@ module Olelo
|
|
260
259
|
errors << :no_changes.t if !page.modified?
|
261
260
|
end
|
262
261
|
page.save
|
263
|
-
Page.commit(:attributes_edited.t(:
|
262
|
+
Page.commit(:attributes_edited.t(page: page.title))
|
264
263
|
end
|
265
264
|
|
266
265
|
def show_page
|
267
266
|
@menu_versions = true
|
268
|
-
render(:show, :
|
267
|
+
render(:show, locals: {content: page.try(:content)})
|
269
268
|
end
|
270
269
|
|
271
|
-
get '/(:path)', :
|
270
|
+
get '/(:path)', tail: true do
|
272
271
|
begin
|
273
272
|
@page = Page.find!(params[:path])
|
274
|
-
cache_control :
|
273
|
+
cache_control version: page.version
|
275
274
|
show_page
|
276
275
|
rescue NotFound
|
277
|
-
redirect build_path(params[:path], :
|
276
|
+
redirect build_path(params[:path], action: :new)
|
278
277
|
end
|
279
278
|
end
|
280
279
|
|
281
280
|
get '/version/:version(/:path)' do
|
282
281
|
@page = Page.find!(params[:path], params[:version])
|
283
|
-
cache_control :
|
282
|
+
cache_control version: page.version
|
284
283
|
show_page
|
285
284
|
end
|
286
285
|
|
287
|
-
post '/(:path)', :
|
286
|
+
post '/(:path)', tail: true do
|
288
287
|
action, @close = params[:action].to_s.split('-', 2)
|
289
288
|
if respond_to? "post_#{action}"
|
290
289
|
on_error :edit
|
@@ -306,12 +305,12 @@ module Olelo
|
|
306
305
|
end
|
307
306
|
end
|
308
307
|
|
309
|
-
delete '/:path', :
|
308
|
+
delete '/:path', tail: true do
|
310
309
|
Page.transaction do
|
311
310
|
@page = Page.find!(params[:path])
|
312
311
|
on_error :delete
|
313
312
|
page.delete
|
314
|
-
Page.commit(:page_deleted.t(:
|
313
|
+
Page.commit(:page_deleted.t(page: page.path))
|
315
314
|
render :deleted
|
316
315
|
end
|
317
316
|
end
|
data/lib/olelo/attributes.rb
CHANGED
@@ -19,12 +19,12 @@ module Olelo
|
|
19
19
|
end
|
20
20
|
|
21
21
|
def label
|
22
|
-
@label ||= Locale.translate(key, :
|
22
|
+
@label ||= Locale.translate(key, fallback: titlecase(name))
|
23
23
|
end
|
24
24
|
|
25
25
|
def label_tag
|
26
26
|
type = self.class.name.split('::').last.downcase
|
27
|
-
title = Locale.translate("type_#{type}", :
|
27
|
+
title = Locale.translate("type_#{type}", fallback: titlecase(type))
|
28
28
|
%{<label for="#{key}" title="#{escape_html title}">#{escape_html label}</label>}
|
29
29
|
end
|
30
30
|
|
@@ -119,7 +119,7 @@ module Olelo
|
|
119
119
|
def field_tag(attr)
|
120
120
|
%{<input class="observe" type="text" id="#{key}" name="#{key}" value="#{escape_html(values[attr] || attr)}"/>
|
121
121
|
<script type="text/javascript">
|
122
|
-
$('##{key}').combobox({ source: #{escape_javascript values.values.sort
|
122
|
+
$('##{key}').combobox({ source: #{escape_javascript MultiJson.dump(values.values.sort)} });
|
123
123
|
</script>}
|
124
124
|
end
|
125
125
|
|
@@ -149,7 +149,7 @@ module Olelo
|
|
149
149
|
end
|
150
150
|
|
151
151
|
def label
|
152
|
-
@label ||= name.blank? ? '' : Locale.translate("group_#{path}", :
|
152
|
+
@label ||= name.blank? ? '' : Locale.translate("group_#{path}", fallback: titlecase(name))
|
153
153
|
end
|
154
154
|
|
155
155
|
# Build form for this group
|
data/lib/olelo/extensions.rb
CHANGED
@@ -157,14 +157,7 @@ class Object
|
|
157
157
|
end
|
158
158
|
end
|
159
159
|
|
160
|
-
class NilClass; def blank?; true; end; end
|
161
|
-
class FalseClass; def blank?; true; end; end
|
162
|
-
class TrueClass; def blank?; false; end; end
|
163
|
-
|
164
160
|
class String
|
165
|
-
# Faster blank?
|
166
|
-
alias blank? empty?
|
167
|
-
|
168
161
|
# Try to force encoding
|
169
162
|
#
|
170
163
|
# Force encoding of string and revert
|
data/lib/olelo/helper.rb
CHANGED
@@ -34,11 +34,9 @@ module Olelo
|
|
34
34
|
env['olelo.flash']
|
35
35
|
end
|
36
36
|
|
37
|
-
def flash_messages
|
38
|
-
|
39
|
-
|
40
|
-
%{<ul class="flash">#{li.join}</ul>}.html_safe if !li.empty?
|
41
|
-
end
|
37
|
+
def flash_messages
|
38
|
+
li = [:error, :warn, :info].map {|level| flash[level].to_a.map {|msg| %{<li class="#{level}">#{escape_html msg}</li>} } }.flatten
|
39
|
+
%{<ul class="flash">#{li.join}</ul>}.html_safe if !li.empty?
|
42
40
|
end
|
43
41
|
end
|
44
42
|
|
@@ -50,7 +48,7 @@ module Olelo
|
|
50
48
|
if page
|
51
49
|
render_page(page)
|
52
50
|
else
|
53
|
-
%{<a href="#{escape_html build_path(path, :
|
51
|
+
%{<a href="#{escape_html build_path(path, action: :new)}">#{escape_html :create_page.t(page: path)}</a>}
|
54
52
|
end
|
55
53
|
end
|
56
54
|
|
@@ -62,7 +60,7 @@ module Olelo
|
|
62
60
|
return if page_count <= 1
|
63
61
|
li = []
|
64
62
|
li << if page_nr > 1
|
65
|
-
%{<a href="#{escape_html build_path(path, options.merge(:
|
63
|
+
%{<a href="#{escape_html build_path(path, options.merge(page: page_nr - 1))}">◂</a>}
|
66
64
|
else
|
67
65
|
%{<span class="disabled">◂</span>}
|
68
66
|
end
|
@@ -76,20 +74,20 @@ module Olelo
|
|
76
74
|
max = max + 2 < page_count ? max : page_count
|
77
75
|
min = min > 3 ? min : 1
|
78
76
|
if min != 1
|
79
|
-
li << %{<a href="#{escape_html build_path(path, options.merge(:
|
77
|
+
li << %{<a href="#{escape_html build_path(path, options.merge(page: 1))}">1</a>} << %{<span class="ellipsis"/>}
|
80
78
|
end
|
81
79
|
(min..max).each do |i|
|
82
80
|
li << if i == page_nr
|
83
81
|
%{<span class="current">#{i}</span>}
|
84
82
|
else
|
85
|
-
%{<a href="#{escape_html build_path(path, options.merge(:
|
83
|
+
%{<a href="#{escape_html build_path(path, options.merge(page: i))}">#{i}</a>}
|
86
84
|
end
|
87
85
|
end
|
88
86
|
if max != page_count
|
89
|
-
li << %{<span class="ellipsis"/>} << %{<a href="#{escape_html build_path(path, options.merge(:
|
87
|
+
li << %{<span class="ellipsis"/>} << %{<a href="#{escape_html build_path(path, options.merge(page: page_count))}">#{page_count}</a>}
|
90
88
|
end
|
91
89
|
li << if page_nr < page_count
|
92
|
-
%{<a href="#{escape_html build_path(path, options.merge(:
|
90
|
+
%{<a href="#{escape_html build_path(path, options.merge(page: page_nr + 1))}">▸</a>}
|
93
91
|
else
|
94
92
|
%{<span class="disabled">▸</span>}
|
95
93
|
end
|
@@ -101,8 +99,8 @@ module Olelo
|
|
101
99
|
end
|
102
100
|
|
103
101
|
def format_diff(diff)
|
104
|
-
summary = PatchSummary.new(:
|
105
|
-
formatter = PatchFormatter.new(:
|
102
|
+
summary = PatchSummary.new(links: true)
|
103
|
+
formatter = PatchFormatter.new(links: true, header: true)
|
106
104
|
PatchParser.parse(diff.patch, summary, formatter)
|
107
105
|
(summary.html + formatter.html).html_safe
|
108
106
|
end
|
@@ -110,11 +108,11 @@ module Olelo
|
|
110
108
|
def breadcrumbs(page)
|
111
109
|
path = page.try(:path) || ''
|
112
110
|
li = [%{<li>
|
113
|
-
<a accesskey="z" href="#{escape_html build_path(nil, :
|
111
|
+
<a accesskey="z" href="#{escape_html build_path(nil, version: page)}">#{escape_html :root.t}</a></li>}]
|
114
112
|
path.split('/').inject('') do |parent,elem|
|
115
113
|
current = parent/elem
|
116
114
|
li << %{<li>
|
117
|
-
<a href="#{escape_html build_path(current, :
|
115
|
+
<a href="#{escape_html build_path(current, version: page)}">#{escape_html elem}</a></li>}
|
118
116
|
current
|
119
117
|
end
|
120
118
|
('<ul class="breadcrumbs">' << li.join('<li>/</li>') << '</ul>').html_safe
|
@@ -141,16 +139,6 @@ module Olelo
|
|
141
139
|
end
|
142
140
|
'/' + (Config['base_path'] / path)
|
143
141
|
end
|
144
|
-
|
145
|
-
def edit_content(page)
|
146
|
-
if params[:content]
|
147
|
-
params[:content]
|
148
|
-
elsif !(String === page.content) || !valid_xml_chars?(page.content)
|
149
|
-
:error_binary.t(:page => page.title, :type => "#{page.mime.comment} (#{page.mime})")
|
150
|
-
else
|
151
|
-
params[:pos] ? page.content[params[:pos].to_i, params[:len].to_i].to_s : page.content
|
152
|
-
end
|
153
|
-
end
|
154
142
|
end
|
155
143
|
|
156
144
|
module HttpHelper
|
data/lib/olelo/html_safe.rb
CHANGED
data/lib/olelo/locale.yml
CHANGED
@@ -32,13 +32,14 @@ en:
|
|
32
32
|
edit_page_section: 'Editing #{page} (Section)'
|
33
33
|
email: 'E-Mail'
|
34
34
|
empty_password: 'Empty password'
|
35
|
-
|
35
|
+
info_binary: '#{page} is a binary #{type} and cannot be edited like a text file.'
|
36
36
|
error_occurred: 'Oh snap! An error occurred.'
|
37
37
|
file: 'File'
|
38
38
|
groups: 'Groups'
|
39
39
|
history: 'History'
|
40
40
|
history_of: 'History of #{page}'
|
41
41
|
invalid_email: 'E-Mail is invalid'
|
42
|
+
invalid_mime_type: 'Invalid mime type'
|
42
43
|
invalid_name: 'Name is invalid'
|
43
44
|
invalid_path: 'Invalid path'
|
44
45
|
last_modified: 'Last modified'
|
@@ -120,13 +121,14 @@ de:
|
|
120
121
|
edit_page_section: 'Bearbeite #{page} (Bereich)'
|
121
122
|
email: 'E-Mail'
|
122
123
|
empty_password: 'Leeres Passwort'
|
123
|
-
|
124
|
+
info_binary: '#{page} ist eine Datei mit dem Typ #{type} und kann nicht wie eine Textdatei bearbeitet werden.'
|
124
125
|
error_occurred: 'Hoppla! Es ist ein Fehler aufgetreten.'
|
125
126
|
file: 'Datei'
|
126
127
|
groups: 'Gruppen'
|
127
128
|
history: 'Historie'
|
128
129
|
history_of: 'Historie von #{page}'
|
129
130
|
invalid_email: 'E-Mail ist ungültig'
|
131
|
+
invalid_mime_type: 'Mime-Typ ist ungültig'
|
130
132
|
invalid_name: 'Name ist ungültig'
|
131
133
|
invalid_path: 'Ungültiger Pfad'
|
132
134
|
last_modified: 'Letzte Änderung'
|
@@ -214,13 +216,14 @@ cs_CZ:
|
|
214
216
|
edit_page_section: 'Editovat #{page} (Sekci)'
|
215
217
|
email: 'e-mail'
|
216
218
|
empty_password: 'Prázdné heslo'
|
217
|
-
|
219
|
+
info_binary: 'Stránka #{page} je binární typ #{type} a nemůže být editována jako textový soubor.'
|
218
220
|
error_occurred: 'Ouvej! Vyskytla se chyba.'
|
219
221
|
file: 'Soubor'
|
220
222
|
groups: 'Skupiny'
|
221
223
|
history: 'Historie'
|
222
224
|
history_of: 'Historie stránky #{page}'
|
223
225
|
invalid_email: 'e-mail je neplatný'
|
226
|
+
invalid_mime_type: 'mime-type je neplatný'
|
224
227
|
invalid_name: 'Jméno je neplatné'
|
225
228
|
invalid_path: 'Neplatná cesta'
|
226
229
|
last_modified: 'Poslední modifikace'
|
data/lib/olelo/menu.rb
CHANGED
@@ -91,7 +91,7 @@ module Olelo
|
|
91
91
|
|
92
92
|
def build_menu
|
93
93
|
attrs = options.dup
|
94
|
-
label = attrs.delete(:label) || Locale.translate("menu_#{path.join('_')}", :
|
94
|
+
label = attrs.delete(:label) || Locale.translate("menu_#{path.join('_')}", fallback: titlecase(name))
|
95
95
|
klass = [*attrs.delete(:class)].flatten.compact
|
96
96
|
klass = klass.empty? ? '' : %{class="#{klass.join(' ')}" }
|
97
97
|
attrs = attrs.map {|k,v| %{#{k}="#{escape_html v}"} }.join(' ')
|
data/lib/olelo/page.rb
CHANGED
@@ -109,7 +109,7 @@ module Olelo
|
|
109
109
|
raise 'Page is new' if new?
|
110
110
|
destination = destination.to_s.cleanpath
|
111
111
|
Page.check_path(destination)
|
112
|
-
raise :already_exists.t(:
|
112
|
+
raise :already_exists.t(page: destination) if Page.find(destination)
|
113
113
|
with_hooks(:move, destination) { repository.move(path, destination) }
|
114
114
|
after_commit {|tree_version| update(destination, tree_version) }
|
115
115
|
end
|
@@ -158,6 +158,7 @@ module Olelo
|
|
158
158
|
@attributes = a
|
159
159
|
@mime = nil
|
160
160
|
end
|
161
|
+
raise :invalid_mime_type.t if attributes['mime'] && attributes['mime'] != mime.to_s
|
161
162
|
end
|
162
163
|
|
163
164
|
def saved_content
|
@@ -181,7 +182,7 @@ module Olelo
|
|
181
182
|
|
182
183
|
def save
|
183
184
|
raise 'Page is not head' unless head?
|
184
|
-
raise :already_exists.t(:
|
185
|
+
raise :already_exists.t(page: path) if new? && Page.find(path)
|
185
186
|
with_hooks(:save) do
|
186
187
|
repository.set_content(path, content)
|
187
188
|
repository.set_attributes(path, attributes)
|
@@ -229,22 +230,24 @@ module Olelo
|
|
229
230
|
end
|
230
231
|
|
231
232
|
def detect_mime
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
|
233
|
+
[attributes['mime'], *Config['mime'], 'application/octet-stream'].each do |method|
|
234
|
+
mime =
|
235
|
+
case method
|
236
|
+
when nil
|
237
|
+
when 'extension'
|
238
|
+
MimeMagic.by_extension(extension)
|
239
|
+
when 'content', 'magic'
|
240
|
+
unless new?
|
241
|
+
if content.blank?
|
242
|
+
children.empty? ? EMPTY_MIME : DIRECTORY_MIME
|
243
|
+
else
|
244
|
+
MimeMagic.by_magic(content)
|
245
|
+
end
|
246
|
+
end
|
247
|
+
else
|
248
|
+
MimeMagic.new(method)
|
249
|
+
end
|
250
|
+
return mime if mime && (!mime.text? || valid_xml_chars?(content))
|
248
251
|
end
|
249
252
|
end
|
250
253
|
|