change in parser and widget rendering completed with also lot of changes in kernel

Conflicts:
	app/helpers/orbit_helper.rb
This commit is contained in:
Harry Bomrah 2014-05-22 19:19:25 +08:00
parent 40a0dbb555
commit d7107f02f4
40 changed files with 670 additions and 459 deletions

View File

@ -65,10 +65,10 @@ if($.support.touch) {
$checked.each(function(i) { $checked.each(function(i) {
if($(this).attr('type') == "checkbox") { if($(this).attr('type') == "checkbox") {
if($(this).data().disabled) { if($(this).data().disabled) {
console.log("d")
$(this).parent('.togglebox').addClass('disable').closest('li').addClass('disabled'); $(this).parent('.togglebox').addClass('disable').closest('li').addClass('disabled');
if($(this).prop('checked')) { if($(this).prop('checked')) {
$(this).parent('.togglebox').removeClass('disable').closest('li').removeClass('disabled'); $(this).parent('.togglebox').removeClass('disable').closest('li').removeClass('disabled');
$(this).val("1");
}; };
} else { } else {
if($(this).prop('checked')) { if($(this).prop('checked')) {
@ -79,6 +79,12 @@ if($.support.touch) {
change: function() { change: function() {
$(this).parent('.togglebox').toggleClass('disable'); $(this).parent('.togglebox').toggleClass('disable');
$(this).closest('tr').toggleClass('disable'); $(this).closest('tr').toggleClass('disable');
if($(this).is(":checked")){
$(this).val("1");
}else{
$(this).val("0");
$(this).prop("checked","checked");
}
} }
}); });
}; };

View File

@ -25,8 +25,11 @@
$.each(data.parts,function(i,part){ $.each(data.parts,function(i,part){
var page_part = $("*[" + part.name + "]"); var page_part = $("*[" + part.name + "]");
$.each(part.subparts,function(x,subpart){ $.each(part.subparts,function(x,subpart){
var newsub = $("<div data-ps='" + x + "'>" + subpart.module + "/" + subpart.widget + "</div>"); var newsub = (subpart.kind == "module_widget" ? $("<div data-partid='" + part.id + "' data-ps='" + subpart.id + "'>" + subpart.module + "/" + subpart.widget + "</div>") : $("<div data-partid='" + part.id + "' data-ps='" + subpart.id + "'>Text</div>"));
page_part.prepend(newsub); page_part.prepend(newsub);
newsub.click(function(){
window.location.href = "/page_parts/edit_sub_part?page_id=" + page_params["id"] + "&part_id=" + $(this).data("partid") + "&sub_part_id=" + $(this).data("ps");
})
}) })
}) })
}) })
@ -41,8 +44,7 @@
window.location.href = "/page_parts/new?part=" + part.data("pp") + "&page_id=" + page_params["id"]; window.location.href = "/page_parts/new?part=" + part.data("pp") + "&page_id=" + page_params["id"];
} }
}) })
$(this).append(add_btn); part.append(add_btn);
}) })
}) })
})(); })();

View File

@ -6,6 +6,7 @@ class Admin::SitesController < OrbitAdminController
end end
def site_info def site_info
@pages = Page.where(:module=>"page_content")
end end
def responsive_setting def responsive_setting

View File

@ -5,9 +5,10 @@ class PagePartsController < ApplicationController
@part.sub_parts.build @part.sub_parts.build
@part_number = params[:part] @part_number = params[:part]
@page_id = params[:page_id] @page_id = params[:page_id]
@modules = ModuleApp.all @modules = ModuleApp.widget_enabled
@no_orbit_bar = @no_side_bar = true @no_orbit_bar = @no_side_bar = true
@html_class = "page-parts" @select_number = 0
@html_class = "page-parts"
render :layout => "structure" render :layout => "structure"
end end
@ -16,16 +17,70 @@ class PagePartsController < ApplicationController
@part = page.page_parts.where(:part_id => params[:id]).first @part = page.page_parts.where(:part_id => params[:id]).first
@part.sub_parts.build @part.sub_parts.build
@page_id = params[:page_id] @page_id = params[:page_id]
@modules = ModuleApp.all @part_number = params[:id]
@select_number = @part.sub_parts.count
@modules = ModuleApp.widget_enabled
@no_orbit_bar = @no_side_bar = true @no_orbit_bar = @no_side_bar = true
@html_class = "page-parts" @html_class = "page-parts"
render :layout => "structure" render :layout => "structure"
end end
def edit_sub_part
@part = PagePart.find(params[:part_id])
@subpart = SubPart.find(params[:sub_part_id])
@select_number = @part.sub_parts.index(@subpart)
@kind = @subpart.kind
@modules = ModuleApp.widget_enabled
if @kind == "module_widget"
@widget_types = []
module_name = @subpart.module
Dir.glob("#{Rails.root}/app/templates/#{@key}/modules/#{module_name.downcase}/*").each do |w|
w = File.basename(w, ".*")
w = File.basename(w, ".*")
@widget_types << w.gsub("_","") if w != "index" && w != "show"
end
app = ModuleApp.find_by_key(module_name)
@categories = app.categories
@widget_methods = app.get_registration.get_widget_methods
@widget_settings = app.get_registration.get_widget_settings
@data_count = nil
if !@widget_settings.blank?
@data_count = @widget_settings["data_count"] rescue nil
if !@widget_settings['override_category_with'].nil?
@custom = @widget_settings['override_category_with'].classify.constantize.all
@multiselect = @widget_settings['multiselect'] rescue true
@display_field = @widget_settings['display_field']
end
end
end
@no_orbit_bar = @no_side_bar = true
@html_class = "page-parts"
render :layout => "structure"
end
def update_sub_part
subpart = SubPart.find(params[:id])
p = part_params["sub_parts_attributes"]
keys = p.keys
final_params = {}
keys.each do |key|
p["#{key}"].each do |k,value|
final_params["#{k}"] = value
end
end
if final_params["kind"] == "none"
subpart.destroy
else
subpart.update_attributes(final_params)
end
render :json => {"success"=>true}.to_json
end
def getwidgets def getwidgets
module_name = params[:module] module_name = params[:module]
part = PagePart.where(:part_id => params[:part_id], :page_id => params[:page_id]).first
@select_number = params[:number_of_select] @select_number = part.sub_parts.count rescue 0
@widget_types = [] @widget_types = []
Dir.glob("#{Rails.root}/app/templates/#{@key}/modules/#{module_name.downcase}/*").each do |w| Dir.glob("#{Rails.root}/app/templates/#{@key}/modules/#{module_name.downcase}/*").each do |w|
w = File.basename(w, ".*") w = File.basename(w, ".*")
@ -34,7 +89,18 @@ class PagePartsController < ApplicationController
end end
module_name = module_name.downcase.singularize module_name = module_name.downcase.singularize
app = ModuleApp.find_by_key(module_name) app = ModuleApp.find_by_key(module_name)
@categories = app.categories
@widget_methods = app.get_registration.get_widget_methods @widget_methods = app.get_registration.get_widget_methods
@widget_settings = app.get_registration.get_widget_settings
@data_count = nil
if !@widget_settings.blank?
@data_count = @widget_settings["data_count"] rescue nil
if !@widget_settings['override_category_with'].nil?
@custom = @widget_settings['override_category_with'].classify.constantize.all
@multiselect = @widget_settings['multiselect'] rescue true
@display_field = @widget_settings['display_field']
end
end
render :layout => false render :layout => false
end end
@ -47,9 +113,9 @@ class PagePartsController < ApplicationController
subparts = part.sub_parts subparts = part.sub_parts
subpart = [] subpart = []
subparts.each do |p| subparts.each do |p|
subpart << {"module" => p.module, "widget" => p.widget_type} subpart << {"module" => p.module, "widget" => p.widget_type, "id" => p.id.to_s, "kind" => p.kind}
end end
data << {"name" => partid, "subparts" => subpart} data << {"name" => partid, "subparts" => subpart, "id" => part.id.to_s}
end end
render :json => {"parts" => data}.to_json render :json => {"parts" => data}.to_json
end end
@ -57,20 +123,20 @@ class PagePartsController < ApplicationController
def create def create
@part = PagePart.new(part_params) @part = PagePart.new(part_params)
@part.save! @part.save!
redirect_to pages_edit_view_path(:id => params[:page_part][:page_id]) render :json => {"success"=>true}.to_json
end end
def update def update
@part = PagePart.find(params[:page_part][:page_part_id]) @part = PagePart.find(params[:part_id])
@part.update_attributes(part_params) @part.update_attributes(part_params)
redirect_to pages_edit_view_path(:id => params[:page_part][:page_id]) render :json => {"success"=>true}.to_json
end end
private private
def part_params def part_params
params.require(:page_part).permit(:part_id, :page_id, sub_parts_attributes: [:module, :widget_type,:widget_method, :id]) params.require(:page_part).permit!
end end
end end

View File

