Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Refactored everything

  • Loading branch information...
commit fd988bab5f9370cfb797edd533d65b2279fb4cc9 1 parent 3f08162
Khalid Shaikh authored
13 lib/brandy.rb
View
@@ -1,19 +1,12 @@
require "brandy/version"
-require "brandy/action_view"
+require "brandy/brandy_helper"
+require "branding"
module Brandy
class << self
- attr_accessor :brands
-
- def load_file
- @brands = YAML::load_file 'config/branding.yml'
- end
-
def prefix request
- @brands[request.domain.split('.').last] ||= @brands.values.first
+ Branding.config['domains'][Branding.tld(request)] || Branding.config['domains']['com'] || 'nexia'
end
-
end
- load_file
end
16 lib/brandy/action_view.rb
View
@@ -1,16 +0,0 @@
-module ActionView
- module Helpers
- module AssetTagHelper
-
- def image_path(source)
- "/" + Brandy.prefix(request) + compute_public_path(source, 'images')
- end
- alias_method :path_to_image, :image_path # aliased to avoid conflicts with an image_path named route
-
- def stylesheet_path(source)
- "/" + Brandy.prefix(request) + compute_public_path(source, 'stylesheets', 'css')
- end
- alias_method :path_to_stylesheet, :stylesheet_path
- end
- end
-end
34 lib/brandy/brandy_helper.rb
View
@@ -0,0 +1,34 @@
+module BrandyHelper
+
+ # branded_image_tag 'image'
+ # nexia/image
+ #
+ # branded_image_tag '/image'
+ # nexia/image
+
+ # branded_image_tag 'intro'
+ # /images
+
+ def branded_image_tag(source, options = {})
+ image_tag(File.join(Brandy.prefix(request), source), options)
+ end
+
+ def branded_stylesheet_link_tag(*sources)
+ options = sources.extract_options!
+ sources.map!{ |source| File.join(Brandy.prefix(request), source) }
+ sources << options
+ stylesheet_link_tag *sources
+ end
+
+ # def branded_image_path(source)
+ # "/" + Brandy.prefix(request) + compute_public_path(source, 'images')
+ # end
+ # alias_method :path_to_image, :image_path # aliased to avoid conflicts with an image_path named route
+
+ # def branded_stylesheet_path(source)
+ # "/" + Brandy.prefix(request) + compute_public_path(source, 'stylesheets', 'css')
+ # end
+ # alias_method :path_to_stylesheet, :stylesheet_path
+
+end
+include BrandyHelper
Please sign in to comment.
Something went wrong with that request. Please try again.