Orbit Announcement

This commit is contained in:
Manson Wang 2014-01-14 19:54:35 +08:00
commit 490ced3b4d
75 changed files with 4523 additions and 0 deletions

6
.gitignore vendored Normal file
View File

@ -0,0 +1,6 @@
.bundle/
log/*.log
pkg/
test/dummy/db/*.sqlite3
test/dummy/log/*.log
test/dummy/tmp/

17
Gemfile Normal file
View File

@ -0,0 +1,17 @@
source "http://rubygems.org"
# Declare your gem's dependencies in announcement.gemspec.
# Bundler will treat runtime dependencies like base dependencies, and
# development dependencies will be added by default to the :development group.
gemspec
# jquery-rails is used by the dummy application
gem "jquery-rails"
# Declare any dependencies that are still in development here instead of in
# your gemspec. These might include edge Rails or gems from your path or
# Git. Remember to move these dependencies to your gemspec before releasing
# your gem to rubygems.org.
# To use debugger
# gem 'ruby-debug19', :require => 'ruby-debug'

20
MIT-LICENSE Normal file
View File

@ -0,0 +1,20 @@
Copyright 2011 YOURNAME
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

0
README Normal file
View File

3
README.rdoc Normal file
View File

@ -0,0 +1,3 @@
= Announcement
This project rocks and uses MIT-LICENSE.

39
Rakefile Normal file
View File

@ -0,0 +1,39 @@
#!/usr/bin/env rake
begin
require 'bundler/setup'
rescue LoadError
puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
end
begin
require 'rdoc/task'
rescue LoadError
require 'rdoc/rdoc'
require 'rake/rdoctask'
RDoc::Task = Rake::RDocTask
end
RDoc::Task.new(:rdoc) do |rdoc|
rdoc.rdoc_dir = 'rdoc'
rdoc.title = 'Announcement'
rdoc.options << '--line-numbers'
rdoc.rdoc_files.include('README.rdoc')
rdoc.rdoc_files.include('lib/**/*.rb')
end
APP_RAKEFILE = File.expand_path("../test/dummy/Rakefile", __FILE__)
load 'rails/tasks/engine.rake'
Bundler::GemHelper.install_tasks
require 'rake/testtask'
Rake::TestTask.new(:test) do |t|
t.libs << 'lib'
t.libs << 'test'
t.pattern = 'test/**/*_test.rb'
t.verbose = false
end
task :default => :test

23
announcement.gemspec Normal file
View File

@ -0,0 +1,23 @@
# coding: utf-8
lib = File.expand_path('../lib', __FILE__)
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
require 'announcement/version'
Gem::Specification.new do |spec|
spec.name = "announcement"
spec.version = Announcement::VERSION
spec.authors = ["Manson Wang"]
spec.email = ["manson@rulingcom.com"]
spec.description = "Orbit Announcement module"
spec.summary = ""
spec.homepage = ""
spec.license = "RulingDigital"
spec.files = `git ls-files`.split($/)
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
spec.require_paths = ["lib"]
spec.add_development_dependency "bundler", "~> 1.3"
spec.add_development_dependency "rake"
end

View File

View File

@ -0,0 +1,45 @@
$(document).ready(function(){
var topic1="0px";
var topic2="-948px";
var topic3="-1896px";
var topic_page=1;
$(".topic_prev").addClass("topic_prev_first");
$(document).on("click", ".topic_prev", function() {
if (topic_page !=1){
topic_page-=1;
}else{
}
if (topic_page == 1){
$("#topic_list").stop().animate({"left": topic1}, "slow");
$(".topic_prev").addClass("topic_prev_first");
}
if (topic_page == 2){
$("#topic_list").stop().animate({"left": topic2}, "slow");
$(".topic_prev").removeClass("topic_prev_first");
$(".topic_next").removeClass("topic_next_last");
}
if (topic_page == 3){
$("#topic_list").stop().animate({"left": topic3}, "slow");
$(".topic_prev").removeClass("topic_next_last");
}
});
$(document).on("click", ".topic_next", function() {
if (topic_page >=1 && topic_page <=2){
topic_page+=1;
}else{
}
if (topic_page == 1){
$("#topic_list").stop().animate({"left": topic1}, "slow");
$(".topic_prev").addClass("topic_prev_first");
}
if (topic_page == 2){
$("#topic_list").stop().animate({"left": topic2}, "slow");
$(".topic_prev").removeClass("topic_prev_first");
}
if (topic_page == 3){
$("#topic_list").stop().animate({"left": topic3}, "slow");
$(".topic_next").addClass("topic_next_last");
}
});
});

View File

@ -0,0 +1,78 @@
.mega_tab_block {
clear: both;
position: relative;
}
.mega_tab_block h3 {
font: 22px/100% 'arial',sans-serif;
margin: 0 0 10px;
padding: 0;
}
.mega_tab_block .pagination {
float: left;
height: auto;
margin: 10px 0 0;
width: auto;
}
.mega_tab_block .pagination a {
background: none repeat scroll 0 0 #EEEEEE;
display: block;
float: left;
margin: 0 5px 0 0;
padding: 10px;
}
.tag_block {
clear: both;
margin: 0 0 20px;
position: relative;
}
.mega_tab_block .tag_list {
background: none repeat scroll 0 0 #EEEEEE;
margin: 0;
overflow: hidden;
padding: 0 0 0 5px;
}
.mega_tab_block .tag_list li {
float: left;
list-style: none outside none;
}
.mega_tab_block .tag_list li a {
background: none repeat scroll 0 0 #DDDDDD;
float: left;
margin: 0 5px 0 0;
padding: 10px;
}
.news_block {
clear: both;
margin: 0 0 20px;
overflow: hidden;
position: relative;
}
.mega_tab_block .news_list {
margin: 0;
padding: 0;
}
.mega_tab_block .news_list li {
list-style: none outside none;
padding: 5px 0;
}
.links_block {
clear: both;
overflow: hidden;
position: relative;
}
.mega_tab_block .links_list {
margin: 0;
padding: 0;
}
.mega_tab_block .links_list li {
list-style: none outside none;
padding: 5px 0;
}

0
app/controllers/.gitkeep Normal file
View File

View File

@ -0,0 +1,23 @@
class ApplicationController < ActionController::Base
protect_from_forgery
before_filter :set_locale
# Set I18n.locale
def set_locale
# update session if passed
session[:locale] = params[:locale] if params[:locale]
# set locale based on session or default
begin
# check if locale is valid for non site pages
if !VALID_LOCALES.include?(session[:locale])
I18n.locale = I18n.default_locale
else
I18n.locale = session[:locale]
end
rescue
I18n.locale = I18n.default_locale
end
end
end

View File

@ -0,0 +1,65 @@
class Panel::Announcement::BackEnd::ApprovalsController < OrbitBackendController
before_filter :authenticate_user!
before_filter :is_admin?
include AdminHelper
# layout 'admin'
def preview_and_approve
@bulletin = Bulletin.find params[:bulletin_id]
end
def approve
notice = ""
@bulletin = Bulletin.find params[:bulletin_id]
@bulletin.proc_check(params[:bulletin][:is_checked],params[:bulletin][:not_checked_reason])
@bulletin.de_pending
if @bulletin.save
notice = t('announcement.approve_bulletin_success')
else
notice = t('announcement.approve_bulletin_fail')
end
redirect_to(panel_announcement_back_end_bulletins_url,:notice => notice)
end
def setting
@sys_users = User.all(conditions: {admin: false}).includes(:avatar).not_guest_user
@bulletin_categorys = BulletinCategory.all
@options_from_collection_for_select_bulletin_categorys = @bulletin_categorys.collect{|bc| [bc.title,bc.id] }
if params.has_key? :category
@bulletin_category = BulletinCategory.find params[:category][:id]
else
@bulletin_category = @bulletin_categorys.first
end
preload_object_auth = @bulletin_category.get_object_auth_by_title('fact_check')
@users_array = preload_object_auth.privilege_users rescue []
respond_to do |format|
format.html
format.js
end
end
def update_setting
object_auth = update_setting_by_params
if object_auth.save!
flash[:notice] = t('update.success_')
else
flash[:notice] = t('update.fail')
end
end
def user_list
@bulletin_category = BulletinCategory.find params[:category][:id]
end
protected
def update_setting_by_params
category = BulletinCategory.find params[:category][:id]
privilege_users = params[:users].collect{|key,value| User.find key } rescue []
object_auth_ary = category.object_auths.where(title: 'fact_check') || (category.object_auths.create :title=> 'fact_check')
object_auth = object_auth_ary.first
object_auth.privilege_users = privilege_users
object_auth
end
end

View File

@ -0,0 +1,48 @@
class Panel::Announcement::BackEnd::BulletinFilesController < ApplicationController
layout 'back_end'
def index
@bulletin_files = BulletinFile.all
respond_to do |format|
format.html # index.html.erb
# format.xml { render :xml => @bulletins }
format.js
end
end
# POST /bulletins
# POST /bulletins.xml
def create
@bulletin_file = BulletinFile.new(params[:bulletin_file])
respond_to do |format|
if @bulletin_file.save
format.html { redirect_to(panel_announcement_back_end_bulletins_url) }
format.js
else
format.html { render :action => "new" }
format.js { render action: "new" }
end
end
end
# PUT /bulletins/1
# PUT /bulletins/1.xml
def update
@bulletin_file = BulletinFile.find(params[:id])
respond_to do |format|
if @bulletin_file.update_attributes(params[:bulletin_file])
format.html { redirect_to(panel_announcement_back_end_bulletins_url) }
format.js
else
format.html { render :action => "edit" }
format.js { render :action => "edit" }
end
end
end
end

View File

@ -0,0 +1,49 @@
class Panel::Announcement::BackEnd::BulletinLinksController < ApplicationController
layout 'back_end'
def index
@bulletin_links = BulletinLink.all
respond_to do |format|
format.html # index.html.erb
# format.xml { render :xml => @bulletins }
format.js
end
end
# POST /bulletins
# POST /bulletins.xml
def create
@bulletin_link = BulletinLink.new(params[:bulletin_link])
# @bulletin_link.bulletin_id = params[:bulletin_link][:bulletin_id]
respond_to do |format|
if @bulletin_link.save
format.html { redirect_to(panel_announcement_back_end_bulletins_url) }
format.js
else
format.html { render :action => "new" }
format.js { render action: "new" }
end
end
end
# PUT /bulletins/1
# PUT /bulletins/1.xml
def update
@bulletin_link = BulletinLink.find(params[:id])
respond_to do |format|
if @bulletin_link.update_attributes(params[:bulletin_link])
format.html { redirect_to(panel_announcement_back_end_bulletins_url) }
format.js
else
format.html { render :action => "edit" }
format.js { render :action => "edit" }
end
end
end
end

View File