@ -17,7 +17,10 @@ class PagesController < ApplicationController
@dataApi = "edit" @dataApi = "edit"
# @qq = render_to_string(:partial => @p, :layout => false) # @qq = render_to_string(:partial => @p, :layout => false)
render get_view view = get_view
if File.exists?(view)
render view
end
end end
def home def home
@ -69,7 +72,6 @@ class PagesController < ApplicationController
end end
impressionist(page) impressionist(page)
# render render_final_page("#{module_app}/#{params[:target_action]}",page)
render :html => render_final_page("#{module_app}/#{params[:target_action]}",page,layout).html_safe render :html => render_final_page("#{module_app}/#{params[:target_action]}",page,layout).html_safe
else else
render :file => "#{Rails.root}/public/404.html", :layout => false, :status => :not_found render :file => "#{Rails.root}/public/404.html", :layout => false, :status => :not_found
@ -168,56 +170,58 @@ class PagesController < ApplicationController
private private
def render_final_page(original_view=get_view,page,layout) def render_final_page(original_view=get_view,page,layout)
if layout if layout
parts = page.page_parts rescue [] parts = page.page_parts rescue []
@part_partials = {} @part_partials = {}
parts.each do |part| parts.each do |part|
subparts = part.sub_parts subparts = part.sub_parts
partials = [] partials = []
subparts.each do |subpart| subparts.each do |subpart|
partials << render_widget_for_frontend(subpart.module,subpart.widget_method,subpart.widget_type) if subpart.kind == "module_widget"
OrbitHelper.set_widget_data_count subpart.data_count
OrbitHelper.set_widget_categories subpart.categories
OrbitHelper.set_widget_module_app subpart.module
custom_value = subpart.custom_string_field || subpart.custom_array_field rescue nil
if !custom_value.nil?
OrbitHelper.set_widget_custom_value custom_value
end
partials << render_widget_for_frontend(subpart.module,subpart.widget_method,subpart.widget_type)
elsif subpart.kind == "text"
partials << subpart.content
end
end
@part_partials["data-pp='#{part.part_id}'"] = partials
end end
@part_partials["data-pp='#{part.part_id}'"] = partials @file = nil
end @layout_html = nil
if original_view == "home"
@file = File.join('../templates', "#{@key}", '/home/index.html.erb')
else
@file = File.join('../templates', "#{@key}", '/home/page.html.erb')
end
@layout_html = render_to_string(@file)
doc = Nokogiri::HTML(@layout_html, nil, "UTF-8")
@part_partials.each do |key, partial|
html_string = ""
partial.each do |p|
html_string = html_string + p
end
pp = doc.css("*[#{key}]")
pp = pp[0]
pp.inner_html = html_string
end
if original_view != "home"
viewarea = doc.css("*[data-content='true']")[0]
viewarea.inner_html = render_to_string(original_view)
end
doc.to_html
@file = nil
@layout_html = nil
if original_view == "home"
@file = File.join('../templates', "#{@key}", '/home/index.html.erb')
else else
@file = File.join('../templates', "#{@key}", '/home/page.html.erb') render_to_string(original_view)
end end
@layout_html = render_to_string(@file)
doc = Nokogiri::HTML(@layout_html, nil, "UTF-8")
@part_partials.each do |key, partial|
html_string = ""
partial.each do |p|
html_string = html_string + p
end
pp = doc.css("*[#{key}]")
pp = pp[0]
pp.inner_html = html_string
end
if original_view != "home"
viewarea = doc.css("*[data-content='true']")[0]
viewarea.inner_html = render_to_string(original_view)
end
doc.to_html
else
render_to_string(original_view)
end
# newlayout = "#{page.name}_layout.html.erb"
# file_path = File.join(Rails.root, 'app', 'views', 'frontend', newlayout)
# f = File.open(file_path,"w")
# f.write(doc.to_html)
# f.close
# view_to_render = "frontend/#{newlayout}"
# view_to_render
end end
def get_widget_path(widget) def get_widget_path(widget)

View File

@ -0,0 +1,18 @@
class SitemapsController < ApplicationController
def index
pages = Page.root.child_pages_enabled_for_sitemap
def create_json(pages)
item = {}
pages.each do |page|
if page.child_page.size > 0
item["#{page.name}"] = {"url"=> "/#{locale.to_s}" + page.url, "children"=>create_json(page.sorted_published_child_pages)}
else
item["#{page.name}"] = {"url"=> "/#{locale.to_s}" + page.url}
end
end
item
end
items = create_json(pages)
items
end
end

View File

