Sha256: bb038a9909e3cff74c22f93bef21ab51aa03e086d348a631c8d68262a3a433ad

Contents?: true

Size: 1.02 KB

Versions: 15

Compression:

Stored size: 1.02 KB

Contents

#
# 01purge_cache.rb: trigger purging caches by update diary or comment
#
# Copyright (C) 2020, TADA Tadashi <t@tdtds.jp>
# SPDX-License-Identifier: GPL-2.0-or-later
#
# usage: 
#   add_purge_cache_proc do |pages|
#      pages.each do |page|
#         purge_cache_on_a_cdn(base_url + page)
#      end
#   end
#
@purge_cache_procs = []

def add_purge_cache_proc(&proc)
	@purge_cache_procs << proc
end

add_update_proc do
	unless @purge_cache_procs.empty?
		@purge_cache_procs.empty?
		date = @date.strftime('%Y%m%d')
		days = @diaries.keys.sort
		diary = @diaries[date]
		categories = []
		diary.each_section do |section|
			categories += section.categories
		end
		pages = [
			anchor("#{@date.strftime('%Y%m%d')}"),
			anchor("#{@date.strftime('%m%d')}"),
			anchor("#{@date.strftime('%Y%m')}"),
			(0...@conf.latest_limit).map{|i|
				days[days.index(date)+i]
			}.compact.map{|day|
				anchor("#{day}-#{@conf.latest_limit}")
			},
			categories.map{|c| "?category=#{c}"}
		].flatten
		@purge_cache_procs.each{|proc| proc.call(pages)}
	end
end

Version data entries

15 entries across 12 versions & 1 rubygems

Version Path
tdiary-5.3.0 lib/tdiary/plugin/03purge_cache.rb
tdiary-5.2.4 lib/tdiary/plugin/03purge_cache.rb
tdiary-5.2.3 lib/tdiary/plugin/03purge_cache.rb
tdiary-5.2.2 lib/tdiary/plugin/03purge_cache.rb
tdiary-5.2.1 lib/tdiary/plugin/03purge_cache.rb
tdiary-5.2.0 lib/tdiary/plugin/03purge_cache.rb
tdiary-5.1.7 lib/tdiary/plugin/03purge_cache.rb
tdiary-5.1.6 vendor/bundle/ruby/2.7.0/gems/tdiary-5.1.5/vendor/bundle/ruby/3.0.0/gems/tdiary-5.1.4/lib/tdiary/plugin/03purge_cache.rb
tdiary-5.1.6 vendor/bundle/ruby/2.7.0/gems/tdiary-5.1.5/lib/tdiary/plugin/03purge_cache.rb
tdiary-5.1.6 lib/tdiary/plugin/03purge_cache.rb
tdiary-5.1.5 vendor/bundle/ruby/3.0.0/gems/tdiary-5.1.4/lib/tdiary/plugin/03purge_cache.rb
tdiary-5.1.5 lib/tdiary/plugin/03purge_cache.rb
tdiary-5.1.4 lib/tdiary/plugin/03purge_cache.rb
tdiary-5.1.3 lib/tdiary/plugin/03purge_cache.rb
tdiary-5.1.2 lib/tdiary/plugin/03purge_cache.rb