@ -0,0 +1,187 @@
class Panel::Announcement::BackEnd::BulletinsController < OrbitBackendController
# include OrbitControllerLib::DivisionForDisable
before_filter :clean_values, :only => [:create, :update]
open_for_visitor :only => [:index, :show, :get_sorted_and_filtered_bulletins]
before_filter :only => [ :new, :create, :edit, :update ] do |controller|
@categories = get_categories_for_form
end
def preview
bulletin = Bulletin.new params
@preview_obj = bulletin.to_preview
@preview_obj.save
render '/shared/preview/preview.html.erb',:layout=>false
end
def index
@tags = get_tags
@categories = get_categories_for_index
@statuses = get_statuses
category_ids = @categories.collect{|t| t.id}
@bulletins = get_sorted_and_filtered("bulletin", :category_id.in => category_ids)
respond_to do |format|
format.html # index.html.erb
format.js { }
format.xml { render :xml => @bulletins }
end
end
# GET /bulletins/1
# GET /bulletins/1.xml
def show
@bulletin = Bulletin.find(params[:id])
@tags = get_tags
respond_to do |format|
format.html # show.html.erb
format.xml { render :xml => @bulletin }
end
end
# GET /bulletins/new
# GET /bulletins/new.xml
def new
if(session[:in_validate_object].blank?)
@bulletin = Bulletin.new(:postdate => DateTime.now)
else
@bulletin = session[:in_validate_object]
session[:in_validate_object] = {}
end
@link_url = panel_announcement_back_end_bulletins_path
@tags = get_tags
respond_to do |format|
format.html # new.html.erb
format.xml { render :xml => @bulletin }
end
end
# GET /bulletins/1/edit
def edit
@bulletin = Bulletin.find(params[:id])
@tags = get_tags
is_authorized_sub_manager = @bulletin.category.auth_sub_manager.authorized_user_ids rescue nil
if !(is_manager? || is_admin? || is_authorized_sub_manager.include?(current_user.id))
redirect_to :action => :index
else
# @summary_variable = @bulletin.summary_variable
@link_url = panel_announcement_back_end_bulletin_path(@bulletin)
@tags = get_tags
end
end
# POST /bulletins
# POST /bulletins.xml
def create
@tags = get_tags
@bulletin = Bulletin.new(params[:bulletin])
@bulletin.deadline = nil if (@bulletin.deadline < @bulletin.postdate rescue nil)
@bulletin.create_user_id = current_user.id
@bulletin.update_user_id = current_user.id
# if(is_manager? || is_admin?)
# @bulletin.is_checked = true
# @bulletin.is_rejected = false
# @bulletin.de_pending
# end
respond_to do |format|
if @bulletin.save
format.html { redirect_to(panel_announcement_back_end_bulletins_url, :notice => t('announcement.create_bulletin_success')) }
format.xml { render :xml => @bulletin, :status => :created, :location => @bulletin }
# format.js
format.js {
@info = {"success"=>"true","redirect_url"=>panel_announcement_back_end_bulletins_url}
flash[:notice] = t('bulletin.create_bulletin_success')
render "/shared/preview/after_create.js.erb"
}
else
format.html { render :action => "new" }
format.xml { render :xml => @bulletin.errors, :status => :unprocessable_entity }
format.js {
@info = {"success"=>"false","redirect_url"=>new_panel_announcement_back_end_bulletin_url(:bulletin => @bulletin)}
session[:in_validate_object] = @bulletin
render "/shared/preview/after_create.js.erb"
}
end
end
end
# PUT /bulletins/1
# PUT /bulletins/1.xml
def update
@bulletin = Bulletin.find(params[:id])
delete_out_invalid_date_from_params
respond_to do |format|
if @bulletin.update_attributes(params[:bulletin])
format.html { redirect_to(panel_announcement_back_end_bulletins_url, :notice => t('bulletin.update_bulletin_success')) }
format.js { render 'toggle_enable' }
format.xml { head :ok }
else
@tags = get_tags
format.html { render :action => "edit" }
format.xml { render :xml => @bulletin.errors, :status => :unprocessable_entity }
end
end
end
# DELETE /bulletins/1
# DELETE /bulletins/1.xml
def destroy
@bulletin = Bulletin.find(params[:id])
# @bulletin.bulletin_files.destroy
@bulletin.destroy
respond_to do |format|
format.html { redirect_to(panel_announcement_back_end_bulletins_url) }
# format.xml { head :ok }
format.js
end
end
def delete
if params[:ids]
bulletins = Bulletin.any_in(:_id => params[:ids]).destroy_all
end
redirect_to panel_announcement_back_end_bulletins_url(:filter => params[:filter], :direction => params[:direction], :sort => params[:sort], :sort_options => params[:sort_options])
end
protected
def delete_out_invalid_date_from_params
if((params[:bulletin]["deadline(1i)"] && params[:bulletin]["deadline(1i)"].blank?) or (params[:bulletin]["deadline(2i)"] && params[:bulletin]["deadline(2i)"].blank?) or (params[:bulletin]["deadline(3i)"] && params[:bulletin]["deadline(3i)"].blank?))
params[:bulletin].delete("deadline(1i)")
params[:bulletin].delete("deadline(2i)")
params[:bulletin].delete("deadline(3i)")
params[:bulletin].delete("deadline(4i)")
params[:bulletin].delete("deadline(5i)")
@bulletin.deadline = nil
end rescue nil
end
def clean_values
if params[:bulletin]
params[:bulletin][:bulletin_links_attributes].each_with_index do |link, index|
params[:bulletin][:bulletin_links_attributes].delete(index.to_s) if link[1]['url'].blank? and link[1]['title_translations'].blank?
end rescue nil
params[:bulletin][:bulletin_files_attributes].each_with_index do |link, index|
params[:bulletin][:bulletin_files_attributes].delete(index.to_s) if link[1]['file'].blank? and link[1]['title_translations'].blank?
end rescue nil
end
end
end

View File

@ -0,0 +1,81 @@
class Panel::Announcement::FrontEnd::BulletinsController < OrbitWidgetController
# GET /bulletins
# GET /bulletins.xml
def index_bulletins_by_unit
@item = Page.find(params[:page_id]) rescue nil
@bulletins=Bulletin.all.available_for_lang(I18n.locale).can_display.where("cache_dept.#{I18n.locale.to_s.downcase}"=>params[:name]).page( params[:page_main]).per(15)
render :index
end
def search_result
if params[:search_query] == ""
@bulletins = get_bulletins_for_index
else
@search = Bulletin.tire.search "#{params[:search_query]}"
search_result = @search.collect{|result| result.id}
@bulletins = Bulletin.all.available_for_lang(I18n.locale).can_display.any_in(_id:search_result).page( params[:page_main]).per(@page_num)
end
end
def index
@bulletins = get_bulletins_for_index
end
def get_bulletins_for_index
@item = Page.find(params[:page_id]) rescue nil
if @item
if @item.frontend_data_count
@page_num = @item.frontend_data_count
else
@page_num = 15
end
@frontend_style = @item.frontend_style
end
date_now = Time.now
if !params[:category_id].blank? && !params[:tag_id].blank?
@bulletins = Bulletin.available_for_lang(I18n.locale).can_display.where(:category_id.in => params[:category_id], :tagged_ids.in => params[:tag_id]).desc( :is_top, :postdate).page( params[:page_main]).per(@page_num)
# @bulletins = Bulletin.available_for_lang(I18n.locale).can_display.where(:category_id.in=>params[:category_id],:tagged_ids.in=>params[:tag_id])
@current_category = BulletinCategory.from_id(params[:category_id]) rescue nil
elsif !params[:category_id].blank?
@bulletins = Bulletin.all.available_for_lang(I18n.locale).can_display.where(:category_id.in => params[:category_id]).desc( :is_top, :postdate).page( params[:page_main]).per(@page_num)
@current_category = BulletinCategory.from_id(params[:category_id]) rescue nil
elsif !params[:tag_id].blank?
@bulletins = Bulletin.available_for_lang(I18n.locale).can_display.where(:tagged_ids.in => params[:tag_id]).desc( :is_top, :postdate).page( params[:page_main]).per(@page_num)
else
@bulletins = Bulletin.all.available_for_lang(I18n.locale).can_display.desc( :is_top, :postdate).page( params[:page_main]).per(@page_num)
end
# delayed_impressionist(@tag) if @tag
@bulletins
end
def show
@item = Page.find(params[:page_id]) rescue nil
if params[:preview] == "true"
preview_content
else
@bulletin = Bulletin.all.can_display.where(_id: params[:id]).first
if @bulletin and !@bulletin.disable?
if @bulletin.enabled_for_lang(I18n.locale.to_s)
# delayed_impressionist(@bulletin)
impressionist(@bulletin)
else
render :text => "<div class='alert alert-error'>#{t('sys.can_not_display_due_to_no_context')}</div>".html_safe
end
else
render :nothing => true, :status => 403
end
end
end
def preview_content
@bulletin = Bulletin.find params[:id] rescue nil
@bulletin = Preview.find(params[:id]).get_virtual_object if @bulletin.nil?
end
end

View File

