olelo 0.9.8 → 0.9.9

Sign up to get free protection for your applications and to get access to all the features.
Files changed (71) hide show
  1. data/.gitignore +1 -0
  2. data/Rakefile +44 -10
  3. data/config.ru +4 -1
  4. data/lib/olelo/application.rb +1 -54
  5. data/lib/olelo/helper.rb +12 -7
  6. data/lib/olelo/initializer.rb +10 -13
  7. data/lib/olelo/locale.rb +7 -12
  8. data/lib/olelo/locale.yml +1 -36
  9. data/lib/olelo/plugin.rb +0 -12
  10. data/lib/olelo/routing.rb +1 -1
  11. data/lib/olelo/templates.rb +2 -3
  12. data/lib/olelo/util.rb +1 -1
  13. data/lib/olelo/version.rb +1 -1
  14. data/{views → lib/olelo/views}/delete.slim +0 -0
  15. data/{views → lib/olelo/views}/deleted.slim +0 -0
  16. data/{views → lib/olelo/views}/edit.slim +3 -3
  17. data/{views → lib/olelo/views}/error.slim +0 -0
  18. data/{views → lib/olelo/views}/layout.slim +1 -1
  19. data/{views → lib/olelo/views}/login.slim +1 -1
  20. data/{views → lib/olelo/views}/move.slim +0 -0
  21. data/{views → lib/olelo/views}/not_found.slim +0 -0
  22. data/{views → lib/olelo/views}/profile.slim +0 -0
  23. data/lib/olelo/views/show.slim +8 -0
  24. data/lib/olelo/virtualfs.rb +5 -29
  25. data/plugins/aspects/changelog.rb +3 -5
  26. data/plugins/aspects/documentbrowser.rb +24 -2
  27. data/plugins/aspects/download.rb +12 -0
  28. data/plugins/aspects/gallery/main.rb +9 -0
  29. data/plugins/aspects/highlight.rb +11 -0
  30. data/plugins/aspects/image.rb +12 -0
  31. data/plugins/aspects/imageinfo.rb +36 -2
  32. data/plugins/aspects/main.rb +16 -1
  33. data/plugins/aspects/pageinfo.rb +20 -2
  34. data/plugins/aspects/source.rb +12 -0
  35. data/plugins/aspects/subpages.rb +17 -1
  36. data/plugins/aspects/text.rb +12 -0
  37. data/plugins/blog/main.rb +4 -4
  38. data/plugins/editor/preview.rb +16 -0
  39. data/plugins/editor/recaptcha.rb +19 -0
  40. data/plugins/filters/editsection.rb +19 -0
  41. data/plugins/filters/locale.yml +11 -16
  42. data/plugins/filters/toc.rb +12 -0
  43. data/{views → plugins/history}/changes.slim +0 -0
  44. data/{views → plugins/history}/compare.slim +2 -2
  45. data/{views → plugins/history}/history.slim +1 -1
  46. data/plugins/history/locale.yml +40 -0
  47. data/plugins/history/main.rb +67 -0
  48. data/plugins/history/script.js +2 -0
  49. data/{static/script/12-olelo.historytable.js → plugins/history/script/00-historytable.js} +0 -0
  50. data/plugins/history/script/init.js +7 -0
  51. data/plugins/login/persistent.rb +11 -0
  52. data/plugins/repositories/git_grep.rb +19 -2
  53. data/plugins/repositories/gitrb_repository.rb +8 -0
  54. data/plugins/repositories/rugged_repository.rb +10 -0
  55. data/plugins/security/acl.rb +23 -0
  56. data/plugins/security/private_wiki.rb +11 -0
  57. data/plugins/utils/assets.rb +15 -21
  58. data/plugins/utils/store.rb +40 -19
  59. data/static/{images/favicon.png → favicon.png} +0 -0
  60. data/static/script.js +3 -5
  61. data/static/script/init.js +0 -1
  62. data/static/themes/atlantis/screen.scss +3 -3
  63. data/static/themes/atlantis/style.css +1 -1
  64. data/test/templates_test.rb +3 -11
  65. metadata +47 -49
  66. data/plugins/aspects/locale.yml +0 -87
  67. data/plugins/editor/locale.yml +0 -20
  68. data/plugins/login/locale.yml +0 -8
  69. data/plugins/repositories/locale.yml +0 -16
  70. data/plugins/security/locale.yml +0 -24
  71. data/views/show.slim +0 -8
@@ -17,18 +17,6 @@ module Olelo
17
17
  # Get failed plugins
18
18
  attr_reader :failed
19
19
 
