Skip to content
This repository has been archived by the owner on Feb 28, 2022. It is now read-only.

Commit

Permalink
Fall back to old edit mode for browsers that are not officially suppo…
Browse files Browse the repository at this point in the history
…rted by Ace.
  • Loading branch information
bootstraponline committed May 29, 2012
1 parent 76f87f9 commit aeeaeb1
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
1 change: 1 addition & 0 deletions gollum.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ Gem::Specification.new do |s|
s.add_dependency('mustache', [">= 0.11.2", "< 1.0.0"])
s.add_dependency('sanitize', "~> 2.0.0")
s.add_dependency('nokogiri', "~> 1.4")
s.add_dependency('useragent', "~> 0.4.9")

s.add_development_dependency('RedCloth')
s.add_development_dependency('mocha')
Expand Down
11 changes: 10 additions & 1 deletion lib/gollum/frontend/app.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
require 'sinatra'
require 'gollum'
require 'mustache/sinatra'
require 'useragent'

require 'gollum/frontend/views/layout'
require 'gollum/frontend/views/editable'
Expand All @@ -25,6 +26,14 @@ class App < Sinatra::Base

dir = File.dirname(File.expand_path(__FILE__))

# Detect unsupported browsers.
@@supported_browsers = ['Firefox', 'Chrome', 'Safari']

def is_supported( user_agent )
browser = UserAgent.parse( user_agent ).browser
@@supported_browsers.include? browser
end

# We want to serve public assets for now
set :public_folder, "#{dir}/public/gollum"
set :static, true
Expand Down Expand Up @@ -67,7 +76,7 @@ class App < Sinatra::Base
@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')
if page.format.to_s.include?('markdown') && is_supported( request.user_agent )
redirect '/livepreview/index.html?page=' + encodeURIComponent(@name)
else
@page = page
Expand Down

0 comments on commit aeeaeb1

Please sign in to comment.