widget & frontend field

This commit is contained in:
unknown 2012-08-09 15:25:30 +08:00
parent c0cac812c5
commit d5c55c9697
19 changed files with 604 additions and 100 deletions

View File

@ -11,6 +11,11 @@ class Admin::ModuleAppsController < ApplicationController
def reload_frontend_pages def reload_frontend_pages
@module_app = ModuleApp.find(params[:id]) @module_app = ModuleApp.find(params[:id])
@frontend_path = @module_app.widgets.keys[0] if ( !@module_app.widgets.blank? && @module_app.widgets[0].blank? )
@frontend_style = @module_app.widgets[@frontend_path] if ( !@frontend_path.blank? )
case @module_app.key case @module_app.key
when 'announcement' when 'announcement'
@categories = BulletinCategory.all @categories = BulletinCategory.all

View File

@ -49,6 +49,10 @@ class Admin::PagePartsController < ApplicationController
def update def update
@part = PagePart.find(params[:id]) @part = PagePart.find(params[:id])
params[:page_part][:widget_field] = params[:page_part][:widget_field].zip( params[:page_part][:widget_field_type] )
params[:page_part][:widget_field_type] = nil
if @part.update_attributes(params[:page_part]) if @part.update_attributes(params[:page_part])
set_children_sub_menu(@part) if @part.public_r_tag && @part.public_r_tag.eql?('sub_menu') set_children_sub_menu(@part) if @part.public_r_tag && @part.public_r_tag.eql?('sub_menu')
flash.now[:notice] = t('admin.update_success_content') flash.now[:notice] = t('admin.update_success_content')
@ -74,11 +78,12 @@ class Admin::PagePartsController < ApplicationController
def reload_widgets def reload_widgets
@module_app = ModuleApp.find(params[:id]) @module_app = ModuleApp.find(params[:id])
@widget_path = @module_app.widgets.keys[0] @widget_path = @module_app.widgets.keys[0] if ( @module_app.widgets[0].blank? )
@widget_style = @module_app.widgets[@widget_path]
@widget_style = @module_app.widgets[@widget_path] if ( !@widget_path.blank? )
case @module_app.key case @module_app.key
when 'announcement' when 'announcement'
# @widget_style = @module_app.widgets['index']
@categories = BulletinCategory.all @categories = BulletinCategory.all
@tags = AnnouncementTag.all @tags = AnnouncementTag.all
when 'news' when 'news'

View File

@ -28,10 +28,19 @@ class Admin::PagesController < ApplicationController
def edit def edit
@item = Page.find(params[:id]) @item = Page.find(params[:id])
@apps = ModuleApp.excludes(app_pages: nil).entries @apps = ModuleApp.excludes(app_pages: nil).entries
@module_apps = ModuleApp.excludes(widgets: nil).where(enable_frontend: true).order_by(:title, :asc)
@designs = Design.all.entries @designs = Design.all.entries
@design = @item.design ? @item.design : @designs.first @design = @item.design ? @item.design : @designs.first
@app_frontend_urls = @item.module_app.app_pages if @item.module_app @app_frontend_urls = @item.module_app.app_pages if @item.module_app
if @item.module_app if @item.module_app
@module_app = @item.module_app
@frontend_path = @item.app_frontend_url ? @item.app_frontend_url : @module_app.widgets.keys[0]
@frontend_style = @module_app.widgets[@frontend_path] if !@frontend_path.blank? && !@module_app.widgets.blank?
case @item.module_app.key case @item.module_app.key
when 'announcement' when 'announcement'
@categories = BulletinCategory.all @categories = BulletinCategory.all
@ -45,6 +54,7 @@ class Admin::PagesController < ApplicationController
end end
else else
@categories = nil @categories = nil
@module_app = @module_apps[0]
end end
end end
@ -79,6 +89,9 @@ class Admin::PagesController < ApplicationController
@item.page_contexts.build(:create_user_id => current_user.id, :update_user_id => current_user.id ) @item.page_contexts.build(:create_user_id => current_user.id, :update_user_id => current_user.id )
end end
params[:page][:frontend_field] = params[:page][:frontend_field].zip( params[:page][:frontend_field_type] )
params[:page][:frontend_field_type] = nil
if @item.update_attributes(params[:page]) if @item.update_attributes(params[:page])
flash[:notice] = t('admin.update_success_page') flash[:notice] = t('admin.update_success_page')
respond_to do |format| respond_to do |format|

View File

@ -10,6 +10,10 @@ class Page < Item
field :tag field :tag
field :view_count, :type => Integer, :default => 0 field :view_count, :type => Integer, :default => 0
field :frontend_style
field :frontend_field , :type => Array
field :frontend_data_count
belongs_to :design belongs_to :design
belongs_to :module_app belongs_to :module_app
has_one :title, :class_name => "I18nVariable", :as => :language_value, :autosave => true, :dependent => :destroy has_one :title, :class_name => "I18nVariable", :as => :language_value, :autosave => true, :dependent => :destroy
@ -18,7 +22,7 @@ class Page < Item
has_many :page_metas, :autosave => true, :dependent => :destroy has_many :page_metas, :autosave => true, :dependent => :destroy
accepts_nested_attributes_for :page_parts, :allow_destroy => true accepts_nested_attributes_for :page_parts, :allow_destroy => true
before_save :create_parts, :set_key before_save :create_parts, :set_key , :delete_empty_frontend_field
# embeds_many :custom_images, :class_name => 'Image', as: :design_image # embeds_many :custom_images, :class_name => 'Image', as: :design_image
@ -53,4 +57,18 @@ class Page < Item
end end
end end
def delete_empty_frontend_field
if self.frontend_field
self.frontend_field.reject! { |ff| (ff[0].blank? || ff[1].blank?) }
# self.frontend_field.each do | ff |
# if ff[0].blank? || ff[1].blank?
# self.frontend_field.delete("") if self.frontend_field
# self.frontend_field.delete(ff)
# end
# end
end
end
end end

