gollum 3.0.0 → 3.1.0

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of gollum might be problematic. Click here for more details.

Files changed (35) hide show
  1. checksums.yaml +13 -5
  2. data/HISTORY.md +14 -0
  3. data/README.md +15 -11
  4. data/bin/gollum +17 -4
  5. data/{openrc → contrib/openrc}/conf.d/gollum +0 -0
  6. data/{openrc → contrib/openrc}/init.d/gollum +0 -0
  7. data/contrib/systemd/gollum@.service +12 -0
  8. data/gollum.gemspec +9 -5
  9. data/lib/gollum.rb +1 -1
  10. data/lib/gollum/app.rb +44 -12
  11. data/lib/gollum/editing_auth.rb +34 -0
  12. data/lib/gollum/helpers.rb +12 -0
  13. data/lib/gollum/public/gollum/css/dialog.css +117 -15
  14. data/lib/gollum/public/gollum/css/editor.css +220 -62
  15. data/lib/gollum/public/gollum/css/gollum.css +139 -22
  16. data/lib/gollum/public/gollum/css/ie7.css +6 -0
  17. data/lib/gollum/public/gollum/css/template.css +56 -2
  18. data/lib/gollum/public/gollum/javascript/editor/gollum.editor.js +60 -0
  19. data/lib/gollum/public/gollum/javascript/editor/langs/asciidoc.js +26 -11
  20. data/lib/gollum/public/gollum/javascript/gollum.dialog.js +26 -4
  21. data/lib/gollum/templates/compare.mustache +16 -10
  22. data/lib/gollum/templates/editor.mustache +6 -2
  23. data/lib/gollum/templates/history.mustache +4 -2
  24. data/lib/gollum/templates/latest_changes.mustache +39 -0
  25. data/lib/gollum/templates/layout.mustache +14 -5
  26. data/lib/gollum/templates/page.mustache +30 -15
  27. data/lib/gollum/templates/pages.mustache +4 -3
  28. data/lib/gollum/views/compare.rb +1 -1
  29. data/lib/gollum/views/create.rb +8 -0
  30. data/lib/gollum/views/edit.rb +8 -0
  31. data/lib/gollum/views/history.rb +1 -1
  32. data/lib/gollum/views/latest_changes.rb +90 -0
  33. data/lib/gollum/views/page.rb +33 -11
  34. data/lib/gollum/views/pages.rb +6 -2
  35. metadata +38 -34
checksums.yaml CHANGED
@@ -1,7 +1,15 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: ae63e46f52e80b39d9876f199ecf4adc35cb4ed3
4
- data.tar.gz: 2e899d40a26492fb28fa9719fd07fb28cfe114be
2
+ !binary "U0hBMQ==":
3
+ metadata.gz: !binary |-
4
+ MTM5MzlkY2I5YjA4NjhkZWVkYmExYmVjZjQ0ZDk3OGJmYjFkY2JiNA==
5
+ data.tar.gz: !binary |-
6
+ ZDc2NTE5NTcwZmMzMWYwOWI4YTIwNjUxMTJiZTFhN2U5NDVhYzIxNw==
5
7
  SHA512:
