announcemenet & web_resource widget

This commit is contained in:
unknown 2012-02-16 17:52:49 +08:00
parent e61aa6b210
commit 5da75161c4
12 changed files with 114 additions and 26 deletions

View File

@ -1,7 +1,7 @@
$(document).ready(function() { $(document).ready(function() {
$('body').prepend("<div id='orbit_bar'/>"); $('body').prepend("<div id='orbit_bar'/>");
ajax_load_proc($('#orbit_bar'), 'load_orbit_bar'); ajax_load_proc($('#orbit_bar'), '/load_orbit_bar');
$.each($(".dymanic_load"),function(){ $.each($(".dymanic_load"),function(){
if($(this).attr("path")==''){$(this).html("App setting Failed");} if($(this).attr("path")==''){$(this).html("App setting Failed");}

View File

@ -11,15 +11,25 @@ class Panel::Announcement::Widget::BulletinsController < ObitWidgetController
def index def index
# deadline # deadline
# @bulletin_categorys = BulletinCategory.first;
@bulletin = Bulletin.where( :postdate.lte => Date.today ).desc(:is_top, :postdate).first # @bulletins = Bulletin.widget_datas(@bulletin_categorys.id).limit(9)
@bulletins = Bulletin.widget_datas.limit(9)
@bulletins = Bulletin.widget_datas
get_categorys get_categorys
end end
def bulletins_list
@bulletins = Bulletin.widget_datas.limit(5)
# get_categorys
module_app = ModuleApp.first(:conditions => {:key => 'announcement'})
@tags = Tag.all(:conditions => {:module_app_id => module_app.id})
end
protected protected

View File

@ -65,15 +65,19 @@ class Bulletin
end end
def self.widget_datas def self.widget_datas( category_id = nil )
date_now = Time.now date_now = Time.now
# find(:all, :conditions => {:postdate => {"$lte" => Date.today}, deadline: nil} ).desc( :is_top, :postdate) # find(:all, :conditions => {:postdate => {"$lte" => Date.today}, deadline: nil} ).desc( :is_top, :postdate)
# where( :postdate.lte => date_now ).where( :deadline => nil ).desc(:is_top, :postdate) # where( :postdate.lte => date_now ).where( :deadline => nil ).desc(:is_top, :postdate)
# any_of({ :title => "test" },{:deadline => nil, :title => "123"}) # any_of({ :title => "test" },{:deadline => nil, :title => "123"})
any_of( {deadline: nil,:postdate.lte => date_now} , {:deadline.gte => date_now,:postdate.lte => date_now} ).desc( :is_top, :postdate)
if category_id.to_s.size > 0
find(:all, :conditions => {bulletin_category_id: category_id}).any_of( {deadline: nil,:postdate.lte => date_now} , {:deadline.gte => date_now,:postdate.lte => date_now} ).desc( :is_top, :postdate)
else
any_of( {deadline: nil,:postdate.lte => date_now} , {:deadline.gte => date_now,:postdate.lte => date_now} ).desc( :is_top, :postdate)
end
end end

View File

@ -0,0 +1,29 @@
<% # encoding: utf-8 %>
<% if @bulletins and !@bulletins.nil? %>
<!-- tag -->
<div class="tag_block">
<ul class="tag_list">
<% @tags.each do |tag| %>
<li><%= tag[I18n.locale] %></li>
<% end %>
</ul>
</div>
<!-- news -->
<div class="news_block">
<h3 class="news_title"><%= t('公告訊息')%></h3>
<ul class="news_list">
<% @bulletins.each do |post| %>
<li><%= link_to post.title[I18n.locale], panel_announcement_front_end_bulletin_path(post) %></li>
<% end %>
</ul>
</div>
<% end %>

View File

@ -10,7 +10,7 @@
<% @bulletins.each do |post| %> <% @bulletins.each do |post| %>
<li> <li>
<div class="news_img"><%= image_tag(post.image.url, :size => "290x130") if post.image.file %></div> <div class="news_img"><%= image_tag(post.image.url, :size => "290x130") if post.image.file %></div>
<h3 class="h3 news_title"><%= post.title[I18n.locale] %></h3> <h3 class="h3 news_title"><%= link_to post.title[I18n.locale], panel_announcement_front_end_bulletin_path(post) %></h3>
<p class="news_wrap"><%= post.subtitle[I18n.locale] %></p> <p class="news_wrap"><%= post.subtitle[I18n.locale] %></p>
</li> </li>
<% end %> <% end %>

View File

@ -15,6 +15,7 @@ Rails.application.routes.draw do
end end
namespace :widget do namespace :widget do
match "bulletins" => "bulletins#index" match "bulletins" => "bulletins#index"
match "bulletins_list" => "bulletins#bulletins_list"
end end
end end
end end

View File

@ -12,7 +12,7 @@ class Panel::WebResource::BackEnd::WebLinksController < ApplicationController
@web_links = WebLink.search(params[:category_id]) @web_links = WebLink.search(params[:category_id])
get_tags() get_tags
respond_to do |format| respond_to do |format|
format.html # index.html.erb format.html # index.html.erb
@ -37,10 +37,10 @@ class Panel::WebResource::BackEnd::WebLinksController < ApplicationController
def new def new
@web_link = WebLink.new @web_link = WebLink.new
get_tags()
get_categorys get_categorys
get_tags
respond_to do |format| respond_to do |format|
format.html # new.html.erb format.html # new.html.erb
format.xml { render :xml => @web_link } format.xml { render :xml => @web_link }
@ -51,7 +51,7 @@ class Panel::WebResource::BackEnd::WebLinksController < ApplicationController
def edit def edit
@web_link = WebLink.find(params[:id]) @web_link = WebLink.find(params[:id])
get_categorys get_categorys
get_tags() get_tags
end end
# POST /web_links # POST /web_links
@ -113,7 +113,7 @@ class Panel::WebResource::BackEnd::WebLinksController < ApplicationController
@web_link_categorys = (id ? WebLinkCategory.find(id).to_a : WebLinkCategory.excludes('disabled' => true)) @web_link_categorys = (id ? WebLinkCategory.find(id).to_a : WebLinkCategory.excludes('disabled' => true))
end end
def get_tags() def get_tags
module_app = ModuleApp.first(:conditions => {:key => 'web_resource'}) module_app = ModuleApp.first(:conditions => {:key => 'web_resource'})
@tags = Tag.all(:conditions => {:module_app_id => module_app.id}) @tags = Tag.all(:conditions => {:module_app_id => module_app.id})
end end

View File

@ -0,0 +1,35 @@
class Panel::WebResource::Widget::WebLinksController < ObitWidgetController
def initialize
super
@app_title = NewBlog::MOUDLEAPP_TITLE
end
# GET /web_links
# GET /web_links.xml
def index
# deadline
@web_link = WebLink.where( :is_hidden => false ).desc(:is_top, :name).first
@web_links = WebLink.widget_datas
get_categorys
end
protected
def get_categorys
@web_link_categorys = WebLinkCategory.excludes('disabled' => true)
end
def get_tags
module_app = ModuleApp.first(:conditions => {:key => 'web_resource'})
@tags = Tag.all(:conditions => {:module_app_id => module_app.id})
end
end

View File

@ -42,13 +42,7 @@ class WebLink
def self.widget_datas def self.widget_datas
date_now = Time.now
# find(:all, :conditions => {:postdate => {"$lte" => Date.today}, deadline: nil} ).desc( :is_top, :name)
where( :is_hidden => false ).desc(:is_top, :name) where( :is_hidden => false ).desc(:is_top, :name)
# any_of({ :name => "test" },{:deadline => nil, :name => "123"})
# any_of( {deadline: nil,:postdate.lte => date_now} , {:deadline.gte => date_now,:postdate.lte => date_now} ).desc( :is_top, :name)
end end

View File

@ -0,0 +1,14 @@
<% # encoding: utf-8 %>
<% if @web_links and !@web_links.nil? %>
<div class="links_block">
<h3 class="links_title"><%= t('相關連結')%></h3>
<ul class="links_list">
<% @web_links.each do |post| %>
<li><%= link_to post.name[I18n.locale], post.url, {:target => '_blank', :title => post.name[I18n.locale]} %></li>
<% end %>
</ul>
</div>
<% end %>

View File

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

View File

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