View File

@ -10,6 +10,7 @@ class PagePart
field :public_r_tag_object_id, :default => nil field :public_r_tag_object_id, :default => nil
field :public_r_tag_option, :default => nil field :public_r_tag_option, :default => nil
field :widget_path field :widget_path
field :widget_style field :widget_style
field :widget_field , :type => Array field :widget_field , :type => Array
field :widget_data_count field :widget_data_count
@ -20,7 +21,7 @@ class PagePart
belongs_to :page belongs_to :page
belongs_to :module_app belongs_to :module_app
before_save :set_key before_save :set_key, :delete_empty_widget_field
def i18n_variable def i18n_variable
@i18n_variable ||= I18nVariable.first(:conditions => {:key => 'i18n_variable', :language_value_id => self.id, :language_value_type => self.class}) rescue nil @i18n_variable ||= I18nVariable.first(:conditions => {:key => 'i18n_variable', :language_value_id => self.id, :language_value_type => self.class}) rescue nil
@ -37,4 +38,12 @@ class PagePart
i18n_variable.key = 'i18n_variable' if i18n_variable && (i18n_variable.key.blank? rescue true) i18n_variable.key = 'i18n_variable' if i18n_variable && (i18n_variable.key.blank? rescue true)
end end
def delete_empty_widget_field
if self.widget_field
self.widget_field.reject! { |wf| (wf[0].blank? || wf[1].blank?) }
end
# self.widget_field.delete("") if self.widget_field
end
end end

View File

@ -1,3 +1,5 @@
$('#app_page_url').html("<%= escape_javascript(select 'page', 'app_frontend_url', @module_app.app_pages) %>"); $('#app_page_url').html("<%= escape_javascript(select 'page', 'app_frontend_url', @module_app.app_pages) %>");
$('#app_page_frontend_style').html("<%= escape_javascript(select 'page', 'frontend_style', @module_app.widgets[@frontend_path]) if !@frontend_path.blank? %>");
$('#app_page_category').html("<%= j (select 'page', 'category', @categories.collect{|category| [category.i18n_variable[I18n.locale], category.id]}, {:include_blank => true}) if @categories %>"); $('#app_page_category').html("<%= j (select 'page', 'category', @categories.collect{|category| [category.i18n_variable[I18n.locale], category.id]}, {:include_blank => true}) if @categories %>");
$('#app_page_tag').html("<%= j (select 'page', 'tag', @tags.collect{|tag| [tag[I18n.locale], tag.id]}, {:include_blank => true}) if @tags %>"); $('#app_page_tag').html("<%= j (select 'page', 'tag', @tags.collect{|tag| [tag[I18n.locale], tag.id]}, {:include_blank => true}) if @tags %>");
$('#app_page_frontend_field').html("<%= j render '../admin/pages/frontend_fields' %>")

View File

@ -20,7 +20,6 @@
<span id='widget_style_list'> <span id='widget_style_list'>
<%= f.select :widget_style, @widget_style, :selected => @part.widget_style %> <%= f.select :widget_style, @widget_style, :selected => @part.widget_style %>
<%#= render 'widget_styles' %>
</span> </span>
: :
@ -35,13 +34,13 @@
<span id='widget_field'> <span id='widget_field'>
<%= f.label :widget_field %> <%= render 'widget_fields' %>
<% @module_app.widget_fields.each_with_index do |widget_field, i| %> <%#= f.label :widget_field %>
<%= i+1 %> <%# @module_app.widget_fields.each_with_index do |widget_field, i| %>
<%= select_tag "page_part[widget_field][]", options_for_select(@module_app.widget_fields.collect{|widget_field| [widget_field.humanize, widget_field]}, (@part.widget_field ? @part.widget_field[i] : nil) ), :include_blank => true %> <br /> <%#= i+1 %>
<%#= select_tag "page_part[widget_field][]", options_for_select(@module_app.widget_fields.collect{|widget_field| [widget_field.humanize, widget_field]}, (@part.widget_field ? @part.widget_field[i] : nil) ), :include_blank => true %> <br />
<% end %> <%# end %>
<%#= select_tag "page_part[widget_field][]", options_for_select(@module_app.widget_fields.collect{|widget_field| [widget_field.humanize, widget_field]}, @part.widget_field.collect{|widget_field| widget_field}), {:multiple => :multiple, :size => 6} %> <%#= select_tag "page_part[widget_field][]", options_for_select(@module_app.widget_fields.collect{|widget_field| [widget_field.humanize, widget_field]}, @part.widget_field.collect{|widget_field| widget_field}), {:multiple => :multiple, :size => 6} %>
</span> </span>

View File

@ -0,0 +1,12 @@
<% if (@module_app && @module_app.widget_fields) %>
<%= label_tag('widget_field') %>
<% @module_app.widget_fields.each_with_index do |widget_field, i| %>
<%= i+1 %>
<%= select_tag "page_part[widget_field][]", options_for_select(@module_app.widget_fields.collect{|widget_field| [widget_field.humanize, widget_field]}, (@part[:widget_field][i][0] if (@part && !@part[:widget_field].blank? && !@part[:widget_field][i].blank?)) ), :include_blank => true %>
<%= select_tag "page_part[widget_field_type][]", options_for_select(LIST[:widget_field_type].collect{|widget_field| [widget_field.humanize, widget_field]}, (@part[:widget_field][i][1] if (@part && !@part[:widget_field].blank? && !@part[:widget_field][i].blank?)) ), :include_blank => true %> <br />
<% end %>
<% end %>

