Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge remote-tracking branch 'joev/logo' into favicon-test

  • Loading branch information...
commit 91ff2cd725ff9fc54281f3fd3a33f77674448061 2 parents 82dafd6 + e685926
@adahmash adahmash authored
View
24 app/controllers/admin/branding_controller.rb
@@ -0,0 +1,24 @@
+class Admin::BrandingController < AdminController
+ before_filter :set_current_tab
+
+ def create
+ if params[:logo]
+ Branding.main.update_attribute(:logo, params[:logo].read)
+ end
+ if params[:favicon]
+ Branding.main.update_attribute(:favicon, params[:favicon].read)
+ end
+ flash[:notice] = "Updated!"
+ redirect_to :action => 'show'
+ end
+
+ def show
+ end
+
+ private
+
+ def set_current_tab
+ @current_tab = 'settings'
+ end
+
+end
View
17 app/controllers/branding_controller.rb
@@ -0,0 +1,17 @@
+class BrandingController < ActionController::Base
+ def logo
+ send_file(Branding.logo)
+ end
+
+ def favicon
+ send_file(Branding.favicon)
+ end
+
+ private
+
+ def send_file data
+ if data.present?
+ send_data(data, :disposition => 'inline', :content_type => 'image/png')
+ end
+ end
+end
View
6 app/helpers/layout_helper.rb
@@ -40,7 +40,11 @@ def icon_fan_app_location
end
def icon_fan_app_url
- base_url(path_to_image(icon_fan_app_location))
+ if Branding.favicon
+ favicon_branding_url
+ else
+ base_url(path_to_image(icon_fan_app_location))
+ end
end
def item_page_title item
View
13 app/models/branding.rb
@@ -0,0 +1,13 @@
+class Branding < ActiveRecord::Base
+ def self.logo
+ main.logo
+ end
+
+ def self.favicon
+ main.favicon
+ end
+
+ def self.main
+ Branding.first || Branding.create!
+ end
+end
View
20 app/views/admin/branding/show.html.haml
@@ -0,0 +1,20 @@
+%h1 Site Branding
+
+= form_tag '', :multipart => true do
+
+ %p
+ = file_field_tag :logo
+ - if Branding.logo
+ = image_tag logo_branding_url
+ - else
+ No logo uploaded yet.
+
+ %p
+ = file_field_tag :favicon
+ - if Branding.favicon
+ = image_tag favicon_branding_url
+ - else
+ No favicon uploaded yet.
+
+
+ = submit_tag "Update Site Branding"
View
1  app/views/layouts/new_admin.html.haml
@@ -169,6 +169,7 @@
%li= link_to 'Translations', admin_translations_path
%li= link_to 'Refresh changes', refresh_admin_locales_path
%li= link_to 'Menu Items', admin_menu_items_path
+ %li= link_to 'Logo / Favicon', admin_branding_path
%li
%a{:href => "#links"} Your Site
%ul
View
7 app/views/shared/_header.html.haml
@@ -4,6 +4,13 @@
%h1#site-name-wrap
%a#site-name{:title => "Front Page - #{get_setting('site_title').try(:value)}", :href => "#{root_url}"}= get_setting('site_title').try(:value)
+ - # Override css with custom logo if provided
+ - if Branding.logo
+ %style{:type => 'text/css'}
+ :sass
+ #site-name
+ background-image: url(#{logo_branding_url}) !important
+
#header-actions
- cache :google_search_header_html, :expires_in => 180.minute do
- if Metadata::Setting.find_setting('google_search_engine_id').present?
View
4 config/routes/admin.rb
@@ -7,6 +7,8 @@
match '/translations.:format' => 'translations#translations', :as => :translations
match '/asset_translations.:format' => 'translations#asset_translations', :as => :asset_translations
+ resource :branding, :controller => 'branding'
+
resources :activity_scores
resources :ad_layouts
resources :ads
@@ -94,7 +96,7 @@
post :save
end
end
-
+
resources :newswires
resources :prediction_groups do
member do
View
5 config/routes/main.rb
@@ -13,6 +13,9 @@
end
end
+ match '/branding/logo' => 'branding#logo', :as => :logo_branding
+ match '/favicon.ico' => 'branding#favicon', :as => :favicon_branding
+
resources :resource_sections do
resources :resources
member do
@@ -124,7 +127,7 @@
match '/classifieds/:id/set_status/:status.:format' => 'classifieds#set_status', :as => :set_status_classified
match '/classifieds/category/:category.:format' => 'classifieds#categories', :as => :categorized_classifieds
match '/classifieds/category/:category/page/:page.:format' => 'classifieds#categories', :as => :categorized_classifieds_with_page
-
+
match '/tags/suggest' => 'tags#suggest', :as => :tags_suggest
resources :users do
View
11 db/migrate/20120406052102_add_branding.rb
@@ -0,0 +1,11 @@
+class AddBranding < ActiveRecord::Migration
+ def up
+ create_table :brandings do |t|
+ t.binary :logo
+ t.binary :favicon
+ end
+ end
+
+ def down
+ end
+end
Please sign in to comment.
Something went wrong with that request. Please try again.