@ -16,10 +16,42 @@ module ApplicationHelper
"/module/#{module_name}/show" "/module/#{module_name}/show"
end end
def render_header
site = Site.first
key = Template::KEY
header_file = File.join('../templates', "#{key}", '/home/header.html.erb')
header_file_html = render :file => header_file
header = Nokogiri::HTML(header_file_html, nil, "UTF-8")
sub_menu_html = site.sub_menu
html = header.to_s
html = html.gsub("{{site_name}}",site.title)
html = html.gsub("%7B%7Blogo_url%7D%7D",(site.default_image.file.url rescue "http://placehold.it/50x50"))
if site.sitemap_menu_in_header
sub_menu_html = sub_menu_html + "<a href='/#{I18n.locale.to_s}#{site.site_map_link}'>Sitemap</a>"
end
html = html.gsub("{{header-data}}",sub_menu_html)
html.html_safe
end
def render_footer
site = Site.first
key = Template::KEY
footer_file = File.join('../templates', "#{key}", '/home/footer.html.erb')
footer_file_html = render :file => footer_file
footer = Nokogiri::HTML(footer_file_html, nil, "UTF-8")
html = footer.to_s
site_footer = site.footer
if site.enable_terms_of_use
site_footer = site_footer + "<a href='/#{I18n.locale.to_s}#{site.terms_of_use_link}'>Terms of use</a>"
end
html = html.gsub("{{footer-data}}",site_footer)
html.html_safe
end
def render_menu def render_menu
# json_file = File.read(File.join(Rails.root, 'public', "menu.json")) # json_file = File.read(File.join(Rails.root, 'public', "menu.json"))
# @items = JSON.parse(json_file) # @items = JSON.parse(json_file)
@pages = Page.where(:parent_page_id.ne => "" , :parent_page_id.exists => false).first.sorted_published_child_pages @pages = Page.root.sorted_published_child_pages
def create_json(pages) def create_json(pages)
item = {} item = {}
@ -85,39 +117,39 @@ module ApplicationHelper
def render_view def render_view
def parsing_repeats_again(elements,d,level) def parsing_repeats_again(elements,d,level)
newhtml = [] newhtml = []
oldhtml = [] oldhtml = []
elements.each do |el| elements.each do |el|
html_to_render = "" html_to_render = ""
data_name = el.attr("data-list") data_name = el.attr("data-list")
wrap_elements = el.css("*[data-list][data-level='#{level}']") wrap_elements = el.css("*[data-list][data-level='#{level}']")
if d["#{data_name}"] if d["#{data_name}"]
d["#{data_name}"].each_with_index do |item,i| d["#{data_name}"].each_with_index do |item,i|
element = el.inner_html element = el.inner_html
if wrap_elements.count > 0 if wrap_elements.count > 0
htmls = parsing_repeats_again(wrap_elements,d["#{data_name}"][i], level + 1) htmls = parsing_repeats_again(wrap_elements,d["#{data_name}"][i], level + 1)
htmls[0].each_with_index do |html,i| htmls[0].each_with_index do |html,i|
element = element.gsub(html,htmls[1][i]) element = element.gsub(html,htmls[1][i])
end end
end end
item.each do |key,value| item.each do |key,value|
if !value.kind_of?(Array) if !value.kind_of?(Array)
value = value.nil? ? "" : value value = value.nil? ? "" : value
element = element.gsub("{{#{key}}}",value) element = element.gsub("{{#{key}}}",value.to_s)
element = element.gsub("%7B%7B#{key}%7D%7D",value) element = element.gsub("%7B%7B#{key}%7D%7D",value.to_s)
end end
end end
html_to_render = html_to_render + element html_to_render = html_to_render + element
end end
temp = el.to_s temp = el.to_s
oldhtml << temp oldhtml << temp
temp = temp.gsub(el.inner_html, html_to_render) temp = temp.gsub(el.inner_html, html_to_render)
newhtml << temp newhtml << temp
end end
end end
[oldhtml,newhtml] [oldhtml,newhtml]
end end
if params[:target_action] == "index" if params[:target_action] == "index"
@ -129,54 +161,54 @@ module ApplicationHelper
keys = data.keys keys = data.keys
wrap_elements = doc.css("*[data-list][data-level='0']") wrap_elements = doc.css("*[data-list][data-level='0']")
htmls = parsing_repeats_again(wrap_elements,data,1) htmls = parsing_repeats_again(wrap_elements,data,1)
html = doc.to_s html = doc.to_s
htmls[0].each_with_index do |h,i| htmls[0].each_with_index do |h,i|
html = html.gsub(h,htmls[1][i]) html = html.gsub(h,htmls[1][i])
end end
if keys[1] if keys[1]
(data[keys[1]].kind_of?(Array) ? data[keys[0]] : data[keys[1]]).each do |key,value| (data[keys[1]].kind_of?(Array) ? data[keys[0]] : data[keys[1]]).each do |key,value|
value = value.nil? ? "" : value value = value.nil? ? "" : value
html = html.gsub("{{#{key}}}",value) html = html.gsub("{{#{key}}}",value.to_s)
html = html.gsub("%7B%7B#{key}%7D%7D",value) html = html.gsub("%7B%7B#{key}%7D%7D",value.to_s)
end end
end end
html.html_safe html.html_safe
elsif params[:target_action] == "show" elsif params[:target_action] == "show"
file = File.open(File.join(Rails.root, 'app', 'templates', "#{@key}", 'modules', params[:target_controller].singularize, "#{params[:target_action]}.html.erb")) file = File.open(File.join(Rails.root, 'app', 'templates', "#{@key}", 'modules', params[:target_controller].singularize, "#{params[:target_action]}.html.erb"))
doc = Nokogiri::HTML(file, nil, "UTF-8") doc = Nokogiri::HTML(file, nil, "UTF-8")
file.close file.close
controller = "#{params[:target_controller].capitalize}_controller".classify.constantize.new controller = "#{params[:target_controller].capitalize}_controller".classify.constantize.new
data = controller.send("#{params[:target_action]}") data = controller.send("#{params[:target_action]}")
if data.blank? || data.empty? if data.blank? || data.empty?
file = File.open("#{Rails.root}/public/404.html") file = File.open("#{Rails.root}/public/404.html")
doc = Nokogiri::HTML(file, nil, "UTF-8") doc = Nokogiri::HTML(file, nil, "UTF-8")
file.close file.close
doc.to_html.html_safe doc.to_html.html_safe
else else
unless data['impressionist'].blank? unless data['impressionist'].blank?
impression = data['impressionist'].impressions.create impression = data['impressionist'].impressions.create
impression.user_id = request.session['user_id'] impression.user_id = request.session['user_id']
impression.controller_name = params[:target_controller] impression.controller_name = params[:target_controller]
impression.action_name = params[:target_action] impression.action_name = params[:target_action]
impression.ip_address = request.remote_ip impression.ip_address = request.remote_ip
impression.session_hash = request.session.id impression.session_hash = request.session.id
impression.request_hash = @impressionist_hash impression.request_hash = @impressionist_hash
impression.referrer = request.referrer impression.referrer = request.referrer
impression.save impression.save
data['impressionist'].view_count = data['impressionist'].impressions.count data['impressionist'].view_count = data['impressionist'].impressions.count
data['impressionist'].save data['impressionist'].save
end end
wrap_elements = doc.css("*[data-list][data-level='0']") wrap_elements = doc.css("*[data-list][data-level='0']")
if wrap_elements.count == 0 if wrap_elements.count == 0
wrap_element_html = doc.to_s wrap_element_html = doc.to_s
el = wrap_element_html el = wrap_element_html
data.each do |key,value| data.each do |key,value|
next if key.eql? 'impressionist' next if key.eql? 'impressionist'
value = value.nil? ? "" : value value = value.nil? ? "" : value
el = el.gsub("{{#{key}}}",value) el = el.gsub("{{#{key}}}",value.to_s)
el = el.gsub("%7B%7B#{key}%7D%7D",value) el = el.gsub("%7B%7B#{key}%7D%7D",value.to_s)
end end
el.html_safe el.html_safe
else else
@ -185,24 +217,23 @@ module ApplicationHelper
data.keys.each do |key| data.keys.each do |key|
not_array_key = key if data["#{key}"].kind_of?(Hash) not_array_key = key if data["#{key}"].kind_of?(Hash)
end end
htmls = parsing_repeats_again(wrap_elements,data,1) htmls = parsing_repeats_again(wrap_elements,data,1)
html = doc.to_s html = doc.to_s
htmls[0].each_with_index do |h,i| htmls[0].each_with_index do |h,i|
html = html.gsub(h,htmls[1][i]) html = html.gsub(h,htmls[1][i])
end end
if data["#{not_array_key}"] if data["#{not_array_key}"]
data["#{not_array_key}"].each do |key,value| data["#{not_array_key}"].each do |key,value|
next if key.eql? 'impressionist' next if key.eql? 'impressionist'
value = value.nil? ? "" : value value = value.nil? ? "" : value
html = html.gsub("{{#{key}}}",value) html = html.gsub("{{#{key}}}",value.to_s)
html = html.gsub("%7B%7B#{key}%7D%7D",value) html = html.gsub("%7B%7B#{key}%7D%7D",value.to_s)
end end
end end
html.html_safe html.html_safe
end end
end end
end end
end end
def action_data def action_data
@ -249,4 +280,26 @@ module ApplicationHelper
image_tag(user.avatar.thumb.url) image_tag(user.avatar.thumb.url)
end end
def render_sitemap
items = action_data
def node(items)
html = "<ul>"
items.each do |key,item|
if item["children"] && !item["children"].empty?
url = item["url"]
html = html + "<li><a href='#{url}'>#{key}</a>"
html = html + node(item["children"])
html = html + "</li>"
else
url = item["url"]
html = html + "<li><a href='#{url}'>#{key}</a></li>"
end
end
html = html + "</ul>"
html
end
html = node(items)
html.html_safe
end
end end

View File

@ -22,10 +22,27 @@ module OrbitHelper
def self.this_module_app def self.this_module_app
@module_app @module_app
end end
def self.widget_module_app
@widget_module_app
end
def self.set_this_module_app(module_app) def self.set_this_module_app(module_app)
@module_app = ModuleApp.where(:key=>module_app).first @module_app = ModuleApp.where(:key=>module_app).first
end end
def self.set_widget_custom_value(value)
@widget_custom_value = value
end
def self.widget_custom_value
@widget_custom_value
end
def self.set_widget_module_app(module_app)
@widget_module_app = ModuleApp.where(:key=>module_app).first
end
def self.params def self.params
@params @params
end end
@ -47,6 +64,22 @@ module OrbitHelper
@site_locale = locale @site_locale = locale
end end
def self.set_widget_data_count(data_count)
@widget_data_count = data_count
end
def self.widget_data_count
@widget_data_count
end
def self.set_widget_categories(categories)
@widget_categories = categories
end
def self.widget_categories
@widget_categories
end
def self.get_site_locale def self.get_site_locale
@site_locale @site_locale
end end
@ -62,6 +95,9 @@ module OrbitHelper
def get_item_module_infos(page) def get_item_module_infos(page)
if page.parent_page_id.nil? if page.parent_page_id.nil?
["Home","icons-house"] ["Home","icons-house"]
elsif page.module == "sitemap"
module_app = ModuleApp.find_by_key("page_content")
[module_app.title, module_app.get_registration.icon_class]
else else
module_app = ModuleApp.where(:key => page.module).first module_app = ModuleApp.where(:key => page.module).first
unless module_app.nil? unless module_app.nil?

View File

@ -12,6 +12,39 @@ module PagesHelper
end end
def render_widget_for_frontend(controller_name, widget_method, widget_file) def render_widget_for_frontend(controller_name, widget_method, widget_file)
def parsing_repeats_again(elements,d,level)
newhtml = []
oldhtml = []
elements.each do |el|
html_to_render = ""
data_name = el.attr("data-list")
wrap_elements = el.css("*[data-list][data-level='#{level}']")
if d["#{data_name}"]
d["#{data_name}"].each_with_index do |item,i|
element = el.inner_html
if wrap_elements.count > 0
htmls = parsing_repeats_again(wrap_elements,d["#{data_name}"][i], level + 1)
htmls[0].each_with_index do |html,i|
element = element.gsub(html,htmls[1][i])
end
end
item.each do |key,value|
if !value.kind_of?(Array)
value = value.nil? ? "" : value
element = element.gsub("{{#{key}}}",value.to_s)
element = element.gsub("%7B%7B#{key}%7D%7D",value.to_s)
end
end
html_to_render = html_to_render + element
end
temp = el.to_s
oldhtml << temp
temp = temp.gsub(el.inner_html, html_to_render)
newhtml << temp
end
end
[oldhtml,newhtml]
end
controller_name = controller_name.downcase.singularize controller_name = controller_name.downcase.singularize
f = File.join('../templates', current_site.template, 'modules', "#{controller_name}", "_#{widget_file}.html.erb"); f = File.join('../templates', current_site.template, 'modules', "#{controller_name}", "_#{widget_file}.html.erb");
s = render_to_string(f) s = render_to_string(f)
@ -21,24 +54,16 @@ module PagesHelper
OrbitHelper.set_current_widget_module controller_name OrbitHelper.set_current_widget_module controller_name
data = controller.send("#{widget_method}") data = controller.send("#{widget_method}")
keys = data.keys keys = data.keys
wrap_elements.each do |wrap_element| wrap_elements = doc.css("*[data-list][data-level='0']")
html_to_render = "" htmls = parsing_repeats_again(wrap_elements,data,1)
(data[keys[0]].kind_of?(Array) ? data[keys[0]] : data[keys[1]]).each do |item| html = doc.to_s
el = wrap_element.inner_html htmls[0].each_with_index do |h,i|
item.each do |key,value| html = html.gsub(h,htmls[1][i])
value = value.nil? ? "" : value
el = el.gsub("{{#{key}}}",value.to_s)
el = el.gsub("%7B%7B#{key}%7D%7D",value.to_s)
end
html_to_render = html_to_render + el
end
wrap_element.inner_html = html_to_render
end end
html = doc.to_html
if keys[1] if keys[1]
(data[keys[1]].kind_of?(Array) ? data[keys[0]] : data[keys[1]]).each do |key,value| (data[keys[1]].kind_of?(Array) ? data[keys[0]] : data[keys[1]]).each do |key,value|
html = html.gsub("{{#{key}}}",value) html = html.gsub("{{#{key}}}",value.to_s)
html = html.gsub("%7B%7B#{key}%7D%7D",value) html = html.gsub("%7B%7B#{key}%7D%7D",value.to_s)
end end
end end
html.html_safe html.html_safe

