Merge branch 'master' into various_bugs

Conflicts:
	config/locales/en.yml
	config/locales/zh_tw.yml
	vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/_bulletin.html.erb
	vendor/built_in_modules/personal_patent/app - %BDƻs/views/panel/personal_patent/back_end/writing_patents/_form.html.erb
	vendor/built_in_modules/personal_patent/app - %BDƻs/views/panel/personal_patent/plugin/writing_patents/_form.html.erb
This commit is contained in:
chris 2012-11-06 11:44:00 +08:00
commit b40d4702d5
233 changed files with 3124 additions and 5384 deletions

22
Guardfile Normal file
View File

@ -0,0 +1,22 @@
guard 'livereload' do
watch(%r{app/.+\.(erb|haml)})
watch(%r{app/helpers/.+\.rb})
watch(%r{public/.+\.(css|js|html)})
watch(%r{config/locales/.+\.yml})
end
guard 'rspec', :version => 2 do
watch(%r{^spec/.+_spec\.rb})
watch(%r{^lib/(.+)\.rb}) { |m| "spec/lib/#{m[1]}_spec.rb" }
watch('spec/spec_helper.rb') { "spec" }
# Rails example
watch('spec/spec_helper.rb') { "spec" }
watch('config/routes.rb') { "spec/routing" }
watch('app/controllers/application_controller.rb') { "spec/controllers" }
watch(%r{^spec/.+_spec\.rb})
watch(%r{^app/(.+)\.rb}) { |m| "spec/#{m[1]}_spec.rb" }
watch(%r{^lib/(.+)\.rb}) { |m| "spec/lib/#{m[1]}_spec.rb" }
watch(%r{^app/controllers/(.+)_(controller)\.rb}) { |m| ["spec/routing/#{m[1]}_routing_spec.rb", "spec/#{m[2]}s/#{m[1]}_#{m[2]}_spec.rb", "spec/requests/#{m[1]}_spec.rb"] }
watch(%r{^app/views/(.+)/}) { |m| "spec/requests/#{m[1]}_spec.rb" }
end

View File

@ -332,9 +332,9 @@ var orbitDesktop = function(dom){
if(j==0)$group.attr("id",tile.group_id); if(j==0)$group.attr("id",tile.group_id);
if(tile.data_category == "app") if(tile.data_category == "app")
$li = $('<li id="'+tile._id+'" class="element '+tile.shape+' hp vp" data-category="'+tile.data_category+'" data-content="'+tile.data_content+'"><span class="tile '+tilecolor+' '+op+'"></span><a href="'+tile.data_content+'" class="appicon" onclick="return false;"><img src="'+o.iconPath+tile.data_content+'.png" alt="" ></a><h1 class="appname thmtxt">'+tile.title+'</h1></li>'); $li = $('<li data-id="'+tile.id+'" class="element '+tile.shape+' hp vp" data-category="'+tile.data_category+'" data-content="'+tile.data_content+'" ><span class="tile '+tilecolor+' '+op+'"></span><a href="'+tile.data_content+'" class="appicon" onclick="return false;"><img src="'+o.iconPath+tile.data_content+'.png" alt="" ></a><h1 class="appname thmtxt">'+tile.title+'</h1></li>');
else else
$li = $('<li id="'+tile._id+'" class="element '+tile.shape+' hp vp" data-category="'+tile.data_category+'" data-content="'+tile.data_content+'"><span class="tile '+tilecolor+' '+op+'"></span><h1 class="appname thmtxt">'+tile.title+'</h1><div class="appholder">Loading...</div></li>'); $li = $('<li data-id="'+tile.id+'" class="element '+tile.shape+' hp vp" data-category="'+tile.data_category+'" data-content="'+tile.data_content+'" js-link="'+tile.js[0].url+'" css-link="'+tile.css.url+'"><span class="tile '+tilecolor+' '+op+'"></span><h1 class="appname thmtxt">'+tile.title+'</h1><div class="appholder">Loading...</div></li>');
$group.find('.col'+colindex).append($li); $group.find('.col'+colindex).append($li);
} }
@ -1557,10 +1557,10 @@ var orbitDesktop = function(dom){
var widget = $(this); var widget = $(this);
if(widget.attr("data-category")=="widget"){ if(widget.attr("data-category")=="widget"){
var widgename = widget.attr("data-content"); var widgename = widget.attr("data-content");
$.getScript("/desktop_widgets/"+widgename+"/"+widgename+".js",function(){ $.getScript(widget.attr("js-link"),function(){
widget.find("div.appholder").load("/desktop_widgets/"+widgename+"/index.html.erb"); widget.find("div.appholder").load(widget.attr("data-content"));
}); });
// $(this).find("div.appholder").append( $('<link rel="stylesheet" id="dyn_css" type="text/css" />').attr('href', "/desktop_widgets/"+widgename+"/css/"+widgename+".css")); $(this).find("div.appholder").append( '<link rel="stylesheet" id="dyn_css" href="'+widget.attr("css-link")+'" type="text/css" />')
} }
}) })
@ -1697,3 +1697,4 @@ orbitDesktop.prototype.currentUsername = "Harry";
var uselessfunction = function(){ var uselessfunction = function(){
$.post("/desktop/temp_func",{sectionid:"4f83e7bbbd98eb041600001d"}); $.post("/desktop/temp_func",{sectionid:"4f83e7bbbd98eb041600001d"});
} }

View File

@ -287,36 +287,42 @@
padding: 0 20px 0 150px !important; padding: 0 20px 0 150px !important;
margin: 20px 0 0; margin: 20px 0 0;
} }
.user-role .user-info { .role-block .user-info {
top: 23px; top: 23px;
margin-left: -135px; margin-left: -135px;
width: 100px; width: 100px;
border-right: none; border-right: none;
box-shadow: none; box-shadow: none;
} }
.user-role .map-block h4 .gender { .role-block .map-block h4 .gender {
top: -1px; top: -1px;
bottom: auto; bottom: auto;
left: -1px; left: -1px;
right: auto; right: auto;
border-radius: 4px 0 0 0; border-radius: 4px 0 0 0;
} }
.user-role .teacher h4 .gender { .role-block .teacher h4 .gender {
border-color: #186AB6 transparent transparent #186AB6; border-color: #186AB6 transparent transparent #186AB6;
} }
.user-role .student h4 .gender { .role-block .student h4 .gender {
border-color: #F38C08 transparent transparent #F38C08; border-color: #F38C08 transparent transparent #F38C08;
} }
.user-role .staff h4 .gender { .role-block .staff h4 .gender {
border-color: #139E2F transparent transparent #139E2F; border-color: #139E2F transparent transparent #139E2F;
} }
.user-role .tab-content, .user-role .nav-pills { .role-block .tab-content, .role-block .nav-pills {
float: left; float: left;
} }
.user-role .nav-pills { .role-block .nav-pills {
margin-left: 10px; margin-bottom: 0;g
} }
.plural .input-append input, .plural .input-append select, .plural .input-append .uneditable-input { .role-block .nav-pills > li > a {
margin-top: 0;
}
/*.role-block .control-group .inline {
float:
}*/
.plural .input-append input, .plural .input-append select, .plural .input-append .uneditable-input, .unRadius input {
-webkit-border-radius: 3px; -webkit-border-radius: 3px;
-moz-border-radius: 3px; -moz-border-radius: 3px;
border-radius: 3px; border-radius: 3px;
@ -339,3 +345,7 @@
-moz-border-radius: 0 3px 3px 0; -moz-border-radius: 0 3px 3px 0;
border-radius: 0 3px 3px 0; border-radius: 0 3px 3px 0;
} }
.language-swich .tab-pane {
margin-bottom: 5px;
margin-right: 10px;
}

View File

@ -81,37 +81,60 @@
background-color: #5EB92B; background-color: #5EB92B;
font-size: 9px; font-size: 9px;
padding: 0px 10px; padding: 0px 10px;
border-radius: 8px; border-radius: 11px;
line-height: 16px; line-height: 20px;
height: 15px; height: 19px;
color: #FFF; color: #FFF;
width: 38px; width: 40px;
border: none; border: none;
box-shadow: 0px 1px 0px rgba(255, 255, 255, 0.5), 0 0 5px rgba(13, 75, 23, 0.5) inset; box-shadow: 0px 1px 0px rgba(255, 255, 255, 0.5), 0 0 5px rgba(13, 75, 23, 0.5) inset;
margin-top: 2px; margin-top: 1px;
} }
/* for mamber role */ /* for mamber role */
.role-block .form-horizontal {
.user-role .form-horizontal {
padding: 20px 10px 10px; padding: 20px 10px 10px;
background-color: #FFF; background-color: #FFF;
margin-bottom: 0; margin-bottom: 0;
border-radius: 0 0 4px 4px; border-radius: 0 0 4px 4px;
} }
.user-role .form-horizontal .control-label { .role-block [class*="type"] {
background-color: #F1F1F1;
padding: 20px 0 10px;
border-radius: 5px;
margin: -25px 0 40px;
/*box-shadow: 0px 1px 3px rgba(100,100,100,.4)*/
}
.role-block .form-horizontal .control-label {
width: 100px; width: 100px;
} }
.user-role .form-horizontal .controls { .role-block .form-horizontal .controls {
margin-left: 120px; margin-left: 120px;
} }
.user-role .form-horizontal .controls>.input-append { .role-block .form-horizontal .controls>.input-append {
margin-bottom: 10px; margin-bottom: 10px;
} }
.user-role .map-block { .role-block .form-horizontal legend .onoff {
margin-top: 4px;
}
.role-block .form-horizontal legend .btn-danger {
margin-right: 20px;
}
.role-block .form-horizontal legend>.clear {
margin-right: 150px;
min-width: 350px;
}
.role-block .map-block {
min-width: 440px; min-width: 440px;
} }
.user-role .map-block legend { .role-block .map-block .form-actions {
margin: 0;
padding: 10px 20px;
}
.role-block .map-block legend {
font-size: 18px; font-size: 18px;
line-height: 25px; line-height: 25px;
} }
.role-block .map-block legend .nav {
font-size: 12px;
}

View File

@ -1,9 +1,10 @@
class Admin::InfosController < ApplicationController class Admin::InfosController < ApplicationController
layout "admin" layout "new_admin"
before_filter :authenticate_user! before_filter :authenticate_user!
before_filter :is_admin? before_filter :is_admin?
before_filter :set_attribute, :only => [:index, :show, :new, :edit] before_filter :set_attribute, :only => [:index, :show, :new, :edit]
helper Admin::AttributeValuesViewHelper
def index def index
@attributes = Info.all.entries @attributes = Info.all.entries
@ -32,8 +33,8 @@ class Admin::InfosController < ApplicationController
def update def update
@attribute = Info.find(params[:id]) @attribute = Info.find(params[:id])
# binding.pry
@attribute.update_attributes(params[:info]) @attribute.update_attributes(params[:info])
@attribute.attribute_fields.each{|t| t.destroy if t["to_delete"] == true}
respond_to do |format| respond_to do |format|
format.html { redirect_to :action => :index } format.html { redirect_to :action => :index }
format.js { render 'admin/attributes/toggle_enable' } format.js { render 'admin/attributes/toggle_enable' }
@ -47,10 +48,10 @@ class Admin::InfosController < ApplicationController
end end
def add_attribute_field def add_attribute_field
@attribute = Info.find(params[:id]) rescue nil attribute = Info.find(params[:info_id]) rescue nil
if !@attribute @attribute_field_counter = attribute.attribute_fields.count
@attribute = Info.new @attribute_field = attribute.attribute_fields.build
end @attribute_field.save
end end
protected protected

View File

@ -33,14 +33,10 @@ class Admin::UsersNewInterfaceController < ApplicationController
@student_data = [] @student_data = []
@staff_data = [] @staff_data = []
attribute_values = @user.attribute_values
attribute_values = @user.attribute_values.reject{|att_val|
# binding.pry if(att_val.id.to_s == '507fa1295789b52a540000e0')
!att_val.attribute_field.locale and (att_val.attribute_field.neutral_for != I18n.locale.to_s)
}
attribute_values.each{|att_val| attribute_values.each{|att_val|
@profile_data.push({:name => att_val.attribute_field.title,:value =>att_val.get_value_by_locale(I18n.locale)}) if att_val.attribute_field.attribute.key=="profile" rescue false binding.pry if att_val.id.to_s == '5052dab52b5c49ae9d000006'
@profile_data.push({:name => att_val.attribute_field.title,:value =>att_val.get_value_by_locale(I18n.locale.to_s)}) if att_val.attribute_field.attribute.key=="profile" rescue false
} }
@ -75,7 +71,6 @@ class Admin::UsersNewInterfaceController < ApplicationController
end end
def create def create
binding.pry
puts params.to_yaml puts params.to_yaml
# attribute_values_key = params[:user].has_key?('new_attribute_values') ? 'new_attribute_values' : 'attribute_values' # attribute_values_key = params[:user].has_key?('new_attribute_values') ? 'new_attribute_values' : 'attribute_values'
# attribute_values = params[:user].delete(attribute_values_key) # attribute_values = params[:user].delete(attribute_values_key)
@ -84,6 +79,7 @@ class Admin::UsersNewInterfaceController < ApplicationController
# @user.attribute_values.build(value) # @user.attribute_values.build(value)
# } # }
# @user.rebuild_sub_roles_from_attribute_values!(attribute_values) # @user.rebuild_sub_roles_from_attribute_values!(attribute_values)
binding.pry
if @user.save if @user.save
flash[:notice] = t('create.success.user') flash[:notice] = t('create.success.user')
redirect_to :action => :index redirect_to :action => :index

View File

@ -103,11 +103,41 @@ class DesktopController< ApplicationController
def getgroups def getgroups
@section = Section.find(params["sectionid"]) @section = Section.find(params["sectionid"])
@groups = @section.groups @groups = @section.groups
a = Array.new
gr = Array.new
@groups.each do |group| @groups.each do |group|
a << group.tiles a = Array.new
t = group.tiles
t.each do |tile|
data_content = ""
jsfile = []
cssfile = ""
shape = "w1 h1"
if tile.data_category == "widget"
widge = DesktopWidget.find(tile.desktop_widget_id.to_s)
# data_content = widge.widget_layout.file
data_content = "desktop/widget_layout?id="+tile.desktop_widget_id.to_s
jsfile = widge.javascripts.collect{|js| js.file}
cssfile = widge.css_default.file
shape = widge.shape
title = widge.name
else
data_content = tile.data_content
title = tile.title
end end
render :json =>a.to_json a << {"id"=>tile.id,"data_category"=>tile.data_category,"data_content"=>data_content,"js"=>jsfile,"css"=>cssfile,"shape"=>shape,"position"=>tile.position,"title"=>title}
end
gr << a
end
render :json =>gr.to_json
end
def widget_layout
widget = DesktopWidget.find(params[:id])
link = '<link href="'+widget.css_default.file.to_s+'" media="screen" rel="stylesheet" type="text/css" />'
content = widget.widget_layout.body
dhtml = link + content
render :text => dhtml.html_safe
end end
def getsectionlist def getsectionlist

View File

@ -8,6 +8,7 @@ class DesktopPublicationsController< ApplicationController
end end
def journal_p_add def journal_p_add
debugger
render "desktop/journal_pages/add", :layout => false render "desktop/journal_pages/add", :layout => false
end end

View File