@ -0,0 +1,162 @@
class Panel::Announcement::Widget::BulletinsController < OrbitWidgetController
def initialize
super
@app_title = 'announcement'
end
# GET /bulletins
# GET /bulletins.xml
# def index
# @part = PagePart.find(params[:part_id])
# if @part.widget_data_count
# @page_num = @part.widget_data_count
# else
# @page_num = 4
# end
# num_of_fields = @part.widget_field_name.reject(&:empty?).length
# widget_field_names = @part.widget_field_name.reject(&:empty?)
# widget_classes = @part.widget_class.reject(&:empty?)
# @widget_fields = []
# if @part.widget_field_name
# num_of_fields.times do |index|
# @widget_fields << [widget_field_names[index], widget_classes[index]]
# end
# end
# @title = @part.title_translations[I18n.locale.to_s]
# @widget_style = @part.widget_style
# @category_id = @part.category
# date_now = Time.now
# if !params[:category_id].blank? && !params[:tag_id].blank?
# @posts = Bulletin.available_for_lang(I18n.locale).can_display.where(:category_id.in => params[:category_id], :tagged_ids.in => params[:tag_id]).desc( :is_top, :postdate).page( params[:page_main]).per(@page_num)
# elsif !params[:category_id].blank?
# @posts = Bulletin.all.available_for_lang(I18n.locale).can_display.where(:category_id.in => params[:category_id]).desc( :is_top, :postdate).page( params[:page_main]).per(@page_num)
# elsif !params[:tag_id].blank?
# @posts = Bulletin.available_for_lang(I18n.locale).can_display.where(:tagged_ids.in => params[:tag_id]).desc( :is_top, :postdate).page( params[:page_main]).per(@page_num)
# else
# @posts = Bulletin.all.available_for_lang(I18n.locale).can_display.desc( :is_top, :postdate).page( params[:page_main]).per(@page_num)
# end
# @categories = @module_app.categories.enabled
# end
def bulletins_list_and_pic
if params[:widget_data_count]
@page_num = params[:widget_data_count];
else
@page_num = 4;
end
@title = params[:part_title]
date_now = Time.now
if !params[:category_id].blank?
@bulletins = Bulletin.all.available_for_lang(I18n.locale).can_display.where(: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(@page_num )
@current_category = BulletinCategory.from_id(params[:category_id]) rescue nil
elsif !params[:tag_id].blank?
@bulletins = Bulletin.available_for_lang(I18n.locale).can_display.where(:tagged_ids => params[:tag_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(@page_num)
else
@bulletins = Bulletin.available_for_lang(I18n.locale).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(@page_num )
end
@categories = @module_app.categories.enabled
end
def bulletins_and_web_links
@part = PagePart.find(params[:part_id]) if !params[:part_id].blank?
@title = @part.title_translations[I18n.locale.to_s]
if !@part.blank? and @part.widget_data_count
@page_num = @part.widget_data_count
else
@page_num = 5
end
date_now = Time.now
if !params[:tag_id].blank?
@tags = Tag.any_in(:_id => params[:tag_id]).asc(:created_at)
elsif params[:tag_id].blank? and !@part.tag.blank?
@tags = Tag.any_in(:_id => @part.tag).asc(:created_at)
else
@ModuleApp_b = ModuleApp.first(:conditions => {:key=>'announcement'})
@tags = Tag.where(:module_tag_id => @ModuleApp_b.id).asc(:created_at)
end
@selected_tag = Tag.find(params[:id]).first rescue @tags[0]
@bulletins = Bulletin.available_for_lang(I18n.locale).can_display.where(:tagged_ids => @selected_tag.id.to_s, :is_hidden => false).any_of( {deadline: nil,:postdate.lte => date_now} , {:deadline.gte => date_now,:postdate.lte => date_now} ).desc(:is_top, :postdate).page(params[:page]).per(@page_num) rescue nil
if @part.widget_style == 'bulletins_and_links'
@ModuleApp_w = ModuleApp.first(:conditions => {:key=>'web_resource'})
@link_module_tag = ModuleTag.first(:conditions => {:name => @selected_tag.name, :module_app_id => @ModuleApp_w.id})
if !@link_module_tag.blank?
@link_selected_tag = Tag.first(:conditions => {:name => @selected_tag.name, :tag_lease_id => @link_module_tag.id})
else
@link_selected_tag = @link_module_tag
end
@web_links = WebLink.where(:tagged_ids => @link_selected_tag.id.to_s, :is_hidden => false).desc(:is_top,:created_at).available_for_lang(I18n.locale).page(params[:page]).per(@page_num) rescue nil
end
end
def reload_bulletins
@part = PagePart.find(params[:part_id]) if !params[:part_id].blank?
@title = @part.title_translations[I18n.locale.to_s]
if !@part.blank? and @part.widget_data_count
@page_num = @part.widget_data_count
else
@page_num = 5
end
date_now = Time.now
@selected_tag = Tag.find(params[:tag_id]).first
@bulletins = Bulletin.available_for_lang(I18n.locale).can_display.where(:tagged_ids => @selected_tag.id.to_s, :is_hidden => false).any_of( {deadline: nil,:postdate.lte => date_now} , {:deadline.gte => date_now,:postdate.lte => date_now} ).desc(:is_top, :postdate).page(params[:page]).per(@page_num) rescue nil
end
def reload_web_links
@part = PagePart.find(params[:part_id]) if !params[:part_id].blank?
if !@part.blank? and @part.widget_data_count
@page_num = @part.widget_data_count
else
@page_num = 5
end
date_now = Time.now
@selected_tag = Tag.find(params[:tag_id]).first
@ModuleApp = ModuleApp.first(:conditions => {:key=>'web_resource'})
@link_selected_tag = Tag.first(:conditions => {:name => @selected_tag.name, :module_tag_id => @ModuleApp.id})
@web_links = WebLink.where(:tagged_ids => @link_selected_tag.id.to_s, :is_hidden => false).desc(:is_top,:created_at).available_for_lang(I18n.locale).page(params[:page]).per(@page_num) rescue nil
end
def bulletins_side_bar
@tags_and_class = @module_app.sorted_tags_for_cloud
@categories = @module_app.categories.enabled
end
def bulletins_search_block
@part = PagePart.find params[:part_id]
end
end

0
app/helpers/.gitkeep Normal file
View File

0
app/mailers/.gitkeep Normal file
View File

0
app/models/.gitkeep Normal file
View File

163
app/models/bulletin.rb Normal file
View File

@ -0,0 +1,163 @@
# encoding: utf-8
class Bulletin
include Mongoid::Document
include Mongoid::Timestamps
include Mongoid::MultiParameterAttributes
include Impressionist::Impressionable
include OrbitCategory::Categorizable
include OrbitCoreLib::Preview
# include OrbitModel::Approval
include OrbitModel::LanguageRestrict
include OrbitModel::Status
include OrbitModel::TimeFrame
include OrbitTag::Taggable
include Tire::Model::Search
include Tire::Model::Callbacks
is_impressionable :counter_cache => { :column_name => :view_count }
field :title, localize: true
field :subtitle, localize: true
field :text, localize: true
field :create_user_id
field :update_user_id, :class_name => "User"
field :view_count, :type => Integer, :default => 0
field :public, :type => Boolean, :default => true
mount_uploader :image, ImageUploader
has_many :bulletin_links, :autosave => true, :dependent => :destroy
has_many :bulletin_files, :autosave => true, :dependent => :destroy
accepts_nested_attributes_for :bulletin_files, :allow_destroy => true
accepts_nested_attributes_for :bulletin_links, :allow_destroy => true
validates :title, :at_least_one => true
def to_indexed_json
self.to_json
end
# search_in :title, :subtitle, :text
#before_save :clean_values, :save_bulletin_links, :save_bulletin_files
# def self.search(str, options={})
# options[:limit] = options[:limit] || 50
# # default limit: 50 (mongoDB default: 100)
# res = self.mongo_session.command({ text: self.collection.name,
# search: str}.merge(options))
# # We shall now return a criteria of resulting objects!!
# self.where(:id.in => res['results'].collect {|o| o['obj']['_id']})
# end
def bulletin_category_with_title
self.category.title
end
def get_bulletin_category
self.category
end
def share_item
Item.first(conditions:{name: 'announcement'})
end
def enabled_for_lang(lang)
eval("self.available_for_#{lang}") rescue false
end
def publish_month
published_at.strftime("%B %Y")
end
# def self.search( search = nil, category_id = nil )
# if category_id.to_s.size > 0 and search.to_s.size > 0
# key = /#{search}/
# find(:all, :conditions => {title: key, category_id: category_id}).desc( :is_top, :postdate )
# elsif category_id.to_s.size > 0 and search.to_s.size < 1
# find(:all, :conditions => {category_id: category_id}).desc( :is_top, :postdate )
# elsif search.to_s.size > 0 and category_id.to_s.size < 1
# key = /#{search}/
# find(:all, :conditions => {title: key}).desc( :is_top, :postdate )
# else
# find(:all).desc( :is_top, :postdate)
# end
# end
def self.widget_datas( category_id = nil )
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"})
if category_id.to_s.size > 0
find(:all, :conditions => {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
def save_bulletin_links
self.bulletin_links.each do |t|
if t.should_destroy
t.destroy
end
end
end
def save_bulletin_files
self.bulletin_files.each do |t|
if t.should_destroy
t.destroy
end
end
end
def self.filter(bulletins)
bulletins.each do |bulletin|
p "#{bulletin.id}/#{bulletin.is_top}/#{bulletin.is_hot}/#{bulletin.is_hidden}"
end
return nil
end
def to_preview
preview_object = Preview.new(:expired_at=>DateTime.now+30.minutes,:preview_at_link=>"panel_announcement_front_end_bulletin_path",:object_class_type=>"Bulletin")
self.bulletin["bulletin_files_attributes"].each_with_index do |atr,idx|
preview_object.preview_files.build(:file=>self.bulletin["bulletin_files_attributes"][idx.to_s],:field_name_for_rebuild=>'bulletin_files',:file_in_array=>true)
end unless self.bulletin["bulletin_files_attributes"].nil?
self.bulletin["bulletin_links_attributes"].each_with_index do |atr,idx|
preview_object.preview_associations.build(:object=>self.bulletin["bulletin_links_attributes"][idx.to_s],:field_name_for_rebuild=>'bulletin_links',:object_in_array=>true)
end unless self.bulletin["bulletin_links_attributes"].nil?
preview_object.object = self.bulletin.except("bulletin_files_attributes","bulletin_links_attributes")
preview_object
end
protected
# def clean_values
# self.bulletin_links.each do |link|
# link.delete if link.url.blank? && link.title.blank?
# end
# self.tag_ids.delete('')
# end
end

View File

@ -0,0 +1,33 @@
# encoding: utf-8
class BulletinCategory
include Mongoid::Document
include Mongoid::Timestamps
include OrbitCoreLib::ObjectAuthable
include OrbitCoreLib::ObjectDisable
ObjectAuthTitlesOptions = %W{submit_new fact_check}
AfterObjectAuthUrl = '/panel/announcement/back_end/bulletin_categorys'
# include Mongoid::MultiParameterAttributes
PAYMENT_TYPES = [ "List", "Picture" ]
APP_NAME = 'Announcement'
field :disable, type: Boolean, :default => false
field :display
field :key
field :title, localize: true
has_many :bulletins
validates :title, :at_least_one => true
def pp_object
title
end
def self.from_id(id)
BulletinCategory.find(id) rescue nil
end
end

View File

@ -0,0 +1,14 @@
class BulletinFile
include Mongoid::Document
include Mongoid::Timestamps
mount_uploader :file, AssetUploader
field :description, localize: true
field :should_destroy, :type => Boolean
field :title, localize: true
belongs_to :bulletin
end

View File

@ -0,0 +1,25 @@
class BulletinLink
include Mongoid::Document
include Mongoid::Timestamps
field :url
field :title, localize: true
field :should_destroy, :type => Boolean
# embedded_in :bulletin
belongs_to :bulletin
before_validation :add_http
validates :url, :presence => true, :format => /^(http|https):\/\/(([a-z0-9]+([\-\.]{1}[a-z0-9]+)*\.[a-z]{2,5})|((25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?))(:[0-9]{1,5})?(\/.*)?/i
protected
def add_http
unless self.url[/^http:\/\//] || self.url[/^https:\/\//]
self.url = 'http://' + self.url
end
end
end

View File

@ -0,0 +1,11 @@
class UnitListForAnc
include Mongoid::Document
include Mongoid::Timestamps
field :order
field :ut_code
field :up_ut_code
field :title, localize: true
end

0
app/views/.gitkeep Normal file
View File

View File

@ -0,0 +1,83 @@
<% if bulletin -%>
<div class="modal hide fade in banner-preview" id="bulletin-<%=bulletin.id%>">
<div class="modal-header">
<a class="close" data-dismiss="modal">×</a>
<h3><%= t(:preview) %></h3>
</div>
<div class="modal-body">
<iframe src=<%= panel_announcement_front_end_bulletin_path(bulletin, :category_id => bulletin.category.id ,:preview=>true) %>></iframe>
</div>
<div class="modal-footer">
<%= form_for bulletin, :url => panel_announcement_back_end_bulletin_approve_path(bulletin),:method => :post, :html => {:class => 'form-horizontal'} do |f| %>
<%= content_tag :div,:class => "control-group pull-left" do -%>
<%= f.label :approval_stat, t('approval.stat'), :class=>"control-label" %>
<%= content_tag :div,:class => "controls" do -%>
<%= content_tag :label,:class => "radio inline" do -%>
<%= f.radio_button :is_checked, true , {:class => 'privacy'} %>
<%= t('approval.pass') %>
<% end -%>
<%= content_tag :label,:class => "radio inline" do -%>
<%= f.radio_button :is_checked, false, (!@bulletin.is_checked ? {:checked => true, :class => 'privacy'} : {})%>
<%= t('approval.not_pass') %>
<% end -%>
<% end -%>
<% end -%>
<%= content_tag :div,:class => "control-group pull-left reject" do -%>
<%= label :is_checked_false, t('approval.not_pass_reason'), :class=>"control-label" %>
<%= content_tag :div,:class => "controls" do -%>
<%= f.text_field :not_checked_reason, :class=>"input-xlarge" %>
<% end %>
<% end %>
<%= content_tag :div,:class => "control-group pull-right" do -%>
<%= f.submit t(:submit_approval),:class=>"btn"%>
<button class="btn" data-dismiss="modal" aria-hidden="true"><%= t(:close) %></button>
<% end %>
<% end %>
</div>
<div>
<script type="text/javascript" src="/assets/kernel.js"></script>
<script type="text/javascript">
$(function() {
$("iframe").load(function() {
// Get the body element
var frameBody = $("iframe").contents().find('body');
// Get all links inside the BODY tag
$("iframe").contents().find('#orbit-bar').hide();
frameBody.find('a').click(function(e){
//Disable all default actions
e.preventDefault();
});
$('input', frameBody).attr("disabled", true);
});
$(".modal").on("hidden", function () {
$("#show_preview").remove();
});
});
</script>
<script>
$('#show_preview').on(clickEvent, 'input[type="radio"]', function(event) {
if($(this).val() == "true") {
$('.reject').addClass('hide');
} else {
$('.reject').removeClass('hide');
}
});
</script>
</div>
</div>
<% end -%>

View File

@ -0,0 +1,44 @@
<% if category -%>
<div class="modal hide fade in" id="category-<%=category.id%>">
<div class="modal-header">
<a class="close" data-dismiss="modal">×</a>
<h3><%= t("approval.user_list") %></h3>
</div>
<div class="modal-body">
<div class="clear">
<% category.get_object_auth_by_title('fact_check').auth_users.each do |user| %>
<div class="checkbox clear checked">
<div class='member-avatar'>
<% if user.avatar? %>
<%= image_tag(user.avatar.thumb.url,:class => "member-img") %>
<% else %>
<%= image_tag "person.png",:class => "member-img" %>
<% end %>
</div>
<%= label_tag "lab-user-#{user.id}", (user.name rescue ''),:class=>"member-name",:id=>nil -%>
</div>
<% end -%>
<divl>
</div>
<div class="modal-footer">
<a href="#" class="btn" data-dismiss="modal"><%= t(:close) %></a>
</div>
<div>
<script type="text/javascript" src="/assets/kernel.js"></script>
<script type="text/javascript">
$(document).ready(function() {
$("#category-<%=category.id%>").on("show", function () {
});
$(".modal").on("hidden", function () {
$("#show_preview").remove();
});
});
</script>
</div>
</div>
<% end -%>

View File

@ -0,0 +1,2 @@
$('#show_preview').html("<%= escape_javascript(render(:partial => 'modal_approve',:locals => {:bulletin => @bulletin})) %>");
var start_modal_with_id = "bulletin-<%=@bulletin.id%>";

View File

@ -0,0 +1,53 @@
<% content_for :page_specific_css do %>
<%= stylesheet_link_tag "inc/permission-checkbox" %>
<% end %>
<% content_for :page_specific_javascript do %>
<%= javascript_include_tag "inc/permission-checkbox" %>
<%= javascript_include_tag "inc/search" %>
<%= javascript_include_tag "inc/modal-preview" %>
<% end %>
<%= form_tag('', :remote => true,:class => "prevent_enter_submit_form") %>
<div class="subnav clear">
<ul class="nav nav-pills filter pull-left">
<li class="accordion-group">
<div class="form-search" style="margin: 5px 10px;">
<%= label_tag :category, t(:category) %>
<%= select "category",'id',@options_from_collection_for_select_bulletin_categorys %>
<%= search_field_tag 'user_filter' %>
</div>
</li>
</ul>
<%= link_to t("approval.user_list"), panel_announcement_back_end_approval_user_list_path , :class=>'preview_trigger btn btn-success pull-right'%>
</div>
<%#= label_tag :role, t(:roles) %>
<div class="clear">
<%= content_tag :div do -%>
<% form_tag panel_announcement_back_end_approval_setting_path do %>
<%= render :partial => "layouts/users_checkbox_ary" %>
<div class="form-actions form-fixed pagination-right">
<%= submit_tag t(:update_), :class => 'btn btn-primary' %>
</div>
<% end -%>
<% end -%>
</div>
<script type="text/javascript" charset="utf-8">
var availableTags = [];
$(document).ready(function() {
$(".prevent_enter_submit_form").bind("keypress", function(e) {
if (e.keyCode == 13) {
return false;
}
});
$('#category_id').change(function() {
$.ajax({
type: 'GET',
dataType: "script",
url:$(this).parents("from").attr("href"),
data:$(this).parents("form").serialize()
});
});
});
</script>

View File

@ -0,0 +1,2 @@
$("#users_checkbox_ary").replaceWith('<%= escape_javascript(render :partial=> "layouts/users_checkbox_ary" )%>');
permissionCheckbox();

View File

@ -0,0 +1 @@
alert( "<% flash.each do |key, msg| %><%= msg %><% end%>");

View File

@ -0,0 +1,2 @@
$('#show_preview').html("<%= escape_javascript(render(:partial => 'modal_list',:locals => {:category => @category})) %>");
var start_modal_with_id = "category-<%=@category.id%>"

View File

@ -0,0 +1,44 @@
<% if bulletin_category -%>
<div class="modal hide fade in" id="bulletin_category-<%=bulletin_category.id%>">
<div class="modal-header">
<a class="close" data-dismiss="modal">×</a>
<h3><%= t(:submit_user_list) %></h3>
</div>
<div class="modal-body">
<div class="clear">
<% bulletin_category.get_object_auth_by_title('submit').auth_users.each do |user| %>
<div class="checkbox clear checked">
<div class='member-avatar'>
<% if user.avatar? %>
<%= image_tag(user.avatar.thumb.url,:class => "member-img") %>
<% else %>
<%= image_tag "person.png",:class => "member-img" %>
<% end %>
</div>
<%= label_tag "lab-user-#{user.id}", (user.name rescue ''),:class=>"member-name",:id=>nil -%>
</div>
<% end -%>
<divl>
</div>
<div class="modal-footer">
<a href="#" class="btn" data-dismiss="modal"><%= t(:close) %></a>
</div>
<div>
<script type="text/javascript" src="/assets/kernel.js"></script>
<script type="text/javascript">
$(document).ready(function() {
$("#bulletin_category-<%=bulletin_category.id%>").on("show", function () {
});
$(".modal").on("hidden", function () {
$("#show_preview").remove();
});
});
</script>
</div>
</div>
<% end -%>

View File

@ -0,0 +1,307 @@
<% content_for :page_specific_css do %>
<%= stylesheet_link_tag "lib/main-forms" %>
<%= stylesheet_link_tag "lib/fileupload" %>
<%= stylesheet_link_tag "lib/main-list" %>
<% end %>
<% content_for :page_specific_javascript do %>
<%= javascript_include_tag "lib/bootstrap-fileupload" %>
<%= javascript_include_tag "lib/bootstrap-datetimepicker" %>
<%= javascript_include_tag "lib/datetimepicker/datetimepicker.js" %>
<%= javascript_include_tag "lib/modal-preview" %>
<%= javascript_include_tag "lib/file-type" %>
<%= javascript_include_tag "lib/module-area" %>
<% end %>
<%= f.error_messages %>
<!-- Input Area -->
<div class="input-area">
<!-- Module Tabs -->
<div class="nav-name"><strong><%= t(:module) %></strong></div>
<ul class="nav nav-pills module-nav">
<li class="active">
<a href="#basic" data-toggle="tab"><%= t(:basic) %></a>
</li>
<% if show_form_status_field(@bulletin) %>
<li>
<a href="#status" data-toggle="tab"><%= t(:status) %></a>
</li>
<% end %>
<li>
<a href="#tag" data-toggle="tab"><%= t(:tags) %></a>
</li>
<li>
<a href="#imageupload" data-toggle="tab"><%= t(:image) %></a>
</li>
</ul>
<!-- Module -->
<div class="tab-content module-area">
<!-- Basic Module -->
<div class="tab-pane fade in active" id="basic">
<!-- Category -->
<div class="control-group">
<label class="control-label muted"><%= t(:category) %></label>
<div class="controls">
<%= f.select :category_id, @categories.collect{|t| [ t.title, t.id ]} %>
</div>
</div>
<!-- Date Time Picker -->
<div class="control-group">
<label class="control-label muted"><%= t(:start) %></label>
<div class="controls">
<%= f.datetime_picker :postdate, :no_label => true %>
</div>
</div>
<div class="control-group">
<label class="control-label muted"><%= t(:end) %></label>
<div class="controls">
<%= f.datetime_picker :deadline, :no_label => true %>
</div>
</div>
</div>
<!-- Status Module -->
<% if show_form_status_field(@bulletin) %>
<div class="tab-pane fade" id="status">
<!-- Status -->
<div class="control-group">
<label class="control-label muted"><%= t(:status) %></label>
<div class="controls" data-toggle="buttons-checkbox">
<label class="checkbox inline btn <%= 'active' if @bulletin.is_top? %>">
<%= f.check_box :is_top %> <%= t(:top) %>
</label>
<label class="checkbox inline btn <%= 'active' if @bulletin.is_hot? %>">
<%= f.check_box :is_hot %> <%= t(:hot) %>
</label>
<label class="checkbox inline btn <%= 'active' if @bulletin.is_hidden? %>">
<%= f.check_box :is_hidden %> <%= t(:hide) %>
</label>
</div>
</div>
</div>
<% end %>
<!-- Tag Module -->
<div class="tab-pane fade" id="tag">
<!-- Tag -->
<div class="control-group">
<label class="control-label muted"><%= t(:tags) %></label>
<div class="controls" data-toggle="buttons-checkbox">
<% @tags.each do |tag| %>
<label class="checkbox inline btn <%= 'active' if @bulletin.tag_ids.include?(tag.id) %>">
<%= check_box_tag 'bulletin[tag_ids][]', tag.id, @bulletin.tag_ids.include?(tag.id) %> <%= tag.name %>
<%= hidden_field_tag 'bulletin[tag_ids][]', '' %>
</label>
<% end %>
</div>
</div>
</div>
<!-- Images Module -->
<div class="tab-pane fade" id="imageupload">
<!-- Images Upload -->
<div class="control-group">
<label class="control-label muted"><%= t(:image) %></label>
<div class="controls">
<div class="fileupload fileupload-new clearfix <%= 'fileupload-edit' if @bulletin.image.file %>" data-provides="fileupload">
<div class="fileupload-new thumbnail pull-left">
<% if @bulletin.image.file %>
<%= image_tag @bulletin.image %>
<% else %>
<img src="http://www.placehold.it/50x50/EFEFEF/AAAAAA" />
<% end %>
</div>
<div class="fileupload-preview fileupload-exists thumbnail pull-left"></div>
<span class="btn btn-file">
<span class="fileupload-new"><%= t(:select_image) %></span>
<span class="fileupload-exists"><%= t(:change) %></span>
<%= f.file_field :image %>
</span>
<a href="#" class="btn fileupload-exists" data-dismiss="fileupload"><%= t(:cancel) %></a>
<div class="controls" data-toggle="buttons-checkbox">
<label class="checkbox inline btn btn-danger fileupload-remove">
<%= f.check_box :remove_image %><%= t(:remove) %>
</label>
</div>
</div>
</div>
</div>
</div>
</div>
<!-- Language Tabs -->
<div class="nav-name"><strong><%= t(:language) %></strong></div>
<ul class="nav nav-pills language-nav">
<% @site_in_use_locales.each_with_index do |locale, i| %>
<li class="<%= 'active' if i == 0 %>">
<a data-toggle="tab" href=".<%= locale %>"><%= I18nVariable.from_locale(locale) %></a>
</li>
<% end %>
</ul>
<!-- Language -->
<div class="tab-content language-area">
<% @site_in_use_locales.each_with_index do |locale, i| %>
<div class="<%= locale %> tab-pane fade <%= ( i == 0 ) ? "in active" : '' %>">
<!-- Title-->
<div class="control-group input-title">
<label class="control-label muted"><%= t(:title) %></label>
<div class="controls">
<%= f.fields_for :title_translations do |f| %>
<%= f.text_field locale, class: "input-block-level", placeholder: t(:title), value: (@bulletin.title_translations[locale] rescue nil) %>
<% end %>
</div>
</div>
<!-- Sub Title -->
<div class="control-group input-subtitle">
<label class="control-label muted"><%= t(:subtitle) %></label>
<div class="controls">
<div class="textarea">
<%= f.fields_for :subtitle_translations do |f| %>
<%= f.text_area locale, rows: 2, class: "input-block-level", value: (@bulletin.subtitle_translations[locale] rescue nil) %>
<% end %>
</div>
</div>
</div>
<!-- Content -->
<div class="control-group input-content">
<label class="control-label muted"><%= t(:content) %></label>
<div class="controls">
<div class="textarea">
<%= f.fields_for :text_translations do |f| %>
<%= f.cktext_area locale, rows: 5, class: "input-block-level", :value => (@bulletin.text_translations[locale] rescue nil) %>
<% end %>
</div>
</div>
</div>
</div>
<% end %>
<!-- Link -->
<div class="control-group">
<label class="control-label muted"><%= t(:link) %></label>
<div class="controls add-input">
<!-- Exist -->
<% if @bulletin && !@bulletin.bulletin_links.blank? %>
<div class="exist">
<% @bulletin.bulletin_links.each_with_index do |bulletin_link, i| %>
<%= f.fields_for :bulletin_links, bulletin_link do |f| %>
<%= render :partial => 'form_link', :object => bulletin_link, :locals => {:f => f, :i => i} %>
<% end %>
<% end %>
<hr>
</div>
<% end %>
<!-- Add -->
<div class="add-target">
</div>
<p class="add-btn">
<%= hidden_field_tag 'bulletin_link_field_count', @bulletin.bulletin_links.count %>
<a id="add_link" class="trigger btn btn-small btn-primary"><i class="icons-plus"></i> <%= t(:add) %></a>
</p>
</div>
</div>
<!-- File -->
<div class="control-group">
<label class="control-label muted"><%= t(:file_) %></label>
<div class="controls">
<!-- Exist -->
<% if @bulletin && !@bulletin.bulletin_files.blank? %>
<div class="exist">
<% @bulletin.bulletin_files.each_with_index do |bulletin_file, i| %>
<%= f.fields_for :bulletin_files, bulletin_file do |f| %>
<%= render :partial => 'form_file', :object => bulletin_file, :locals => {:f => f, :i => i} %>
<% end %>
<% end %>
<hr>
</div>
<% end %>
<!-- Add -->
<div class="add-target">
</div>
<p class="add-btn">
<%= hidden_field_tag 'bulletin_file_field_count', @bulletin.bulletin_files.count %>
<a id="add_file" class="trigger btn btn-small btn-primary"><i class="icons-plus"></i> <%= t(:add) %></a>
</p>
</div>
</div>
</div>
</div>
<!-- Form Actions -->
<div class="form-actions">
<%= f.submit t('submit'), class: 'btn btn-primary' %>
<%= button_tag t("preview"), id: "button_for_preview", name: "commit", class: 'btn post_preview', type: :button, url: preview_panel_announcement_back_end_bulletins_path %>
<%= link_to t('cancel'), get_go_back, :class=>"btn" %>
</div>
<% content_for :page_specific_javascript do %>
<script>
$(function() {
$(document).on('click', '#add_link', function(){
var new_id = $(this).prev().attr('value');
var old_id = new RegExp("new_bulletin_links", "g");
var on = $('.language-nav li.active').index();
var le = $(this).parent('.add-btn').prev('.add-target').children('.start-line').length;
$(this).prev().attr('value', parseInt(new_id) + 1);
$(this).parent().siblings('.add-target').append(("<%= escape_javascript(add_attribute 'form_link', f, :bulletin_links) %>").replace(old_id, new_id));
$(this).parent('.add-btn').prev('.add-target').children('.start-line').eq(le).children('.tab-content').children('.tab-pane').eq(on).addClass('in active').siblings().removeClass('in active');
formTip();
});
$(document).on('click', '#add_file', function(){
var new_id = $(this).prev().attr('value');
var old_id = new RegExp("new_bulletin_files", "g");
var on = $('.language-nav li.active').index();
var le = $(this).parent('.add-btn').prev('.add-target').children('.start-line').length;
$(this).prev().attr('value', parseInt(new_id) + 1);
$(this).parent().siblings('.add-target').append(("<%= escape_javascript(add_attribute 'form_file', f, :bulletin_files) %>").replace(old_id, new_id));
$(this).parent('.add-btn').prev('.add-target').children('.start-line').eq(le).children('.input-append').find('.tab-content').each(function() {
$(this).children('.tab-pane').eq(on).addClass('in active').siblings().removeClass('in active');
});
formTip();
});
$(document).on('click', '.delete_link', function(){
$(this).parents('.input-prepend').remove();
});
$(document).on('click', '.delete_file', function(){
$(this).parents('.input-prepend').remove();
});
$(document).on('click', '.remove_existing_record', function(){
if(confirm("<%= I18n.t(:sure?)%>")){
$(this).children('.should_destroy').attr('value', 1);
$(this).parents('.start-line').hide();
}
});
});
</script>
<% end %>

View File

@ -0,0 +1,305 @@
<% # encoding: utf-8 %>
<% content_for :page_specific_javascript do -%>
<%= javascript_include_tag "inc/modal-preview" %>
<% end -%>
<!--Widget start-->
<%= f.error_messages %>
<div id="sub-wiget">
<div id="widget-picture" class="widget-box">
<div class="widget-action clear tip" title="Upload pictures">
<a class="action"><i class="icon-exclamation-sign icon-white"></i></a>
</div>
<h3 class="widget-title"><i class="icons-pictures"></i><%= t('announcement.picture') %></h3>
<div class="widget-content clear">
<div class="control-group">
<!-- <img class="pull-left upload-picture" src="/assets/default-img.png" /> -->
<div class="upload-picture">
<% if @bulletin.image %>
<%= image_tag @bulletin.image rescue ''%>
<% else %>
<img class="pull-left upload-picture" src="/assets/default-img.png" />
<% end %>
</div>
<span class="alert widgetInfo"><%= t("ad.widget_info_for_ad_image_size", :best_size=> "290px x 150px") %></span>
<div class="controls file-upload input-prepend">
<%= t(:browse) %>
<%= f.file_field :image, :id => "input-upload", :class => '', :onchange => "document.getElementById('fu').innerHTML = this.form.fu.value = this.value;" %>
<!-- <span id='fu' class="file-name"></span>
<br>
<input name='fu' class="input-medium" type="text">
<br> -->
<% if @bulletin.image.file %>
<%= f.check_box :remove_image %>
<%= t('delete.file') %>
<% end %>
</div>
</div>
</div>
</div>
<div id="widget-date" class="widget-box widget-size-300">
<div class="widget-action clear tip" title="Set the announcement to start and end dates">
<a href="#" class="action"><i class="icon-exclamation-sign icon-white"></i></a>
</div>
<h3 class="widget-title"><i class="icons-calendar"></i><%= t(:date_) %></h3>
<div class="widget-content clear">
<div class="control-group">
<%= f.datetime_picker :postdate, :picker_type => 'separated', :label => t(:start) %>
</div>
<div class="control-group">
<%= f.datetime_picker :deadline, :picker_type => 'separated', :label => t(:end) %>
</div>
</div>
</div>
<% if show_form_status_field(@bulletin)%>
<div id="widget-status" class="widget-box widget-size-300">
<div class="widget-action clear tip" title="Setting the announcement state">
<a class="action"><i class="icon-exclamation-sign icon-white"></i></a>
</div>
<h3 class="widget-title"><i class="icons-star"></i><%= t(:status) %></h3>
<div class="widget-content clear">
<div class="controls">
<%= content_tag :label,:class => "checkbox inline" do -%>
<%= f.check_box :is_top %>
<%= t('top') %>
<% end -%>
<%= content_tag :label,:class => "checkbox inline" do -%>
<%= f.check_box :is_hot %>
<%= t('hot') %>
<% end -%>
<%= content_tag :label,:class => "checkbox inline" do -%>
<%= f.check_box :is_hidden %>
<%= t('hide') %>
<% end -%>
</div>
</div>
</div>
<% end %>
<!-- <% if @bulletin.is_rejected %>
<div id="widget-rejected" class="widget-box widget-size-300">
<div class="widget-action clear tip" title="Rejected Report">
<a class="action"><i class="icon-cog icon-white"></i></a>
</div>
<h3 class="widget-title"><i class="icons-tag"></i><%= t('approval.stat') %></h3>
<div class="widget-content clear form-horizontal">
<%= @bulletin.not_checked_reason rescue t("rejected_reason_empty") %>
</div>
</div>
<% end %> -->
<div id="widget-tags" class="widget-box widget-size-300">
<div class="widget-action clear tip" title="Setting">
<a class="action"><i class="icon-cog icon-white"></i></a>
</div>
<h3 class="widget-title"><i class="icons-tag"></i><%= t(:tags) %></h3>
<div class="widget-content clear form-horizontal">
<p>
<% @tags.each do |tag| %>
<%= content_tag :label,:class => "checkbox inline" do -%>
<%= check_box_tag 'bulletin[tag_ids][]', tag.id, @bulletin.tag_ids.include?(tag.id) %>
<%= tag.name %>
<%= hidden_field_tag 'bulletin[tag_ids][]', '' %>
<% end %>
<% end %>
</p>
</div>
</div>
<% if params[:action] != 'new' %>
<div id="widget-audit" class="widget-box">
<div class="widget-action clear tip" title="A">
<a class="action"><i class="icon-exclamation-sign icon-white"></i></a>
</div>
</div>
<% elsif current_user.admin? %>
<%= f.hidden_field :is_checked,:value => true%>
<% end %>
</div>
<!--Wiget End-->
<!--Post Start-->
<div id="post-body">
<div id="post-body-content" class="clear">
<%#= f.label :unit_list_for_anc%>
<%#= f.select :unit_list_for_anc_id,@unit_list_for_anc.collect{|t| [ t.title, t.id ]}, {}, :class => "input-medium" %>
<%= f.label :category,t(:category)%>
<%= f.select :category_id, @bulletin_categories.collect{|t| [ t.title, t.id ]}, {}, :class => "input-medium" %>
<ul class="nav nav-tabs">
<%# @site_valid_locales.each_with_index do |locale, i| %>
<% @site_in_use_locales.each_with_index do |locale, i| %>
<li <%= ( i == 0 ) ? " class=active" : '' %>><a data-toggle="tab" href=".<%= locale %>"><%= I18nVariable.from_locale(locale) %></a></li>
<% end %>
</ul>
<div class="tab-content">
<%# @site_valid_locales.each_with_index do |locale, i| %>
<% @site_in_use_locales.each_with_index do |locale, i| %>
<div class="<%= locale %> fade tab-pane <%= ( i == 0 ) ? "in active" : '' %>">
<div class="title">
<%= f.label :title ,t(:title)%>
<%= f.fields_for :title_translations do |f| %>
<%= I18nVariable.from_locale(locale) %>
<%= f.text_field locale, :class=>'post-title', :value => (@bulletin.title_translations[locale] rescue nil) %>
<% end %>
</div>
<div class="editor">
<%= f.label :subtitle, t(:subtitle) %>
<%= f.fields_for :subtitle_translations do |f| %>
<%= I18nVariable.from_locale(locale) %>
<%= f.text_area locale, :rows => 5, :style=>"width:100%", :value => (@bulletin.subtitle_translations[locale] rescue nil) %>
<% end %>
</div>
<div class="editor">
<%= f.label :text ,t(:text)%>
<%= f.fields_for :text_translations do |f| %>
<%= I18nVariable.from_locale(locale) %>
<%= f.text_area locale, :style=>"width:100%", :class => 'tinymce_textarea', :value => (@bulletin.text_translations[locale] rescue nil) %>
<% end %>
</div>
</div>
<% end %>
</div>
<div class="main-wiget">
<div id="widget-link" class="widget-box">
<div class="widget-action clear tip" title="Add a reference link">
<a class="action"><i class="icon-exclamation-sign icon-white"></i></a>
</div>
<h3 class="widget-title"><i class="icons-link"></i><%= t(:link) %></h3>
<div class="widget-content">
<div id='bulletin_links' class="bulletin_links_block">
<table class="table table-condensed">
<thead>
<tr>
<th><%= t('announcement.url') %></th>
<th><%= t('announcement.link_name') %></th>
<th class="span1"></th>
</tr>
</thead>
<tfoot>
<tr>
<td style="text-align:center" colspan="4">
<div id='add_bulletin_link' class="info_input bulletin_links_block">
<%= hidden_field_tag 'bulletin_link_field_count', @bulletin.bulletin_links.count %>
<a class="add"><span class="btn btn-primary btn-small"><i class="icon-plus icon-white"></i><%= t(:add) %></span></a>
</div>
</td>
</tr>
</tfoot>
<tbody>
<% @bulletin.bulletin_links.each_with_index do |bulletin_link, i| %>
<%#= fields_for "bulletin[bulletin_links][]", bulletin_link do |f| %>
<%= f.fields_for :bulletin_links, bulletin_link do |f| %>
<%= render :partial => 'form_bulletin_link', :object => bulletin_link, :locals => {:f => f, :i => i} %>
<% end %>
<% end %>
</tbody>
</table>
</div>
</div>
</div>
<div id="widget-file" class="widget-box">
<div class="widget-action clear tip" title="Added to the file">
<a class="action"><i class="icon-exclamation-sign icon-white"></i></a>
</div>
<h3 class="widget-title"><i class="icons-paperclip"></i><%= t('announcement.file') %></h3>
<div class="widget-content">
<div id='bulletin_files' class="bulletin_files_block">
<table class="table table-condensed">
<thead>
<tr>
<th><%= t('announcement.selected_file') %></th>
<th><%= t('announcement.file_name') %></th>
<th><%= t('announcement.file_description') %></th>
<th class="span1"></th>
</tr>
</thead>
<tfoot>
<tr>
<td style="text-align:center" colspan="4">
<div id='add_bulletin_file' class="info_input bulletin_files_block">
<%= hidden_field_tag 'bulletin_file_field_count', @bulletin.bulletin_files.count %>
<a class="add"><span class="btn btn-primary btn-small"><i class="icon-plus icon-white"></i><%= t(:add) %></span></a>
<p><%= t("sys.limit_of_upload_file_size",:best_size => '3MB') %></p>
<p><%= t("sys.preview_only_for_img") %></p>
</div>
</td>
</tr>
</tfoot>
<tbody>
<% @bulletin.bulletin_files.each_with_index do |bulletin_file, i| %>
<%#= fields_for "bulletin[bulletin_files][]", bulletin_file do |f| %>
<%= f.fields_for :bulletin_files, bulletin_file do |f| %>
<%= render :partial => 'form_bulletin_file', :object => bulletin_file, :locals => {:f => f, :i => i} %>
<% end %>
<% end %>
</tbody>
</table>
</div>
</div>
</div>
</div>
</div>
<!--Post End-->
</div>
<div class="form-actions">
<%= button_tag t("preview"), :id=>"button_for_preview", :name=>"commit",:class=>'btn post_preview two_btn',:type=>:button,:url=>preview_panel_announcement_back_end_bulletins_path %>
<%= f.submit t('submit'), :class=>'btn btn-primary two_btn' %>
<%= link_to t('cancel'), get_go_back, :class=>"btn" %>
</div>
</div>
<% content_for :page_specific_javascript do %>
<%= javascript_include_tag "bulletin_form" %>
<%= javascript_include_tag "inc/jquery.imagesloaded.js" %>
<script>
$(document).ready(function() {
$('#add_bulletin_link a.add').live('click', function(){
var new_id = $(this).prev().attr('value');
var old_id = new RegExp("new_bulletin_links", "g");
$(this).prev().attr('value', parseInt(new_id) + 1);
$(this).parents('table').append(("<%= escape_javascript(add_attribute 'form_bulletin_link', f, :bulletin_links) %>").replace(old_id, new_id));
});
$('#add_bulletin_file a.add').live('click', function(){
var new_id = $(this).prev().attr('value');
var old_id = new RegExp("new_bulletin_files", "g");
$(this).prev().attr('value', parseInt(new_id) + 1);
$(this).parents('table').append(("<%= escape_javascript(add_attribute 'form_bulletin_file', f, :bulletin_files) %>").replace(old_id, new_id));
});
$('.for_preview').popover({ html : true });
});
</script>
<% end %>

View File

@ -0,0 +1,55 @@
<% if form_file.new_record? %>
<div class="fileupload fileupload-new start-line" data-provides="fileupload">
<% else %>
<div class="fileupload fileupload-exist start-line" data-provides="fileupload">
<% if form_file.file.blank? %>
<%= t(:no_file) %>
<% else %>
<%= link_to content_tag(:i) + form_file.file_identifier, form_file.file.url, {:class => 'file-link file-type', :target => '_blank', :title => form_file.file_identifier} %>
<% end %>
<% end %>
<div class="input-prepend input-append">
<label>
<span class="add-on btn btn-file" title='<%= t(:file_) %>'>
<i class="icons-paperclip"></i>
<%= f.file_field :file %>
</span>
<div class="uneditable-input input-medium">
<i class="icon-file fileupload-exists"></i>
<span class="fileupload-preview"><%= (form_file.new_record? || form_file.file.blank?) ? t(:select_file) : t(:change_file) %></span>
</div>
</label>
<span class="add-on icons-pencil" title='<%= t(:alternative) %>'></span>
<span class="tab-content">
<% @site_in_use_locales.each_with_index do |locale, i| %>
<span class="tab-pane fade <%= ( i == 0 ) ? "in active" : '' %> <%= locale %>">
<%= f.fields_for :title_translations do |f| %>
<%= f.text_field locale, :class => "input-medium", placeholder: t(:alternative), :value => (form_file.title_translations[locale] rescue nil) %>
<% end %>
</span>
<% end %>
</span>
<span class="add-on icons-pencil" title='<%= t(:description) %>'></span>
<span class="tab-content">
<% @site_in_use_locales.each_with_index do |locale, i| %>
<span class="tab-pane fade <%= ( i == 0 ) ? "in active" : '' %> <%= locale %>">
<%= f.fields_for :description_translations do |f| %>
<%= f.text_field locale, :class => "input-medium", placeholder: t(:description), :value => (form_file.description_translations[locale] rescue nil) %>
<% end %>
</span>
<% end %>
</span>
</span>
<% if form_file.new_record? %>
<span class="delete_file add-on btn" title="<%= t(:delete_) %>">
<a class="icon-trash"></a>
</span>
<% else %>
<span class="remove_existing_record add-on btn" title="<%= t(:remove) %>">
<%= f.hidden_field :id %>
<a class="icon-remove"></a>
<%= f.hidden_field :_destroy, :value => nil, :class => 'should_destroy' %>
</span>
<% end %>
</div>
</div>

View File

@ -0,0 +1,26 @@
<div class="input-prepend input-append start-line">
<span class="add-on icons-link" title="<%= t(:url) %>"></span>
<%= f.text_field :url, class: "input-large", placeholder: t(:url) %>
<span class="add-on icons-pencil" title="<%= t(:url_alt) %>"></span>
<span class="tab-content">
<% @site_in_use_locales.each_with_index do |locale, i| %>
<span class="tab-pane fade <%= ( i == 0 ) ? "in active" : '' %> <%= locale %>">
<%= f.fields_for :title_translations do |f| %>
<%= f.text_field locale, :class => "input-large", placeholder: t(:url_alt), :value => (form_link.title_translations[locale] rescue nil) %>
<% end %>
</span>
<% end %>
</span>
<% if form_link.new_record? %>
<span class="delete_link add-on btn" title="<%= t(:delete_) %>">
<a class="icon-trash"></a>
</span>
<% else %>
<span class="remove_existing_record add-on btn" title="<%= t(:remove) %>">
<%= f.hidden_field :id %>
<a class="remove_existing_record icon-remove"></a>
<%= f.hidden_field :_destroy, :value => nil, :class => 'should_destroy' %>
</span>
<% end %>
</div>

View File

@ -0,0 +1,48 @@
<% if bulletin -%>
<div class="modal hide fade in banner-preview" id="bulletin-<%=bulletin.id%>" style="width:1024px;height:500px;margin-left:-512px">
<div class="modal-header">
<a class="close" data-dismiss="modal">×</a>
<h3><%= t(:preview) %></h3>
</div>
<div class="modal-body">
<p class="bulletin_slideshow">
<iframe src=<%= panel_announcement_front_end_bulletin_path(bulletin, :category_id => bulletin.category.id ,:preview=>true) %> style="width:1000px;height:300px" >
</iframe>
</p>
</div>
<div class="modal-footer">
<a href="#" class="btn" data-dismiss="modal"><%= t(:close) %></a>
</div>
<div>
<script type="text/javascript" src="/assets/kernel.js"></script>
<script type="text/javascript">
$(document).ready(function() {
$(".modal").on("hidden", function () {
$("#show_preview").remove();
});
$("iframe").load(function(){
// Get the body element
var frameBody = $("iframe").contents().find("body");
// Get all links inside the BODY tag
$('a', frameBody).click(function(e){
//Disable all default actions
e.preventDefault();
});
$('input', frameBody).attr("disabled", true);
});
});
</script>
</div>
</div>
<% end -%>

View File

@ -0,0 +1 @@
$("#<%= dom_id @bulletin %>").remove();

View File

@ -0,0 +1,5 @@
<%= form_for @bulletin, url: panel_announcement_back_end_bulletin_path(@bulletin), html: {class: "form-horizontal main-forms previewable"} do |f| %>
<fieldset>
<%= render partial: 'form', locals: {f: f} %>
</fieldset>
<% end %>

View File

@ -0,0 +1,61 @@
<% set_default_index do
objects @bulletins
quick_edit_link type: 'edit',
link: 'edit_panel_announcement_back_end_bulletin_path'
quick_edit_link type: 'detail'
quick_edit_link type: 'delete',
link: 'panel_announcement_back_end_bulletin_path'
# can have: title, warning, cancel and submit values
# quick_edit_link type: 'approval',
# link: 'panel_announcement_back_end_bulletin_approval_preview_path'
# quick_edit_link type: 'reject_reason'
field type: 'status',
db_field: @statuses,
translation: 'status',
hide: 'phone',
sort: 'status'
field type: 'associated',
db_field: 'category',
model_field: 'title',
translation: 'category',
hide: 'phone',
sort: 'category'
field db_field: 'title',
translation: 'title',
sort: 'title',
display_option: 'link_to value, panel_announcement_front_end_bulletin_path(object)',
quick_edit: true,
header_class: 'span5'
field db_field: 'postdate',
translation: 'start_date',
hide: 'phone',
sort: 'start_date'
field db_field: 'deadline',
translation: 'end_date',
hide: 'phone',
sort: 'end_date'
field type: 'tags',
hide: 'all',
sort: 'tags'
field type: 'id',
db_field: 'update_user_id',
model: User,
model_field: 'name',
translation: 'last_modified',
hide: 'phone',
sort: 'last_modified'
filter_field type: 'array',
values: @statuses,
translation: 'status'
filter_field type: 'objects',
values: @categories,
translation: 'category',
object_field: 'title'
filter_field type: 'objects',
values: @tags,
translation: 'tags',
object_field: 'name'
footer link: 'new_panel_announcement_back_end_bulletin_path'
end %>
<%= render 'admin/default_index/index' %>

View File

@ -0,0 +1,5 @@
<%= form_for @bulletin, url: panel_announcement_back_end_bulletins_path, html: {class: "form-horizontal main-forms previewable"} do |f| %>
<fieldset>
<%= render partial: 'form', locals: {f: f} %>
</fieldset>
<% end %>

View File

@ -0,0 +1,2 @@
$('#show_preview').html("<%= escape_javascript(render(:partial => 'modal_preview',:locals => {:bulletin => @bulletin})) %>");
var start_modal_with_id = "bulletin-<%=@bulletin.id%>"

View File

@ -0,0 +1,49 @@
<ul>
<li>
<b><%= t(:category) %></b>
<%= @bulletin.category.title rescue nil %>
</li>
<li>
<b><%= t(:postdate) %></b>
<%= display_date_time(@bulletin.postdate) %>
</li>
<li>
<b><%= t(:title) %></b>
<%= @bulletin.title %>
</li>
<li>
<%#= image_tag(@bulletin.image.url, :size => "320x240") if @bulletin.image.file %>
<%= link_to image_tag(@bulletin.image.url, :size => "320x240"), @bulletin.image.url, {:target => '_blank', :title => @bulletin.image_identifier} if @bulletin.image.file %>
</li>
<li>
<b><%= t(:subtitle) %></b>
<%= @bulletin.subtitle.html_safe rescue '' %>
</li>
<li>
<b><%= t(:text) %></b>
<%= @bulletin.text.html_safe rescue '' %>
</li>
<li>
<li>
<b><%= t(:link) %></b>
<% @bulletin.bulletin_links.each do | blink | %>
<%= link_to blink.title, blink.url, :target => '_blank' %>
<% end %>
</li>
<li>
<b><%= t(:file) %></b>
<% @bulletin.bulletin_files.each do | bfile | %>
<%= link_to bfile.title, bfile.file.url, {:target => '_blank', :title => bfile.description} if bfile.file.file %>
<% end %>
</li>
<li>
<b><%= t(:posted_by) %></b>
<%= User.find(@bulletin.create_user_id).name %>
</li>
<li>
<b><%= t(:last_modified) %></b>
<%= display_date(@bulletin.updated_at) %>
</li>
<%= link_back %>

View File

@ -0,0 +1,3 @@
$("#enable_<%= @bulletin.id %>").toggle();
$("#disable_<%= @bulletin.id %>").toggle();
$("#bulletin_<%= @bulletin.id %>").toggleClass('disable');

View File

@ -0,0 +1,25 @@
<%= content_tag :div ,:id => "users_checkbox_ary",:class => 'clear' do -%>
<% sys_users = User.all.not_guest_user -%>
<% sys_users.each do |user| -%>
<div class="checkblock">
<% user.sub_roles.each do |sr| %>
<div class="for_unit" style="display:none;"> <%= sr.key %></div>
<% end %>
<%= content_tag :div,:data=>{'original-title'=>t('announcement.bulletin.fact_check_setting_window_title'),:content => "#{user.sub_roles.collect{|sr| sr.key}.join(',')}"},:class=>"checkbox clear" do %>
<div class="check-icon">
</div>
<div class='member-avatar'>
<% if user.avatar? %>
<%= image_tag(user.avatar.thumb.url,:class => "member-img") %>
<% else %>
<%= image_tag "person.png",:class => "member-img" %>
<% end %>
</div>
<%= label_tag "lab-user-#{user.id}", (user.name rescue ''),:class=>"member-name",:id=>nil -%>
<%= check_box_tag "[users][#{user.id}]", 'true',users.include?(user),:class => "check" -%>
<%end -%>
</div>
<% end -%>
<% end -%>

View File

@ -0,0 +1,34 @@
<% # encoding: utf-8 %>
<%= flash_messages %>
<h1 class="h1"><%= @page.title rescue nil %></h1>
<table class="table table-bordered">
<tr>
<%= content_tag (:th) do %>
<%= t('announcement.bulletin.category') %>
<% end if (!params[:search_query].blank? or params[:category_id].blank?)-%>
<th><%= t('announcement.bulletin.title') %></th>
<th><%= t('announcement.bulletin.postdate') %></th>
</tr>
<% if !params[:name].blank?%>
<%= t("search.unit_get",:unit_name => params[:name],:item_num=>@bulletins.count) %>
<% end %>
<%= render :partial => 'shared/search_header',:locals=>{:items=>@bulletins} %>
<% @bulletins.each do |post| %>
<tr>
<td><%= post.category.title rescue nil %></td>
<td><%= link_to post.title, panel_announcement_front_end_bulletin_path(post, :category_id => post.category_id) %>
<%#= link_to post.title, panel_announcement_back_end_bulletin_path(post) %>
</td>
<td><%= display_date_time(post.postdate) %></td>
</tr>
<% end %>
</table>
<%= paginate( @bulletins, :param_name => :page_main, :params => {:inner => 'false'} ) rescue nil%>

View File

@ -0,0 +1,22 @@
xml.instruct! :xml, :version => "1.0"
xml.rss :version => "2.0" do
xml.channel do
if @current_category
xml.title @current_category.title_translations[I18n.locale.to_s]
else
xml.title t('announcement.announcement')
end
xml.link url_for(:action=>"index", :controller=>"panel/announcement/front_end/bulletins",:format=> :rss,:only_path=>false,:inner=>true)
for bulletin in @bulletins
xml.item do
xml.title bulletin.title_translations[I18n.locale.to_s]
xml.pubDate bulletin.postdate.to_s(:rfc822)
xml.description bulletin.text_translations[I18n.locale.to_s]
xml.link url_for(:action=>"show", :controller=>"panel/announcement/front_end/bulletins", :id=>bulletin ,:only_path=>false)
xml.guid url_for(:action=>"show", :controller=>"panel/announcement/front_end/bulletins", :id=>bulletin ,:only_path=>false)
xml.fb_share generate_fb_url(bulletin, "announcement")
end
end
end
end

View File

@ -0,0 +1,34 @@
<% # encoding: utf-8 %>
<%= flash_messages %>
<h1 class="h1"><%= @page.title rescue nil %></h1>
<table class="table table-bordered">
<tr>
<%= content_tag (:th) do %>
<%= t('announcement.bulletin.category') %>
<% end if (!params[:search_query].blank? or params[:category_id].blank?)-%>
<th><%= t('announcement.bulletin.title') %></th>
<th><%= t('announcement.bulletin.postdate') %></th>
</tr>
<% if !params[:name].blank?%>
<%= t("search.unit_get",:unit_name => params[:name],:item_num=>@bulletins.count) %>
<% end %>
<%= render :partial => 'shared/search_header',:locals=>{:items=>@bulletins} %>
<% @bulletins.each do |post| %>
<tr>
<td><%= post.category.title rescue nil %></td>
<td><%= link_to post.title, panel_announcement_front_end_bulletin_path(post, :category_id => post.category_id) %>
<%#= link_to post.title, panel_announcement_back_end_bulletin_path(post) %>
</td>
<td><%= display_date_time(post.postdate) %></td>
</tr>
<% end %>
</table>

View File

@ -0,0 +1,41 @@
<% # encoding: utf-8 %>
<h1 class="h1"><%= @bulletin.title %></h1>
<div class="info">
<div class="info1">
<span class="pull-right"><%= dislpay_view_count(@bulletin) %></span>
<span class="date"><%= display_date_time(@bulletin.postdate) %></span>
<% unit = @bulletin.cache_dept[I18n.locale.to_s] rescue nil %>
<span><%= link_to unit,panel_announcement_front_end_index_bulletins_by_unit_path(:name=>unit) unless unit.blank? %></span>
</div>
</div>
<div class="news_image">
<%#= image_tag(@bulletin.image.url, :size => "320x240") if @bulletin.image.file %>
<%= link_to image_tag(@bulletin.image.url, :size => "320x240"), @bulletin.image.url, {:target => '_blank', :title => @bulletin.image_identifier} if @bulletin.image.file %>
</div>
<div class="news_paragraph">
<%= @bulletin.text.html_safe rescue '' %>
</div>
<div class="linkAndFile">
<% if @bulletin.bulletin_links.size > 0 %>
<div>
<i class="icons-link"></i>
<div class="showLink">
<% @bulletin.bulletin_links.each do | blink | %>
<%= link_to blink.title, blink.url, :target => '_blank' %>
<% end %>
</div>
</div>
<% end %>
<% if @bulletin.bulletin_files.size > 0 %>
<div>
<i class="icons-paperclip"></i>
<div class="showFile">
<% @bulletin.bulletin_files.each do | bfile | %>
<%= link_to bfile.title, bfile.file.url, {:target => '_blank', :title => bfile.description} if bfile.file.file %>
<% end %>
</div>
</div>
<% end %>
</div>
<%= share_links(@bulletin, 'announcement') %>

View File

@ -0,0 +1,19 @@
xml.instruct! :xml, :version => "1.0"
xml.rss :version => "2.0" do
xml.channel do
if @current_category
xml.title @current_category.title_translations[I18n.locale.to_s]
else
xml.title t('announcement.announcement')
end
xml.link url_for(:action=>"index", :controller=>"panel/announcement/front_end/bulletins",:format=> :rss,:only_path=>false,:inner=>true)
xml.item do
xml.title @bulletin.title_translations[I18n.locale.to_s]
xml.description @bulletin.text_translations[I18n.locale.to_s]
xml.pubDate @bulletin.postdate.to_s(:rfc822)
xml.link url_for(:action=>"show", :controller=>"panel/announcement/front_end/bulletins", :id=>@bulletin ,:format=> :rss,:only_path=>false,:inner=>true)
xml.guid url_for(:action=>"show", :controller=>"panel/announcement/front_end/bulletins", :id=>@bulletin ,:only_path=>false)
end
# end
end
end

View File

@ -0,0 +1,53 @@
<%
if @user
@bulletins = Bulletin.where(:create_user_id => @user.id).page(params[:page]).per(10)
else
@bulletins = Bulletin.all.page(params[:page]).per(10)
end
%>
<table class="table main-list">
<thead>
<tr>
<th class="span1"><%= t('category') %></th>
<th class="span3"><%= t('title') %></th>
<th class="span1"><%= t('start_date') %></th>
<th class="span1"><%= t('end_date') %></th>
<th class="span1"><%= t('tags') %></th>
<% if not @user%>
<th class="span1"><%= t('last_modified') %></th>
<% end %>
</tr>
</thead>
<tbody id="tbody_bulletin" class="sort-holder">
<% @bulletins.each do |bulletin| %>
<tr id="<%= dom_id bulletin%>" class="with_action">
<td><%= bulletin.category.title%></td>
<td>
<% if bulletin.is_checked? %>
<%= link_to bulletin.title, panel_announcement_front_end_bulletin_path(bulletin, :category_id => bulletin.category.id) rescue ''%>
<% else %>
<%= bulletin.title%>
<% end %>
</td>
<td><%= display_date_time(bulletin.postdate) %></td>
<% if not bulletin.deadline.nil?%>
<td><%= display_date_time(bulletin.deadline) %></td>
<%else%>
<td><%= t('no_deadline') %></td>
<% end %>
<td>
<div class="label-group">
<% bulletin.sorted_tags.each do |tag| %>
<span class="label label-tags"><%= tag.name %></span>
<% end %>
</div>
</td>
<% if not @user%>
<td><%= User.find(bulletin.create_user_id).name %></td>
<% end %>
</tr>
<% end %>
</tbody>
</table>

View File

@ -0,0 +1,10 @@
<% @bulletins.each do |bulletin| %>
<li>
<%= link_to bulletin.title, panel_announcement_front_end_bulletin_path(bulletin, :category_id => bulletin.category_id, :part_id => params[:part_id] , :tag_id => @selected_tag.id ) %>
</li>
<% end %>
<div class='pagination'>
<%= link_to_previous_page @bulletins, 'Previous Page', :params => {:controller => 'widget/bulletins', :action => 'reload_bulletins', :part_id => params[:part_id], :tag_id => [@selected_tag.id]}, :remote => true, :class => 'previous' %>
<%= link_to_next_page @bulletins, 'Next Page', :params => {:controller => 'widget/bulletins', :action => 'reload_bulletins', :part_id => params[:part_id], :tag_id => [@selected_tag.id]}, :remote => true, :class => 'next' %>
</div>

View File

@ -0,0 +1,252 @@
<% # encoding: utf-8 %>
<% if @title %>
<h2 class="h2"><%= @title %></h2>
<% end %>
<% if !@widget_fields.blank? %>
<% if @widget_style == '1' %>
<div class="default_widget_typeA">
<table class="default_widget_tb" border="0" cellpadding="0" cellspacing="0" >
<thead>
<tr>
<% @widget_fields.each do |wf| %>
<th><span class="<%= wf[1] %>"><%= t("announcement.default_widget.#{wf[0]}") if !wf[0].blank? %></span></th>
<% end %>
</tr>
</thead>
<% @posts.each do |post| %>
<tr class="<%= cycle('odd', '')%>">
<% @widget_fields.each do |wf| %>
<td>
<span class="<%= wf[1] %>">
<% if wf[1] == 'title' %>
<%= link_to post.send("#{wf[0]}"), panel_announcement_front_end_bulletin_path(post, :category_id => post.send("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]}").title rescue nil %>
<% elsif wf[1] == 'img' %>
<div class="img 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]}").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] == 'poster' %>
<%= User.from_id(post.update_user_id).name rescue ''%>
<% end %>
</span>
</td>
<% end %>
</tr>
<% end %>
</table>
<div class="more"><%= link_to t('announcement.more'), panel_announcement_front_end_bulletins_path() %></div>
</div>
<% elsif @widget_style == '2' %>
<div class="default_widget_list">
<ul class="newslist">
<% @posts.each do |post| %>
<li class="<%= cycle('odd', '')%>">
<div class="img app-pic" style="width:50px; height:50px;"><%= 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]}"), panel_announcement_front_end_bulletin_path(post, :category_id => post.send("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]}").title rescue nil %>
<% elsif wf[1] == 'text' %>
<%#= post.send("#{wf[0]}[#{I18n.locale}]").html_safe %>
<%= post.send("#{wf[0]}").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] == 'poster' %>
<%= 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">
<% @bulletins.each do |post| %>
<li class="<%= cycle('odd', '')%>">
<div class="img 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]}"), 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]}").title rescue nil %>
<% elsif wf[1] == 'text' %>
<%#= post.send("#{wf[0]}[#{I18n.locale}]").html_safe %>
<%= post.send("#{wf[0]}").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] == 'poster' %>
<%= 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 == '4' %>
<div class="news news4">
<ul class="newslist">
<% @bulletins.each do |post| %>
<li class="<%= cycle('odd', '')%>">
<div class="img 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]}"), 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]}").title rescue nil %>
<% elsif wf[1] == 'text' %>
<%#= post.send("#{wf[0]}[#{I18n.locale}]").html_safe %>
<%= post.send("#{wf[0]}").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] == 'poster' %>
<%= 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]}"), 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]}").title rescue nil %>
<% elsif wf[1] == 'text' %>
<%#= post.send("#{wf[0]}[#{I18n.locale}]").html_safe %>
<%= post.send("#{wf[0]}").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] == 'poster' %>
<%= 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 %>