View File

@ -10,12 +10,14 @@ class ModuleApp
field :frontend_enable, type: Boolean, default: false field :frontend_enable, type: Boolean, default: false
field :sidebar_order,type: Integer,default: 0 field :sidebar_order,type: Integer,default: 0
field :authorizable_models, type: Array field :authorizable_models, type: Array
field :widget_enable, type: Boolean, default: false
has_many :categories, dependent: :destroy, :autosave => true has_many :categories, dependent: :destroy, :autosave => true
has_and_belongs_to_many :tags, dependent: :destroy, :autosave => true has_and_belongs_to_many :tags, dependent: :destroy, :autosave => true
has_many :authorizations has_many :authorizations
scope :frontend_enabled, ->{ where(:frontend_enable => true)} scope :frontend_enabled, ->{ where(:frontend_enable => true)}
scope :widget_enabled, ->{ where(:widget_enable => true)}
def refetch_setting!(reg) def refetch_setting!(reg)
self[:taggable] = reg.is_taggable self[:taggable] = reg.is_taggable
@ -23,6 +25,7 @@ class ModuleApp
self[:authorizable] = reg.is_authorizable self[:authorizable] = reg.is_authorizable
self[:authorizable_models] = reg.get_authorizable_models self[:authorizable_models] = reg.get_authorizable_models
self[:frontend_enable] = reg.is_frontend_enabled self[:frontend_enable] = reg.is_frontend_enabled
self[:widget_enable] = reg.is_widget_enabled
end end
def get_registration def get_registration

View File

@ -1,7 +1,7 @@
class Page class Page
include Mongoid::Document include Mongoid::Document
include Mongoid::Timestamps include Mongoid::Timestamps
include OrbitModel::Impression include OrbitModel::Impression
field :name, localize: true field :name, localize: true
field :number, type: Integer field :number, type: Integer
@ -11,8 +11,8 @@ class Page
field :data_count, type: Integer, default: 10 field :data_count, type: Integer, default: 10
field :enabled_for, type: Array, default: [] field :enabled_for, type: Array, default: []
field :menu_enabled_for, type: Array, default: [] field :menu_enabled_for, type: Array, default: []
field :categories, type: Array, :default => [] field :categories, type: Array, :default => []
field :enabled_for_sitemap, type: Array, :default => [] field :enabled_for_sitemap, type: Array, :default => []
has_many :page_parts, :autosave => true, :dependent => :destroy has_many :page_parts, :autosave => true, :dependent => :destroy
@ -22,11 +22,11 @@ class Page
def to_param def to_param
page_id.parameterize page_id.parameterize
end end
def self.find_by_param(input) def self.find_by_param(input)
self.find_by(page_id: input) rescue nil self.find_by(page_id: input) rescue nil
end end
def self.root def self.root
@ -37,11 +37,15 @@ class Page
self.parent_page_id.nil? self.parent_page_id.nil?
end end
def sorted_published_child_pages def sorted_published_child_pages
self.child_page.where(:menu_enabled_for => I18n.locale).asc(:number) self.child_page.where(:menu_enabled_for => I18n.locale).asc(:number)
end end
def published_child_pages def child_pages_enabled_for_sitemap
self.child_page.where(:menu_enabled_for => I18n.locale) self.child_page.where(:enabled_for_sitemap => I18n.locale)
end end
def published_child_pages
self.child_page.where(:menu_enabled_for => I18n.locale)
end
end end

View File

@ -8,7 +8,8 @@ class Site
field :address, type: String field :address, type: String
field :footer, localize: true field :footer, localize: true
field :sub_menu, localize: true field :sub_menu, localize: true
field :terms_of_use, localize: true field :site_map_link, type: String, :default => "/sitemap"
field :terms_of_use_link, type: String
field :google_analytics, type: String field :google_analytics, type: String
field :in_use_locales, :type => Array field :in_use_locales, :type => Array
field :valid_locales, :type => Array field :valid_locales, :type => Array

View File

@ -3,10 +3,15 @@ class SubPart
include Mongoid::Timestamps include Mongoid::Timestamps
field :module field :module
field :title, localize: true
field :widget_type field :widget_type
field :widget_method field :widget_method
field :kind, default: "none" field :kind, default: "none"
field :content, localize: true
field :data_count, type: Integer, default: 10
field :categories, type: Array, :default => []
field :custom_string_field, type: String
field :custom_array_field, type: Array, :default => []
belongs_to :page_part belongs_to :page_part
end end

View File

@ -0,0 +1,7 @@
<footer class="footer">
<div class="container footer-inner">
<div>
{{footer-data}}
</div>
</div>
</footer>

View File

@ -3,14 +3,13 @@
<div class="header-title pull-left"> <div class="header-title pull-left">
<h1> <h1>
<a href="/"> <a href="/">
<img src="http://placehold.it/150x60"> <img src="{{logo_url}}">
<span>{{site_name}}</span> <span>{{site_name}}</span>
</a> </a>
</h1> </h1>
</div> </div>
<div class="header-nav pull-right"> <div class="header-nav pull-right" >
<a href="#">Sitemap</a> {{header-data}}
<a href="#">Contact</a>
</div> </div>
</div> </div>
<%= render_partial("menu") %> <%= render_partial("menu") %>

View File

@ -5,10 +5,10 @@
</head> </head>
<body> <body>
<div class="warp container"> <div class="warp container">
<%= render_partial("header") %> <%= render_header %>
<!-- Site Banner --> <!-- Site Banner -->
<section class="main-slide" data-banner="true"> <section class="main-slide" data-pp="4">
<%= render_widget "ad_banner/widget" %> <%#= render_widget "ad_banner/widget" %>
</section><!-- Site Banner end --> </section><!-- Site Banner end -->
<div class="warp-inner"> <div class="warp-inner">
@ -29,7 +29,7 @@
</aside> </aside>
</div> </div>
</div> </div>
<%= render_partial("footer") %> <%= render_footer %>
</div> </div>
</body> </body>
</html> </html>

View File

@ -1,6 +1,6 @@
<ul class="nav navbar-nav" data-menu-level="0"> <ul class="nav navbar-nav" data-menu-level="0">
<li class="dropdown"> <li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown" data-menu-link="true">{{link_name}}</a> <a href="#" class="dropdown-toggle" data-menu-link="true">{{link_name}}</a>
<ul class="dropdown-menu" data-menu-level="1"> <ul class="dropdown-menu" data-menu-level="1">
<li> <li>
<a href="index.html" data-menu-link="true">{{link_name}}</a> <a href="index.html" data-menu-link="true">{{link_name}}</a>

View File

@ -5,10 +5,10 @@
</head> </head>
<body> <body>
<div class="warp container"> <div class="warp container">
<%= render_partial("header") %> <%= render_header %>
<!-- Site Banner --> <!-- Site Banner -->
<section class="main-slide" data-banner="true"> <section class="main-slide" data-pp="4">
<%= render_widget "ad_banner/widget" %> <%#= render_widget "ad_banner/widget" %>
</section><!-- Site Banner end --> </section><!-- Site Banner end -->
<div class="warp-inner"> <div class="warp-inner">
@ -29,7 +29,7 @@
</aside> </aside>
</div> </div>
</div> </div>
<%= render_partial("footer") %> <%= render_footer %>
</div> </div>
</body> </body>
</html> </html>

View File

