Skip to content
Browse files

Can choose to have compressed output of bkbk.js or not

Pass ?compressed=true to bkbk.js path
  • Loading branch information...
1 parent 04818fd commit 9c4c741682bbb19cdde680677a9c3bf7b33f0b9c @cannikin committed
Showing with 7 additions and 4 deletions.
  1. +7 −4 app.rb
View
11 app.rb
@@ -39,11 +39,14 @@
if @user = User.where(:uuid => params[:u]).first
@js_lib = File.read("public/javascripts/#{params[:lib]}.min.js")
@styles = Sass::Engine.new(File.read('views/styles.css.sass'),
- :style => :compressed).render.chomp
+ :style => :compressed).render.chomp.gsub(/"/,'\"')
headers "Content-Type" => "application/javascript"
- erb :'bookmark.js'
- # uglify 'bookmark.js.erb'
+ if params[:compressed]
+ uglify 'bookmark.js.erb'
+ else
+ erb :'bookmark.js'
+ end
else
User.where(:uuid => params[:u]).inspect
end
@@ -155,7 +158,7 @@ def host_with_port
# Runs the named JS file through the Uglifier gem
def uglify(file)
- Uglifier.compile(ERB.new(File.read(File.join('views', file))).result(binding))
+ Uglifier.compile(ERB.new(File.read(File.join('views', file))).result(binding).force_encoding('UTF-8').gsub(/^#.*?\n/,''))
end
def bookmark_output(bookmark)

0 comments on commit 9c4c741

Please sign in to comment.
Something went wrong with that request. Please try again.