blogo 0.0.6 → 0.0.7
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/app/controllers/blogo/admin/comments_controller.rb +5 -1
- data/app/controllers/blogo/admin/posts_controller.rb +20 -2
- data/app/controllers/blogo/admin/sessions_controller.rb +11 -0
- data/app/controllers/blogo/posts_controller.rb +34 -23
- data/app/helpers/blogo/application_helper.rb +1 -14
- data/app/models/blogo/post.rb +6 -1
- data/app/services/blogo/base_post_service.rb +5 -3
- data/app/views/blogo/{shared → posts}/_disqus_comments.html.erb +1 -1
- data/app/views/blogo/{shared → posts}/_post.html.erb +0 -0
- data/app/views/blogo/posts/_post_header.html.erb +1 -1
- data/app/views/blogo/posts/_post_overview.html.erb +1 -1
- data/app/views/blogo/posts/feed.atom.builder +2 -2
- data/app/views/blogo/posts/show.html.erb +2 -2
- data/app/views/blogo/shared/_aside.html.erb +1 -1
- data/app/views/blogo/{posts → shared}/_meta.html.erb +0 -0
- data/app/views/blogo/{posts/_icons.html.erb → shared/_social_icons.html.erb} +0 -0
- data/app/views/layouts/blogo/blog.html.erb +2 -2
- data/db/migrate/20140218134550_create_blogo_posts.rb +2 -1
- data/lib/blogo/version.rb +1 -1
- metadata +34 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 267c58dc478854e27327ad35435293f38555184e
|
4
|
+
data.tar.gz: 676ee2ecc4e6f947e929f60ff3d65d3e05632621
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 35308726152df9737d2bb597bc58a9bed9e69cbacddf7f058564a669018fe8e6d1df3152584470dbd4f081797c1f4560705521ea0f176dc7cb7bad9053e32cbd
|
7
|
+
data.tar.gz: 399072ad5edc5019b984c0f0921d293d79139c523852ea31565ee8164d9c85461e943c22915f0902681c89606d0ab8b8a4acf5bde1eceda6405e1a971edd5ee2
|
@@ -1,14 +1,21 @@
|
|
1
1
|
module Blogo::Admin
|
2
|
+
# Responsible for posts management: creation, editing, deletion, preview.
|
2
3
|
class PostsController < BaseController
|
3
4
|
|
5
|
+
# GET /admin/posts
|
6
|
+
#
|
4
7
|
def index
|
5
8
|
@posts = Blogo::Post.all
|
6
9
|
end
|
7
10
|
|
11
|
+
# GET /admin/posts/new
|
12
|
+
#
|
8
13
|
def new
|
9
14
|
@post = Blogo::Post.new(published: true)
|
10
15
|
end
|
11
16
|
|
17
|
+
# POST /admin/posts
|
18
|
+
#
|
12
19
|
def create
|
13
20
|
service = Blogo::CreatePostService.new(blogo_current_user, post_params)
|
14
21
|
|
@@ -22,12 +29,16 @@ module Blogo::Admin
|
|
22
29
|
end
|
23
30
|
end
|
24
31
|
|
32
|
+
# GET /admin/posts/:id/edit
|
33
|
+
#
|
25
34
|
def edit
|
26
|
-
@post = Blogo::Post.
|
35
|
+
@post = Blogo::Post.where(permalink: params[:id]).first!
|
27
36
|
end
|
28
37
|
|
38
|
+
# PATCH /admin/posts/:id
|
39
|
+
#
|
29
40
|
def update
|
30
|
-
@post = Blogo::Post.
|
41
|
+
@post = Blogo::Post.where(permalink: params[:id]).first!
|
31
42
|
service = Blogo::UpdatePostService.new(@post, post_params)
|
32
43
|
|
33
44
|
if service.update!
|
@@ -38,6 +49,8 @@ module Blogo::Admin
|
|
38
49
|
end
|
39
50
|
end
|
40
51
|
|
52
|
+
# DELETE /admin/posts/:id
|
53
|
+
#
|
41
54
|
def destroy
|
42
55
|
post = Blogo::Post.find(params[:id])
|
43
56
|
Blogo::DestroyPostService.new(post).destroy!
|
@@ -46,6 +59,8 @@ module Blogo::Admin
|
|
46
59
|
redirect_to blogo_admin_posts_path
|
47
60
|
end
|
48
61
|
|
62
|
+
# POST /admin/posts/preview
|
63
|
+
#
|
49
64
|
def preview
|
50
65
|
@post = Blogo::PreviewPostService.new(blogo_current_user, post_params).preview
|
51
66
|
|
@@ -57,6 +72,9 @@ module Blogo::Admin
|
|
57
72
|
|
58
73
|
private
|
59
74
|
|
75
|
+
# Get post parameters from params.
|
76
|
+
#
|
77
|
+
# @return [Hash]
|
60
78
|
def post_params
|
61
79
|
params.require(:post).permit(:title, :permalink, :published_at, :raw_content, :published, :tags_string)
|
62
80
|
end
|
@@ -1,10 +1,18 @@
|
|
1
1
|
module Blogo::Admin
|
2
|
+
# Responsible for authentication of blog users.
|
3
|
+
# Simply performs 2 operation: login and logout.
|
4
|
+
# User is logged in if it has set sessions[:blogo_user_id].
|
5
|
+
#
|
2
6
|
class SessionsController < BaseController
|
3
7
|
skip_before_filter :ensure_authenticated!
|
4
8
|
|
9
|
+
# GET /admin/login
|
10
|
+
#
|
5
11
|
def new
|
6
12
|
end
|
7
13
|
|
14
|
+
# POST /admin/sessions
|
15
|
+
#
|
8
16
|
def create
|
9
17
|
user = Blogo::User.find_by_email(params[:email])
|
10
18
|
if user && user.authenticate(params[:password])
|
@@ -16,6 +24,9 @@ module Blogo::Admin
|
|
16
24
|
end
|
17
25
|
end
|
18
26
|
|
27
|
+
|
28
|
+
# GET /admin/logout
|
29
|
+
#
|
19
30
|
def destroy
|
20
31
|
session[:blogo_user_id] = nil
|
21
32
|
redirect_to blogo_admin_url, notice: "You have logged out"
|
@@ -1,38 +1,45 @@
|
|
1
1
|
module Blogo
|
2
|
+
# Responsible for showing posts and atom feeds to visitors.
|
2
3
|
class PostsController < ApplicationController
|
3
4
|
layout 'blogo/blog'
|
4
5
|
|
5
6
|
# Number of posts shown in feed.
|
6
7
|
FEED_POSTS_LIMIT = 20
|
7
8
|
|
9
|
+
# GET /posts
|
10
|
+
#
|
8
11
|
def index
|
9
12
|
@tag = params[:tag]
|
10
13
|
set_vars
|
11
14
|
set_paginator
|
12
15
|
|
13
16
|
@meta = {}
|
14
|
-
@meta[:title]
|
15
|
-
@meta[:site_name]
|
16
|
-
@meta[:keywords]
|
17
|
-
@meta[:type]
|
17
|
+
@meta[:title] = "#{Blogo.config.site_title} - #{Blogo.config.site_subtitle}"
|
18
|
+
@meta[:site_name] = Blogo.config.site_title
|
19
|
+
@meta[:keywords] = Blogo.config.keywords
|
20
|
+
@meta[:type] = 'website'
|
18
21
|
end
|
19
22
|
|
23
|
+
# GET /posts/:permalink
|
24
|
+
#
|
20
25
|
def show
|
21
26
|
@post = Post.published.where(:permalink => params[:permalink]).first!
|
22
27
|
set_vars
|
23
28
|
|
24
29
|
@meta = {}
|
25
|
-
@meta[:title]
|
26
|
-
@meta[:description]
|
27
|
-
@meta[:keywords]
|
28
|
-
@meta[:url]
|
29
|
-
@meta[:image]
|
30
|
-
@meta[:type]
|
31
|
-
@meta[:site_name]
|
30
|
+
@meta[:title] = "#{@post.title} - #{Blogo.config.site_title}"
|
31
|
+
@meta[:description] = @post.meta_description
|
32
|
+
@meta[:keywords] = [@post.tags_string, Blogo.config.keywords].flatten.join(", ")
|
33
|
+
@meta[:url] = request.url
|
34
|
+
@meta[:image] = meta_image
|
35
|
+
@meta[:type] = 'article'
|
36
|
+
@meta[:site_name] = Blogo.config.site_title
|
32
37
|
end
|
33
38
|
|
39
|
+
# GET /posts/feed
|
40
|
+
#
|
34
41
|
def feed
|
35
|
-
@posts =
|
42
|
+
@posts = Post.published.limit(FEED_POSTS_LIMIT)
|
36
43
|
@updated = @posts.first.try(:updated_at)
|
37
44
|
|
38
45
|
render 'feed', layout: false
|
@@ -41,25 +48,28 @@ module Blogo
|
|
41
48
|
|
42
49
|
private
|
43
50
|
|
51
|
+
# Build a paginator object and set to @paginator.
|
52
|
+
#
|
53
|
+
# @return [Blogo::Paginator]
|
44
54
|
def set_paginator
|
45
|
-
|
46
|
-
|
55
|
+
posts_scope = Post.published
|
56
|
+
|
57
|
+
if @tag
|
58
|
+
posts_scope = posts_scope.joins(:tags).where("#{Tag.table_name}.name = ?", @tag)
|
59
|
+
end
|
47
60
|
|
48
61
|
@paginator = Paginator.new(
|
49
|
-
|
62
|
+
posts_scope,
|
50
63
|
:page => (params[:page] || 1),
|
51
64
|
:per_page => conf.posts_per_page,
|
52
65
|
:size => conf.paginator_size)
|
53
66
|
end
|
54
67
|
|
68
|
+
# Sets @recent_posts and @tags.
|
69
|
+
#
|
55
70
|
def set_vars
|
56
|
-
@recent_posts =
|
57
|
-
@tags
|
58
|
-
end
|
59
|
-
|
60
|
-
|
61
|
-
def published_posts
|
62
|
-
Post.published
|
71
|
+
@recent_posts = Post.published.limit(conf.recent_posts) if conf.recent_posts
|
72
|
+
@tags = Tag.all
|
63
73
|
end
|
64
74
|
|
65
75
|
# Engine configuration. Method +config+ is already used by Rails.
|
@@ -69,9 +79,10 @@ module Blogo
|
|
69
79
|
Blogo.config
|
70
80
|
end
|
71
81
|
|
72
|
-
|
82
|
+
# @return [String, nil] full URL to image or nil
|
73
83
|
def meta_image
|
74
84
|
return nil unless @post.meta_image.present?
|
85
|
+
|
75
86
|
if @post.meta_image =~ /\Ahttp/
|
76
87
|
@post.meta_image
|
77
88
|
else
|
@@ -3,19 +3,6 @@ module Blogo
|
|
3
3
|
module ApplicationHelper
|
4
4
|
include Rails.application.routes.url_helpers
|
5
5
|
|
6
|
-
# Path to a post with year prefix.
|
7
|
-
#
|
8
|
-
# @param post [Blogo::Post]
|
9
|
-
#
|
10
|
-
# @return [String]
|
11
|
-
def path_to_post(post)
|
12
|
-
blogo_post_path(:permalink => post.permalink)
|
13
|
-
end
|
14
|
-
|
15
|
-
def url_to_post(post)
|
16
|
-
blogo_post_url(:permalink => post.permalink)
|
17
|
-
end
|
18
|
-
|
19
6
|
# Path to a page or a page in scope of a particular tag.
|
20
7
|
#
|
21
8
|
# @param page [Integer]
|
@@ -36,7 +23,7 @@ module Blogo
|
|
36
23
|
#
|
37
24
|
# @return [String]
|
38
25
|
def post_overview(post)
|
39
|
-
post.
|
26
|
+
post.html_overview ? post.html_overview : post.html_content
|
40
27
|
end
|
41
28
|
end
|
42
29
|
end
|
data/app/models/blogo/post.rb
CHANGED
@@ -31,13 +31,18 @@ class Blogo::Post < ActiveRecord::Base
|
|
31
31
|
end
|
32
32
|
|
33
33
|
|
34
|
+
def to_param
|
35
|
+
permalink
|
36
|
+
end
|
37
|
+
|
38
|
+
|
34
39
|
private
|
35
40
|
|
36
41
|
# Filter html content to get plain text and set first 200 characters as meta_description.
|
37
42
|
#
|
38
43
|
# @return [void]
|
39
44
|
def set_meta_description
|
40
|
-
html =
|
45
|
+
html = html_overview || html_content
|
41
46
|
|
42
47
|
self.meta_description =
|
43
48
|
html.gsub(/<\/?[^>]*>/, ' '). # replace HTML tags with spaces
|
@@ -36,14 +36,16 @@ module Blogo
|
|
36
36
|
end
|
37
37
|
|
38
38
|
def render_and_set_content!
|
39
|
-
|
39
|
+
return unless @post.raw_content
|
40
40
|
|
41
|
+
renderer = Blogo::Renderer.get(Blogo.config.markup_lang)
|
41
42
|
overview, rest = @post.raw_content.split(JUMP_BREAK, 2)
|
43
|
+
|
42
44
|
if rest.present?
|
43
|
-
@post.
|
45
|
+
@post.html_overview = renderer.render(overview)
|
44
46
|
@post.html_content = renderer.render(overview + rest)
|
45
47
|
else
|
46
|
-
@post.
|
48
|
+
@post.html_overview = nil
|
47
49
|
@post.html_content = renderer.render(@post.raw_content)
|
48
50
|
end
|
49
51
|
end
|
@@ -9,7 +9,7 @@
|
|
9
9
|
<script type="text/javascript">
|
10
10
|
var disqus_shortname = '<%= Blogo.config.disqus_shortname %>';
|
11
11
|
var disqus_identifier = 'blog-post-<%= @post.id %>';
|
12
|
-
var disqus_url = '<%=
|
12
|
+
var disqus_url = '<%= blogo_post_url(@post) %>';
|
13
13
|
var disqus_title = '<%= @post.title %>';
|
14
14
|
var disqus_script = 'embed.js';
|
15
15
|
|
File without changes
|
@@ -4,8 +4,8 @@ atom_feed do |feed|
|
|
4
4
|
feed.updated @updated
|
5
5
|
|
6
6
|
@posts.each do |post|
|
7
|
-
feed.entry(post, url:
|
8
|
-
entry.url
|
7
|
+
feed.entry(post, url: blogo_post_url(post)) do |entry|
|
8
|
+
entry.url blogo_post_url(post)
|
9
9
|
entry.title post.title
|
10
10
|
entry.content post_overview(post), :type => 'html'
|
11
11
|
entry.updated post.updated_at.strftime("%Y-%m-%dT%H:%M:%SZ")
|
File without changes
|
File without changes
|
@@ -4,7 +4,7 @@
|
|
4
4
|
<title><%= @meta[:title] %></title>
|
5
5
|
<meta charset="UTF-8">
|
6
6
|
|
7
|
-
<%= render partial: 'blogo/
|
7
|
+
<%= render partial: 'blogo/shared/meta' %>
|
8
8
|
|
9
9
|
<%= csrf_meta_tags %>
|
10
10
|
<%= stylesheet_link_tag "blogo/blog" %>
|
@@ -21,7 +21,7 @@
|
|
21
21
|
</div>
|
22
22
|
|
23
23
|
<div class='header-icons'>
|
24
|
-
<%= render partial: 'blogo/
|
24
|
+
<%= render partial: 'blogo/shared/social_icons' %>
|
25
25
|
</div>
|
26
26
|
</header>
|
27
27
|
|
@@ -13,7 +13,7 @@ class CreateBlogoPosts < ActiveRecord::Migration
|
|
13
13
|
t.text :raw_content , null: false
|
14
14
|
|
15
15
|
t.text :html_content , null: false
|
16
|
-
t.text :
|
16
|
+
t.text :html_overview, null: true
|
17
17
|
|
18
18
|
t.string :tags_string , null: true
|
19
19
|
t.string :meta_description , null: false
|
@@ -26,6 +26,7 @@ class CreateBlogoPosts < ActiveRecord::Migration
|
|
26
26
|
add_index posts_table, :permalink, unique: true
|
27
27
|
add_index posts_table, :published_at
|
28
28
|
|
29
|
+
# NOTE: respond_to?(:add_foreign_key) does not work
|
29
30
|
if defined?(Foreigner)
|
30
31
|
users_table = "#{Blogo.table_name_prefix}users"
|
31
32
|
add_foreign_key posts_table, users_table, column: :user_id
|
data/lib/blogo/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: blogo
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sergey Potapov
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-03-
|
11
|
+
date: 2014-03-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -24,6 +24,34 @@ dependencies:
|
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '4.0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: jquery-rails
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: coffee-rails
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
27
55
|
- !ruby/object:Gem::Dependency
|
28
56
|
name: bcrypt-ruby
|
29
57
|
requirement: !ruby/object:Gem::Requirement
|
@@ -106,9 +134,9 @@ files:
|
|
106
134
|
- app/views/blogo/admin/posts/new.html.erb
|
107
135
|
- app/views/blogo/admin/sessions/new.html.erb
|
108
136
|
- app/views/blogo/admin/shared/_nav_bar.html.erb
|
109
|
-
- app/views/blogo/posts/
|
110
|
-
- app/views/blogo/posts/_meta.html.erb
|
137
|
+
- app/views/blogo/posts/_disqus_comments.html.erb
|
111
138
|
- app/views/blogo/posts/_paginator.html.erb
|
139
|
+
- app/views/blogo/posts/_post.html.erb
|
112
140
|
- app/views/blogo/posts/_post_header.html.erb
|
113
141
|
- app/views/blogo/posts/_post_overview.html.erb
|
114
142
|
- app/views/blogo/posts/_social_share.html.erb
|
@@ -116,9 +144,9 @@ files:
|
|
116
144
|
- app/views/blogo/posts/index.html.erb
|
117
145
|
- app/views/blogo/posts/show.html.erb
|
118
146
|
- app/views/blogo/shared/_aside.html.erb
|
119
|
-
- app/views/blogo/shared/_disqus_comments.html.erb
|
120
147
|
- app/views/blogo/shared/_google_analytics.html.erb
|
121
|
-
- app/views/blogo/shared/
|
148
|
+
- app/views/blogo/shared/_meta.html.erb
|
149
|
+
- app/views/blogo/shared/_social_icons.html.erb
|
122
150
|
- app/views/layouts/blogo/admin.html.erb
|
123
151
|
- app/views/layouts/blogo/blog.html.erb
|
124
152
|
- config/environment.rb
|