@ -1,43 +1,6 @@
<!-- <div class="widget" module="banner"> <div class="slide" >
<div class="cycle-slideshow" data-cycle-fx="scrollHorz"> <div class="cycle-slideshow carousel-inner" data-list="images" data-level="0">
<img src="http://placehold.it/768x320" alt=""> {{caption}}
<img src="http://placehold.it/768x320" alt=""> <img class="{{class}} click-img" src="{{image_link}}" alt="" style="height:{{height}}px;" data-link="{{link}}" data-cycle-title="{{title}}" data-cycle-desc="{{context}}">
<img src="http://placehold.it/768x320" alt="">
</div> </div>
</div> -->
<div id="carousel-example-captions" class="carousel slide" data-ride="carousel">
<ol class="carousel-indicators">
<li data-target="#carousel-example-captions" data-slide-to="0" class="active"></li>
<li data-target="#carousel-example-captions" data-slide-to="1" class=""></li>
<li data-target="#carousel-example-captions" data-slide-to="2" class=""></li>
</ol>
<div class="carousel-inner">
<div class="item active">
<img src="http://placehold.it/768x320" alt="">
<div class="carousel-caption">
<h3>First slide label</h3>
<p>Nulla vitae elit libero, a pharetra augue mollis interdum.</p>
</div>
</div>
<div class="item">
<img src="http://placehold.it/768x320" alt="">
<div class="carousel-caption">
<h3>Second slide label</h3>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit.</p>
</div>
</div>
<div class="item">
<img src="http://placehold.it/768x320" alt="">
<div class="carousel-caption">
<h3>Third slide label</h3>
<p>Praesent commodo cursus magna, vel scelerisque nisl consectetur.</p>
</div>
</div>
</div>
<a class="left carousel-control" href="#carousel-example-captions" data-slide="prev">
<span class="glyphicon glyphicon-chevron-left"></span>
</a>
<a class="right carousel-control" href="#carousel-example-captions" data-slide="next">
<span class="glyphicon glyphicon-chevron-right"></span>
</a>
</div> </div>

View File

@ -1,15 +1,15 @@
<div class="widget-1 row" module="announcement" data-repeat="3" data-module="announcement" data-ps=""> <div class="widget-1 row" module="announcement" data-level="0" data-list="announcements" data-ps="">
<div class="box col-sm-4"> <div class="box col-sm-4">
<!-- .box-inner --> <!-- .box-inner -->
<div class="box-inner"> <div class="box-inner">
<div class="pic"> <div class="pic">
<img src="http://placehold.it/360x200" alt=""> <img src="{{img_src}}" alt="">
</div> </div>
<div class="box-excerpt"> <div class="box-excerpt">
<h3 class="box-title">{{title}}</h3> <h3 class="box-title">{{title}}</h3>
<span>{{postdate}}</span> <span>{{postdate}}</span>
<p>{{subtitle}}</p> <p>{{subtitle}}</p>
<p><a href="{{link_to_show}}">Some Link</a></p> <p><a href="{{link_to_show}}">Read More</a></p>
</div> </div>
</div><!-- /.box-inner --> </div><!-- /.box-inner -->
</div><!-- /.box --> </div><!-- /.box -->

View File

@ -1,12 +1,12 @@
<div class="widget-2" module="announcement" data-ps=""> <div class="widget-2" module="announcement" data-ps="">
<h2 class="widget-title">{{widget-title}}</h2> <h2 class="widget-title">{{widget-title}}</h2>
<ul class="widget-list" data-repeat="6" data-module="announcement"> <ul class="widget-list"data-level="0" data-list="announcements">
<li> <li>
<a href="{{link_to_show}}"><i class="fa fa-chevron-right"></i>{{title}}<span>{{postdate}}</span></a> <a href="{{link_to_show}}"><i class="fa fa-chevron-right"></i>{{title}}<span>{{postdate}}</span></a>
</li> </li>
</ul> </ul>
<p class="more"> <p class="more">
<a class="btn btn-sm btn-info" href="/module/announcement">More</a> <a class="btn btn-sm btn-info" href="#">More</a>
</p> </p>
</div> </div>
<hr class="dotted"> <hr class="dotted">

View File

@ -1,40 +1,10 @@
<div class="widget" module="archive" data-ps=""> <div class="widget" module="archive" data-ps="">
<h2 class="widget-title">{{widget-title}}</h2> <h2 class="widget-title">{{widget-title}}</h2>
<div class="list-group"> <div class="list-group">
<div class="list-group-item"> <div class="list-group-item" data-list="categories" data-level="0">
<h4 class="list-group-item-heading">{{title}}</h4> <h4 class="list-group-item-heading">{{category-title}}</h4>
<ul class="list-group-item-text"> <ul class="list-group-item-text" data-list="archives" data-level="1">
<li>Service Updates</li> <li>{{archive-title}}</li>
<li>Help Desk</li>
<li>Validate License</li>
<li>Privacy Policy</li>
</ul>
</div>
<div class="list-group-item">
<h4 class="list-group-item-heading">{{title}}</h4>
<ul class="list-group-item-text">
<li>Service Updates</li>
<li>Help Desk</li>
<li>Validate License</li>
<li>Privacy Policy</li>
</ul>
</div>
<div class="list-group-item">
<h4 class="list-group-item-heading">{{title}}</h4>
<ul class="list-group-item-text">
<li>Service Updates</li>
<li>Help Desk</li>
<li>Validate License</li>
<li>Privacy Policy</li>
</ul>
</div>
<div class="list-group-item">
<h4 class="list-group-item-heading">{{title}}</h4>
<ul class="list-group-item-text">
<li>Service Updates</li>
<li>Help Desk</li>
<li>Validate License</li>
<li>Privacy Policy</li>
</ul> </ul>
</div> </div>
</div> </div>

View File

@ -1,17 +1,12 @@
<div class="widget-1 row" module="announcement" data-repeat="3" data-module="announcement" data-ps=""> <div class="widget-2" module="announcement" data-ps="">
<div class="box col-sm-4"> <h2 class="widget-title">{{widget-title}}</h2>
<!-- .box-inner --> <ul class="widget-list" data-level="0" data-list="faqs" >
<div class="box-inner"> <li>
<div class="pic"> <a href="{{link_to_show}}"><i class="fa fa-chevron-right"></i>{{title}}<span>{{postdate}}</span></a>
<img src="http://placehold.it/360x200" alt=""> </li>
</div> </ul>
<div class="box-excerpt"> <p class="more">
<h3 class="box-title">{{title}}</h3> <a class="btn btn-sm btn-info" href="/module/announcement">More</a>
<span>{{postdate}}</span> </p>
<p>{{subtitle}}</p>
<p><a href="{{link_to_show}}">Some Link</a></p>
</div>
</div><!-- /.box-inner -->
</div><!-- /.box -->
</div> </div>
<hr class="dotted"> <hr class="dotted">

View File

@ -1,12 +0,0 @@
<div class="widget-2" module="announcement" data-ps="">
<h2 class="widget-title">{{widget-title}}</h2>
<ul class="widget-list" data-repeat="6" data-module="announcement">
<li>
<a href="{{link_to_show}}"><i class="fa fa-chevron-right"></i>{{title}}<span>{{postdate}}</span></a>
</li>
</ul>
<p class="more">
<a class="btn btn-sm btn-info" href="/module/announcement">More</a>
</p>
</div>
<hr class="dotted">

View File

@ -1,18 +1,7 @@
<div class="widget" module="gallery" data-ps=""> <div class="widget" module="gallery" data-ps="">
<h2 class="widget-title">{{widget-title}}</h2> <h2 class="widget-title">{{widget-title}}</h2>
<ul class="row"> <ul class="row" data-list="images" data-level="0">
<li class="col-md-4 col-sm-6 col-xs-3"><a href="{{link_to_show}}"><img class="img-rounded" src="http://placehold.it/320x320" alt=""></a></li> <li class="col-md-4 col-sm-6 col-xs-3"><a href="{{link_to_show}}"><img class="img-rounded" src="{{thumb-src}}" alt=""></a></li>
<li class="col-md-4 col-sm-6 col-xs-3"><a href="{{link_to_show}}"><img class="img-rounded" src="http://placehold.it/320x320" alt=""></a></li>
<li class="col-md-4 col-sm-6 col-xs-3"><a href="{{link_to_show}}"><img class="img-rounded" src="http://placehold.it/320x320" alt=""></a></li>
<li class="col-md-4 col-sm-6 col-xs-3"><a href="{{link_to_show}}"><img class="img-rounded" src="http://placehold.it/320x320" alt=""></a></li>
<li class="col-md-4 col-sm-6 col-xs-3"><a href="{{link_to_show}}"><img class="img-rounded" src="http://placehold.it/320x320" alt=""></a></li>
<li class="col-md-4 col-sm-6 col-xs-3"><a href="{{link_to_show}}"><img class="img-rounded" src="http://placehold.it/320x320" alt=""></a></li>
<li class="col-md-4 col-sm-6 col-xs-3"><a href="{{link_to_show}}"><img class="img-rounded" src="http://placehold.it/320x320" alt=""></a></li>
<li class="col-md-4 col-sm-6 col-xs-3"><a href="{{link_to_show}}"><img class="img-rounded" src="http://placehold.it/320x320" alt=""></a></li>
<li class="col-md-4 col-sm-6 col-xs-3"><a href="{{link_to_show}}"><img class="img-rounded" src="http://placehold.it/320x320" alt=""></a></li>
<li class="col-md-4 col-sm-6 col-xs-3"><a href="{{link_to_show}}"><img class="img-rounded" src="http://placehold.it/320x320" alt=""></a></li>
<li class="col-md-4 col-sm-6 col-xs-3"><a href="{{link_to_show}}"><img class="img-rounded" src="http://placehold.it/320x320" alt=""></a></li>
<li class="col-md-4 col-sm-6 col-xs-3"><a href="{{link_to_show}}"><img class="img-rounded" src="http://placehold.it/320x320" alt=""></a></li>
</ul> </ul>
<p class="more"> <p class="more">
<a class="btn btn-sm btn-info" href="/module/gallery">More</a> <a class="btn btn-sm btn-info" href="/module/gallery">More</a>