View File

@ -1 +0,0 @@
<%= select 'page_part', 'widget_style', @widget_style, :selected => (@part ? @part[:widget_style] : nil), :include_blank => true if @widget_style && @widget_style.size > 0 %>

View File

@ -1,4 +1,5 @@
$('#widget_list select').html("<%= j options_for_select(@module_app.widgets.collect{|k,v| k}) %>") $('#widget_list select').html("<%= j options_for_select(@module_app.widgets.collect{|k,v| k}) %>")
$('#widget_style_list select').html("<%= j options_for_select(@module_app.widgets[@widget_path]) %>") $('#widget_style_list select').html("<%= j options_for_select( @module_app.widgets[@widget_path] ) if !@widget_path.blank? %>")
$('#widget_field').html("<%= j render 'widget_fields' %>")
$('#widget_category').html("<%= j render 'widget_categories' %>") $('#widget_category').html("<%= j render 'widget_categories' %>")
$('#widget_tag').html("<%= j render 'widget_tags' %>") $('#widget_tag').html("<%= j render 'widget_tags' %>")

View File

@ -42,15 +42,27 @@
<span id="app_page_url"> <span id="app_page_url">
<%= select('page','app_frontend_url', @app_frontend_urls, :selected => @item.app_frontend_url ) rescue ''%> <%= select('page','app_frontend_url', @app_frontend_urls, :selected => @item.app_frontend_url ) rescue ''%>
</span> </span>
<span id="app_page_frontend_style">
<%= select('page','frontend_style', @frontend_style, :selected => @item[:frontend_style], :include_blank => true ) rescue ''%>
</span>
<span id="app_page_category"> <span id="app_page_category">
<%= select('page','category', @categories.collect{|category| [category.i18n_variable[I18n.locale], category.id]}, :selected => @item[:category], :include_blank => true ) rescue ''%> <%= select('page','category', @categories.collect{|category| [category.i18n_variable[I18n.locale], category.id]}, :selected => @item[:category], :include_blank => true ) rescue ''%>
</span> </span>
<span id="app_page_tag"> <span id="app_page_tag">
<%= select('page','tag', @tags.collect{|tag| [tag[I18n.locale], tag.id]}, :selected => @item[:tag], :include_blank => true ) rescue ''%> <%= select('page','tag', @tags.collect{|tag| [tag[I18n.locale], tag.id]}, :selected => @item[:tag], :include_blank => true ) rescue ''%>
</span> </span>
<span id="app_page_frontend_field">
<%= render 'frontend_fields' %>
</span>
<!-- <p class="help-block">In addition to freeform text, any HTML5 text-based input appears like so.</p> --> <!-- <p class="help-block">In addition to freeform text, any HTML5 text-based input appears like so.</p> -->
</div> </div>
</div> </div>
<div class="control-group">
<%= f.label :frontend_data_count, t('admin.frontend_data_count'), :class => 'control-label' %>
<div class="controls">
<%= f.text_field :frontend_data_count %>
</div>
</div>
<div class="control-group"> <div class="control-group">
<%= f.label :is_published, "#{t('admin.is_published')} ?", :class => 'control-label' %> <%= f.label :is_published, "#{t('admin.is_published')} ?", :class => 'control-label' %>
<div class="controls"> <div class="controls">

View File

@ -0,0 +1,11 @@
<% if (@module_app && @module_app.widget_fields) %>
<%= label_tag('frontend_field & frontend_field_type') %>
<% @module_app.widget_fields.each_with_index do |frontend_field, i| %>
<%= i+1 %>
<%= select_tag "page[frontend_field][]", options_for_select(@module_app.widget_fields.collect{|frontend_field| [frontend_field.humanize, frontend_field]}, (@item[:frontend_field][i][0] if (@item && !@item[:frontend_field].blank? && !@item[:frontend_field][i].blank?)) ), :include_blank => true %>
<%= select_tag "page[frontend_field_type][]", options_for_select(LIST[:widget_field_type].collect{|frontend_field| [frontend_field.humanize, frontend_field]}, (@item[:frontend_field][i][1] if (@item && !@item[:frontend_field].blank? && !@item[:frontend_field][i].blank?)) ), :include_blank => true %> <br />
<% end %>
<% end %>

View File

@ -15,3 +15,26 @@ page_part_kinds:
- text - text
- public_r_tag - public_r_tag
- module_widget - module_widget
widget_field:
- title
- category
- image
- date
- subtitle
- content
- link
- file
widget_field_type:
- title
- category
- img
- date
- text
- link
- file
- status
- tag
- viewcount
- host

View File