View File

@ -0,0 +1,3 @@
<li>
<%= link_to tag.name, panel_announcement_widget_bulletins_and_web_links_path(:inner=>true, :id => [tag.id], :part_id=>params[:part_id]), :remote => true, :class => ('active' if tag.eql?(@selected_tag)) %>
</li>

View File

@ -0,0 +1,10 @@
<% @web_links.each do |web_link| %>
<li>
<%= link_to web_link.title, web_link.url %>
</li>
<% end %>
<div class='pagination'>
<%= link_to_previous_page @web_links, 'Previous Page', :params => {:controller => 'widget/bulletins', :action => 'reload_web_links', :part_id => params[:part_id], :tag_id => @selected_tag.id}, :remote => true, :class => 'previous' %>
<%= link_to_next_page @web_links, 'Next Page', :params => {:controller => 'widget/bulletins', :action => 'reload_web_links', :part_id => params[:part_id], :tag_id => @selected_tag.id}, :remote => true, :class => 'next' %>
</div>

View File

@ -0,0 +1,35 @@
<div class="mega_tab_block">
<div class="tag_block">
<ul id='bulletins_web_links_tags' class="tag_list">
<%= render :partial => 'tag', :collection => @tags %>
</ul>
</div>
<div class="news_block">
<h3 class="news_title2">
<%#= link_to t("announcement.bulletins"), panel_announcement_front_end_bulletins_path, :class => 'more' %>
<%= link_to @title, panel_announcement_front_end_bulletins_path, :class => 'more' %>
</h3>
<ul id='bulletins_web_links_bulletins' class="news_list">
<%= render 'bulletins' if @bulletins %>
</ul>
</div>
<% if @part.widget_style == 'bulletins_and_links' %>
<div class="links_block">
<h3 class="links_title"><%= t(:related_links) %></h3>
<ul id='bulletins_web_links_web_links' class="links_list">
<%= render 'web_links' if @web_links %>
</ul>
</div>
<% end %>
</div>
<% content_for :page_specific_javascript do %>
<% end %>
<%#= stylesheet_link_tag "announcement/bulletins_and_web_links" %>