@ -0,0 +1,62 @@
class DesktopWidgetsController < OrbitBackendController
require "net/http"
require "uri"
require 'zip/zip'
def index
end
def upload
if !params[:desktop_widget].nil?
temp_file = Tempfile.new("temp_file")
original_file = params[:desktop_widget][:package_file]
#if original_file.content_type == 'application/zip'
temp_file.write(original_file.read.force_encoding('UTF-8'))
temp_file.rewind
filename = File.basename(original_file.original_filename,".zip")
unzip_widget(temp_file, filename)
#else
# flash[:error] = "Upload file should be in zip format"
#end
temp_file.close
end
end
def unzip_widget(file, zip_name)
Zip::ZipFile.open(file) { |zip_file|
dw = DesktopWidget.new.from_json(zip_file.read("#{zip_name}/settings.json"))
Dir.mktmpdir('f_path') { |dir|
javascripts_entries = []
images_entries = []
zip_file.entries.each do |entry|
case (path = entry.to_s)
when /\A(#{zip_name})\/(default\.css)\z/
#for default css
dw.build_css_default(:file => get_temp_file(zip_file, dir, entry))
when /\A(#{zip_name})\/(widget\.html)\z/ #for layout html
dw.build_widget_layout(:file => get_temp_file(zip_file, dir, entry))
when /\A(#{zip_name})\/(javascripts)\/.*(\.js)\z/ #for js
javascripts_entries << entry
when /\A(#{zip_name})\/(images)\/.*((\.jpg)|(\.png)|(\.gif))\z/ #for img
images_entries << entry
end
end
['javascripts', 'images'].each do |type|
eval("#{type}_entries").each do |entry|
eval("dw.#{type}").build(:file => get_temp_file(zip_file, dir, entry))
end
end
}
dw.save
}
end
def get_temp_file(zip_file, dir, entry)
filename = File.basename(entry.to_s)
temp_file = File.new(dir + '/' + filename, 'w+')
temp_file.write (zip_file.read entry ).force_encoding('UTF-8')
temp_file
end
end

View File

@ -1,4 +1,4 @@
class OtheraccountsController< ApplicationController class Desktop::OtheraccountsController< ApplicationController
require 'open-uri' require 'open-uri'
require 'rexml/document' require 'rexml/document'
require 'net/http' require 'net/http'

View File

@ -0,0 +1,16 @@
module Admin::AttributeValuesViewHelper
OPT = [
["YYYY / MM / DD hh : mm","format1"],
["YYYY / MM / DD","format2"],
["YYYY / MM","format3"],
["YYYY","format4"]
]
def show_type_panel(attribute_field,type)
markup = attribute_field.markup
LIST[:markups][markup]["panel"] == type ? type : [type,'hide'].join(" ")
end
def name_to_id(str)
str.gsub(/\]/,'').gsub(/\[/,"_")
end
end

View File

@ -9,14 +9,18 @@ module AttributeFieldsHelper
include ActionView::Helpers::RenderingHelper include ActionView::Helpers::RenderingHelper
def block_helper(user,index,disable = false) def block_helper(user,index,disable = false)
unless self.disabled
@index = index @index = index
@markup_options = markup_options.merge(:disabled=>disable) @markup_options = markup_options.merge(:disabled=>disable,:func=>"input_unit")
@user = user @user = user
@attribute_value = @user.get_value_from_field_id(id) @attribute_value = @user.get_value_from_field_id(id)
@new_attribute = @attribute_value.nil? @new_attribute = @attribute_value.nil?
@attribute_value = @attribute_value || @user.attribute_values.build( attribute_field_id: id ) @attribute_value = @attribute_value || @user.attribute_values.build( attribute_field_id: id )
@prefiled_value = @attribute_value.get_values @prefiled_value = @attribute_value.value
@panel_setting = self.get_data
return instance_eval("render_#{markup}") #rescue "" return instance_eval("render_#{markup}") #rescue ""
end
end end
def lang_tab(str,lang) def lang_tab(str,lang)
@ -24,6 +28,7 @@ module AttributeFieldsHelper
end end
def render_address def render_address
#NP
control_group_wrapper do |key,value| control_group_wrapper do |key,value|
result = '<div class="input-append">'.html_safe result = '<div class="input-append">'.html_safe
@ -44,17 +49,26 @@ module AttributeFieldsHelper
end end
def render_checkbox def render_checkbox
@prefiled_value ||=[] @prefiled_value ||=[]
markup_value = eval(self.markup_value) rescue {} # begin
# markup_value = eval(self.markup_value)
# rescue
# markup_value = self.markup_value
# ensure
# markup_value ||= {}
# end
control_group_wrapper do control_group_wrapper do
markup_value.collect do |key,value| a = self[:option_list].collect do |key,value|
label_tag(key,check_box_tag(get_field_name_base+"[value][#{key}]", value[I18n.locale.to_s], (@prefiled_value.include?(key) ? true : false), {})+value[I18n.locale.to_s],@markup_options.merge(:class=>"control-label")) label_tag(key,check_box_tag(get_field_name_base+"[#{key}]", true , (@prefiled_value.include?(key) ? true : false), {})+value[I18n.locale.to_s],@markup_options.merge(:class=>"control-label"))
end.join rescue "" end.join rescue ""
end end
end end
def render_date def render_date
control_group_wrapper{date_select(get_field_name_base+"[value]",nil,@markup_options.merge(:default=>@prefiled_value),:class=>"input-small")} #NP
control_group_wrapper{date_select(get_field_name_base,nil,@markup_options.merge(:default=>@prefiled_value),:class=>"input-small")}
end end
def render_date_durnation #Need re-write low priority def render_date_durnation #Need re-write low priority
@ -63,17 +77,27 @@ module AttributeFieldsHelper
def render_radio_button def render_radio_button
@prefiled_value ||=[] @prefiled_value ||=[]
markup_value = eval(self.markup_value) rescue {} # begin
# markup_value = eval(self.markup_value)
# rescue
# markup_value = self.markup_value
# ensure
# markup_value ||= {}
# end
control_group_wrapper do control_group_wrapper do
markup_value.collect do |key,value| self[:option_list].collect do |key,value|
label_tag(key,radio_button_tag(get_field_name_base+"[value][#{key}]", value[I18n.locale.to_s], (@prefiled_value.include?(key) ? true : false), {})+value[I18n.locale.to_s],@markup_options.merge(:class=>"control-label")) label_tag(key,radio_button_tag(get_field_name_base, key , (@prefiled_value.include?(key) ? true : false), {})+value[I18n.locale.to_s],@markup_options.merge(:class=>"control-label"))
end.join rescue "" end.join
end end
end end
def render_select def render_select
markup_value = (self.markup_value.is_a?(Hash) ? self.markup_value : eval(self.markup_value) )rescue {}
control_group_wrapper{select_tag( get_field_name_base+"[value]",options_for_select(markup_value.collect{|p| [p[1][I18n.locale.to_s],p[0]]},@prefiled_value),@markup_options)} rescue "" prompt = @panel_setting[:prompt][I18n.locale] rescue nil
@markup_options.merge!(:prompt => prompt) unless prompt.nil?
# markup_value = (self.markup_value.is_a?(Hash) ? self.markup_value : eval(self.markup_value) )rescue {}
# check self[:option_list].collect{|p| [p[1][I18n.locale.to_s],p[0]]}
control_group_wrapper{select_tag( get_field_name_base,options_for_select(self.option_list.collect{|p| [p[1][I18n.locale.to_s],p[0]]},@prefiled_value),@markup_options)} rescue ""
end end
def render_text_area def render_text_area
@ -81,28 +105,35 @@ module AttributeFieldsHelper
if(add_more and value.is_a?(Hash)) if(add_more and value.is_a?(Hash))
values = value values = value
values.each_with_index.collect do |value,index| values.each_with_index.collect do |value,index|
text_area_tag(get_field_name_base + (key.nil? ? '' : "[#{key}][#{index}]"), value.last,@markup_options) place_holder= @panel_setting["placeholder"][key]
text_area_tag(get_field_name_base + (key.nil? ? '' : "[#{key}][#{index}]"), value.last,@markup_options.merge(:placeholder=>place_holder))
end.join.html_safe end.join.html_safe
else else
value = can_muti_lang_input ? @prefiled_value[key] : @prefiled_value value = can_muti_lang_input ? @prefiled_value[key] : @prefiled_value
key = can_muti_lang_input ? "[#{key}]" : "[value]" key = can_muti_lang_input ? "[#{key}]" : ""
text_area_tag(get_field_name_base + key, value,@markup_options) place_holder= @panel_setting["placeholder"][I18n.locale.to_s] rescue ''
text_area_tag(get_field_name_base + key, value,@markup_options.merge(:placeholder=>place_holder))
end end
end end
end end
def render_text_field def render_text_field
control_group_wrapper do |key,value| control_group_wrapper do |key,value|
if(add_more and value.is_a?(Hash)) if(add_more)
values = value values = value
values.each_with_index.collect do |value,index| result = ""
unless values.nil?
text_field_tag(get_field_name_base + (key.nil? ? '' : "[#{key}][#{index}]"), value.last,@markup_options) result = values.each_with_index.collect do |value,index|
place_holder= @panel_setting["placeholder"][key]
text_field_tag(get_field_name_base + (key.nil? ? '' : "[#{key}][#{index}]"), value.last,@markup_options.merge(:placeholder=>place_holder))
end.join.html_safe end.join.html_safe
end
result
else else
value = can_muti_lang_input ? @prefiled_value[key] : @prefiled_value value = (can_muti_lang_input ? @prefiled_value[key] : @prefiled_value) rescue nil
key = can_muti_lang_input ? "[#{key}]" : "[value]" key_field = can_muti_lang_input ? "[#{key}]" : ""
text_field_tag(get_field_name_base + key, value,@markup_options) place_holder= @panel_setting["placeholder"][key] rescue ''
text_field_tag(get_field_name_base + key_field, value,@markup_options.merge(:placeholder=>place_holder))
end end
end end
end end
@ -121,12 +152,14 @@ protected
if can_muti_lang_input if can_muti_lang_input
result << "<div class='tabbable'>" result << "<div class='tabbable'>"
result << "<div class='tab-content'>" result << "<div class='tab-content'>"
VALID_LOCALES.collect do |key| VALID_LOCALES.collect do |key|
value = @prefiled_value[key.to_s] rescue nil value = @prefiled_value[key.to_s] rescue nil
div_class = ["tab-pane" ,"fade"].join(" ") div_class = ["tab-pane" ,"fade"].join(" ")
div_class << (key == I18n.locale.to_s ? " active in" : '') div_class << (key == I18n.locale.to_s ? " active in" : '')
result << content_tag(:div,yield(key,value),:class=>div_class,:id=>"tab"+id.to_s+"_#{key}") result << content_tag(:div,yield(key,value),:class=>div_class,:id=>"tab"+id.to_s+"_#{key}")
end end
result << "</div>" result << "</div>"
result << "<ul class='nav nav-pills'>" result << "<ul class='nav nav-pills'>"
VALID_LOCALES.each do |key| VALID_LOCALES.each do |key|
@ -161,15 +194,13 @@ protected
def end_block def end_block
if @new_attribute if @new_attribute
hidden_field_tag(get_field_name_base+"[attribute_field_id]",id,:for=>"field_#{@index}") hidden_field_tag(get_basic_field_name_base+"[attribute_field_id]",id,:for=>"field_#{@index}")
else else
hidden_field_tag(get_field_name_base+"[id]",@attribute_value.id,:for=>"field_#{@index}") hidden_field_tag(get_basic_field_name_base+"[id]",@attribute_value.id,:for=>"field_#{@index}")
end end
end end
def get_field_name_base def get_basic_field_name_base
# "user[#{self.attribute._type.downcase.pluralize}][#{self.attribute._id.to_s}][attribute_values][#{attribute_value.id}]"
# binding.pry if @attribute_value[:key] == 'status'
if @new_attribute if @new_attribute
"user[new_attribute_values][#{@index}]" "user[new_attribute_values][#{@index}]"
else else
@ -177,12 +208,16 @@ protected
end end
end end
def get_field_name_base
get_basic_field_name_base + "[value]"
end
def label def label
label_tag(key,title,:class=>"control-label") label_tag(key,title,:class=>"control-label",:func => "field_label")
end end
def can_muti_lang_input def can_muti_lang_input
locale and LIST[:markups][markup]["muti_lang_input_supprt"] LIST[:markups][markup]["muti_lang_input_supprt"] #and locale
end end
def can_add_more def can_add_more

View File

@ -1,5 +1,8 @@
class CssDefault < Stylesheet class CssDefault < Stylesheet
belongs_to :design # belongs_to :design
# belongs_to :desktop_widget
belongs_to :css, polymorphic: true
end end

View File

@ -8,11 +8,11 @@ class Design
field :title, :type => String field :title, :type => String
field :version, :type => String field :version, :type => String
has_one :css_default, :autosave => true, :dependent => :destroy has_one :css_default, as: :css, :autosave => true, :dependent => :destroy
has_one :layout, :autosave => true, :dependent => :destroy has_one :layout, :autosave => true, :dependent => :destroy
has_one :css_reset, :autosave => true, :dependent => :destroy has_one :css_reset, :autosave => true, :dependent => :destroy
has_many :images, :autosave => true, :dependent => :destroy has_many :images,as: :imgs, :autosave => true, :dependent => :destroy
has_many :javascripts, :autosave => true, :dependent => :destroy has_many :javascripts, as: :js, :autosave => true, :dependent => :destroy
has_many :pages has_many :pages
has_many :themes, :autosave => true, :dependent => :destroy has_many :themes, :autosave => true, :dependent => :destroy

View File

@ -10,7 +10,10 @@ class Image
mount_uploader :file, ImageUploader mount_uploader :file, ImageUploader
belongs_to :design # belongs_to :design
# belongs_to :desktop_widget
belongs_to :imgs, polymorphic: true
before_save :set_name before_save :set_name

View File

@ -1,3 +1,6 @@
class Javascript < DesignFile class Javascript < DesignFile
belongs_to :design # belongs_to :design
# belongs_to :desktop_widget
belongs_to :js, polymorphic: true
end end

View File

@ -1,23 +1,27 @@
class Stylesheet < DesignFile class Stylesheet < DesignFile
belongs_to :design # belongs_to :design
mount_uploader :file_orig, AssetUploader mount_uploader :file_orig, AssetUploader
def parse_urls def parse_urls
orig_content = content = self.file.read.force_encoding("UTF-8") orig_content = content = self.file.read.force_encoding("UTF-8")
# self.remove_file! # self.remove_file!
# self.remove_file_orig! # self.remove_file_orig!
names = [] names = {}
images = self.design.images images = self.css.images
content.scan(/(?<=url)(.*?)(?=\))/){ content.scan(/(?<=url)(.*?)(?=\))/){
css_name = $1.gsub(' ','').gsub('(','') css_name = $1.gsub(' ','').gsub('(','')
unless names.has_key?(css_name)
name = File.basename(css_name).gsub(/[\\\"]/, '') name = File.basename(css_name).gsub(/[\\\"]/, '')
image = images.detect{ |i| i.file_identifier.eql?(name) } rescue nil image = images.detect{ |i| i.file_identifier.eql?(name) } rescue nil
image.update_attribute(:in_css, true) if image if image
file_name = image.file_url rescue nil image.update_attribute(:in_css, true)
names << [css_name, file_name] file_name = image.file_url
names.merge!({css_name => file_name})
end
end
} }
names.each do |name| names.each_pair do |key, value|
content.gsub!(name[0], name[1]) if name[1] content.gsub!(key, value)
end end
Dir.mktmpdir('f_path') { |dir| Dir.mktmpdir('f_path') { |dir|
orig_file_name = self.file_identifier orig_file_name = self.file_identifier

View File

@ -2,14 +2,15 @@ class Desktop
include Mongoid::Document include Mongoid::Document
include Mongoid::Timestamps include Mongoid::Timestamps
field :theme, default: "4f8d3f493b67fcd05f086359" field :theme, default: "4f8d3f533b67fcd05f08635a"
field :customtheme field :customtheme
field :wallpaper field :wallpaper
belongs_to :user belongs_to :user
has_and_belongs_to_many :desktop_widgets, :autosave => true
has_many :sections, :autosave => true, :dependent => :destroy has_many :sections, :autosave => true, :dependent => :destroy
has_many :desktop_widgets, :autosave => true, :dependent => :destroy # has_many :desktop_widgets, :autosave => true, :dependent => :destroy
before_create :initialize_section before_create :initialize_section

View File

@ -0,0 +1,33 @@
class DesktopWidget
include Mongoid::Document
include Mongoid::Timestamps
include ParserLayoutWidget
field :name
field :author
field :shape
field :version, :type => String
has_one :css_default, as: :css, :autosave => true, :dependent => :destroy
has_one :widget_layout, :autosave => true, :dependent => :destroy
has_many :images, as: :imgs, :autosave => true, :dependent => :destroy
has_many :javascripts, as: :js, :autosave => true, :dependent => :destroy
has_and_belongs_to_many :desktops, :autosave => true
belongs_to :tiles, :autosave => true
accepts_nested_attributes_for :images, :allow_destroy => true
accepts_nested_attributes_for :javascripts, :allow_destroy => true
after_save :parse_css_for_images
# belongs_to :desktop
protected
def parse_css_for_images
self.css_default.parse_urls
parse_widget_for_images(self)
end
end

View File

@ -0,0 +1,18 @@
class Group
include Mongoid::Document
include Mongoid::Timestamps
belongs_to :section
has_many :tiles, :autosave => true, :dependent => :destroy
before_create :initialize_tile
def initialize_tile
self.tiles.build(data_category: "app", data_content: "quotes", position: 5, shape: "w1 h1", title: "Quotes")
self.tiles.build(data_category: "app", data_content: "dailyenglish", position: 6, shape: "w1 h1", title: "Daily English Word")
widgets = self.section.desktop.desktop_widgets.collect{|widget| widget.id}
for i in 0..3
self.tiles.build(data_category: "widget", position: i+1,desktop_widget_id: widgets[i])
end
end
end

View File

@ -9,6 +9,6 @@ class Tile
field :title field :title
belongs_to :group belongs_to :group
has_one :desktop_widget
end end

View File

@ -0,0 +1,18 @@
class WidgetLayout < DesignFile
attr_reader :content
field :body
belongs_to :desktop_widget
def content
self.file.read.force_encoding("UTF-8") rescue ''
end
def self.exist_one?
WidgetLayout.count > 0
end
end

View File

@ -1,13 +0,0 @@
class DesktopWidget
include Mongoid::Document
include Mongoid::Timestamps
field :name
field :author
field :shape
field :desktop_id
field :status
field :section
belongs_to :desktop
end

View File

@ -1,19 +0,0 @@
class Group
include Mongoid::Document
include Mongoid::Timestamps
belongs_to :section
has_many :tiles, :autosave => true, :dependent => :destroy
before_create :initialize_tile
def initialize_tile
self.tiles.build(data_category: "widget", data_content: "timetable", position: 1, shape: "w2 h2", title: "Tiime Table")
self.tiles.build(data_category: "app", data_content: "quotes", position: 2, shape: "w1 h1", title: "Quotes")
self.tiles.build(data_category: "widget", data_content: "weather", position: 3, shape: "w2 h2", title: "Weather")
self.tiles.build(data_category: "widget", data_content: "clock", position: 4, shape: "w2 h1", title: "Clock")
self.tiles.build(data_category: "app", data_content: "dailyenglish", position: 5, shape: "w1 h1", title: "Daily English Word")
self.tiles.build(data_category: "widget", data_content: "school_events", position: 6, shape: "w2 h1", title: "School Events")
end
end

View File

@ -11,6 +11,7 @@ class Attribute
has_many :attribute_fields, :autosave => true, :dependent => :destroy has_many :attribute_fields, :autosave => true, :dependent => :destroy
accepts_nested_attributes_for :attribute_fields, :allow_destroy => true accepts_nested_attributes_for :attribute_fields, :allow_destroy => true
def is_built_in? def is_built_in?
self.built_in self.built_in
end end

View File

@ -5,26 +5,43 @@ class AttributeField
include ::AttributeFieldsHelper include ::AttributeFieldsHelper
field :key field :key
field :markup field :markup ,:default=>"text_field"
field :markup_value ,:type => Hash field :option_list ,:type => Hash,:default => {}
field :markup_options,:type => Hash field :markup_options,:type => Hash
field :locale, :type => Boolean, :default => true # field :locale, :type => Boolean, :default => true
# field :list_options, :type => Array # field :list_options, :type => Array
field :built_in, :type => Boolean, :default => false field :built_in, :type => Boolean, :default => false
field :disabled, :type => Boolean, :default => false field :disabled, :type => Boolean, :default => false
field :add_more,:type => Boolean, :default => false field :to_delete,:type=> Boolean,:default => false
field :typeA,:type=> Hash,:default=>{}
field :typeB,:type=> Hash,:default=>{}
field :typeC,:type=> Hash,:default=>{:claendar=>"west_claendar"}
field :typeD,:type=> Hash,:default=>{}
field :typeE,:type=> Hash,:default=>{}
#field :title, localize: true #field :title, localize: true
field :locale_title, localize: true field :title, localize: true
field :neutral_title
field :neutral_for
belongs_to :attribute belongs_to :attribute
# belongs_to :role # belongs_to :role
has_many :attribute_values,:autosave => true, :dependent => :destroy has_many :attribute_values,:autosave => true, :dependent => :destroy
before_save :check_option_list
# validates_uniqueness_of :key # validates_uniqueness_of :key
def add_more
(get_data["add_more"] == "true" ? true : false) rescue false
end
def locale
default = true
if get_data["locale"].nil?
return default
else
(get_data["locale"] == "true" ? true : false) rescue default
end
end
def self_defined_markup_options? def self_defined_markup_options?
(self.attribute.role.method(self[:key].pluralize.to_sym) && self.attribute.role.method(self[:key].pluralize+"_for_"+markup)) rescue false (self.attribute.role.method(self[:key].pluralize.to_sym) && self.attribute.role.method(self[:key].pluralize+"_for_"+markup)) rescue false
@ -36,16 +53,16 @@ class AttributeField
end end
end end
def markup_value def option_list
if self_defined_markup_options? if self_defined_markup_options?
#Class need to have corresponding field and value agent #Class need to have corresponding field and value agent
# Ex: For "status" the class must have field called "statuses" for the relation and "statuses_for_select" for the select function # Ex: For "status" the class must have field called "statuses" for the relation and "statuses_for_select" for the select function
method = self.attribute.role.method(self[:key].pluralize+"_for_"+markup) method = self.attribute.role.method(self[:key].pluralize+"_for_"+markup)
return (method.call rescue {}) return (method.call rescue {})
elsif self[:markup_value].nil? || (self[:markup_value].empty?) elsif self[:option_list].nil? || (self[:option_list].empty?)
return {} return {}
else else
return self[:markup_value] return self[:option_list]
end end
end end
@ -68,36 +85,49 @@ class AttributeField
self.attribute.role self.attribute.role
end end
def title_translations def panel
if locale panel = LIST[:markups][self[:markup]]["panel"]
return locale_title_translations
else
return Hash[VALID_LOCALES.map{|d| [d,neutral_title]}]
end
end end
def title_translations=(var) def get_data
if locale self[panel]
self.locale_title_translations = var
end
end end
def title
if locale
return self.locale_title
else
return self.neutral_title
end
end
def title=(var) # def title_translations
# binding.pry # if locale
if locale # return self.locale_title_translations
self.locale_title = var # else
else # return self[:neutral_title] #Hash[VALID_LOCALES.map{|d| [d,neutral_title]}]
self.neutral_title = var # end
end # end
end
# def title_translations=(var)
# if locale
# self.locale_title_translations = var
# end
# end
# def title
# if locale
# return self.locale_title
# else
# return self.neutral_title
# end
# end
# def check_title
# if locale
# self.locale_title_translations = self[:temp_title]
# else
# self.neutral_title = self[:temp_title]
# end
# self.unset("temp_title")
# end
# def title=(var)
# self["temp_title"] = var
# end
# # Convert the string list_options into an array # # Convert the string list_options into an array
# def select_list_options=(var) # def select_list_options=(var)
@ -117,4 +147,9 @@ class AttributeField
self.disabled self.disabled
end end
protected
def check_option_list
self[:option_list] = self[panel]["option_list"]
end
end end

View File

@ -10,11 +10,56 @@ class AttributeValue
belongs_to :user belongs_to :user
before_save :check_key before_save :check_key
before_save :data_proc
# NO_MULTI_TAG = ["select","date","radio_button","checkbox","date_durnation"] # NO_MULTI_TAG = ["select","date","radio_button","checkbox","date_durnation"]
def data_proc
# binding.pry
# binding.pry if self.attribute_field.markup == 'radio_button'
# if self.attribute_field
case self.attribute_field.markup
when 'text_field','text_area'
# binding.pry
self[:temp_data].each{|key,val|
self[key] = val
} unless self[:temp_data].nil?
when 'select','date','radio_button'
self["val"] = self[:temp_data]
when 'checkbox'
self["val"] = self[:temp_data].keys rescue {}
end #end of case
else # if not locale
case self.attribute_field.markup
when 'text_field','text_area'
self["val"] = self[:temp_data]
when 'select','date','radio_button'
self["val"] = self[:temp_data]
when 'checkbox'
self["val"] = self[:temp_data].keys rescue {}
end #end of case
# end #of if self.attribute_field
self.unset('temp_data')
end
def value
result=""
if self.attribute_field.locale && (self.attribute_field.markup == "text_field" || self.attribute_field.markup == "text_area")
result= Hash[VALID_LOCALES.collect{|lang| [lang,self[lang.to_sym]]}]
else
result = self["val"]
end
result
end
def value=(value)
#save everything to temp_data waiting for futher process
# binding
self[:temp_data] = value
end
def check_key def check_key
binding.pry if attribute_field.nil?
self.key = attribute_field.key self.key = attribute_field.key
end end
@ -27,45 +72,46 @@ class AttributeValue
end end
def get_value_by_locale(locale) def get_value_by_locale(locale)
case self.attribute_field.markup case self.attribute_field.markup
when "text_field" when "text_field"
self.attribute_field.locale ? self[locale] : self[:value] self.attribute_field.locale ? self[locale.to_s] : self.value
when "select" when "select"
markup_values = self.attribute_field.self_defined_markup_options? ? self.attribute_field.markup_value : eval(self.attribute_field.markup_value) markup_values = self.attribute_field.self_defined_markup_options? ? self.attribute_field.markup_value : eval(self.attribute_field.markup_value)
markup_values[self[:value]][locale.to_s] rescue 'NoData' markup_values[self.value][locale.to_s] rescue 'NoData'
when "text_area" when "text_area"
self.attribute_field.locale ? self[locale] : self[:value] self.attribute_field.locale ? self[locale.to_s] : self.value
when "date" when "date"
Date.new(self[:value]["(1i)"].to_i,self[:value]["(2i)"].to_i,self[:value]["(3i)"].to_i) rescue nil Date.new(self[:val]["(1i)"].to_i,self[:val]["(2i)"].to_i,self[:val]["(3i)"].to_i) rescue nil
when "addr" when "addr"
self[:value] self.value
when "radio_button" when "radio_button"
markup_values = eval(self.attribute_field.markup_value) markup_values = eval(self.attribute_field.markup_value)
markup_values[self[:value].first[0]][locale.to_s] markup_values[:value][locale.to_s]
when "checkbox" when "checkbox"
markup_values = eval(self.attribute_field.markup_value) markup_values = self.attribute_field.markup_value
self[:value].keys.collect{|key| markup_values[key][locale.to_s]}.join(",") self[:value].keys.collect{|key| markup_values[key][locale.to_s]}.join(",")
when "date_durnation" when "date_durnation"
self[:value] self.value
else else
self.attribute_field.locale ? self[locale] : self[:value] self.attribute_field.locale ? self[locale.to_s] : self.value
end end
end end
def get_values # def get_values
unless ['select','checkbox','radio_button'].include?(self.attribute_field.markup ) # unless ['select','checkbox','radio_button'].include?(self.attribute_field.markup )
if self.attribute_field.locale && LIST[:markups][self.attribute_field.markup]["muti_lang_input_supprt"] # if self.attribute_field.locale && LIST[:markups][self.attribute_field.markup]["muti_lang_input_supprt"]
return Hash[VALID_LOCALES.collect{|lang| [lang,get_value_by_locale(lang.to_sym)]}] # return Hash[VALID_LOCALES.collect{|lang| [lang,get_value_by_locale(lang.to_sym)]}]
else # else
return get_value_by_locale("") # return get_value_by_locale("")
end # end
else # else
if self.attribute_field.markup == "select" # if self.attribute_field.markup == "select"
self[:value] # self[:value]
else # else
self[:value].keys rescue self[:value] # self[:value].keys rescue self[:value]
end # end
end # end
end # end
end end

View File

@ -35,7 +35,8 @@ class User
before_save :save_roles before_save :save_roles
scope :remote_account, where(:nccu_id.ne => nil) scope :remote_account, where(:nccu_id.ne => nil)
validates_uniqueness_of :email,:message=> I18n.t("devise.registrations.email_not_unique") # validates_uniqueness_of :email,:message=> I18n.t("devise.registrations.email_not_unique")
# def new_attribute_values=(vars) # def new_attribute_values=(vars)
# binding.pry # binding.pry
# end # end
@ -176,7 +177,7 @@ class User
end end
def initialize_desktop def initialize_desktop
self.build_desktop self.build_desktop(desktop_widget_ids: DesktopWidget.all.collect{|widget| widget.id})
end end
protected protected

View File

@ -1,14 +1,139 @@
<% content_for :secondary do %> <%= form_for @attribute,:url => admin_info_path(@attribute) ,:class=> "form-horizontal" do |f| %>
<%= render 'admin/users/side_bar' %> <div class="site-map role-block">
<div class="map-block back">
<h4><span><%= t("admin.info")%></span></h4>
<div class="form-horizontal">
<div class="clear">
<div class="control-group pull-left">
<label class="control-label" for="key"><%= t("admin.key") %></label>
<div class="controls">
<% if @attribute.new_record? %>
<%= f.text_field :key,:placeholder=>"Key" %>
<% else %>
<div><%= @attribute.key%></div>
<% end %>
</div>
</div>
<%= render :partial=>"placeholder_block",:locals=>{:value=>@attribute.title_translations,:class_ext=>"pull-left",:label_ext=>t("admin.infos.item_name"),:field_name=>"info[title_translations]"}%>
</div>
</div>
</div>
<div class="map-block back attributes">
<h4><span><%= t("admin.attributes")%></span></h4>
<%= render :partial=>"attribute_field",:collection=>@attribute.attribute_fields%>
</div>
</div>
<div class="form-actions form-fixed pagination-right">
<%= link_to content_tag(:i,t("admin.infos.add_attribute_field"),:class=>"icon-plus icon-white"),admin_info_add_attribute_field_path(@attribute),:class=>"btn btn-primary",:remote => true%>
<%= f.submit t("admin.infos.save"),:class=>"btn btn-primary"%>
</div>
<% end %>
<% content_for :page_specific_css do -%>
<%= stylesheet_link_tag "member" %>
<%= stylesheet_link_tag "site-map" %>
<% end %> <% end %>
<div id="profile"> <% content_for :page_specific_javascript do -%>
<%= form_for @attribute, :url => eval("admin_#{@attribute_type}_path(@attribute)") do |f| %> <script>
<%= f.error_messages %> var CloneTarget ;
<%= render :partial => "admin/#{@attribute_type}s/form", :locals => { :f => f, :is_new => false } %>
<div class='button_bar'> var NewNode;
<%= link_back %>
<%= link_to t('update'), "#", :onclick=>"$('#edit_#{@attribute_type}_#{@attribute.id}').submit()" %> $(document).ready(function(){
</div> // function mas(){
<% end %> // $('.site-map').masonry({
</div> // itemSelector: '.map-block',
// columnWidth: 450,
// isAnimated: true
// });
// }
function checkSwitch() {
$(".groups").addClass('disabled').has('.groups > .form-horizontal > div:not(.hide)').removeClass('disabled');
}
function checkMultipleInput() {
$(".multipleInput").each(function() {
$(this).find('.controls').length==1 ? $(this).addClass("plural") : $(this).removeClass("plural")
});
}
function removeInput(){
$(".removeInput").live('click',function (){
$(this).parents(".controls").remove();
checkMultipleInput();
return false;
});
}
checkSwitch();
checkMultipleInput();
removeInput();
$(".remove_attribute").live('click',function(){
$(this).siblings(".attribute_field_to_delete").val("true");
$(this).parents(".form-horizontal").fadeOut("slow", function () { $(this).hide(); });
});
$(".help-block a").live('click',function (){
CloneTarget = $(this).parents(".controls").prev(".multipleInput").find('.controls:last');
NewNode = CloneTarget.clone();
var index;
NewNode.find("input").each(function(k,v){
index = CloneTarget.parents("div.control-group").find(".list_count").val()
field_name = CloneTarget.parents("div.control-group").find(".field_name").val()
ori_str = $(v).attr("name").replace(field_name,"");
lang = ori_str.match(/\[\D*\]/);
new_field_name = (field_name+"[" + (parseInt(index)+1) + "]" + lang);
$(v).attr("name",new_field_name);
})
$(this).parents("div.control-group").find(".list_count").val(parseInt(index)+1)
$(this).parents(".controls").prev(".multipleInput").append(NewNode);
$(this).parents(".controls").prev(".multipleInput").find('.controls:last input').val("");
removeInput();
checkMultipleInput();
return false;
})
$(".status select").each(function (i) {
$(this).change(function () {
$(".status option:selected").eq(i).each(function () {
if($(this).attr("value")=="alumna") {
$(this).parents(".status").nextAll(".graduated").removeClass("hide");
$(this).parents(".status").nextAll(".graduated").find("select").removeAttr("disabled");
}else{
$(this).parents(".status").nextAll(".graduated").addClass("hide");
$(this).parents(".status").nextAll(".graduated").find("select").attr({disabled:''});
}
});
})
})
$('.onoff').live('click',function () {
if($(this).parents("h4").length==1) {
$(this).parents(".map-block").toggleClass("disabled");
$(this).parents(".map-block").find(".form-horizontal").toggleClass("hide");
if($(this).parents(".map-block").hasClass("disabled")){
$(this).text("OFF");
}else{
$(this).text("ON");
}
}
if($(this).parents("legend").length==1) {
$(this).toggleClass("disabled");
$(this).parents("legend").next("div").toggleClass("hide");
if($(this).parents("legend").next("div").hasClass("hide")){
$(this).text("OFF");
$(this).siblings(".attribute_field_disabled").val("true");
}else{
$(this).text("ON");
$(this).siblings(".attribute_field_disabled").val("false");
}
checkSwitch();
}
return false;
});
$(".dataType").change(function () {
$(this).parents("legend").next("div").find("div[class^='type']").addClass("hide");
$(this).parents("legend").next("div").find("."+$(this).find("option:selected").attr("ref")).removeClass("hide");
})
});
</script>
<% end -%>

View File

@ -1,3 +1,100 @@
<%= f.fields_for :attribute_fields, attribute_field do |f| %> <div class="form-horizontal">
<%= render :partial => 'admin/attributes/attribute_field', :object => attribute_field, :locals => {:f => f} %> <legend>
<button class="onoff pull-right <%= attribute_field.disabled ? 'disabled' : ''%>">ON</button>
<%= hidden_field "info[attribute_fields][#{attribute_field_counter}]","disabled",:value=>attribute_field.disabled,:class=>"attribute_field_disabled"%>
<%= hidden_field "info[attribute_fields][#{attribute_field_counter}]","to_delete",:value=>false,:class=>"attribute_field_to_delete"%>
<a class="btn btn-small pull-right btn-danger remove_attribute" href="#"><i class="icon-trash icon-large"></i> <%= t("delete")%></a>
<div class="clear">
<div class="control-group pull-left">
<label class="control-label" for="key"><%= t("admin.key") %></label>
<div class="multipleInput">
<div class="controls">
<%= text_field "info[attribute_fields][#{attribute_field_counter}]","key",:value=>attribute_field.key%>
</div>
</div>
</div>
<%= render :partial=>"placeholder_block",:locals=>{:values=>attribute_field.title_translations,:class_ext=>"pull-left",:label_ext=>t("admin.infos.name"),:field_name=>"info[attribute_fields][#{attribute_field_counter}][title_translations]"}%>
<div class="control-group pull-left">
<label class="control-label" for=""><%= t("admin.infos.type")%></label>
<div class="controls">
<%#= select_tag "info[attribute_fields][#{attribute_field_counter}][markup]" do %>
<select class="dataType" name=<%= "info[attribute_fields][#{attribute_field_counter}][markup]"%>>
<%LIST[:markups].each do |key,val|%>
<option value="<%= key %>" <%= attribute_field.markup == key ? 'selected="selected"' : '' %> ref="<%=val["panel"]%>"><%=t("lists.markups."+key)%></option >
<% end %> <% end %>
</select>
</div>
</div>
</div>
</legend>
<div class="<%= attribute_field.disabled ? 'hide' : ''%>">
<%= content_tag :div,:class=>show_type_panel(attribute_field,"typeA") do%>
<div class="control-group">
<label class="control-label"><%= t("admin.infos.options")%></label>
<div class="controls">
<label class="checkbox inline">
<%= check_box_tag("info[attribute_fields][#{attribute_field_counter}][typeA][multilingual]","true",attribute_field["typeA"]["multilingual"]) %>
<%= t("admin.infos.multilingual")%>
</label>
<label class="checkbox inline">
<%= check_box_tag("info[attribute_fields][#{attribute_field_counter}][typeA][add_more]","true",attribute_field["typeA"]["add_more"]) %>
<%= t("admin.infos.add_more")%>
</label>
</div>
</div>
<%= render :partial=> "placeholder_block",:locals=>{:values=>attribute_field["typeA"]["placeholder"],:field_name=>"info[attribute_fields][#{attribute_field_counter}][typeA][placeholder]"}%>
<% end %>
<%= content_tag :div,:class=>show_type_panel(attribute_field,"typeB") do %>
<%= render :partial=> "placeholder_block",:locals=>{:label_ext=>t("admin.infos.initial"),:values=>attribute_field["typeB"]["initial"],:field_name=>"info[attribute_fields][#{attribute_field_counter}][typeB][initial]"}%>
<%= render :partial=>"list_block",:locals=>{:values=>attribute_field["option_list"],:field_name=> "info[attribute_fields][#{attribute_field_counter}][typeB][option_list]"} %>
<% end %>
<%= content_tag :div,:class=>show_type_panel(attribute_field,"typeC") do %>
<div class="control-group">
<label class="control-label"><%= t("admin.infos.date.format")%></label>
<div class="controls">
<%= select "info[attribute_fields][#{attribute_field_counter}][typeC]","format",Admin::AttributeValuesViewHelper::OPT,:class=>"dataType",:selected=>attribute_field["typeC"]["format"] %>
</div>
</div>
<div class="control-group">
<label class="control-label"><%= t("admin.infos.date.range")%></label>
<div class="controls">
<label class="radio inline">
<%= radio_button("info[attribute_fields][#{attribute_field_counter}][typeC]", "is_range", "false",:checked => (attribute_field["typeC"]["is_range"]== "false" ? true : false)) %><%= t("admin.infos.not_range")%>
</label>
<label class="radio inline">
<%= radio_button("info[attribute_fields][#{attribute_field_counter}][typeC]", "is_range", "true",:checked => (attribute_field["typeC"]["is_range"]== "true" ? true : false)) %><%= t("admin.infos.is_range")%>
</label>
</div>
</div>
<div class="control-group">
<label class="control-label"><%= t("admin.infos.date.claendar")%></label>
<div class="controls">
<label class="radio inline">
<%= radio_button("info[attribute_fields][#{attribute_field_counter}][typeC]", "claendar", "west_claendar",:checked =>(attribute_field["typeC"]["claendar"]== "west_claendar" ? true : false)) %><%= t("admin.infos.date.west_claendar")%>
</label>
<label class="radio inline">
<%= radio_button("info[attribute_fields][#{attribute_field_counter}][typeC]", "claendar", "tw_claendar",:checked =>(attribute_field["typeC"]["claendar"]== "tw_claendar" ? true : false)) %><%= t("admin.infos.date.tw_claendar")%>
</label>
</div>
</div>
<% end %>
<%= content_tag :div,:class=>show_type_panel(attribute_field,"typeD") do%>
<div class="control-group">
<label class="control-label"><%= t("admin.infos.options")%></label>
<div class="controls">
<label class="checkbox inline">
<%= check_box_tag("info[attribute_fields][#{attribute_field_counter}][typeD][multilingual]","true",attribute_field["typeD"]["multilingual"]) %>
<%= t("admin.infos.multilingual")%>
</label>
</div>
</div>
<%= render :partial=> "placeholder_block",:locals=>{:field_name=>"info[attribute_fields][#{attribute_field_counter}][typeD][placeholder]",:values=>attribute_field["typeD"]["placeholder"]} %>
<% end %>
<%= content_tag :div,:class=>show_type_panel(attribute_field,"typeE") do%>
<%= render :partial=>"list_block",:locals=>{:field_name=>"info[attribute_fields][#{attribute_field_counter}][typeE][option_list]",:values=>attribute_field["option_list"]}%>
<% end %>
</div>
<%= hidden_field "info[attribute_fields][#{attribute_field_counter}]","id",:value=>attribute_field.id%>
</div>

View File

@ -0,0 +1,45 @@
<% temp_field_name = field_name.gsub /\[\D*\]$/,'[temp]'%>
<div class="control-group">
<%= hidden_field_tag "#{temp_field_name}[count]",((values.keys.collect{|t| t.to_i}.max rescue nil) || 0 ),:class=>"list_count"%>
<%= hidden_field_tag "#{temp_field_name}[name]",field_name,:class=>"field_name"%>
<label class="control-label" ><%= t("admin.infos.list")%></label>
<div class="multipleInput">
<%if values.blank? %>
<div class="controls">
<% @site_valid_locales.each do |locale| %>
<% last = (locale == @site_valid_locales.last ? true : false) %>
<% p_value = value[locale.to_s] rescue nil%>
<%= content_tag :div,:class=>"input-append #{"unRadius" if last }" do%>
<%= text_field("#{field_name}[0]", locale,:placeholder=>t("langs.#{locale}")) %>
<% if last %>
<a href="#" class="btn removeInput" type="button"><i class="icon-trash"></i></a>
<% end %>
<% end %>
<% end %>
</div>
<%else%>
<%values.each do |index,value|%>
<div class="controls">
<% @site_valid_locales.each do |locale| %>
<% last = (locale == @site_valid_locales.last ? true : false) %>
<% p_value = value[locale.to_s] rescue nil%>
<%= content_tag :div,:class=>"input-append #{"unRadius" if last }" do%>
<%= text_field("#{field_name}[#{index}]", locale,:value=>p_value,:placeholder=>t("langs.#{locale}")) %>
<% if last %>
<a href="#" class="btn removeInput" type="button"><i class="icon-trash"></i></a>
<% end %>
<% end %>
<% end %>
</div>
<% end %>
<% end %>
</div>
<div class="controls">
<span class="help-block">
<a href="#"><i class="icon-plus-sign"></i><%= t("admin.infos.add") %></a>
</span>
</div>
</div>

View File

@ -0,0 +1,25 @@
<% values ||=[]%>
<%= content_tag :div,:class=>"control-group language-swich #{class_ext rescue "" }" do%>
<label class="control-label" for=""><%= (defined? label_ext) ? label_ext : t("admin.infos.placeholder") %></label>
<div class="controls">
<div class="tabbable">
<div class="tab-content">
<% @site_valid_locales.each do |locale| %>
<% active = (locale == @site_valid_locales.first ? "active in" : "'") %>
<%= content_tag :div,:class=>"tab-pane fade #{active}",:id=>"#{name_to_id(field_name)}_#{locale}" do%>
<% value = values[locale.to_s] rescue nil%>
<%= text_field(field_name, locale,:value=>value,:placeholder=>t("langs.#{locale}")) %>
<% end %>
<% end %>
</div>
<ul class="nav nav-pills ">
<% @site_valid_locales.each do |locale| %>
<% active = (locale == @site_valid_locales.first ? "active" : "'") %>
<%=content_tag :li,:class=>active do %>
<%= link_to t("langs.#{locale}"),"##{name_to_id(field_name)}_#{locale}",:data=>{:toggle=>"tab"}%>
<% end %>
<% end %>
</ul>
</div>
</div>
<% end %>

View File

@ -0,0 +1,6 @@
$(".attributes").append('<%= escape_javascript(render :partial=>"attribute_field",:locals=>{:attribute_field=>@attribute_field,:attribute_field_counter=>@attribute_field_counter} )%>');
$(".dataType").change(function () {
$(this).parents("legend").next("div").find("div[class^='type']").addClass("hide");
$(this).parents("legend").next("div").find("."+$(this).find("option:selected").attr("ref")).removeClass("hide");
})

View File

@ -14,7 +14,7 @@
<% end -%> <% end -%>
<%= content_tag :div,:class=>"user-role site-map" do%> <%= content_tag :div,:class=>"user-role site-map role-block" do%>
<%= form_for @user, :url => admin_users_new_interface_path(@user), :html => { :multipart => true } do |f| %> <%= form_for @user, :url => admin_users_new_interface_path(@user), :html => { :multipart => true } do |f| %>
<%= f.error_messages %> <%= f.error_messages %>

View File

@ -61,6 +61,18 @@
</ul> </ul>
</div> </div>
</div> </div>
<div class="hh2 hp sdm">
<div class="sdm_t hh2" id='ns'>New Share</div>
<div class="admbg sdm_o">
<ul>
<li><a class="hp hh2 admtxt remote_url" href="<%= panel_personal_journal_plugin_writing_journals_path %>">Full</a></li>
<li><a class="hp hh2 admtxt" href="">Abstract</a></li>
<li><a class="hp hh2 admtxt" href="">Friends</a></li>
<li><a class="hp hh2 admtxt" href="">Private</a></li>
<li><a class="hp hh2 admtxt" href="">Group</a></li>
</ul>
</div>
</div>
<div class="hh2 hp sdm"> <div class="hh2 hp sdm">
<div class="sdm_t hh2"><span class="icon-question-sign"></span></div> <div class="sdm_t hh2"><span class="icon-question-sign"></span></div>
</div> </div>
@ -73,3 +85,18 @@
</div> </div>
</div> </div>
</div> </div>
Panel::PersonalJournal::Plugin::WritingJournals
<script type="text/javascript">
orbitDesktop.prototype.bindItems = function(){
var bindHandlers = function(){
}
$(".remote_url").click(function(){
$(".overview").load($(this).attr("href"),function(){
bindHandlers();
})
return false;
})
}
o.bindItems();
</script>

View File

@ -0,0 +1,12 @@
<h4>Upload Widget Package </h4>
<div class="main2">
<%= form_tag '',:multipart => true,:action=>"post" do |f| %>
<p>
<%= file_field :desktop_widget,:package_file %>
</p>
<%= submit_tag %>
<% end %>
</div>

View File

@ -81,7 +81,7 @@
<% end -%> <% end -%>
<% end %> <% end %>
<%= content_tag :li, :class => active_for_controllers('archive_files', 'tags', 'archive_file_categorys') do -%> <%= content_tag :li, :class => active_for_controllers('archive_files', 'panel/archive/back_end/tags', 'archive_file_categorys') do -%>
<%= link_to content_tag(:i, nil, :class => 'icons-asset') + content_tag(:span, t('admin.archive')), panel_archive_back_end_archive_files_path %> <%= link_to content_tag(:i, nil, :class => 'icons-asset') + content_tag(:span, t('admin.archive')), panel_archive_back_end_archive_files_path %>
<%= content_tag :ul, :class => ("nav nav-list " + visible_for_controllers('archive_files', 'tags', 'archive_file_categorys')) do -%> <%= content_tag :ul, :class => ("nav nav-list " + visible_for_controllers('archive_files', 'tags', 'archive_file_categorys')) do -%>
<%= content_tag :li, link_to((t('admin.all_articles') + content_tag(:i, nil, :class => 'icon-chevron-right')).html_safe, panel_archive_back_end_archive_files_path), :class => active_for_action('archive_file', 'index') %> <%= content_tag :li, link_to((t('admin.all_articles') + content_tag(:i, nil, :class => 'icon-chevron-right')).html_safe, panel_archive_back_end_archive_files_path), :class => active_for_action('archive_file', 'index') %>
@ -91,14 +91,14 @@
<% end -%> <% end -%>
<% end -%> <% end -%>
<%= content_tag :li, :class => active_for_controllers('cals') || active_for_app_auth("calendar") do -%> <%= content_tag :li, :class => active_for_controllers('cals','panel/calendar/back_end/tags') || active_for_app_auth("calendar") do -%>
<%= link_to content_tag(:i, nil, :class => 'icons-calendar') + content_tag(:span, t('admin.calendar')), panel_calendar_back_end_cals_path %> <%= link_to content_tag(:i, nil, :class => 'icons-calendar') + content_tag(:span, t('admin.calendar')), panel_calendar_back_end_cals_path %>
<%= content_tag :ul, :class => ("nav nav-list " + visible_for_controllers('cals','calendar_categories') ) do -%> <%= content_tag :ul, :class => ("nav nav-list " + visible_for_controllers('cals','calendar_categories') ) do -%>
<%#= content_tag :li, link_to(t('admin.ad.all_banners'), admin_ad_banners_path), :class => active_for_action('ad_banners', 'index') %> <%#= content_tag :li, link_to(t('admin.ad.all_banners'), admin_ad_banners_path), :class => active_for_action('ad_banners', 'index') %>
<%#= content_tag :li, link_to(t('admin.ad.new_banner'), new_admin_ad_banner_path), :class => active_for_action('ad_banners', 'new') %> <%#= content_tag :li, link_to(t('admin.ad.new_banner'), new_admin_ad_banner_path), :class => active_for_action('ad_banners', 'new') %>
<%#= content_tag :li, link_to(t('admin.ad.new_image'), new_ad_image_admin_ad_banners_path), :class => active_for_action('ad_images', 'new') %> <%#= content_tag :li, link_to(t('admin.ad.new_image'), new_ad_image_admin_ad_banners_path), :class => active_for_action('ad_images', 'new') %>
<%= content_tag :li, link_to((t('calendar.calendars') + content_tag(:i, nil, :class => 'icon-chevron-right')).html_safe, new_panel_calendar_back_end_cal_path), :class => active_for_action('cals','new') %> <%= content_tag :li, link_to((t('admin.calendars') + content_tag(:i, nil, :class => 'icon-chevron-right')).html_safe, new_panel_calendar_back_end_cal_path), :class => active_for_action('cals','new') %>
<%#= content_tag :li, link_to(t('gallery.tags'), panel_gallery_back_end_tags_path), :class => active_for_action('/panel/gallery/back_end/tags', 'index') %> <%= content_tag :li, link_to(t('admin.tags'), panel_calendar_back_end_tags_path), :class => active_for_action('/panel/calendar/back_end/tags', 'index') %>
<%#= content_tag :li, link_to(t('admin.module.authorization'),admin_module_app_manager_auth_proc_path(ModuleApp.first(conditions: {key: "gallery"}))), :class => active_for_app_auth('gallery') if (is_admin? rescue nil) %> <%#= content_tag :li, link_to(t('admin.module.authorization'),admin_module_app_manager_auth_proc_path(ModuleApp.first(conditions: {key: "gallery"}))), :class => active_for_app_auth('gallery') if (is_admin? rescue nil) %>
<% end -%> <% end -%>
<% end %> <% end %>

View File

@ -0,0 +1,13 @@
<div class="modal hide fade" id="address-edit" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true" style="display: none; ">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
<h3 id="myModalLabel">Modal header</h3>
</div>
<div class="modal-body">
<p>One fine body…</p>
</div>
<div class="modal-footer">
<button class="btn" data-dismiss="modal" aria-hidden="true">Close</button>
<button class="btn btn-primary">Save changes</button>
</div>
</div>

View File

@ -33,6 +33,7 @@ module Orbit
config.autoload_paths += %W(#{config.root}/app/models/meta) config.autoload_paths += %W(#{config.root}/app/models/meta)
config.autoload_paths += %W(#{config.root}/app/models/purchase) config.autoload_paths += %W(#{config.root}/app/models/purchase)
config.autoload_paths += %W(#{config.root}/app/models/user) config.autoload_paths += %W(#{config.root}/app/models/user)
config.autoload_paths += %W(#{config.root}/app/models/desktop)
# Include all helpers # Include all helpers
# 'helper :all' must be removed in ApplicationController # 'helper :all' must be removed in ApplicationController

View File

@ -9,21 +9,27 @@ markups:
text_field: text_field:
muti_lang_input_supprt: true muti_lang_input_supprt: true
ext_support: true ext_support: true
panel: typeA
select: select:
muti_lang_input_supprt: false muti_lang_input_supprt: false
ext_support: false ext_support: false
panel: typeB
date: date:
muti_lang_input_supprt: false muti_lang_input_supprt: false
ext_support: false ext_support: false
panel: typeC
text_area: text_area:
muti_lang_input_supprt: true muti_lang_input_supprt: true
ext_support: false ext_support: false
panel: typeD
radio_button: radio_button:
muti_lang_input_supprt: false muti_lang_input_supprt: false
ext_support: false ext_support: false
panel: typeE
checkbox: checkbox:
muti_lang_input_supprt: false muti_lang_input_supprt: false
ext_support: false ext_support: false
panel: typeE
# date_durnation: # date_durnation:
# muti_lang_input_supprt: false # muti_lang_input_supprt: false
# ext_support: false # ext_support: false

View File

@ -158,6 +158,14 @@ en:
user: Users list user: Users list
list_: List list_: List
list_lower: list list_lower: list
lists:
markups:
text_field: Text Field
select: Select
date: Date
text_area: Text Area
radio_button: Radio button
checkbox: Checkbox
login: Login login: Login
logout: Logout logout: Logout
mail: mail:
@ -407,7 +415,7 @@ en:
attributes: Attributes attributes: Attributes
author: Author author: Author
calendar: Calendar calendar: Calendar
gprs: GPRS gprs: GPS
cant_delete_self: You can not delete yourself. cant_delete_self: You can not delete yourself.
cant_revoke_self_admin: You can not revoke your admin role yourself. cant_revoke_self_admin: You can not revoke your admin role yourself.
category: Category category: Category

View File

@ -158,6 +158,14 @@ zh_tw:
user: 使用者列表 user: 使用者列表
list_: 列表 list_: 列表
list_lower: 列表 list_lower: 列表
lists:
markups:
text_field: 文字輸入框
select: 下拉選單
date: 日期
text_area: 文字輸入方塊
radio_button: 單選
checkbox: 多選
login: 登入 login: 登入
logout: 登出 logout: 登出
mail: mail:
@ -342,8 +350,30 @@ zh_tw:
# : ======= # : =======
errors: errors:
at_least_one: 必須至少有一個值 at_least_one: 必須至少有一個值
admin: admin:
infos:
add_attribute_field: 新增
save: 儲存
initial: 起始值
markup: 輸入模式
item_name: 資料表名稱
name: 名稱
options: 選項
multilingual: 多語言輸入
add_more: 使用者可自行延伸欄位
add: 新增
placeholder: 輸入協助
type: 類型
placeholder: 提示內容
list: 自定選單
is_range:
not_range:
date:
claendar: 紀年法
range: 本欄為時間區段
format: 格式
tw_claendar: 民國
west_claendar: 西元
access: access:
denied: denied:
app: app:

View File

@ -141,7 +141,17 @@ Orbit::Application.routes.draw do
resources :users resources :users
end end
match '/desktop/'=>'desktop#index' resources :desktop_widgets do
collection do
get 'upload'
get 'delete'
post 'upload'
end
end
namespace :desktop do
match "/"=>"desktop#index"
# Sinatra Routes start # Sinatra Routes start
@ -176,46 +186,50 @@ Orbit::Application.routes.draw do
# Sinatra Routes end # Sinatra Routes end
match '/desktop/desktop'=>'desktop#desktop' match '/desktop'=>'desktop#desktop'
match '/desktop/app_manager'=>'desktop#app_manager' match '/app_manager'=>'desktop#app_manager'
match '/desktop/sections'=>'desktop#sections' match '/sections'=>'desktop#sections'
match '/desktop/settings'=>'desktop#settings' match '/settings'=>'desktop#settings'
match '/desktop/get_desktop_settings/'=>'desktop#get_desktop_settings' match '/get_desktop_settings/'=>'desktop#get_desktop_settings'
match '/desktop/save_desktop_settings/'=>'desktop#save_desktop_settings' match '/save_desktop_settings/'=>'desktop#save_desktop_settings'
match '/desktop/getgroups/'=>'desktop#getgroups' match '/getgroups/'=>'desktop#getgroups'
match '/desktop/getsectionlist/'=>'desktop#getsectionlist' match '/getsectionlist/'=>'desktop#getsectionlist'
match '/desktop/settingthemes/'=>'desktop#settingthemes' match '/settingthemes/'=>'desktop#settingthemes'
match '/desktop/settingsections/'=>'desktop#settingsections' match '/settingsections/'=>'desktop#settingsections'
match '/desktop/getapplist/'=>'desktop#getapplist' match '/getapplist/'=>'desktop#getapplist'
match '/desktop/newpositions/'=>'desktop#newpositions' match '/newpositions/'=>'desktop#newpositions'
match '/desktop/settingconnection/'=>'desktop#settingconnection' match '/settingconnection/'=>'desktop#settingconnection'
match '/widget_layout' => 'desktop#widget_layout'
match '/desktop/journal_p/'=>'desktop_publications#journal_p' match '/journal_p/'=>'desktop_publications#journal_p'
match '/desktop/journal_p_list/'=>'desktop_publications#journal_p_list' match '/journal_p_list/'=>'desktop_publications#journal_p_list'
match '/desktop/journal_p_add/'=>'desktop_publications#journal_p_add' match '/journal_p_add/'=>'desktop_publications#journal_p_add'
match '/desktop_publications/getjournals' => 'desktop_publications#getjournals' match '/books' => 'desktop_publications#books'
match '/desktop/books' => 'desktop_publications#books' match '/books_list/'=>'desktop_publications#books_list'
match '/desktop/books_list/'=>'desktop_publications#books_list' match '/books_add/'=>'desktop_publications#books_add'
match '/desktop/books_add/'=>'desktop_publications#books_add'
match '/desktop/seminar_p' => 'desktop_publications#seminar_p' match '/seminar_p' => 'desktop_publications#seminar_p'
match '/desktop/seminar_p_list/'=>'desktop_publications#seminar_p_list' match '/seminar_p_list/'=>'desktop_publications#seminar_p_list'
match '/desktop/seminar_p_add/'=>'desktop_publications#seminar_p_add' match '/seminar_p_add/'=>'desktop_publications#seminar_p_add'
match '/desktop/research_d' => 'desktop_research#research_d' match '/research_d' => 'desktop_research#research_d'
match '/desktop/research_d_list/' => 'desktop_research#research_d_list' match '/research_d_list/' => 'desktop_research#research_d_list'
match '/desktop/research_d_add' => 'desktop_research#research_d_add' match '/research_d_add' => 'desktop_research#research_d_add'
match '/desktop/research_p' => 'desktop_research#research_p' match '/research_p' => 'desktop_research#research_p'
match '/desktop/research_p_list/' => 'desktop_research#research_p_list' match '/research_p_list/' => 'desktop_research#research_p_list'
match '/desktop/research_p_add' => 'desktop_research#research_p_add' match '/research_p_add' => 'desktop_research#research_p_add'
match '/desktop/twitter/'=>'otheraccounts#twitter'
match '/desktop/forgmail/'=>'otheraccounts#gmail' match '/temp_func/'=>'desktop#temp_func'
match '/desktop/getaccounts'=>'otheraccounts#getaccounts' end
match '/desktop/save_account_info/'=>'otheraccounts#saveaccountinfo'
match '/twitter/'=>'otheraccounts#twitter'
match '/forgmail/'=>'otheraccounts#gmail'
match '/getaccounts'=>'otheraccounts#getaccounts'
match '/save_account_info/'=>'otheraccounts#saveaccountinfo'
match '/desktop_appstore/appstore'=>'desktop_appstore#appstore' match '/desktop_appstore/appstore'=>'desktop_appstore#appstore'
match '/desktop_appstore/widgets'=>'desktop_appstore#widgets' match '/desktop_appstore/widgets'=>'desktop_appstore#widgets'
@ -226,13 +240,14 @@ Orbit::Application.routes.draw do
match '/desktop_orbit/eventajaxload'=> 'desktop_orbit#eventajaxload' match '/desktop_orbit/eventajaxload'=> 'desktop_orbit#eventajaxload'
match '/desktop_orbit/gettimelinespan' => 'desktop_orbit#gettimelinespan' match '/desktop_orbit/gettimelinespan' => 'desktop_orbit#gettimelinespan'
match '/desktop_publications/getjournals' => 'desktop_publications#getjournals'
#match '/desktop_orbit/eventajaxload' => 'desktop_publications#create_journal' #match '/desktop_orbit/eventajaxload' => 'desktop_publications#create_journal'
#match '/desktop_orbit/eventajaxload' => 'desktop_publications#delete_journal' #match '/desktop_orbit/eventajaxload' => 'desktop_publications#delete_journal'
# match '/desktop_orbit/eventajaxload' => 'desktop_publications#update_journal' # match '/desktop_orbit/eventajaxload' => 'desktop_publications#update_journal'
match '/desktop/temp_func/'=>'desktop#temp_func'
match '/panel/:app_name/front_end/:app_action/:id(/:controller_action)' => 'pages#show_from_link', :constraints => lambda { |request| match '/panel/:app_name/front_end/:app_action/:id(/:controller_action)' => 'pages#show_from_link', :constraints => lambda { |request|
!request.query_string.include?("inner=true") !request.query_string.include?("inner=true")

View File

@ -0,0 +1,22 @@
module ParserLayoutWidget
require 'nokogiri'
def parse_widget_for_images(widget)
content = widget.widget_layout.file.read.force_encoding("UTF-8")
widge = Nokogiri::HTML(content)
a = []
b = []
widge.css('.widget_image').each do |page_image|
image = widget.images.where( file: File.basename(page_image['src']))[0]
a << page_image['src']
b << image.file
image.update_attributes(:html_id => page_image['id'], :html_class => page_image['class'], :in_html => true) if image
end
a.each_with_index do |img,i|
content = content.gsub(img,b[i].to_s)
end
widget.widget_layout.update_attributes(:body => content)
end
end

Binary file not shown.

Before

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 16 KiB

View File

@ -1,69 +0,0 @@
.clock{
/* The .clock div. Created dynamically by jQuery */
/*background-color:#252525;*/
height:200px;
width:200px;
position:relative;
overflow:hidden;
float:left;
}
.clock .rotate{
/* There are two .rotate divs - one for each half of the background */
position:absolute;
width:200px;
height:200px;
top:0;
left:0;
}
.rotate.right{
display:none;
z-index:11;
}
.clock .bg, .clock .front{
width:100px;
height:200px;
/*background-color:#252525;*/
position:absolute;
top:0;
}
.clock .display{
/* Holds the number of seconds, minutes or hours respectfully */
position:absolute;
width:200px;
font-family:"Lucida Sans Unicode", "Lucida Grande", sans-serif;
z-index:20;
color:#F5F5F5;
font-size:60px;
text-align:center;
top:65px;
left:0;
/* CSS3 text shadow: */
text-shadow:4px 4px 5px #333333;
}
/* The left part of the background: */
.clock .bg.left{ left:0; }
/* Individual styles for each color: */
.orange .bg.left{ background:url(bg_orange.png) no-repeat left top; }
.green .bg.left{ background:url(bg_green.png) no-repeat left top; }
.blue .bg.left{ background:url(bg_blue.png) no-repeat left top; }
/* The right part of the background: */
.clock .bg.right{ left:100px; }
.orange .bg.right{ background:url(bg_orange.png) no-repeat right top; }
.green .bg.right{ background:url(bg_green.png) no-repeat right top; }
.blue .bg.right{ background:url(bg_blue.png) no-repeat right top; }
.clock .front.left{
left:0;
z-index:10;
}

View File

@ -1,45 +0,0 @@
<style type="text/css">
.g_weather { position: relative; height: 198px; }
.g_weather img { float: left; display: block; margin: 0; padding: 12px; }
.g_weather .gw_recent {
overflow: hidden;
height: 96%;
padding-top: 4%;
}
.g_weather .gw_weekly { display: none; }
.g_weather .gw_location {
position: absolute;
left: 0;
bottom: 0;
font-size: 15px;
line-height: 20px;
}
.g_weather .gw_condition_des { font-size: 22px; }
.g_weather .gw_temp { margin-top: 26px; }
.g_weather .gw_temp_num { font-size: 56px; }
.g_weather .gw_temp_unit { font-size: 26px; }
.g_weather .gw_forecast {
position: absolute;
right: 0;
bottom: 0;
font-size: 13px;
line-height: 20px;
}
</style>
<div class="g_weather">
<div class="gw_recent">
<img src="desktop_widgets/4fa7817cc88514014d7c59c2/img/sunny.png" alt="sunny" class="gw_condition">
<div class="gw_temp">
<span class="gw_temp_num thmtxt">29</span><span class="gw_temp_unit thmtxt">°C</span>
</div>
<div class="gw_condition_des thmtxt">Sunny</div>
</div>
<div class="gw_weekly">
weekly report
</div>
<div class="gw_location thmtxt">Hsin-Chu</div>
<a href="" class="gw_forecast thmtxt">> Weekly Report</a>
</div>
<script type="text/javascript">
g_weather();
</script>

View File

@ -0,0 +1 @@
/* No Css */

View File

@ -0,0 +1,6 @@
{
"author" : "Harry",
"name" : "Browser",
"shape" : "w2 h1",
"version" : "1.0"
}

View File

@ -1,5 +1,3 @@
<link href="http://fonts.googleapis.com/css?family=Rationale|Orbitron" rel="stylesheet" type="text/css">
<style>
.clock{ .clock{
/* The .clock div. Created dynamically by jQuery */ /* The .clock div. Created dynamically by jQuery */
background-color:#111; background-color:#111;
@ -74,8 +72,3 @@
left: 50%; left: 50%;
margin: -36px 0 0 -114px; margin: -36px 0 0 -114px;
} }
</style>
<div id="fancyClock"></div>
<script>
$('#fancyClock').tzineClock();
</script>

View File

Before

Width:  |  Height:  |  Size: 9.4 KiB

After

Width:  |  Height:  |  Size: 9.4 KiB

View File

Before

Width:  |  Height:  |  Size: 6.7 KiB

After

Width:  |  Height:  |  Size: 6.7 KiB

View File

Before

Width:  |  Height:  |  Size: 9.5 KiB

After

Width:  |  Height:  |  Size: 9.5 KiB

View File

@ -0,0 +1,7 @@
{
"author" : "Harry",
"name" : "Clock",
"shape" : "w2 h1",
"version" : "1.0"
}

View File

@ -0,0 +1,5 @@
<link href="http://fonts.googleapis.com/css?family=Rationale|Orbitron" rel="stylesheet" type="text/css">
<div id="fancyClock"></div>
<script>
$('#fancyClock').tzineClock();
</script>

View File

@ -1,4 +1,3 @@
<style>
#search{border-radius: 5px; margin:10px;margin-top:25px;} #search{border-radius: 5px; margin:10px;margin-top:25px;}
input { input {
border:none; border:none;
@ -19,16 +18,3 @@ input {
color: #222; color: #222;
text-shadow: 0px 1px 1px #555; text-shadow: 0px 1px 1px #555;
} }
</style>
<center>
<form id="search">
<img src="desktop_widgets/4fa78140c88514014d7c59be/img/google_64.png" style='margin-right:10px;'><br />
<input id="googlesearch">
<input type="submit" style="display:none;">
<br>
<span id="eric">Powered by Eric</span>
</form>
</center>
<script>
search();
</script>

View File

Before

Width:  |  Height:  |  Size: 5.3 KiB

After

Width:  |  Height:  |  Size: 5.3 KiB

View File

@ -0,0 +1,7 @@
{
"author" : "Eric",
"name" : "Google Search",
"shape" : "w2 h1",
"version" : "1.0"
}

View File

@ -0,0 +1,13 @@
<center>
<form id="search">
<img src="desktop_widgets/4fa78140c88514014d7c59be/img/google_64.png" style='margin-right:10px;' class="widget_image"><br />
<input id="googlesearch">
<input type="submit" style="display:none;">
<br>
<span id="eric">Powered by Eric</span>
</form>
</center>
<script>
search();
</script>

View File

@ -0,0 +1,26 @@
.g_weather { position: relative; height: 198px; }
.g_weather img { float: left; display: block; margin: 0; padding: 12px; }
.g_weather .gw_recent {
overflow: hidden;
height: 96%;
padding-top: 4%;
}
.g_weather .gw_weekly { display: none; }
.g_weather .gw_location {
position: absolute;
left: 0;
bottom: 0;
font-size: 15px;
line-height: 20px;
}
.g_weather .gw_condition_des { font-size: 22px; }
.g_weather .gw_temp { margin-top: 26px; }
.g_weather .gw_temp_num { font-size: 56px; }
.g_weather .gw_temp_unit { font-size: 26px; }
.g_weather .gw_forecast {
position: absolute;
right: 0;
bottom: 0;
font-size: 13px;
line-height: 20px;
}

View File

Before

Width:  |  Height:  |  Size: 2.2 KiB

After

Width:  |  Height:  |  Size: 2.2 KiB

View File

@ -0,0 +1,7 @@
{
"author" : "Devin",
"name" : "Weather",
"shape" : "w2 h2",
"version" : "0.0"
}

View File

@ -0,0 +1,17 @@
<div class="g_weather">
<div class="gw_recent">
<img src="desktop_widgets/4fa7817cc88514014d7c59c2/img/sunny.png" alt="sunny" class="gw_condition widget_image">
<div class="gw_temp">
<span class="gw_temp_num thmtxt">29</span><span class="gw_temp_unit thmtxt">°C</span>
</div>
<div class="gw_condition_des thmtxt">Sunny</div>
</div>
<div class="gw_weekly">
weekly report
</div>
<div class="gw_location thmtxt">Hsin-Chu</div>
<a href="" class="gw_forecast thmtxt">> Weekly Report</a>
</div>
<script type="text/javascript">
g_weather();
</script>

View File

@ -0,0 +1,78 @@
#encoding: UTF-8
require 'spec_helper'
describe AttributeFieldsHelper do
describe "#attribute_field" do
context "In the HTML,there should always be 'value' tag in it's name"
before(:all) do
@user = User.where(email:'chris@rulingcom.com').first
end #end before
# binding.pry
LIST[:markups].each do |markup|
it "should have 'value' when it's #{markup[0]} (no locale)" do
title = "標題"
pre_set_markup_value = case markup[0]
when "select","checkbox","radio_button"
'{"1"=>{"en"=>"Male", "zh_tw"=>"男性"}, "2"=>{"en"=>"Female", "zh_tw"=>"女性"}, "3"=>{"en"=>"Not public", "zh_tw"=>"不公開"}}'
else
nil
end
attribute_field=AttributeField.find_or_create_by(key:'Test',markup: markup[0],markup_value: pre_set_markup_value,:title=>title)
html = attribute_field.block_helper(@user,1)
nodes = Nokogiri::HTML.fragment(html).search('*[@func="input_unit"]')
nodes.each do |input|
attri = input.attributes["name"]
attri = input.children().first.attributes["name"] if (markup[0] == 'checkbox' || markup[0] == 'radio_button' )
attri.to_s.should match /user\[.*attribute_values\]\[\d*\]\[value\].*/
# user[attribute_values][1][id]
# user[attribute_values][1][value][en]
end #end of input loop
end # end of it
end #end markups
LIST[:markups].each do |markup|
if markup[1]["muti_lang_input_supprt"]
[true,false].each do |locale_sat|
title = locale_sat ? {"en"=>"Title", "zh_tw"=>"標題"} : "標題"
it "should have 'value' when it's #{markup[0]} for locale => #{locale_sat}" do
pre_set_markup_value = case markup[0]
when "select","checkbox","radio_button"
'{"1"=>{"en"=>"Male", "zh_tw"=>"男性"}, "2"=>{"en"=>"Female", "zh_tw"=>"女性"}, "3"=>{"en"=>"Not public", "zh_tw"=>"不公開"}}'
else
nil
end
if (markup[0] == "text_field" || markup[0] == "text_area") && (locale_sat == false)
# binding.pry
end
attribute_field=AttributeField.find_or_create_by(key:'Test',markup: markup[0],markup_value: pre_set_markup_value,:title=>title,:locale => locale_sat)
html = attribute_field.block_helper(@user,1)
# p html
nodes = Nokogiri::HTML.fragment(html).search('*[@func="input_unit"]')
nodes.each do |input|
input.attributes["name"].to_s.should match /user\[.*attribute_values\]\[\d*\]\[value\].*/
# user[attribute_values][1][id]
# user[attribute_values][1][value][en]
end #end of input loop
nodes = Nokogiri::HTML.fragment(html).search('*[@func="field_label"]')
nodes.each do |input|
# p input.to_s
# binding.pry if
input.children.text.should match "標題"
end # end of field_label loop
end # end of it
end # end of T/F
end# end of if support
end #end markups
end
end

View File

@ -1,218 +1,218 @@
require 'spec_helper' # require 'spec_helper'
require 'ruby-debug' # require 'ruby-debug'
describe AppAuth do # describe AppAuth do
before do # before do
User.all.destroy # User.all.destroy
Role.all.destroy # Role.all.destroy
SubRole.all.destroy # SubRole.all.destroy
AppAuth.all.destroy # AppAuth.all.destroy
ModuleApp.all.destroy # ModuleApp.all.destroy
#Create some fixtures of Main Role # #Create some fixtures of Main Role
main_role_key = ["Stud","Teacher","Staff"] # main_role_key = ["Stud","Teacher","Staff"]
@new_main_role_list = main_role_key.each do |role| # @new_main_role_list = main_role_key.each do |role|
new_role = Role.new :key => role # new_role = Role.new :key => role
new_role.save # new_role.save
end
#Create Some SubRoles
sub_role_key = ["graduated_school","undergraduated_school","TA","Senior"]
@new_main_role_list = sub_role_key.each do |role|
new_role = SubRole.new :key => role
new_role.save
end
#Create some users of User
user_emails = ["a_good_ug_stud_1","a_good_ug_stud_2","a_bad_ug_stud","a_good_g_stud","a_bad_g_stud","a_teacher","a_staff"]
user_emails.each do |user_email|
email=user_email+"@rulingcom.com"
new_user = User.new :email=> email
new_user.save
end
#MRK = Member Role Key SRK=Sub Role Key
@stud_MRK = Role.first(conditions:{key:"Stud"})
@teacher_MRK = Role.first(conditions:{key:"Teacher"})
@staff_MRK = Role.first(conditions:{key:"Staff"})
@graduated_SRK = SubRole.first(conditions:{key:"graduated_school"})
@under_graduated_SRK = SubRole.first(conditions:{key:"undergraduated_school"})
@ta_SRK = SubRole.first(conditions:{key:"TA"})
@senior_SRK = SubRole.first(conditions:{key:"Senior"})
@stud_MRK.sub_roles += [@graduated,@under_graduated,@ta]
@stud_MRK.save!
@teacher_MRK.sub_roles = [@senior]
@teacher_MRK.save!
@good_ug_stu_1 = User.first(conditions:{email:"a_good_ug_stud_1@rulingcom.com"})
@good_ug_stu_2 = User.first(conditions:{email:"a_good_ug_stud_2@rulingcom.com"})
@bad_ug_stu = User.first(conditions:{email:"a_bad_ug_stud@rulingcom.com"})
@good_g_stu = User.first(conditions:{email:"a_good_g_stud@rulingcom.com"})
@bad_g_stu = User.first(conditions:{email:"a_bad_g_stud@rulingcom.com"})
@teacher = User.first(conditions:{email:"a_teacher@rulingcom.com"})
@staff = User.first(conditions:{email:"a_staff@rulingcom.com"})
#setting Roles for users
@good_g_stu.role = @stud_MRK
@bad_g_stu.role = @stud_MRK
@good_ug_stu_1.role = @stud_MRK
@good_ug_stu_2.role = @stud_MRK
@bad_ug_stu.role = @stud_MRK
@good_g_stu.sub_roles = [@graduated_SRK,@ta_SRK]
@bad_g_stu.sub_roles << @graduated_SRK
@good_ug_stu_1.sub_roles << @under_graduated_SRK
@good_ug_stu_2.sub_roles << @under_graduated_SRK
@bad_ug_stu.sub_roles << @under_graduated_SRK
@teacher.role = @teacher_MRK
@staff.role = @staff_MRK
@good_g_stu.save!
@bad_g_stu.save!
@good_ug_stu_1.save!
@good_ug_stu_2.save!
@bad_ug_stu.save!
@teacher.save!
@staff.save!
end
describe "Starting a ClassBulletin Auth for teacher , staff and ta" do
before do
@bulletin_app_auth = AppAuth.new()
#all teacher and staff has access right
@bulletin_app_auth.roles = [@teacher_MRK,@staff_MRK]
#all person with TA sub_role has access right
@bulletin_app_auth.sub_roles << @ta_SRK
#a_bad_ug_stud add to block to bulletin_app_auth
#@bulletin_app_auth.blocked_users << @bad_ug_stu
#all teacher has access right
# @bulletin_app_auth.roles << @teacher_MRK
# @bulletin_app_auth.privilege_users << @staff
@bulletin_app_auth.save!
end
context "Should just initialize all obj that is needed" do
it "Testing @bulletin_app_auth init result" do
@bulletin_app_auth.roles.should have(2).item #teacher staff
@bulletin_app_auth.sub_roles.should have(1).item #ta
end
it "@bulletin_app_auth should have Roles: Staff , Teacher " do
key_ary = @bulletin_app_auth.roles.collect do |role|
role.key
end
key_ary.sort.should == ["Staff","Teacher"].sort
end
it "bulletin_app_auth should have 3 auth users" do
user_ary = [@teacher,@staff,@good_g_stu]
@bulletin_app_auth.auth_users.sort.should == user_ary.sort
check_user_has_app user_ary
end
it "Adding a undergraduate stud into app_auth by privilege list" do
user_ary = [@teacher,@staff,@good_g_stu,@good_ug_stu_1]
@bulletin_app_auth.add_user_to_privilege_list @good_ug_stu_1
@bulletin_app_auth.auth_users.sort.should == user_ary.sort
check_user_has_app user_ary
end
it "Adding all graudated-stud into app_auth" do
user_ary = [@teacher,@staff,@good_g_stu,@bad_g_stu]
@bulletin_app_auth.add_sub_role @graduated_SRK
@bulletin_app_auth.auth_users.sort.should == user_ary.sort
check_user_has_app user_ary
end
it "Blocking bad-graduate student" do
user_ary =[@teacher,@staff,@good_g_stu]
@bulletin_app_auth.add_sub_role @graduated_SRK
@bulletin_app_auth.add_user_to_black_list @bad_g_stu
@bulletin_app_auth.auth_users_after_block_list.sort.should == user_ary.sort
check_user_has_app user_ary
end
it "Removing all graudated-stud from app_auth" do
user_ary =[@teacher,@staff,@good_g_stu]
@bulletin_app_auth.add_sub_role @graduated_SRK
@bulletin_app_auth.remove_sub_role @graduated_SRK
@bulletin_app_auth.auth_users.sort.should == user_ary.sort
check_user_has_app user_ary
end
# it "@bulletin_app_auth should have one Privialage user which is belongs to Staff" do
# p_user_ary = @bulletin_app_auth.privilege_users.collect do |p_user|
# p_user.roles.key
# end # end
# p_user_ary.should include("Staff") # #Create Some SubRoles
# sub_role_key = ["graduated_school","undergraduated_school","TA","Senior"]
# @new_main_role_list = sub_role_key.each do |role|
# new_role = SubRole.new :key => role
# new_role.save
# end # end
# it "@bulletin_app_auth should have one student listed at blocklist" do # #Create some users of User
# @bad_stu = User.first(conditions:{email:"a_bad_g_stud@rulingcom.com"}) # user_emails = ["a_good_ug_stud_1","a_good_ug_stud_2","a_bad_ug_stud","a_good_g_stud","a_bad_g_stud","a_teacher","a_staff"]
# @bulletin_app_auth.blocked_users.should have(1).item
# @bulletin_app_auth.blocked_users.should include(@bad_stu)
# end
# it "[Development #1]-1.Authorizing roles: roles + blocklist" do
# @good_stu = User.first(conditions:{email:"a_good_g_stud@rulingcom.com"})
# @teacher = User.first(conditions:{email:"a_teacher@rulingcom.com"})
# @staff = User.first(conditions:{email:"a_staff@rulingcom.com"})
# ary = [@good_stu,@teacher,@staff]
# @bulletin_app_auth.auth_users_after_block_list.should == ary
# end
#
# it "[Development #1]-2.Authorizing single users: list of users [new_user1~2]" do
# user_emails = ["new_user1","new_user2","new_user3","new_user4"]
# user_emails.each do |user_email| # user_emails.each do |user_email|
# email=user_email+"@rulingcom.com" # email=user_email+"@rulingcom.com"
# new_user = User.new :email=> email # new_user = User.new :email=> email
# new_user.save # new_user.save
# end # end
# user1= User.first(conditions:{email:"new_user1@rulingcom.com"}) # #MRK = Member Role Key SRK=Sub Role Key
# user2= User.first(conditions:{email:"new_user2@rulingcom.com"}) # @stud_MRK = Role.first(conditions:{key:"Stud"})
# user3= User.first(conditions:{email:"new_user3@rulingcom.com"}) # @teacher_MRK = Role.first(conditions:{key:"Teacher"})
# user4= User.first(conditions:{email:"new_user4@rulingcom.com"}) # @staff_MRK = Role.first(conditions:{key:"Staff"})
#
# @bulletin_app_auth.privilege_users << user1 # @graduated_SRK = SubRole.first(conditions:{key:"graduated_school"})
# @bulletin_app_auth.privilege_users << user2 # @under_graduated_SRK = SubRole.first(conditions:{key:"undergraduated_school"})
# # @ta_SRK = SubRole.first(conditions:{key:"TA"})
# @bulletin_app_auth.auth_users_after_block_list.should include(user1,user2) # @senior_SRK = SubRole.first(conditions:{key:"Senior"})
# @bulletin_app_auth.auth_users_after_block_list.should_not include(user3,user4)
# # @stud_MRK.sub_roles += [@graduated,@under_graduated,@ta]
# @stud_MRK.save!
# @teacher_MRK.sub_roles = [@senior]
# @teacher_MRK.save!
# @good_ug_stu_1 = User.first(conditions:{email:"a_good_ug_stud_1@rulingcom.com"})
# @good_ug_stu_2 = User.first(conditions:{email:"a_good_ug_stud_2@rulingcom.com"})
# @bad_ug_stu = User.first(conditions:{email:"a_bad_ug_stud@rulingcom.com"})
# @good_g_stu = User.first(conditions:{email:"a_good_g_stud@rulingcom.com"})
# @bad_g_stu = User.first(conditions:{email:"a_bad_g_stud@rulingcom.com"})
# @teacher = User.first(conditions:{email:"a_teacher@rulingcom.com"})
# @staff = User.first(conditions:{email:"a_staff@rulingcom.com"})
# #setting Roles for users
# @good_g_stu.role = @stud_MRK
# @bad_g_stu.role = @stud_MRK
# @good_ug_stu_1.role = @stud_MRK
# @good_ug_stu_2.role = @stud_MRK
# @bad_ug_stu.role = @stud_MRK
# @good_g_stu.sub_roles = [@graduated_SRK,@ta_SRK]
# @bad_g_stu.sub_roles << @graduated_SRK
# @good_ug_stu_1.sub_roles << @under_graduated_SRK
# @good_ug_stu_2.sub_roles << @under_graduated_SRK
# @bad_ug_stu.sub_roles << @under_graduated_SRK
# @teacher.role = @teacher_MRK
# @staff.role = @staff_MRK
# @good_g_stu.save!
# @bad_g_stu.save!
# @good_ug_stu_1.save!
# @good_ug_stu_2.save!
# @bad_ug_stu.save!
# @teacher.save!
# @staff.save!
# end
# describe "Starting a ClassBulletin Auth for teacher , staff and ta" do
# before do
# @bulletin_app_auth = AppAuth.new()
# #all teacher and staff has access right
# @bulletin_app_auth.roles = [@teacher_MRK,@staff_MRK]
# #all person with TA sub_role has access right
# @bulletin_app_auth.sub_roles << @ta_SRK
# #a_bad_ug_stud add to block to bulletin_app_auth
# #@bulletin_app_auth.blocked_users << @bad_ug_stu
# #all teacher has access right
# # @bulletin_app_auth.roles << @teacher_MRK
# # @bulletin_app_auth.privilege_users << @staff
# @bulletin_app_auth.save!
# end
# context "Should just initialize all obj that is needed" do
# it "Testing @bulletin_app_auth init result" do
# @bulletin_app_auth.roles.should have(2).item #teacher staff
# @bulletin_app_auth.sub_roles.should have(1).item #ta
# end
# it "@bulletin_app_auth should have Roles: Staff , Teacher " do
# key_ary = @bulletin_app_auth.roles.collect do |role|
# role.key
# end
# key_ary.sort.should == ["Staff","Teacher"].sort
# end
# it "bulletin_app_auth should have 3 auth users" do
# user_ary = [@teacher,@staff,@good_g_stu]
# @bulletin_app_auth.auth_users.sort.should == user_ary.sort
# check_user_has_app user_ary
# end
# it "Adding a undergraduate stud into app_auth by privilege list" do
# user_ary = [@teacher,@staff,@good_g_stu,@good_ug_stu_1]
# @bulletin_app_auth.add_user_to_privilege_list @good_ug_stu_1
# @bulletin_app_auth.auth_users.sort.should == user_ary.sort
# check_user_has_app user_ary
# end
# it "Adding all graudated-stud into app_auth" do
# user_ary = [@teacher,@staff,@good_g_stu,@bad_g_stu]
# @bulletin_app_auth.add_sub_role @graduated_SRK
# @bulletin_app_auth.auth_users.sort.should == user_ary.sort
# check_user_has_app user_ary
# end
# it "Blocking bad-graduate student" do
# user_ary =[@teacher,@staff,@good_g_stu]
# @bulletin_app_auth.add_sub_role @graduated_SRK
# @bulletin_app_auth.add_user_to_black_list @bad_g_stu
# @bulletin_app_auth.auth_users_after_block_list.sort.should == user_ary.sort
# check_user_has_app user_ary
# end
# it "Removing all graudated-stud from app_auth" do
# user_ary =[@teacher,@staff,@good_g_stu]
# @bulletin_app_auth.add_sub_role @graduated_SRK
# @bulletin_app_auth.remove_sub_role @graduated_SRK
# @bulletin_app_auth.auth_users.sort.should == user_ary.sort
# check_user_has_app user_ary
# end
# # it "@bulletin_app_auth should have one Privialage user which is belongs to Staff" do
# # p_user_ary = @bulletin_app_auth.privilege_users.collect do |p_user|
# # p_user.roles.key
# # end
# # p_user_ary.should include("Staff")
# # end
# # it "@bulletin_app_auth should have one student listed at blocklist" do
# # @bad_stu = User.first(conditions:{email:"a_bad_g_stud@rulingcom.com"})
# # @bulletin_app_auth.blocked_users.should have(1).item
# # @bulletin_app_auth.blocked_users.should include(@bad_stu)
# # end
# # it "[Development #1]-1.Authorizing roles: roles + blocklist" do
# # @good_stu = User.first(conditions:{email:"a_good_g_stud@rulingcom.com"})
# # @teacher = User.first(conditions:{email:"a_teacher@rulingcom.com"})
# # @staff = User.first(conditions:{email:"a_staff@rulingcom.com"})
# # ary = [@good_stu,@teacher,@staff]
# # @bulletin_app_auth.auth_users_after_block_list.should == ary
# # end
# #
# # it "[Development #1]-2.Authorizing single users: list of users [new_user1~2]" do
# # user_emails = ["new_user1","new_user2","new_user3","new_user4"]
# # user_emails.each do |user_email|
# # email=user_email+"@rulingcom.com"
# # new_user = User.new :email=> email
# # new_user.save
# # end
# # user1= User.first(conditions:{email:"new_user1@rulingcom.com"})
# # user2= User.first(conditions:{email:"new_user2@rulingcom.com"})
# # user3= User.first(conditions:{email:"new_user3@rulingcom.com"})
# # user4= User.first(conditions:{email:"new_user4@rulingcom.com"})
# #
# # @bulletin_app_auth.privilege_users << user1
# # @bulletin_app_auth.privilege_users << user2
# #
# # @bulletin_app_auth.auth_users_after_block_list.should include(user1,user2)
# # @bulletin_app_auth.auth_users_after_block_list.should_not include(user3,user4)
# #
# # end
# #
# # it "[Development #1]-3.Authorizing roles and single users: roles + blocklist + list of users" do
# # @bulletin_app_auth.auth_users.should have(7).item
# # end
# #
# # it "[Development #1]-4.Authorizing all: blocklist" do
# # @bad_stu = User.first(conditions:{email:"a_bad_g_stud@rulingcom.com"})
# # @new_bulletin_app_auth = (AppAuth.new :all => true)
# # @new_bulletin_app_auth.blocked_users << @bad_stu
# #
# # @new_bulletin_app_auth.auth_users.should == User.all.entries
# # @new_bulletin_app_auth.auth_users_after_block_list.should_not include(@bad_stu)
# # @new_bulletin_app_auth.save!
# # end
# def check_user_has_app(user_ary)
# user_ary.each do |user|
# user.avb_apps.should include(@bulletin_app_auth)
# end # end
#
# it "[Development #1]-3.Authorizing roles and single users: roles + blocklist + list of users" do
# @bulletin_app_auth.auth_users.should have(7).item
# end # end
#
# it "[Development #1]-4.Authorizing all: blocklist" do
# @bad_stu = User.first(conditions:{email:"a_bad_g_stud@rulingcom.com"})
# @new_bulletin_app_auth = (AppAuth.new :all => true)
# @new_bulletin_app_auth.blocked_users << @bad_stu
#
# @new_bulletin_app_auth.auth_users.should == User.all.entries
# @new_bulletin_app_auth.auth_users_after_block_list.should_not include(@bad_stu)
# @new_bulletin_app_auth.save!
# end # end
def check_user_has_app(user_ary)
user_ary.each do |user|
user.avb_apps.should include(@bulletin_app_auth)
end
end
end
end # end
end # end

View File

@ -1,81 +1,81 @@
require 'spec_helper' # require 'spec_helper'
require 'ruby-debug' # require 'ruby-debug'
describe AppAuth do # describe AppAuth do
before(:all) do # before(:all) do
@app_ary = [ # @app_ary = [
{"name" => "G_app_1" , "all" => false,"blockusers" => ["a_bad_stud@rulingcom.com"]}, # {"name" => "G_app_1" , "all" => false,"blockusers" => ["a_bad_stud@rulingcom.com"]},
{"name" => "G_app_2" , "all" => true,"blockusers" => ["a_bad_stud@rulingcom.com"]}, # {"name" => "G_app_2" , "all" => true,"blockusers" => ["a_bad_stud@rulingcom.com"]},
{"name" => "G_app_3_for_bad" , "all" => true,"blockusers" => []} # {"name" => "G_app_3_for_bad" , "all" => true,"blockusers" => []}
] # ]
@app_ary.each do |t| # @app_ary.each do |t|
a = ModuleApp.new :title => t["name"] # a = ModuleApp.new :title => t["name"]
blocked_users = t["blockusers"].collect do |b_user| # blocked_users = t["blockusers"].collect do |b_user|
User.first(conditions:{email:b_user}) # User.first(conditions:{email:b_user})
end # end
a.create_app_auth :all=> t["all"],:blocked_users => blocked_users # a.create_app_auth :all=> t["all"],:blocked_users => blocked_users
a.save! # a.save!
end # end
@good_stud_become_bad = User.first(conditions:{email:"a_good_stud@rulingcom.com"}) # @good_stud_become_bad = User.first(conditions:{email:"a_good_stud@rulingcom.com"})
@bad_stud_become_good = User.first(conditions:{email:"a_bad_stud@rulingcom.com"}) # @bad_stud_become_good = User.first(conditions:{email:"a_bad_stud@rulingcom.com"})
@g_app_1 = ModuleApp.first(conditions:{title:"G_app_1"}) # @g_app_1 = ModuleApp.first(conditions:{title:"G_app_1"})
@g_app_2 = ModuleApp.first(conditions:{title:"G_app_2"}) # @g_app_2 = ModuleApp.first(conditions:{title:"G_app_2"})
@g_app_3 = ModuleApp.first(conditions:{title:"G_app_3_for_bad"}) # @g_app_3 = ModuleApp.first(conditions:{title:"G_app_3_for_bad"})
end # end
describe "[Init status check]" do # describe "[Init status check]" do
it "bad_stud_become_good status " do # it "bad_stud_become_good status " do
@bad_stud_become_good.avb_apps.should_not include @g_app_1.app_auth # @bad_stud_become_good.avb_apps.should_not include @g_app_1.app_auth
@bad_stud_become_good.avb_apps.should_not include @g_app_2.app_auth # @bad_stud_become_good.avb_apps.should_not include @g_app_2.app_auth
@bad_stud_become_good.avb_apps.should include @g_app_3.app_auth # @bad_stud_become_good.avb_apps.should include @g_app_3.app_auth
end # end
it "good_stud_become_bad status " do # it "good_stud_become_bad status " do
@good_stud_become_bad.avb_apps.should_not include @g_app_1.app_auth # @good_stud_become_bad.avb_apps.should_not include @g_app_1.app_auth
@good_stud_become_bad.avb_apps.should include @g_app_2.app_auth # @good_stud_become_bad.avb_apps.should include @g_app_2.app_auth
@good_stud_become_bad.avb_apps.should include @g_app_3.app_auth # @good_stud_become_bad.avb_apps.should include @g_app_3.app_auth
end # end
end # end
describe ".add_user_to_black_list sutd" do # describe ".add_user_to_black_list sutd" do
it "When good stud is blocked with app1 and app2" do # it "When good stud is blocked with app1 and app2" do
@g_app_1.app_auth.add_user_to_black_list @good_stud_become_bad # @g_app_1.app_auth.add_user_to_black_list @good_stud_become_bad
@g_app_2.app_auth.add_user_to_black_list @good_stud_become_bad # @g_app_2.app_auth.add_user_to_black_list @good_stud_become_bad
@good_stud_become_bad.avb_apps.should_not include @g_app_1.app_auth # @good_stud_become_bad.avb_apps.should_not include @g_app_1.app_auth
@good_stud_become_bad.avb_apps.should_not include @g_app_2.app_auth # @good_stud_become_bad.avb_apps.should_not include @g_app_2.app_auth
end # end
end # end
describe ".remove_user_from_black_list sutd" do # describe ".remove_user_from_black_list sutd" do
it "When bad stud is authed with app1 and app2" do # it "When bad stud is authed with app1 and app2" do
@g_app_1.app_auth.remove_user_from_black_list @bad_stud_become_good # @g_app_1.app_auth.remove_user_from_black_list @bad_stud_become_good
@g_app_2.app_auth.remove_user_from_black_list @bad_stud_become_good # @g_app_2.app_auth.remove_user_from_black_list @bad_stud_become_good
#@bad_stud_become_good.avb_apps.should include @g_app_1.app_auth # #@bad_stud_become_good.avb_apps.should include @g_app_1.app_auth
@bad_stud_become_good.avb_apps.should include @g_app_2.app_auth # @bad_stud_become_good.avb_apps.should include @g_app_2.app_auth
end # end
end # end
describe ".add_user_to_privilege_list sutd" do # describe ".add_user_to_privilege_list sutd" do
it "When bad stud is auth for one more app" do # it "When bad stud is auth for one more app" do
@bad_stud_become_good.avb_apps.should_not include @g_app_1.app_auth #shouldn't have at first time since app1 is not sat for all # @bad_stud_become_good.avb_apps.should_not include @g_app_1.app_auth #shouldn't have at first time since app1 is not sat for all
@g_app_1.app_auth.add_user_to_privilege_list @bad_stud_become_good #change status # @g_app_1.app_auth.add_user_to_privilege_list @bad_stud_become_good #change status
@bad_stud_become_good.avb_apps.should include @g_app_1.app_auth #check # @bad_stud_become_good.avb_apps.should include @g_app_1.app_auth #check
end # end
end # end
describe ".remove_user_from_privilege_list sutd" do # describe ".remove_user_from_privilege_list sutd" do
it "admin mistake. remove user from privilege list" do # it "admin mistake. remove user from privilege list" do
@g_app_1.app_auth.remove_user_from_privilege_list @bad_stud_become_good # @g_app_1.app_auth.remove_user_from_privilege_list @bad_stud_become_good
@bad_stud_become_good.avb_apps.should_not include @g_app_1.app_auth # @bad_stud_become_good.avb_apps.should_not include @g_app_1.app_auth
end # end
end # end
after(:all) do # after(:all) do
@app_ary.each do |item| # @app_ary.each do |item|
ModuleApp.first(conditions: {title: item["name"]}).destroy # ModuleApp.first(conditions: {title: item["name"]}).destroy
end # end
end # end
end # end

View File

@ -0,0 +1,12 @@
require 'spec_helper'
describe AttributeField do
describe "#list field" do
context "when field is in type text_field(without add more)" do
before(:each) do
@attribute_field = AttributeField.new(:key=>'test',:markup=>"text_field")
end
end
end
end

View File

@ -0,0 +1,63 @@
#encoding: UTF-8
require 'spec_helper'
describe AttributeValue do
describe "#attribute_value" do
context "Data should be able to input and out put as aspect"
before do
@af = AttributeField.find '5052cf9f2b5c49a742000005'
@user = User.where(email:'chris@rulingcom.com').first
@av = AttributeValue.last
end #end before
[true,false].each do |locale_sat|
LIST[:markups].each do |markup|
@av = nil
it "[#{markup[0]}]Input: should save data at right way when local is set to #{locale_sat}" do
@af.markup = markup[0]
@av = nil
@input_value = assume_result = case markup[0]
when 'text_field','text_area'
(locale_sat ? {"en"=> "lalala","zh_tw"=>"拉拉拉"} : "hahaha")
when 'select','radio_button'
"1"
when 'date'
{"(1i)"=>Date.today.year.to_s,"(2i)"=>Date.today.month.to_s,"(3i)"=>Date.today.day.to_s}
when 'checkbox'
{"1"=>"true", "3"=>"true"}
end #end of case
assume_result = ["1","3"] if markup[0] == 'checkbox'
@af.locale = locale_sat
@af.save
@data_hash = {"attribute_field_id" => @af.id,"value" => @input_value}
@av = @user.attribute_values.build(@data_hash)
@av.save
@av.value.should == assume_result
# @av.destroy
end
it "[#{markup[0]}]Output(just for show): should output data at right way when local is set to #{locale_sat}" do
locale = I18n.locale
assume_result = case markup[0]
when 'text_area'
(locale_sat ? "拉拉拉" : "hahaha")
when 'text_field'
(locale_sat ? "拉拉拉" : "hahaha")
when 'select','radio_button'
(locale_sat ? "男性" : "男性")
when 'date'
Date.today
when 'checkbox'
(locale_sat ? "男性,不公開" : "男性,不公開")
end #end of case
@av.get_value_by_locale(locale).should == assume_result
end
end #end of LIST loop
end
end
end

View File

@ -1,113 +1,113 @@
require 'spec_helper' # require 'spec_helper'
describe Role do # describe Role do
before do # before do
@role = Role.create(:key => 'teacher', # @role = Role.create(:key => 'teacher',
:i18n_variable => {:key => 'teacher', :en => 'Teacher', :zh_tw => 'Teacher in Chinese', :document_class => 'Role'}, # :i18n_variable => {:key => 'teacher', :en => 'Teacher', :zh_tw => 'Teacher in Chinese', :document_class => 'Role'},
:sub_roles => [{:key => 'undergrad', # :sub_roles => [{:key => 'undergrad',
:i18n_variable => {:key => 'yeah', :en => 'Yeah', :zh_tw => 'Yeah', :document_class => 'Role'}, # :i18n_variable => {:key => 'yeah', :en => 'Yeah', :zh_tw => 'Yeah', :document_class => 'Role'},
:attribute_fields => [{:key => 'department'}, # :attribute_fields => [{:key => 'department'},
{:key => 'room'}]}, # {:key => 'room'}]},
{:key => 'master', # {:key => 'master',
:attribute_fields => [{:key => 'department'}]}]) # :attribute_fields => [{:key => 'department'}]}])
end # end
describe 'New role' do # describe 'New role' do
describe '#Role' do # describe '#Role' do
it 'should have :built_in false' do # it 'should have :built_in false' do
@role.built_in.should be false # @role.built_in.should be false
end # end
it 'should have :disabled false' do # it 'should have :disabled false' do
@role.disabled.should be false # @role.disabled.should be false
end # end
it 'should have a i18n_variable' do # it 'should have a i18n_variable' do
@role.i18n_variable.should be_an_instance_of I18nVariable # @role.i18n_variable.should be_an_instance_of I18nVariable
end # end
it 'should create sub_roles' do # it 'should create sub_roles' do
@role.should have(2).sub_roles # @role.should have(2).sub_roles
end # end
it 'should create attribute_fields' do # it 'should create attribute_fields' do
@role.sub_roles[1].should have(1).attribute_fields # @role.sub_roles[1].should have(1).attribute_fields
end # end
end # end
describe '#SubRole' do # describe '#SubRole' do
it 'should have :built_in false' do # it 'should have :built_in false' do
@role.sub_roles[0].built_in.should be false # @role.sub_roles[0].built_in.should be false
end # end
it 'should have :disabled false' do # it 'should have :disabled false' do
@role.sub_roles[0].disabled.should be false # @role.sub_roles[0].disabled.should be false
end # end
it 'should have a i18n_variable' do # it 'should have a i18n_variable' do
@role.sub_roles[0].i18n_variable.should be_an_instance_of I18nVariable # @role.sub_roles[0].i18n_variable.should be_an_instance_of I18nVariable
end # end
end # end
describe '#AttributeField' do # describe '#AttributeField' do
it 'should have :built_in false' do # it 'should have :built_in false' do
@role.sub_roles[0].attribute_fields[0].built_in.should be false # @role.sub_roles[0].attribute_fields[0].built_in.should be false
end # end
it 'should have :disabled false' do # it 'should have :disabled false' do
@role.sub_roles[0].attribute_fields[0].disabled.should be false # @role.sub_roles[0].attribute_fields[0].disabled.should be false
end # end
end # end
end # end
describe 'Edit role' do # describe 'Edit role' do
describe '#Role' do # describe '#Role' do
before do # before do
@role.update_attributes({:key => 'student', :i18n_variable => {:en => 'Student'}, # @role.update_attributes({:key => 'student', :i18n_variable => {:en => 'Student'},
:sub_roles => [{:key => 'new', # :sub_roles => [{:key => 'new',
:attribute_fields => [{:key => 'bob'}, # :attribute_fields => [{:key => 'bob'},
{:key => 'great'}]}, # {:key => 'great'}]},
{:id => @role.sub_roles[0].id}, # {:id => @role.sub_roles[0].id},
{:id => @role.sub_roles[1].id}]}) # {:id => @role.sub_roles[1].id}]})
end # end
it 'should not be the old :key' do # it 'should not be the old :key' do
@role.key.should_not == 'teacher' # @role.key.should_not == 'teacher'
end # end
it 'should be the new :key' do # it 'should be the new :key' do
@role.key.should == 'student' # @role.key.should == 'student'
end # end
it 'should not be the old :i18n_variable[:en]' do # it 'should not be the old :i18n_variable[:en]' do
@role.i18n_variable[:en].should_not == 'Teacher' # @role.i18n_variable[:en].should_not == 'Teacher'
end # end
it 'should be the new :i18n_variable[:en]' do # it 'should be the new :i18n_variable[:en]' do
@role.i18n_variable[:en].should == 'Student' # @role.i18n_variable[:en].should == 'Student'
end # end
it 'should have one more SubRole' do # it 'should have one more SubRole' do
@role.should have(3).sub_roles # @role.should have(3).sub_roles
end # end
end # end
end # end
describe 'Destroy' do # describe 'Destroy' do
describe '#AttributeField' do # describe '#AttributeField' do
before do # before do
@role.update_attributes(:key => 'teacher', # @role.update_attributes(:key => 'teacher',
:i18n_variable => {:key => 'teacher', :en => 'Teacher', :zh_tw => 'Teacher in Chinese', :document_class => 'Role'}, # :i18n_variable => {:key => 'teacher', :en => 'Teacher', :zh_tw => 'Teacher in Chinese', :document_class => 'Role'},
:sub_roles_attributes => {'0' => {:id => @role.sub_roles[0].id, # :sub_roles_attributes => {'0' => {:id => @role.sub_roles[0].id,
:key => 'undergrad', # :key => 'undergrad',
:attribute_fields_attributes => {'0' => {:id => @role.sub_roles[0].attribute_fields[0].id, # :attribute_fields_attributes => {'0' => {:id => @role.sub_roles[0].attribute_fields[0].id,
:key => 'department'}, # :key => 'department'},
'1' => {:id => @role.sub_roles[0].attribute_fields[1].id, # '1' => {:id => @role.sub_roles[0].attribute_fields[1].id,
:key => 'room', :_destroy => true}}}}) # :key => 'room', :_destroy => true}}}})
end # end
it 'should have only one AttributeField for the first SubRole' do # it 'should have only one AttributeField for the first SubRole' do
@role.sub_roles[0].should have(1).attribute_fields # @role.sub_roles[0].should have(1).attribute_fields
end # end
end # end
describe '#I18nVariable' do # describe '#I18nVariable' do
before do # before do
@role.update_attributes(:key => 'teacher', # @role.update_attributes(:key => 'teacher',
:i18n_variable_attributes => {:id => @role.i18n_variable.id, :key => 'teacher', :en => 'Teacher', :zh_tw => 'Teacher in Chinese', :document_class => 'Role', :_destroy => true}) # :i18n_variable_attributes => {:id => @role.i18n_variable.id, :key => 'teacher', :en => 'Teacher', :zh_tw => 'Teacher in Chinese', :document_class => 'Role', :_destroy => true})
end # end
it 'should not have a I18nVariable' do # it 'should not have a I18nVariable' do
@role.i18n_variable.should_not be_an_instance_of I18nVariable # @role.i18n_variable.should_not be_an_instance_of I18nVariable
end # end
end # end
describe '#Role' do # describe '#Role' do
it 'should destroy the I18nVariable' do # it 'should destroy the I18nVariable' do
id = @role.i18n_variable.id # id = @role.i18n_variable.id
@role.destroy # @role.destroy
lambda {I18nVariable.find(id)}.should raise_error # lambda {I18nVariable.find(id)}.should raise_error
end # end
end # end
end # end
end # end

View File

@ -38,6 +38,7 @@ Spork.prefork do
# automatically. This will be the default behavior in future versions of # automatically. This will be the default behavior in future versions of
# rspec-rails. # rspec-rails.
config.infer_base_class_for_anonymous_controllers = false config.infer_base_class_for_anonymous_controllers = false
end end
end end

View File

@ -1 +1,53 @@
Hello~ I am your plugin profile <%
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('bulletin.category') %></th>
<th class="span3"><%= t('bulletin.title') %></th>
<th class="span1"><%= t('bulletin.start_date') %></th>
<th class="span1"><%= t('bulletin.end_date') %></th>
<th class="span1"><%= t('bulletin.tags') %></th>
<% if not @user%>
<th class="span1"><%= t('bulletin.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.bulletin_category.title%></td>
<td>
<% if bulletin.is_checked? %>
<%= link_to bulletin.title, panel_announcement_front_end_bulletin_path(bulletin, :category_id => bulletin.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('bulletin.no_deadline') %></td>
<% end %>
<td>
<div class="label-group">
<% bulletin.sorted_tags.each do |tag| %>
<span class="label label-tags"><%= tag[I18n.locale] %></span>
<% end %>
</div>
</td>
<% if not @user%>
<td><%= User.find(bulletin.create_user_id).name %></td>
<% end %>
</tr>
<% end %>
</tbody>
</table>

View File

@ -37,7 +37,6 @@ class Panel::Archive::BackEnd::ArchiveFileCategorysController < OrbitBackendCont
# GET /archive_files/1/edit # GET /archive_files/1/edit
def edit def edit
@archive_file_category = ArchiveFileCategory.find(params[:id]) @archive_file_category = ArchiveFileCategory.find(params[:id])
@i18n_variable = @archive_file_category.i18n_variable
@url = panel_archive_back_end_archive_file_category_path(@archive_file_category) @url = panel_archive_back_end_archive_file_category_path(@archive_file_category)

View File

@ -55,7 +55,6 @@ class Panel::Archive::BackEnd::ArchiveFilesController < OrbitBackendController
# POST /archive_files.xml # POST /archive_files.xml
def create def create
@archive_file = ArchiveFile.new(params[:archive_file]) @archive_file = ArchiveFile.new(params[:archive_file])
@archive_file.create_user_id = current_user.id @archive_file.create_user_id = current_user.id
@archive_file.update_user_id = current_user.id @archive_file.update_user_id = current_user.id
@ -64,6 +63,8 @@ class Panel::Archive::BackEnd::ArchiveFilesController < OrbitBackendController
format.html { redirect_to(panel_archive_back_end_archive_files_url) } format.html { redirect_to(panel_archive_back_end_archive_files_url) }
format.xml { render :xml => @archive_file, :status => :created, :location => @archive_file } format.xml { render :xml => @archive_file, :status => :created, :location => @archive_file }
else else
get_categorys
get_tags
format.html { render :action => "new" } format.html { render :action => "new" }
format.xml { render :xml => @archive_file.errors, :status => :unprocessable_entity } format.xml { render :xml => @archive_file.errors, :status => :unprocessable_entity }
end end

View File

@ -9,7 +9,7 @@ class Panel::Archive::FrontEnd::ArchiveFilesController < OrbitWidgetController
@item = Page.find(params[:page_id]) @item = Page.find(params[:page_id])
@title = @item.i18n_variable[I18n.locale] @title = @item.title
if @item.frontend_data_count if @item.frontend_data_count
@page_num = @item.frontend_data_count @page_num = @item.frontend_data_count
@ -41,7 +41,7 @@ class Panel::Archive::FrontEnd::ArchiveFilesController < OrbitWidgetController
@item = Page.find(params[:page_id]) @item = Page.find(params[:page_id])
@title = @item.i18n_variable[I18n.locale] @title = @item.title
@archive_file = ArchiveFile.find(params[:id]) @archive_file = ArchiveFile.find(params[:id])
@ -55,7 +55,7 @@ class Panel::Archive::FrontEnd::ArchiveFilesController < OrbitWidgetController
@item = Page.find(params[:page_id]) @item = Page.find(params[:page_id])
@title = @item.i18n_variable[I18n.locale] @title = @item.title
if @item.frontend_data_count if @item.frontend_data_count
@page_num = @item.frontend_data_count @page_num = @item.frontend_data_count

View File

@ -26,7 +26,7 @@ class ArchiveFile
accepts_nested_attributes_for :archive_file_multiples, :allow_destroy => true accepts_nested_attributes_for :archive_file_multiples, :allow_destroy => true
validates_presence_of :title validates :title, :at_least_one => true
after_save :save_archive_file_multiples after_save :save_archive_file_multiples

View File

@ -7,8 +7,10 @@ class ArchiveFileCategory
field :key field :key
has_one :i18n_variable, :as => :language_value, :autosave => true, :dependent => :destroy field :title, localize: true
has_many :archive_files has_many :archive_files
validates :title, :at_least_one => true
end end

View File

@ -9,8 +9,6 @@ class ArchiveFileMultiple
# field :description # field :description
field :choose_lang, :type => Array, :default => nil field :choose_lang, :type => Array, :default => nil
# has_one :i18n_variable, :as => :language_value, :autosave => true, :dependent => :destroy
field :should_destroy, :type => Boolean field :should_destroy, :type => Boolean
def choose_lang_display(lang) def choose_lang_display(lang)

View File

@ -11,6 +11,6 @@
</div> </div>
</td> </td>
<% @site_valid_locales.each do |locale| %> <% @site_valid_locales.each do |locale| %>
<td><%= archive_file_category.i18n_variable[locale] rescue nil %></td> <td><%= archive_file_category.title_translations[locale] rescue nil %></td>
<% end %> <% end %>
</tr> </tr>

View File

@ -10,12 +10,12 @@
</div> </div>
<div id="widget-title"> <div id="widget-title">
<%= f.fields_for :i18n_variable, (@archive_file_category.new_record? ? @archive_file_category.build_i18n_variable : @archive_file_category.i18n_variable) do |f| %> <%= f.fields_for :title_translations do |f| %>
<% @site_valid_locales.each do |locale| %> <% @site_valid_locales.each do |locale| %>
<div class="control-group"> <div class="control-group">
<%= label_tag "name-#{locale}", "Name-#{I18nVariable.from_locale(locale)}", :class => 'control-label' %> <%= label_tag "name-#{locale}", "Name-#{I18nVariable.from_locale(locale)}", :class => 'control-label' %>
<div class="controls"> <div class="controls">
<%= f.text_field locale, :class => 'input-xxlarge' %> <%= f.text_field locale, :class =>' input-xxlarge', :value => (@archive_file_category.title[locale] rescue nil) %>
</div> </div>
</div> </div>
<% end %> <% end %>

View File

@ -17,7 +17,7 @@
</ul> </ul>
</div> </div>
</td> </td>
<td><%= post.archive_file_category.i18n_variable[I18n.locale] %></td> <td><%= post.archive_file_category.title %></td>
<td> <td>
<%= link_to post.title, panel_archive_front_end_archive_file_path(post) %> <%= link_to post.title, panel_archive_front_end_archive_file_path(post) %>
</td> </td>

View File

@ -43,7 +43,7 @@
<div id="post-body-content" class="clear"> <div id="post-body-content" class="clear">
<%= f.label :category %> <%= f.label :category %>
<%= f.select :archive_file_category_id, @archive_file_categorys.collect {|t| [ t.i18n_variable[I18n.locale], t.id ]} %> <%= f.select :archive_file_category_id, @archive_file_categorys.collect {|t| [ t.title, t.id ]} %>
<ul class="nav nav-tabs"> <ul class="nav nav-tabs">
<% @site_valid_locales.each_with_index do |locale, i| %> <% @site_valid_locales.each_with_index do |locale, i| %>
@ -74,7 +74,7 @@
<div> <div>
<div id='archive_file_multiples' class="archive_file_multiples_block"> <div class="archive_file_multiples_block">
<table class="table table-condensed"> <table class="table table-condensed">
<thead> <thead>

View File

@ -1,219 +0,0 @@
/*
* jQuery File Upload File Processing Plugin 1.0
* https://github.com/blueimp/jQuery-File-Upload
*
* Copyright 2012, Sebastian Tschan
* https://blueimp.net
*
* Licensed under the MIT license:
* http://www.opensource.org/licenses/MIT
*/
/*jslint nomen: true, unparam: true, regexp: true */
/*global define, window, document */
(function (factory) {
'use strict';
if (typeof define === 'function' && define.amd) {
// Register as an anonymous AMD module:
define([
'jquery',
'load-image',
'canvas-to-blob',
'./jquery.fileupload'
], factory);
} else {
// Browser globals:
factory(
window.jQuery,
window.loadImage
);
}
}(function ($, loadImage) {
'use strict';
// The File Upload IP version extends the basic fileupload widget
// with file processing functionality:
$.widget('blueimpFP.fileupload', $.blueimp.fileupload, {
options: {
// The list of file processing actions:
process: [
/*
{
action: 'load',
fileTypes: /^image\/(gif|jpeg|png)$/,
maxFileSize: 20000000 // 20MB
},
{
action: 'resize',
maxWidth: 1920,
maxHeight: 1200,
minWidth: 800,
minHeight: 600
},
{
action: 'save'
}
*/
],
// The add callback is invoked as soon as files are added to the
// fileupload widget (via file input selection, drag & drop or add
// API call). See the basic file upload widget for more information:
add: function (e, data) {
$(this).fileupload('process', data).done(function () {
data.submit();
});
}
},
processActions: {
// Loads the image given via data.files and data.index
// as canvas element.
// Accepts the options fileTypes (regular expression)
// and maxFileSize (integer) to limit the files to load:
load: function (data, options) {
var that = this,
file = data.files[data.index],
dfd = $.Deferred();
if (window.HTMLCanvasElement &&
window.HTMLCanvasElement.prototype.toBlob &&
($.type(options.maxFileSize) !== 'number' ||
file.size < options.maxFileSize) &&
(!options.fileTypes ||
options.fileTypes.test(file.type))) {
loadImage(
file,
function (canvas) {
data.canvas = canvas;
dfd.resolveWith(that, [data]);
},
{canvas: true}
);
} else {
dfd.rejectWith(that, [data]);
}
return dfd.promise();
},
// Resizes the image given as data.canvas and updates
// data.canvas with the resized image.
// Accepts the options maxWidth, maxHeight, minWidth and
// minHeight to scale the given image:
resize: function (data, options) {
if (data.canvas) {
var canvas = loadImage.scale(data.canvas, options);
if (canvas.width !== data.canvas.width ||
canvas.height !== data.canvas.height) {
data.canvas = canvas;
data.processed = true;
}
}
return data;
},
// Saves the processed image given as data.canvas
// inplace at data.index of data.files:
save: function (data, options) {
// Do nothing if no processing has happened:
if (!data.canvas || !data.processed) {
return data;
}
var that = this,
file = data.files[data.index],
name = file.name,
dfd = $.Deferred(),
callback = function (blob) {
if (!blob.name) {
if (file.type === blob.type) {
blob.name = file.name;
} else if (file.name) {
blob.name = file.name.replace(
/\..+$/,
'.' + blob.type.substr(6)
);
}
}
// Store the created blob at the position
// of the original file in the files list:
data.files[data.index] = blob;
dfd.resolveWith(that, [data]);
};
// Use canvas.mozGetAsFile directly, to retain the filename, as
// Gecko doesn't support the filename option for FormData.append:
if (data.canvas.mozGetAsFile) {
callback(data.canvas.mozGetAsFile(
(/^image\/(jpeg|png)$/.test(file.type) && name) ||
((name && name.replace(/\..+$/, '')) ||
'blob') + '.png',
file.type
));
} else {
data.canvas.toBlob(callback, file.type);
}
return dfd.promise();
}
},
// Resizes the file at the given index and stores the created blob at
// the original position of the files list, returns a Promise object:
_processFile: function (files, index, options) {
var that = this,
dfd = $.Deferred().resolveWith(that, [{
files: files,
index: index
}]),
chain = dfd.promise();
that._processing += 1;
$.each(options.process, function (i, settings) {
chain = chain.pipe(function (data) {
return that.processActions[settings.action]
.call(this, data, settings);
});
});
chain.always(function () {
that._processing -= 1;
if (that._processing === 0) {
that.element
.removeClass('fileupload-processing');
}
});
if (that._processing === 1) {
that.element.addClass('fileupload-processing');
}
return chain;
},
// Processes the files given as files property of the data parameter,
// returns a Promise object that allows to bind a done handler, which
// will be invoked after processing all files (inplace) is done:
process: function (data) {
var that = this,
options = $.extend({}, this.options, data);
if (options.process && options.process.length &&
this._isXHRUpload(options)) {
$.each(data.files, function (index, file) {
that._processingQueue = that._processingQueue.pipe(
function () {
var dfd = $.Deferred();
that._processFile(data.files, index, options)
.always(function () {
dfd.resolveWith(that);
});
return dfd.promise();
}
);
});
}
return this._processingQueue;
},
_create: function () {
$.blueimp.fileupload.prototype._create.call(this);
this._processing = 0;
this._processingQueue = $.Deferred().resolveWith(this)
.promise();
}
});
}));

Some files were not shown because too many files have changed in this diff Show More