From 5da75161c418a774399bd7e58d092a8499093e64 Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 16 Feb 2012 17:52:49 +0800 Subject: [PATCH] announcemenet & web_resource widget --- public/static/kernel.js | 2 +- .../widget/bulletins_controller.rb | 18 +++++++--- .../announcement/app/models/bulletin.rb | 20 ++++++----- .../widget/bulletins/bulletins_list.html.erb | 29 +++++++++++++++ .../widget/bulletins/index.html.erb | 2 +- .../announcement/config/routes.rb | 1 + .../back_end/web_links_controller.rb | 10 +++--- .../widget/web_links_controller.rb | 35 +++++++++++++++++++ .../web_resource/app/models/web_link.rb | 6 ---- .../widget/web_links/index.html.erb | 14 ++++++++ .../web_resource/config/routes.rb | 2 +- .../web_resource/web_resource.json | 1 + 12 files changed, 114 insertions(+), 26 deletions(-) create mode 100644 vendor/built_in_modules/announcement/app/views/panel/announcement/widget/bulletins/bulletins_list.html.erb create mode 100644 vendor/built_in_modules/web_resource/app/controllers/panel/web_resource/widget/web_links_controller.rb create mode 100644 vendor/built_in_modules/web_resource/app/views/panel/web_resource/widget/web_links/index.html.erb diff --git a/public/static/kernel.js b/public/static/kernel.js index 537d1828..a922d21c 100644 --- a/public/static/kernel.js +++ b/public/static/kernel.js @@ -1,7 +1,7 @@ $(document).ready(function() { $('body').prepend("
"); - ajax_load_proc($('#orbit_bar'), 'load_orbit_bar'); + ajax_load_proc($('#orbit_bar'), '/load_orbit_bar'); $.each($(".dymanic_load"),function(){ if($(this).attr("path")==''){$(this).html("App setting Failed");} diff --git a/vendor/built_in_modules/announcement/app/controllers/panel/announcement/widget/bulletins_controller.rb b/vendor/built_in_modules/announcement/app/controllers/panel/announcement/widget/bulletins_controller.rb index 5ba9ffc0..41319bf1 100644 --- a/vendor/built_in_modules/announcement/app/controllers/panel/announcement/widget/bulletins_controller.rb +++ b/vendor/built_in_modules/announcement/app/controllers/panel/announcement/widget/bulletins_controller.rb @@ -11,15 +11,25 @@ class Panel::Announcement::Widget::BulletinsController < ObitWidgetController def index # deadline - - @bulletin = Bulletin.where( :postdate.lte => Date.today ).desc(:is_top, :postdate).first - - @bulletins = Bulletin.widget_datas + # @bulletin_categorys = BulletinCategory.first; + # @bulletins = Bulletin.widget_datas(@bulletin_categorys.id).limit(9) + @bulletins = Bulletin.widget_datas.limit(9) get_categorys 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 diff --git a/vendor/built_in_modules/announcement/app/models/bulletin.rb b/vendor/built_in_modules/announcement/app/models/bulletin.rb index 6097251b..d086d531 100644 --- a/vendor/built_in_modules/announcement/app/models/bulletin.rb +++ b/vendor/built_in_modules/announcement/app/models/bulletin.rb @@ -65,16 +65,20 @@ class Bulletin 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) - # where( :postdate.lte => date_now ).where( :deadline => nil ).desc(:is_top, :postdate) - # 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) - - + # 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) + # any_of({ :title => "test" },{:deadline => nil, :title => "123"}) + + 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 diff --git a/vendor/built_in_modules/announcement/app/views/panel/announcement/widget/bulletins/bulletins_list.html.erb b/vendor/built_in_modules/announcement/app/views/panel/announcement/widget/bulletins/bulletins_list.html.erb new file mode 100644 index 00000000..e110b5c9 --- /dev/null +++ b/vendor/built_in_modules/announcement/app/views/panel/announcement/widget/bulletins/bulletins_list.html.erb @@ -0,0 +1,29 @@ +<% # encoding: utf-8 %> + +<% if @bulletins and !@bulletins.nil? %> + + +
+
    + <% @tags.each do |tag| %> +
  • <%= tag[I18n.locale] %>
  • + <% end %> +
+
+ + +
+

<%= t('公告訊息')%>

+
    + <% @bulletins.each do |post| %> +
  • <%= link_to post.title[I18n.locale], panel_announcement_front_end_bulletin_path(post) %>
  • + <% end %> +
+
+ +<% end %> + + + + + diff --git a/vendor/built_in_modules/announcement/app/views/panel/announcement/widget/bulletins/index.html.erb b/vendor/built_in_modules/announcement/app/views/panel/announcement/widget/bulletins/index.html.erb index 76c6edfb..b6ef3597 100644 --- a/vendor/built_in_modules/announcement/app/views/panel/announcement/widget/bulletins/index.html.erb +++ b/vendor/built_in_modules/announcement/app/views/panel/announcement/widget/bulletins/index.html.erb @@ -10,7 +10,7 @@ <% @bulletins.each do |post| %>
  • <%= image_tag(post.image.url, :size => "290x130") if post.image.file %>
    -

    <%= post.title[I18n.locale] %>

    +

    <%= link_to post.title[I18n.locale], panel_announcement_front_end_bulletin_path(post) %>

    <%= post.subtitle[I18n.locale] %>

  • <% end %> diff --git a/vendor/built_in_modules/announcement/config/routes.rb b/vendor/built_in_modules/announcement/config/routes.rb index 6fc80895..6e65320f 100644 --- a/vendor/built_in_modules/announcement/config/routes.rb +++ b/vendor/built_in_modules/announcement/config/routes.rb @@ -15,6 +15,7 @@ Rails.application.routes.draw do end namespace :widget do match "bulletins" => "bulletins#index" + match "bulletins_list" => "bulletins#bulletins_list" end end end diff --git a/vendor/built_in_modules/web_resource/app/controllers/panel/web_resource/back_end/web_links_controller.rb b/vendor/built_in_modules/web_resource/app/controllers/panel/web_resource/back_end/web_links_controller.rb index 1b29f5f1..f1ec7485 100644 --- a/vendor/built_in_modules/web_resource/app/controllers/panel/web_resource/back_end/web_links_controller.rb +++ b/vendor/built_in_modules/web_resource/app/controllers/panel/web_resource/back_end/web_links_controller.rb @@ -12,7 +12,7 @@ class Panel::WebResource::BackEnd::WebLinksController < ApplicationController @web_links = WebLink.search(params[:category_id]) - get_tags() + get_tags respond_to do |format| format.html # index.html.erb @@ -37,9 +37,9 @@ class Panel::WebResource::BackEnd::WebLinksController < ApplicationController def new @web_link = WebLink.new - get_tags() - get_categorys + + get_tags respond_to do |format| format.html # new.html.erb @@ -51,7 +51,7 @@ class Panel::WebResource::BackEnd::WebLinksController < ApplicationController def edit @web_link = WebLink.find(params[:id]) get_categorys - get_tags() + get_tags end # 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)) end - def get_tags() + def get_tags module_app = ModuleApp.first(:conditions => {:key => 'web_resource'}) @tags = Tag.all(:conditions => {:module_app_id => module_app.id}) end diff --git a/vendor/built_in_modules/web_resource/app/controllers/panel/web_resource/widget/web_links_controller.rb b/vendor/built_in_modules/web_resource/app/controllers/panel/web_resource/widget/web_links_controller.rb new file mode 100644 index 00000000..9bfc0d88 --- /dev/null +++ b/vendor/built_in_modules/web_resource/app/controllers/panel/web_resource/widget/web_links_controller.rb @@ -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 diff --git a/vendor/built_in_modules/web_resource/app/models/web_link.rb b/vendor/built_in_modules/web_resource/app/models/web_link.rb index 5f88a621..e6753fea 100644 --- a/vendor/built_in_modules/web_resource/app/models/web_link.rb +++ b/vendor/built_in_modules/web_resource/app/models/web_link.rb @@ -42,13 +42,7 @@ class WebLink 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) - # 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 diff --git a/vendor/built_in_modules/web_resource/app/views/panel/web_resource/widget/web_links/index.html.erb b/vendor/built_in_modules/web_resource/app/views/panel/web_resource/widget/web_links/index.html.erb new file mode 100644 index 00000000..265b0710 --- /dev/null +++ b/vendor/built_in_modules/web_resource/app/views/panel/web_resource/widget/web_links/index.html.erb @@ -0,0 +1,14 @@ +<% # encoding: utf-8 %> + +<% if @web_links and !@web_links.nil? %> + + + +<% end %> diff --git a/vendor/built_in_modules/web_resource/config/routes.rb b/vendor/built_in_modules/web_resource/config/routes.rb index 59c49707..fb2eed2d 100644 --- a/vendor/built_in_modules/web_resource/config/routes.rb +++ b/vendor/built_in_modules/web_resource/config/routes.rb @@ -15,7 +15,7 @@ Rails.application.routes.draw do resources :web_links end namespace :widget do - root :to => "web_links#index" + match "web_links" => "web_links#index" end end end diff --git a/vendor/built_in_modules/web_resource/web_resource.json b/vendor/built_in_modules/web_resource/web_resource.json index e1dc59de..f159630f 100644 --- a/vendor/built_in_modules/web_resource/web_resource.json +++ b/vendor/built_in_modules/web_resource/web_resource.json @@ -7,5 +7,6 @@ "update_info": "Some info", "create_date": "11-11-2011", "app_pages": ["web_links"], + "widgets": ["web_links"], "enable_frontend": true }