forked from saurabh/orbit4-5
added links for structure .. fixed a small bug for widget rendering
This commit is contained in:
parent
bc7e2f9514
commit
2a6d9487ae
|
@ -149,11 +149,13 @@ class PagesController < ApplicationController
|
|||
|
||||
def edit
|
||||
@page = Page.find(params[:id])
|
||||
@pages = Page.where(:page_id.ne => "" , :page_id.exists => true)
|
||||
@modules = ModuleApp.all.frontend_enabled
|
||||
module_app = ModuleApp.find_by_key(@page.module) rescue nil
|
||||
@categories = module_app.categories rescue []
|
||||
@layout_types = get_layouts module_app.key
|
||||
if params[:type] == "page"
|
||||
@pages = Page.where(:page_id.ne => "" , :page_id.exists => true)
|
||||
@modules = ModuleApp.all.frontend_enabled
|
||||
module_app = ModuleApp.find_by_key(@page.module) rescue nil
|
||||
@categories = module_app.categories rescue []
|
||||
@layout_types = get_layouts module_app.key
|
||||
end
|
||||
end
|
||||
|
||||
def update
|
||||
|
@ -270,13 +272,13 @@ class PagesController < ApplicationController
|
|||
page = Page.find(params[:page][:parent_page])
|
||||
page.url = page.url == "/" ? "" : page.url
|
||||
@url = page.url + "/#{params[:page][:page_id]}"
|
||||
p = params.require(:page).permit(:number, :page_id, :module, :layout, :parent_page, :data_count, enabled_for_sitemap: [], enabled_for: [], menu_enabled_for: [], categories: [], name_translations: [:en, :zh_tw])
|
||||
p = params.require(:page).permit(:number, :page_type, :page_id, :module, :layout, :parent_page, :data_count, enabled_for_sitemap: [], enabled_for: [], menu_enabled_for: [], categories: [], name_translations: [:en, :zh_tw],external_url_translations: [:en, :zh_tw])
|
||||
p["url"] = @url
|
||||
p
|
||||
end
|
||||
|
||||
def page_update_params
|
||||
p = params.require(:page).permit(:number, :page_id, :module, :layout, :parent_page, :data_count, enabled_for_sitemap: [], enabled_for: [],menu_enabled_for: [], categories: [], name_translations: [:en, :zh_tw])
|
||||
p = params.require(:page).permit(:number, :page_type, :page_id, :module, :layout, :parent_page, :data_count, enabled_for_sitemap: [], enabled_for: [],menu_enabled_for: [], categories: [], name_translations: [:en, :zh_tw], external_url_translations: [:en, :zh_tw])
|
||||
p["enabled_for"] = p["enabled_for"] || []
|
||||
p["menu_enabled_for"] = p["menu_enabled_for"] || []
|
||||
p
|
||||
|
|
|
@ -5,9 +5,17 @@ class SitemapsController < ApplicationController
|
|||
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)}
|
||||
if page.page_type == "page"
|
||||
item["#{page.name}"] = {"url"=> "/#{locale.to_s}" + page.url, "children"=>create_json(page.sorted_published_child_pages), "target"=>"_self"}
|
||||
else
|
||||
item["#{page.name}"] = {"url"=> page.external_url, "children"=>create_json(page.sorted_published_child_pages), "target"=>"_blank"}
|
||||
end
|
||||
else
|
||||
item["#{page.name}"] = {"url"=> "/#{locale.to_s}" + page.url}
|
||||
if page.page_type == "page"
|
||||
item["#{page.name}"] = {"url"=> "/#{locale.to_s}" + page.url, "target"=>"_self"}
|
||||
else
|
||||
item["#{page.name}"] = {"url"=> page.external_url, "target"=>"_blank"}
|
||||
end
|
||||
end
|
||||
end
|
||||
item
|
||||
|
|
|
@ -61,9 +61,17 @@ module ApplicationHelper
|
|||
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)}
|
||||
if page.page_type == "page"
|
||||
item["#{page.name}"] = {"url"=> "/#{locale.to_s}" + page.url, "children"=>create_json(page.sorted_published_child_pages), "target" => "_self"}
|
||||
elsif page.page_type == "link"
|
||||
item["#{page.name}"] = {"url"=> page.external_url, "children"=>create_json(page.sorted_published_child_pages), "target" => "_blank"}
|
||||
end
|
||||
else
|
||||
item["#{page.name}"] = {"url"=> "/#{locale.to_s}" + page.url}
|
||||
if page.page_type == "page"
|
||||
item["#{page.name}"] = {"url"=> "/#{locale.to_s}" + page.url, "target" => "_self"}
|
||||
elsif page.page_type == "link"
|
||||
item["#{page.name}"] = {"url"=> page.external_url, "target" => "_blank"}
|
||||
end
|
||||
end
|
||||
end
|
||||
item
|
||||
|
@ -91,6 +99,7 @@ module ApplicationHelper
|
|||
t = Nokogiri::HTML(menu, nil, "UTF-8")
|
||||
a = t.css("*[data-menu-link='true']")
|
||||
a[0]["href"] = "href_here"
|
||||
a[0]["target"] = "target_here"
|
||||
li = t.css("*[data-menu-level='#{i}'] > *")
|
||||
@menus_items << li.to_html
|
||||
ul = t.css("*[data-menu-level='#{i}']")
|
||||
|
@ -103,7 +112,7 @@ module ApplicationHelper
|
|||
items.each do |key,item|
|
||||
li = @menus_items[level].gsub("href_here",item["url"])
|
||||
li = li.gsub("{{link_name}}",key)
|
||||
|
||||
li = li.gsub("target_here",item["target"])
|
||||
li = request.original_fullpath == item['url'] ? li.gsub("{{active}}","active") : li.gsub("{{active}}","")
|
||||
|
||||
if item["children"] && !item["children"].empty?
|
||||
|
@ -331,12 +340,14 @@ module ApplicationHelper
|
|||
items.each do |key,item|
|
||||
if item["children"] && !item["children"].empty?
|
||||
url = item["url"]
|
||||
html = html + "<li><a href='#{url}'>#{key}</a>"
|
||||
target = item["target"]
|
||||
html = html + "<li><a href='#{url}' target='#{target}'>#{key}</a>"
|
||||
html = html + node(item["children"])
|
||||
html = html + "</li>"
|
||||
else
|
||||
target = item["target"]
|
||||
url = item["url"]
|
||||
html = html + "<li><a href='#{url}'>#{key}</a></li>"
|
||||
html = html + "<li><a href='#{url}' target='#{target}'>#{key}</a></li>"
|
||||
end
|
||||
end
|
||||
html = html + "</ul>"
|
||||
|
|
|
@ -46,9 +46,11 @@ module PagesHelper
|
|||
[oldhtml,newhtml]
|
||||
end
|
||||
controller_name = controller_name.downcase.singularize
|
||||
f = File.join('../templates', "#{@key}", 'modules', "#{controller_name}", "_#{widget_file}.html.erb");
|
||||
f = File.join(Rails.root, 'app', 'templates', "#{@key}", 'modules', "#{controller_name}", "_#{widget_file}.html.erb");
|
||||
if !File.exists?f
|
||||
f = File.join('../templates', "#{@key}", 'modules', "#{controller_name}", "_widget.html.erb");
|
||||
else
|
||||
f = File.join('../templates', "#{@key}", 'modules', "#{controller_name}", "_#{widget_file}.html.erb");
|
||||
end
|
||||
s = render_to_string(f)
|
||||
doc = Nokogiri::HTML(s, nil, "UTF-8")
|
||||
|
|
|
@ -7,6 +7,8 @@ class Page
|
|||
field :number, type: Integer
|
||||
field :module
|
||||
field :url
|
||||
field :page_type, type: String, default: "page"
|
||||
field :external_url, localize: true
|
||||
field :page_id
|
||||
field :layout, type: String, default: "index"
|
||||
field :data_count, type: Integer, default: 10
|
||||
|
|
|
@ -168,7 +168,15 @@
|
|||
|
||||
$("#check-site-url").click(function(){checkSiteUrl();});
|
||||
|
||||
$("#import-start-btn").click(function(){getModuleCategories()});
|
||||
$("#import-start-btn").click(function(){
|
||||
switch(module){
|
||||
case "page":
|
||||
importPages();
|
||||
break;
|
||||
default:
|
||||
getModuleCategories();
|
||||
}
|
||||
});
|
||||
$("#import-back-btn").click(function(){
|
||||
$("#import-progress").fadeOut(300,function(){
|
||||
$("#import-head").fadeIn(0);
|
||||
|
@ -176,6 +184,11 @@
|
|||
});
|
||||
});
|
||||
|
||||
var importPages = function(){
|
||||
$("#import-progress .bar").css('width','0%');
|
||||
$("#import-progress-text").html("Importing Pages<br/><br/>");
|
||||
}
|
||||
|
||||
var importModule = function(m){
|
||||
module = m;
|
||||
dataList=null;
|
||||
|
|
|
@ -1,31 +1,29 @@
|
|||
<div class="navbar">
|
||||
<div class="navbar-inner">
|
||||
<span class="brand"><i class="<%= node.root? ? 'icons-house' : 'icons-list-2' %>"></i></span>
|
||||
<% if node.class.to_s.eql?('Page') %>
|
||||
<% unless node.root? %>
|
||||
<% name, icon_name = get_item_module_infos(node) %>
|
||||
<span title="<%= name %>" class="item-type page tip"><i class="<%= icon_name %>"></i></span>
|
||||
<% if node.page_type == "page" %>
|
||||
<% name, icon_name = get_item_module_infos(node) %>
|
||||
<span title="<%= name %>" class="item-type page tip"><i class="<%= icon_name %>"></i></span>
|
||||
<% else %>
|
||||
<span title="<%= t(:link) %>" class="item-type link tip"><i class="icon-link"></i></span>
|
||||
<% end %>
|
||||
<% end %>
|
||||
<% else %>
|
||||
<span title="<%= t(:link) %>" class="item-type link tip"><i class="icon-link"></i></span>
|
||||
<% end %>
|
||||
<div class="item-title">
|
||||
<%= content_tag(:em, node.url, class: "muted") if node.class.to_s.eql?('Link') %>
|
||||
<% if node.class.to_s.eql?('Page') %>
|
||||
<% if node.page_type.eql?('page') %>
|
||||
<%= link_to node.name, "/" + I18n.locale.to_s + node.url %>
|
||||
<% else %>
|
||||
<%= link_to node.title, "/" + I18n.locale.to_s + node.url %>
|
||||
<em class="muted"><%= node.external_url %></em>
|
||||
<%= link_to node.name, node.external_url %>
|
||||
<% end %>
|
||||
<div class="item-menu">
|
||||
<%= link_to content_tag(:i, nil, class: "icon-eye-open"), pages_edit_view_path(:id => node.id.to_s), class: "view-page open-slide tip", title: "View", data: {title: node.name} if node.class.to_s.eql?('Page') %>
|
||||
<%# elsif node.class.to_s.downcase.eql?("link") %>
|
||||
<%#= link_to content_tag(:i, nil, class: "icon-edit"), "#link", class: "open-slide tip link edit", title: t('editing.link'), data: {title: t('editing.link'), id: node.id.to_s, parent: node.parent_id.to_s, form: {name: node.name}.merge(node.title_translations).merge(node.urls)} %>
|
||||
<%# end %>
|
||||
<%= link_to content_tag(:i, nil, class: "icons-mobile"), pages_edit_view_path(:id => node.id.to_s, :mobile_view=>1), class: "view-page open-slide tip mobile-view-btn", title: "Edit Mobile Page", data: {title: "Edit Mobile Page"} if node.class.to_s.downcase.eql?("page") && current_site.mobile_on%>
|
||||
<%= link_to content_tag(:i, nil, class: "icon-eye-open"), pages_edit_view_path(:id => node.id.to_s), class: "view-page open-slide tip", title: "View", data: {title: node.name} if node.page_type.eql?('page') %>
|
||||
<%= link_to content_tag(:i, nil, class: "icons-mobile"), pages_edit_view_path(:id => node.id.to_s, :mobile_view=>1), class: "view-page open-slide tip mobile-view-btn", title: "Edit Mobile Page", data: {title: "Edit Mobile Page"} if node.page_type.eql?("page") && current_site.mobile_on%>
|
||||
<% unless name.eql? "sitemap" %>
|
||||
<%= link_to content_tag(:i, nil, class: "icon-edit"), edit_page_path(node.id), class: "open-slide tip page edit", title: "Edit Page", data: {title: "Edit Page"} if node.class.to_s.downcase.eql?("page") && !node.root? %>
|
||||
<%= link_to content_tag(:i, nil, class: "icons-newspaper"), new_page_path(:parent_page => node.id.to_s), class: "open-slide tip page", title: "Add Page", data: {title: "Add Page", id: 'new', parent: node.id.to_s} if node.class.to_s.eql?('Page') && level < 3 %>
|
||||
<%#= link_to content_tag(:i, nil, class: "icon-link"), "#link", class: "open-slide tip link", title: t(:add_link), data: {title: t(:add_link), id: 'new', parent: node.id.to_s} if node.class.to_s.eql?('Page') %>
|
||||
<%= link_to content_tag(:i, nil, class: "icon-edit"), edit_page_path(node.id,:type => node.page_type), class: "open-slide tip page edit", title: "Edit #{node.page_type.capitalize}", data: {title: "Edit #{node.page_type.capitalize}"} if node.class.to_s.downcase.eql?("page") && !node.root? %>
|
||||
<%= link_to content_tag(:i, nil, class: "icons-link"), new_page_path(:parent_page => node.id.to_s,:type => "link"), class: "open-slide tip link", title: "Add Link", data: {title: "Add Link", id: 'new', parent: node.id.to_s} if node.class.to_s.eql?('Page') && level < 3 %>
|
||||
<%= link_to content_tag(:i, nil, class: "icons-newspaper"), new_page_path(:parent_page => node.id.to_s,:type => "page"), class: "open-slide tip page", title: "Add Page", data: {title: "Add Page", id: 'new', parent: node.id.to_s} if node.class.to_s.eql?('Page') && level < 3 %>
|
||||
<%= link_to content_tag(:i, nil, class: "icon-trash"), page_path(node.id),:method => :delete,:remote => true, "data-confirm" => "Are you sure ?", class: "delete tip", title: "Delete", data: {title: "Delete"} unless node.root? %>
|
||||
<% end %>
|
||||
</div>
|
||||
|
|
|
@ -22,6 +22,7 @@
|
|||
<div class="controls">
|
||||
<%= f.select(:module, @modules.map{|m| [m.title,m.key]},{:include_blank => true},:class=>"module_select") %>
|
||||
<%= f.hidden_field :parent_page, value: (params[:parent_page] || @page.parent_page_id) %>
|
||||
<%= f.hidden_field :page_type, value: "page" %>
|
||||
</div>
|
||||
</div>
|
||||
<div class="control-group">
|
||||
|
|
|
@ -0,0 +1,58 @@
|
|||
<% if params[:action] == "edit" %>
|
||||
<h4><%= @page.name %></h4>
|
||||
<% end %>
|
||||
<div class="control-group">
|
||||
<% I18n.available_locales.each do |locale| %>
|
||||
<label class="control-label">Page name (<%= t(locale.to_s) %>) :</label>
|
||||
<div class="controls">
|
||||
<%= f.fields_for :name_translations do |n| %>
|
||||
<%= n.text_field locale, :value=>@page.name_translations[locale] rescue nil %>
|
||||
<% end %>
|
||||
</div>
|
||||
<% end %>
|
||||
</div>
|
||||
<div class="control-group">
|
||||
<% I18n.available_locales.each do |locale| %>
|
||||
<label class="control-label">Url (<%= t(locale.to_s) %>) :</label>
|
||||
<div class="controls">
|
||||
<%= f.fields_for :external_url_translations do |n| %>
|
||||
<%= n.text_field locale, :value=>@page.external_url_translations[locale] rescue nil %>
|
||||
<% end %>
|
||||
</div>
|
||||
<% end %>
|
||||
</div>
|
||||
<div class="control-group">
|
||||
<% if params[:action] == "new" %>
|
||||
<label class="control-label">Page id :</label>
|
||||
<div class="controls">
|
||||
<%= f.text_field :page_id %>
|
||||
</div>
|
||||
<% end %>
|
||||
<div class="controls">
|
||||
<%= f.hidden_field :parent_page, value: (params[:parent_page] || @page.parent_page_id) %>
|
||||
<%= f.hidden_field :page_type, value: "link" %>
|
||||
</div>
|
||||
</div>
|
||||
<div class="control-group" id="enable-menu">
|
||||
<div class="controls">
|
||||
<label class="control-label">Activation :</label>
|
||||
<% I18n.available_locales.each do |locale| %>
|
||||
<label class="checkbox">
|
||||
<input type="checkbox" name="page[enabled_for][]" value="<%= locale.to_s %>" class="main-enable-parent" for="<%= "checkbox_for_#{locale}" %>" <%= "checked" if @page.enabled_for.include? locale.to_s %> />
|
||||
<%= t(locale.to_s) %>
|
||||
</label>
|
||||
<div style="margin-left:25px;">
|
||||
<label class="checkbox">
|
||||
Enable for menu
|
||||
<input type="checkbox" name="page[menu_enabled_for][]" for="<%= "checkbox_for_child_#{locale}" %>" class="main-enable-child" value="<%= locale.to_s %>" <%= "checked" if @page.menu_enabled_for.include? locale.to_s %> />
|
||||
</label>
|
||||
</div>
|
||||
<div style="margin-left:25px;">
|
||||
<label class="checkbox">
|
||||
Enable for sitemap
|
||||
<input type="checkbox" name="page[enabled_for_sitemap][]" class="main-enable-child-child" value="<%= locale.to_s %>" <%= "checked" if @page.enabled_for_sitemap.include? locale.to_s %> />
|
||||
</label>
|
||||
</div>
|
||||
<% end %>
|
||||
</div>
|
||||
</div>
|
|
@ -1,8 +1,16 @@
|
|||
<%= form_for @page, url: {action: "update"},:class =>"form-horizontal", remote: true do |f| %>
|
||||
<%= render "form", {:f=> f} %>
|
||||
<% if params[:type] == "page" %>
|
||||
<%= render "form", {:f=> f} %>
|
||||
<% elsif params[:type] == "link" %>
|
||||
<%= render "form_link", {:f=> f} %>
|
||||
<% end %>
|
||||
<div class="control-group">
|
||||
<div class="controls">
|
||||
<%= f.submit "Update Page",:class=>"btn btn-primary" %>
|
||||
<% if params[:type] == "page" %>
|
||||
<%= f.submit "Update Page", :class=>"btn btn-primary" %>
|
||||
<% elsif params[:type] == "link" %>
|
||||
<%= f.submit "Update Link", :class=>"btn btn-primary" %>
|
||||
<% end %>
|
||||
</div>
|
||||
</div>
|
||||
<% end %>
|
|
@ -1,8 +1,16 @@
|
|||
<%= form_for @page, url: {action: "create"},:class =>"form-horizontal", remote: true do |f| %>
|
||||
<%= render "form", {:f=> f} %>
|
||||
<% if params[:type] == "page" %>
|
||||
<%= render "form", {:f=> f} %>
|
||||
<% elsif params[:type] == "link" %>
|
||||
<%= render "form_link", {:f=> f} %>
|
||||
<% end %>
|
||||
<div class="control-group">
|
||||
<div class="controls">
|
||||
<% if params[:type] == "page" %>
|
||||
<%= f.submit "Create Page", :class=>"btn btn-primary" %>
|
||||
<% elsif params[:type] == "link" %>
|
||||
<%= f.submit "Create Link", :class=>"btn btn-primary" %>
|
||||
<% end %>
|
||||
</div>
|
||||
</div>
|
||||
<% end %>
|
Loading…
Reference in New Issue