dynamic_sitemaps
dynamic_sitemaps copied to clipboard
And heroku?
Heroku file system prevent creation of static files. How can i use dynamic_sitemaps?
I don't know – haven't used Heroku. Any ideas?
+1
Any ideas?
I'm writing this custom rake task right now to send my sitemap to s3, but in the ping part of the dynamic sitemap generator you'd need to point to the s3 route. Oh and the config for the generator points to tmp directory.
namespace :sitemap do
desc "Generate dynamic sitemap then push to S3"
task :update => :environment do
Rake::Task["sitemap:generate"].execute
s3 = AWS::S3.new(access_key_id: ENV['AWS_ACCESS_KEY'],secret_access_key: ENV['AWS_SECRET_ACCESS_KEY'])
s3.buckets['mommychannel-sitemaps'].objects['sitemap.xml'].write(data: File.open(Rails.root.join('tmp','sitemaps','sitemap.xml')), acl: :public_read)
end
end
DynamicSitemaps.configure do |config|
config.path = Rails.root.join("tmp")
end
Added heroku scheduler to run once a day.
That sounds like a good solution. Would Google index the sitemap if it's not on the same server/host as the website? Thanks.
It is supposed to if you use robots.txt. However I couldn't submit it manually without same host so I made a route that loads the file contents from S3. On Dec 7, 2013 1:08 AM, "Lasse Bunk" [email protected] wrote:
That sounds like a good solution. Would Google index the sitemap if it's not on the same server/host as the website? Thanks.
— Reply to this email directly or view it on GitHubhttps://github.com/lassebunk/dynamic_sitemaps/issues/15#issuecomment-30051039 .
So your suggestion is to implement that in the plugin, so that it loads the file contents from S3 and serves that? Would this be plausible for big files? Thanks.
I did not implement it into the gem, I just am using that rake task for getting around read-only file systems. My site generated about 1060 unique links, so I think it would work alright for most sites... On Dec 7, 2013 2:10 PM, "Lasse Bunk" [email protected] wrote:
So your suggestion is to implement that in the plugin, so that it loads the file contents from S3 and serves that? Would this be plausible for big files? Thanks.
— Reply to this email directly or view it on GitHubhttps://github.com/lassebunk/dynamic_sitemaps/issues/15#issuecomment-30066251 .
I forked this gem to support store sitemaps at database or AWS.
ASAP I will do a pull request, i'm only waiting to have time to write some tests
This fork is available at: http://github.com/efqdalton/dynamic_sitemaps
And the branch with this feature is named adds-custom-storages
If someone wants to write those tests… it should be great!
Thanks – looking forward to that! :)
On 25 Feb 2014 at 18:54:39, Dalton ([email protected]) wrote:
I forked this gem to support store sitemaps at database or AWS.
ASAP I will do a pull request, i'm only waiting to have time to write some tests
This fork is available at: http://github.com/efqdalton/dynamic_sitemaps
And the branch with this feature is named adds-custom-storages
If someone wants to write those tests… it should be great!
— Reply to this email directly or view it on GitHub.
@efqdalton I would love to use your fork - any chance you could provide some pointers on how to use it please?
I'm in such a rush this year, and I didn't have time to organize it...
So, if someone could finish that, it would be nice! Im using it in production on this site kuadro.com.br, but most of glue code is written in the app, using database as persistence, so it works.
On my fork, exists a branch called adds-custom-storage, use this branch.
So at config file you have to put this:
DynamicSitemaps.configure do |config|
config.storage = DynamicSitemaps::DatabaseStorage
end
And add a migration like that to create Sitemap model:
class CreateSitemaps < ActiveRecord::Migration
def change
create_table :sitemaps do |t|
t.string :path, null: false
t.text :content
end
add_index :sitemaps, :path, unique: true
end
end
And there is a a Job on Sidekiq squeduler that calls, once a day, this:
DynamicSitemaps.generate_sitemap
Now explaining better, to provide pointers to someone who wants to finish it:
As you could see, I created an abstract class Storage, and I added "3" implementations: DatabaseStorage, LocalStorage and S3Storage.
But don't be so happy, S3Storage is not working, I just started to write it, and not finished, since I started using DatabaseStorage, and it's working well... sorry...
One more problem, as you could see, the last change that I made to this branch was at Feb 25, so if someone finish it, it would be nice to rebase it...
So, I hope that I could help writing this, ask if there is more doubts, maybe I forgot something... 8 months is a long time to remember all details of a almost finished code.
https://github.com/kjvarga/sitemap_generator could be used as an example of how to hook up S3 storage.
@tayeke - Are your environment variables loaded fine when you run a rake task? I'm having trouble loading the values from my .env
file.
The code works fine with string literals.
http://stackoverflow.com/questions/29585431/env-variables-not-loaded-when-invoked-in-rake-task
I'm using Mac Yosemite, Foreman and Unicorn. My .env file has the right keys.
For anyone in here wondering, on Heroku the env variables will be loaded fine when running something like heroku run rake sitemaps:update
. Locally however, you need to use something like Figaro.