forked from saurabh/orbit4-5
fixed problem of sitemap sorting and also import modules dont go back after importing. also added sitemap for google crawler.
This commit is contained in:
parent
72c8d4917b
commit
23bead2b5d
|
@ -30,13 +30,19 @@ var Items = function(){
|
||||||
update: function(event, ui) {
|
update: function(event, ui) {
|
||||||
var parent = (ui.item.parent().closest('li').length ? ui.item.parent().closest('li') : ui.item.parent().closest('ol')),
|
var parent = (ui.item.parent().closest('li').length ? ui.item.parent().closest('li') : ui.item.parent().closest('ol')),
|
||||||
children = (parent.hasClass("root") ? parent.find(">li") : parent.find(">ol li")),
|
children = (parent.hasClass("root") ? parent.find(">li") : parent.find(">ol li")),
|
||||||
children_ids = [];
|
parents_parent = (parent.parent().closest('li').length ? parent.parent().closest('li') : parent.parent().closest('ol')),
|
||||||
|
parents_children = (parents_parent.hasClass("root") ? parents_parent.find(">li") : parents_parent.find(">ol li"))
|
||||||
|
children_ids = [],
|
||||||
|
parent_children_ids = [];
|
||||||
children.each(function(){
|
children.each(function(){
|
||||||
children_ids.push($(this).attr("id"));
|
children_ids.push($(this).attr("id"));
|
||||||
})
|
})
|
||||||
|
parents_children.each(function(){
|
||||||
|
parent_children_ids.push($(this).attr("id"));
|
||||||
|
})
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url : "<%= Rails.application.routes.url_helpers.pages_update_item_position_path %>",
|
url : "<%= Rails.application.routes.url_helpers.pages_update_item_position_path %>",
|
||||||
data : {"parent_id" : parent.attr("id"), "id" : ui.item.attr("id"),"children_ids" : children_ids},
|
data : {"parent_id" : parent.attr("id"), "id" : ui.item.attr("id"), "children_ids" : children_ids, "parents_parent_id" : parents_parent.attr("id"), "parent_children_ids" : parent_children_ids},
|
||||||
dataType : "json",
|
dataType : "json",
|
||||||
type : "post"
|
type : "post"
|
||||||
})
|
})
|
||||||
|
|
|
@ -120,7 +120,13 @@ class PagesController < ApplicationController
|
||||||
if new_parent_page.id != old_parent_page_id
|
if new_parent_page.id != old_parent_page_id
|
||||||
old_parent_page = Page.find(old_parent_page_id)
|
old_parent_page = Page.find(old_parent_page_id)
|
||||||
|
|
||||||
old_parent_page.child_page.each_with_index do |page,i|
|
# old_parent_page.child_page.each_with_index do |page,i|
|
||||||
|
# page.number = i
|
||||||
|
# page.save
|
||||||
|
# end
|
||||||
|
params["parent_children_ids"] = params["parent_children_ids"] || []
|
||||||
|
params["parent_children_ids"].each_with_index do |child, i|
|
||||||
|
page = Page.find(child)
|
||||||
page.number = i
|
page.number = i
|
||||||
page.save
|
page.save
|
||||||
end
|
end
|
||||||
|
@ -383,6 +389,7 @@ class PagesController < ApplicationController
|
||||||
p["categories"] = p["categories"] || []
|
p["categories"] = p["categories"] || []
|
||||||
p["enabled_for"] = p["enabled_for"] || []
|
p["enabled_for"] = p["enabled_for"] || []
|
||||||
p["menu_enabled_for"] = p["menu_enabled_for"] || []
|
p["menu_enabled_for"] = p["menu_enabled_for"] || []
|
||||||
|
p["enabled_for_sitemap"] = p["enabled_for_sitemap"] || []
|
||||||
p["enabled_for_mobile"] = p["enabled_for_mobile"] || 0
|
p["enabled_for_mobile"] = p["enabled_for_mobile"] || 0
|
||||||
if p["external_url_translations"]
|
if p["external_url_translations"]
|
||||||
p["external_url_translations"]["en"] = p["external_url_translations"]["en"].sub("http://" + request.host_with_port,"")
|
p["external_url_translations"]["en"] = p["external_url_translations"]["en"].sub("http://" + request.host_with_port,"")
|
||||||
|
|
|
@ -1,5 +1,20 @@
|
||||||
class SitemapsController < ApplicationController
|
class SitemapsController < ApplicationController
|
||||||
|
# caches_page :sitemap_xml
|
||||||
def index
|
def index
|
||||||
|
genrate_sitemap
|
||||||
|
end
|
||||||
|
|
||||||
|
def sitemap_xml
|
||||||
|
@items = Page.where(:id.ne => Page.root.id).asc(:number)
|
||||||
|
@home = Page.root
|
||||||
|
respond_to do |format|
|
||||||
|
format.xml
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
private
|
||||||
|
|
||||||
|
def genrate_sitemap
|
||||||
if $mobile.blank?
|
if $mobile.blank?
|
||||||
pages = Page.root.child_pages_enabled_for_sitemap
|
pages = Page.root.child_pages_enabled_for_sitemap
|
||||||
else
|
else
|
||||||
|
@ -35,4 +50,6 @@ class SitemapsController < ApplicationController
|
||||||
items = create_json(pages)
|
items = create_json(pages)
|
||||||
items
|
items
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
end
|
end
|
|
@ -679,13 +679,13 @@
|
||||||
$("#import-progress .bar").css('width',percentage);
|
$("#import-progress .bar").css('width',percentage);
|
||||||
$("#import-progress-text").html(progress+' / '+dataList.length+'<br/>'+percentage);
|
$("#import-progress-text").html(progress+' / '+dataList.length+'<br/>'+percentage);
|
||||||
|
|
||||||
if(percentage=="100%"){
|
// if(percentage=="100%"){
|
||||||
$("#import-progress").delay(1000).fadeOut(300,function(){
|
// $("#import-progress").delay(1000).fadeOut(300,function(){
|
||||||
$("#import-head").fadeIn(0);
|
// $("#import-head").fadeIn(0);
|
||||||
$("#import-modules").fadeIn(300);
|
// $("#import-modules").fadeIn(300);
|
||||||
$('#import-start-btn').show();
|
// $('#import-start-btn').show();
|
||||||
});
|
// });
|
||||||
}
|
// }
|
||||||
|
|
||||||
importModuleData();
|
importModuleData();
|
||||||
});
|
});
|
||||||
|
|
|
@ -0,0 +1,21 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<urlset xmlns="http://www.google.com/schemas/sitemap/0.90">
|
||||||
|
<% @site_in_use_locales.each do |locale| %>
|
||||||
|
<url>
|
||||||
|
<loc><%= request.protocol + request.host_with_port + "/?locale=#{locale.to_s}"%></loc>
|
||||||
|
<lastmod><%= @home.page_parts.desc(:updated_at).first.updated_at %></lastmod>
|
||||||
|
<priority>0.5</priority>
|
||||||
|
</url>
|
||||||
|
<% end %>
|
||||||
|
<% @items.each do |item| %>
|
||||||
|
<% @site_in_use_locales.each do |locale| %>
|
||||||
|
<% if item.enabled_for_sitemap.include?locale.to_s %>
|
||||||
|
<url>
|
||||||
|
<loc><%= request.protocol + request.host_with_port + "/" + locale.to_s + item.url %></loc>
|
||||||
|
<lastmod><%= item.updated_at %></lastmod>
|
||||||
|
<priority>0.5</priority>
|
||||||
|
</url>
|
||||||
|
<% end %>
|
||||||
|
<% end %>
|
||||||
|
<% end %>
|
||||||
|
</urlset>
|
|
@ -4,6 +4,8 @@ Orbit::Application.routes.draw do
|
||||||
|
|
||||||
resources :sessions
|
resources :sessions
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
get "logout", to: "sessions#destroy", as: "logout"
|
get "logout", to: "sessions#destroy", as: "logout"
|
||||||
|
|
||||||
get "/pages/edit_view" => "pages#edit_view"
|
get "/pages/edit_view" => "pages#edit_view"
|
||||||
|
@ -38,6 +40,8 @@ Orbit::Application.routes.draw do
|
||||||
|
|
||||||
scope "(:locale)", locale: Regexp.new((locales+[:zh_cn]).join("|")) do
|
scope "(:locale)", locale: Regexp.new((locales+[:zh_cn]).join("|")) do
|
||||||
|
|
||||||
|
get "sitemap.xml" => "sitemaps#sitemap_xml", as: "sitemap", defaults: { format: "xml" }
|
||||||
|
|
||||||
get 'users/form' => "users#form_page"
|
get 'users/form' => "users#form_page"
|
||||||
get 'users/role_page' => "users#role_page"
|
get 'users/role_page' => "users#role_page"
|
||||||
get 'users/check_availability' => "users#check_availability"
|
get 'users/check_availability' => "users#check_availability"
|
||||||
|
|
Loading…
Reference in New Issue