diff --git a/app/assets/javascripts/lib/items/items.js.erb b/app/assets/javascripts/lib/items/items.js.erb index 5922b1d..909c278 100755 --- a/app/assets/javascripts/lib/items/items.js.erb +++ b/app/assets/javascripts/lib/items/items.js.erb @@ -30,13 +30,19 @@ var Items = function(){ update: function(event, ui) { 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_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_ids.push($(this).attr("id")); }) + parents_children.each(function(){ + parent_children_ids.push($(this).attr("id")); + }) $.ajax({ 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", type : "post" }) diff --git a/app/controllers/pages_controller.rb b/app/controllers/pages_controller.rb index 39d07f7..cc0de2e 100644 --- a/app/controllers/pages_controller.rb +++ b/app/controllers/pages_controller.rb @@ -120,7 +120,13 @@ class PagesController < ApplicationController if new_parent_page.id != 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.save end @@ -383,6 +389,7 @@ class PagesController < ApplicationController p["categories"] = p["categories"] || [] p["enabled_for"] = p["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 if p["external_url_translations"] p["external_url_translations"]["en"] = p["external_url_translations"]["en"].sub("http://" + request.host_with_port,"") diff --git a/app/controllers/sitemaps_controller.rb b/app/controllers/sitemaps_controller.rb index 243db1e..e5a82f2 100644 --- a/app/controllers/sitemaps_controller.rb +++ b/app/controllers/sitemaps_controller.rb @@ -1,5 +1,20 @@ class SitemapsController < ApplicationController + # caches_page :sitemap_xml 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? pages = Page.root.child_pages_enabled_for_sitemap else @@ -35,4 +50,6 @@ class SitemapsController < ApplicationController items = create_json(pages) items end + + end \ No newline at end of file diff --git a/app/views/admin/import/index.html.erb b/app/views/admin/import/index.html.erb index 74a083c..7ff279d 100644 --- a/app/views/admin/import/index.html.erb +++ b/app/views/admin/import/index.html.erb @@ -679,13 +679,13 @@ $("#import-progress .bar").css('width',percentage); $("#import-progress-text").html(progress+' / '+dataList.length+'
'+percentage); - if(percentage=="100%"){ - $("#import-progress").delay(1000).fadeOut(300,function(){ - $("#import-head").fadeIn(0); - $("#import-modules").fadeIn(300); - $('#import-start-btn').show(); - }); - } + // if(percentage=="100%"){ + // $("#import-progress").delay(1000).fadeOut(300,function(){ + // $("#import-head").fadeIn(0); + // $("#import-modules").fadeIn(300); + // $('#import-start-btn').show(); + // }); + // } importModuleData(); }); diff --git a/app/views/sitemaps/sitemap_xml.xml.erb b/app/views/sitemaps/sitemap_xml.xml.erb new file mode 100644 index 0000000..5528139 --- /dev/null +++ b/app/views/sitemaps/sitemap_xml.xml.erb @@ -0,0 +1,21 @@ + + + <% @site_in_use_locales.each do |locale| %> + + <%= request.protocol + request.host_with_port + "/?locale=#{locale.to_s}"%> + <%= @home.page_parts.desc(:updated_at).first.updated_at %> + 0.5 + + <% end %> + <% @items.each do |item| %> + <% @site_in_use_locales.each do |locale| %> + <% if item.enabled_for_sitemap.include?locale.to_s %> + + <%= request.protocol + request.host_with_port + "/" + locale.to_s + item.url %> + <%= item.updated_at %> + 0.5 + + <% end %> + <% end %> + <% end %> + \ No newline at end of file diff --git a/config/routes.rb b/config/routes.rb index 611d6d0..7ca2ee8 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -4,6 +4,8 @@ Orbit::Application.routes.draw do resources :sessions + + get "logout", to: "sessions#destroy", as: "logout" get "/pages/edit_view" => "pages#edit_view" @@ -37,6 +39,8 @@ Orbit::Application.routes.draw do locales = Site.first.in_use_locales rescue I18n.available_locales 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/role_page' => "users#role_page"