View File

@ -0,0 +1,3 @@
$('#bulletins_web_links_tags').html("<%= j render :partial => 'tag', :collection => @tags %>")
$('#bulletins_web_links_bulletins').html("<%= j render 'bulletins' if @bulletins %>")
$('#bulletins_web_links_web_links').html("<%= j render 'web_links' if @web_links %>")

View File

@ -0,0 +1,31 @@
<% # encoding: utf-8 %>
<% if @bulletins and !@bulletins.nil? %>
<div class="tag_block">
<ul class="tag_list">
<% @tags.each do |tag| %>
<li><%= tag.name %></li>
<% end %>
</ul>
</div>
<% @tags.each_with_index do |tag, index| %>
<div id="news_<%= index %>" class="news_block">
<h3 class="news_title2"><%= t("announcement.bulletins") %></h3>
<div class="news_prev">prev</div>
<div class="news_next">next</div>
<ul class="news_list">
<% Bulletin.where(:tagged_ids => tag).each do |post| %>
<li><%= link_to post.title, panel_announcement_front_end_bulletin_path(post) %></li>
<% end %>
</ul>
</div>
<% end %>
<% end %>

View File

@ -0,0 +1,9 @@
<p>Search</p>
<%= form_tag panel_announcement_front_end_search_result_path, method: :get do %>
<%= hidden_field_tag :category_id, params[:category_id] %>
<%= hidden_field_tag :tag_id, params[:tag_id] %>
<p>
<%= text_field_tag :search_query, params[:search_query],{:value => (params[:search_query].blank?? '' : params[:search_query]),:placeholder => t("announcement.search") }%>
<%= submit_tag t("search_"), name: nil %>
</p>
<% end %>

