Changes for widgets

This commit is contained in:
Christophe Vilayphiou 2012-05-13 21:55:39 +08:00
parent 4685952bd6
commit 281cfa6518
22 changed files with 95 additions and 87 deletions

View File

@ -6,4 +6,3 @@
//
//= require jquery
//= require jquery_ujs
//= require news_link

View File

@ -1,7 +1,7 @@
class OrbitFrontendComponentController< ApplicationController
before_filter :setup_vars
before_filter {|c| c.front_end_available(@app_title)}
layout :false
layout "module_widget"
def setup_vars
@app_title = request.fullpath.split('/')[2]

View File

@ -8,5 +8,7 @@
<% end %>
<script>
load_tinymce();
$(document).ready(function() {
load_tinymce();
});
</script>

View File

@ -5,7 +5,9 @@
<%= javascript_include_tag "html5" %>
<![endif]-->
<%#= stylesheet_link_tag "module_widget" %>
<%= javascript_include_tag "module_widget" %>
<%= javascript_include_tag "module" %>
<%#= javascript_include_tag "#{@app_title}/module_widget" %>
<%= yield :page_specific_javascript %>
<%= csrf_meta_tag %>
</head>
<body>

View File

@ -1,9 +0,0 @@
// This is a manifest file that'll be compiled into including all the files listed below.
// Add new JavaScript/Coffee code in separate files in this directory and they'll automatically
// be included in the compiled file accessible from http://example.com/assets/application.js
// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
// the compiled file.
//
//= require jquery
//= require jquery_ujs
//= require announcement_link

View File

@ -31,7 +31,6 @@ class Panel::Announcement::Widget::BulletinsController < OrbitWidgetController
@selected_tag = AnnouncementTag.find(params[:id]) rescue @tags[0]
@bulletins = @selected_tag.get_visible_bulletins.can_display.page(params[:page]).per(5) rescue nil
@web_links = WebResourceTag.first(:conditions => {:en => @selected_tag[:en]}).get_visible_links.page(params[:page]).per(5) rescue nil
render :layout => 'module_widget'
end
def reload_bulletins

View File

@ -0,0 +1,29 @@
<% if @current_category %>
<h1 class="h1"><%= @current_category.i18n_variable[I18n.locale] + t('announcement.bulletin.list_lower') %></h1>
<% elsif @tag %>
<h1 class="h1"><%= @tag[I18n.locale] + t('announcement.bulletin.list_lower') %></h1>
<% else %>
<h1 class="h1"><%= t('announcement.list_announcement') %></h1>
<% end %>
<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] %></td>
<td><%= link_to post.title[I18n.locale], panel_announcement_front_end_bulletin_path(post, :category_id => post.bulletin_category_id) %>
</td>
<td><%= post.postdate %></td>
</tr>
<% end %>
</table>
<%= paginate @bulletins, :params => {:inner => 'true'}, :remote => true %>

View File

@ -16,4 +16,8 @@
<ul id='bulletins_web_links_web_links' class="links_list">
<%= render 'web_links' if @web_links %>
</ul>
</div>
</div>
<% content_for :page_specific_javascript do %>
<%= javascript_include_tag "news_link" %>
<% end %>

View File

@ -1,29 +1,3 @@
<% if @current_category %>
<h1 class="h1"><%= @current_category.i18n_variable[I18n.locale] + t('announcement.bulletin.list_lower') %></h1>
<% elsif @tag %>
<h1 class="h1"><%= @tag[I18n.locale] + t('announcement.bulletin.list_lower') %></h1>
<% else %>
<h1 class="h1"><%= t('announcement.list_announcement') %></h1>
<% end %>
<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] %></td>
<td><%= link_to post.title[I18n.locale], panel_announcement_front_end_bulletin_path(post, :category_id => post.bulletin_category_id) %>
</td>
<td><%= post.postdate %></td>
</tr>
<% end %>
</table>
<%= paginate @bulletins, :params => {:inner => 'false'} %>
<div id="bulletin_widget">
<%= render 'index' %>
</div>

View File

@ -0,0 +1 @@
$('#bulletin_widget').html("<%= j render 'index' %>")

View File

@ -11,14 +11,14 @@ class Panel::News::Widget::NewsBulletinsController < OrbitWidgetController
def index
date_now = Time.now
if !params[:category_id].blank?
@news_bulletins = NewsBulletin.can_display.where(:news_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]).per(10)
@news_bulletins = NewsBulletin.can_display.where(:news_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]).per(5)
@current_category = NewsBulletinCategory.from_id(params[:category_id]) rescue nil
elsif !params[:tag_id].blank?
@tag = NewsTag.find(params[:tag_id]) rescue nil
@tag = NewsTag.where(key: params[:tag_id])[0] unless @tag
@news_bulletins = @tag.news_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]).per(10) rescue nil
@news_bulletins = @tag.news_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]).per(5) rescue nil
else
@news_bulletins = NewsBulletin.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]).per(10)
@news_bulletins = NewsBulletin.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]).per(5)
end
end
@ -28,7 +28,6 @@ class Panel::News::Widget::NewsBulletinsController < OrbitWidgetController
@selected_tag = NewsTag.find(params[:id]) rescue @tags[0]
@news_bulletins = @selected_tag.get_visible_news_bulletins.can_display.page(params[:page]).per(5) rescue nil
@web_links = WebResourceTag.first(:conditions => {:en => @selected_tag[:en]}).get_visible_links.page(params[:page]).per(5) rescue nil
render :layout => 'module_widget'
end
def reload_news_bulletins

