olelo 0.9.9 → 0.9.10

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.
Files changed (55) hide show
  1. data/Rakefile +41 -5
  2. data/config.ru +5 -3
  3. data/lib/olelo.rb +1 -0
  4. data/lib/olelo/application.rb +7 -6
  5. data/lib/olelo/helper.rb +9 -9
  6. data/lib/olelo/initializer.rb +3 -2
  7. data/lib/olelo/locale.rb +1 -3
  8. data/lib/olelo/locale.yml +5 -61
  9. data/lib/olelo/menu.rb +13 -13
  10. data/lib/olelo/middleware/static_cache.rb +20 -0
  11. data/lib/olelo/page.rb +1 -1
  12. data/lib/olelo/plugin.rb +28 -24
  13. data/lib/olelo/version.rb +1 -1
  14. data/lib/olelo/views/layout.slim +0 -1
  15. data/olelo.gemspec +7 -6
  16. data/plugins/aspects/documentbrowser.rb +3 -3
  17. data/plugins/aspects/download.rb +3 -3
  18. data/plugins/aspects/feed.rb +100 -0
  19. data/plugins/aspects/gallery/main.rb +1 -1
  20. data/plugins/aspects/highlight.rb +1 -1
  21. data/plugins/aspects/image.rb +4 -4
  22. data/plugins/aspects/imageinfo.rb +9 -3
  23. data/plugins/aspects/locale.yml +20 -0
  24. data/plugins/aspects/main.rb +25 -13
  25. data/plugins/aspects/pageinfo.rb +9 -3
  26. data/plugins/aspects/source.rb +1 -1
  27. data/plugins/aspects/subpages.rb +10 -6
  28. data/plugins/aspects/text.rb +1 -1
  29. data/plugins/authentication/locale.yml +16 -0
  30. data/plugins/blog/locale.yml +1 -1
  31. data/plugins/blog/main.rb +1 -1
  32. data/plugins/editor/preview.rb +1 -1
  33. data/plugins/editor/recaptcha.rb +1 -1
  34. data/plugins/filters/editsection.rb +1 -1
  35. data/plugins/filters/locale.yml +1 -1
  36. data/plugins/filters/toc.rb +1 -1
  37. data/plugins/history/locale.yml +1 -1
  38. data/plugins/history/main.rb +18 -14
  39. data/plugins/login/persistent.rb +8 -6
  40. data/plugins/misc/variables.rb +16 -5
  41. data/plugins/misc/webdav.rb +21 -19
  42. data/plugins/repositories/git_grep.rb +3 -2
  43. data/plugins/security/acl.rb +1 -1
  44. data/plugins/security/private_wiki.rb +3 -2
  45. data/plugins/utils/assets.rb +13 -18
  46. data/plugins/utils/cache.rb +18 -16
  47. data/static/script.js +1 -1
  48. data/static/script/14-olelo.tabwidget.js +2 -0
  49. data/static/themes/atlantis/menu.scss +3 -0
  50. data/static/themes/atlantis/style.css +1 -1
  51. data/test/request_test.rb +0 -1
  52. metadata +65 -53
  53. data/lib/rack/static_cache.rb +0 -93
  54. data/plugins/aspects/changelog.rb +0 -46
  55. data/plugins/misc/fragment_cache.rb +0 -31
@@ -147,7 +147,7 @@ end
147
147
  # Plug-in the aspect subsystem
148
148
  module ::Olelo::PageHelper
149
149
  def render_page(page)
150
- Cache.cache("include-#{page.path}-#{page.etag}", update: no_cache?, defer: true) do |context|
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
- Cache.cache("aspect-#{page.path}-#{page.etag}-#{build_query(params)}",
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
- 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? }.each do |label, a|
194
- view_menu << 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? }.each do |label, a|
197
- view_menu << MenuItem.new(a.name, label: label, href: build_path(page, aspect: a.name), class: 'download')
198
- end
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
- cs_CZ:
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:
@@ -16,10 +16,10 @@ table
16
16
  td= :name.t
17
17
  td= @page.name
18
18
  tr
19
- td= :title.t
19
+ td= :attribute_title.t
20
20
  td= @page.title
21
21
  tr
22
- td= :description.t
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
- cs_CZ:
46
+ cs:
41
47
  aspect_pageinfo: 'Informace o stránce'
42
48
  download: 'Stáhnout'
43
49
  type: 'Typ'
@@ -8,7 +8,7 @@ end
8
8
 
9
9
  __END__
10
10
  @@ locale.yml
11
- cs_CZ:
11
+ cs:
12
12
  aspect_source: 'Zdroj stránky'
13
13
  de:
14
14
  aspect_source: 'Quellcode'
@@ -20,7 +20,7 @@ table#subpages
20
20
  thead
21
21
  tr
22
22
  th= :name.t
23
- th= :description.t
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
- cs_CZ:
49
+ cs:
50
+ actions: 'Akce'
50
51
  aspect_subpages: 'Podstránky'
51
- author: 'Autor'
52
+ history: 'Historie'
52
53
  de:
