olelo 0.9.9 → 0.9.10
Sign up to get free protection for your applications and to get access to all the features.
- data/Rakefile +41 -5
- data/config.ru +5 -3
- data/lib/olelo.rb +1 -0
- data/lib/olelo/application.rb +7 -6
- data/lib/olelo/helper.rb +9 -9
- data/lib/olelo/initializer.rb +3 -2
- data/lib/olelo/locale.rb +1 -3
- data/lib/olelo/locale.yml +5 -61
- data/lib/olelo/menu.rb +13 -13
- data/lib/olelo/middleware/static_cache.rb +20 -0
- data/lib/olelo/page.rb +1 -1
- data/lib/olelo/plugin.rb +28 -24
- data/lib/olelo/version.rb +1 -1
- data/lib/olelo/views/layout.slim +0 -1
- data/olelo.gemspec +7 -6
- data/plugins/aspects/documentbrowser.rb +3 -3
- data/plugins/aspects/download.rb +3 -3
- data/plugins/aspects/feed.rb +100 -0
- data/plugins/aspects/gallery/main.rb +1 -1
- data/plugins/aspects/highlight.rb +1 -1
- data/plugins/aspects/image.rb +4 -4
- data/plugins/aspects/imageinfo.rb +9 -3
- data/plugins/aspects/locale.yml +20 -0
- data/plugins/aspects/main.rb +25 -13
- data/plugins/aspects/pageinfo.rb +9 -3
- data/plugins/aspects/source.rb +1 -1
- data/plugins/aspects/subpages.rb +10 -6
- data/plugins/aspects/text.rb +1 -1
- data/plugins/authentication/locale.yml +16 -0
- data/plugins/blog/locale.yml +1 -1
- data/plugins/blog/main.rb +1 -1
- data/plugins/editor/preview.rb +1 -1
- data/plugins/editor/recaptcha.rb +1 -1
- data/plugins/filters/editsection.rb +1 -1
- data/plugins/filters/locale.yml +1 -1
- data/plugins/filters/toc.rb +1 -1
- data/plugins/history/locale.yml +1 -1
- data/plugins/history/main.rb +18 -14
- data/plugins/login/persistent.rb +8 -6
- data/plugins/misc/variables.rb +16 -5
- data/plugins/misc/webdav.rb +21 -19
- data/plugins/repositories/git_grep.rb +3 -2
- data/plugins/security/acl.rb +1 -1
- data/plugins/security/private_wiki.rb +3 -2
- data/plugins/utils/assets.rb +13 -18
- data/plugins/utils/cache.rb +18 -16
- data/static/script.js +1 -1
- data/static/script/14-olelo.tabwidget.js +2 -0
- data/static/themes/atlantis/menu.scss +3 -0
- data/static/themes/atlantis/style.css +1 -1
- data/test/request_test.rb +0 -1
- metadata +65 -53
- data/lib/rack/static_cache.rb +0 -93
- data/plugins/aspects/changelog.rb +0 -46
- data/plugins/misc/fragment_cache.rb +0 -31
data/plugins/aspects/main.rb
CHANGED
@@ -147,7 +147,7 @@ end
|
|
147
147
|
# Plug-in the aspect subsystem
|
148
148
|
module ::Olelo::PageHelper
|
149
149
|
def render_page(page)
|
150
|
-
|
150
|
+
cache("include-#{page.path}-#{page.etag}", update: no_cache?, defer: true) do
|
151
151
|
begin
|
152
152
|
context = Context.new(page: page, params: {included: true})
|
153
153
|
Aspect.find!(page, layout: true).call(context, page)
|
@@ -163,8 +163,7 @@ class ::Olelo::Application
|
|
163
163
|
def show_page
|
164
164
|
params[:aspect] ||= 'subpages' if params[:path].to_s.ends_with? '/'
|
165
165
|
@selected_aspect, layout, header, content =
|
166
|
-
|
167
|
-
update: no_cache?, defer: true) do |cache|
|
166
|
+
cache("aspect-#{page.path}-#{page.etag}-#{build_query(params)}", update: no_cache?, defer: true) do |cache|
|
168
167
|
aspect = Aspect.find!(page, name: params[:aspect])
|
169
168
|
cache.disable! if !aspect.cacheable?
|
170
169
|
context = Context.new(page: page, params: params, request: request)
|
@@ -187,22 +186,35 @@ class ::Olelo::Application
|
|
187
186
|
|
188
187
|
hook :menu do |menu|
|
189
188
|
if menu.name == :actions && view_menu = menu[:view]
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
189
|
+
view_menu.append(cache("aspect-menu-#{page.path}-#{page.etag}-#{@selected_aspect}", update: no_cache?, defer: true) do
|
190
|
+
aspects = Aspect.find_all(page).select {|a| !a.hidden? || a.name == @selected_aspect || a.name == page.attributes['aspect'] }.map do |a|
|
191
|
+
[Locale.translate("aspect_#{a.name}", fallback: titlecase(a.name)), a]
|
192
|
+
end.sort_by(&:first)
|
193
|
+
aspects.select {|label, a| a.layout? }.map do |label, a|
|
194
|
+
MenuItem.new(a.name, label: label, href: build_path(page, aspect: a.name), class: a.name == @selected_aspect ? 'selected' : nil)
|
195
|
+
end +
|
196
|
+
aspects.reject {|label, a| a.layout? }.map do |label, a|
|
197
|
+
MenuItem.new(a.name, label: label, href: build_path(page, aspect: a.name), class: 'download')
|
198
|
+
end
|
199
|
+
end)
|
200
|
+
end
|
201
|
+
end
|
202
|
+
|
203
|
+
redefine_method :footer do |content = nil, &block|
|
204
|
+
# FIXME: Use block instead of block_given?, block_given? returns always false. Is this a ruby issue?
|
205
|
+
if block || content
|
206
|
+
super(content, &block)
|
207
|
+
elsif page
|
208
|
+
cache("footer-#{page.path}-#{page.etag}", update: no_cache?) { super() }
|
209
|
+
else
|
210
|
+
super()
|
199
211
|
end
|
200
212
|
end
|
201
213
|
end
|
202
214
|
|
203
215
|
__END__
|
204
216
|
@@ locale.yml
|
205
|
-
|
217
|
+
cs:
|
206
218
|
aspect_not_available: 'Vzhled %{aspect} není k dispozici pro stránku %{page} s typem %{type}.'
|
207
219
|
attribute_aspect: 'Přednastavený vzhled'
|
208
220
|
de:
|
data/plugins/aspects/pageinfo.rb
CHANGED
@@ -16,10 +16,10 @@ table
|
|
16
16
|
td= :name.t
|
17
17
|
td= @page.name
|
18
18
|
tr
|
19
|
-
td= :
|
19
|
+
td= :attribute_title.t
|
20
20
|
td= @page.title
|
21
21
|
tr
|
22
|
-
td= :
|
22
|
+
td= :attribute_description.t
|
23
23
|
td= @page.attributes['description']
|
24
24
|
- if @page.version
|
25
25
|
tr
|
@@ -28,6 +28,12 @@ table
|
|
28
28
|
tr
|
29
29
|
td= :version.t
|
30
30
|
td.version = @page.version
|
31
|
+
tr
|
32
|
+
td= :author.t
|
33
|
+
td= @page.version.author.name
|
34
|
+
tr
|
35
|
+
td= :comment.t
|
36
|
+
td= @page.version.comment
|
31
37
|
tr
|
32
38
|
td= :type.t
|
33
39
|
td= @page.mime.comment.blank? ? @page.mime : "#{@page.mime.comment} (#{@page.mime})"
|
@@ -37,7 +43,7 @@ table
|
|
37
43
|
td
|
38
44
|
a href=build_path(@page, aspect: 'download') = :download.t
|
39
45
|
@@ locale.yml
|
40
|
-
|
46
|
+
cs:
|
41
47
|
aspect_pageinfo: 'Informace o stránce'
|
42
48
|
download: 'Stáhnout'
|
43
49
|
type: 'Typ'
|
data/plugins/aspects/source.rb
CHANGED
data/plugins/aspects/subpages.rb
CHANGED
@@ -20,7 +20,7 @@ table#subpages
|
|
20
20
|
thead
|
21
21
|
tr
|
22
22
|
th= :name.t
|
23
|
-
th= :
|
23
|
+
th= :attribute_description.t
|
24
24
|
th= :last_modified.t
|
25
25
|
th= :author.t
|
26
26
|
th= :comment.t
|
@@ -46,15 +46,19 @@ table#subpages
|
|
46
46
|
|
47
47
|
__END__
|
48
48
|
@@ locale.yml
|
49
|
-
|
49
|
+
cs:
|
50
|
+
actions: 'Akce'
|
50
51
|
aspect_subpages: 'Podstránky'
|
51
|
-
|
52
|
+
history: 'Historie'
|
52
53
|
de:
|
54
|
+
actions: 'Aktionen'
|
53
55
|
aspect_subpages: 'Unterseiten'
|
54
|
-
|
56
|
+
history: 'Historie'
|
55
57
|
en:
|
58
|
+
actions: 'Actions'
|
56
59
|
aspect_subpages: 'Subpages'
|
57
|
-
|
60
|
+
history: 'History'
|
58
61
|
fr:
|
62
|
+
actions: "Actions"
|
59
63
|
aspect_subpages: "Sous-pages"
|
60
|
-
|
64
|
+
history: "Historique"
|
data/plugins/aspects/text.rb
CHANGED
@@ -0,0 +1,16 @@
|
|
1
|
+
cs:
|
2
|
+
user_already_exists: 'Uživatel %{name} již existuje'
|
3
|
+
wrong_password: 'Chybné heslo'
|
4
|
+
wrong_user_or_pw: 'Chybné jméno uživatele nebo heslo'
|
5
|
+
de:
|
6
|
+
user_already_exists: 'Benutzer %{name} existiert bereits'
|
7
|
+
wrong_password: 'Falsches Passwort'
|
8
|
+
wrong_user_or_pw: 'Falscher Benutzername oder falsches Passwort'
|
9
|
+
en:
|
10
|
+
user_already_exists: 'User %{name} already exists'
|
11
|
+
wrong_password: 'Wrong password'
|
12
|
+
wrong_user_or_pw: 'Wrong username or password'
|
13
|
+
fr:
|
14
|
+
user_already_exists: "L'utilisateur %{name} existe déjà"
|
15
|
+
wrong_password: "Mot de passe incorect"
|
16
|
+
wrong_user_or_pw: "Nom d'utilisateur ou mot de passe incorect"
|
data/plugins/blog/locale.yml
CHANGED
data/plugins/blog/main.rb
CHANGED
@@ -10,7 +10,7 @@ end
|
|
10
10
|
Tags::Tag.define 'menu', optional: 'path', description: 'Show blog menu', dynamic: true do |context, attrs, content|
|
11
11
|
page = Page.find(attrs[:path]) rescue nil
|
12
12
|
if page
|
13
|
-
|
13
|
+
cache("blog-#{page.path}-#{page.etag}", update: no_cache?(context.request.env), defer: true) do
|
14
14
|
years = {}
|
15
15
|
page.children.each do |child|
|
16
16
|
(years[child.version.date.year] ||= [])[child.version.date.month] = true
|
data/plugins/editor/preview.rb
CHANGED
data/plugins/editor/recaptcha.rb
CHANGED
data/plugins/filters/locale.yml
CHANGED
data/plugins/filters/toc.rb
CHANGED
data/plugins/history/locale.yml
CHANGED
data/plugins/history/main.rb
CHANGED
@@ -1,9 +1,9 @@
|
|
1
1
|
description 'History menu'
|
2
|
-
dependencies 'utils/assets'
|
2
|
+
dependencies 'utils/assets', 'utils/cache'
|
3
3
|
export_scripts '*.js'
|
4
4
|
|
5
5
|
class ::Olelo::Application
|
6
|
-
get '/compare/:versions(
|
6
|
+
get '/compare/:versions(/(:path))', versions: '(?:\w+)\.{2,3}(?:\w+)' do
|
7
7
|
@page = Page.find!(params[:path])
|
8
8
|
versions = params[:versions].split(/\.{2,3}/)
|
9
9
|
begin
|
@@ -15,12 +15,12 @@ class ::Olelo::Application
|
|
15
15
|
render :compare
|
16
16
|
end
|
17
17
|
|
18
|
-
get '/compare(
|
18
|
+
get '/compare(/(:path))' do
|
19
19
|
versions = params[:versions] || []
|
20
20
|
redirect build_path(params[:path], action: versions.size < 2 ? :history : "compare/#{versions.first}...#{versions.last}")
|
21
21
|
end
|
22
22
|
|
23
|
-
get '/changes/:version(
|
23
|
+
get '/changes/:version(/(:path))' do
|
24
24
|
@page = Page.find!(params[:path])
|
25
25
|
begin
|
26
26
|
@diff = page.diff(nil, params[:version])
|
@@ -33,7 +33,7 @@ class ::Olelo::Application
|
|
33
33
|
render :changes
|
34
34
|
end
|
35
35
|
|
36
|
-
get '/history(
|
36
|
+
get '/history(/(:path))' do
|
37
37
|
per_page = 30
|
38
38
|
@page = Page.find!(params[:path])
|
39
39
|
@page_nr = [params[:page].to_i, 1].max
|
@@ -45,7 +45,7 @@ class ::Olelo::Application
|
|
45
45
|
end
|
46
46
|
|
47
47
|
before :action do |method, path|
|
48
|
-
@history_versions_menu = method == :get && (path == '/version/:version(
|
48
|
+
@history_versions_menu = method == :get && (path == '/version/:version(/(:path))' || path == '/(:path)')
|
49
49
|
end
|
50
50
|
|
51
51
|
hook :menu do |menu|
|
@@ -53,14 +53,18 @@ class ::Olelo::Application
|
|
53
53
|
history_menu = menu.item(:history, href: build_path(page, action: :history), accesskey: 'h')
|
54
54
|
|
55
55
|
if @history_versions_menu
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
56
|
+
history_menu.append(cache("history-menu-#{page.path}-#{page.etag}", update: no_cache?, defer: true) do
|
57
|
+
head = !page.head? && (Olelo::Page.find(page.path) rescue nil)
|
58
|
+
items = []
|
59
|
+
if page.previous_version || head || page.next_version
|
60
|
+
items << MenuItem.new(:older, href: build_path(page, original_params.merge(version: page.previous_version)),
|
61
|
+
accesskey: 'o') if page.previous_version
|
62
|
+
items << MenuItem.new(:head, href: build_path(page.path, original_params), accesskey: 'c') if head
|
63
|
+
items << MenuItem.new(:newer, href: build_path(page, original_params.merge(version: page.next_version)),
|
64
|
+
accesskey: 'n') if page.next_version
|
65
|
+
end
|
66
|
+
items
|
67
|
+
end)
|
64
68
|
end
|
65
69
|
end
|
66
70
|
end
|
data/plugins/login/persistent.rb
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
1
2
|
description 'Persistent login'
|
2
3
|
|
3
4
|
class ::Olelo::Application
|
@@ -14,11 +15,6 @@ class ::Olelo::Application
|
|
14
15
|
end
|
15
16
|
end
|
16
17
|
|
17
|
-
before :login_buttons do
|
18
|
-
%{<input type="checkbox" name="persistent" id="persistent" value="1"/>
|
19
|
-
<label for="persistent">#{escape_html :persistent_login.t}</label><br/>}
|
20
|
-
end
|
21
|
-
|
22
18
|
after :action do |method, path|
|
23
19
|
if path == '/login'
|
24
20
|
if User.logged_in? && params[:persistent]
|
@@ -29,11 +25,17 @@ class ::Olelo::Application
|
|
29
25
|
response.delete_cookie(TOKEN_NAME)
|
30
26
|
end
|
31
27
|
end
|
28
|
+
|
29
|
+
before(:login_buttons) { render_partial :persistent_login }
|
32
30
|
end
|
33
31
|
|
34
32
|
__END__
|
33
|
+
@@ persistent_login.slim
|
34
|
+
&checkbox#persistent name="persistent" value="1"
|
35
|
+
label for="persistent" = :persistent_login.t
|
36
|
+
br
|
35
37
|
@@ locale.yml
|
36
|
-
|
38
|
+
cs:
|
37
39
|
persistent_login: 'Trvalé přihlášení'
|
38
40
|
de:
|
39
41
|
persistent_login: 'Dauerhaft anmelden'
|
data/plugins/misc/variables.rb
CHANGED
@@ -1,9 +1,15 @@
|
|
1
1
|
description 'Export variables to context and javascript'
|
2
2
|
dependencies 'aspects'
|
3
3
|
|
4
|
-
def self.
|
4
|
+
def self.exported_global_variables
|
5
5
|
{
|
6
6
|
'base_path' => Config['base_path'],
|
7
|
+
'default_mime' => Page.default_mime
|
8
|
+
}
|
9
|
+
end
|
10
|
+
|
11
|
+
def self.exported_page_variables(page)
|
12
|
+
{
|
7
13
|
'page_name' => page.name,
|
8
14
|
'page_new' => page.new?,
|
9
15
|
'page_modified' => page.modified?,
|
@@ -12,19 +18,24 @@ def self.exported_variables(page)
|
|
12
18
|
'page_version' => page.version.to_s,
|
13
19
|
'page_next_version' => page.next_version.to_s,
|
14
20
|
'page_previous_version' => page.previous_version.to_s,
|
15
|
-
'page_mime' => page.mime.to_s
|
16
|
-
'default_mime' => Page.default_mime
|
21
|
+
'page_mime' => page.mime.to_s
|
17
22
|
}
|
18
23
|
end
|
19
24
|
|
20
25
|
# Export variables to aspect context
|
21
26
|
Aspects::Context.hook(:initialized) do
|
22
|
-
params.merge!(PLUGIN.
|
27
|
+
params.merge!(PLUGIN.exported_global_variables)
|
28
|
+
params.merge!(PLUGIN.exported_page_variables(page))
|
23
29
|
end
|
24
30
|
|
25
31
|
# Export variables to javascript for client extensions
|
26
32
|
Application.hook :head, 1 do
|
27
|
-
vars =
|
33
|
+
vars = params.merge(PLUGIN.exported_global_variables)
|
34
|
+
if page
|
35
|
+
vars.merge!(cache("variables-#{page.path}-#{page.etag}", update: no_cache?, defer: true) do
|
36
|
+
PLUGIN.exported_page_variables(page)
|
37
|
+
end)
|
38
|
+
end
|
28
39
|
vars = vars.merge('user_name' => User.current.name) if User.logged_in?
|
29
40
|
%{<script type="text/javascript">Olelo = #{escape_javascript MultiJson.dump(vars)};</script>}
|
30
41
|
end
|
data/plugins/misc/webdav.rb
CHANGED
@@ -18,28 +18,30 @@ class ::Olelo::Application
|
|
18
18
|
:bad_request
|
19
19
|
end
|
20
20
|
|
21
|
-
|
22
|
-
|
23
|
-
:
|
24
|
-
|
25
|
-
|
21
|
+
get '/webdav(/(:path))' do
|
22
|
+
begin
|
23
|
+
page = Page.find!(params[:path])
|
24
|
+
cache_control etag: page.etag
|
25
|
+
response['Content-Type'] = page.mime.to_s
|
26
|
+
page.content
|
27
|
+
rescue NotFound => ex
|
28
|
+
Olelo.logger.error ex
|
29
|
+
:not_found
|
30
|
+
rescue Exception => ex
|
31
|
+
Olelo.logger.error ex
|
32
|
+
:bad_request
|
26
33
|
end
|
27
34
|
end
|
28
35
|
|
29
|
-
|
30
|
-
|
31
|
-
super()
|
32
|
-
else
|
33
|
-
webdav_post
|
34
|
-
end
|
35
|
-
end
|
36
|
+
put('/webdav(/(:path))') { webdav_post }
|
37
|
+
post('/webdav(/(:path))') { webdav_post }
|
36
38
|
|
37
39
|
# TODO: Implement more methods if needed
|
38
|
-
add_route('PROPFIND', '/(:path)'
|
39
|
-
add_route('PROPPATCH', '/(:path)'
|
40
|
-
add_route('MKCOL', '/(:path)'
|
41
|
-
add_route('COPY', '/(:path)'
|
42
|
-
add_route('MOVE', '/(:path)'
|
43
|
-
add_route('LOCK', '/(:path)'
|
44
|
-
add_route('UNLOCK', '/(:path)'
|
40
|
+
add_route('PROPFIND', '/webdav(/(:path))') { :not_found }
|
41
|
+
add_route('PROPPATCH', '/webdav(/(:path))') { :not_implemented }
|
42
|
+
add_route('MKCOL', '/webdav(/(:path))') { :not_implemented }
|
43
|
+
add_route('COPY', '/webdav(/(:path))') { :not_implemented }
|
44
|
+
add_route('MOVE', '/webdav(/(:path))') { :not_implemented }
|
45
|
+
add_route('LOCK', '/webdav(/(:path))') { :not_implemented }
|
46
|
+
add_route('UNLOCK', '/webdav(/(:path))') { :not_implemented }
|
45
47
|
end
|