@ -10,16 +10,26 @@ class Panel::Announcement::FrontEnd::BulletinsController < OrbitWidgetController
def index def index
@item = Page.find(params[:page_id])
if @item.frontend_data_count
@page_num = @item.frontend_data_count
else
@page_num = 10
end
@frontend_style = @item.frontend_style
date_now = Time.now date_now = Time.now
if !params[:category_id].blank? if !params[:category_id].blank?
@bulletins = Bulletin.can_display.where(:bulletin_category_id => params[:category_id]).any_of( {deadline: nil,:postdate.lte => date_now} , {:deadline.gte => date_now,:postdate.lte => date_now} ).desc( :is_top, :postdate).page( params[:page_main]).per(10) @bulletins = Bulletin.can_display.where(:bulletin_category_id => params[:category_id]).any_of( {deadline: nil,:postdate.lte => date_now} , {:deadline.gte => date_now,:postdate.lte => date_now} ).desc( :is_top, :postdate).page( params[:page_main]).per(@page_num)
@current_category = BulletinCategory.from_id(params[:category_id]) rescue nil @current_category = BulletinCategory.from_id(params[:category_id]) rescue nil
elsif !params[:tag_id].blank? elsif !params[:tag_id].blank?
@tag = AnnouncementTag.find(params[:tag_id]) rescue nil @tag = AnnouncementTag.find(params[:tag_id]) rescue nil
@tag = AnnouncementTag.where(key: params[:tag_id])[0] unless @tag @tag = AnnouncementTag.where(key: params[:tag_id])[0] unless @tag
@bulletins = @tag.bulletins.can_display.any_of( {deadline: nil,:postdate.lte => date_now} , {:deadline.gte => date_now,:postdate.lte => date_now} ).desc( :is_top, :postdate).page( params[:page_main]).per(10) @bulletins = @tag.bulletins.can_display.any_of( {deadline: nil,:postdate.lte => date_now} , {:deadline.gte => date_now,:postdate.lte => date_now} ).desc( :is_top, :postdate).page( params[:page_main]).per(@page_num)
else else
@bulletins = Bulletin.can_display.any_of( {deadline: nil,:postdate.lte => date_now} , {:deadline.gte => date_now,:postdate.lte => date_now} ).desc( :is_top, :postdate).page( params[:page_main]).per(10) @bulletins = Bulletin.can_display.any_of( {deadline: nil,:postdate.lte => date_now} , {:deadline.gte => date_now,:postdate.lte => date_now} ).desc( :is_top, :postdate).page( params[:page_main]).per(@page_num)
end end
end end

View File

@ -13,8 +13,6 @@ class Bulletin
has_one :text, :class_name => "I18nVariable", :as => :language_value, :autosave => true, :dependent => :destroy has_one :text, :class_name => "I18nVariable", :as => :language_value, :autosave => true, :dependent => :destroy
has_and_belongs_to_many :tags, :class_name => "AnnouncementTag" has_and_belongs_to_many :tags, :class_name => "AnnouncementTag"
field :title2, localize: true
field :postdate , :type => DateTime field :postdate , :type => DateTime
field :deadline , :type => DateTime field :deadline , :type => DateTime
# field :url # field :url

View File

@ -148,12 +148,6 @@
<% end %> <% end %>
</div> </div>
<%= f.label :title2 %>
<%= f.fields_for :title2_translations do |f| %>
<%= I18nVariable.from_locale(locale) %>
<%= f.text_field locale, :class=>'post-title', :value => (@bulletin.title2_translations[locale] rescue nil) %>
<% end %>
<div class="editor"> <div class="editor">
<%= f.label :subtitle %> <%= f.label :subtitle %>
<%= f.fields_for :subtitle, (@bulletin.new_record? ? @bulletin.build_subtitle : @bulletin.subtitle ) do |f| %> <%= f.fields_for :subtitle, (@bulletin.new_record? ? @bulletin.build_subtitle : @bulletin.subtitle ) do |f| %>

View File

