Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

And heroku? #15

Open
descovi opened this issue Sep 16, 2013 · 15 comments
Open

And heroku? #15

descovi opened this issue Sep 16, 2013 · 15 comments

Comments

@descovi
Copy link

descovi commented Sep 16, 2013

Heroku file system prevent creation of static files. How can i use dynamic_sitemaps?

@lassebunk
Copy link
Owner

I don't know – haven't used Heroku. Any ideas?

@tayeke
Copy link

tayeke commented Dec 6, 2013

+1

@lassebunk
Copy link
Owner

Any ideas?

@tayeke
Copy link

tayeke commented Dec 7, 2013

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.

@lassebunk
Copy link
Owner

That sounds like a good solution.
Would Google index the sitemap if it's not on the same server/host as the website?
Thanks.

@tayeke
Copy link

tayeke commented Dec 7, 2013

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" notifications@github.com 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//issues/15#issuecomment-30051039
.

@lassebunk
Copy link
Owner

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.

@tayeke
Copy link

tayeke commented Dec 8, 2013

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" notifications@github.com 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//issues/15#issuecomment-30066251
.

@efqdalton
Copy link

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!

@lassebunk
Copy link
Owner

Thanks – looking forward to that! :)

On 25 Feb 2014 at 18:54:39, Dalton (notifications@github.com) 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.

@robbieshepherd
Copy link

@efqdalton I would love to use your fork - any chance you could provide some pointers on how to use it please?

@dalthon
Copy link

dalthon commented Nov 9, 2014

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.

@brandoncc
Copy link

https://github.com/kjvarga/sitemap_generator could be used as an example of how to hook up S3 storage.

@sergiotapia
Copy link

@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.

@sergiotapia
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants