Permalink
Browse files

Merge branch 'master' into test-tags-fix

  • Loading branch information...
2 parents 6ad8575 + d913036 commit 52483d7cbed597f24ffb2c8d050cd7e28c9a7350 @adahmash adahmash committed Apr 13, 2012
Showing with 272 additions and 100 deletions.
  1. BIN app/assets/images/template_previews/Double-One-Large-Two-Small.png
  2. BIN app/assets/images/template_previews/Double-Two-Medium.png
  3. BIN app/assets/images/template_previews/Single-Two-Small.png
  4. BIN app/assets/images/template_previews/Triple-1-Large-4-Small.png
  5. BIN app/assets/images/template_previews/Triple-Four-Small.png
  6. BIN app/assets/images/template_previews/Triple-Three-Medium.png
  7. BIN app/assets/images/template_previews/Triple-Two-Large.png
  8. BIN app/assets/images/template_previews/single-col-ad-300x250.png
  9. BIN app/assets/images/template_previews/single-col-custom-weather.png
  10. BIN app/assets/images/template_previews/single-col-facebook-recommendations.png
  11. BIN app/assets/images/template_previews/single-col-newest-items-with-pics.png
  12. BIN app/assets/images/template_previews/single-col-twitter-standard.png
  13. BIN app/assets/images/template_previews/single-col-universal-top-items-list.png
  14. BIN app/assets/images/template_previews/single-col-user-images.png
  15. BIN app/assets/images/template_previews/single-col-welcome-panel.png
  16. +17 −0 app/assets/stylesheets/admin.sass
  17. +24 −0 app/controllers/admin/branding_controller.rb
  18. +0 −1 app/controllers/admin/view_objects_controller.rb
  19. +1 −1 app/controllers/admin/widgets_controller.rb
  20. +5 −1 app/controllers/admin_controller.rb
  21. +17 −0 app/controllers/branding_controller.rb
  22. +5 −1 app/helpers/layout_helper.rb
  23. +13 −0 app/models/branding.rb
  24. +3 −0 app/models/metadata/custom_widget.rb
  25. +2 −0 app/models/view_object.rb
  26. +20 −0 app/views/admin/branding/show.html.haml
  27. +1 −0 app/views/admin/view_objects/edit.html.haml
  28. +15 −4 app/views/admin/view_objects/new.html.haml
  29. +3 −1 app/views/admin/view_objects/show.html.haml
  30. +1 −0 app/views/layouts/new_admin.html.haml
  31. +7 −0 app/views/shared/_header.html.haml
  32. +3 −1 config/routes/admin.rb
  33. +4 −1 config/routes/main.rb
  34. +11 −0 db/migrate/20120406052102_add_branding.rb
  35. +17 −0 db/migrate/20120408023719_change_view_object_template_names.rb
  36. +20 −0 db/migrate/20120409185035_remove_old_vo_templates.rb
  37. +6 −0 db/migrate/20120409195722_add_is_blockable_to_view_objects.rb
  38. +6 −0 db/migrate/20120409203626_add_is_blockable_to_metadatas.rb
  39. +41 −0 db/migrate/20120411203207_add_preview_to_view_object_templates.rb
  40. +28 −87 db/seeds.rb
  41. +2 −2 lib/view_tree.rb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@@ -252,3 +252,20 @@ ul.forums
