monologue 0.1.3 → 0.2.0.beta3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/README.md +29 -21
- data/app/assets/javascripts/monologue/blog/twitter.js.coffee +32 -0
- data/app/assets/stylesheets/monologue/blog/application.css +3 -3
- data/app/assets/stylesheets/monologue/blog/monologue.css +150 -7
- data/app/controllers/monologue/admin/cache_controller.rb +27 -0
- data/app/controllers/monologue/admin/posts_controller.rb +28 -12
- data/app/controllers/monologue/admin/sessions_controller.rb +2 -2
- data/app/controllers/monologue/admin/users_controller.rb +13 -0
- data/app/controllers/monologue/application_controller.rb +22 -6
- data/app/controllers/monologue/posts_controller.rb +7 -7
- data/app/controllers/monologue/tags_controller.rb +12 -0
- data/app/helpers/monologue/application_helper.rb +76 -0
- data/app/helpers/monologue/tags_helper.rb +5 -0
- data/app/models/monologue/post.rb +43 -29
- data/app/models/monologue/posts_revision.rb +50 -52
- data/app/models/monologue/tag.rb +16 -0
- data/app/models/monologue/tagging.rb +4 -0
- data/app/models/monologue/user.rb +1 -0
- data/app/sweepers/monologue/posts_sweeper.rb +20 -4
- data/app/sweepers/monologue/total_sweeper.rb +5 -0
- data/app/views/layouts/monologue/admin/_nav_bar.html.erb +17 -6
- data/app/views/layouts/monologue/application.html.erb +15 -20
- data/app/views/layouts/monologue/application/_disqus.html.erb +18 -0
- data/app/views/layouts/monologue/application/_disqus_embed.html.erb +17 -0
- data/app/views/layouts/monologue/application/_fb_open_graph.html.erb +4 -1
- data/app/views/layouts/monologue/application/_gauge_analytics.html.erb +15 -0
- data/app/views/layouts/monologue/application/_google_analytics.html.erb +1 -1
- data/app/views/layouts/monologue/application/_head.html.erb +3 -2
- data/app/views/layouts/monologue/application/_sidebar.html.erb +5 -0
- data/app/views/layouts/monologue/application/_social_icons.html.erb +5 -0
- data/app/views/layouts/monologue/application/_twitter_cards.html.erb +7 -0
- data/app/views/monologue/admin/cache/_config.html.erb +18 -0
- data/app/views/monologue/admin/cache/how_to_enable.html.erb +6 -0
- data/app/views/monologue/admin/cache/show.html.erb +26 -0
- data/app/views/monologue/admin/posts/_form.html.erb +3 -2
- data/app/views/monologue/admin/posts/edit.html.erb +1 -1
- data/app/views/monologue/admin/posts/index.html.erb +1 -1
- data/app/views/monologue/admin/users/edit.html.erb +9 -0
- data/app/views/monologue/posts/_post.html.erb +14 -0
- data/app/views/monologue/posts/_revision_header.html.erb +9 -0
- data/app/views/monologue/posts/_social_sharing.html.erb +45 -36
- data/app/views/monologue/posts/index.html.erb +4 -17
- data/app/views/monologue/posts/show.html.erb +11 -24
- data/app/views/monologue/sidebar/_categories.html.erb +7 -0
- data/app/views/monologue/sidebar/_latest_posts.html.erb +7 -0
- data/app/views/monologue/sidebar/_latest_tweets.html.erb +8 -0
- data/app/views/monologue/sidebar/_tag_cloud.html.erb +5 -0
- data/app/views/monologue/tags/_tag.html.erb +1 -0
- data/app/views/monologue/tags/show.html.erb +4 -0
- data/config/locales/en.yml +54 -10
- data/config/locales/fr.yml +55 -11
- data/config/routes.rb +8 -2
- data/db/migrate/20120514164158_create_monologue_tags.rb +8 -0
- data/db/migrate/20120514194459_join_posts_and_tags.rb +7 -0
- data/db/migrate/20120604010152_rename_post_tags_table.rb +5 -0
- data/db/migrate/20120612013442_create_taggings.rb +11 -0
- data/db/migrate/20120612015727_delete_join_posts_tags.rb +11 -0
- data/db/migrate/20120612020023_add_index_to_tag_name.rb +5 -0
- data/deprecations.rb +10 -0
- data/lib/monologue.rb +20 -1
- data/lib/monologue/engine.rb +12 -1
- data/lib/monologue/version.rb +1 -1
- data/lib/tasks/monologue_cache.rake +26 -0
- data/vendor/assets/fonts/monologue/foundation_icons/social_foundicons.eot +0 -0
- data/vendor/assets/fonts/monologue/foundation_icons/social_foundicons.svg +15 -0
- data/vendor/assets/fonts/monologue/foundation_icons/social_foundicons.ttf +0 -0
- data/vendor/assets/fonts/monologue/foundation_icons/social_foundicons.woff +0 -0
- data/vendor/assets/javascripts/monologue/bootstrap/bootstrap.min.js +6 -1
- data/vendor/assets/stylesheets/monologue/bootstrap/bootstrap-responsive.min.css +9 -3
- data/vendor/assets/stylesheets/monologue/bootstrap/bootstrap.min.css +9 -610
- data/vendor/assets/stylesheets/monologue/foundation_icons/social_foundicons.css.erb +148 -0
- metadata +109 -10
- data/app/helpers/monologue/admin/admin_helper.rb +0 -4
- data/app/helpers/monologue/posts_helper.rb +0 -4
- data/app/helpers/monologue/sessions_helper.rb +0 -6
- data/lib/tasks/monologue_tasks.rake +0 -4
@@ -0,0 +1,13 @@
|
|
1
|
+
class Monologue::Admin::UsersController < Monologue::Admin::BaseController
|
2
|
+
def edit
|
3
|
+
@user = current_user
|
4
|
+
end
|
5
|
+
|
6
|
+
def update
|
7
|
+
@user = current_user
|
8
|
+
if @user.update_attributes(params[:user])
|
9
|
+
flash.notice = "User modified"
|
10
|
+
end
|
11
|
+
render :edit
|
12
|
+
end
|
13
|
+
end
|
@@ -1,7 +1,20 @@
|
|
1
1
|
class Monologue::ApplicationController < ApplicationController
|
2
|
-
|
2
|
+
|
3
3
|
layout Monologue.layout if Monologue.layout # TODO: find a way to test that. It was asked in issue #54 (https://github.com/jipiboily/monologue/issues/54)
|
4
4
|
|
5
|
+
before_filter :recent_posts, :all_tags
|
6
|
+
|
7
|
+
def recent_posts
|
8
|
+
@recent_posts = Monologue::Post.published.limit(3)
|
9
|
+
end
|
10
|
+
|
11
|
+
def all_tags
|
12
|
+
@tags = Monologue::Tag.all(:order => "name").select{|t| t.frequency>0}
|
13
|
+
#could use minmax here but it's only supported with ruby > 1.9'
|
14
|
+
@tags_frequency_min = @tags.map{|t| t.frequency}.min
|
15
|
+
@tags_frequency_max = @tags.map{|t| t.frequency}.max
|
16
|
+
end
|
17
|
+
|
5
18
|
def not_found
|
6
19
|
# fallback to the default 404.html page from main_app.
|
7
20
|
file = Rails.root.join('public', '404.html')
|
@@ -12,13 +25,16 @@ class Monologue::ApplicationController < ApplicationController
|
|
12
25
|
render :action => "404", :status => 404, :formats => [:html]
|
13
26
|
end
|
14
27
|
end
|
15
|
-
|
16
|
-
|
28
|
+
|
17
29
|
private
|
18
30
|
|
19
31
|
def current_user
|
20
|
-
@
|
32
|
+
@monologue_current_user ||= Monologue::User.find(session[:monologue_user_id]) if session[:monologue_user_id]
|
21
33
|
end
|
22
|
-
|
23
|
-
|
34
|
+
|
35
|
+
def monologue_page_cache_enabled?
|
36
|
+
current_user.nil? && Monologue::PageCache.enabled
|
37
|
+
end
|
38
|
+
|
39
|
+
helper_method :current_user, :monologue_page_cache_enabled?
|
24
40
|
end
|
@@ -1,24 +1,24 @@
|
|
1
1
|
class Monologue::PostsController < Monologue::ApplicationController
|
2
|
-
caches_page :index, :show, :feed , :if => Proc.new {
|
2
|
+
caches_page :index, :show, :feed , :if => Proc.new { monologue_page_cache_enabled? }
|
3
3
|
|
4
4
|
def index
|
5
5
|
@page = params[:page].nil? ? 1 : params[:page]
|
6
6
|
@posts = Monologue::Post.published.page(@page)
|
7
7
|
end
|
8
|
-
|
8
|
+
|
9
9
|
def show
|
10
|
-
|
11
|
-
post = Monologue::Post.published.where("monologue_posts_revisions.url = :url", {:url => params[:post_url]}).first
|
12
|
-
else
|
10
|
+
if current_user
|
13
11
|
post = Monologue::Post.default.where("monologue_posts_revisions.url = :url", {:url => params[:post_url]}).first
|
12
|
+
else
|
13
|
+
post = Monologue::Post.published.where("monologue_posts_revisions.url = :url", {:url => params[:post_url]}).first
|
14
14
|
end
|
15
15
|
if post.nil?
|
16
16
|
not_found
|
17
17
|
return
|
18
18
|
end
|
19
|
-
@revision = post.
|
19
|
+
@revision = post.active_revision
|
20
20
|
end
|
21
|
-
|
21
|
+
|
22
22
|
def feed
|
23
23
|
@posts = Monologue::Post.published.limit(25)
|
24
24
|
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
class Monologue::TagsController < Monologue::ApplicationController
|
2
|
+
caches_page :show , :if => Proc.new { monologue_page_cache_enabled? }
|
3
|
+
def show
|
4
|
+
@tag = Monologue::Tag.find_by_name(params[:tag])
|
5
|
+
if @tag
|
6
|
+
@page = nil
|
7
|
+
@posts = @tag.posts_with_tag
|
8
|
+
else
|
9
|
+
redirect_to :root ,:notice => "No post found with label \"#{params[:tag]}\""
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
@@ -1,5 +1,9 @@
|
|
1
1
|
module Monologue
|
2
2
|
module ApplicationHelper
|
3
|
+
include Monologue::Engine.routes.url_helpers if ENV["RAILS_ENV"] == "test" # TODO: try and see why this is needed for specs to pass
|
4
|
+
#Number of sizes defined in the css
|
5
|
+
NUMBER_OF_LABEL_SIZES = 5
|
6
|
+
|
3
7
|
def monologue_admin_form_for(object, options = {}, &block)
|
4
8
|
options[:builder] = MonologueAdminFormBuilder
|
5
9
|
form_for(object, options, &block)
|
@@ -8,5 +12,77 @@ module Monologue
|
|
8
12
|
def monologue_accurate_title
|
9
13
|
content_for?(:title) ? ((content_for :title) + " | #{Monologue.site_name}") : Monologue.site_name
|
10
14
|
end
|
15
|
+
|
16
|
+
def sidebar_section_for(title, &block)
|
17
|
+
content_tag(:section, :class => 'widget') do
|
18
|
+
content_tag(:header, content_tag(:h1, title)) +
|
19
|
+
capture(&block)
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
def rss_head_link
|
24
|
+
tag("link", :href => feed_url, :rel => "alternate", :title => "RSS", :type => "application/rss+xml")
|
25
|
+
end
|
26
|
+
|
27
|
+
def rss_icon
|
28
|
+
social_icon("rss", feed_url, Monologue.show_rss_icon)
|
29
|
+
end
|
30
|
+
|
31
|
+
def github_icon
|
32
|
+
social_icon("github", "http://github.com/#{Monologue.github_username}", Monologue.github_username)
|
33
|
+
end
|
34
|
+
|
35
|
+
def twitter_icon
|
36
|
+
social_icon("twitter", "http://twitter.com/#{Monologue.twitter_username}", Monologue.twitter_username)
|
37
|
+
end
|
38
|
+
|
39
|
+
def linkedin_icon
|
40
|
+
social_icon("linkedin", Monologue.linkedin_url, Monologue.linkedin_url)
|
41
|
+
end
|
42
|
+
|
43
|
+
def googleplus_icon
|
44
|
+
social_icon("google-plus", Monologue.google_plus_account_url, Monologue.google_plus_account_url)
|
45
|
+
end
|
46
|
+
|
47
|
+
def facebook_icon
|
48
|
+
social_icon("facebook", Monologue.facebook_url, Monologue.facebook_url)
|
49
|
+
end
|
50
|
+
|
51
|
+
def absolute_image_url(url)
|
52
|
+
return url if url.starts_with? "http"
|
53
|
+
request.protocol + request.host + url
|
54
|
+
end
|
55
|
+
|
56
|
+
# TODO: That should be move in TagHelper if I manage to get that loaded
|
57
|
+
def tag_url(tag)
|
58
|
+
"#{Monologue::Engine.routes.url_helpers.root_path}tags/#{tag.name.downcase}"
|
59
|
+
end
|
60
|
+
|
61
|
+
def label_for_tag(tag, min, max)
|
62
|
+
"label-size-#{size_for_tag(tag, min, max)}"
|
63
|
+
end
|
64
|
+
|
65
|
+
def size_for_tag(tag, min, max)
|
66
|
+
#logarithmic scaling based on the number of occurrences of each tag
|
67
|
+
if min<max && tag.frequency>0
|
68
|
+
1 + ((NUMBER_OF_LABEL_SIZES-1)*(log_distance_to_min(tag.frequency, min))/log_distance_to_min(max, min)).round
|
69
|
+
else
|
70
|
+
1
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
private
|
75
|
+
def social_icon foundicon, url, setting
|
76
|
+
return if setting.nil? || !setting
|
77
|
+
content_tag :a, :href => url, :class => "social", :target => "_blank" do
|
78
|
+
content_tag :i, :class => "foundicon-#{foundicon}" do # using an empty content tag for foundicons to appear. TODO: try to do otherwise and use only tag method
|
79
|
+
end
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
83
|
+
def log_distance_to_min(value, min)
|
84
|
+
Math.log(value)-Math.log(min)
|
85
|
+
end
|
86
|
+
|
11
87
|
end
|
12
88
|
end
|
@@ -1,40 +1,54 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
1
|
+
class Monologue::Post < ActiveRecord::Base
|
2
|
+
has_many :posts_revisions, :dependent => :destroy
|
3
|
+
has_many :taggings
|
4
|
+
has_many :tags, :through => :taggings, :dependent => :destroy
|
4
5
|
|
5
|
-
|
6
|
-
|
7
|
-
|
6
|
+
accepts_nested_attributes_for :posts_revisions
|
7
|
+
attr_writer :tag_list
|
8
|
+
attr_accessible :posts_revisions_attributes, :published, :tag_list
|
8
9
|
|
9
|
-
|
10
|
-
|
11
|
-
scope :default, includes(:posts_revisions).where("posts_revision_id = monologue_posts_revisions.id").order("published_at DESC")
|
12
|
-
scope :published, default.where(:published => true).where("published_at <= ?", DateTime.now)
|
10
|
+
scope :default, includes(:posts_revisions).where("posts_revision_id = monologue_posts_revisions.id").order("published_at DESC")
|
11
|
+
scope :published, default.where(:published => true).where("published_at <= ?", DateTime.now)
|
13
12
|
|
14
|
-
|
13
|
+
default_scope includes(:tags)
|
15
14
|
|
16
|
-
|
17
|
-
self.posts_revisions.where("post_id = ?", self.id).order("monologue_posts_revisions.updated_at DESC").offset(1).limit(1).first
|
18
|
-
end
|
15
|
+
validates :posts_revision_id, :uniqueness => true
|
19
16
|
|
20
|
-
|
21
|
-
|
22
|
-
|
17
|
+
# TODO: move that in a spec helper as it only used by tests
|
18
|
+
def just_the_revision_one_before
|
19
|
+
self.posts_revisions.where("post_id = ?", self.id).order("monologue_posts_revisions.updated_at DESC").offset(1).limit(1).first
|
20
|
+
end
|
23
21
|
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
p = (p.nil? ? 0 : p.to_i - 1)
|
28
|
-
offset = (p==0 ? 0 : p * per_page)
|
29
|
-
self.limit(per_page).offset(offset)
|
30
|
-
end
|
22
|
+
def latest_revision
|
23
|
+
self.posts_revisions.where("post_id = ?", self.id).order("monologue_posts_revisions.updated_at DESC").limit(1).first
|
24
|
+
end
|
31
25
|
|
32
|
-
|
33
|
-
|
34
|
-
|
26
|
+
def active_revision
|
27
|
+
Monologue::PostsRevision.find(self.posts_revision_id)
|
28
|
+
end
|
35
29
|
|
36
|
-
|
37
|
-
|
30
|
+
def tag!(tags)
|
31
|
+
self.tags = tags.select { |t| t.present? }.map do |tag|
|
32
|
+
tag.strip!
|
33
|
+
if tag.present?
|
34
|
+
Monologue::Tag.find_or_create_by_name(tag)
|
35
|
+
end
|
38
36
|
end
|
39
37
|
end
|
38
|
+
|
39
|
+
def self.page p
|
40
|
+
per_page = Monologue.posts_per_page || 10
|
41
|
+
set_total_pages(per_page)
|
42
|
+
p = (p.nil? ? 0 : p.to_i - 1)
|
43
|
+
offset = (p==0 ? 0 : p * per_page)
|
44
|
+
self.limit(per_page).offset(offset)
|
45
|
+
end
|
46
|
+
|
47
|
+
def self.total_pages
|
48
|
+
@number_of_pages
|
49
|
+
end
|
50
|
+
|
51
|
+
def self.set_total_pages per_page
|
52
|
+
@number_of_pages = self.count / per_page + (self.count % per_page == 0 ? 0 : 1)
|
53
|
+
end
|
40
54
|
end
|
@@ -1,63 +1,61 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
attr_accessible :title, :content, :url, :published_at
|
1
|
+
class Monologue::PostsRevision < ActiveRecord::Base
|
2
|
+
attr_accessible :title, :content, :url, :published_at
|
4
3
|
|
5
|
-
|
4
|
+
before_validation :generate_url
|
6
5
|
|
7
|
-
|
8
|
-
after_save :latest_revision_is_current
|
9
|
-
|
10
|
-
belongs_to :post
|
11
|
-
belongs_to :user
|
6
|
+
after_save :latest_revision_is_current
|
12
7
|
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
8
|
+
belongs_to :post
|
9
|
+
belongs_to :user
|
10
|
+
|
11
|
+
validates :title, :presence => true
|
12
|
+
validates :content, :presence => true
|
13
|
+
validates :url, :presence => true
|
14
|
+
validate :url_do_not_start_with_slash
|
15
|
+
validate :url_is_unique
|
16
|
+
validates :user_id, :presence => true
|
19
17
|
# validates :post_id, :presence => true # TODO: do something about this validation on the first creation of a POST
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
18
|
+
validates :published_at, :presence => true
|
19
|
+
|
20
|
+
#isn't it post concern?'
|
21
|
+
def latest_revision_is_current
|
22
|
+
#post = Monologue::Post.find(self.post_id)
|
23
|
+
self.post.posts_revision_id = self.id
|
24
|
+
self.post.save!
|
25
|
+
end
|
27
26
|
|
28
|
-
|
29
|
-
|
30
|
-
|
27
|
+
def full_url
|
28
|
+
"#{Monologue::Engine.routes.url_helpers.root_path}#{self.url}"
|
29
|
+
end
|
31
30
|
|
32
|
-
|
33
|
-
|
34
|
-
|
31
|
+
def url_do_not_start_with_slash
|
32
|
+
errors.add(:url, I18n.t("activerecord.errors.models.monologue/posts_revision.attributes.url.start_with_slash")) if self.url.start_with?("/")
|
33
|
+
end
|
35
34
|
|
36
|
-
|
37
|
-
|
38
|
-
|
35
|
+
def url_is_unique
|
36
|
+
errors.add(:url, I18n.t("activerecord.errors.models.monologue/posts_revision.attributes.url.unique")) if self.url_exists?
|
37
|
+
end
|
39
38
|
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
end
|
39
|
+
def url_exists?
|
40
|
+
if self.post_id.nil?
|
41
|
+
return Monologue::PostsRevision.where("url = ?", self.url).count > 0
|
42
|
+
else
|
43
|
+
return Monologue::PostsRevision.where("url = ? and post_id <> ?", self.url, self.post_id).count > 0
|
46
44
|
end
|
45
|
+
end
|
47
46
|
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
end
|
47
|
+
private
|
48
|
+
|
49
|
+
def generate_url
|
50
|
+
year = self.published_at.class == ActiveSupport::TimeWithZone ? self.published_at.year : DateTime.now.year
|
51
|
+
return if self.title.blank?
|
52
|
+
base_title = "#{year}/#{self.title.parameterize}"
|
53
|
+
url_empty = self.url.nil? || self.url.strip == ""
|
54
|
+
self.url = base_title if url_empty
|
55
|
+
while self.url_exists? && url_empty
|
56
|
+
i ||= 1
|
57
|
+
self.url = "#{base_title}-#{i}"
|
58
|
+
i += 1
|
61
59
|
end
|
62
|
-
|
63
|
-
end
|
60
|
+
end
|
61
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
class Monologue::Tag < ActiveRecord::Base
|
2
|
+
attr_accessible :name
|
3
|
+
|
4
|
+
validates :name, :uniqueness => true,:presence => true
|
5
|
+
has_many :taggings
|
6
|
+
has_many :posts,:through=> :taggings
|
7
|
+
|
8
|
+
def posts_with_tag
|
9
|
+
self.posts.published
|
10
|
+
end
|
11
|
+
|
12
|
+
def frequency
|
13
|
+
posts_with_tag.size
|
14
|
+
end
|
15
|
+
|
16
|
+
end
|
@@ -1,29 +1,45 @@
|
|
1
1
|
class Monologue::PostsSweeper < ActionController::Caching::Sweeper
|
2
2
|
observe Monologue::Post
|
3
3
|
|
4
|
-
|
5
4
|
def sweep(post)
|
5
|
+
if ActionController::Base.perform_caching && Monologue::PageCache.enabled && Monologue::PageCache.wipe_enabled && Monologue::PageCache.wipe_after_save && (ActionController::Base.page_cache_directory != Rails.public_path)
|
6
|
+
Monologue::TotalSweeper.wipe_all
|
7
|
+
else
|
8
|
+
sweep_for_single_post post
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
def sweep_for_single_post post
|
6
13
|
return unless post.published
|
7
14
|
root_path = Monologue::Engine.routes.url_helpers.root_path if root_path.nil? # TODO: why do I have to do this to make tests pass? There must be something much more clean to make tests pass
|
8
15
|
page_cache_directory = Rails.public_path if page_cache_directory.nil? # TODO: we should not need this either...
|
16
|
+
|
17
|
+
# post
|
9
18
|
if post.posts_revisions.count > 0
|
10
|
-
current_post_path = "#{page_cache_directory}#{post.just_the_revision_one_before.url}.html" unless post.just_the_revision_one_before.nil?
|
11
|
-
current_post_path = "#{page_cache_directory}#{post.posts_revisions.last.url}.html" if post.posts_revisions.count == 1
|
19
|
+
current_post_path = "#{page_cache_directory}#{root_path}#{post.just_the_revision_one_before.url}.html" unless post.just_the_revision_one_before.nil?
|
20
|
+
current_post_path = "#{page_cache_directory}#{root_path}#{post.posts_revisions.last.url}.html" if post.posts_revisions.count == 1
|
12
21
|
File.delete current_post_path if File.exists? current_post_path
|
13
22
|
end
|
14
23
|
|
24
|
+
# tags
|
25
|
+
tags_path = "#{page_cache_directory}#{root_path}tags"
|
26
|
+
FileUtils.rm_rf tags_path
|
27
|
+
|
28
|
+
# feed
|
15
29
|
feed_file_path = "#{page_cache_directory}#{root_path}feed.rss"
|
16
30
|
File.delete feed_file_path if File.exists? feed_file_path
|
17
31
|
|
32
|
+
# root
|
18
33
|
root_file_path = "#{page_cache_directory}#{root_path.chomp("/")}.html"
|
19
34
|
root_file_path = "#{page_cache_directory}/index.html" if root_path.chomp("/") == "" # TODO: add test for that? It would need another dummy app mounted at root...?
|
20
35
|
File.delete root_file_path if File.exists? root_file_path
|
21
36
|
|
37
|
+
# paging
|
22
38
|
FileUtils.rm_rf "#{page_cache_directory}/page" # remove pages
|
23
39
|
end
|
24
40
|
|
25
41
|
alias_method :after_create, :sweep
|
26
|
-
alias_method :after_update, :sweep
|
42
|
+
alias_method :after_update, :sweep
|
27
43
|
alias_method :after_destroy, :sweep
|
28
44
|
|
29
45
|
end
|