lib/darkext/sinatra.rb in darkhelmet-darkext-0.8.2 vs lib/darkext/sinatra.rb in darkhelmet-darkext-0.8.3
- old
+ new
@@ -1,8 +1,10 @@
-module Darkext
- module Sinatra
- module Helpers
+require 'sinatra/base'
+
+module Sinatra
+ module DarkHelpers
+ module HelperMethods
def view(view, options = {})
html = haml(view,options)
flash.clear
html
end
@@ -11,15 +13,15 @@
# Can't make this use view() because of the flash.clear
haml(page, options.merge!(:layout => false))
end
def css_link_tag(sheet, media = 'screen,projection')
- partial("%link{ :type => 'text/css', :href => '/stylesheets/#{sheet}.css', :rel => 'stylesheet', :media => '#{media}' }")
+ partial("%link{ :type => 'text/css', :href => 'stylesheets/#{sheet}.css', :rel => 'stylesheet', :media => '#{media}' }")
end
def js_script_tag(script)
- partial("%script{ :type => 'text/javascript', :src => '/javascripts/#{script}.js' }")
+ partial("%script{ :type => 'text/javascript', :src => 'javascripts/#{script}.js' }")
end
def js_tag(script)
@dsh_script = script
temp = ["%script{ :type => 'text/javascript' }",
@@ -33,11 +35,11 @@
session[:flash] = {} if session[:flash] && session[:flash].class != Hash
session[:flash] ||= {}
end
def host
- port = request.env['SERVER_PORT']
+ port = request.env['SERVER_PORT'].to_i
port = port == 80 ? "" : ":#{port}"
"#{protocol}://#{server_name}#{port}"
end
def protocol
@@ -54,7 +56,13 @@
def base
"#{host}#{options.site_base}"
end
end
+
+ def self.registered(app)
+ app.helpers HelperMethods
+ end
end
+
+ register DarkHelpers
end