Last active
August 29, 2015 14:18
-
-
Save rossmari/b73d90bf652bfc5eff50 to your computer and use it in GitHub Desktop.
Implementation of sitemap generator for engine ( use gem SitemapGenerator )
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# STEP 3 | |
# in application.rb of your main application add | |
require "fortuna/sitemap" | |
# and then you can use it from anywhere | |
# [1] Example from console, generate sitemap for engine: | |
>> Fortuna::Sitemap.new | |
# In '/home/rossmari/Projects/ebox/public/': | |
# Fortuna::Girl Load (0.8ms) SELECT "fortuna_girls".* FROM "fortuna_girls" | |
# + sitemap.xml 5 links / 1.43 KB | |
# Sitemap stats: 5 links / 1 sitemaps / 0m00s | |
# [2] Example from main application sitemap.rb | |
SitemapGenerator::Sitemap.compress = false | |
SitemapGenerator::Sitemap.create(default_host: 'http://www.ebox.ru', filename: :sitemap) do | |
# generate content for models of main application | |
Publication.find_each do |publication| | |
add admin_publication_path(publication), lastmod: publication.updated_at | |
end | |
end | |
# run Fortuna engine sitemap generator | |
Fortuna::Sitemap.new |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# STEP 1 | |
# Fortuna engine sitemap generator class | |
module Fortuna | |
class Sitemap | |
# also specify sitemap file name unique for this engine | |
def initialize | |
SitemapGenerator::Sitemap.create(default_host: 'http://www.ebox.ru/fortuna/', filename: :fortuna_sitemap) do | |
Girl.find_each do |girl| | |
add Engine.routes.url_helpers.admin_girl_path(girl), lastmod: girl.updated_at | |
end | |
end | |
end | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# STEP 2 | |
# require sitemap generator class in engine to use it from main application | |
require "fortuna/engine" | |
require "fortuna/engine_sitemap" | |
module Fortuna | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment