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
@@ -1,93 +0,0 @@
1
- module Rack
2
-
3
- #
4
- # The Rack::StaticCache middleware automatically adds, removes and modifies
5
- # stuffs in response headers to facilitiate client and proxy caching for static files
6
- # that minimizes http requests and improves overall load times for second time visitors.
7
- #
8
- # Once a static content is stored in a client/proxy the only way to enforce the browser
9
- # to fetch the latest content and ignore the cache is to rename the static file.
10
- #
11
- # Alternatively, we can add a version number into the URL to the content to bypass
12
- # the caches. Rack::StaticCache by default handles version numbers in the filename.
13
- # As an example,
14
- # http://yoursite.com/images/test-1.0.0.png and http://yoursite.com/images/test-2.0.0.png
15
- # both reffers to the same image file http://yoursite.com/images/test.png
16
- #
17
- # Another way to bypass the cache is adding the version number in a field-value pair in the
18
- # URL query string. As an example, http://yoursite.com/images/test.png?v=1.0.0
19
- # In that case, set the option :versioning to false to avoid unneccessary regexp calculations.
20
- #
21
- # It's better to keep the current version number in some config file and use it in every static
22
- # content's URL. So each time we modify our static contents, we just have to change the version
23
- # number to enforce the browser to fetch the latest content.
24
- #
25
- # You can use Rack::Deflater along with Rack::StaticCache for further improvements in page loading time.
26
- #
27
- # Examples:
28
- # use Rack::StaticCache, :urls => ["/images", "/css", "/js", "/documents*"], :root => "statics"
29
- # will serve all requests beginning with /images, /csss or /js from the
30
- # directory "statics/images", "statics/css", "statics/js".
31
- # All the files from these directories will have modified headers to enable client/proxy caching,
32
- # except the files from the directory "documents". Append a * (star) at the end of the pattern
33
- # if you want to disable caching for any pattern . In that case, plain static contents will be served with
34
- # default headers.
35
- #
36
- # use Rack::StaticCache, :urls => ["/images"], :duration => 2, :versioning => false
37
- # will serve all requests begining with /images under the current directory (default for the option :root
38
- # is current directory). All the contents served will have cache expiration duration set to 2 years in headers
39
- # (default for :duration is 1 year), and StaticCache will not compute any versioning logics (default for
40
- # :versioning is true)
41
- #
42
-
43
-
44
- class StaticCache
45
-
46
- def initialize(app, options={})
47
- @app = app
48
- @urls = options[:urls]
49
- @no_cache = {}
50
- @urls.collect! do |url|
51
- if url =~ /\*$/
52
- url.sub!(/\*$/, '')
53
- @no_cache[url] = 1
54
- end
55
- url
56
- end
57
- root = options[:root] || Dir.pwd
58
- @file_server = Rack::File.new(root)
59
- @cache_duration = options[:duration] || 1
60
- @versioning_enabled = true
61
- @versioning_enabled = options[:versioning] unless options[:versioning].nil?
62
- @duration_in_seconds = self.duration_in_seconds
63
- @duration_in_words = self.duration_in_words
64
- end
65
-
66
- def call(env)
67
- path = env["PATH_INFO"]
68
- url = @urls.detect{ |u| path.index(u) == 0 }
69
- unless url.nil?
70
- path.sub!(/-[\d.]+([.][a-zA-Z][\w]+)?$/, '\1') if @versioning_enabled
71
- status, headers, body = @file_server.call(env)
72
- if @no_cache[url].nil?
73
- headers['Cache-Control'] ="max-age=#{@duration_in_seconds}, public"
74
- headers['Expires'] = @duration_in_words
75
- headers.delete 'Etag'
76
- headers.delete 'Pragma'
77
- headers.delete 'Last-Modified'
78
- end
79
- [status, headers, body]
80
- else
81
- @app.call(env)
82
- end
83
- end
84
-
85
- def duration_in_words
86
- (Time.now + self.duration_in_seconds).strftime '%a, %d %b %Y %H:%M:%S GMT'
87
- end
88
-
89
- def duration_in_seconds
90
- 60 * 60 * 24 * 365 * @cache_duration
91
- end
92
- end
93
- end
@@ -1,46 +0,0 @@
1
- # -*- coding: utf-8 -*-
2
- description 'Changelog Aspect'
3
- require 'rss/maker'
4
-
5
- Aspect.create(:changelog, 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 == 'rss' ? 'rss' : 'atom'}+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
- content = RSS::Maker.make(format == 'rss' ? '2.0' : 'atom') do |feed|
17
- feed.channel.generator = 'Ōlelo'
18
- feed.channel.title = Config['title']
19
- feed.channel.id = feed.channel.link = url + '/' + page.path
20
- feed.channel.description = Config['title'] + ' Changelog'
21
- feed.channel.updated = Time.now
22
- feed.channel.author = Config['title']
23
- feed.items.do_sort = true
24
- history.each do |version|
25
- i = feed.items.new_item
26
- i.title = version.comment
27
- i.link = "#{url}/changes/#{version}"
28
- i.date = version.date
29
- i.dc_creator = version.author.name
30
- end
31
- end
32
- content.to_s
33
- end
34
- end
35
-
36
- Application.hook :head do
37
- result = %{<link rel="alternate" type="application/atom+xml" title="Sitewide Atom Changelog"
38
- href="#{escape_html build_path('/', aspect: 'changelog', format: 'atom')}"/>
39
- <link rel="alternate" type="application/rss+xml" title="Sitewide RSS Changelog"
40
- href="#{escape_html build_path('/', aspect: 'changelog', format: 'rss')}"/>}
41
- result << %{<link rel="alternate" type="application/atom+xml" title="#{escape_html page.path} Atom Changelog"
42
- href="#{escape_html(build_path(page.path, aspect: 'changelog', format: 'atom'))}"/>
43
- <link rel="alternate" type="application/rss+xml" title="#{escape_html page.path} RSS Changelog"
44
- href="#{escape_html(build_path(page.path, aspect: 'changelog', format: 'rss'))}"/>} if page && !page.new? && !page.root?
45
- result
46
- end
@@ -1,31 +0,0 @@
1
- description 'Cache page fragments'
2
- dependencies 'utils/cache'
3
-
4
- class ::Olelo::Application
5
- def cache_id
6
- @cache_id ||= page ? "#{page.path}-#{page.etag}-#{build_query(params)}" : "#{request.path_info}-#{build_query(params)}"
7
- end
8
-
9
- redefine_method :menu do |name|
10
- Cache.cache("menu-#{name}-#{cache_id}", update: no_cache?) do |cache|
11
- super(name)
12
- end
13
- end
14
-
15
- redefine_method :head do
16
- Cache.cache("head-#{cache_id}", update: no_cache?) do |cache|
17
- super()
18
- end
19
- end
20
-
21
- redefine_method :footer do |content = nil, &block|
22
- # FIXME: Use block instead of block_given?, block_given? returns always false. Is this a ruby issue?
23
- if block || content
24
- super(content, &block)
25
- else
26
- Cache.cache("footer-#{cache_id}", update: no_cache?) do |cache|
27
- super()
28
- end
29
- end
30
- end
31
- end