6
- metadata.gz: 5a239050238237bc42b2a3b0dd7a74c1b5a2f618945eb4dede46794cd20f150ecbbc1475743bfc765a5007e137fe57b5adac727fb776caafc2a7570b3fb9d2f1
7
- data.tar.gz: 8a033dc8543467eba6a508c6a01e035d05d02aa5a804a668787437f923d6eb1c055a990e7b0282554f673fff51079a8b6dde20b913993b5c959a112a2b4a64fe
8
+ metadata.gz: !binary |-
9
+ ZmYwZDMwNmM2NjJmMmUzZmJlNzFkYzkzYjc3NTk4NzIxZGUyNzU0NmVjZjc2
10
+ MzczNjQ3NmY5NmMxODY1OWQ1ZjFmN2IyYzQ5Nzg1YTQyZTAwNzRjMjU1NmMy
11
+ NjQ5YjY1YTQyNTQ2Yjk0NjQxYTY4NzdmNDU4NTI2ZWNiZGM4NDM=
12
+ data.tar.gz: !binary |-
13
+ YjFmNzAwOGM0OTExMDUzOTkzYzJjMGYyMTQzZmQxNzQ1NDY4NjA0ZTQ4MTkz
14
+ Njg2N2Y0OGIzN2NiZGFjZjA1NThlZmIxMDgwYzdiMjI0OTYwYTJlMmEzNGY2
15
+ ZDAxNGZmMmY5OWRhZmRhYWMyY2YxNDFiZmNiOGZmNDczYmJiZTQ=
data/HISTORY.md CHANGED
@@ -1,3 +1,17 @@
1
+ # 3.1 / 2014-11-28
2
+
3
+ * New features
4
+ * Drag-and-drop uploading in the editor [@lucas-clemente](https://github.com/lucas-clemente)
5
+ * Latest changes view [@etienneCharignon](https://github.com/etienneCharignon) (#707)
6
+ * Option `--no-edit` to disable editing from the web interface [@bambycha](https://github.com/bambycha) (#879)
7
+ * Option `--mathjax-config` to specify custom mathjax configuration [@hardywu](https://github.com/hardywu) (#842)
8
+ * Major enhancements
9
+ * Made the Gollum theme responsive [@rtrvrtg](https://github.com/rtrvrtg) (#831)
10
+ * Depends on new [gollum-lib](https://github.com/gollum/gollum-lib) `4.0.0`
11
+ * Allows specifiying [git adapter](https://github.com/gollum/gollum/wiki/Git-adapters) with `--adapter` [@bartkamphorst](https://github.com/bartkamphorst), [@dometto](https://github.com/dometto)
12
+ * Numerous bugfixes
13
+ * **NB**: please pass `--h1-title` if you do not want page titles to default to the page's filepath. See [here](https://github.com/gollum/gollum/wiki/Page-titles).
14
+
1
15
  # 2.4.11 / 2013-01-08
2
16
 
3
17
  * Numerous security issues have been fixed. Please update to `2.4.11`
data/README.md CHANGED
@@ -29,7 +29,7 @@ Gollum follows the rules of [Semantic Versioning](http://semver.org/) and uses
29
29
 
30
30
  ## SECURITY
31
31
 
32
- Don't enable `--custom-css` or `--custom-js` unless you trust every user who has the ability to edit the wiki.
32
+ Don't enable `--custom-css`, `--custom-js` or `--mathjax-config` unless you trust every user who has the ability to edit the wiki.
33
33
  A better solution with more security is being tracked in [#665](https://github.com/gollum/gollum/issues/665).
34
34
 
35
35
  ## INSTALLATION
@@ -39,6 +39,7 @@ The best way to install Gollum is with RubyGems:
39
39
  ```bash
40
40
  $ [sudo] gem install gollum
41
41
  ```
42
+ You may first need to install some additional [development packages](https://github.com/gollum/gollum/wiki/Installation) for your OS.
42
43
 
43
44
  If you're installing from source, you can use [Bundler][bundler] to pick up all the
44
45
  gems:
@@ -51,7 +52,7 @@ In order to use the various formats that Gollum supports, you will need to
51
52
  separately install the necessary dependencies for each format. You only need
52
53
  to install the dependencies for the formats that you plan to use.
53
54
 
54
- * [ASCIIDoc](http://www.methods.co.nz/asciidoc/) -- `brew install asciidoc` on mac or `apt-get install -y asciidoc` on Ubuntu
55
+ * [AsciiDoc](http://asciidoctor.org) -- `gem install asciidoctor`
55
56
  * [Creole](http://wikicreole.org/) -- `gem install creole`
56
57
  * [Markdown](http://daringfireball.net/projects/markdown/) -- `gem install redcarpet`
57
58
  * [GitHub Flavored Markdown](https://help.github.com/articles/github-flavored-markdown) -- `gem install github-markdown`
@@ -98,23 +99,26 @@ Options:
98
99
  --port [PORT] Bind port (default 4567).
99
100
  --host [HOST] Hostname or IP address to listen on (default 0.0.0.0).
100
101
  --version Display current version.
101
- --config [CONFIG] Path to additional configuration file
102
+ --config [CONFIG] Path to additional configuration file.
103
+ --adapter [ADAPTER] Git adapter to use in the backend. Defaults to grit.
102
104
  --irb Start an irb process with gollum loaded for the current wiki.
103
- --css Inject custom css. Uses custom.css from root repository
104
- --js Inject custom js. Uses custom.js from root repository
105
- --template-dir [PATH] Specify custom template directory
105
+ --css Inject custom css. Uses custom.css from root repository.
106
+ --js Inject custom js. Uses custom.js from root repository.
107
+ --template-dir [PATH] Specify custom template directory.
106
108
  --page-file-dir [PATH] Specify the sub directory for all page files (default: repository root).
107
- --base-path [PATH] Specify the base path.
108
- --gollum-path [PATH] Specify the gollum path.
109
+ --base-path [PATH] Specify the base path for the served pages (default: /) Example: --base-path wiki yields the home page accessible at http://localhost:4567/wiki/.
110
+ --gollum-path [PATH] Specify the path to the git repository to be served.
109
111
  --ref [REF] Specify the repository ref to use (default: master).
112
+ --no-edit Restricts editing capability through frontend.
110
113
  --no-live-preview Disables livepreview.
111
114
  --live-preview Enables livepreview.
112
- --allow-uploads Allows file uploads.
113
- --mathjax Enables mathjax.
115
+ --allow-uploads [MODE] Allows file uploads. Modes: dir (default, store all uploads in the same directory), page (store each upload at the same location as the page).
116
+ --mathjax Enables mathjax for rendering mathematical equations. Uses the TeX-AMS-MML_HTMLorMML config with the autoload-all extension by default.
117
+ --mathjax-config [SOURCE] Inject custom mathjax config file. Uses mathjax.config.js from root repository by default.
114
118
  --user-icons [SOURCE] Set the history user icons. Valid values: gravatar, identicon, none. Default: none.
115
119
  --show-all Shows all files in file view. By default only valid pages are shown.
116
120
  --collapse-tree Collapse file view tree. By default, expanded tree is shown.
117
- --h1-title Sets page title to value of first h1
121
+ --h1-title Sets page title to value of first h1.
118
122
  ```
119
123
 
120
124
  Note that the gollum server will not run on Windows because of [an issue](https://github.com/rtomayko/posix-spawn/issues/9) with posix-spawn (which is used by Grit).
data/bin/gollum CHANGED
@@ -22,6 +22,7 @@ options = { 'port' => 4567, 'bind' => '0.0.0.0' }
22
22
  wiki_options = {
23
23
  :live_preview => false,
24
24
  :allow_uploads => false,
25
+ :allow_editing => true,
25
26
  }
26
27
 
27
28
  opts = OptionParser.new do |opts|
@@ -44,6 +45,10 @@ opts = OptionParser.new do |opts|
44
45
  options['config'] = config
45
46
  end
46
47
 
48
+ opts.on("--adapter [ADAPTER]", "Git adapter to use in the backend. Defaults to grit.") do |adapter|
49
+ Gollum::GIT_ADAPTER = adapter
50
+ end
51
+
47
52
  opts.on("--irb", "Start an irb process with gollum loaded for the current wiki.") do
48
53
  options['irb'] = true
49
54
  end
@@ -64,11 +69,11 @@ opts = OptionParser.new do |opts|
64
69
  wiki_options[:page_file_dir] = path
65
70
  end
66
71
 
67
- opts.on("--base-path [PATH]", "Specify the base path.") do |path|
72
+ opts.on("--base-path [PATH]", "Specify the base path for the served pages (default: /) Example: --base-path wiki yields the home page accessible at http://localhost:4567/wiki/.") do |path|
68
73
  wiki_options[:base_path] = path
69
74
  end
70
75
 
71
- opts.on("--gollum-path [PATH]", "Specify the gollum path.") do |path|
76
+ opts.on("--gollum-path [PATH]", "Specify the path to the git repository to be served.") do |path|
72
77
  wiki_options[:gollum_path] = path
73
78
  end
74
79
 
@@ -76,6 +81,10 @@ opts = OptionParser.new do |opts|
76
81
  wiki_options[:ref] = ref
77
82
  end
78
83
 
84
+ opts.on("--no-edit", "Restricts editing capability through frontend.") do
85
+ wiki_options[:allow_editing] = false
86
+ end
87
+
79
88
  opts.on("--no-live-preview", "Disables livepreview.") do
80
89
  wiki_options[:live_preview] = false
81
90
  end
@@ -89,10 +98,14 @@ opts = OptionParser.new do |opts|
89
98
  wiki_options[:per_page_uploads] = true if mode == :page
90
99
  end
91
100
 
92
- opts.on("--mathjax", "Enables mathjax.") do
101
+ opts.on("--mathjax", "Enables mathjax for rendering mathematical equations. Uses the TeX-AMS-MML_HTMLorMML config with the autoload-all extension by default.") do
93
102
  wiki_options[:mathjax] = true
94
103
  end
95
104
 
105
+ opts.on("--mathjax-config [SOURCE]", "Inject custom mathjax config file. Uses mathjax.config.js from root repository by default") do |source|
106
+ wiki_options[:mathjax_config] = source || 'mathjax.config.js'
107
+ end
108
+
96
109
  opts.on("--user-icons [SOURCE]", "Set the history user icons. Valid values: gravatar, identicon, none. Default: none.") do |source|
97
110
  wiki_options[:user_icons] = source
98
111
  end
@@ -211,4 +224,4 @@ else
211
224
  # Rack::Handler does not work with Ctrl + C. Use Rack::Server instead.
212
225
  Rack::Server.new(:app => MapGollum.new(base_path), :Port => options['port'], :Host => options['bind']).start
213
226
  end
214
- end
227
+ end
File without changes
File without changes
@@ -0,0 +1,12 @@
1
+ [Unit]
2
+ Description=Gollum wiki server
3
+ After=network.target
4
+
5
+ [Service]
6
+ Type=simple
7
+ User=%i
8
+ ExecStart=/usr/bin/gollum
9
+ Restart=on-abort
10
+
11
+ [Install]
12
+ WantedBy=multi-user.target
data/gollum.gemspec CHANGED
@@ -5,8 +5,8 @@ Gem::Specification.new do |s|
5
5
  s.required_ruby_version = '>= 1.9'
6
6
 
7
7
  s.name = 'gollum'
8
- s.version = '3.0.0'
9
- s.date = '2014-04-05'
8
+ s.version = '3.1.0'
9
+ s.date = '2014-11-28'
10
10
  s.rubyforge_project = 'gollum'
11
11
  s.license = 'MIT'
12
12
 
@@ -24,7 +24,7 @@ Gem::Specification.new do |s|
24
24
  s.rdoc_options = ['--charset=UTF-8']
25
25
  s.extra_rdoc_files = %w[README.md LICENSE]
26
26
 
27
- s.add_dependency 'gollum-lib', '~> 3.0'
27
+ s.add_dependency 'gollum-lib', '~> 4.0'
28
28
  s.add_dependency 'github-markdown', '~> 0.6.5'
29
29
  s.add_dependency 'sinatra', '~> 1.4', '>= 1.4.4'
30
30
  s.add_dependency 'mustache', ['>= 0.99.5', '< 1.0.0']
@@ -45,10 +45,14 @@ Gem::Specification.new do |s|
45
45
  Rakefile
46
46
  bin/gollum
47
47
  config.rb
48
+ contrib/openrc/conf.d/gollum
49
+ contrib/openrc/init.d/gollum
50
+ contrib/systemd/gollum@.service
48
51
  docs/sanitization.md
49
52
  gollum.gemspec
50
53
  lib/gollum.rb
51
54
  lib/gollum/app.rb
55
+ lib/gollum/editing_auth.rb
52
56
  lib/gollum/helpers.rb
53
57
  lib/gollum/public/gollum/css/_styles.css
54
58
  lib/gollum/public/gollum/css/dialog.css
@@ -517,6 +521,7 @@ Gem::Specification.new do |s|
517
521
  lib/gollum/templates/history_authors/gravatar.mustache
518
522
  lib/gollum/templates/history_authors/identicon.mustache
519
523
  lib/gollum/templates/history_authors/none.mustache
524
+ lib/gollum/templates/latest_changes.mustache
520
525
  lib/gollum/templates/layout.mustache
521
526
  lib/gollum/templates/page.mustache
522
527
  lib/gollum/templates/pages.mustache
@@ -531,6 +536,7 @@ Gem::Specification.new do |s|
531
536
  lib/gollum/views/file_view.rb
532
537
  lib/gollum/views/has_page.rb
533
538
  lib/gollum/views/history.rb
539
+ lib/gollum/views/latest_changes.rb
534
540
  lib/gollum/views/layout.rb
535
541
  lib/gollum/views/page.rb
536
542
  lib/gollum/views/pages.rb
@@ -538,8 +544,6 @@ Gem::Specification.new do |s|
538
544
  licenses/css_tree_menu_thecssninja/license.txt
539
545
  licenses/licenses.txt
540
546
  licenses/unity_asset_pool/COPYRIGHT
541
- openrc/conf.d/gollum
542
- openrc/init.d/gollum
543
547
  ]
544
548
  # = MANIFEST =
545
549
 
data/lib/gollum.rb CHANGED
@@ -16,7 +16,7 @@ require File.expand_path('../gollum/uri_encode_component', __FILE__)
16
16
  $KCODE = 'U' if RUBY_VERSION[0, 3] == '1.8'
17
17
 
18
18
  module Gollum
19
- VERSION = '3.0.0'
19
+ VERSION = '3.1.0'
20
20
 
21
21
  def self.assets_path
22
22
  ::File.expand_path('gollum/public', ::File.dirname(__FILE__))
data/lib/gollum/app.rb CHANGED
@@ -13,6 +13,8 @@ require 'gollum/views/has_page'
13
13
 
14
14
  require File.expand_path '../helpers', __FILE__
15
15
 
16
+ require 'gollum/editing_auth'
17
+
16
18
  #required to upload bigger binary files
17
19
  Gollum::set_git_timeout(120)
18
20
  Gollum::set_git_max_filesize(190 * 10**6)
@@ -42,6 +44,7 @@ module Precious
42
44
  class App < Sinatra::Base
43
45
  register Mustache::Sinatra
44
46
  include Precious::Helpers
47
+ use Precious::EditingAuth
45
48
 
46
49
  dir = File.dirname(File.expand_path(__FILE__))
47
50
 
@@ -91,6 +94,8 @@ module Precious
91
94
  settings.wiki_options.merge!({ :base_path => @base_url })
92
95
  @css = settings.wiki_options[:css]
93
96
  @js = settings.wiki_options[:js]
97
+ @mathjax_config = settings.wiki_options[:mathjax_config]
98
+ @allow_editing = settings.wiki_options[:allow_editing]
94
99
  end
95
100
 
96
101
  get '/' do
@@ -105,7 +110,6 @@ module Precious
105
110
  # name, path, version
106
111
  def wiki_page(name, path = nil, version = nil, exact = true)
107
112
  wiki = wiki_new
108
-
109
113
  path = name if path.nil?
110
114
  name = extract_name(name) || wiki.index_page
111
115
  path = extract_path(path)
@@ -126,11 +130,14 @@ module Precious
126
130
  end
127
131
 
128
132
  get '/edit/*' do
133
+ forbid unless @allow_editing
129
134
  wikip = wiki_page(params[:splat].first)
130
135
  @name = wikip.name
131
136
  @path = wikip.path
137
+ @upload_dest = find_upload_dest(@path)
132
138
 
133
139
  wiki = wikip.wiki
140
+ @allow_uploads = wiki.allow_uploads
134
141
  if page = wikip.page
135
142
  if wiki.live_preview && page.format.to_s.include?('markdown') && supported_useragent?(request.user_agent)
136
143
  live_preview_url = '/livepreview/index.html?page=' + encodeURIComponent(@name)
@@ -251,21 +258,27 @@ module Precious
251
258
  end
252
259
 
253
260
  get '/delete/*' do
261
+ forbid unless @allow_editing
254
262
  wikip = wiki_page(params[:splat].first)
255
263
  name = wikip.name
256
264
  wiki = wikip.wiki
257
265
  page = wikip.page
258
266
  unless page.nil?
259
- wiki.delete_page(page, { :message => "Destroyed #{name} (#{page.format})" })
267
+ commit = commit_message
268
+ commit[:message] = "Destroyed #{name} (#{page.format})"
269
+ wiki.delete_page(page, commit)
260
270
  end
261
271
 
262
272
  redirect to('/')
263
273
  end
264
274
 
265
275
  get '/create/*' do
276
+ forbid unless @allow_editing
266
277
  wikip = wiki_page(params[:splat].first.gsub('+', '-'))
267
278
  @name = wikip.name.to_url
268
279
  @path = wikip.path
280
+ @allow_uploads = wikip.wiki.allow_uploads
281
+ @upload_dest = find_upload_dest(@path)
269
282
 
270
283
  page_dir = settings.wiki_options[:page_file_dir].to_s
271
284
  unless page_dir.empty?
@@ -351,6 +364,13 @@ module Precious
351
364
  end
352
365
  end
353
366
 
367
+ get '/latest_changes' do
368
+ @wiki = wiki_new
369
+ max_count = settings.wiki_options.fetch(:latest_changes_count, 10)
370
+ @versions = @wiki.latest_changes({:max_count => max_count})
371
+ mustache :latest_changes
372
+ end
373
+
354
374
  post '/compare/*' do
355
375
  @file = params[:splat].first
356
376
  @versions = params[:versions] || []
@@ -396,6 +416,8 @@ module Precious
396
416
  @content = page.formatted_data
397
417
  @version = version
398
418
  mustache :page
419
+ elsif file = wikip.wiki.file("#{file_path}", version, true)
420
+ show_file(file)
399
421
  else
400
422
  halt 404
401
423
  end
@@ -453,10 +475,7 @@ module Precious
453
475
  @page = page
454
476
  @name = name
455
477
  @content = page.formatted_data
456
- @upload_dest = settings.wiki_options[:allow_uploads] ?
457
- (settings.wiki_options[:per_page_uploads] ?
458
- "#{path}/#{@name}".sub(/^\/\//, '') : 'uploads'
459
- ) : ''
478
+ @upload_dest = find_upload_dest(path)
460
479
 
461
480
  # Extensions and layout data
462
481
  @editable = true
@@ -469,18 +488,24 @@ module Precious
469
488
 
470
489
  mustache :page
471
490
  elsif file = wiki.file(fullpath, wiki.ref, true)
472
- if file.on_disk?
473
- send_file file.on_disk_path, :disposition => 'inline'
474
- else
475
- content_type file.mime_type
476
- file.raw_data
477
- end
491
+ show_file(file)
478
492
  else
493
+ not_found unless @allow_editing
479
494
  page_path = [path, name].compact.join('/')
480
495
  redirect to("/create/#{clean_url(encodeURIComponent(page_path))}")
481
496
  end
482
497
  end
483
498
 
499
+ def show_file(file)
500
+ return unless file
501
+ if file.on_disk?
502
+ send_file file.on_disk_path, :disposition => 'inline'
503
+ else
504
+ content_type file.mime_type
505
+ file.raw_data
506
+ end
507
+ end
508
+
484
509
  def update_wiki_page(wiki, page, content, commit, name = nil, format = nil)
485
510
  return if !page ||
486
511
  ((!content || page.raw_data == content) && page.format == format)
@@ -505,5 +530,12 @@ module Precious
505
530
  commit_message.merge! author_parameters unless author_parameters.nil?
506
531
  commit_message
507
532
  end
533
+
534
+ def find_upload_dest(path)
535
+ settings.wiki_options[:allow_uploads] ?
536
+ (settings.wiki_options[:per_page_uploads] ?
537
+ "#{path}/#{@name}".sub(/^\/\//, '') : 'uploads'
538
+ ) : ''
539
+ end
508
540
  end
509
541
  end
@@ -0,0 +1,34 @@
1
+ module Precious
2
+ class EditingAuth < Sinatra::Base
3
+ def initialize(app)
4
+ @app = app
5
+ end
6
+
7
+ def call(env)
8
+ @env = env
9
+ # Blocks all potentially editable pages. Use EditingAuth::whitelist_pages to unblock pages.
10
+ unless (env["REQUEST_METHOD"] == "GET") || App::settings.wiki_options[:allow_editing]
11
+ return block unless excluded_page?
12
+ end
13
+ @app.call(env)
14
+ end
15
+
16
+ def block
17
+ [403, {'Content-Type' => 'text/html', 'Content-Length' => '9'}, ['Forbidden']]
18
+ end
19
+
20
+ def excluded_page?
21
+ return false if env["REQUEST_PATH"].nil?
22
+ whitelist_pages.any? do |whitelisted_page|
23
+ env["REQUEST_PATH"].include? whitelisted_page
24
+ end
25
+ end
26
+
27
+ private
28
+ # List pages paths as str that you want to whitelist.
29
+ # Pages will be compared with env["REQUEST_PATH"] using String::include? method.
30
+ def whitelist_pages
31
+ return ["/compare/"]
32
+ end
33
+ end
34
+ end
@@ -39,5 +39,17 @@ module Precious
39
39
  url.gsub('%2F', '/').gsub(/^\/+/, '').gsub('//', '/')
40
40
  end
41
41
 
42
+ def forbid(msg = "Forbidden.")
43
+ @message = msg
44
+ status 403
45
+ halt mustache :error
46
+ end
47
+
48
+ def not_found(msg = nil)
49
+ @message = msg || "The requested page does not exist."
50
+ status 404
51
+ return mustache :error
52
+ end
53
+
42
54
  end
43
55
  end