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/lib/olelo/menu.rb
CHANGED
@@ -6,22 +6,21 @@ module Olelo
|
|
6
6
|
|
7
7
|
def initialize(name)
|
8
8
|
@name = name.to_sym
|
9
|
-
@items =
|
10
|
-
@items_map = {}
|
9
|
+
@items = {}
|
11
10
|
end
|
12
11
|
|
13
12
|
def each(&block)
|
14
|
-
@items.
|
13
|
+
@items.each_value(&block)
|
15
14
|
end
|
16
15
|
|
17
16
|
def [](name)
|
18
17
|
path = path.to_s
|
19
18
|
i = path.index('/')
|
20
19
|
if i
|
21
|
-
item = @
|
20
|
+
item = @items[path[0...i]]
|
22
21
|
item[path[i+1..-1]] if item
|
23
22
|
else
|
24
|
-
@
|
23
|
+
@items[name.to_sym]
|
25
24
|
end
|
26
25
|
end
|
27
26
|
|
@@ -29,12 +28,15 @@ module Olelo
|
|
29
28
|
self << MenuItem.new(name, options)
|
30
29
|
end
|
31
30
|
|
31
|
+
def append(items)
|
32
|
+
items.each {|item| self << item }
|
33
|
+
end
|
34
|
+
|
32
35
|
def <<(item)
|
33
36
|
raise TypeError, "Only items allowed" unless MenuItem === item
|
34
|
-
raise "Item #{item.name} exists already in #{path.join('/')}" if @
|
37
|
+
raise "Item #{item.name} exists already in #{path.join('/')}" if @items.include?(item.name)
|
35
38
|
item.parent = self
|
36
|
-
@items
|
37
|
-
@items_map[item.name] = item
|
39
|
+
@items[item.name] = item
|
38
40
|
end
|
39
41
|
|
40
42
|
def empty?
|
@@ -43,23 +45,21 @@ module Olelo
|
|
43
45
|
|
44
46
|
def clear
|
45
47
|
@items.clear
|
46
|
-
@items_map.clear
|
47
48
|
end
|
48
49
|
|
49
50
|
def remove(name)
|
50
51
|
path = name.to_s
|
51
52
|
i = path.index('/')
|
52
53
|
if i
|
53
|
-
item = @
|
54
|
+
item = @items[path[0...i]]
|
54
55
|
item.remove(path[i+1..-1]) if item
|
55
56
|
else
|
56
|
-
|
57
|
-
@items.delete(item) if item
|
57
|
+
@items.delete(name.to_sym)
|
58
58
|
end
|
59
59
|
end
|
60
60
|
|
61
61
|
def build_menu
|
62
|
-
empty? ? '' : %{<ul id="menu-#{html_id}">#{map
|
62
|
+
empty? ? '' : %{<ul id="menu-#{html_id}">#{map(&:build_menu).join}</ul>}
|
63
63
|
end
|
64
64
|
|
65
65
|
def to_html
|
@@ -0,0 +1,20 @@
|
|
1
|
+
module Olelo
|
2
|
+
module Middleware
|
3
|
+
class StaticCache
|
4
|
+
def initialize(app)
|
5
|
+
@app = app
|
6
|
+
end
|
7
|
+
|
8
|
+
def call(env)
|
9
|
+
# Add a cache-control header if asset is static with version string
|
10
|
+
if env['PATH_INFO'].sub!(%r{^/static-\w+/}, '/static/')
|
11
|
+
status, headers, body = @app.call(env)
|
12
|
+
headers['Cache-Control'] = 'public, max-age=31536000'
|
13
|
+
[status, headers, body]
|
14
|
+
else
|
15
|
+
@app.call(env)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
data/lib/olelo/page.rb
CHANGED
data/lib/olelo/plugin.rb
CHANGED
@@ -32,40 +32,44 @@ module Olelo
|
|
32
32
|
@loaded[path] = plugin
|
33
33
|
end
|
34
34
|
|
35
|
-
# Load
|
35
|
+
# Load plugin by path
|
36
36
|
#
|
37
|
-
# @param
|
37
|
+
# @param [String] path Plugin path to load
|
38
38
|
# @return [Boolean] true if every plugin was loaded
|
39
|
-
def load(
|
40
|
-
|
39
|
+
def load(path)
|
40
|
+
path = path.sub(%r{/main$}, '')
|
41
|
+
files = [File.join(@dir, path, 'main.rb'), File.join(@dir, "#{path}.rb")].select {|file| File.file?(file) }
|
42
|
+
if files.size == 2
|
43
|
+
Olelo.logger.error "Duplicate plugin #{files.join(', ')}"
|
44
|
+
return false
|
45
|
+
end
|
41
46
|
return false if files.empty?
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
end
|
59
|
-
@loaded.delete(path)
|
60
|
-
false
|
47
|
+
|
48
|
+
if @loaded.include?(path)
|
49
|
+
true
|
50
|
+
elsif @failed.include?(path) || !enabled?(path)
|
51
|
+
false
|
52
|
+
else
|
53
|
+
begin
|
54
|
+
new(path, files.first)
|
55
|
+
true
|
56
|
+
rescue Exception => ex
|
57
|
+
@failed << path
|
58
|
+
if LoadError === ex
|
59
|
+
Olelo.logger.warn "Plugin #{path} could not be loaded due to: #{ex.message} (Missing gem?)"
|
60
|
+
else
|
61
|
+
Olelo.logger.error "Plugin #{path} could not be loaded due to: #{ex.message}"
|
62
|
+
Olelo.logger.debug ex
|
61
63
|
end
|
64
|
+
@loaded.delete(path)
|
65
|
+
false
|
62
66
|
end
|
63
67
|
end
|
64
68
|
end
|
65
69
|
|
66
70
|
# Load all plugins
|
67
71
|
def load_all
|
68
|
-
|
72
|
+
Dir[File.join(@dir, '**', '*.rb')].inject(true) {|result,file| load(file[(@dir.size+1)..-4]) && result }
|
69
73
|
end
|
70
74
|
|
71
75
|
# Check if plugin is enabled
|
data/lib/olelo/version.rb
CHANGED
data/lib/olelo/views/layout.slim
CHANGED
@@ -2,7 +2,6 @@ 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/favicon.png?1') type='image/png'
|
6
5
|
= head
|
7
6
|
body
|
8
7
|
#header
|
data/olelo.gemspec
CHANGED
@@ -19,18 +19,19 @@ Gem::Specification.new do |s|
|
|
19
19
|
|
20
20
|
s.required_ruby_version = '>= 1.9.2'
|
21
21
|
|
22
|
-
s.add_runtime_dependency('
|
23
|
-
s.add_runtime_dependency('slim', ['~> 1.3.3'])
|
22
|
+
s.add_runtime_dependency('RedCloth', ['~> 4.2.9'])
|
24
23
|
s.add_runtime_dependency('creole', ['~> 0.5.0'])
|
25
|
-
s.add_runtime_dependency('
|
24
|
+
s.add_runtime_dependency('evaluator', ['~> 0.1.6'])
|
26
25
|
s.add_runtime_dependency('mimemagic', ['~> 0.2.0'])
|
26
|
+
s.add_runtime_dependency('multi_json', ['~> 1.3.7'])
|
27
|
+
s.add_runtime_dependency('nokogiri', ['~> 1.5.5'])
|
27
28
|
s.add_runtime_dependency('rack', ['~> 1.4.1'])
|
28
29
|
s.add_runtime_dependency('redcarpet', ['~> 2.2.2'])
|
29
30
|
s.add_runtime_dependency('rugged', ['~> 0.17.0.b7'])
|
30
|
-
s.add_runtime_dependency('
|
31
|
+
s.add_runtime_dependency('slim', ['~> 1.3.3'])
|
31
32
|
|
32
|
-
s.add_development_dependency('rake', ['>= 0.8.7'])
|
33
|
-
s.add_development_dependency('sass', ['~> 3.2.3'])
|
34
33
|
s.add_development_dependency('bacon', ['~> 1.1.0'])
|
35
34
|
s.add_development_dependency('rack-test', ['~> 0.6.2'])
|
35
|
+
s.add_development_dependency('rake', ['>= 0.8.7'])
|
36
|
+
s.add_development_dependency('sass', ['~> 3.2.3'])
|
36
37
|
end
|
@@ -37,10 +37,10 @@ table
|
|
37
37
|
td= :name.t
|
38
38
|
td= @page.name
|
39
39
|
tr
|
40
|
-
td= :
|
40
|
+
td= :attribute_title.t
|
41
41
|
td= @page.title
|
42
42
|
tr
|
43
|
-
td= :
|
43
|
+
td= :attribute_description.t
|
44
44
|
td= @page.attributes['description']
|
45
45
|
- if @page.version
|
46
46
|
tr
|
@@ -57,7 +57,7 @@ table
|
|
57
57
|
td
|
58
58
|
a href=build_path(@page, aspect: 'download') = :download.t
|
59
59
|
@@ locale.yml
|
60
|
-
|
60
|
+
cs:
|
61
61
|
aspect_documentbrowser: 'Document Browser'
|
62
62
|
download: 'Stáhnout'
|
63
63
|
information: 'Informace'
|
data/plugins/aspects/download.rb
CHANGED
@@ -13,11 +13,11 @@ end
|
|
13
13
|
|
14
14
|
__END__
|
15
15
|
@@ locale.yml
|
16
|
-
|
16
|
+
cs:
|
17
17
|
aspect_download: 'Stažení (neupraveno)'
|
18
18
|
de:
|
19
19
|
aspect_download: 'Herunterladen'
|
20
20
|
en:
|
21
|
-
aspect_download: '
|
21
|
+
aspect_download: 'Download'
|
22
22
|
fr:
|
23
|
-
aspect_download: "Téléchargement
|
23
|
+
aspect_download: "Téléchargement"
|
@@ -0,0 +1,100 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
description 'Newsfeed Aspect'
|
3
|
+
require 'time'
|
4
|
+
|
5
|
+
Aspect.create(:feed, cacheable: true, hidden: true) do
|
6
|
+
def call(context, page)
|
7
|
+
format = context.params[:format]
|
8
|
+
|
9
|
+
url = context.request.base_url
|
10
|
+
context.header['Content-Type'] = "application/#{format == 'atom' ? 'atom' : 'rss'}+xml; charset=utf-8"
|
11
|
+
|
12
|
+
per_page = 30
|
13
|
+
page_nr = [context.params[:page].to_i, 1].max
|
14
|
+
history = page.history((page_nr - 1) * per_page, per_page)
|
15
|
+
|
16
|
+
title = page.root? ? Config['Title'] : page.title
|
17
|
+
feed = {
|
18
|
+
self_link: url + build_path(page, {aspect: 'feed', format: format}.reject{ |k,v| v.blank? }),
|
19
|
+
generator: 'Ōlelo',
|
20
|
+
title: title,
|
21
|
+
description: :feed_description.t(title: title),
|
22
|
+
link: url + '/' + page.path,
|
23
|
+
date: Time.now,
|
24
|
+
author: Config['title'],
|
25
|
+
items: []
|
26
|
+
}
|
27
|
+
history.each do |version|
|
28
|
+
feed[:items] << {
|
29
|
+
title: version.comment,
|
30
|
+
link: "#{url}/changes/#{version}",
|
31
|
+
date: version.date,
|
32
|
+
author: version.author.name
|
33
|
+
}
|
34
|
+
end
|
35
|
+
|
36
|
+
render(format == 'atom' ? :feed_atom : :feed_rss, locals: {feed: feed})
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
Application.hook :head do
|
41
|
+
render_partial :feed_header
|
42
|
+
end
|
43
|
+
|
44
|
+
__END__
|
45
|
+
@@ feed_header.slim
|
46
|
+
link rel="alternate" type="application/atom+xml" title=:sitewide_atom_feed.t href=build_path('/', aspect: 'feed', format: 'atom')
|
47
|
+
link rel="alternate" type="application/rss+xml" title=:sitewide_rss_feed.t href=build_path('/', aspect: 'feed', format: 'rss')
|
48
|
+
- if page && !page.new? && !page.root?
|
49
|
+
link rel="alternate" type="application/atom+xml" title=:page_atom_feed.t(page: page.path) href=build_path(page.path, aspect: 'feed', format: 'atom')
|
50
|
+
link rel="alternate" type="application/rss+xml" title=:page_rss_feed.t(page: page.path) href=build_path(page.path, aspect: 'feed', format: 'rss')
|
51
|
+
@@ feed_atom.slim
|
52
|
+
doctype xml
|
53
|
+
feed xmlns="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/"
|
54
|
+
author
|
55
|
+
name = feed[:title]
|
56
|
+
generator = feed[:generator]
|
57
|
+
id = feed[:link]
|
58
|
+
link href=feed[:link] /
|
59
|
+
link href=feed[:self_link] rel="self" type="application/atom+xml"/
|
60
|
+
subtitle = feed[:description]
|
61
|
+
title = feed[:title]
|
62
|
+
updated = feed[:date].iso8601()
|
63
|
+
- feed[:items].each do |item|
|
64
|
+
entry
|
65
|
+
id = item[:link]
|
66
|
+
link href=item[:link] /
|
67
|
+
title = item[:title]
|
68
|
+
updated = item[:date].iso8601()
|
69
|
+
dc:creator = item[:author]
|
70
|
+
dc:date = item[:date].iso8601()
|
71
|
+
@@ feed_rss.slim
|
72
|
+
doctype xml
|
73
|
+
rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/"
|
74
|
+
channel
|
75
|
+
title = feed[:title]
|
76
|
+
link = feed[:link]
|
77
|
+
description = feed[:description]
|
78
|
+
pubDate = feed[:date].rfc822()
|
79
|
+
atom:link href=feed[:self_link] rel="self" type="application/rss+xml"/
|
80
|
+
- feed[:items].each do |item|
|
81
|
+
item
|
82
|
+
title = item[:title]
|
83
|
+
guid = item[:link]
|
84
|
+
link = item[:link]
|
85
|
+
pubDate = item[:date].rfc822()
|
86
|
+
dc:creator = item[:author]
|
87
|
+
@@ locale.yml
|
88
|
+
de:
|
89
|
+
feed_description: 'Newsfeed für %{title}'
|
90
|
+
sitewide_rss_feed: 'RSS-Newsfeed für die ganze Seite'
|
91
|
+
sitewide_atom_feed: 'Atom-Newsfeed für die ganze Seite'
|
92
|
+
sitewide_rss_feed: 'RSS-Newsfeed für die ganze Seite'
|
93
|
+
page_atom_feed: '%{page} Atom-Newsfeed'
|
94
|
+
page_rss_feed: '%{page} RSS-Newsfeed'
|
95
|
+
en:
|
96
|
+
feed_description: '%{title} Newsfeed'
|
97
|
+
sitewide_atom_feed: 'Sitewide Atom Feed'
|
98
|
+
sitewide_rss_feed: 'Sitewide RSS Feed'
|
99
|
+
page_atom_feed: '%{page} Atom Feed'
|
100
|
+
page_rss_feed: '%{page} RSS Feed'
|
data/plugins/aspects/image.rb
CHANGED
@@ -43,11 +43,11 @@ end
|
|
43
43
|
|
44
44
|
__END__
|
45
45
|
@@ locale.yml
|
46
|
-
|
47
|
-
aspect_image: 'Stažení
|
46
|
+
cs:
|
47
|
+
aspect_image: 'Stažení'
|
48
48
|
de:
|
49
49
|
aspect_image: 'Bild'
|
50
50
|
en:
|
51
|
-
aspect_image: '
|
51
|
+
aspect_image: 'Image'
|
52
52
|
fr:
|
53
|
-
aspect_image: "Image
|
53
|
+
aspect_image: "Image"
|
@@ -25,10 +25,10 @@ table
|
|
25
25
|
td= :name.t
|
26
26
|
td= @page.name
|
27
27
|
tr
|
28
|
-
td= :
|
28
|
+
td= :attribute_title.t
|
29
29
|
td= @page.title
|
30
30
|
tr
|
31
|
-
td= :
|
31
|
+
td= :attribute_description.t
|
32
32
|
td= @page.attributes['description']
|
33
33
|
tr
|
34
34
|
td= :type.t
|
@@ -43,6 +43,12 @@ table
|
|
43
43
|
tr
|
44
44
|
td= :version.t
|
45
45
|
td.version= @page.version
|
46
|
+
tr
|
47
|
+
td= :author.t
|
48
|
+
td= @page.version.author.name
|
49
|
+
tr
|
50
|
+
td= :comment.t
|
51
|
+
td= @page.version.comment
|
46
52
|
- unless @exif.empty?
|
47
53
|
h3= :exif.t
|
48
54
|
table
|
@@ -56,7 +62,7 @@ table
|
|
56
62
|
td= key
|
57
63
|
td= value
|
58
64
|
@@ locale.yml
|
59
|
-
|
65
|
+
cs:
|
60
66
|
aspect_imageinfo: 'Informace o obrázku'
|
61
67
|
entry: 'Položka'
|
62
68
|
exif: 'Informace EXIF'
|
@@ -0,0 +1,20 @@
|
|
1
|
+
cs:
|
2
|
+
author: 'Autor'
|
3
|
+
last_modified: 'Poslední modifikace'
|
4
|
+
name: 'Jméno'
|
5
|
+
version: 'Verze'
|
6
|
+
de:
|
7
|
+
author: 'Autor'
|
8
|
+
last_modified: 'Letzte Änderung'
|
9
|
+
name: 'Name'
|
10
|
+
version: 'Version'
|
11
|
+
en:
|
12
|
+
author: 'Author'
|
13
|
+
last_modified: 'Last modified'
|
14
|
+
name: 'Name'
|
15
|
+
version: 'Version'
|
16
|
+
fr:
|
17
|
+
author: "Auteur"
|
18
|
+
last_modified: "Dernière modification"
|
19
|
+
name: "Nom"
|
20
|
+
version: "Version"
|