@ -8,26 +8,252 @@
<h1 class="h1"><%= t('announcement.announcement') %></h1> <h1 class="h1"><%= t('announcement.announcement') %></h1>
<% end %> <% end %>
<% if !@item.frontend_field.blank? %>
<table class="table table-bordered"> <% if @frontend_style == '1' %>
<tr>
<th><%= t('announcement.bulletin.category') %></th>
<th><%= t('announcement.bulletin.title') %></th>
<th><%= t('announcement.bulletin.postdate') %></th>
</tr>
<% @bulletins.each do |post| %> <div class="news news1">
<tr> <table class="newstb" border="0" cellpadding="0" cellspacing="0" >
<td><%= post.bulletin_category.i18n_variable[I18n.locale] rescue nil %></td> <thead>
<td><%= link_to post.title[I18n.locale], panel_announcement_front_end_bulletin_path(post, :category_id => post.bulletin_category_id) %> <tr>
<%#= link_to post.title, panel_announcement_back_end_bulletin_path(post) %> <% @item.frontend_field.each do |ff| %>
</td> <th><span class="<%= ff[1] %>"><%= t("announcement.bulletin.#{ff[0]}") if !ff[0].blank? %></span></th>
<td><%= display_date_time(post.postdate) %></td> <% end %>
</tr> </tr>
</thead>
<% @bulletins.each do |post| %>
<% @item.frontend_field.each do |ff| %>
<tr class="<%= cycle('odd', '')%>">
<td>
<span class="<%= ff[1] %>">
<% if ff[1] == 'title' %>
<%= link_to post.send("#{ff[0]}")[I18n.locale], panel_announcement_front_end_bulletin_path(post, :category_id => post.send("#{post.class.to_s.underscore}_category_id")) %>
<% elsif ff[1] == 'date' %>
<%= display_date(post.send(ff[0])) %>
<% elsif ff[1] == 'category' %>
<%= post.send("#{post.class.to_s.underscore}_#{ff[0]}").i18n_variable[I18n.locale] rescue nil %>
<% elsif ff[1] == 'img' %>
<div class="newsimg app-pic"><%= image_tag(post.image.url) %></div>
<% elsif ff[1] == 'text' %>
<%#= post.send("#{ff[0]}[#{I18n.locale}]").html_safe %>
<%= post.send("#{ff[0]}")[I18n.locale].html_safe %>
<% elsif ff[1] == 'status' %>
<% if post.is_top? %>
<span class="top"><%= t(:top) %></span>
<% end %>
<% if post.is_hot? %>
<span class="hot"><%= t(:hot) %></span>
<% end %>
<% elsif ff[1] == 'link' %>
<% elsif ff[1] == 'file' %>
<% elsif ff[1] == 'tag' %>
<% elsif ff[1] == 'viewcount' %>
<%= dislpay_view_count(post) %>
<% elsif ff[1] == 'host' %>
<%= User.from_id(post.update_user_id).name rescue ''%>
<% end %>
</span>
</td>
</tr>
<% end %>
<% end %>
</table>
</div>
<% elsif @frontend_style == '2' %>
<div class="news news2">
<ul class="newslist">
<% @bulletins.each do |post| %>
<li class="<%= cycle('odd', '')%>">
<div class="newsimg app-pic"><%= image_tag(post.image.url) %></div>
<% @item.frontend_field.each do |ff| %>
<span class="<%= ff[1] %>">
<% if ff[1] == 'title' %>
<%= link_to post.title[I18n.locale], panel_announcement_front_end_bulletin_path(post, :category_id => post.bulletin_category_id) %>
<% elsif ff[1] == 'date' %>
<%= display_date(post.send(ff[0])) %>
<% elsif ff[1] == 'category' %>
<%= post.send("#{post.class.to_s.underscore}_#{ff[0]}").i18n_variable[I18n.locale] rescue nil %>
<% elsif ff[1] == 'text' %>
<%#= post.send("#{ff[0]}[#{I18n.locale}]").html_safe %>
<%= post.send("#{ff[0]}")[I18n.locale].html_safe %>
<% elsif ff[1] == 'status' %>
<% if post.is_top? %>
<span class="top"><%= t(:top) %></span>
<% end %>
<% if post.is_hot? %>
<span class="hot"><%= t(:hot) %></span>
<% end %>
<% elsif ff[1] == 'link' %>
<% elsif ff[1] == 'file' %>
<% elsif ff[1] == 'tag' %>
<% elsif ff[1] == 'viewcount' %>
<%= dislpay_view_count(post) %>
<% elsif ff[1] == 'host' %>
<%= User.from_id(post.update_user_id).name rescue ''%>
<% end %>
</span>
<% end %>
</li>
<% end %>
</ul>
</div>
<% elsif @frontend_style == '3' %>
<div class="news news3">
<ul class="newslist">
<% @bulletins.each do |post| %>
<li class="<%= cycle('odd', '')%>">
<div class="newsimg app-pic"><%= image_tag(post.image.url) %></div>
<div class="wrap">
<% @item.frontend_field.each do |ff| %>
<span class="<%= ff[1] %>">
<% if ff[1] == 'title' %>
<%= link_to post.send("#{ff[0]}")[I18n.locale], panel_announcement_front_end_bulletin_path(post, :category_id => post.send("#{post.class.to_s.underscore}_category_id")) %>
<% elsif ff[1] == 'date' %>
<%= display_date(post.send(ff[0])) %>
<% elsif ff[1] == 'category' %>
<%= post.send("#{post.class.to_s.underscore}_#{ff[0]}").i18n_variable[I18n.locale] rescue nil %>
<% elsif ff[1] == 'text' %>
<%#= post.send("#{ff[0]}[#{I18n.locale}]").html_safe %>
<%= post.send("#{ff[0]}")[I18n.locale].html_safe %>
<% elsif ff[1] == 'status' %>
<% if post.is_top? %>
<span class="top"><%= t(:top) %></span>
<% end %>
<% if post.is_hot? %>
<span class="hot"><%= t(:hot) %></span>
<% end %>
<% elsif ff[1] == 'link' %>
<% elsif ff[1] == 'file' %>
<% elsif ff[1] == 'tag' %>
<% elsif ff[1] == 'viewcount' %>
<%= dislpay_view_count(post) %>
<% elsif ff[1] == 'host' %>
<%= User.from_id(post.update_user_id).name rescue ''%>
<% end %>
</span>
<% end %>
</div>
</li>
<% end %>
</ul>
</div>
<% elsif @frontend_style == '4' %>
<div class="news news4">
<ul class="newslist">
<% @bulletins.each do |post| %>
<li class="<%= cycle('odd', '')%>">
<div class="newsimg app-pic"><%= image_tag(post.image.url) %></div>
<div class="wrap">
<% @item.frontend_field.each do |ff| %>
<span class="<%= ff[1] %>">
<% if ff[1] == 'title' %>
<%= link_to post.send("#{ff[0]}")[I18n.locale], panel_announcement_front_end_bulletin_path(post, :category_id => post.send("#{post.class.to_s.underscore}_category_id")) %>
<% elsif ff[1] == 'date' %>
<%= display_date(post.send(ff[0])) %>
<% elsif ff[1] == 'category' %>
<%= post.send("#{post.class.to_s.underscore}_#{ff[0]}").i18n_variable[I18n.locale] rescue nil %>
<% elsif ff[1] == 'text' %>
<%#= post.send("#{ff[0]}[#{I18n.locale}]").html_safe %>
<%= post.send("#{ff[0]}")[I18n.locale].html_safe %>
<% elsif ff[1] == 'status' %>
<% if post.is_top? %>
<span class="top"><%= t(:top) %></span>
<% end %>
<% if post.is_hot? %>
<span class="hot"><%= t(:hot) %></span>
<% end %>
<% elsif ff[1] == 'link' %>
<% elsif ff[1] == 'file' %>
<% elsif ff[1] == 'tag' %>
<% elsif ff[1] == 'viewcount' %>
<%= dislpay_view_count(post) %>
<% elsif ff[1] == 'host' %>
<%= User.from_id(post.update_user_id).name rescue ''%>
<% end %>
</span>
<% end %>
</div>
</li>
<% end %>
</ul>
</div>
<% elsif @frontend_style == '5' %>
<div class="news news5">
<div class="img app-pic"><%= image_tag(@bulletins.first.image.url) %></div>
<ul class="newslist">
<% @bulletins.each do |post| %>
<li class="<%= cycle('odd', '')%>">
<% @item.frontend_field.each do |ff| %>
<span class="<%= ff[1] %>">
<% if ff[1] == 'title' %>
<%= link_to post.send("#{ff[0]}")[I18n.locale], panel_announcement_front_end_bulletin_path(post, :category_id => post.send("#{post.class.to_s.underscore}_category_id")) %>
<% elsif ff[1] == 'date' %>
<%= display_date(post.send(ff[0])) %>
<% elsif ff[1] == 'category' %>
<%= post.send("#{post.class.to_s.underscore}_#{ff[0]}").i18n_variable[I18n.locale] rescue nil %>
<% elsif ff[1] == 'text' %>
<%#= post.send("#{ff[0]}[#{I18n.locale}]").html_safe %>
<%= post.send("#{ff[0]}")[I18n.locale].html_safe %>
<% elsif ff[1] == 'status' %>
<% if post.is_top? %>
<span class="top"><%= t(:top) %></span>
<% end %>
<% if post.is_hot? %>
<span class="hot"><%= t(:hot) %></span>
<% end %>
<% elsif ff[1] == 'link' %>
<% elsif ff[1] == 'file' %>
<% elsif ff[1] == 'tag' %>
<% elsif ff[1] == 'viewcount' %>
<%= dislpay_view_count(post) %>
<% elsif ff[1] == 'host' %>
<%= User.from_id(post.update_user_id).name rescue ''%>
<% end %>
</span>
<% end %>
</li>
<% end %>
</ul>
</div>
<% end %> <% end %>
</table> <% else %>
<table class="table table-bordered">
<tr>
<th><%= t('announcement.bulletin.category') %></th>
<th><%= t('announcement.bulletin.title') %></th>
<th><%= t('announcement.bulletin.postdate') %></th>
</tr>
<% @bulletins.each do |post| %>
<tr>
<td><%= post.bulletin_category.i18n_variable[I18n.locale] rescue nil %></td>
<td><%= link_to post.title[I18n.locale], panel_announcement_front_end_bulletin_path(post, :category_id => post.bulletin_category_id) %>
<%#= link_to post.title, panel_announcement_back_end_bulletin_path(post) %>
</td>
<td><%= display_date_time(post.postdate) %></td>
</tr>
<% end %>
</table>
<% end %>
<%= paginate @bulletins, :param_name => :page_main, :params => {:inner => 'false'} %> <%= paginate @bulletins, :param_name => :page_main, :params => {:inner => 'false'} %>