54
+ actions: 'Aktionen'
53
55
  aspect_subpages: 'Unterseiten'
54
- author: 'Autor'
56
+ history: 'Historie'
55
57
  en:
58
+ actions: 'Actions'
56
59
  aspect_subpages: 'Subpages'
57
- author: 'Author'
60
+ history: 'History'
58
61
  fr:
62
+ actions: "Actions"
59
63
  aspect_subpages: "Sous-pages"
60
- author: "Auteur"
64
+ history: "Historique"
@@ -11,7 +11,7 @@ end
11
11
 
12
12
  __END__
13
13
  @@ locale.yml
14
- cs_CZ:
14
+ cs:
15
15
  aspect_text: 'Stažení textu'
16
16
  de:
17
17
  aspect_text: 'Quellcode herunterladen'
@@ -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"
@@ -1,4 +1,4 @@
1
- cs_CZ:
1
+ cs:
2
2
  full_article: 'Plný článek'
3
3
  no_articles: 'Žádné články nenalezeny'
4
4
  written_by: 'Napsal: %{author}'
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
- Cache.cache("blog-#{page.path}-#{page.etag}", update: no_cache?(context.request.env), defer: true) do
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
@@ -54,7 +54,7 @@ end
54
54
 
55
55
  __END__
56
56
  @@ locale.yml
57
- cs_CZ:
57
+ cs:
58
58
  changes: 'Změny'
59
59
  preview: 'Náhled'
60
60
  de:
@@ -61,7 +61,7 @@ end
61
61
 
62
62
  __END__
63
63
  @@ locale.yml
64
- cs_CZ:
64
+ cs:
65
65
  captcha_invalid: 'Neplatný captcha kód'
66
66
  captcha_valid: 'Platný captcha kód'
67
67
  enter_captcha: 'Vložte laskavě captcha kód.'
@@ -68,7 +68,7 @@ Filters::Filter.register :editsection, EditSection
68
68
 
69
69
  __END__
70
70
  @@ locale.yml
71
- cs_CZ:
71
+ cs:
72
72
  attribute_no_editsection: 'Zablokovat editaci sekcí'
73
73
  edit_section: 'Edituj sekci "%{section}"'
74
74
  section_edited: 'Sekce "%{section}" editována'
@@ -1,4 +1,4 @@
1
- cs_CZ:
1
+ cs:
2
2
  aspect_latex: 'LaTeX'
3
3
  aspect_page: 'Stránce'
4
4
  de:
@@ -52,7 +52,7 @@ end
52
52
 
53
53
  __END__
54
54
  @@ locale.yml
55
- cs_CZ:
55
+ cs:
56
56
  attribute_toc: 'Vytvořit obsah'
57
57
  de:
58
58
  attribute_toc: 'Inhaltsverzeichnis erzeugen'
@@ -1,4 +1,4 @@
1
- cs_CZ:
1
+ cs:
2
2
  author: 'Autor'
3
3
  changes: 'Změny'
4
4
  changes_of: 'Změny stránky %{page}'
@@ -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(/:path)', versions: '(?:\w+)\.{2,3}(?:\w+)' do
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(/:path)' do
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(/:path)' do
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(/:path)' do
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(/:path)' || path == '/(:path)')
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
- head = !page.head? && (Olelo::Page.find(page.path) rescue nil)
57
- if page.previous_version || head || page.next_version
58
- history_menu.item(:older, href: build_path(page, original_params.merge(version: page.previous_version)),
59
- accesskey: 'o') if page.previous_version
60
- history_menu.item(:head, href: build_path(page.path, original_params), accesskey: 'c') if head
61
- history_menu.item(:newer, href: build_path(page, original_params.merge(version: page.next_version)),
62
- accesskey: 'n') if page.next_version
63
- end
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
@@ -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
- cs_CZ:
38
+ cs:
37
39
  persistent_login: 'Trvalé přihlášení'
38
40
  de:
39
41
  persistent_login: 'Dauerhaft anmelden'
@@ -1,9 +1,15 @@
1
1
  description 'Export variables to context and javascript'
2
2
  dependencies 'aspects'
3
3
 
4
- def self.exported_variables(page)
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.exported_variables(page))
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 = page ? params.merge(PLUGIN.exported_variables(page)) : params
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
@@ -18,28 +18,30 @@ class ::Olelo::Application
18
18
  :bad_request
19
19
  end
20
20
 
21
- put '/(:path)', tail: true do
22
- if request.form_data?
23
- :not_implemented
24
- else
25
- webdav_post
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
- post '/(:path)', tail: true do
30
- if request.form_data?
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)', tail: true) { :not_found }
39
- add_route('PROPPATCH', '/(:path)', tail: true) { :not_implemented }
40
- add_route('MKCOL', '/(:path)', tail: true) { :not_implemented }
41
- add_route('COPY', '/(:path)', tail: true) { :not_implemented }
42
- add_route('MOVE', '/(:path)', tail: true) { :not_implemented }
43
- add_route('LOCK', '/(:path)', tail: true) { :not_implemented }
44
- add_route('UNLOCK', '/(:path)', tail: true) { :not_implemented }
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