View File

@ -0,0 +1,33 @@
<% # encoding: utf-8 %>
<%= flash_messages %>
<% if @current_category %>
<h1 class="h1"><%= @current_category.i18n_variable[I18n.locale] + t('news.news_bulletin.list_lower') %></h1>
<% elsif @tag %>
<h1 class="h1"><%= @tag[I18n.locale] + t('news.news_bulletin.list_lower') %></h1>
<% else %>
<h1 class="h1"><%= t('news.list_news') %></h1>
<% end %>
<table class="table table-bordered">
<tbody>
<tr>
<th class="span2"><%= t('news.news_bulletin.image') %></th>
<th><%= t('news.news_bulletin.title') %></th>
<th class="span2 pagination-right"><%= t('news.news_bulletin.postdate') %></th>
</tr>
<% @news_bulletins.each do |post| %>
<tr>
<td><%= image_tag post.image %></td>
<td>
<%= link_to post.title[I18n.locale], panel_news_front_end_news_bulletin_path(post), :class => 'news_title' %>
<%= post.subtitle[I18n.locale].html_safe %>
</td>
<td><%= post.postdate %></td>
</tr>
<% end %>
</tbody>
</table>
<%= paginate @news_bulletins, :params => {:inner => 'true'}, :remote => true %>

View File

@ -1,33 +1,3 @@
<% # encoding: utf-8 %>
<%= flash_messages %>
<% if @current_category %>
<h1 class="h1"><%= @current_category.i18n_variable[I18n.locale] + t('news.news_bulletin.list_lower') %></h1>
<% elsif @tag %>
<h1 class="h1"><%= @tag[I18n.locale] + t('news.news_bulletin.list_lower') %></h1>
<% else %>
<h1 class="h1"><%= t('news.list_news') %></h1>
<% end %>
<table class="table table-bordered">
<tbody>
<tr>
<th class="span2"><%= t('news.news_bulletin.image') %></th>
<th><%= t('news.news_bulletin.title') %></th>
<th class="span2 pagination-right"><%= t('news.news_bulletin.postdate') %></th>
</tr>
<% @news_bulletins.each do |post| %>
<tr>
<td><%= image_tag post.image %></td>
<td>
<%= link_to post.title[I18n.locale], panel_news_front_end_news_bulletin_path(post), :class => 'news_title' %>
<%= post.subtitle[I18n.locale].html_safe %>
</td>
<td><%= post.postdate %></td>
</tr>
<% end %>
</tbody>
</table>
<%= paginate @news_bulletins, :params => {:inner => 'false'} %>
<div id='news_bulletin_widget'>
<%= render 'index' %>
</div>

View File

@ -0,0 +1 @@
$('#news_bulletin_widget').html("<%= j render 'index' %>")

View File

@ -16,4 +16,8 @@
<ul id='news_bulletins_web_links_web_links' class="links_list">
<%= render 'web_links' if @web_links %>
</ul>
</div>
</div>
<% content_for :page_specific_javascript do %>
<%= javascript_include_tag "announcement_link" %>
<% end %>

View File

@ -7,6 +7,6 @@
"update_info": "Some info",
"create_date": "11-11-2011",
"app_pages": ["news_bulletins"],
"widgets": ["news_bulletins", "news_bulletins_and_web_links", "home_banner"],
"widgets": ["news_bulletins", "home_banner"],
"enable_frontend": true
}

View File

@ -12,7 +12,7 @@ class Panel::WebResource::FrontEnd::WebLinksController < OrbitWidgetController
date_now = Time.now
@web_links = WebLink.where( :is_hidden => false ).desc(:is_top, :name).page( params[:page]).per(20)
@web_links = WebLink.where( :is_hidden => false ).desc(:is_top, :name).page(params[:page]).per(10)
get_categorys
end

View File

@ -2,7 +2,7 @@
<%= flash_messages %>
<%= paginate @web_links %>
<%= paginate @web_links, :params => {:inner => false}%>
<h1><%= t('web_link.list_web_resource') %></h1>

View File

@ -13,7 +13,6 @@ Rails.application.routes.draw do
resources :tags
end
namespace :front_end do
root :to => "web_links#index"
resources :web_links
end
namespace :widget do

View File

@ -7,6 +7,6 @@
"update_info": "Some info",
"create_date": "11-11-2011",
"app_pages": ["web_links"],
"widgets": ["web_links", "home_list"],
"widgets": ["home_list"],
"enable_frontend": true
}