* 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>
52 lines
1.5 KiB
Ruby
52 lines
1.5 KiB
Ruby
module Admin
|
|
class ToolsController < Admin::ApplicationController
|
|
layout "admin"
|
|
|
|
def index; end
|
|
|
|
def bust_cache
|
|
flash[:success] = if params[:dead_link]
|
|
handle_dead_path
|
|
"#{params[:dead_link]} was successfully busted"
|
|
elsif params[:bust_user]
|
|
handle_user_cache
|
|
"User ##{params[:bust_user]} was successfully busted"
|
|
elsif params[:bust_article]
|
|
handle_article_cache
|
|
"Article ##{params[:bust_article]} was successfully busted"
|
|
end
|
|
redirect_to "/admin/tools"
|
|
rescue StandardError => e
|
|
flash[:danger] = e.message
|
|
redirect_to "/admin/tools"
|
|
end
|
|
|
|
private
|
|
|
|
def handle_dead_path
|
|
bust_link(params[:dead_link])
|
|
end
|
|
|
|
def handle_user_cache
|
|
user = User.find(params[:bust_user].to_i)
|
|
user.touch(:profile_updated_at, :last_followed_at, :last_comment_at)
|
|
bust_link(user.path)
|
|
end
|
|
|
|
def handle_article_cache
|
|
article = Article.find(params[:bust_article].to_i)
|
|
article.touch(:last_commented_at)
|
|
CacheBuster.bust_article(article)
|
|
end
|
|
|
|
def bust_link(link)
|
|
if link.starts_with?(URL.url)
|
|
link.sub!(URL.url, "")
|
|
end
|
|
CacheBuster.bust(link)
|
|
CacheBuster.bust("#{link}/")
|
|
CacheBuster.bust("#{link}?i=i")
|
|
CacheBuster.bust("#{link}/?i=i")
|
|
end
|
|
end
|
|
end
|