publify_core 9.0.0.pre6 → 9.0.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 +4 -4
- data/CHANGELOG.md +44 -0
- data/README.md +9 -0
- data/app/controllers/admin/base_controller.rb +0 -6
- data/app/controllers/admin/content_controller.rb +34 -15
- data/app/controllers/admin/dashboard_controller.rb +4 -9
- data/app/controllers/admin/feedback_controller.rb +1 -0
- data/app/controllers/admin/notes_controller.rb +1 -1
- data/app/controllers/admin/pages_controller.rb +3 -7
- data/app/controllers/admin/sidebar_controller.rb +1 -0
- data/app/controllers/admin/tags_controller.rb +1 -0
- data/app/controllers/articles_controller.rb +50 -55
- data/app/controllers/comments_controller.rb +2 -3
- data/app/controllers/content_controller.rb +8 -17
- data/app/controllers/feedback_controller.rb +5 -39
- data/app/controllers/notes_controller.rb +1 -3
- data/app/controllers/setup_controller.rb +14 -18
- data/app/controllers/tags_controller.rb +13 -15
- data/app/controllers/theme_controller.rb +7 -5
- data/app/controllers/xml_controller.rb +11 -59
- data/app/helpers/authors_helper.rb +2 -2
- data/app/helpers/base_helper.rb +11 -4
- data/app/helpers/xml_helper.rb +2 -2
- data/app/jobs/application_job.rb +2 -0
- data/app/models/archives_sidebar.rb +8 -11
- data/app/models/article.rb +53 -72
- data/app/models/article/factory.rb +1 -1
- data/app/models/blog.rb +17 -40
- data/app/models/comment.rb +4 -3
- data/app/models/content.rb +18 -21
- data/app/models/content_base.rb +0 -5
- data/app/models/feedback.rb +76 -54
- data/app/models/meta_sidebar.rb +1 -0
- data/app/models/note.rb +7 -0
- data/app/models/page.rb +10 -5
- data/app/models/ping.rb +0 -113
- data/app/models/post_type.rb +1 -0
- data/app/models/redirect.rb +1 -1
- data/app/models/resource.rb +1 -19
- data/app/models/sidebar.rb +1 -1
- data/app/models/static_sidebar.rb +1 -0
- data/app/models/tag.rb +13 -9
- data/app/models/tag_sidebar.rb +4 -4
- data/app/models/trackback.rb +1 -8
- data/app/models/trigger.rb +1 -15
- data/app/models/user.rb +2 -9
- data/app/uploaders/resource_uploader.rb +33 -2
- data/app/views/accounts/confirm.html.erb +0 -1
- data/app/views/admin/content/_article_list.html.erb +1 -1
- data/app/views/admin/content/_form.html.erb +3 -7
- data/app/views/admin/pages/_form.html.erb +2 -2
- data/app/views/admin/seo/_general.html.erb +33 -28
- data/app/views/admin/seo/_permalinks.html.erb +2 -2
- data/app/views/admin/seo/_titles.html.erb +36 -36
- data/app/views/admin/settings/display.html.erb +20 -27
- data/app/views/admin/settings/feedback.html.erb +44 -51
- data/app/views/admin/settings/index.html.erb +14 -14
- data/app/views/admin/settings/write.html.erb +12 -30
- data/app/views/admin/tags/_index_and_form.html.erb +1 -1
- data/app/views/articles/_archives_article.html.erb +9 -0
- data/app/views/articles/_article.html.erb +8 -6
- data/app/views/articles/_article_collection.html.erb +1 -1
- data/app/views/articles/_article_excerpt.html.erb +10 -8
- data/app/views/articles/_article_links.html.erb +4 -2
- data/app/views/articles/_comment_list.html.erb +5 -5
- data/app/views/articles/_full_article_content.html.erb +4 -2
- data/app/views/articles/archives.html.erb +10 -20
- data/app/views/articles/feedback_atom_feed.atom.builder +5 -5
- data/app/views/articles/feedback_rss_feed.rss.builder +12 -13
- data/app/views/articles/index_atom_feed.atom.builder +3 -4
- data/app/views/articles/index_rss_feed.rss.builder +9 -10
- data/app/views/articles/read.html.erb +5 -31
- data/app/views/articles/search.html.erb +1 -1
- data/app/views/articles/trackback.xml.builder +1 -1
- data/app/views/authors/show.html.erb +11 -21
- data/app/views/authors/show_atom_feed.atom.builder +3 -4
- data/app/views/authors/show_rss_feed.rss.builder +9 -10
- data/app/views/comments/_comment.html.erb +17 -16
- data/app/views/feedback/index.atom.builder +7 -0
- data/app/views/feedback/index.rss.builder +19 -0
- data/app/views/notes/_note.html.erb +16 -15
- data/app/views/notes/index.html.erb +1 -1
- data/app/views/notification_mailer/_mail_footer.html.erb +0 -2
- data/app/views/notification_mailer/_mail_header.html.erb +2 -0
- data/app/views/notification_mailer/article.html.erb +4 -3
- data/app/views/notification_mailer/comment.html.erb +7 -6
- data/app/views/notification_mailer/notif_user.html.erb +3 -8
- data/app/views/setup/index.html.erb +4 -0
- data/app/views/shared/_atom_header.atom.builder +3 -3
- data/app/views/shared/_atom_item_article.atom.builder +26 -19
- data/app/views/shared/_atom_item_comment.atom.builder +3 -5
- data/app/views/shared/_atom_item_trackback.atom.builder +3 -4
- data/app/views/shared/_page_header.html.erb +1 -1
- data/app/views/shared/_rss_item_article.rss.builder +10 -15
- data/app/views/shared/_rss_item_comment.rss.builder +1 -2
- data/app/views/shared/_rss_item_trackback.rss.builder +1 -1
- data/app/views/tags/index.html.erb +2 -2
- data/app/views/xml/sitemap.googlesitemap.builder +7 -0
- data/config/initializers/mime_types.rb +0 -1
- data/config/locales/da.yml +8 -37
- data/config/locales/de.yml +7 -36
- data/config/locales/en.yml +7 -36
- data/config/locales/es-MX.yml +8 -37
- data/config/locales/fr.yml +7 -36
- data/config/locales/he.yml +4 -33
- data/config/locales/it.yml +7 -36
- data/config/locales/ja.yml +5 -34
- data/config/locales/lt.yml +7 -36
- data/config/locales/nb-NO.yml +7 -36
- data/config/locales/nl.yml +9 -38
- data/config/locales/pl.yml +8 -37
- data/config/locales/pt-BR.yml +8 -37
- data/config/locales/ro.yml +9 -38
- data/config/locales/ru.yml +7 -36
- data/config/locales/zh-CN.yml +6 -35
- data/config/locales/zh-TW.yml +7 -36
- data/config/routes.rb +6 -28
- data/db/migrate/113_initial_schema.rb +191 -191
- data/db/migrate/114_fixes_buggy_articles_and_notes.rb +6 -7
- data/db/migrate/115_drops_categories_for_tags.rb +3 -3
- data/db/migrate/20150207131657_add_missing_indexes.rb +1 -1
- data/db/migrate/20150807134129_simplify_redirect_relations.rb +1 -1
- data/db/migrate/20150808052637_add_blog_ids.rb +3 -5
- data/db/migrate/20150808191127_add_blog_id_to_redirects.rb +1 -1
- data/db/migrate/20150810094754_add_blog_id_to_tags.rb +1 -1
- data/db/migrate/20160108111120_add_devise_to_users.rb +3 -3
- data/db/migrate/20160108184201_move_last_connection_to_last_sign_in_at.rb +1 -1
- data/db/migrate/20160110094906_remove_profiles_rights.rb +1 -1
- data/db/migrate/20160605103918_replace_profile_id_with_string.rb +1 -3
- data/db/migrate/20160605154632_remove_profiles.rb +2 -2
- data/db/migrate/20160701061851_demand_blog_id_on_contents.rb +1 -1
- data/db/migrate/20160701062604_add_blog_id_to_resources.rb +1 -1
- data/db/migrate/20170528093024_move_resources_to_content.rb +5 -0
- data/db/migrate/20170528094923_move_tags_to_content.rb +6 -0
- data/db/migrate/20170528201606_remove_separate_published_flag.rb +5 -0
- data/db/migrate/20170605071626_remove_extra_state_columns_from_feedback.rb +6 -0
- data/db/migrate/20170702105201_remove_published_at_from_feedback.rb +5 -0
- data/db/seeds.rb +1 -1
- data/lib/publify_core.rb +0 -1
- data/lib/publify_core/version.rb +1 -1
- data/lib/publify_guid.rb +1 -1
- data/lib/publify_time.rb +2 -2
- data/lib/sidebar_field.rb +19 -12
- data/lib/transforms.rb +1 -0
- metadata +102 -66
- data/.gitignore +0 -13
- data/.rspec +0 -2
- data/.rubocop.yml +0 -84
- data/.rubocop_todo.yml +0 -148
- data/.travis.yml +0 -27
- data/Gemfile +0 -17
- data/README.rdoc +0 -3
- data/Rakefile +0 -35
- data/app/assets/stylesheets/publify_core/.keep +0 -0
- data/app/controllers/.keep +0 -0
- data/app/controllers/admin/migrations_controller.rb +0 -19
- data/app/controllers/concerns/.keep +0 -0
- data/app/controllers/trackbacks_controller.rb +0 -36
- data/app/helpers/.keep +0 -0
- data/app/mailers/.keep +0 -0
- data/app/models/.keep +0 -0
- data/app/models/article/states.rb +0 -179
- data/app/models/concerns/.keep +0 -0
- data/app/models/feedback/states.rb +0 -256
- data/app/services/migrator.rb +0 -25
- data/app/views/.keep +0 -0
- data/app/views/comments/index.html.erb +0 -1
- data/app/views/comments/index_atom_feed.atom.builder +0 -8
- data/app/views/comments/index_rss_feed.rss.builder +0 -20
- data/app/views/trackbacks/index_atom_feed.atom.builder +0 -7
- data/app/views/trackbacks/index_rss_feed.rss.builder +0 -20
- data/app/views/trackbacks/trackback.xml.builder +0 -4
- data/app/views/xml/feed.googlesitemap.builder +0 -7
- data/app/views/xml/rsd.rsd.builder +0 -8
- data/lib/stateful.rb +0 -106
- data/publify_core.gemspec +0 -54
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
class CommentsController <
|
|
1
|
+
class CommentsController < BaseController
|
|
2
2
|
before_action :get_article, only: [:create, :preview]
|
|
3
3
|
|
|
4
4
|
def create
|
|
@@ -43,7 +43,6 @@ class CommentsController < FeedbackController
|
|
|
43
43
|
def new_comment_defaults
|
|
44
44
|
{ ip: request.remote_ip,
|
|
45
45
|
author: 'Anonymous',
|
|
46
|
-
published: true,
|
|
47
46
|
user: @current_user,
|
|
48
47
|
user_agent: request.env['HTTP_USER_AGENT'],
|
|
49
48
|
referrer: request.env['HTTP_REFERER'],
|
|
@@ -53,7 +52,7 @@ class CommentsController < FeedbackController
|
|
|
53
52
|
def set_cookies_for(comment)
|
|
54
53
|
add_to_cookies(:author, comment.author)
|
|
55
54
|
add_to_cookies(:url, comment.url)
|
|
56
|
-
|
|
55
|
+
if comment.email.present?
|
|
57
56
|
add_to_cookies(:gravatar_id, Digest::MD5.hexdigest(comment.email.strip))
|
|
58
57
|
end
|
|
59
58
|
end
|
|
@@ -1,21 +1,5 @@
|
|
|
1
1
|
class ContentController < BaseController
|
|
2
|
-
|
|
3
|
-
def before(_controller)
|
|
4
|
-
@request_time = Time.now
|
|
5
|
-
end
|
|
6
|
-
|
|
7
|
-
def after(controller)
|
|
8
|
-
future_article =
|
|
9
|
-
this_blog.articles.where('published = ? AND published_at > ?', true, @request_time).
|
|
10
|
-
order('published_at ASC').first
|
|
11
|
-
if future_article
|
|
12
|
-
delta = future_article.published_at - Time.now
|
|
13
|
-
controller.response.lifetime = delta <= 0 ? 0 : delta
|
|
14
|
-
end
|
|
15
|
-
end
|
|
16
|
-
end
|
|
17
|
-
|
|
18
|
-
protected
|
|
2
|
+
private
|
|
19
3
|
|
|
20
4
|
# TODO: Make this work for all content.
|
|
21
5
|
def auto_discovery_feed(options = {})
|
|
@@ -28,4 +12,11 @@ class ContentController < BaseController
|
|
|
28
12
|
def theme_layout
|
|
29
13
|
this_blog.current_theme.layout(action_name)
|
|
30
14
|
end
|
|
15
|
+
|
|
16
|
+
def render_cached_xml(template, object)
|
|
17
|
+
feed = cache([controller_name, template, object]) do
|
|
18
|
+
render_to_string template, layout: false
|
|
19
|
+
end
|
|
20
|
+
render xml: feed
|
|
21
|
+
end
|
|
31
22
|
end
|
|
@@ -1,45 +1,11 @@
|
|
|
1
1
|
class FeedbackController < BaseController
|
|
2
|
-
before_action :get_article, only: [:create]
|
|
3
|
-
|
|
4
|
-
# Used only by comments. Maybe need move to comments controller
|
|
5
|
-
# or use it in our code with send some feed about trackback
|
|
6
|
-
#
|
|
7
|
-
# Redirect to article with good anchor with /comments?article_id=xxx ou
|
|
8
|
-
# /trackacks?article_id=xxx
|
|
9
|
-
#
|
|
10
|
-
# If no article_id params, so no page found. TODO: See all
|
|
11
|
-
# comments/trackbacks with paginate ?
|
|
12
|
-
#
|
|
13
|
-
# If /comments.rss|atom or /trabacks.atom|rss see a feed about all comments
|
|
14
|
-
# or trackback
|
|
15
|
-
#
|
|
16
|
-
# If article_id params in feed see only this comment|feedback on this
|
|
17
|
-
# article.
|
|
18
|
-
#
|
|
19
|
-
# TODO: It's usefull but use anywhere. Create some extension in xml_sidebar
|
|
20
|
-
# to define this feed.
|
|
21
2
|
def index
|
|
22
|
-
@
|
|
3
|
+
@feedback = Feedback.ham.
|
|
4
|
+
newest_first.
|
|
5
|
+
limit(this_blog.per_page(params[:format]))
|
|
23
6
|
respond_to do |format|
|
|
24
|
-
format.
|
|
25
|
-
|
|
26
|
-
article = Article.find(params[:article_id])
|
|
27
|
-
redirect_to "#{URI.parse(article.permalink_url).path}\##{@page_title.underscore}"
|
|
28
|
-
else
|
|
29
|
-
render plain: 'this space left blank'
|
|
30
|
-
end
|
|
31
|
-
end
|
|
32
|
-
feedbacks = Feedback.from(controller_name, params[:article_id]).limit(this_blog.per_page(params[:format]))
|
|
33
|
-
format.atom { render_feed 'atom', feedbacks }
|
|
34
|
-
format.rss { render_feed 'rss', feedbacks }
|
|
7
|
+
format.atom { render 'index', format: 'atom' }
|
|
8
|
+
format.rss { render 'index', format: 'rss' }
|
|
35
9
|
end
|
|
36
10
|
end
|
|
37
|
-
|
|
38
|
-
protected
|
|
39
|
-
|
|
40
|
-
def render_feed(format, collection)
|
|
41
|
-
ivar_name = "@#{self.class.to_s.sub(/Controller$/, '').underscore}"
|
|
42
|
-
instance_variable_set(ivar_name, collection)
|
|
43
|
-
render "index_#{format}_feed"
|
|
44
|
-
end
|
|
45
11
|
end
|
|
@@ -15,9 +15,7 @@ class NotesController < ContentController
|
|
|
15
15
|
end
|
|
16
16
|
|
|
17
17
|
def show
|
|
18
|
-
@note = Note.published.find_by permalink: CGI.escape(params[:permalink])
|
|
19
|
-
|
|
20
|
-
return render 'errors/404', status: 404 unless @note
|
|
18
|
+
@note = Note.published.find_by! permalink: CGI.escape(params[:permalink])
|
|
21
19
|
|
|
22
20
|
if @note.in_reply_to_message.present?
|
|
23
21
|
@reply = JSON.parse(@note.in_reply_to_message)
|
|
@@ -1,30 +1,25 @@
|
|
|
1
1
|
class SetupController < BaseController
|
|
2
|
-
before_action :check_config
|
|
2
|
+
before_action :check_config
|
|
3
3
|
layout 'accounts'
|
|
4
4
|
|
|
5
5
|
def index
|
|
6
|
-
|
|
6
|
+
end
|
|
7
7
|
|
|
8
|
+
def create
|
|
8
9
|
this_blog.blog_name = params[:setting][:blog_name]
|
|
9
10
|
this_blog.base_url = blog_base_url
|
|
10
11
|
|
|
11
12
|
@user = User.new(login: 'admin',
|
|
12
13
|
email: params[:setting][:email],
|
|
14
|
+
password: params[:setting][:password],
|
|
13
15
|
nickname: 'Publify Admin')
|
|
14
|
-
@user.generate_password!
|
|
15
16
|
@user.name = @user.login
|
|
16
17
|
|
|
17
|
-
unless this_blog.
|
|
18
|
+
unless this_blog.save && @user.save
|
|
18
19
|
redirect_to setup_url
|
|
19
20
|
return
|
|
20
21
|
end
|
|
21
22
|
|
|
22
|
-
return unless this_blog.save
|
|
23
|
-
|
|
24
|
-
session[:tmppass] = @user.password
|
|
25
|
-
|
|
26
|
-
return unless @user.save
|
|
27
|
-
|
|
28
23
|
sign_in @user
|
|
29
24
|
|
|
30
25
|
if User.count == 1
|
|
@@ -32,24 +27,25 @@ class SetupController < BaseController
|
|
|
32
27
|
create_first_page @user
|
|
33
28
|
end
|
|
34
29
|
|
|
30
|
+
EmailNotify.send_user_create_notification(@user)
|
|
31
|
+
|
|
35
32
|
redirect_to confirm_accounts_url
|
|
36
33
|
end
|
|
37
34
|
|
|
38
35
|
private
|
|
39
36
|
|
|
40
37
|
def create_first_post(user)
|
|
41
|
-
this_blog.articles.
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
user: user)
|
|
38
|
+
this_blog.articles.build(title: I18n.t('setup.article.title'),
|
|
39
|
+
author: user.login,
|
|
40
|
+
body: I18n.t('setup.article.body'),
|
|
41
|
+
allow_comments: 1,
|
|
42
|
+
allow_pings: 1,
|
|
43
|
+
user: user).publish!
|
|
48
44
|
end
|
|
49
45
|
|
|
50
46
|
def create_first_page(user)
|
|
51
47
|
this_blog.pages.create(name: 'about',
|
|
52
|
-
|
|
48
|
+
state: 'published',
|
|
53
49
|
title: I18n.t('setup.page.about'),
|
|
54
50
|
user: user,
|
|
55
51
|
body: I18n.t('setup.page.body'))
|
|
@@ -6,38 +6,36 @@ class TagsController < ContentController
|
|
|
6
6
|
@tags = Tag.page(params[:page]).per(100)
|
|
7
7
|
@page_title = controller_name.capitalize
|
|
8
8
|
@keywords = ''
|
|
9
|
-
@description = "
|
|
9
|
+
@description = "Tags for #{this_blog.blog_name}"
|
|
10
10
|
end
|
|
11
11
|
|
|
12
12
|
def show
|
|
13
|
-
@
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
@keywords = ''
|
|
20
|
-
@keywords << @grouping.keywords unless @grouping.keywords.blank?
|
|
21
|
-
@keywords << this_blog.meta_keywords unless this_blog.meta_keywords.blank?
|
|
22
|
-
@articles = @grouping.articles.published.page(params[:page]).per(10)
|
|
23
|
-
end
|
|
13
|
+
@tag = Tag.find_by!(name: params[:id])
|
|
14
|
+
|
|
15
|
+
@articles = @tag.
|
|
16
|
+
contents.includes(:blog, :user, :tags, :resources, :text_filter).
|
|
17
|
+
published.page(params[:page]).per(10)
|
|
18
|
+
|
|
24
19
|
respond_to do |format|
|
|
25
20
|
format.html do
|
|
26
21
|
if @articles.empty?
|
|
27
|
-
|
|
22
|
+
raise ActiveRecord::RecordNotFound
|
|
28
23
|
else
|
|
24
|
+
@page_title = this_blog.tag_title_template.to_title(@tag, this_blog, params).strip
|
|
25
|
+
@description = this_blog.tag_desc_template.to_title(@tag, this_blog, params).strip
|
|
26
|
+
@keywords = this_blog.meta_keywords
|
|
29
27
|
render template_name(params[:id])
|
|
30
28
|
end
|
|
31
29
|
end
|
|
32
30
|
|
|
33
31
|
format.atom do
|
|
34
32
|
@articles = @articles[0, this_blog.limit_rss_display]
|
|
35
|
-
|
|
33
|
+
render_cached_xml 'articles/index_atom_feed', @articles
|
|
36
34
|
end
|
|
37
35
|
|
|
38
36
|
format.rss do
|
|
39
37
|
@articles = @articles[0, this_blog.limit_rss_display]
|
|
40
|
-
|
|
38
|
+
render_cached_xml 'articles/index_rss_feed', @articles
|
|
41
39
|
end
|
|
42
40
|
end
|
|
43
41
|
end
|
|
@@ -24,17 +24,19 @@ class ThemeController < ContentController
|
|
|
24
24
|
private
|
|
25
25
|
|
|
26
26
|
def render_theme_item(type, file, mime = nil)
|
|
27
|
-
|
|
28
|
-
if file.split(%r{[\\/]}).include?('..')
|
|
29
|
-
return (render 'errors/404', status: 404, formats: ['html'])
|
|
30
|
-
end
|
|
27
|
+
return render_not_found if file.split(%r{[\\/]}).include?('..')
|
|
31
28
|
|
|
32
29
|
src = this_blog.current_theme.path + "/#{type}/#{file}"
|
|
33
|
-
return
|
|
30
|
+
return render_not_found unless File.exist? src
|
|
34
31
|
|
|
32
|
+
mime ||= mime_for(file)
|
|
35
33
|
send_file(src, type: mime, disposition: 'inline', stream: true)
|
|
36
34
|
end
|
|
37
35
|
|
|
36
|
+
def render_not_found
|
|
37
|
+
render plain: 'Not Found', status: 404
|
|
38
|
+
end
|
|
39
|
+
|
|
38
40
|
def mime_for(filename)
|
|
39
41
|
case filename.downcase
|
|
40
42
|
when /\.js$/
|
|
@@ -1,66 +1,18 @@
|
|
|
1
1
|
class XmlController < BaseController
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
2
|
+
def sitemap
|
|
3
|
+
@items = []
|
|
4
|
+
@blog = this_blog
|
|
5
5
|
|
|
6
|
-
|
|
6
|
+
@feed_title = this_blog.blog_name
|
|
7
|
+
@link = this_blog.base_url
|
|
8
|
+
@self_url = request.url
|
|
7
9
|
|
|
8
|
-
|
|
9
|
-
@
|
|
10
|
-
|
|
11
|
-
@format = NORMALIZED_FORMAT_FOR[params[:format]]
|
|
12
|
-
return render(plain: 'Unsupported format', status: 404) unless @format
|
|
13
|
-
end
|
|
14
|
-
|
|
15
|
-
# TODO: Move redirects into config/routes.rb, if possible
|
|
16
|
-
param_type = ACCEPTED_TYPE.dup.delete(params[:type])
|
|
17
|
-
param_id = params[:id] # .present? && params[:id].to_i # Think about a way to secure that to a valid tag/author for int value ...
|
|
18
|
-
|
|
19
|
-
case param_type
|
|
20
|
-
when 'feed'
|
|
21
|
-
redirect_to controller: 'articles', action: 'index', format: @format, status: :moved_permanently
|
|
22
|
-
when 'comments'
|
|
23
|
-
redirect_to admin_comments_url(format: @format), status: :moved_permanently
|
|
24
|
-
when 'article'
|
|
25
|
-
redirect_to this_blog.articles.find(param_id).feed_url(@format), status: :moved_permanently
|
|
26
|
-
when 'tag', 'author'
|
|
27
|
-
redirect_to send("#{param_type}_url", param_id, format: @format), status: :moved_permanently
|
|
28
|
-
when 'trackbacks'
|
|
29
|
-
redirect_to trackbacks_url(format: @format), status: :moved_permanently
|
|
30
|
-
when 'sitemap'
|
|
31
|
-
@items = []
|
|
32
|
-
@blog = this_blog
|
|
33
|
-
|
|
34
|
-
@feed_title = this_blog.blog_name
|
|
35
|
-
@link = this_blog.base_url
|
|
36
|
-
@self_url = request.url
|
|
10
|
+
@items += Article.find_already_published(1000)
|
|
11
|
+
@items += Page.find_already_published(1000)
|
|
12
|
+
@items += Tag.find_all_with_content_counters unless this_blog.unindex_tags
|
|
37
13
|
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
@items += Tag.find_all_with_article_counters unless this_blog.unindex_tags
|
|
41
|
-
|
|
42
|
-
respond_to do |format|
|
|
43
|
-
format.googlesitemap
|
|
44
|
-
end
|
|
45
|
-
else
|
|
46
|
-
return render(plain: 'Unsupported feed type', status: 404)
|
|
14
|
+
respond_to do |format|
|
|
15
|
+
format.googlesitemap
|
|
47
16
|
end
|
|
48
17
|
end
|
|
49
|
-
|
|
50
|
-
# TODO: Move redirects into config/routes.rb, if possible
|
|
51
|
-
def articlerss
|
|
52
|
-
redirect_to(URI.parse(Article.find(params[:id]).feed_url('rss')).path, status: :moved_permanently)
|
|
53
|
-
end
|
|
54
|
-
|
|
55
|
-
def commentrss
|
|
56
|
-
redirect_to admin_comments_url(format: 'rss'), status: :moved_permanently
|
|
57
|
-
end
|
|
58
|
-
|
|
59
|
-
def trackbackrss
|
|
60
|
-
redirect_to trackbacks_url(format: 'rss'), status: :moved_permanently
|
|
61
|
-
end
|
|
62
|
-
|
|
63
|
-
def rsd
|
|
64
|
-
render 'rsd', formats: [:rsd], handlers: [:builder]
|
|
65
|
-
end
|
|
66
18
|
end
|
|
@@ -2,7 +2,7 @@ module AuthorsHelper
|
|
|
2
2
|
include BlogHelper
|
|
3
3
|
|
|
4
4
|
def display_profile_item(item, item_desc)
|
|
5
|
-
return
|
|
5
|
+
return if item.blank?
|
|
6
6
|
item = link_to(item, item) if is_url?(item)
|
|
7
7
|
content_tag :li do
|
|
8
8
|
safe_join([item_desc, item], ' ')
|
|
@@ -16,7 +16,7 @@ module AuthorsHelper
|
|
|
16
16
|
end
|
|
17
17
|
|
|
18
18
|
def author_description(user)
|
|
19
|
-
return
|
|
19
|
+
return if user.description.blank?
|
|
20
20
|
|
|
21
21
|
content_tag(:div, user.description, id: 'author-description')
|
|
22
22
|
end
|
data/app/helpers/base_helper.rb
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
# coding: utf-8
|
|
2
|
+
|
|
2
3
|
# Methods added to this helper will be available to all templates in the application.
|
|
3
4
|
require 'digest/sha1'
|
|
4
5
|
|
|
@@ -38,7 +39,12 @@ module BaseHelper
|
|
|
38
39
|
options = {}
|
|
39
40
|
options[:class] = style if style
|
|
40
41
|
options[:rel] = 'nofollow' if nofollow
|
|
41
|
-
|
|
42
|
+
url = item.permalink_url(anchor, only_path)
|
|
43
|
+
if url
|
|
44
|
+
link_to title, url, options
|
|
45
|
+
else
|
|
46
|
+
title
|
|
47
|
+
end
|
|
42
48
|
end
|
|
43
49
|
|
|
44
50
|
def avatar_tag(options = {})
|
|
@@ -52,7 +58,7 @@ module BaseHelper
|
|
|
52
58
|
end
|
|
53
59
|
|
|
54
60
|
def meta_tag(name, value)
|
|
55
|
-
tag :meta, name: name, content: value
|
|
61
|
+
tag :meta, name: name, content: value if value.present?
|
|
56
62
|
end
|
|
57
63
|
|
|
58
64
|
def markup_help_popup(markup, text)
|
|
@@ -98,7 +104,7 @@ module BaseHelper
|
|
|
98
104
|
user.resource.upload.avatar.url
|
|
99
105
|
end
|
|
100
106
|
return if avatar_path.nil?
|
|
101
|
-
avatar_url =
|
|
107
|
+
avatar_url = this_blog.file_url(avatar_path)
|
|
102
108
|
elsif user.twitter_profile_image.present?
|
|
103
109
|
avatar_url = user.twitter_profile_image
|
|
104
110
|
end
|
|
@@ -168,6 +174,7 @@ module BaseHelper
|
|
|
168
174
|
end
|
|
169
175
|
|
|
170
176
|
def display_date_and_time(timestamp)
|
|
177
|
+
return if timestamp.blank?
|
|
171
178
|
if this_blog.date_format == 'setting_date_format_distance_of_time_in_words'
|
|
172
179
|
timeago_tag timestamp, date_only: false
|
|
173
180
|
else
|
|
@@ -177,7 +184,7 @@ module BaseHelper
|
|
|
177
184
|
|
|
178
185
|
def show_meta_keyword
|
|
179
186
|
return unless this_blog.use_meta_keyword
|
|
180
|
-
meta_tag 'keywords', @keywords
|
|
187
|
+
meta_tag 'keywords', @keywords if @keywords.present?
|
|
181
188
|
end
|
|
182
189
|
|
|
183
190
|
def stop_index_robots?(blog)
|
data/app/helpers/xml_helper.rb
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
module XmlHelper
|
|
2
2
|
def collection_lastmod(collection)
|
|
3
|
-
article_updated = collection.
|
|
4
|
-
article_published = collection.
|
|
3
|
+
article_updated = collection.contents.order(updated_at: :desc).first
|
|
4
|
+
article_published = collection.contents.order(published_at: :desc).first
|
|
5
5
|
|
|
6
6
|
times = []
|
|
7
7
|
times.push article_updated.updated_at if article_updated
|
|
@@ -6,16 +6,12 @@ class ArchivesSidebar < Sidebar
|
|
|
6
6
|
|
|
7
7
|
attr_accessor :archives
|
|
8
8
|
|
|
9
|
-
def self.
|
|
9
|
+
def self.date_funcs
|
|
10
10
|
@date_func ||=
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
'extract(year from published_at) as year,extract(month from published_at) as month'
|
|
16
|
-
end
|
|
17
|
-
rescue NameError
|
|
18
|
-
'extract(year from published_at) as year,extract(month from published_at) as month'
|
|
11
|
+
if Content.connection.class.name =~ /SQLite3Adapter/
|
|
12
|
+
["strftime('%Y', published_at) as year", "strftime('%m', published_at) as month"]
|
|
13
|
+
else
|
|
14
|
+
['extract(year from published_at) as year', 'extract(month from published_at) as month']
|
|
19
15
|
end
|
|
20
16
|
end
|
|
21
17
|
|
|
@@ -25,9 +21,10 @@ class ArchivesSidebar < Sidebar
|
|
|
25
21
|
# Unfortunately, there's no universally-supported way to do this
|
|
26
22
|
# across all three of our supported DBs. So, we resort to a bit of
|
|
27
23
|
# DB-specific code.
|
|
28
|
-
|
|
24
|
+
date_funcs = self.class.date_funcs
|
|
29
25
|
|
|
30
|
-
article_counts =
|
|
26
|
+
article_counts = Article.published.select('count(*) as count', *date_funcs).
|
|
27
|
+
group(:year, :month).reorder('year desc', 'month desc').limit(count.to_i)
|
|
31
28
|
|
|
32
29
|
@archives = article_counts.map do |entry|
|
|
33
30
|
month = entry.month.to_i
|