View File

@ -0,0 +1,23 @@
<!-- <div class="search"> <input type="text" onfocus="this.value='';this.searchClickFlag=true;" onblur="if(this.value==''){this.value='公告搜尋';this.searchClickFlag=false;}" value="公告搜尋" id="q" class="search_key" name="q"/> <input type="submit" name="sa" id="sa" class="sa" value="." /> </div> -->
<div class="category_list">
<h3 class="h3"><%= t(:categories) %></h3>
<ul class="list">
<% @categories.each do |category| %>
<li class="<%= category.id.to_s.eql?(params[:category_id]) ? 'active' : nil %>">
<%= link_to category.title, panel_announcement_front_end_bulletins_path(:category_id => category.id) %>
</li>
<% end %>
</ul>
</div>
<div class="tag_cloud">
<h3 class="h3"><%= t(:tag_cloud) %></h3>
<div class="cloud">
<% @tags_and_class.each do |tag| %>
<%= link_to tag[0][I18n.locale], panel_announcement_front_end_bulletins_path(:tag_id => tag[0].id, :category_id => params[:category_id]), :class => "#{tag[1]} #{(tag[0].id.to_s.eql?(params[:tag_id]) || tag[0].key.eql?(params[:tag_id])) ? 'active' : nil} " %>
<% end %>
</div>
</div>
<!-- <div class="clear"></div> -->
<!-- <div class="rss_feed">
<a href="" class="rssimg"> Rss feed </a>
</div> -->

