adva_blog 0.0.1 → 0.2.0
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.
- checksums.yaml +5 -5
- data/app/controllers/admin/blog/contents_controller.rb +1 -1
- data/app/controllers/blog_articles_controller.rb +10 -14
- data/app/helpers/blog_helper.rb +6 -6
- data/app/models/blog.rb +2 -2
- data/app/views/admin/blog/articles/index.html.erb +6 -20
- data/app/views/admin/sections/settings/_blog.html.erb +1 -5
- data/app/views/blogs/articles/_article.html.erb +6 -5
- data/app/views/blogs/articles/_footer.html.erb +5 -7
- data/app/views/blogs/articles/index.atom.builder +1 -1
- data/config/initializers/base_controller.rb +1 -1
- data/config/routes.rb +4 -6
- data/lib/adva_blog/version.rb +1 -1
- data/lib/adva_blog.rb +5 -1
- metadata +3 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 85b9f7df75c4a48ce6dc3ab8e567a49f4b0d65e042f7e59f1ab204f626416c03
|
4
|
+
data.tar.gz: 37e7e41f62a13b73d3b0db962c5571e4b8b4a9fe4efee004439afeb5bd678a88
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3b55484db019345e339206c2bcc29c2daa65f3c326079cb369f06d4de76d5dd9d4c90e8411fab63e7be8e542966dab5cd2d0694f33dfa023225164294295e032
|
7
|
+
data.tar.gz: d75ed39340ccf5ed1fca04a7542b40b1586b03f1a9a6fb085d23925ca557a76bc25bd5791982eddeb6ee83ca50eeed11ffb087aa6b16968ae5c3ec0b541c266f
|
@@ -1,23 +1,19 @@
|
|
1
1
|
class BlogArticlesController < ArticlesController
|
2
2
|
def index
|
3
|
-
|
3
|
+
articles
|
4
|
+
|
5
|
+
if defined?(Comment)
|
6
|
+
articles.includes!(:approved_comments_counter)
|
7
|
+
end
|
8
|
+
|
9
|
+
# set after articles are fetched
|
10
|
+
@category ||= section.categories.build(title: "All Categories")
|
11
|
+
|
12
|
+
if skip_caching? or stale?([site, section], public: true)
|
4
13
|
respond_to do |format|
|
5
14
|
format.html { render :template => "blogs/articles/index" }
|
6
15
|
format.atom { render :template => "blogs/articles/index", :layout => false }
|
7
16
|
end
|
8
17
|
end
|
9
18
|
end
|
10
|
-
|
11
|
-
protected
|
12
|
-
def set_articles
|
13
|
-
scope = @category ? @category.all_contents : @section.articles
|
14
|
-
scope = scope.tagged("'#{@tags}'") if @tags.present?
|
15
|
-
scope = scope.published # (params[:year], params[:month])
|
16
|
-
scope = scope.includes(:approved_comments_counter) if defined?(Comment)
|
17
|
-
@articles = scope.paginate(page: current_page, per_page: @section.contents_per_page).order(published_at: :desc)
|
18
|
-
end
|
19
|
-
|
20
|
-
def valid_article?
|
21
|
-
@article and (@article.draft? or @article.published_at?(params.values_at(:year, :month, :day)))
|
22
|
-
end
|
23
19
|
end
|
data/app/helpers/blog_helper.rb
CHANGED
@@ -5,12 +5,12 @@ module BlogHelper
|
|
5
5
|
month = archive_month(month) if month && !month.is_a?(Time)
|
6
6
|
|
7
7
|
title = []
|
8
|
-
title <<
|
9
|
-
title <<
|
10
|
-
title <<
|
8
|
+
title << "from #{month.strftime('%B %Y')}" if month
|
9
|
+
title << "about #{category.title}" if category
|
10
|
+
title << "tagged #{tags.to_sentence}" if tags
|
11
11
|
|
12
12
|
if title.present?
|
13
|
-
title =
|
13
|
+
title = "Articles #{title.join(', ')}"
|
14
14
|
options[:format] ? raw(options[:format]) % title : title
|
15
15
|
end
|
16
16
|
end
|
@@ -19,7 +19,7 @@ module BlogHelper
|
|
19
19
|
Time.local(params[:year], params[:month]) if params[:year]
|
20
20
|
end
|
21
21
|
|
22
|
-
def blog_article_path section, article
|
22
|
+
def blog_article_path section, article, options={}
|
23
23
|
if article.published_at
|
24
24
|
super :section_permalink => section.permalink,
|
25
25
|
:year => article.published_at.year,
|
@@ -31,7 +31,7 @@ module BlogHelper
|
|
31
31
|
end
|
32
32
|
end
|
33
33
|
|
34
|
-
def blog_article_url section, article
|
34
|
+
def blog_article_url section, article, options={}
|
35
35
|
if article.published_at
|
36
36
|
super :section_permalink => section.permalink,
|
37
37
|
:year => article.published_at.year,
|
data/app/models/blog.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
class Blog < Section
|
2
|
-
has_many :articles, -> { order("contents.published_at DESC") }, :
|
2
|
+
has_many :articles, -> { order("contents.published_at DESC") }, foreign_key: :section_id, dependent: :destroy do
|
3
3
|
def permalinks
|
4
|
-
published.
|
4
|
+
published.pluck(:permalink)
|
5
5
|
end
|
6
6
|
end
|
7
7
|
alias_method :contents, :articles
|
@@ -9,32 +9,18 @@
|
|
9
9
|
|
10
10
|
t.row do |r, content|
|
11
11
|
r.add_class "level_#{content.level}"
|
12
|
-
r.cell content_status(content) + link_to(content.title, [:edit, :admin, @
|
12
|
+
r.cell content_status(content) + " " + link_to(content.title, [:edit, :admin, @section, content], :class => content.state)
|
13
13
|
r.cell content.category_titles.join(", ") if @section.categories.any?
|
14
|
-
r.cell content.accept_comments? && content.comments.present? ? link_to(content.comments.size, admin_comments_path) :
|
14
|
+
r.cell content.accept_comments? && content.comments.present? ? link_to(content.comments.size, admin_comments_path) : "none" if defined?(Comment)
|
15
15
|
r.cell published_at_formatted(content)
|
16
|
-
r.cell link_to("Edit", [:edit, :admin, @
|
17
|
-
link_to("Delete", [:admin, @
|
16
|
+
r.cell link_to("Edit", [:edit, :admin, @section, content], :class => "edit content") +
|
17
|
+
link_to("Delete", [:admin, @section, content], :method => :delete, :class => "delete content")
|
18
18
|
end
|
19
19
|
|
20
20
|
t.empty :p, :class => 'empty' do
|
21
|
-
raw
|
22
|
-
|
23
|
-
t(:'adva.contents.no_contents', :section => @section.title) + "\n" +
|
24
|
-
link_to(t(:'adva.contents.links.create_now'), [:new, :admin, @site, @section, :article])
|
21
|
+
raw "There are no contents in #{@section.title}. " +
|
22
|
+
link_to("Create one now", [:new, :admin, @section, :article])
|
25
23
|
end
|
26
24
|
end
|
27
25
|
%>
|
28
26
|
|
29
|
-
<%= content_for :sidebar do -%>
|
30
|
-
<!--
|
31
|
-
<div class="tabs">
|
32
|
-
<ul>
|
33
|
-
<li class="active"><a href="#filters" onclick="return false;">Filters</a></li>
|
34
|
-
</ul>
|
35
|
-
<div class="tab active" id="tab_filters">
|
36
|
-
<%= filter_for(Article, :categories => @section.categories) %>
|
37
|
-
</div>
|
38
|
-
</div>
|
39
|
-
-->
|
40
|
-
<% end -%>
|
@@ -1,11 +1,7 @@
|
|
1
|
-
<h2
|
1
|
+
<h2>Blog settings</h2>
|
2
2
|
|
3
3
|
<% f.field_set :blog_settings do %>
|
4
4
|
<div class="col">
|
5
5
|
<%= f.text_field :contents_per_page, :label => true %>
|
6
6
|
</div>
|
7
|
-
|
8
|
-
<div class="col">
|
9
|
-
<%= f.select :content_filter, filter_options, {}, :label => true, :hint => :'adva.sections.hints.content_filter' %>
|
10
|
-
</div>
|
11
7
|
<% end %>
|
@@ -3,15 +3,15 @@
|
|
3
3
|
<div class="meta">
|
4
4
|
<p>
|
5
5
|
<%= datetime_with_microformat(article.published_at, :format => :long) %><br />
|
6
|
-
|
6
|
+
by: <%= article.author_name %>
|
7
7
|
<%= link_to_content_comments article if (defined?(Comment) && (article.accept_comments? || article.comments.present?)) && mode != :single %>
|
8
8
|
<% authorized_tag :span, :update, article do -%>
|
9
|
-
<%= link_to
|
9
|
+
<%= link_to "Edit", edit_admin_article_path(@section, article) %>
|
10
10
|
<% end -%>
|
11
11
|
</p>
|
12
12
|
<p>
|
13
|
-
<%= links_to_content_categories article
|
14
|
-
<%= links_to_content_tags article
|
13
|
+
<%= links_to_content_categories article %>
|
14
|
+
<%= links_to_content_tags article %>
|
15
15
|
</p>
|
16
16
|
</div>
|
17
17
|
<div class="content">
|
@@ -20,7 +20,8 @@
|
|
20
20
|
</h2>
|
21
21
|
<% if article.has_excerpt? %>
|
22
22
|
<%= raw article.excerpt_html %>
|
23
|
-
<p><%= link_to_content
|
23
|
+
<p><%= link_to_content "Read the rest of this entry", article unless mode == :single %></p>
|
24
|
+
|
24
25
|
<% end %>
|
25
26
|
<%= raw article.body_html if mode == :single || !article.has_excerpt? %>
|
26
27
|
</div>
|
@@ -1,8 +1,8 @@
|
|
1
1
|
<% content_for :footer do %>
|
2
2
|
<div id="footer" class="clearing">
|
3
|
-
<% if @section.categories.
|
3
|
+
<% if @section.categories.select(&:persisted?).any? %>
|
4
4
|
<div>
|
5
|
-
<h4
|
5
|
+
<h4>Categories</h4>
|
6
6
|
<ul id="categories_list">
|
7
7
|
<% @section.categories.each do |category| %>
|
8
8
|
<li><%= link_to_category @section, category %></li>
|
@@ -13,7 +13,7 @@
|
|
13
13
|
|
14
14
|
<% if @section.article_counts_by_month.present? %>
|
15
15
|
<div>
|
16
|
-
<h4
|
16
|
+
<h4>Archives</h4>
|
17
17
|
<ul id="archives">
|
18
18
|
<% @section.archive_months.each do |month| %>
|
19
19
|
<li><%= link_to l( month, :format => '%B %Y' ), blog_path(@section, :year => month.year, :month => month.month) %></li>
|
@@ -23,7 +23,7 @@
|
|
23
23
|
<% end %>
|
24
24
|
|
25
25
|
<% if false and @section and @section.tag_counts.present? %>
|
26
|
-
<h4
|
26
|
+
<h4>Tags</h4>
|
27
27
|
<ul id="tags_list">
|
28
28
|
<% @section.tag_counts.each do |tag| %>
|
29
29
|
<li><%= link_to_tag @section, tag %></li>
|
@@ -32,9 +32,7 @@
|
|
32
32
|
<% end %>
|
33
33
|
</div>
|
34
34
|
|
35
|
-
<%= render :partial => 'shared/footer' %>
|
36
|
-
|
37
35
|
<ul id="feeds">
|
38
|
-
<li><%= link_to
|
36
|
+
<li><%= link_to "Entries feed", blog_url(@section, :format => :atom) %></li>
|
39
37
|
</ul>
|
40
38
|
<% end %>
|
@@ -8,7 +8,7 @@ atom_feed :url => request.url do |feed|
|
|
8
8
|
feed.updated @articles.first ? @articles.first.updated_at : Time.now.utc
|
9
9
|
|
10
10
|
@articles[0..12].each do |article|
|
11
|
-
url =
|
11
|
+
url = [request.protocol, @site.host, url_for([@section, article])].join("")
|
12
12
|
feed.entry article, :url => url do |entry|
|
13
13
|
entry.title article.title
|
14
14
|
entry.content "#{absolutize_links(article.excerpt_html)} #{absolutize_links(article.body_html)}", :type => 'html'
|
data/config/routes.rb
CHANGED
@@ -8,12 +8,10 @@ Rails.application.routes.draw do
|
|
8
8
|
end
|
9
9
|
|
10
10
|
namespace :admin do
|
11
|
-
resources :
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
put "/", :action => "update_all", :on => :collection
|
16
|
-
end
|
11
|
+
resources :blogs do
|
12
|
+
scope :module => :blog do
|
13
|
+
resources :contents, :articles, :categories do
|
14
|
+
put "/", :action => "update_all", :on => :collection
|
17
15
|
end
|
18
16
|
end
|
19
17
|
end
|
data/lib/adva_blog/version.rb
CHANGED
data/lib/adva_blog.rb
CHANGED
@@ -1,10 +1,14 @@
|
|
1
1
|
# require "adva_blog/version"
|
2
2
|
require "rails"
|
3
3
|
|
4
|
+
# FIXME there's gotta be a better way!
|
5
|
+
spec = Gem::Specification.find_by_name("adva")
|
6
|
+
require "#{spec.gem_dir}/app/models/section"
|
7
|
+
|
4
8
|
module AdvaBlog
|
5
9
|
class Engine < Rails::Engine
|
6
10
|
initializer "adva_blog.init" do
|
7
|
-
Section.register_type 'Blog'
|
11
|
+
::Section.register_type 'Blog'
|
8
12
|
end
|
9
13
|
end
|
10
14
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: adva_blog
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Micah Geisel
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2024-07-30 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: Adva Blog
|
14
14
|
email:
|
@@ -76,8 +76,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
76
76
|
- !ruby/object:Gem::Version
|
77
77
|
version: '0'
|
78
78
|
requirements: []
|
79
|
-
|
80
|
-
rubygems_version: 2.4.6
|
79
|
+
rubygems_version: 3.2.32
|
81
80
|
signing_key:
|
82
81
|
specification_version: 4
|
83
82
|
summary: Engine for Adva CMS blog component
|