From 5ab4bbd36731bac8285a6efd3289b2b066718eca Mon Sep 17 00:00:00 2001 From: Fu Matthew Date: Wed, 9 Jan 2013 16:54:33 +0800 Subject: [PATCH] add ad_banner inner page,pic title. --- app/controllers/front_controller.rb | 4 ++++ app/controllers/pages_controller.rb | 1 - app/helpers/front_helper.rb | 9 +++++++++ app/views/front/show_banner.html.erb | 2 +- app/views/front/show_inner_ad_image.html.erb | 21 ++++++++++++++++++++ config/routes.rb | 2 ++ lib/tasks/migrate.rake | 6 ++++++ 7 files changed, 43 insertions(+), 2 deletions(-) create mode 100644 app/helpers/front_helper.rb create mode 100644 app/views/front/show_inner_ad_image.html.erb diff --git a/app/controllers/front_controller.rb b/app/controllers/front_controller.rb index 0ef39633..eb14b25d 100644 --- a/app/controllers/front_controller.rb +++ b/app/controllers/front_controller.rb @@ -28,6 +28,10 @@ class FrontController < ApplicationController @page_id = params[:page_id] end + def show_inner_ad_image + @ad_image = AdImage.find(params[:id]) rescue nil + @ad_images = AdImage.all + end private diff --git a/app/controllers/pages_controller.rb b/app/controllers/pages_controller.rb index a6535c5f..57e6a5ff 100644 --- a/app/controllers/pages_controller.rb +++ b/app/controllers/pages_controller.rb @@ -65,7 +65,6 @@ class PagesController < ApplicationController def get_item module_app = ModuleApp.first(:conditions => {:key => params[:app_name]}) - if !params[:category_id].blank? && !params[:tag_id].blank? @item = Item.first(:conditions => {:module_app_id => module_app.id, :app_frontend_url => params[:app_action], :category => params[:category_id], :tag => params[:tag_id]}) @item = Item.first(:conditions => {:module_app_id => module_app.id, :app_frontend_url => params[:app_action], :category => params[:category_id], :tag => ''}) unless @item diff --git a/app/helpers/front_helper.rb b/app/helpers/front_helper.rb new file mode 100644 index 00000000..b44f28f2 --- /dev/null +++ b/app/helpers/front_helper.rb @@ -0,0 +1,9 @@ +module FrontHelper + + def ad_image_link(ad_image) + link = ad_image.out_link + link =front_show_inner_ad_image_path(:id=> ad_image.id) if link.blank? && !ad_image.context.blank? + + end + +end \ No newline at end of file diff --git a/app/views/front/show_banner.html.erb b/app/views/front/show_banner.html.erb index 921c360d..10dee26a 100644 --- a/app/views/front/show_banner.html.erb +++ b/app/views/front/show_banner.html.erb @@ -19,7 +19,7 @@
<% (images = @ad_banner.ad_images).shuffle.each do |ad_image| %> <% if ad_image.display? %> - <%= ad_image.title || ' time_to_next='<%= @ad_banner.transition_msec %>' link_open='<%= ad_image.link_open %>' link_url='<%= (ad_image.out_link) %>' style=' <%= 'cursor:pointer;' if !ad_image.out_link.blank? %>'/> + <%= ad_image.title || ' title='<%= ad_image.title || ' ' %>' time_to_next='<%= @ad_banner.transition_msec %>' link_open='<%= ad_image.link_open %>' link_url='<%= ad_image_link(ad_image)%>' style=' <%= 'cursor:pointer;' if !ad_image.out_link.blank? %>'/> <% end %> <% end %>
diff --git a/app/views/front/show_inner_ad_image.html.erb b/app/views/front/show_inner_ad_image.html.erb new file mode 100644 index 00000000..39350f62 --- /dev/null +++ b/app/views/front/show_inner_ad_image.html.erb @@ -0,0 +1,21 @@ +<%if @ad_image && @ad_image.display? %> +

<%= @ad_image.title %>

+
+
+ <%= display_date_time(@ad_image.post_date) %> +
+
+
+ <%#= image_tag(@ad_image.image.url, :size => "320x240") if @ad_image.image.file %> + <%= link_to image_tag(@ad_image.file.url, :size => "320x240"), @ad_image.file.url, {:target => '_blank', :title => @ad_image.title} if @ad_image.file.file %> +
+
+ <%= @ad_image.context.html_safe rescue '' %> +
+ + <%#= share_links(@ad_image, 'ad_image') %> + + +<% else %> + +<% end %> \ No newline at end of file diff --git a/config/routes.rb b/config/routes.rb index 20ddb31f..74130c07 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -280,4 +280,6 @@ Orbit::Application.routes.draw do root :to => 'pages#index' + match '/panel/ad_banner/front_end/inner_page/:id' => 'front#show_inner_ad_image', :as => :front_show_inner_ad_image + end diff --git a/lib/tasks/migrate.rake b/lib/tasks/migrate.rake index 63994388..e55ab296 100644 --- a/lib/tasks/migrate.rake +++ b/lib/tasks/migrate.rake @@ -383,5 +383,11 @@ namespace :migrate do end end + task :add_inner_page_for_ad_banner => :environment do + a = ModuleApp.where(:key=>'ad_banner').first + a.app_pages = ["inner_page"] + a.save + end + end