View File

@ -0,0 +1,7 @@
<%= stylesheet_link_tag "default_widget" %>
<%= javascript_include_tag "mobile/jquery.mu.image.resize.js" %>
<!-- <script type='text/javascript' src='/assets/lib/jquery.mu.image.resize.degsin.js'></script> -->
<div id="default_widget_typeA">
<%= render 'index' %>
</div>

View File

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

View File

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

View File

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

38
config/locales/en.yml Normal file
View File

@ -0,0 +1,38 @@
en:
announcement:
add_new: Add New
all_articles: All Articles
announcement: Announcement
approval_setting: Approval Setting
approve_bulletin_fail: Approval Fail
approve_bulletin_success: Approve Successfully
bulletins: Bulletins
categories: Categories
create_bulletin_success: Create Bulletin Successfully
create_bulletin_category_success: Create Category Successfully
date: Announcement Date
default_widget:
bulletin_category_with_title: Bulletin Category with Title
postdate: Post Date
subtitle: Subtitle
title: Title
editing_announcement: Edit Announcement
editing_announcement_category: Edit Category
file: Attachment
file_description: File Description
file_name: File Name
frontend:
bulletins: Announcement front-end
search_result: Search result
link_name: Link Name
new_bulletin_category: New Bulletin Category
picture: Cover Picture
search: Search
selected_file: Select File
update_bulletin_category_success: Update Category Successfully
url: URL
widget:
bulletins_and_web_links: Differential Nav.
index: Index
search: Search

