Browse files

Merge pull request #374 from arr2036/optional_livepreview

Optional livepreview
  • Loading branch information...
2 parents 59ac86c + 3c709a2 commit ccf70590a40209f8bb8a6f921943196768307c4e @bootstraponline bootstraponline committed Jun 7, 2012
Showing with 7 additions and 1 deletion.
  1. +4 −0 bin/gollum
  2. +1 −1 lib/gollum/frontend/app.rb
  3. +2 −0 lib/gollum/wiki.rb
View
4 bin/gollum
@@ -57,6 +57,10 @@ opts = OptionParser.new do |opts|
wiki_options[:ref] = ref
end
+ opts.on("--no-live-preview", "Disables livepreview.") do
+ wiki_options[:live_preview] = false
+ end
+
opts.on("--no-mathjax", "Disables mathjax.") do
options['mathjax'] = false
end
View
2 lib/gollum/frontend/app.rb
@@ -76,7 +76,7 @@ def supported_useragent?( user_agent )
@name = params[:splat].first
wiki = Gollum::Wiki.new(settings.gollum_path, settings.wiki_options)
if page = wiki.page(@name)
- if page.format.to_s.include?('markdown') && supported_useragent?(request.user_agent)
+ if settings.wiki_options[:live_preview] && page.format.to_s.include?('markdown') && supported_useragent?(request.user_agent)
redirect '/livepreview/index.html?page=' + encodeURIComponent(@name)
else
@page = page
View
2 lib/gollum/wiki.rb
@@ -139,6 +139,7 @@ def history_sanitization
# site.
# options - Optional Hash:
# :universal_toc - Table of contents on all pages. Default: false
+ # :live_preview - Livepreview editing for markdown files. Default: true
# :base_path - String base path for all Wiki links.
# Default: "/"
# :page_class - The page Class. Default: Gollum::Page
@@ -173,6 +174,7 @@ def initialize(path, options = {})
self.class.default_ws_subs
@history_sanitization = options[:history_sanitization] ||
self.class.history_sanitization
+ @live_preview = options.fetch(:live_preview, true)
@universal_toc = options.fetch(:universal_toc, false)
@mathjax = options[:mathjax] || true
end

0 comments on commit ccf7059

Please sign in to comment.