View File

@ -1,9 +0,0 @@
<footer class="footer">
<div class="container footer-inner">
<address>
<p>This is a simulate website with all fake data!!!</p>
</address>
<div data-pp="4">
</div>
</div>
</footer>

View File

@ -6,6 +6,7 @@
<%= javascript_include_tag "lib/jquery-1.11.0.min"%> <%= javascript_include_tag "lib/jquery-1.11.0.min"%>
<%= javascript_include_tag "bootstrap"%> <%= javascript_include_tag "bootstrap"%>
<%= javascript_include_tag "plugin/jquery.lite.image.resize"%> <%= javascript_include_tag "plugin/jquery.lite.image.resize"%>
<%= javascript_include_tag "plugin/jquery.cycle2.min"%>
<%= javascript_include_tag "app"%> <%= javascript_include_tag "app"%>
<%= javascript_include_tag "#{@dataApi}" if @dataApi != nil%> <%= javascript_include_tag "#{@dataApi}" if @dataApi != nil%>
<!--[if lt IE 9]> <!--[if lt IE 9]>

View File

@ -44,7 +44,7 @@
<label class="control-label muted"><%= t :always_display_title %> <label class="control-label muted"><%= t :always_display_title %>
</label> </label>
<div class="controls"> <div class="controls">
<%= f.check_box :title_always_on, :class => "toggle-check", :data => { :title => t('site_title_always_display') } %> <input type="checkbox" class="toggle-check" name="site[title_always_on]" data-disabled="true" <%= @site.title_always_on ? "checked='checked" : "" %> data-title="<%= t('site_title_always_display') %>" />
</div> </div>
</div> </div>
@ -68,7 +68,7 @@
<label class="control-label muted"><%= t :sitemap_menu_in_header %> <label class="control-label muted"><%= t :sitemap_menu_in_header %>
</label> </label>
<div class="controls"> <div class="controls">
<%= f.check_box :sitemap_menu_in_header, :class => "toggle-check" %> <input type="checkbox" class="toggle-check" name="site[sitemap_menu_in_header]" data-disabled="true" <%= @site.sitemap_menu_in_header ? "checked='checked" : "" %> />
</div> </div>
</div> </div>
@ -93,24 +93,17 @@
<div class="control-group"> <div class="control-group">
<label class="control-label muted"><%= t('site.terms_of_use')%></label> <label class="control-label muted"><%= t('site.terms_of_use')%></label>
<div class="controls"> <div class="controls">
<%= f.check_box :enable_terms_of_use, :class => "toggle-check", :data => { :title => t('site.terms_display_in_footer') } %> <input type="checkbox" class="toggle-check for_tou" name="site[enable_terms_of_use]" data-disabled="true" <%= @site.enable_terms_of_use ? "checked='checked'" : "" %> data-title="Display in footer" />
</div> </div>
</div> </div>
<!-- CKeditor Site Footer --> <!-- CKeditor Site Footer -->
<% I18n.available_locales.each do |locale|%> <div class="control-group <%= @site.enable_terms_of_use ? "" : "hide" %>" id="link_select">
<%= content_tag :div, :class => "tab-pane fade #{active_when_current_locale_eq locale} #{locale}" do %> <label class="control-label muted">Select Page</label>
<label class="control-label muted"><%= t('site.terms_of_use_content')%></label>
<div class="controls"> <div class="controls">
<div class="textarea"> <%= f.select(:terms_of_use_link, @pages.map{|p| [p.name,p.url]},{:include_blank => true}) %>
<%= f.fields_for :terms_of_use_translations do |f| %> </div>
<%= f.text_area locale, :class => "ckeditor input-block-level", :value => (@site.terms_of_use_translations[locale] rescue nil) %> </div>
<% end %>
</div>
</div>
<%end%>
<%end%>
<!-- Form Actions --> <!-- Form Actions -->
<div class="form-actions"> <div class="form-actions">
@ -122,3 +115,16 @@
</fieldset> </fieldset>
<% end %> <% end %>
<script type="text/javascript">
$(document).ready(function(){
$(".for_tou").click(function(){
if($(this).is(":checked")){
$("#link_select").removeClass("hide");
}else{
$("#link_select").addClass("hide");
}
})
})
</script>

View File

@ -1,29 +1,26 @@
<div class="btn-group" data-toggle="buttons-radio"> <div class="btn-group" data-toggle="buttons-radio">
<%= f.fields_for :sub_parts do |sub| %> <label href="#none" class="btn btn-large <%= @subpart.kind == "none" ? 'active' : '' rescue nil %>" data-toggle="tab">
<label href="#none" class="btn btn-large" data-toggle="tab">
<%= t("page_part_kinds.none") %> <%= t("page_part_kinds.none") %>
<%= sub.radio_button :kind, "none", class: "hide" %> <input type="radio" <%= @subpart.kind == "none" ? "checked" : "" rescue nil %> class="hide" value="none" name="page_part[sub_parts_attributes][<%= @select_number %>][kind]" />
</label> </label>
<label href="#text" class="btn btn-large" data-toggle="tab"> <label href="#text" class="btn btn-large <%= @subpart.kind == "text" ? 'active' : '' rescue nil %>" data-toggle="tab">
<%= t("page_part_kinds.text") %> <%= t("page_part_kinds.text") %>
<%= sub.radio_button :kind, "text", class: "hide" %> <input type="radio" class="hide" <%= @subpart.kind == "text" ? "checked" : "" rescue nil %> value="text" name="page_part[sub_parts_attributes][<%= @select_number %>][kind]" />
</label> </label>
<!-- <label href="#public_r_tag" class="btn btn-large" data-toggle="tab"> --> <!-- <label href="#public_r_tag" class="btn btn-large" data-toggle="tab"> -->
<%#= t("page_part_kinds.public_r_tag") %> <%#= t("page_part_kinds.public_r_tag") %>
<%#= sub.radio_button :kind, "public_r_tag", class: "hide" %> <%#= sub.radio_button :kind, "public_r_tag", class: "hide" %>
<!-- </label> --> <!-- </label> -->
<label href="#module_widget" class="btn btn-large" data-toggle="tab"> <label href="#module_widget" class="btn btn-large <%= @subpart.kind == "module_widget" ? 'active' : '' rescue nil %>" data-toggle="tab">
<%= t("page_part_kinds.module_widget") %> <%= t("page_part_kinds.module_widget") %>
<%= sub.radio_button :kind, "module_widget", class: "hide" %> <input type="radio" class="hide" value="module_widget" <%= @subpart.kind == "module_widget" ? "checked" : "" rescue nil %> name="page_part[sub_parts_attributes][<%= @select_number %>][kind]" />
</label> </label>
<% end %>
</div> </div>
<fieldset> <fieldset>
<div class="input-area tab-content"> <div class="input-area tab-content">
<div id="none" class="parts-none tab-pane fade in"><%= t(:select_one_function) %></div> <div id="none" class="parts-none tab-pane fade in <%= @subpart.kind == "none" ? 'active' : '' rescue nil %>"><%= t(:select_one_function) %></div>
<div id="text" class="tab-pane fade in"> <div id="text" class="tab-pane fade in <%= @subpart.kind == "text" ? 'active' : '' rescue nil %>">
<div class="nav-name"> <div class="nav-name">
<strong><%= t(:language) %></strong> <strong><%= t(:language) %></strong>
</div> </div>
@ -41,11 +38,7 @@
<label class="control-label muted"><%= t(:content) %></label> <label class="control-label muted"><%= t(:content) %></label>
<div class="controls"> <div class="controls">
<div class="textarea"> <div class="textarea">
<%= f.fields_for :sub_parts do |sub| %> <textarea name="page_part[sub_parts_attributes][<%= @select_number %>][content_translations][<%= locale.to_s %>]" class="ckeditor input-block-level"><%= @subpart.content_translations[locale] rescue nil %></textarea>
<%= sub.fields_for :content_translations do |f| %>
<%= f.text_area locale, class: "ckeditor input-block-level", value: (@part.content_translations[locale] rescue nil) %>
<% end %>
<% end %>
</div> </div>
</div> </div>
</div> </div>
@ -54,43 +47,26 @@
</div> </div>
</div> </div>
<div id="module_widget" class="tab-pane fade in"> <div id="module_widget" class="tab-pane fade in <%= @subpart.kind == "module_widget" ? 'active' : '' rescue nil %>">
<div class="control-group input-content"> <% I18n.available_locales.each do |locale| %>
<%= f.label :module_app_id, t(:module), class: "control-label muted" %> <div class="control-group input-content">
<div class="controls"> <label class="control-label muted">Widget name (<%= t(locale.to_s) %>) :</label>
<%= f.fields_for :sub_parts do |sub| %> <div class="controls">
<%= sub.select(:module, @modules.map{|m| [m.title,m.key]},{:include_blank => true}, "class" => "input-xlarge change module_name") %> <input name="page_part[sub_parts_attributes][<%= @select_number %>][title_translations][<%= locale.to_s %>]" value="<%= @subpart.title_translations[locale.to_s] rescue nil %>" />
<% end %> </div>
</div>
</div>
<!-- <div id="front_url" class="control-group input-content <%#= 'hide' if @widget_paths.blank? %>">
<%#= f.label :widget_path, t('front_page.display_mode'), class: "control-label muted" %>
<div class="controls">
<%#= f.select :widget_path, @widget_paths, {}, selected: (@part.widget_path rescue nil), class: "input-xlarge change" %>
</div>
</div>
<div class="control-group input-content checkbox-groups <%#= 'hide' if @module_app_categories.blank? %>" id="page-category-groups" data-for="category">
<%#= f.label :categories, t(:categories), class: "control-label muted" %>
<div class="controls">
<%#= content_tag :label, class: "checkbox" do %>
<%#= check_box_tag nil, nil, (@part.category.size == @module_app_categories.size ? true : false), class: "select_all" %> <%#= t(:all) %>
<%# end %>
<div class="groups" id="page-category">
<%#= content_tag_for(:label, @module_app_categories, class: "checkbox inline") do |category|%>
<%#= check_box_tag("page_part[category][]", category.id, (@part.category.include?(category.id.to_s) rescue false) ) %>
<%#= category.title %>
<%# end if @module_app_categories %>
<input type="hidden" value>
</div> </div>
</div> <% end %>
</div> --> <div class="control-group input-content">
<%= f.label :module_app_id, t(:module) + " :", class: "control-label muted" %>
<div class="control-group input-content widget_count <%= 'hide' if @module_app.blank? || !@module_app.enable_widget_data_count %>">
<%= f.label :widget_data_count, t(:widget_data_count), class: "control-label muted" %>
<div class="controls"> <div class="controls">
<%#= f.select :widget_data_count, options_for_select(@data_count, @part.widget_data_count), {}, class: "input-mini", id: "page_count" %> <%= select_tag("page_part[sub_parts_attributes][#{@select_number}][module]", options_for_select(@modules.map{|m| [m.title,m.key]}, (@subpart.module rescue nil)),{:include_blank => true,"class" => "input-xlarge change module_name"}) %>
</div> </div>
</div> </div>
<div id="widgets_selection_area">
<% if params[:action] == "edit_sub_part" && @kind == "module_widget"%>
<%= render :partial => "widget_form" %>
<% end %>
</div>
</div> </div>
</div> </div>
<div class="form-actions"> <div class="form-actions">
@ -98,3 +74,10 @@
<button type="button" class="btn" onclick="window.history.back()"><%= t(:cancel) %></button> <button type="button" class="btn" onclick="window.history.back()"><%= t(:cancel) %></button>
</div> </div>
</fieldset> </fieldset>
<script type="text/javascript">
$('*[data-toggle=buttons-radio] label').click(function(){
$('*[data-toggle=buttons-radio] input[type=radio]').removeAttr("checked");
$(this).find("input[type=radio]").prop("checked","checked");
})
</script>