20
- # Current plugin
21
- def caller
22
- last, stack = nil, []
23
- Kernel.caller(1).each do |line|
24
- if line =~ %r{^#{@dir}/(.+?)(?:\/main)?\.rb} && $1 != last
25
- stack << @loaded[$1]
26
- last = $1
27
- end
28
- end
29
- stack
30
- end
31
-
32
20
  # Get loaded plugins
33
21
  def loaded
34
22
  @loaded.values
@@ -31,7 +31,7 @@ module Olelo
31
31
  @original_params.freeze
32
32
 
33
33
  catch(:forward) do
34
- with_hooks(:request) { perform! }
34
+ perform!
35
35
  status, header, body = response.finish
36
36
  return [status, header, request.head? ? [] : body]
37
37
  end
@@ -19,10 +19,9 @@ module Olelo
19
19
  def render(name, options = {}, &block)
20
20
  locals = options.delete(:locals) || {}
21
21
  name = "#{name}.slim"
22
- path = Templates.loader.context.to_s/name
23
- id = [path, options.to_a].flatten.join('-')
22
+ id = [name, options.to_a].flatten.join('-')
24
23
  template = Templates.with_caching(id) do
25
- Slim::Template.new(path, options) { Templates.loader.load(name) }
24
+ Slim::Template.new(name, options) { Templates.loader.call(name) }
26
25
  end
27
26
  template.render(self, locals, &block).html_safe
28
27
  end
@@ -79,7 +79,7 @@ module Olelo
79
79
  # @param [String] s String
80
80
  # @return [String] Escaped string
81
81
  def escape_html(s)
82
- CGI.escapeHTML(s.to_s)
82
+ CGI.escapeHTML(s.to_s).html_safe
83
83
  end
84
84
 
85
85
  # Unescape html entities in string
@@ -1,3 +1,3 @@
1
1
  module Olelo
2
- VERSION = '0.9.8'
2
+ VERSION = '0.9.9'
3
3
  end
File without changes
File without changes
@@ -30,7 +30,7 @@ form action=build_path(page.new? ? nil : page.path) method='post'
30
30
  br
31
31
  label for='edit-comment' = :comment.t
32
32
  &text#edit-comment name='comment' value=params[:comment] size='50'
33
- = render_block :edit_buttons do
33
+ = wrap_block :edit_buttons do
34
34
  button&submit name='action' value='edit' = :save.t
35
35
  button&submit name='action' value='edit-close' = :save_and_close.t
36
36
  button&reset = :reset.t
@@ -48,7 +48,7 @@ form action=build_path(page.new? ? nil : page.path) method='post' enctype='multi
48
48
  label for='upload-file' = :file.t
49
49
  &file#upload-file.observe name='file'
50
50
  br
51
- = render_block :upload_buttons do
51
+ = wrap_block :upload_buttons do
52
52
  button&submit name='action' value='upload' = :save.t
53
53
  button&submit name='action' value='upload-close' = :save_and_close.t
54
54
  button&reset = :reset.t
@@ -64,7 +64,7 @@ form action=build_path(page.new? ? nil : page.path) method='post'
64
64
  - else
65
65
  &hidden name='version' value=page.version
66
66
  = page.attribute_editor
67
- = render_block :attributes_buttons do
67
+ = wrap_block :attributes_buttons do
68
68
  .indent
69
69
  button&submit name='action' value='attributes' = :save.t
70
70
  button&submit name='action' value='attributes-close' = :save_and_close.t
File without changes
@@ -2,7 +2,7 @@ doctype 5
2
2
  html.no-js lang=Olelo::Config['locale'].sub('_', '-') class={page && !page.head? ? 'archive' : nil} xmlns='http://www.w3.org/1999/xhtml'
3
3
  head
4
4
  title= Olelo::Config['title'] + ' - ' + title
5
- link rel='shortcut icon' href=build_path('static/images/favicon.png?1') type='image/png'
5
+ link rel='shortcut icon' href=build_path('static/favicon.png?1') type='image/png'
6
6
  = head
7
7
  body
8
8
  #header
@@ -12,7 +12,7 @@ form action=build_path(:login) method='post'
12
12
  &password#login-password name='password'
13
13
  br
14
14
  .indent
15
- = render_block :login_buttons do
15
+ = wrap_block :login_buttons do
16
16
  button&submit= :login.t
17
17
  br
18
18
  - if signup_enabled
File without changes
File without changes
@@ -0,0 +1,8 @@
1
+ - title page.title
2
+ = define_block :version do
3
+ a.version href=build_path(page, version: page.version, force_version: true) title=page.version = page.version.short
4
+ = footer do
5
+ == :version_by.t(version: render_block(:version), author: escape_html(page.version.author.name), date: date(page.version.date))
6
+ - if !page.attributes['no_title']
7
+ h1= title
8
+ == content
@@ -20,30 +20,6 @@ module Olelo
20
20
  read(name).bytesize
21
21
  end
22
22
 
23
- class VirtualFile
24
- attr_reader :fs, :name
25
-
26
- def initialize(fs, name)
27
- @fs, @name = fs, name
28
- end
29
-
30
- def read
31
- fs.read(name)
32
- end
33
-
34
- def real_path
35
- fs.real_path(name)
36
- end
37
-
38
- def mtime
39
- @mtime ||= fs.mtime(name)
40
- end
41
-
42
- def size
43
- @size ||= fs.size(name)
44
- end
45
- end
46
-
47
23
  class Native < VirtualFS
48
24
  def initialize(dir)
49
25
  @dir = dir
@@ -59,7 +35,7 @@ module Olelo
59
35
  names.map do |name|
60
36
  Dir[real_path(name)].select {|f| File.file?(f) }
61
37
  end.flatten.each do |f|
62
- yield(VirtualFile.new(self, f[@dir.length+1..-1]))
38
+ yield(self, f[@dir.length+1..-1])
63
39
  end
64
40
  end
65
41
 
@@ -89,7 +65,7 @@ module Olelo
89
65
  def read(name)
90
66
  @cache[name] ||=
91
67
  begin
92
- code, data = File.read(@file).split('__END__')
68
+ code, data = File.read(@file).split('__END__', 2)
93
69
  content = nil
94
70
  data.to_s.each_line do |line|
95
71
  if line =~ /^@@\s*([^\s]+)\s*/
@@ -108,10 +84,10 @@ module Olelo
108
84
 
109
85
  # @override
110
86
  def glob(*names)
111
- code, data = File.read(@file).split('__END__')
87
+ code, data = File.read(@file).split('__END__', 2)
112
88
  data.to_s.each_line do |line|
113
- if line =~ /^@@\s*([^\s]+)\s*/ && names.any? {|pattern| File.fnmatch(pattern, $1) }
114
- yield(VirtualFile.new(self, $1))
89
+ if line =~ /^@@\ss*([^\s]+)\s*/ && names.any? {|pattern| File.fnmatch(pattern, $1) }
90
+ yield(self, $1)
115
91
  end
116
92
  end
117
93
  end
@@ -34,15 +34,13 @@ Aspect.create(:changelog, cacheable: true, hidden: true) do
34
34
  end
35
35
 
36
36
  Application.hook :head do
37
- %{<link rel="alternate" type="application/atom+xml" title="Sitewide Atom Changelog"
37
+ result = %{<link rel="alternate" type="application/atom+xml" title="Sitewide Atom Changelog"
38
38
  href="#{escape_html build_path('/', aspect: 'changelog', format: 'atom')}"/>
39
39
  <link rel="alternate" type="application/rss+xml" title="Sitewide RSS Changelog"
40
40
  href="#{escape_html build_path('/', aspect: 'changelog', format: 'rss')}"/>}
41
- end
42
-
43
- Application.hook :head do
44
- %{<link rel="alternate" type="application/atom+xml" title="#{escape_html page.path} Atom Changelog"
41
+ result << %{<link rel="alternate" type="application/atom+xml" title="#{escape_html page.path} Atom Changelog"
45
42
  href="#{escape_html(build_path(page.path, aspect: 'changelog', format: 'atom'))}"/>
46
43
  <link rel="alternate" type="application/rss+xml" title="#{escape_html page.path} RSS Changelog"
47
44
  href="#{escape_html(build_path(page.path, aspect: 'changelog', format: 'rss'))}"/>} if page && !page.new? && !page.root?
45
+ result
48
46
  end
@@ -1,3 +1,4 @@
1
+ # -*- coding: utf-8 -*-
1
2
  description 'Document browser aspect'
2
3
  dependencies 'utils/shell'
3
4
 
@@ -18,13 +19,13 @@ Aspect.create(:documentbrowser, priority: 1, layout: true, cacheable: true, acce
18
19
  @page = page
19
20
  @page_nr = [context.params[:page].to_i, 1].max
20
21
  @page_count = count_pages
21
- render :browser
22
+ render :documentbrowser
22
23
  end
23
24
  end
24
25
 
25
26
  __END__
26
27
 
27
- @@ browser.slim
28
+ @@ documentbrowser.slim
28
29
  = pagination(@page, @page_count, @page_nr, aspect: 'documentbrowser')
29
30
  p
30
31
  img src=build_path(@page, aspect: 'image', geometry: '480x>', trim: 1, page: @page_nr)
@@ -55,3 +56,24 @@ table
55
56
  td= :download.t
56
57
  td
57
58
  a href=build_path(@page, aspect: 'download') = :download.t
59
+ @@ locale.yml
60
+ cs_CZ:
61
+ aspect_documentbrowser: 'Document Browser'
62
+ download: 'Stáhnout'
63
+ information: 'Informace'
64
+ type: 'Typ'
65
+ de:
66
+ aspect_documentbrowser: 'Dokumentenbrowser'
67
+ download: 'Herunterladen'
68
+ information: 'Information'
69
+ type: 'Typ'
70
+ en:
71
+ aspect_documentbrowser: 'Document Browser'
72
+ download: 'Download'
73
+ information: 'Information'
74
+ type: 'Type'
75
+ fr:
76
+ aspect_documentbrowser: "Explorateur de fichier"
77
+ download: "Télécharger"
78
+ information: "Information"
79
+ type: "Type"
@@ -1,3 +1,4 @@
1
+ # -*- coding: utf-8 -*-
1
2
  description 'Download aspect'
2
3
 
3
4
  Aspect.create(:download) do
@@ -9,3 +10,14 @@ Aspect.create(:download) do
9
10
  page.content
10
11
  end
11
12
  end
13
+
14
+ __END__
15
+ @@ locale.yml
16
+ cs_CZ:
17
+ aspect_download: 'Stažení (neupraveno)'
18
+ de:
19
+ aspect_download: 'Herunterladen'
20
+ en:
21
+ aspect_download: 'Raw Download'
22
+ fr:
23
+ aspect_download: "Téléchargement brut"
@@ -32,3 +32,12 @@ table.gallery
32
32
  a.fancybox href=info_path rel="gallery" title=description
33
33
  img src=thumb_path alt=''
34
34
  a.title href=info_path = description
35
+ @@ locale.yml
36
+ cs_CZ:
37
+ aspect_gallery: 'Galerie'
38
+ de:
39
+ aspect_gallery: 'Bildergalerie'
40
+ en:
41
+ aspect_gallery: 'Image Gallery'
42
+ fr:
43
+ aspect_gallery: "Galerie d'images"
@@ -1,3 +1,4 @@
1
+ # -*- coding: utf-8 -*-
1
2
  description 'Source code highlighting aspect'
2
3
  dependencies 'utils/pygments'
3
4
 
@@ -6,3 +7,13 @@ Aspect.create(:highlight, priority: 2, layout: true, cacheable: true) do
6
7
  def call(context, page); Pygments.pygmentize(page.content, Pygments.file_format(page.name)); end
7
8
  end
8
9
 
10
+ __END__
11
+ @@ locale.yml
12
+ cs_CZ:
13
+ aspect_highlight: 'Zvýrazněný zdroj'
14
+ de:
15
+ aspect_highlight: 'Quellcode mit Syntaxhighlighting'
16
+ en:
17
+ aspect_highlight: 'Highlighted Source'
18
+ fr:
19
+ aspect_highlight: "Source mise en valeur"
@@ -1,3 +1,4 @@
1
+ # -*- coding: utf-8 -*-
1
2
  description 'Image aspect'
2
3
  dependencies 'utils/image_magick'
3
4
 
@@ -39,3 +40,14 @@ Aspect.create(:image, priority: 5, accepts: %r{^application/pdf$|postscript$|^im
39
40
  end
40
41
  end
41
42
  end
43
+
44
+ __END__
45
+ @@ locale.yml
46
+ cs_CZ:
47
+ aspect_image: 'Stažení obrázku'
48
+ de:
49
+ aspect_image: 'Bild'
50
+ en:
51
+ aspect_image: 'Raw Image'
52
+ fr:
53
+ aspect_image: "Image brute"
@@ -1,3 +1,4 @@
1
+ # -*- coding: utf-8 -*-
1
2
  description 'Image information aspect'
2
3
  dependencies 'utils/image_magick'
3
4
 
@@ -8,12 +9,12 @@ Aspect.create(:imageinfo, priority: 1, layout: true, cacheable: true, accepts: %
8
9
  @type = identify[0]
9
10
  @geometry = "#{identify[1]}x#{identify[2]}"
10
11
  @exif = identify[3..-1].to_a.map {|line| line.sub(/^exif:/, '').split('=', 2) }
11
- render :info
12
+ render :imageinfo
12
13
  end
13
14
  end
14
15
 
15
16
  __END__
16
- @@ info.slim
17
+ @@ imageinfo.slim
17
18
  p
18
19
  a href=build_path(@page, aspect: 'image')
19
20
  img src=build_path(@page, aspect: 'image', geometry: '640x480>') alt=@page.title
@@ -54,3 +55,36 @@ table
54
55
  tr
55
56
  td= key
56
57
  td= value
58
+ @@ locale.yml
59
+ cs_CZ:
60
+ aspect_imageinfo: 'Informace o obrázku'
61
+ entry: 'Položka'
62
+ exif: 'Informace EXIF'
63
+ geometry: 'Geometrie'
64
+ information: 'Informace'
65
+ type: 'Typ'
66
+ value: 'Hodnota'
67
+ de:
68
+ aspect_imageinfo: 'Bild-Information'
69
+ entry: 'Eintrag'
70
+ exif: 'EXIF-Information'
71
+ geometry: 'Geometrie'
72
+ information: 'Information'
73
+ type: 'Typ'
74
+ value: 'Wert'
75
+ en:
76
+ aspect_imageinfo: 'Image Information'
77
+ entry: 'Entry'
78
+ exif: 'EXIF Information'
79
+ geometry: 'Geometry'
80
+ information: 'Information'
81
+ type: 'Type'
82
+ value: 'Value'
83
+ fr:
84
+ aspect_imageinfo: "Information sur l'image"
85
+ entry: "Entrée"
86
+ exif: "Information EXIF"
87
+ geometry: "Geometrie"
88
+ information: "Information"
89
+ type: "Type"
90
+ value: "Valeur"
@@ -1,3 +1,4 @@
1
+ # -*- coding: utf-8 -*-
1
2
  description 'Aspect subsystem'
2
3
  dependencies 'utils/cache'
3
4
 
@@ -175,7 +176,6 @@ class ::Olelo::Application
175
176
 
176
177
  self.response.header.merge!(header)
177
178
 
178
- @menu_versions = true
179
179
  layout ? render(:show, locals: {content: content}) : content
180
180
  rescue Aspect::NotAvailable => ex
181
181
  cache_control no_cache: true
@@ -199,3 +199,18 @@ class ::Olelo::Application
199
199
  end
200
200
  end
201
201
  end
202
+
203
+ __END__
204
+ @@ locale.yml
205
+ cs_CZ:
206
+ aspect_not_available: 'Vzhled %{aspect} není k dispozici pro stránku %{page} s typem %{type}.'
207
+ attribute_aspect: 'Přednastavený vzhled'
208
+ de:
209
+ aspect_not_available: 'Aspekt %{aspect} für die Seite %{page} mit dem Typ %{type} ist nicht verfügbar.'
210
+ attribute_aspect: 'Standard-Ansicht'
211
+ en:
212
+ aspect_not_available: 'Aspect %{aspect} is not available for page %{page} with type %{type}.'
213
+ attribute_aspect: 'Default Aspect'
214
+ fr:
215
+ aspect_not_available: "L'aspect %{aspect} n'est pas disponible pour la page %{page} avec le type %{type}."
216
+ attribute_aspect: "Aspect par défaut"
@@ -1,14 +1,15 @@
1
+ # -*- coding: utf-8 -*-
1
2
  description 'Page information aspect'
2
3
 
3
4
  Aspect.create(:pageinfo, priority: 4, layout: true, cacheable: true) do
4
5
  def call(context, page)
5
6
  @page = page
6
- render :info
7
+ render :pageinfo
7
8
  end
8
9
  end
9
10
 
10
11
  __END__
11
- @@ info.slim
12
+ @@ pageinfo.slim
12
13
  table
13
14
  tbody
14
15
  tr
@@ -35,3 +36,20 @@ table
35
36
  td= :download.t
36
37
  td
37
38
  a href=build_path(@page, aspect: 'download') = :download.t
39
+ @@ locale.yml
40
+ cs_CZ:
41
+ aspect_pageinfo: 'Informace o stránce'
42
+ download: 'Stáhnout'
43
+ type: 'Typ'
44
+ de:
45
+ aspect_pageinfo: 'Seiten-Information'
46
+ download: 'Herunterladen'
47
+ type: 'Typ'
48
+ en:
49
+ aspect_pageinfo: 'Page Information'
50
+ download: 'Download'
51
+ type: 'Type'
52
+ fr:
53
+ aspect_pageinfo: "Page d'information"
54
+ download: "Télécharger"
55
+ type: "Type"