* Move app_domain from env var to siteconfig *within app area* * Fix SiteConfig * Don't change URL.domain yet * Not use in fastly cache purge yet * Session store magoo * Revert domain issue * Add SetCookie middleware * Temporarily remove cookie middleware and release tasks * Re-enable SetCookieDomain * Add some more comments, get it ready for testing * Remove host from url options and temporarily show errors * Allow forwarded host to be cookie * Fix typo * Change invalidAuthenticityToken * Properly set app domain * Proper Fastly cache * Remove config.app_domain * Remove config.app_domain * Explicitely set remember_user_token * More play with cookies * Fiddle with remember_user_token * Add remember_user_token changes * Monkeypatch devise * Sessions controller * Include rememberable * Include rememberable * Proper cookie monkeypatch * Proper cookie monkeypatch * Proper cookie monkeypatch * Remove extra cookie code * User sign in tweak * Close the loop * Experiment with carrierwave public_url * Finalize carrierwave monkeypatch * Remove async controller specs * Change some tests * Update domain test * Remove temporary production.rb change * modify cookie logic * Remove unneeded changes * Remove unneeded changes * Explicitely pass host * Fix linting * Fix social image test * Add some cookie tests * Modify article url * Fix canonical urls * Fix typo * Remove sessions controller * Remove devise monkeypatch * Add monkeypatch * Remove elsif * Update spec/helpers/application_helper_spec.rb Co-authored-by: Michael Kohl <citizen428@dev.to> * Adjust remember_cookie_sync * Remember user token experimentation * Fiddle with devise * Properly configure devise * Fix typo * Fix formatting issue * Add comment about middleware * Fix typo Co-authored-by: Vaidehi Joshi <vaidehi.sj@gmail.com> * Remove commented-out code Co-authored-by: Michael Kohl <citizen428@dev.to> Co-authored-by: Vaidehi Joshi <vaidehi.sj@gmail.com>
48 lines
2.2 KiB
Ruby
48 lines
2.2 KiB
Ruby
require "sitemap_generator/s3_adapter"
|
|
|
|
# @forem/systems: It's fine if this doesn't 100% work correctly right now, as long as it doesn't break stuff at runtime.
|
|
|
|
if Rails.env.production?
|
|
region = ApplicationConfig["AWS_UPLOAD_REGION"].presence || ApplicationConfig["AWS_DEFAULT_REGION"]
|
|
config_hash = if ENV["FOREM_CONTEXT"] == "forem_cloud" # @forem/systems jdoss's special sauce.
|
|
# Excluding the aws_access_key_id and aws_secret_access_key causes use_iam_profile
|
|
# to be set to true by the S3Adapter
|
|
# https://github.com/kjvarga/sitemap_generator/blob/0b847f1e7a544ea8ef87bb643a732e30a07a14c9/lib/sitemap_generator/adapters/s3_adapter.rb#L39
|
|
{
|
|
fog_provider: "AWS",
|
|
fog_directory: ApplicationConfig["AWS_BUCKET_NAME"],
|
|
fog_region: "us-east-2",
|
|
fog_public: false
|
|
}
|
|
else
|
|
{
|
|
fog_provider: "AWS",
|
|
aws_access_key_id: ApplicationConfig["AWS_ID"],
|
|
aws_secret_access_key: ApplicationConfig["AWS_SECRET"],
|
|
fog_directory: ApplicationConfig["AWS_BUCKET_NAME"],
|
|
fog_region: region
|
|
}
|
|
end
|
|
|
|
SitemapGenerator::Sitemap.adapter = SitemapGenerator::S3Adapter.new(config_hash)
|
|
SitemapGenerator::Sitemap.sitemaps_host = "https://#{ApplicationConfig['AWS_BUCKET_NAME']}.s3.amazonaws.com/"
|
|
SitemapGenerator::Sitemap.public_path = "tmp/"
|
|
SitemapGenerator::Sitemap.sitemaps_path = "sitemaps/"
|
|
end
|
|
|
|
SitemapGenerator::Sitemap.default_host = "#{ApplicationConfig['APP_PROTOCOL']}#{ApplicationConfig['APP_DOMAIN']}"
|
|
|
|
SitemapGenerator::Sitemap.create do
|
|
Article.published.where("score > ? OR featured = ?", 12, true)
|
|
.limit(38_000).find_each do |article|
|
|
add article.path, lastmod: article.last_comment_at, changefreq: "daily"
|
|
end
|
|
|
|
User.order(comments_count: :desc).where("updated_at > ?", 5.days.ago).limit(8000).find_each do |user|
|
|
add "/#{user.username}", changefreq: "daily"
|
|
end
|
|
|
|
Tag.order(hotness_score: :desc).limit(250).find_each do |tag|
|
|
add "/t/#{tag.name}", changefreq: "daily"
|
|
end
|
|
end
|