forked from saurabh/orbit4-5
Compare commits
11 Commits
| Author | SHA1 | Date |
|---|---|---|
|
|
592c8c63fe | |
|
|
2ccabb64f3 | |
|
|
9ec5e21500 | |
|
|
f9dd55eea2 | |
|
|
afe1ffd437 | |
|
|
898059c6d2 | |
|
|
8b8dd22e88 | |
|
|
bead39d5b4 | |
|
|
93d66b5866 | |
|
|
59a198005d | |
|
|
f7c377d092 |
|
|
@ -20,6 +20,7 @@
|
||||||
app/views/frontend
|
app/views/frontend
|
||||||
/public/uploads/*
|
/public/uploads/*
|
||||||
public/assets/*
|
public/assets/*
|
||||||
|
public/site_feeds/*
|
||||||
public/import_status.yml
|
public/import_status.yml
|
||||||
public/announcement_link_widget_en.json
|
public/announcement_link_widget_en.json
|
||||||
public/announcement_link_widget_zh_tw.json
|
public/announcement_link_widget_zh_tw.json
|
||||||
|
|
|
||||||
|
|
@ -38,6 +38,13 @@ var FormValidator = function(form){
|
||||||
}
|
}
|
||||||
var reg = new RegExp(/https?:\/\/(www\.)?[-a-zA-Z0-9@:%._\+~#=]{2,256}\.[a-z]{2,6}\b([-a-zA-Z0-9@:%_\+.~#?&//=]*)/);
|
var reg = new RegExp(/https?:\/\/(www\.)?[-a-zA-Z0-9@:%._\+~#=]{2,256}\.[a-z]{2,6}\b([-a-zA-Z0-9@:%_\+.~#?&//=]*)/);
|
||||||
return reg.test(value);
|
return reg.test(value);
|
||||||
|
},
|
||||||
|
urlwithip : function(value){
|
||||||
|
if(value == "#"){
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
var reg = new RegExp(/^https?\:\/\/[^\/\s]+(\/.*)?$/);
|
||||||
|
return reg.test(value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -236,9 +236,37 @@ class MembersController < ApplicationController
|
||||||
end
|
end
|
||||||
when 'role'
|
when 'role'
|
||||||
if !field['id'].blank?
|
if !field['id'].blank?
|
||||||
field_data = member.attribute_values.find_by(:attribute_field_id=>field['id'],:key=>field['key']).get_field_value rescue {}
|
av = member.attribute_values.find_by(:attribute_field_id=>field['id'],:key=>field['key']) rescue nil
|
||||||
|
if !av.nil?
|
||||||
|
r = av.attribute_field.role rescue nil
|
||||||
|
if !r.nil?
|
||||||
|
if member.roles.include?(r)
|
||||||
|
field_data = av.get_field_value rescue {}
|
||||||
else
|
else
|
||||||
field_data = member.attribute_values.find_by(:key=>field['key']).get_field_value rescue {}
|
field_data = {}
|
||||||
|
end
|
||||||
|
else
|
||||||
|
field_data = {}
|
||||||
|
end
|
||||||
|
else
|
||||||
|
field_data = {}
|
||||||
|
end
|
||||||
|
else
|
||||||
|
av = member.attribute_values.find_by(:key=>field['key']) rescue nil
|
||||||
|
if !av.nil?
|
||||||
|
r = av.attribute_field.role rescue nil
|
||||||
|
if !r.nil?
|
||||||
|
if member.roles.include?(r)
|
||||||
|
field_data = av.get_field_value rescue {}
|
||||||
|
else
|
||||||
|
field_data = {}
|
||||||
|
end
|
||||||
|
else
|
||||||
|
field_data = {}
|
||||||
|
end
|
||||||
|
else
|
||||||
|
field_data = {}
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
next if field_data.blank? or field_data['value'].blank?
|
next if field_data.blank? or field_data['value'].blank?
|
||||||
|
|
|
||||||
|
|
@ -384,7 +384,7 @@ class PagesController < ApplicationController
|
||||||
|
|
||||||
def render_final_page(original_view=get_view,page,layout)
|
def render_final_page(original_view=get_view,page,layout)
|
||||||
final_html_for_render = ""
|
final_html_for_render = ""
|
||||||
|
OrbitHelper.set_css_to_render_to_empty
|
||||||
if layout
|
if layout
|
||||||
parts = $mobile.blank? ? (page.page_parts rescue []) : (page.mobile_page_parts rescue [])
|
parts = $mobile.blank? ? (page.page_parts rescue []) : (page.mobile_page_parts rescue [])
|
||||||
|
|
||||||
|
|
@ -437,7 +437,6 @@ class PagesController < ApplicationController
|
||||||
@layout_html = render_to_string(@file)
|
@layout_html = render_to_string(@file)
|
||||||
doc = Nokogiri::HTML(@layout_html, nil, "UTF-8")
|
doc = Nokogiri::HTML(@layout_html, nil, "UTF-8")
|
||||||
head = doc.css("head")
|
head = doc.css("head")
|
||||||
head[0].inner_html = head.inner_html + OrbitHelper.get_css_to_render_in_head
|
|
||||||
@part_partials.each do |key, partial|
|
@part_partials.each do |key, partial|
|
||||||
html_string = ""
|
html_string = ""
|
||||||
partial.each do |p|
|
partial.each do |p|
|
||||||
|
|
@ -470,6 +469,7 @@ class PagesController < ApplicationController
|
||||||
viewarea.inner_html = render_to_string(original_view) rescue "<div></div>"
|
viewarea.inner_html = render_to_string(original_view) rescue "<div></div>"
|
||||||
head[0].inner_html = OrbitHelper.meta_tags_html + head.inner_html
|
head[0].inner_html = OrbitHelper.meta_tags_html + head.inner_html
|
||||||
end
|
end
|
||||||
|
head[0].inner_html = head.inner_html + OrbitHelper.get_css_to_render_in_head
|
||||||
link = doc.css("link")[0]
|
link = doc.css("link")[0]
|
||||||
link.attributes["href"].value = current_site.favicon.url.nil? ? "/assets/favicon.ico" : current_site.favicon.url
|
link.attributes["href"].value = current_site.favicon.url.nil? ? "/assets/favicon.ico" : current_site.favicon.url
|
||||||
final_html_for_render = doc.to_html
|
final_html_for_render = doc.to_html
|
||||||
|
|
|
||||||
|
|
@ -20,7 +20,7 @@ module AttributeFieldsHelper
|
||||||
@new_attribute = @attribute_value.nil?
|
@new_attribute = @attribute_value.nil?
|
||||||
@attribute_value = @attribute_value || (attribute_type.eql?("role") ? @member.attribute_values.build(attribute_field_id: id) : @member.member_profile_field_values.build(member_profile_field: id))
|
@attribute_value = @attribute_value || (attribute_type.eql?("role") ? @member.attribute_values.build(attribute_field_id: id) : @member.member_profile_field_values.build(member_profile_field: id))
|
||||||
@prefiled_value = @attribute_value.value rescue nil
|
@prefiled_value = @attribute_value.value rescue nil
|
||||||
return instance_eval("render_#{markup}")# rescue ""
|
return instance_eval("render_#{markup}") #rescue ""
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
@ -175,7 +175,7 @@ module AttributeFieldsHelper
|
||||||
|
|
||||||
def render_text_area
|
def render_text_area
|
||||||
control_group_wrapper do |key,value|
|
control_group_wrapper do |key,value|
|
||||||
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}]" : ""
|
key = can_muti_lang_input? ? "[#{key}]" : ""
|
||||||
place_holder= @panel_setting["placeholder"][I18n.locale.to_s] rescue ''
|
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))
|
text_area_tag(get_field_name_base + key, value,@markup_options.merge(:placeholder=>place_holder))
|
||||||
|
|
|
||||||
|
|
@ -22,7 +22,7 @@ module AttributeValuesHelper
|
||||||
end
|
end
|
||||||
|
|
||||||
def show_minguo_calendar(from_to=nil)
|
def show_minguo_calendar(from_to=nil)
|
||||||
get_minguo
|
# get_minguo
|
||||||
|
|
||||||
case from_to
|
case from_to
|
||||||
when :to
|
when :to
|
||||||
|
|
@ -96,12 +96,14 @@ module AttributeValuesHelper
|
||||||
def get_date_by_format(from_to = nil)
|
def get_date_by_format(from_to = nil)
|
||||||
case I18n.locale
|
case I18n.locale
|
||||||
when :zh_tw
|
when :zh_tw
|
||||||
case
|
# case
|
||||||
when self.member_profile_field["typeC"]["calendar"] == "west_calendar"
|
# when self.member_profile_field["typeC"]["calendar"] == "west_calendar"
|
||||||
|
# show_west_calender(from_to)
|
||||||
|
# when self.member_profile_field["typeC"]["calendar"] == "tw_calendar"
|
||||||
|
# show_minguo_calendar(from_to)
|
||||||
|
# end #case self.member_profile_field["typeC"]["calendar"]
|
||||||
show_west_calender(from_to)
|
show_west_calender(from_to)
|
||||||
when self.member_profile_field["typeC"]["calendar"] == "tw_calendar"
|
|
||||||
show_minguo_calendar(from_to)
|
|
||||||
end #case self.member_profile_field["typeC"]["calendar"]
|
|
||||||
when :en
|
when :en
|
||||||
show_west_calender(from_to)
|
show_west_calender(from_to)
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -347,8 +347,12 @@ module OrbitHelper
|
||||||
!$mobile.blank?
|
!$mobile.blank?
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def self.set_css_to_render_to_empty
|
||||||
|
@css_to_render_in_head = []
|
||||||
|
end
|
||||||
|
|
||||||
def self.render_css_in_head(css=[])
|
def self.render_css_in_head(css=[])
|
||||||
@css_to_render_in_head = css
|
@css_to_render_in_head.concat(css)
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.get_css_to_render_in_head
|
def self.get_css_to_render_in_head
|
||||||
|
|
@ -381,6 +385,75 @@ module OrbitHelper
|
||||||
ActionView::Base.full_sanitizer.sanitize(string)
|
ActionView::Base.full_sanitizer.sanitize(string)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# get feeds for the module
|
||||||
|
|
||||||
|
def self.get_feed_for_module(type)
|
||||||
|
if ModuleApp.where(:key => "feed").count == 0
|
||||||
|
return []
|
||||||
|
end
|
||||||
|
categories = []
|
||||||
|
ma = nil
|
||||||
|
if type == "index"
|
||||||
|
categories = @categories if !@categories.nil?
|
||||||
|
ma = @module_app
|
||||||
|
elsif type == "widget"
|
||||||
|
categories = @widget_categories if !@widget_categories.nil?
|
||||||
|
ma = @widget_module_app
|
||||||
|
end
|
||||||
|
if categories.first == "all"
|
||||||
|
feeds = SiteFeed.where(:channel_key => ma.key).enabled
|
||||||
|
else
|
||||||
|
feeds = SiteFeed.where(:channel_key => ma.key, :merge_with_category.in => categories).enabled
|
||||||
|
end
|
||||||
|
data = []
|
||||||
|
if feeds.count > 0
|
||||||
|
temp_ids = []
|
||||||
|
feeds.each do |feed|
|
||||||
|
file = File.join(Rails.root,"public","site_feeds",feed.id.to_s,feed.feed_uid.to_s + ".json")
|
||||||
|
if File.exists?(file)
|
||||||
|
d = File.read(file)
|
||||||
|
d = JSON.parse(d)
|
||||||
|
cat = Category.find(feed.merge_with_category).title
|
||||||
|
final_d = []
|
||||||
|
d[ma.key.pluralize].each{|a|
|
||||||
|
a["category"] = cat
|
||||||
|
if !temp_ids.include?(a["id"])
|
||||||
|
temp_ids << a["id"]
|
||||||
|
a["params"] = a["params"] + "_" + feed.id.to_s + "h"
|
||||||
|
final_d << a
|
||||||
|
end
|
||||||
|
}
|
||||||
|
data.concat(final_d)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
data
|
||||||
|
end
|
||||||
|
|
||||||
|
def self.is_object_from_feed?(uid)
|
||||||
|
return uid.ends_with?("h")
|
||||||
|
end
|
||||||
|
|
||||||
|
def self.get_from_feed(uidwithid)
|
||||||
|
temp = uidwithid.split("_")
|
||||||
|
feed_id = temp[1][0...-1]
|
||||||
|
uid = temp[0]
|
||||||
|
object = nil
|
||||||
|
feed = SiteFeed.find(feed_id) rescue nil
|
||||||
|
if !feed.nil?
|
||||||
|
file = File.join(Rails.root,"public","site_feeds",feed.id.to_s,feed.feed_uid.to_s + ".json")
|
||||||
|
if File.exists?(file)
|
||||||
|
d = File.read(file)
|
||||||
|
d = JSON.parse(d)
|
||||||
|
objects = d[@module_app.key.pluralize]
|
||||||
|
object = objects.select{|obj| obj["id"] == uid}.first
|
||||||
|
cat = Category.find(feed.merge_with_category)
|
||||||
|
object = {} if cat.disable
|
||||||
|
end
|
||||||
|
end
|
||||||
|
object
|
||||||
|
end
|
||||||
|
|
||||||
# ===============================================================
|
# ===============================================================
|
||||||
# Breadcrumbs
|
# Breadcrumbs
|
||||||
# ===============================================================
|
# ===============================================================
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,7 @@ class Role
|
||||||
has_and_belongs_to_many :member_profiles
|
has_and_belongs_to_many :member_profiles
|
||||||
has_many :authorizations
|
has_many :authorizations
|
||||||
|
|
||||||
has_many :attribute_fields
|
has_many :attribute_fields, dependent: :destroy
|
||||||
accepts_nested_attributes_for :attribute_fields
|
accepts_nested_attributes_for :attribute_fields
|
||||||
|
|
||||||
has_many :role_statuses, dependent: :destroy
|
has_many :role_statuses, dependent: :destroy
|
||||||
|
|
|
||||||
|
|
@ -145,9 +145,9 @@
|
||||||
<% end %>
|
<% end %>
|
||||||
<% end %>
|
<% end %>
|
||||||
<% end %>
|
<% end %>
|
||||||
<% end %>
|
|
||||||
</ul>
|
</ul>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
<% end %>
|
||||||
</li>
|
</li>
|
||||||
<% if !current_user.nil? %>
|
<% if !current_user.nil? %>
|
||||||
<li>
|
<li>
|
||||||
|
|
@ -160,7 +160,7 @@
|
||||||
<% if params[:editmode] == "on" %>
|
<% if params[:editmode] == "on" %>
|
||||||
<a tabindex="-1" href="<%= request.fullpath.split("?").first %>" style="color:red;"><i class="icons-bolt"></i>Edit Mode Off</a>
|
<a tabindex="-1" href="<%= request.fullpath.split("?").first %>" style="color:red;"><i class="icons-bolt"></i>Edit Mode Off</a>
|
||||||
<% else %>
|
<% else %>
|
||||||
<a tabindex="-1" href="<%= request.fullpath + "?editmode=on" %>"><i class="icons-bolt"></i>Edit Mode On</a>
|
<a tabindex="-1" href="<%= request.fullpath + "#{(request.query_parameters.empty? ? "?" : "&")}editmode=on" %>"><i class="icons-bolt"></i>Edit Mode On</a>
|
||||||
<% end %>
|
<% end %>
|
||||||
</li>
|
</li>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@
|
||||||
<% if params[:action] == "new" %>
|
<% if params[:action] == "new" %>
|
||||||
<%= f.label :name, content_tag(:i, nil, :class => "icons-star") + t(:page)+' ID' %>
|
<%= f.label :name, content_tag(:i, nil, :class => "icons-star") + t(:page)+' ID' %>
|
||||||
<div class="controls">
|
<div class="controls">
|
||||||
<%= f.text_field :page_id, class:"input-xlarge change", data: {"fv-validation" => "required;nospace;pageid_validation;detect_chinese;", "fv-messages" => "Cannot be empty.;Cannot have blank spaces.;Page id is already taken.;Page ID cannot be in chinese.;"} %>
|
<%= f.text_field :page_id, class:"input-xlarge change", data: {"fv-validation" => "required;nospace;pageid_validation;detect_chinese;cannot_have_dash;", "fv-messages" => "Cannot be empty.;Cannot have blank spaces.;Page id is already taken.;Page ID cannot be in chinese.;Cannot have dash (-) in Page ID.;"} %>
|
||||||
<span><%= t("front_page.name_field_helper") %></span>
|
<span><%= t("front_page.name_field_helper") %></span>
|
||||||
</div>
|
</div>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@
|
||||||
<% if params[:action] == "new" %>
|
<% if params[:action] == "new" %>
|
||||||
<%= f.label :name, content_tag(:i, nil, :class => "icons-star")+t(:link)+' ID' %>
|
<%= f.label :name, content_tag(:i, nil, :class => "icons-star")+t(:link)+' ID' %>
|
||||||
<div class="controls">
|
<div class="controls">
|
||||||
<%= f.text_field :page_id, class: "input-xlarge change", data: {"fv-validation" => "required;nospace;pageid_validation;", "fv-messages" => "Cannot be empty.;Cannot have blank spaces;Page id is already taken.;"} %>
|
<%= f.text_field :page_id, class: "input-xlarge change", data: {"fv-validation" => "required;nospace;pageid_validation;detect_chinese;cannot_have_dash;", "fv-messages" => "Cannot be empty.;Cannot have blank spaces;Page id is already taken.;Page ID cannot be in chinese.;Cannot have dash (-) in Page ID.;"} %>
|
||||||
<span class="help-block"><%= t("front_page.name_field_helper") %></span>
|
<span class="help-block"><%= t("front_page.name_field_helper") %></span>
|
||||||
</div>
|
</div>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
@ -44,7 +44,7 @@
|
||||||
url = "#"
|
url = "#"
|
||||||
end
|
end
|
||||||
%>
|
%>
|
||||||
<%= n.text_field locale, class:"input-xlarge change", data: {"fv-validation" => "required;url;", "fv-messages" => "Cannot be empty.;Must be valid url.;"}, :value=>url rescue "#" %>
|
<%= n.text_field locale, class:"input-xlarge change", data: {"fv-validation" => "required;urlwithip;detect_chinese;", "fv-messages" => "Cannot be empty.;Must be valid url.;Cannont have chinese.;"}, :value=>url rescue "#" %>
|
||||||
<% end %>
|
<% end %>
|
||||||
</div>
|
</div>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
|
||||||
|
|
@ -14,5 +14,9 @@
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
$(document).ready(function(){
|
$(document).ready(function(){
|
||||||
var fromvalidator = new FormValidator($("form.edit_page"));
|
var fromvalidator = new FormValidator($("form.edit_page"));
|
||||||
|
|
||||||
|
fromvalidator.validate_functions.detect_chinese = function(value){
|
||||||
|
return (value.match(/[\u3400-\u9FBF]/) == null);
|
||||||
|
}
|
||||||
})
|
})
|
||||||
</script>
|
</script>
|
||||||
|
|
@ -19,9 +19,14 @@ $(document).ready(function(){
|
||||||
}
|
}
|
||||||
|
|
||||||
fromvalidator.validate_functions.detect_chinese = function(value){
|
fromvalidator.validate_functions.detect_chinese = function(value){
|
||||||
var re1 = new RegExp("^[\u4E00-\uFA29]*$"),
|
// var re1 = new RegExp("^[\u4E00-\uFA29]*$"),
|
||||||
re2 = new RegExp("^[\uE7C7-\uE7F3]*$"); //Chinese character range
|
// re2 = new RegExp("^[\uE7C7-\uE7F3]*$"); //Chinese character range
|
||||||
return (!(re1.test(value) && (! re2.test(value))));
|
// return (!(re1.test(value) && (! re2.test(value))));
|
||||||
|
return (value.match(/[\u3400-\u9FBF]/) == null);
|
||||||
|
}
|
||||||
|
|
||||||
|
fromvalidator.validate_functions.cannot_have_dash = function(value){
|
||||||
|
return (value.indexOf("-") == -1 ? true : false);
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
</script>
|
</script>
|
||||||
|
|
@ -5,7 +5,10 @@ require File.expand_path('../application', __FILE__)
|
||||||
Orbit::Application.initialize!
|
Orbit::Application.initialize!
|
||||||
Orbit::Application.config.secret_key_base = 'acc6ffc5a7d360c9cf2a7bdb4ddf9a897942ec6767413a5c0324a0fa8b86197a96298288a66bd46d8770d8b6edf509aad65716961c2c364ce006b475e6cfd418'
|
Orbit::Application.config.secret_key_base = 'acc6ffc5a7d360c9cf2a7bdb4ddf9a897942ec6767413a5c0324a0fa8b86197a96298288a66bd46d8770d8b6edf509aad65716961c2c364ce006b475e6cfd418'
|
||||||
OrbitApp.cleanup_modules
|
OrbitApp.cleanup_modules
|
||||||
OrbitApp.check_module_permissions
|
begin
|
||||||
|
OrbitApp.check_module_permissions
|
||||||
|
rescue Exception => e
|
||||||
|
end
|
||||||
|
|
||||||
if Site.count == 0
|
if Site.count == 0
|
||||||
site = Site.new
|
site = Site.new
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue