-
Notifications
You must be signed in to change notification settings - Fork 313
Adding site map generation #185 #210
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
class SitemapRefreshWorker | ||
include Sidekiq::Worker | ||
sidekiq_options queue: :high | ||
|
||
def perform | ||
SitemapGenerator::Sitemap.default_host = "https://coderwall.com" | ||
SitemapGenerator::Sitemap.public_path = 'tmp/' | ||
SitemapGenerator::Sitemap.sitemaps_host = "http://#{ENV['FOG_DIRECTORY']}.s3.amazonaws.com/" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Don't use the cdn to servesite map. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @seuros should this use the CDN? The URL above is for the S3 I believe. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I see. Then fine, let keep it. I didn't know that heroku is RO. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. After further reading. It seem that only the bambo stack is RO. I think we have Cedar. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @seuros @just3ws I don't believe anything is persisted between dynos. From https://devcenter.heroku.com/articles/how-heroku-works: "Changes to the filesystem on one dyno are not propagated to other dynos and are not persisted across deploys and dyno restarts." Also, from https://devcenter.heroku.com/articles/dynos#isolation-and-security "Ephemeral File System": |
||
SitemapGenerator::Sitemap.sitemaps_path = 'sitemaps/' | ||
SitemapGenerator::Sitemap.adapter = SitemapGenerator::WaveAdapter.new | ||
|
||
SitemapGenerator::Sitemap.create do | ||
add '/welcome', :priority => 0.7, :changefreq => 'montlhy' | ||
add '/contact_us', :priority => 0.5, :changefreq => 'montlhy' | ||
add '/blog', :priority => 0.7, :changefreq => 'weekly' | ||
add '/api', :priority => 0.5, :changefreq => 'monthly' | ||
add '/faq', :priority => 0.5, :changefreq => 'monthly' | ||
add '/privacy_policy', :priority => 0.2, :changefreq => 'monthly' | ||
add '/tos', :priority => 0.2, :changefreq => 'monthly' | ||
add '/jobs', :priority => 0.7, :changefreq => 'daily' | ||
add '/employers', :priority => 0.7, :changefreq => 'monthly' | ||
Protip.find_each do |protip| | ||
add protip_path(protip), :lastmod => protip.updated_at | ||
end | ||
Team.all.each do |team| | ||
add teamname_path(slug: team.slug), :lastmod => team.updated_at | ||
team.jobs.each do |job| | ||
add job_path(:slug => team.slug, :job_id => job.public_id), :lastmod => job.updated_at | ||
end | ||
end | ||
User.find_each do |user| | ||
add badge_path(user.username), :lastmod => user.updated_at | ||
end | ||
BlogPost.all_public.each do |blog_post| | ||
add blog_post_path(blog_post.id), :lastmod => blog_post.posted | ||
end | ||
end | ||
SitemapGenerator::Sitemap.ping_search_engines | ||
end | ||
end |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,3 +6,4 @@ | |
|
||
User-agent: EasouSpider | ||
Disallow: / | ||
Sitemap: https://coderwall-assets-0.s3.amazonaws.com/sitemaps/sitemap.xml.gz |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
tmp ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@seuros /tmp is recommend here for heroku to temporarily store files before uploading to s3 https://github.com/kjvarga/sitemap_generator/wiki/Generate-Sitemaps-on-read-only-filesystems-like-Heroku