41
config/locales/zh_tw.yml Normal file
View File

@ -0,0 +1,41 @@
zh_tw:
announcement:
add_new: 新建
all_articles: 文章列表
announcement: 公告
approval_setting: 審核設定
approve_bulletin_fail: 審核失敗
approve_bulletin_success: 審核成功
bulletins: 公告
categories: 類別
create_bulletin_success: 建立公告成功
create_bulletin_category_success: 建立類別成功
date: 起迄日期
default_widget:
bulletin_category_with_title: 公告類別及標題
postdate: 張貼日期
subtitle: 副標題
title: 標題
editing_announcement: 編輯類別
editing_announcement_category: 編輯類別
error:
no_avilb_cate_for_posting: 沒有可以張貼的類別
file: 附加檔案
file_description: 檔案描述
file_name: 檔案名稱
frontend:
bulletins: 公告前台
search_result: 搜尋結果頁
link_name: 連結名稱
new_bulletin_category: 新增公告類別
picture: 刊頭圖片
search: 搜尋
selected_file: 選擇檔案
update_bulletin_category_success: 更新類別成功
url: 連結位置
widget:
bulletins_and_web_links: 分眾頁籤
index: 索引
search: 搜尋
more: 更多+

46
config/routes.rb Normal file
View File

@ -0,0 +1,46 @@
Rails.application.routes.draw do
namespace :panel do
namespace :announcement do
namespace :back_end do
match 'public' => "announcements#public",:as => :public
match 'approval_setting' => "approvals#setting" ,:as => :approval_setting,:via => :get
match 'approval_setting' => "approvals#update_setting" ,:as => :approval_setting,:via => :post
match 'approval_setting' => "approvals#user_list" ,:as => :approval_user_list,:via => :put
resources :bulletins do
match "approve/:bulletin_id" => "approvals#preview_and_approve",:as => :approval_preview,:via => :put
match "approve/:bulletin_id" => "approvals#approve",:as => :approve,:via => :post
member do
get 'load_quick_edit'
end
collection do
post "preview"
put "preview"
get 'delete'
end
end
resources :bulletin_links
resources :bulletin_files
end
namespace :front_end do
match "index_by_unit" => "bulletins#index_bulletins_by_unit",:as => :index_bulletins_by_unit
match "search_result" => "bulletins#search_result"
resources :bulletins # do
# match "preview" => "bulletins#preview_content",:as => :get_preview_content
# end
end
namespace :widget do
match "index" => "bulletins#index"
match "bulletins_and_web_links" => "bulletins#bulletins_and_web_links"
match "reload_bulletins" => "bulletins#reload_bulletins"
match "reload_web_links" => "bulletins#reload_web_links"
match "bulletins_side_bar" => "bulletins#bulletins_side_bar"
match "bulletins_search_block" => "bulletins#bulletins_search_block"
end
end
end
end

100
lib/announcement.rb Normal file
View File

@ -0,0 +1,100 @@
module Announcement
class Engine < Rails::Engine
initializer "announcement" do
OrbitApp.registration "Announcement",:type=> 'ModuleApp' do
module_label 'announcement.announcement'
base_url File.expand_path File.dirname(__FILE__)
# personal_plugin :enable => true,:path=>"panel/announcement/plugin/profile",:i18n=>'announcement.announcement'
version "0.1"
organization "Rulingcom"
author "RD dep"
intro "I am intro"
update_info 'some update_info'
front_end do
app_page 'search_result' do
frontend_i18n "announcement.frontend.search_result"
end
app_page 'bulletins' do
frontend_i18n "announcement.frontend.bulletins"
style ["1","2","3"]
end
end
# category ["BulletinCategory"]
data_count 1..10
authorizable
# approvable
categorizable
taggable
widgets do
default_widget do
query 'Bulletin'
enable ["typeA", "typeB_style3", "typeC"]
image :image
field :postdate
link_field :title,{:method => 'panel_announcement_front_end_bulletin_path',:args=>:self}
link_field :bulletin_category_with_title,{:method => 'panel_announcement_front_end_bulletins_path',:args=>{:category_id => [:category,:id]}}
field :subtitle
link_to_more 'panel_announcement_front_end_bulletins_path',:title_i18n=> 'more_plus'
end
categories_query 'Category.all'
tags_query 'AnnouncementTag.all'
# customize_widget "index" do
# widget_i18n "announcement.widget.index"
# style ["1","2"]
# end
customize_widget "bulletins_search_block" do
widget_i18n "announcement.widget.search"
end
customize_widget "bulletins_and_web_links" do
widget_i18n "announcement.widget.bulletins_and_web_links"
style ["bulletins_and_links","bulletins_only"]
end
# item "index","announcement.widget.index",:default_template=>true,:fields=>["title","category","postdate"]
# item "bulletins_and_web_links","announcement.widget.bulletins_and_web_links"
end
side_bar do
head_label_i18n 'announcement.announcement',:icon_class=>"icons-megaphone"
available_for [:admin,:guest,:manager,:sub_manager]
active_for_controllers ({:private=>['bulletins', 'bulletin_categorys', 'approvals','module_tags', 'categories']})
active_for_object_auth ['BulletinCategory']
head_link_path "panel_announcement_back_end_bulletins_path"
context_link 'announcement.all_articles',
:link_path=>"panel_announcement_back_end_bulletins_path" ,
:priority=>1,
:active_for_action=>{:bulletins=>:index},
:available_for => [:all]
context_link 'announcement.add_new',
:link_path=>"new_panel_announcement_back_end_bulletin_path" ,
:priority=>2,
:active_for_action=>{:bulletins=>:new},
:available_for => [:sub_manager]
context_link 'announcement.categories',
:link_path=>"admin_module_app_categories_path(get_module_app)" ,
:priority=>3,
:active_for_category => 'Announcement',
:available_for => [:manager]
context_link 'tags',
:link_path=>"admin_module_tags_path(module_app_id: get_module_app)" ,
:priority=>4,
:active_for_tag => 'Announcement',
:available_for => [:manager]
end
end
end
end
end

View File

@ -0,0 +1,3 @@
module Announcement
VERSION = "0.0.1"
end

1485
lib/nccu_ann20120918.csv Normal file

File diff suppressed because one or more lines are too long

6
script/rails Normal file
View File

@ -0,0 +1,6 @@
#!/usr/bin/env ruby.exe
#!/usr/bin/env ruby
# This command will automatically be run when you run "rails" with Rails 3 gems installed from the root of your application.
ENGINE_PATH = File.expand_path('../..', __FILE__)
load File.expand_path('../../test/dummy/script/rails', __FILE__)