View File

@ -3,41 +3,56 @@
<h1 class="h1"><%= @title %></h1> <h1 class="h1"><%= @title %></h1>
<% end %> <% end %>
<% if !@widget_fields.blank? %>
<% if @widget_style == '1' %> <% if @widget_style == '1' %>
<p> ========== 1 ========== </p>
<div class="news news1"> <div class="news news1">
<ul class="newslist"> <table class="newstb" border="0" cellpadding="0" cellspacing="0" >
<thead>
<% @bulletins.each_with_index do |post, i| %> <tr>
<li <%= ( (i+1) % 2 ) == 0 ? "class='odd'" : '' %> >
<% @widget_fields.each do |wf| %> <% @widget_fields.each do |wf| %>
<th><span class="<%= wf[1] %>"><%= t("announcement.bulletin.#{wf[0]}") if !wf[0].blank? %></span></th>
<% if wf == 'title' %>
<%= link_to post.title[I18n.locale], panel_announcement_front_end_bulletin_path(post, :category_id => post.bulletin_category_id), :class=>"newstitle" %>
<% elsif wf == 'date' %>
<span class="date"><%= display_date(post.postdate) %></span>
<% elsif wf == 'status' %>
<% if post.is_top? %>
<span class="top"><%= t(:top) %></span>
<% end %>
<% if post.is_hot? %>
<span class="hot"><%= t(:hot) %></span>
<% end %>
<% elsif wf == 'subtitle' %>
<span class="newsintro"><%= post.subtitle[I18n.locale].html_safe %></span>
<% elsif wf == 'image' %>
<div class="newsimg app-pic"><%#= image_tag(post.image.url, :size => "90x90") if post.image.file %><%= image_tag(post.image.url) %></div>
<% end %>
<% end %> <% end %>
</li> </tr>
</thead>
<% @bulletins.each do |post| %>
<% @widget_fields.each do |wf| %>
<tr class="<%= cycle('odd', '')%>">
<td>
<span class="<%= wf[1] %>">
<% if wf[1] == 'title' %>
<%= link_to post.send("#{wf[0]}")[I18n.locale], panel_announcement_front_end_bulletin_path(post, :category_id => post.send("#{post.class.to_s.underscore}_category_id")) %>
<% elsif wf[1] == 'date' %>
<%= display_date(post.send(wf[0])) %>
<% elsif wf[1] == 'category' %>
<%= post.send("#{post.class.to_s.underscore}_#{wf[0]}").i18n_variable[I18n.locale] rescue nil %>
<% elsif wf[1] == 'img' %>
<div class="newsimg app-pic"><%= image_tag(post.send(wf[0]).url) %></div>
<% elsif wf[1] == 'text' %>
<%#= post.send("#{wf[0]}[#{I18n.locale}]").html_safe %>
<%= post.send("#{wf[0]}")[I18n.locale].html_safe %>
<% elsif wf[1] == 'status' %>
<% if post.is_top? %>
<span class="top"><%= t(:top) %></span>
<% end %>
<% if post.is_hot? %>
<span class="hot"><%= t(:hot) %></span>
<% end %>
<% elsif wf[1] == 'link' %>
<% elsif wf[1] == 'file' %>
<% elsif wf[1] == 'tag' %>
<% elsif wf[1] == 'viewcount' %>
<%= dislpay_view_count(post) %>
<% elsif wf[1] == 'host' %>
<%= User.from_id(post.update_user_id).name rescue ''%>
<% end %>
</span>
</td>
</tr>
<% end %> <% end %>
<% end %>
</ul> </table>
<% if !@category_id.blank? %> <% if !@category_id.blank? %>
<div class="more"><%= link_to t('more'), panel_announcement_front_end_bulletins_path( :category_id => @category_id ) %></div> <div class="more"><%= link_to t('more'), panel_announcement_front_end_bulletins_path( :category_id => @category_id ) %></div>
@ -46,38 +61,92 @@
<% end %> <% end %>
</div> </div>
<% elsif @widget_style == '2' %> <% elsif @widget_style == '2' %>
<p> ========== 2 ========== </p>
<div class="news news2"> <div class="news news2">
<div class="newsimg app-pic"><%= image_tag(@bulletins.first.image.url) %></div> <ul class="newslist">
<% @bulletins.each do |post| %>
<li class="<%= cycle('odd', '')%>">
<div class="newsimg app-pic"><%= image_tag(post.image.url) %></div>
<% @widget_fields.each do |wf| %>
<span class="<%= wf[1] %>">
<% if wf[1] == 'title' %>
<%= link_to post.send("#{wf[0]}")[I18n.locale], panel_announcement_front_end_bulletin_path(post, :category_id => post.send("#{post.class.to_s.underscore}_category_id")) %>
<% elsif wf[1] == 'date' %>
<%= display_date(post.send(wf[0])) %>
<% elsif wf[1] == 'category' %>
<%= post.send("#{post.class.to_s.underscore}_#{wf[0]}").i18n_variable[I18n.locale] rescue nil %>
<% elsif wf[1] == 'text' %>
<%#= post.send("#{wf[0]}[#{I18n.locale}]").html_safe %>
<%= post.send("#{wf[0]}")[I18n.locale].html_safe %>
<% elsif wf[1] == 'status' %>
<% if post.is_top? %>
<span class="top"><%= t(:top) %></span>
<% end %>
<% if post.is_hot? %>
<span class="hot"><%= t(:hot) %></span>
<% end %>
<% elsif wf[1] == 'link' %>
<% elsif wf[1] == 'file' %>
<% elsif wf[1] == 'tag' %>
<% elsif wf[1] == 'viewcount' %>
<%= dislpay_view_count(post) %>
<% elsif wf[1] == 'host' %>
<%= User.from_id(post.update_user_id).name rescue ''%>
<% end %>
</span>
<% end %>
</li>
<% end %>
</ul>
<% if !@category_id.blank? %>
<div class="more"><%= link_to t('more'), panel_announcement_front_end_bulletins_path( :category_id => @category_id ) %></div>
<% else %>
<div class="more"><%= link_to t('more'), panel_announcement_front_end_bulletins_path() %></div>
<% end %>
</div>
<% elsif @widget_style == '3' %>
<div class="news news3">
<ul class="newslist"> <ul class="newslist">
<% @bulletins.each_with_index do |post, i| %> <% @bulletins.each do |post| %>
<li class="<%= cycle('odd', '')%>">
<li <%= ( (i+1) % 2 ) == 0 ? "class='odd'" : '' %> > <div class="newsimg app-pic"><%= image_tag(post.image.url) %></div>
<% @widget_fields.each do |wf| %> <div class="wrap">
<% @widget_fields.each do |wf| %>
<% if wf == 'title' %> <span class="<%= wf[1] %>">
<%= link_to post.title[I18n.locale], panel_announcement_front_end_bulletin_path(post, :category_id => post.bulletin_category_id), :class=>"newstitle" %> <% if wf[1] == 'title' %>
<% elsif wf == 'date' %> <%= link_to post.send("#{wf[0]}")[I18n.locale], panel_announcement_front_end_bulletin_path(post, :category_id => post.send("#{post.class.to_s.underscore}_category_id")) %>
<span class="date"><%= display_date(post.postdate) %></span> <% elsif wf[1] == 'date' %>
<% elsif wf == 'status' %> <%= display_date(post.send(wf[0])) %>
<% elsif wf[1] == 'category' %>
<%= post.send("#{post.class.to_s.underscore}_#{wf[0]}").i18n_variable[I18n.locale] rescue nil %>
<% elsif wf[1] == 'text' %>
<%#= post.send("#{wf[0]}[#{I18n.locale}]").html_safe %>
<%= post.send("#{wf[0]}")[I18n.locale].html_safe %>
<% elsif wf[1] == 'status' %>
<% if post.is_top? %> <% if post.is_top? %>
<span class="top"><%= t(:top) %></span> <span class="top"><%= t(:top) %></span>
<% end %> <% end %>
<% if post.is_hot? %> <% if post.is_hot? %>
<span class="hot"><%= t(:hot) %></span> <span class="hot"><%= t(:hot) %></span>
<% end %> <% end %>
<% elsif wf == 'subtitle' %> <% elsif wf[1] == 'link' %>
<span class="newsintro"><%= post.subtitle[I18n.locale].html_safe %></span> <% elsif wf[1] == 'file' %>
<% elsif wf[1] == 'tag' %>
<% elsif wf[1] == 'viewcount' %>
<%= dislpay_view_count(post) %>
<% elsif wf[1] == 'host' %>
<%= User.from_id(post.update_user_id).name rescue ''%>
<% end %> <% end %>
</span>
<% end %> <% end %>
</div>
</li> </li>
<% end %> <% end %>
</ul> </ul>
@ -89,4 +158,102 @@
</div> </div>
<% elsif @widget_style == '4' %>
<div class="news news4">
<ul class="newslist">
<% @bulletins.each do |post| %>
<li class="<%= cycle('odd', '')%>">
<div class="newsimg app-pic"><%= image_tag(post.image.url) %></div>
<div class="wrap">
<% @widget_fields.each do |wf| %>
<span class="<%= wf[1] %>">
<% if wf[1] == 'title' %>
<%= link_to post.send("#{wf[0]}")[I18n.locale], panel_announcement_front_end_bulletin_path(post, :category_id => post.send("#{post.class.to_s.underscore}_category_id")) %>
<% elsif wf[1] == 'date' %>
<%= display_date(post.send(wf[0])) %>
<% elsif wf[1] == 'category' %>
<%= post.send("#{post.class.to_s.underscore}_#{wf[0]}").i18n_variable[I18n.locale] rescue nil %>
<% elsif wf[1] == 'text' %>
<%#= post.send("#{wf[0]}[#{I18n.locale}]").html_safe %>
<%= post.send("#{wf[0]}")[I18n.locale].html_safe %>
<% elsif wf[1] == 'status' %>
<% if post.is_top? %>
<span class="top"><%= t(:top) %></span>
<% end %>
<% if post.is_hot? %>
<span class="hot"><%= t(:hot) %></span>
<% end %>
<% elsif wf[1] == 'link' %>
<% elsif wf[1] == 'file' %>
<% elsif wf[1] == 'tag' %>
<% elsif wf[1] == 'viewcount' %>
<%= dislpay_view_count(post) %>
<% elsif wf[1] == 'host' %>
<%= User.from_id(post.update_user_id).name rescue ''%>
<% end %>
</span>
<% end %>
</div>
</li>
<% end %>
</ul>
<% if !@category_id.blank? %>
<div class="more"><%= link_to t('more'), panel_announcement_front_end_bulletins_path( :category_id => @category_id ) %></div>
<% else %>
<div class="more"><%= link_to t('more'), panel_announcement_front_end_bulletins_path() %></div>
<% end %>
</div>
<% elsif @widget_style == '5' %>
<div class="news news5">
<div class="img app-pic"><%= image_tag(@bulletins.first.image.url) %></div>
<ul class="newslist">
<% @bulletins.each do |post| %>
<li class="<%= cycle('odd', '')%>">
<% @widget_fields.each do |wf| %>
<span class="<%= wf[1] %>">
<% if wf[1] == 'title' %>
<%= link_to post.send("#{wf[0]}")[I18n.locale], panel_announcement_front_end_bulletin_path(post, :category_id => post.send("#{post.class.to_s.underscore}_category_id")) %>
<% elsif wf[1] == 'date' %>
<%= display_date(post.send(wf[0])) %>
<% elsif wf[1] == 'category' %>
<%= post.send("#{post.class.to_s.underscore}_#{wf[0]}").i18n_variable[I18n.locale] rescue nil %>
<% elsif wf[1] == 'text' %>
<%#= post.send("#{wf[0]}[#{I18n.locale}]").html_safe %>
<%= post.send("#{wf[0]}")[I18n.locale].html_safe %>
<% elsif wf[1] == 'status' %>
<% if post.is_top? %>
<span class="top"><%= t(:top) %></span>
<% end %>
<% if post.is_hot? %>
<span class="hot"><%= t(:hot) %></span>
<% end %>
<% elsif wf[1] == 'link' %>
<% elsif wf[1] == 'file' %>
<% elsif wf[1] == 'tag' %>
<% elsif wf[1] == 'viewcount' %>
<%= dislpay_view_count(post) %>
<% elsif wf[1] == 'host' %>
<%= User.from_id(post.update_user_id).name rescue ''%>
<% end %>
</span>
<% end %>
</li>
<% end %>
</ul>
<% if !@category_id.blank? %>
<div class="more"><%= link_to t('more'), panel_announcement_front_end_bulletins_path( :category_id => @category_id ) %></div>
<% else %>
<div class="more"><%= link_to t('more'), panel_announcement_front_end_bulletins_path() %></div>
<% end %>
</div>
<% end %>
<% end %> <% end %>

View File

@ -39,7 +39,7 @@ Rails.application.routes.draw do
# end # end
end end
namespace :widget do namespace :widget do
match "index" => "bulletins#index" match "bulletins" => "bulletins#index"
match "bulletins_and_web_links" => "bulletins#bulletins_and_web_links" match "bulletins_and_web_links" => "bulletins#bulletins_and_web_links"
match "reload_bulletins" => "bulletins#reload_bulletins" match "reload_bulletins" => "bulletins#reload_bulletins"
match "reload_web_links" => "bulletins#reload_web_links" match "reload_web_links" => "bulletins#reload_web_links"