View File

@ -0,0 +1,54 @@
<div class="control-group input-content">
<label class="control-label muted">Select Widget Type :</label>
<div class="controls">
<%= select_tag("page_part[sub_parts_attributes][#{@select_number}][widget_type]",options_for_select(@widget_types, (@subpart.widget_type rescue nil))) %>
</div>
</div>
<div class="control-group input-content">
<label class="control-label muted">Select Widget Method :</label>
<div class="controls">
<%= select_tag("page_part[sub_parts_attributes][#{@select_number}][widget_method]",options_for_select(@widget_methods, (@subpart.widget_method rescue nil))) %>
</div>
</div>
<% if @widget_settings['override_category_with'].nil? %>
<div class="control-group">
<label class="control-label muted">Category List :</label>
<div class="controls">
<% @categories.each do |category| %>
<label class="checkbox">
<input type="checkbox" <%= @subpart.categories.include?(category.id.to_s) ? "checked='checked'" : "" rescue nil %> value="<%= category.id.to_s %>" name="page_part[sub_parts_attributes][<%= @select_number %>][categories][]">
<%= category.title %>
</label>
<% end %>
</div>
</div>
<% else %>
<% if @multiselect %>
<div class="control-group">
<label class="control-label muted"><%= @widget_settings['override_category_with'].classify %> List :</label>
<div class="controls">
<% @custom.each do |c| %>
<label class="checkbox">
<input type="checkbox" <%= @subpart.custom_array_field.include?(c.id.to_s) ? "checked='checked'" : "" rescue nil %> value="<%= c.id.to_s %>" name="page_part[sub_parts_attributes][<%= @select_number %>][custom_array_field][]">
<%= c["#{@display_field}"] %>
</label>
<% end %>
</div>
</div>
<% else %>
<div class="control-group input-content">
<label class="control-label muted">Select <%= @widget_settings['override_category_with'].classify %> :</label>
<div class="controls">
<%= select_tag("page_part[sub_parts_attributes][#{@select_number}][custom_string_field]",options_for_select(@custom.map{|c| [c["#{@display_field}"],c.id]}, (@subpart.custom_string_field rescue nil))) %>
</div>
</div>
<% end %>
<% end %>
<% if !@data_count.nil? %>
<div class="control-group input-content">
<label class="control-label muted">Data count:</label>
<div class="controls">
<%= select_tag("page_part[sub_parts_attributes][#{@select_number}][data_count]",options_for_select(1..@data_count,(@subpart.data_count rescue nil))) %>
</div>
</div>
<% end %>

View File

@ -1,52 +1,29 @@
<%#= form_for @part, url: {action: "update"} do |f| %>
<%#= f.hidden_field :page_part_id, value: @part.id.to_s %>
<%#= render :partial => "form", :locals => { :f => f } %>
<%# end %>
<% content_for :page_specific_css do %> <% content_for :page_specific_css do %>
<%= stylesheet_link_tag "lib/main-forms" %> <%= stylesheet_link_tag "lib/main-forms" %>
<% end %> <% end %>
<%= form_for @part, url: {action: "update"}, :remote=>true, html: { class: "form-horizontal main-forms"} do |f| %> <%= form_for @part, url: {action: "update"}, :remote=>true, html: { class: "form-horizontal main-forms"} do |f| %>
<%= f.hidden_field :page_part_id, value: @part.id.to_s %> <input type="hidden" name="part_id" value="<%= @part.id.to_s %>" />
<input type="hidden" name="page_id" value="<%= params[:page_id] %>" />
<%= render :partial => "form", :locals => { :f => f } %> <%= render :partial => "form", :locals => { :f => f } %>
<% end %> <% end %>
<script> <script>
$('.btn-group input[type="radio"]').each(function(index, el) { $("select.module_name").on("change",function(){
if($(this).prop('checked')) { var select = $(this),
$(this).closest('label').addClass('active'); widget_area = $("#widgets_selection_area");
$("#" + $(this).val()).addClass('active'); if(select.val()){
} $.ajax({
}); url : "/page_parts/getwidgets",
dataType : "html",
$('.btn-group').on("click", 'label', function(event) { data : {"module" : select.val(), "page_id" : "<%= params[:page_id] %>", "part_id" : <%= @part_number %>},
$(this).find('input').prop('checked', true); type : "get"
event.preventDefault(); }).done(function(html){
}); widget_area.html(html);
})
$("#public_r_tag").on("change", "#tag_list select", function() { }
$.getScript($(this).attr('rel') + '?type=' + $(this).val() + "&id=" + "<%= @part.id %>" ); })
}); $("form").on("ajax:success",function(){
</script> window.location.href = "/pages/edit_view?id=<%= params[:page_id] %>";
<script> })
function toggleChecked(status) {
$(".checkbox").each( function() {
$(this).attr("checked",status);
})
}
</script>
<script type="text/javascript">
// $("select.module_name").on("change",function(){
// var select = $(this);
// if(select.val()){
// $.ajax({
// url : "/page_parts/getwidgets",
// dataType : "html",
// data : {"module" : select.val(),"number_of_select" : select.data("number").replace("pp_","")},
// type : "get"
// }).done(function(html){
// $("span[for=" + select.data("number") + "]").html(html);
// })
// }
// })
</script> </script>

View File