display: inline-block
width: 100%
height: 100%
+
+.template-selection
+ height: 100px
+
+.template-select-column
+ width: 425px
+ margin-left: -20px
+ float: left
+ padding: 10px 10px 10px 0px
+
+.template-preview-column
+ width: 400px
+ float: right
+ margin-right: 25px
+ padding: 10px
+ img
+ max-width: 400px
@@ -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
@@ -3,7 +3,6 @@ class Admin::ViewObjectsController < AdminController
admin_scaffold :view_object do |config|
config.index_fields = [:name, :view_object_template_id]
- #config.show_fields = [:name, :view_object_template_id]
config.actions = [:index]
config.associations = { :belongs_to => { :view_object_template => :view_object_template_id } }
config.order_by = "name asc"
@@ -47,7 +47,7 @@ def newer_widgets
]
@page = ViewObject.find_by_name("home--index")
@view_objects = ViewObject.find(:all, :conditions => ["view_object_template_id is not null"])
- @editable_view_objects = ["v2_double_col_feature_triple_item", "v2_double_col_triple_item", "v2_triple_col_large_2"].map {|name| ViewObjectTemplate.find_by_name(name) }.map(&:view_objects).flatten.select {|vo| vo.setting.kommands.empty? }
+ #@editable_view_objects = ["v2_double_col_feature_triple_item", "v2_double_col_triple_item", "v2_triple_col_large_2"].map {|name| ViewObjectTemplate.find_by_name(name) }.map(&:view_objects).flatten.select {|vo| vo.setting.kommands.empty? }
@main = Widget.main
@sidebar = Widget.sidebar
if @page.present? and @page.edge_children.present?
@@ -160,7 +160,11 @@ def find_moderatable_item
if name =~ /(.+)_id$/
# switch story requests to use the content model
klass = $1 == 'story' ? 'content' : $1
- return klass.classify.constantize.find(value)
+ if klass.classify == "CustomWidget"
+ return Metadata::CustomWidget.find(value)
+ else
+ return klass.classify.constantize.find(value)
+ end
end
end
nil
@@ -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
@@ -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
@@ -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
@@ -1,4 +1,7 @@
class Metadata::CustomWidget < Metadata
+
+ acts_as_moderatable
+
metadata_keys :title, :custom_data, :content_type
scope :key_sub_type_name, lambda { |*args| { :conditions => ["key_sub_type = ? AND key_name = ?", args.first, args.second] } }
@@ -1,5 +1,7 @@
class ViewObject < ActiveRecord::Base
+ acts_as_moderatable
+
belongs_to :view_object_template
belongs_to :parent, :class_name => "ViewObject", :foreign_key => :parent_id
has_one :setting, :class_name => "Metadata", :as => :metadatable
@@ -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"
@@ -100,6 +100,7 @@
= label_tag 'view_object_setting[cache_disabled]', 'Disable Caching', :class => "label" do
= check_box_tag 'view_object_setting[cache_disabled]', 1, @view_object_setting.cache_disabled
Disable Caching
+ %li= link_to(@view_object.blocked? ? 'UnBlock' : 'Block', admin_block_path(@view_object.class.name.foreign_key.to_sym => @view_object))
= field_set_tag nil, :class => 'buttons' do
%ol
@@ -41,6 +41,9 @@
var templateID = $(this).val();
var rangeOptions = optionsFromRange(rangeForTemplate(templateID));
$('#view_object_setting_kommand_limit').html(rangeOptions.join(''));
+ $('.preview').fadeOut();
+ var template_id = $('option:selected', this).val();
+ $('#preview-' + template_id).fadeIn();
});
$('#view_object_setting_klass_name').change(function(event) {
@@ -82,9 +85,18 @@
%li.input.string
= label_tag 'view_object_setting[locale_subtitle]', 'Locale Subtitle*', :class => "label"
= text_field_tag 'view_object_setting[locale_subtitle]', @view_object_setting.locale_subtitle
- %li.input.string
- = label_tag 'view_object[view_object_template_id]', 'Template*', :class => "label"
- = select_tag 'view_object[view_object_template_id]', options_for_select(select_view_object_template_options, @view_object.view_object_template_id)
+ %div.template-selection
+ %div.template-select-column
+ %li.input.string
+ = label_tag 'view_object[view_object_template_id]', 'Template*', :class => "label"
+ = select_tag 'view_object[view_object_template_id]', options_for_select(select_view_object_template_options, @view_object.view_object_template_id)
+ %div.template-preview-column
+ %h5 Template Preview
+ - ViewObjectTemplate.all.each do |t|
+ - if t.id == @view_object.view_object_template_id
+ .preview{:id => "preview-#{t.id}", :style => "display:block;"}= image_tag t.preview unless t.preview.nil?
+ - else
+ .preview{:id => "preview-#{t.id}", :style => "display:nil;"}= image_tag t.preview unless t.preview.nil?
%li.input.string
= label_tag 'view_object_setting[klass_name]', 'Model Resource*', :class => "label"
= select_tag 'view_object_setting[klass_name]', options_for_select(select_view_object_class_options, @view_object_setting.klass_name)
@@ -106,7 +118,6 @@
= label_tag 'view_object_setting[cache_disabled]', 'Disable Caching', :class => "label" do
= check_box_tag 'view_object_setting[cache_disabled]', 1, @view_object_setting.cache_disabled
Disable Caching
-
= field_set_tag nil, :class => 'buttons' do
%ol
%li
@@ -9,7 +9,7 @@
%p== Locale Title Text: #{t(@view_object_setting.locale_title.try(:to_sym)) || @view_object_setting.locale_title}
- if @view_object_setting.locale_subtitle.present?
%p== Locale Subtitle Text: #{t(@view_object_setting.locale_subtitle.to_sym) || @view_object_setting.locale_subtitle}
- - unless @view_object_setting.is_curated
+ - unless @view_object_setting.is_curated or @view_object_setting.kommands.empty?
%p== Model Resource: #{@view_object_setting.klass_name.tableize.titleize}
- kommand = @view_object_setting.kommands.first
%p== Model Method: #{kommand[:method_name].titleize}
@@ -33,6 +33,8 @@
- else
= link_to "Edit", edit_admin_view_object_path(@view_object)
|
+ = link_to(@view_object.blocked? ? 'UnBlock' : 'Block', admin_block_path(@view_object.class.name.foreign_key.to_sym => @view_object))
+ |
= link_to "Clone", clone_admin_view_object_path(@view_object)
-#
%h2 Update View Object
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -0,0 +1,17 @@
+class ChangeViewObjectTemplateNames < ActiveRecord::Migration
+ def up
+ ViewObjectTemplate.all.each do |t|
+ pn = String.new(t.pretty_name)
+ pn = pn.replace(pn[10..100] + "(#{pn[0..8]})") unless !pn.match(/^Version.*/)
+ t.update_attribute :pretty_name, pn unless pn.nil?
+ end
+ end
+
+ def down
+ ViewObjectTemplate.all.each do |t|
+ pn = String.new(t.pretty_name)
+ pn = pn.replace(pn[(pn.length-10)..(pn.length-2)] + " " + pn[0,(pn.length-11)]) unless !pn.match(/.?\(Version 2|3\)$/)
+ t.update_attribute :pretty_name, pn unless pn.nil?
+ end
+ end
+end
@@ -0,0 +1,20 @@
+class RemoveOldVoTemplates < ActiveRecord::Migration
+ def up
+ template_names = ["v2_single_col_list",
+ "v2_triple_col_large_2",
+ "v2_double_col_feature",
+ "v2_single_col_small_list",
+ "v2_single_col_item",
+ "v2_double_col_item",
+ "v2_double_col_item_list",
+ "v2_double_col_triple_item",
+ "v2_double_col_feature_triple_item"]
+ template_names.each do |tn|
+ tn = ViewObjectTemplate.find_by_name(tn)
+ tn.destroy
+ end
+ end
+
+ def down
+ end
+end
@@ -0,0 +1,6 @@
+class AddIsBlockableToViewObjects < ActiveRecord::Migration
+ def change
+ add_column :view_objects, :is_blocked, :boolean, :default => false
+ add_index :view_objects, :is_blocked
+ end
+end
@@ -0,0 +1,6 @@
+class AddIsBlockableToMetadatas < ActiveRecord::Migration
+ def change
+ add_column :metadatas, :is_blocked, :boolean, :default => false
+ add_index :metadatas, :is_blocked
+ end
+end
@@ -0,0 +1,41 @@
+class AddPreviewToViewObjectTemplates < ActiveRecord::Migration
+ def change
+ add_column :view_object_templates, :preview, :string, :default => nil
+
+ vt = ViewObjectTemplate.find_by_name "v3_double_col_1_large_2_small"
+ vt.update_attribute :preview, "template_previews/Double-One-Large-Two-Small.png"
+
+ vt = ViewObjectTemplate.find_by_name "v3_double_col_2_medium"
+ vt.update_attribute :preview, "template_previews/Double-Two-Medium.png"
+
+ vt = ViewObjectTemplate.find_by_name "v3_triple_col_1_large_4_small"
+ vt.update_attribute :preview, "template_previews/Triple-1-Large-4-Small.png"
+
+
+ vt = ViewObjectTemplate.find_by_name "v3_triple_col_4_small"
+ vt.update_attribute :preview, "template_previews/Triple-Four-Small.png"
+
+
+ vt = ViewObjectTemplate.find_by_name "v3_triple_col_3_medium"
+ vt.update_attribute :preview, "template_previews/Triple-Three-Medium.png"
+
+
+ vt = ViewObjectTemplate.find_by_name "v3_triple_col_2_large"
+ vt.update_attribute :preview, "template_previews/Triple-Two-Large.png"
+
+ vt = ViewObjectTemplate.find_by_name "v2_single_col_list_with_profile"
+ vt.update_attribute :preview, "template_previews/single-col-newest-items-with-pics.png"
+
+ vt = ViewObjectTemplate.find_by_name "v2_single_facebook_widget"
+ vt.update_attribute :preview, "template_previews/single-col-facebook-recommendations.png"
+
+ vt = ViewObjectTemplate.find_by_name "v3_single_col_item_list"
+ vt.update_attribute :preview, "template_previews/single-col-universal-top-items-list.png"
+
+ vt = ViewObjectTemplate.find_by_name "v2_single_col_user_list"
+ vt.update_attribute :preview, "template_previews/single-col-user-images.png"
+
+ vt = ViewObjectTemplate.find_by_name "v2_welcome_panel"
+ vt.update_attribute :preview, "template_previews/single-col-welcome-panel.png"
+ end
+end
Oops, something went wrong.

0 comments on commit 52483d7

Please sign in to comment.