First version of new preview. Only plain text
This commit is contained in:
parent
ecb3b5b25c
commit
671f86b612
4
Gemfile
4
Gemfile
|
@ -24,6 +24,10 @@ gem 'mongoid-tree', :require => 'mongoid/tree'
|
||||||
gem "mongo_session_store-rails3"
|
gem "mongo_session_store-rails3"
|
||||||
gem 'mysql2'
|
gem 'mysql2'
|
||||||
gem 'nokogiri'
|
gem 'nokogiri'
|
||||||
|
|
||||||
|
gem 'pry', :group => :development
|
||||||
|
gem 'pry-debugger', :group => :development
|
||||||
|
|
||||||
gem 'radius'
|
gem 'radius'
|
||||||
gem 'rake'
|
gem 'rake'
|
||||||
# gem 'remotipart'
|
# gem 'remotipart'
|
||||||
|
|
25
Gemfile.lock
25
Gemfile.lock
|
@ -69,6 +69,7 @@ GEM
|
||||||
mongoid (~> 2.1)
|
mongoid (~> 2.1)
|
||||||
chinese_pinyin (0.4.1)
|
chinese_pinyin (0.4.1)
|
||||||
chronic (0.6.7)
|
chronic (0.6.7)
|
||||||
|
coderay (1.0.7)
|
||||||
coffee-rails (3.1.1)
|
coffee-rails (3.1.1)
|
||||||
coffee-script (>= 2.2.0)
|
coffee-script (>= 2.2.0)
|
||||||
railties (~> 3.1.0)
|
railties (~> 3.1.0)
|
||||||
|
@ -79,6 +80,13 @@ GEM
|
||||||
color (1.4.1)
|
color (1.4.1)
|
||||||
columnize (0.3.6)
|
columnize (0.3.6)
|
||||||
database_cleaner (0.7.1)
|
database_cleaner (0.7.1)
|
||||||
|
debugger (1.1.4)
|
||||||
|
columnize (>= 0.3.1)
|
||||||
|
debugger-linecache (~> 1.1.1)
|
||||||
|
debugger-ruby_core_source (~> 1.1.3)
|
||||||
|
debugger-linecache (1.1.2)
|
||||||
|
debugger-ruby_core_source (>= 1.1.1)
|
||||||
|
debugger-ruby_core_source (1.1.3)
|
||||||
delorean (1.2.0)
|
delorean (1.2.0)
|
||||||
chronic
|
chronic
|
||||||
devise (1.5.3)
|
devise (1.5.3)
|
||||||
|
@ -118,6 +126,7 @@ GEM
|
||||||
i18n (>= 0.4.0)
|
i18n (>= 0.4.0)
|
||||||
mime-types (~> 1.16)
|
mime-types (~> 1.16)
|
||||||
treetop (~> 1.4.8)
|
treetop (~> 1.4.8)
|
||||||
|
method_source (0.8)
|
||||||
mime-types (1.17.2)
|
mime-types (1.17.2)
|
||||||
mini_magick (3.4)
|
mini_magick (3.4)
|
||||||
subexec (~> 0.2.1)
|
subexec (~> 0.2.1)
|
||||||
|
@ -149,6 +158,18 @@ GEM
|
||||||
progress_bar (0.4.0)
|
progress_bar (0.4.0)
|
||||||
highline (~> 1.6.1)
|
highline (~> 1.6.1)
|
||||||
options (~> 2.3.0)
|
options (~> 2.3.0)
|
||||||
|
pry (0.9.10)
|
||||||
|
coderay (~> 1.0.5)
|
||||||
|
method_source (~> 0.8)
|
||||||
|
slop (~> 3.3.1)
|
||||||
|
pry (0.9.10-x86-mingw32)
|
||||||
|
coderay (~> 1.0.5)
|
||||||
|
method_source (~> 0.8)
|
||||||
|
slop (~> 3.3.1)
|
||||||
|
win32console (~> 1.3)
|
||||||
|
pry-debugger (0.2.0)
|
||||||
|
debugger (~> 1.1.3)
|
||||||
|
pry (~> 0.9.9)
|
||||||
rack (1.3.6)
|
rack (1.3.6)
|
||||||
rack-cache (1.2)
|
rack-cache (1.2)
|
||||||
rack (>= 0.4)
|
rack (>= 0.4)
|
||||||
|
@ -250,6 +271,7 @@ GEM
|
||||||
rack (~> 1.3, >= 1.3.6)
|
rack (~> 1.3, >= 1.3.6)
|
||||||
rack-protection (~> 1.2)
|
rack-protection (~> 1.2)
|
||||||
tilt (~> 1.3, >= 1.3.3)
|
tilt (~> 1.3, >= 1.3.3)
|
||||||
|
slop (3.3.2)
|
||||||
social-share-button (0.0.6)
|
social-share-button (0.0.6)
|
||||||
spork (0.9.0)
|
spork (0.9.0)
|
||||||
spork (0.9.0-x86-mingw32)
|
spork (0.9.0-x86-mingw32)
|
||||||
|
@ -291,6 +313,7 @@ GEM
|
||||||
win32-api (1.4.8-x86-mingw32)
|
win32-api (1.4.8-x86-mingw32)
|
||||||
win32-process (0.6.5)
|
win32-process (0.6.5)
|
||||||
windows-pr (>= 1.1.2)
|
windows-pr (>= 1.1.2)
|
||||||
|
win32console (1.3.2-x86-mingw32)
|
||||||
windows-api (0.4.1)
|
windows-api (0.4.1)
|
||||||
win32-api (>= 1.4.5)
|
win32-api (>= 1.4.5)
|
||||||
windows-pr (1.2.1)
|
windows-pr (1.2.1)
|
||||||
|
@ -326,6 +349,8 @@ DEPENDENCIES
|
||||||
net-ldap (~> 0.3.1)
|
net-ldap (~> 0.3.1)
|
||||||
nokogiri
|
nokogiri
|
||||||
progress_bar
|
progress_bar
|
||||||
|
pry
|
||||||
|
pry-debugger
|
||||||
radius
|
radius
|
||||||
rails (>= 3.1.0, < 3.2.0)
|
rails (>= 3.1.0, < 3.2.0)
|
||||||
rake
|
rake
|
||||||
|
|
|
@ -17,7 +17,7 @@ class SessionsController < Devise::SessionsController
|
||||||
if ($nccu_ldap_connection.bind rescue false)
|
if ($nccu_ldap_connection.bind rescue false)
|
||||||
logger.info "=LDAP Binded password ok..."
|
logger.info "=LDAP Binded password ok..."
|
||||||
result =check_auth_with_ldap(login_uid,login_password)
|
result =check_auth_with_ldap(login_uid,login_password)
|
||||||
if result && login_password!=''
|
if result #&& login_password!=''
|
||||||
logger.info "==LDAP password passed..."
|
logger.info "==LDAP password passed..."
|
||||||
nccu_id = get_nccu_id_from_mid_site(login_uid)
|
nccu_id = get_nccu_id_from_mid_site(login_uid)
|
||||||
resource = nccu_id.nil? ? nil : (User.first(conditions:{ nccu_ldap_uid: nccu_id }))
|
resource = nccu_id.nil? ? nil : (User.first(conditions:{ nccu_ldap_uid: nccu_id }))
|
||||||
|
|
|
@ -0,0 +1,25 @@
|
||||||
|
class Preview
|
||||||
|
include Mongoid::Document
|
||||||
|
include Mongoid::Timestamps
|
||||||
|
|
||||||
|
field :object, :type => Hash
|
||||||
|
field :preview_at_link
|
||||||
|
field :expired_at , :type => DateTime
|
||||||
|
field :link_args, :type => Array
|
||||||
|
field :object_class_type
|
||||||
|
|
||||||
|
def get_arg_hash
|
||||||
|
object.slice(*link_args).inject({}){|la,(k,v)| la[k.to_sym] = v; la}
|
||||||
|
end
|
||||||
|
|
||||||
|
def get_preview_link
|
||||||
|
ap = Rails.application.routes.url_helpers
|
||||||
|
ap.send preview_at_link,({:id=>id,:preview=>true}.merge get_arg_hash)
|
||||||
|
#func = eval("Rails.application.routes.url_helpers.#{preview_at_link}").send
|
||||||
|
end
|
||||||
|
|
||||||
|
def get_virtual_object
|
||||||
|
eval(self.object_class_type).new object
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
|
@ -1,4 +1,17 @@
|
||||||
module OrbitCoreLib
|
module OrbitCoreLib
|
||||||
|
module Preview
|
||||||
|
def self.included(base)
|
||||||
|
base.instance_eval("field :is_preview,type: Boolean,:default => false")
|
||||||
|
base.instance_eval("scope :not_preview,where(:is_preview=>false)")
|
||||||
|
base.define_singleton_method :new_preview do |*args|
|
||||||
|
temp_obj = self.new(args.first)
|
||||||
|
temp_obj.is_preview = true
|
||||||
|
temp_obj.save(:validate => false) rescue
|
||||||
|
temp_obj
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
module BelongsToCategoryMayDisable
|
module BelongsToCategoryMayDisable
|
||||||
def self.included(base)
|
def self.included(base)
|
||||||
base.instance_eval("belongs_to :#{base::BelongsToCategory.to_s}")
|
base.instance_eval("belongs_to :#{base::BelongsToCategory.to_s}")
|
||||||
|
|
|
@ -0,0 +1,6 @@
|
||||||
|
# Read about factories at https://github.com/thoughtbot/factory_girl
|
||||||
|
|
||||||
|
FactoryGirl.define do
|
||||||
|
factory :preview do
|
||||||
|
end
|
||||||
|
end
|
|
@ -0,0 +1,5 @@
|
||||||
|
require 'spec_helper'
|
||||||
|
|
||||||
|
describe Preview do
|
||||||
|
pending "add some examples to (or delete) #{__FILE__}"
|
||||||
|
end
|
|
@ -11,6 +11,14 @@ class Panel::Announcement::BackEnd::BulletinsController < OrbitBackendController
|
||||||
# before_filter :for_admin_only,:only => [:]
|
# before_filter :for_admin_only,:only => [:]
|
||||||
# before_filter :for_app_manager,:only => [:index,:show,]
|
# before_filter :for_app_manager,:only => [:index,:show,]
|
||||||
before_filter :for_app_sub_manager,:except => [:index,:show,:get_sorted_and_filtered_bulletins]
|
before_filter :for_app_sub_manager,:except => [:index,:show,:get_sorted_and_filtered_bulletins]
|
||||||
|
|
||||||
|
def preview
|
||||||
|
debugger
|
||||||
|
a=1
|
||||||
|
|
||||||
|
@bulletin = Bulletin.new_preview(params[:bulletin])
|
||||||
|
end
|
||||||
|
|
||||||
def index
|
def index
|
||||||
# @bulletins = Bulletin.all
|
# @bulletins = Bulletin.all
|
||||||
# @bulletins = Bulletin.desc("postdate desc")
|
# @bulletins = Bulletin.desc("postdate desc")
|
||||||
|
|
|
@ -9,11 +9,7 @@ class Bulletin
|
||||||
|
|
||||||
BelongsToCategory = :bulletin_category
|
BelongsToCategory = :bulletin_category
|
||||||
include OrbitCoreLib::BelongsToCategoryMayDisable
|
include OrbitCoreLib::BelongsToCategoryMayDisable
|
||||||
|
include OrbitCoreLib::Preview
|
||||||
# include NccuSearch
|
|
||||||
|
|
||||||
#scope :searchable,where(:is_checked=>true,:is_hidden=>false,:is_pending=>false)
|
|
||||||
|
|
||||||
is_impressionable :counter_cache => { :column_name => :view_count }
|
is_impressionable :counter_cache => { :column_name => :view_count }
|
||||||
|
|
||||||
field :title, localize: true
|
field :title, localize: true
|
||||||
|
@ -36,7 +32,6 @@ class Bulletin
|
||||||
field :is_checked, :type => Boolean, :default => false
|
field :is_checked, :type => Boolean, :default => false
|
||||||
field :is_pending, :type => Boolean, :default => true
|
field :is_pending, :type => Boolean, :default => true
|
||||||
field :is_rejected, :type => Boolean, :default => false
|
field :is_rejected, :type => Boolean, :default => false
|
||||||
|
|
||||||
field :view_count, :type => Integer, :default => 0
|
field :view_count, :type => Integer, :default => 0
|
||||||
|
|
||||||
field :not_checked_reason
|
field :not_checked_reason
|
||||||
|
|
|
@ -10,7 +10,10 @@ class Panel::News::BackEnd::NewsBulletinsController < OrbitBackendController
|
||||||
controller.get_unit_list
|
controller.get_unit_list
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def preview
|
||||||
|
@preview_obj = Preview.create(:object=>params[:news_bulletin],:expired_at=>DateTime.now+30.minutes,:preview_at_link=>"panel_news_front_end_news_bulletin_path",:object_class_type=>"NewsBulletin")
|
||||||
|
end
|
||||||
|
|
||||||
def index
|
def index
|
||||||
# @news_bulletins = NewsBulletin.all
|
# @news_bulletins = NewsBulletin.all
|
||||||
# @news_bulletins = NewsBulletin.desc("postdate desc")
|
# @news_bulletins = NewsBulletin.desc("postdate desc")
|
||||||
|
@ -117,6 +120,7 @@ class Panel::News::BackEnd::NewsBulletinsController < OrbitBackendController
|
||||||
# POST /news_bulletins
|
# POST /news_bulletins
|
||||||
# POST /news_bulletins.xml
|
# POST /news_bulletins.xml
|
||||||
def create
|
def create
|
||||||
|
binding.pry
|
||||||
get_tags
|
get_tags
|
||||||
|
|
||||||
if params[:news_bulletin_link]
|
if params[:news_bulletin_link]
|
||||||
|
|
|
@ -69,7 +69,8 @@ class Panel::News::FrontEnd::NewsBulletinsController < OrbitWidgetController
|
||||||
end
|
end
|
||||||
|
|
||||||
def preview_content
|
def preview_content
|
||||||
@news_bulletin = NewsBulletin.find params[:id]
|
@news_bulletin = NewsBulletin.find params[:id] rescue nil
|
||||||
|
@news_bulletin = Preview.find(params[:id]).get_virtual_object if @news_bulletin.nil?
|
||||||
get_categorys
|
get_categorys
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -9,6 +9,7 @@ class NewsBulletin
|
||||||
|
|
||||||
BelongsToCategory = :news_bulletin_category
|
BelongsToCategory = :news_bulletin_category
|
||||||
include OrbitCoreLib::BelongsToCategoryMayDisable
|
include OrbitCoreLib::BelongsToCategoryMayDisable
|
||||||
|
include OrbitCoreLib::Preview
|
||||||
# include Tire::Model::Search
|
# include Tire::Model::Search
|
||||||
# include Tire::Model::Callbacks
|
# include Tire::Model::Callbacks
|
||||||
# include Redis::Objects
|
# include Redis::Objects
|
||||||
|
@ -36,7 +37,6 @@ class NewsBulletin
|
||||||
field :is_checked, :type => Boolean, :default => false
|
field :is_checked, :type => Boolean, :default => false
|
||||||
field :is_pending, :type => Boolean, :default => true
|
field :is_pending, :type => Boolean, :default => true
|
||||||
field :is_rejected, :type => Boolean, :default => false
|
field :is_rejected, :type => Boolean, :default => false
|
||||||
|
|
||||||
field :view_count, :type => Integer, :default => 0
|
field :view_count, :type => Integer, :default => 0
|
||||||
|
|
||||||
field :not_checked_reason
|
field :not_checked_reason
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
<div class="modal hide fade in banner-preview" id="<%= news_bulletin.id %>">
|
<div class="modal hide fade in banner-preview" id="<%= @preview_obj.id %>">
|
||||||
<div class="modal-header">
|
<div class="modal-header">
|
||||||
<a class="close" data-dismiss="modal">×</a>
|
<a class="close" data-dismiss="modal">×</a>
|
||||||
<h3><%= t("modal.preview") %></h3>
|
<h3><%= t("modal.preview") %></h3>
|
||||||
</div>
|
</div>
|
||||||
<div class="modal-body">
|
<div class="modal-body">
|
||||||
<p class="news_bulletin_slideshow">
|
<p class="news_bulletin_slideshow">
|
||||||
<iframe src=<%= panel_news_front_end_news_bulletin_path(news_bulletin, :category_id => (news_bulletin.news_bulletin_category.id rescue ""),:preview=>true) %> style="width:1024px;height:300px" >
|
<iframe src=<%= @preview_obj.get_preview_link %> style="width:1024px;height:300px" >
|
||||||
|
|
||||||
</iframe>
|
</iframe>
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
$('#show_preview').html('<%=escape_javascript(render :partial=>"modal_preview",:locals=>{:news_bulletin => @preview_news_bulletin}) %>');
|
$('#show_preview').html('<%=escape_javascript(render :partial=>"modal_preview") %>');
|
||||||
var start_modal_with_id = "<%= @preview_news_bulletin.id %>";
|
var start_modal_with_id = "<%= @preview_obj.id %>";
|
||||||
$("#"+start_modal_with_id).css("width","1050px");
|
$("#"+start_modal_with_id).css("width","1050px");
|
||||||
$("#"+start_modal_with_id).css("height","768px");
|
$("#"+start_modal_with_id).css("height","768px");
|
||||||
$("#"+start_modal_with_id).css("margin","-270px 0 0 -550px");
|
$("#"+start_modal_with_id).css("margin","-270px 0 0 -550px");
|
Reference in New Issue