@ -0,0 +1,28 @@
<% content_for :page_specific_css do %>
<%= stylesheet_link_tag "lib/main-forms" %>
<% end %>
<%= form_for @part, url: update_sub_part_page_part_path(@subpart), :remote=>true, html: { class: "form-horizontal main-forms"} do |f| %>
<input type="hidden" name="part_id" value="<%= @part.id.to_s %>" />
<input type="hidden" name="page_id" value="<%= params[:page_id] %>" />
<%= render :partial => "form", :locals => { :f => f } %>
<% end %>
<script>
$("select.module_name").on("change",function(){
var select = $(this),
widget_area = $("#widgets_selection_area");
if(select.val()){
$.ajax({
url : "/page_parts/getwidgets",
dataType : "html",
data : {"module" : select.val(), "page_id" : "<%= params[:page_id] %>", "part_id" : <%= @part.part_id %>},
type : "get"
}).done(function(html){
widget_area.html(html);
})
}
})
$("form").on("ajax:success",function(){
window.location.href = "/pages/edit_view?id=<%= params[:page_id] %>";
})
</script>

View File

@ -1,4 +1 @@
Select Widget Type <%= render :partial => "widget_form" %>
<%= select_tag("page_part[sub_parts_attributes][#{@select_number}][widget_type]",options_for_select(@widget_types),{:include_blank => true}) %>
Select Widget Method
<%= select_tag("page_part[sub_parts_attributes][#{@select_number}][widget_method]",options_for_select(@widget_methods),{:include_blank => true}) %>

View File

@ -1,38 +1,28 @@
<% content_for :page_specific_css do %> <% content_for :page_specific_css do %>
<%= stylesheet_link_tag "lib/main-forms" %> <%= stylesheet_link_tag "lib/main-forms" %>
<% end %> <% end %>
<%= form_for @part, url: {action: "create"}, :remote=>true, html: { class: "form-horizontal main-forms"} do |f| %> <%= form_for @part, url: {:action => "create"}, :remote=>true, html: { class: "form-horizontal main-forms"} do |f| %>
<%= f.hidden_field :part_id, value: @part_number %> <%= f.hidden_field :part_id, value: @part_number,:class => "hidden_part_id" %>
<%= f.hidden_field :page_id, value: @page_id,:class => "hidden_page_id" %>
<%= render :partial => "form", :locals => { :f => f } %> <%= render :partial => "form", :locals => { :f => f } %>
<% end %> <% end %>
<script type="text/javascript"> <script type="text/javascript">
$("select.module_name").on("change",function(){ $("select.module_name").on("change",function(){
var select = $(this); var select = $(this),
widget_area = $("#widgets_selection_area");
if(select.val()){ if(select.val()){
$.ajax({ $.ajax({
url : "/page_parts/getwidgets", url : "/page_parts/getwidgets",
dataType : "html", dataType : "html",
data : {"module" : select.val(),"number_of_select" : select.data("number").replace("pp_","")}, data : {"module" : select.val(),"part_id" : <%= @part_number %>, "page_id" : "<%= params[:page_id] %>"},
type : "get" type : "get"
}).done(function(html){ }).done(function(html){
$("span[for=" + select.data("number") + "]").html(html); widget_area.html(html);
}) })
} }
}) })
$('.btn-group input[type="radio"]').each(function(index, el) { $("form").on("ajax:success",function(){
if($(this).prop('checked')) { window.location.href = "/pages/edit_view?id=<%= params[:page_id] %>";
$(this).closest('label').addClass('active'); })
$("#" + $(this).val()).addClass('active');
}
});
$('.btn-group').on("click", 'label', function(event) {
$(this).find('input').prop('checked', true);
event.preventDefault();
});
$("#public_r_tag").on("change", "#tag_list select", function() {
$.getScript($(this).attr('rel') + '?type=' + $(this).val() + "&id=" + "<%= @part.id %>" );
});
</script> </script>

View File

@ -0,0 +1 @@
Template doesnt exists for this page.

View File

@ -0,0 +1 @@
<%= render_sitemap %>

View File

@ -1,7 +1,12 @@
gem 'announcement', git: 'git@gitlab.tp.rulingcom.com:saurabh/announcement-test.git' # gem 'announcement', git: 'git@gitlab.tp.rulingcom.com:saurabh/announcement-test.git'
gem 'ad_banner', git: 'git@gitlab.tp.rulingcom.com:saurabh/adbanner-test.git' gem 'announcement', path: '/Volumes/MyData/github/Orbit4.5/new_modules/announcement'
gem "archive", git: 'git@gitlab.tp.rulingcom.com:saurabh/archive.git' # gem 'ad_banner', git: 'git@gitlab.tp.rulingcom.com:saurabh/adbanner-test.git'
gem 'gallery', git: 'git@gitlab.tp.rulingcom.com:saurabh/gallery.git' gem 'ad_banner', path: '/Volumes/MyData/github/Orbit4.5/new_modules/adbanner-test'
# gem "archive", git: 'git@gitlab.tp.rulingcom.com:saurabh/archive.git'
gem "archive", path: '/Volumes/MyData/github/Orbit4.5/new_modules/archive'
# gem 'gallery', git: 'git@gitlab.tp.rulingcom.com:saurabh/gallery.git'
gem 'gallery', path: '/Volumes/MyData/github/Orbit4.5/new_modules/gallery'
gem 'links', git: 'git@gitlab.tp.rulingcom.com:saurabh/links.git' gem 'links', git: 'git@gitlab.tp.rulingcom.com:saurabh/links.git'
gem 'page_content', git: 'git@gitlab.tp.rulingcom.com:saurabh/pagecontent.git' gem 'page_content', git: 'git@gitlab.tp.rulingcom.com:saurabh/pagecontent.git'
gem 'faq', git: 'git@gitlab.tp.rulingcom.com:saurabh/faq.git' # gem 'faq', git: 'git@gitlab.tp.rulingcom.com:saurabh/faq.git'
gem 'faq', path: '/Volumes/MyData/github/Orbit4.5/new_modules/faq'

View File

@ -14,10 +14,15 @@ Orbit::Application.routes.draw do
get "/page_parts/getwidgets" => "page_parts#getwidgets" get "/page_parts/getwidgets" => "page_parts#getwidgets"
get "/page_parts/info" => "page_parts#info" get "/page_parts/info" => "page_parts#info"
get "/page_parts/edit_sub_part" => "page_parts#edit_sub_part"
resources :pages resources :pages
resources :page_parts resources :page_parts do
member do
patch 'update_sub_part'
end
end
get "/module/:name" => "home#index" get "/module/:name" => "home#index"
get "/module/:name/show" => "home#show" get "/module/:name/show" => "home#show"
@ -43,6 +48,8 @@ Orbit::Application.routes.draw do
resources :passwords resources :passwords
namespace :admin do namespace :admin do
resources :dashboards do resources :dashboards do
collection do collection do

View File

@ -31,7 +31,7 @@ module OrbitApp
end end
class RegisteredModule class RegisteredModule
attr_reader :name,:key,:module_label,:widget_methods,:authorizable_models,:is_authorizable, :data_count attr_reader :name,:key,:module_label,:widget_methods,:authorizable_models,:is_authorizable, :data_count, :widget_settings
def initialize(name,&block) def initialize(name,&block)
@name = name @name = name
@ -39,6 +39,7 @@ module OrbitApp
@side_bar = nil @side_bar = nil
@module_label = @name @module_label = @name
@widget_methods = [] @widget_methods = []
@widget_settings = {}
@is_taggable = false @is_taggable = false
@authorizable_models = [] @authorizable_models = []
@is_authorizable = false @is_authorizable = false
@ -77,6 +78,14 @@ module OrbitApp
@widget_methods @widget_methods
end end
def widget_settings(settings)
@widget_settings = settings.first
end
def get_widget_settings
@widget_settings
end
def get_icon_class def get_icon_class
@side_bar.get_icon_class @side_bar.get_icon_class
end end
@ -84,6 +93,7 @@ module OrbitApp
def side_bar(&block) #setter for side_bar from init def side_bar(&block) #setter for side_bar from init
@side_bar = SideBarRegistration::SideBar.new(@name,@key,method(:get_module_app), &block) @side_bar = SideBarRegistration::SideBar.new(@name,@key,method(:get_module_app), &block)
end end
def get_side_bar def get_side_bar
@side_bar @side_bar
end end
@ -138,6 +148,10 @@ module OrbitApp
@is_frontend_enabled @is_frontend_enabled
end end
def is_widget_enabled
!@widget_methods.blank?
end
def data_count(range) def data_count(range)
@data_count = range @data_count = range
end end

View File

@ -27,6 +27,27 @@ module OrbitCategory
end end
end end
def filter_by_widget_categories(categories=[])
categories = OrbitHelper.widget_categories if categories.blank?
if !categories.blank?
if categories.first == "all"
if OrbitHelper.widget_data_count == 0
self.all
else
self.all.limit(OrbitHelper.widget_data_count)
end
else
if OrbitHelper.widget_data_count == 0
self.where(:category_id.in => categories) rescue []
else
self.where(:category_id.in => categories).limit(OrbitHelper.widget_data_count) rescue []
end
end
else
[]
end
end
def with_categories(categories=[]) def with_categories(categories=[])
if categories.blank? if categories.blank?
self.all self.all