Merge for new timeline updates and font updates
This commit is contained in:
commit
f635f642fc
604 files changed
+26660
-2980
No files matched your search
+22
-1
@@ -19,6 +19,26 @@ module OrbitCoreLib
|
||||
|
||||
end
|
||||
|
||||
def cur_user_is_sub_manager_of(title)
|
||||
authed_users(title).include?(User.current)
|
||||
end
|
||||
|
||||
def app_auth
|
||||
ModuleApp.first(conditions: {:title => self.class::APP_NAME} )
|
||||
end
|
||||
|
||||
def pp_object
|
||||
"Object Auth method 'pp_object' need to be defined for class #{self.class}"
|
||||
end
|
||||
|
||||
def get_object_auth_by_title(title)
|
||||
oa = self.object_auths.where({title: title }).first
|
||||
if oa.nil? && (self.class::ObjectAuthTitlesOptions.include? title)
|
||||
oa = self.object_auths.create title: title
|
||||
end
|
||||
oa
|
||||
end
|
||||
|
||||
def authed_users(title=nil)
|
||||
users = []
|
||||
users = case title
|
||||
@@ -33,7 +53,7 @@ module OrbitCoreLib
|
||||
[]
|
||||
end
|
||||
else
|
||||
self.object_auths.where(title: title).first.auth_users rescue []
|
||||
get_object_auth_by_title(title).auth_users rescue []
|
||||
end
|
||||
users
|
||||
end
|
||||
@@ -59,6 +79,7 @@ module OrbitCoreLib
|
||||
module PermissionUnility
|
||||
private
|
||||
def check_permission(type = :use)
|
||||
setup_vars
|
||||
permission_grant = current_user.admin?? true : false
|
||||
module_app = @module_app.nil?? find_module_app_by_token(params[:token]) : @module_app
|
||||
unless permission_grant
|
||||
|
||||
@@ -14,7 +14,7 @@ module ParserBackEnd
|
||||
# }.join(' | ')
|
||||
# end
|
||||
# c.define_tag 'link' do |tag|
|
||||
# item = Item.first(:conditions => { :full_name => tag.attr['name'] })
|
||||
# item = Item.first(:conditions => { :path => tag.attr['name'] })
|
||||
# ret = ''
|
||||
# ret << "<a href='"
|
||||
# ret << eval("admin_#{item._type.downcase}_path(item.id)")
|
||||
@@ -23,62 +23,19 @@ module ParserBackEnd
|
||||
# ret << "</a>"
|
||||
# end
|
||||
|
||||
def parse_page_edit_noko(page, id = nil)
|
||||
def parse_page_edit_noko(page)
|
||||
body = Nokogiri::HTML(page.design.layout.body)
|
||||
parse_menu(body, page, true)
|
||||
public_r_tags = parse_content_edits(body, page, id)
|
||||
public_r_tags = parse_contents(body, page, true)
|
||||
parse_images(body, page)
|
||||
|
||||
parse_footer(body, page)
|
||||
parse_sub_menu(body, page)
|
||||
public_r_tags.each do |tag|
|
||||
send("parse_#{tag}s", body, page,id)
|
||||
send("parse_#{tag}s", body, page, true)
|
||||
end
|
||||
|
||||
body.to_html
|
||||
end
|
||||
|
||||
# page_contents
|
||||
def parse_content_edits(body, page, id)
|
||||
public_r_tags = []
|
||||
body.css('.page_content').each do |content|
|
||||
ret = ''
|
||||
if (content["main"] == "true" && !page.module_app.nil?)
|
||||
ret << "<div id='appfrontend' class='dymanic_load' path='/panel/#{page.module_app.key}/front_end/#{page.app_frontend_url}?inner=true&page_id=#{page.id}"
|
||||
ret << "&category_id=#{page.category}" if page[:category]
|
||||
ret << "'></div>"
|
||||
else
|
||||
part = page.page_parts.detect{ |p| p.name.to_s == content['name'].to_s } rescue nil
|
||||
ret << "<div id='#{content['name']}' part_id='#{part.id}' class='editable' style='border:solid 1px; margin:5px; padding:5px;'>" if part
|
||||
ret << "<div class='edit_link' style='display:none'>"
|
||||
ret << " <a href='#{edit_admin_page_part_path(part.id)}' class='nav'>#{t(:edit)}</a>" if part
|
||||
ret << '</div>'
|
||||
case part.kind
|
||||
when 'text'
|
||||
ret << part.i18n_variable[I18n.locale] rescue ''
|
||||
when 'module_widget'
|
||||
if part[:category]
|
||||
ret << "<div class='dymanic_load' path='/panel/#{part.module_app.key}/widget/#{part.widget_path}?category_id=#{part[:category]}'></div>"
|
||||
else
|
||||
ret << "<div class='dymanic_load' path='/panel/#{part.module_app.key}/widget/#{part.widget_path}'></div>"
|
||||
end
|
||||
when 'public_r_tag'
|
||||
ret << "<r:#{part.public_r_tag} id='#{part.public_r_tag_object_id}'/>"
|
||||
public_r_tags << part.public_r_tag
|
||||
else
|
||||
''
|
||||
end if part
|
||||
end
|
||||
scope = "<#{content.name}"
|
||||
content.attributes.each_pair do |key, value|
|
||||
scope << " #{key}='#{value}'"
|
||||
end
|
||||
scope << ">#{ret}</#{content.name}>"
|
||||
fragment = Nokogiri::HTML::DocumentFragment.new(body, scope)
|
||||
content.swap(fragment)
|
||||
end
|
||||
public_r_tags.uniq
|
||||
end
|
||||
|
||||
|
||||
def self.included(base)
|
||||
base.send :helper_method, :parse_page_edit_noko if base.respond_to? :helper_method
|
||||
end
|
||||
|
||||
+143
-42
@@ -1,58 +1,61 @@
|
||||
module ParserCommon
|
||||
|
||||
def menu_level(page, current, menu, edit = false)
|
||||
include ActionView::Helpers::TagHelper
|
||||
|
||||
def menu_level(page, current_page, current, menu, edit = false)
|
||||
res = ''
|
||||
if menu.levels > 0 && current <= menu.levels
|
||||
if current != 0
|
||||
res << "<div class='rc_dm'>"
|
||||
item = rand(100000)
|
||||
res << "<a href='#{edit ? admin_page_path(page.id) : page.full_name}' class='dm_ctrl' rel='#{item}'>#{page.i18n_variable[I18n.locale]}<span class='down'></span></a>"
|
||||
if page.children.size > 0
|
||||
res << "<div id='#{item}' class='dm_list #{menu.values['class_#{current}']}'>"
|
||||
res << "<ul class='ini_list'>"
|
||||
i = nil
|
||||
i = 1 if menu.values["li_incremental_#{current}"]
|
||||
page.children.each do |child|
|
||||
res << menu_li(child, current, menu, i, edit)
|
||||
i += 1 if i
|
||||
end
|
||||
res << "</ul>"
|
||||
res << "</div>"
|
||||
end
|
||||
res << "</div>"
|
||||
else
|
||||
res << '<ul>'
|
||||
res << "<li>" + "<a href='#{edit ? admin_page_path(page.id) : page.full_name}' class='dm_ctrl'>#{page.i18n_variable[I18n.locale]}</a>" + "</li>"
|
||||
page.children.each do |child|
|
||||
res << "<li>" + menu_level(child, current + 1, menu, edit) + "</li>"
|
||||
end
|
||||
res << '</ul>'
|
||||
if page.visible_children.size > 0
|
||||
res << "<ul class='"
|
||||
res << menu.values["class_#{current}"] rescue nil
|
||||
res << "'>"
|
||||
i = nil
|
||||
i = 1 if menu.values["li_incremental_#{current}"]
|
||||
if menu.values['home'] && current == 1
|
||||
res << menu_li(page, current_page, current, menu, i, edit)
|
||||
end
|
||||
page.visible_children.each do |child|
|
||||
res << menu_li(child, current_page, current, menu, i, edit)
|
||||
i += 1 if i
|
||||
end
|
||||
res << "</ul>"
|
||||
end
|
||||
res
|
||||
end
|
||||
|
||||
def menu_li(page, current, menu, i, edit)
|
||||
res = "<li class="
|
||||
res << menu.values["li_class_#{current}"]
|
||||
def menu_li(page, current_page, current, menu, i, edit)
|
||||
res = "<li class='"
|
||||
res << menu.values["li_class_#{current}"] rescue nil
|
||||
res << "_#{i}" if i
|
||||
res << ">"
|
||||
if page.children.size > 0
|
||||
res << menu_level(page, current + 1, menu, edit)
|
||||
else
|
||||
res << "<a href='#{edit ? admin_page_path(page.id) : page.full_name}' class='nav dm_ctrl'>#{page.i18n_variable[I18n.locale]}</a>"
|
||||
end
|
||||
res << " active" if (current_page.id.eql?(page.id) || current_page.descendant_of?(page))
|
||||
res << "'>"
|
||||
root = "/"
|
||||
res << "<a href='#{edit ? root + admin_page_path(page.id) : (page._type.eql?('Page') ? root + page.path : page.url)}'><span>#{page.i18n_variable[I18n.locale]}</span></a>"
|
||||
if page.visible_children.size > 0 && current <= menu.levels
|
||||
res << "<span class='dot'></span>"
|
||||
res << menu_level(page, current_page, current + 1, menu, edit)
|
||||
end unless (page.root? rescue nil)
|
||||
res << "</li>"
|
||||
end
|
||||
|
||||
# ad_banners
|
||||
def parse_ad_banners(body = nil, page = nil, id = nil)
|
||||
def parse_ad_banners(body = nil, page = nil, edit=nil)
|
||||
body.css('ad_banner').each do |banner|
|
||||
res = ''
|
||||
ad_banner = AdBanner.find(banner["id"]) rescue nil
|
||||
if ad_banner
|
||||
res << "<script type='text/javascript'>
|
||||
$(document).ready(function(){ $('#slideshow-#{ad_banner.title.dehumanize}').cycle({delay: -1000, fx: '#{ad_banner.ad_fx.nil?? 'fade': ad_banner.ad_fx}', timeoutFn: getTimeout }); });
|
||||
$(document).ready(function(){
|
||||
$('#slideshow-#{ad_banner.title.dehumanize}').cycle({
|
||||
delay: -1000,
|
||||
fx: '#{ad_banner.ad_fx.nil? ? 'fade': ad_banner.ad_fx}',
|
||||
timeoutFn: getTimeout,
|
||||
pager: '#banner_nav',
|
||||
pagerAnchorBuilder: function(idx, slide) {
|
||||
return \"<li><a href='#'>sfdsfsf</a></li>\";
|
||||
}
|
||||
});
|
||||
});
|
||||
</script>"
|
||||
res << "<ul id='banner_nav' class='clear'></ul>"
|
||||
res << "<div id='slideshow-#{ad_banner.title.dehumanize}'>"
|
||||
printable_ad_images = []
|
||||
ad_banner.ad_images.each do |ad_image|
|
||||
@@ -65,8 +68,8 @@ module ParserCommon
|
||||
printable_ad_images.shuffle!
|
||||
printable_ad_images.each do |ad_image| #TODO Need Reflact
|
||||
res << "<img src='#{ad_image.file}' "
|
||||
res << "alt='#{ad_image.title || ' '}' "
|
||||
res << "time_to_next='#{ad_banner.transition_sec}' "
|
||||
res << "alt='#{ad_image.title[I18n.locale] || ' '}' "
|
||||
res << "time_to_next='#{ad_banner.transition_msec}' "
|
||||
res << "link_open='#{ad_image.link_open}' "
|
||||
# res << "link_url='#{(ad_image.direct_to_after_click?? ad_image.out_link : ad_banner.context) || ' '}' "
|
||||
res << "link_url='#{(ad_image.out_link || ad_banner.context || ' ')}' "
|
||||
@@ -80,7 +83,7 @@ module ParserCommon
|
||||
end
|
||||
|
||||
# page_images
|
||||
def parse_images(body, page)
|
||||
def parse_images(body, page, edit=nil)
|
||||
body.css('.page_image').each do |page_image|
|
||||
# image = page.custom_images.detect{|image| image.name.eql?(tag.attr['name']) }
|
||||
# image = page.design.custom_images.detect{|image| image.name.eql?(tag.attr['name']) } unless image
|
||||
@@ -102,8 +105,106 @@ module ParserCommon
|
||||
page_menu = body.css('.page_menu').first
|
||||
home = get_homepage
|
||||
menu = page.design.layout.menu
|
||||
fragment = Nokogiri::HTML::DocumentFragment.new(body, menu_level(home, 0, menu, edit))
|
||||
fragment = Nokogiri::HTML::DocumentFragment.new(body, menu_level(home, page, 1, menu, edit))
|
||||
page_menu.swap(fragment)
|
||||
end
|
||||
|
||||
# sub_menus
|
||||
def parse_sub_menus(body = nil, page = nil, edit=nil)
|
||||
body.css('sub_menu').each do |sub_menu|
|
||||
menu_page = Page.find(sub_menu['id']) rescue nil
|
||||
res = ''
|
||||
if menu_page && menu_page.visible_children.size > 0
|
||||
res << "<div class='category_list'>"
|
||||
res << "<h3 class='h3'>#{menu_page.i18n_variable[I18n.locale]}</h3>"
|
||||
res << "<ul class='list'>"
|
||||
menu_page.visible_children.each do |child|
|
||||
res << "<li class='#{page.id.eql?(child.id) ? 'active' : nil}'>"
|
||||
root = "/"
|
||||
res << "<a href='#{edit ? root + admin_page_path(child.id) : (child._type.eql?('Page') ? root + child.path : child.url)}'>#{child.i18n_variable[I18n.locale]}</a>"
|
||||
res << "</li>"
|
||||
end
|
||||
res << "</ul>"
|
||||
res << "</h3>"
|
||||
res << "</div>"
|
||||
end
|
||||
fragment = Nokogiri::HTML::DocumentFragment.new(body, res)
|
||||
sub_menu.swap(fragment)
|
||||
end
|
||||
end
|
||||
|
||||
# page_footer
|
||||
def parse_footer(body, page)
|
||||
page_footer = body.css('.page_footer').first
|
||||
if page_footer
|
||||
res = "<div id='#{page_footer['id']}', class='#{page_footer['class']}'>"
|
||||
res << @site.footer[I18n.locale] rescue nil
|
||||
res << "</div>"
|
||||
fragment = Nokogiri::HTML::DocumentFragment.new(body ,res)
|
||||
page_footer.swap(fragment) rescue nil
|
||||
else
|
||||
''
|
||||
end
|
||||
end
|
||||
|
||||
# page_sub_menu
|
||||
def parse_sub_menu(body, page)
|
||||
page_sub_menu = body.css('.page_sub_menu').first
|
||||
if page_sub_menu
|
||||
res = "<div id='#{page_sub_menu['id']}', class='#{page_sub_menu['class']}'>"
|
||||
res << @site.sub_menu[I18n.locale] rescue nil
|
||||
res << "</div>"
|
||||
fragment = Nokogiri::HTML::DocumentFragment.new(body ,res)
|
||||
page_sub_menu.swap(fragment) rescue nil
|
||||
else
|
||||
''
|
||||
end
|
||||
end
|
||||
|
||||
# page_contents
|
||||
def parse_contents(body, page, edit=nil)
|
||||
public_r_tags = []
|
||||
body.css('.page_content').each do |content|
|
||||
ret = ''
|
||||
category = params[:category_id].blank? ? page[:category] : params[:category_id]
|
||||
tag = params[:tag_id].blank? ? page[:tag] : params[:tag_id]
|
||||
if (content["main"] == "true" && !page.module_app.nil?)
|
||||
ret << "<div id='appfrontend' class='dymanic_load' path='/panel/#{page.module_app.key}/front_end/#{page.app_frontend_url}"
|
||||
ret << "/#{params[:id]}" if params[:id] && !params[:id].eql?(page.id.to_s)
|
||||
ret << "?inner=true&page_id=#{page.id}&category_id=#{category}&tag_id=#{tag}&preview=#{params[:preview]}&page_main=#{params[:page_main]}"
|
||||
ret << "'></div>"
|
||||
else
|
||||
part = page.page_parts.detect{ |p| p.name.to_s == content['name'].to_s } rescue nil
|
||||
part_title = part.title[I18n.locale] rescue nil
|
||||
if edit
|
||||
ret << "<div id='#{content['name']}' part_id='#{part.id}' class='editable' style='border:solid 1px; margin:5px; padding:5px;'>" if part
|
||||
ret << "<div class='edit_link' style='display:none'>"
|
||||
ret << " <a href='#{edit_admin_page_part_path(part.id)}' class='nav'>#{t(:edit)}</a>" if part
|
||||
ret << '</div>'
|
||||
end
|
||||
case part.kind
|
||||
when 'text'
|
||||
ret << part.i18n_variable[I18n.locale] rescue ''
|
||||
when 'module_widget'
|
||||
url = "/panel/#{part.module_app.key}/widget/#{part.widget_path}?inner=true"
|
||||
options = "&category_id=#{!part[:category].blank? ? part[:category].blank? : category}&tag_id=#{!part[:tag].blank? ? part[:tag] : tag}&page=#{params[:page]}&part_title=#{Rack::Utils.escape(part_title).gsub("+", "%20") rescue nil}"
|
||||
ret << "<div class='dymanic_load' path='#{url + options}'></div>"
|
||||
when 'public_r_tag'
|
||||
ret << "<r:#{part.public_r_tag} id='#{part.public_r_tag_object_id}'/>"
|
||||
public_r_tags << part.public_r_tag
|
||||
else
|
||||
''
|
||||
end if part
|
||||
end
|
||||
scope = "<#{content.name}"
|
||||
content.attributes.each_pair do |key, value|
|
||||
scope << " #{key}='#{value}'"
|
||||
end
|
||||
scope << ">#{ret}</#{content.name}>"
|
||||
fragment = Nokogiri::HTML::DocumentFragment.new(body, scope)
|
||||
content.swap(fragment)
|
||||
end
|
||||
public_r_tags.uniq
|
||||
end
|
||||
|
||||
end
|
||||
@@ -11,7 +11,7 @@ module ParserFrontEnd
|
||||
# }.join(' | ')
|
||||
# end
|
||||
# c.define_tag 'link' do |tag|
|
||||
# item = Item.first(:conditions => { :full_name => tag.attr['name'] })
|
||||
# item = Item.first(:conditions => { :path => tag.attr['name'] })
|
||||
# ret = ''
|
||||
# ret << "<a href='#{tag.attr['name']}'>"
|
||||
# ret << item.i18n_variable[I18n.locale]
|
||||
@@ -21,57 +21,18 @@ module ParserFrontEnd
|
||||
|
||||
require 'nokogiri'
|
||||
|
||||
def parse_page_noko(page, id = nil)
|
||||
def parse_page_noko(page)
|
||||
body = Nokogiri::HTML(page.design.layout.body)
|
||||
parse_menu(body, page)
|
||||
public_r_tags = parse_contents(body, page, id)
|
||||
public_r_tags = parse_contents(body, page)
|
||||
parse_images(body, page)
|
||||
|
||||
parse_footer(body, page)
|
||||
parse_sub_menu(body, page)
|
||||
public_r_tags.each do |tag|
|
||||
send("parse_#{tag}s", body, page,id)
|
||||
send("parse_#{tag}s", body, page)
|
||||
end
|
||||
|
||||
body.to_html
|
||||
end
|
||||
|
||||
# page_contents
|
||||
def parse_contents(body, page, id)
|
||||
public_r_tags = []
|
||||
body.css('.page_content').each do |content|
|
||||
ret = ''
|
||||
if (content["main"] == "true" && !page.module_app.nil?)
|
||||
ret << "<div id='appfrontend' class='dymanic_load' path='/panel/#{page.module_app.key}/front_end/#{page.app_frontend_url}"
|
||||
ret << "/#{id}" if id
|
||||
ret << "?inner=true&page_id=#{page.id}"
|
||||
ret << "&category_id=#{page.category}" if page[:category]
|
||||
ret << "'></div>"
|
||||
else
|
||||
part = page.page_parts.detect{ |p| p.name.to_s == content['name'].to_s } rescue nil
|
||||
case part.kind
|
||||
when 'text'
|
||||
ret << part.i18n_variable[I18n.locale] rescue ''
|
||||
when 'module_widget'
|
||||
if part[:category]
|
||||
ret << "<div class='dymanic_load' path='/panel/#{part.module_app.key}/widget/#{part.widget_path}?inner=true&category_id=#{part[:category]}'></div>"
|
||||
else
|
||||
ret << "<div class='dymanic_load' path='/panel/#{part.module_app.key}/widget/#{part.widget_path}?inner=true'></div>"
|
||||
end
|
||||
when 'public_r_tag'
|
||||
ret << "<r:#{part.public_r_tag} id='#{part.public_r_tag_object_id}'/>"
|
||||
public_r_tags << part.public_r_tag
|
||||
else
|
||||
''
|
||||
end if part
|
||||
end
|
||||
scope = "<#{content.name}"
|
||||
content.attributes.each_pair do |key, value|
|
||||
scope << " #{key}='#{value}'"
|
||||
end
|
||||
scope << ">#{ret}</#{content.name}>"
|
||||
fragment = Nokogiri::HTML::DocumentFragment.new(body, scope)
|
||||
content.swap(fragment)
|
||||
end
|
||||
public_r_tags.uniq
|
||||
end
|
||||
|
||||
end
|
||||
@@ -1,3 +1,4 @@
|
||||
require 'resque_scheduler/tasks'
|
||||
# encoding: utf-8
|
||||
|
||||
namespace :anc do
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
# encoding: utf-8
|
||||
|
||||
namespace :designs do
|
||||
task :change_to, [:design_id] => [:environment] do |t, args|
|
||||
design = Design.find(args[:design_id])
|
||||
theme_id = design.themes.first.id
|
||||
Page.all.each do |page|
|
||||
page.update_attributes({design_id: args[:design_id], theme_id: (theme_id unless page.root?)})
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
@@ -0,0 +1,19 @@
|
||||
# encoding: utf-8
|
||||
|
||||
namespace :items do
|
||||
task :tree_changes => :environment do
|
||||
Item.all.each do |item|
|
||||
item.position -= item.position > 5 ? 2 : 1
|
||||
item.parent_ids = ancestors(item)
|
||||
item.rename(:full_name, :path)
|
||||
item.save
|
||||
end
|
||||
end
|
||||
|
||||
def ancestors(item)
|
||||
node, nodes = item, []
|
||||
nodes << node = node.parent while !node.parent.blank? rescue nil
|
||||
nodes.reverse
|
||||
end
|
||||
|
||||
end
|
||||
@@ -0,0 +1,39 @@
|
||||
# require "resque/tasks"
|
||||
# require 'resque/scheduler'
|
||||
# require 'resque/scheduler'
|
||||
|
||||
#
|
||||
# task "resque:setup" => :environment
|
||||
# Resque tasks
|
||||
require 'resque/tasks'
|
||||
require 'resque_scheduler/tasks'
|
||||
|
||||
namespace :resque do
|
||||
task :setup => :environment do
|
||||
require 'resque'
|
||||
require 'resque_scheduler'
|
||||
require 'resque/scheduler'
|
||||
|
||||
# you probably already have this somewhere
|
||||
Resque.redis = 'localhost:6379'
|
||||
|
||||
# If you want to be able to dynamically change the schedule,
|
||||
# uncomment this line. A dynamic schedule can be updated via the
|
||||
# Resque::Scheduler.set_schedule (and remove_schedule) methods.
|
||||
# When dynamic is set to true, the scheduler process looks for
|
||||
# schedule changes and applies them on the fly.
|
||||
# Note: This feature is only available in >=2.0.0.
|
||||
#Resque::Scheduler.dynamic = true
|
||||
|
||||
# The schedule doesn't need to be stored in a YAML, it just needs to
|
||||
# be a hash. YAML is usually the easiest.
|
||||
Resque.schedule = YAML.load_file('config/resque_schedule.yml')
|
||||
|
||||
# If your schedule already has +queue+ set for each job, you don't
|
||||
# need to require your jobs. This can be an advantage since it's
|
||||
# less code that resque-scheduler needs to know about. But in a small
|
||||
# project, it's usually easier to just include you job classes here.
|
||||
# So, someting like this:
|
||||
#require 'jobs'
|
||||
end
|
||||
end
|
||||
Reference in new issue
Block a user