blog-gem 0.1.4 → 0.1.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/controllers/blog/gem/blog_controller.rb +11 -1
- data/app/models/blog/gem/post.rb +4 -0
- data/config/routes.rb +2 -0
- data/lib/blog/gem/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e3c22297d35a71ec554f05a2a8e69ea270b95098
|
4
|
+
data.tar.gz: 6dc8d1b4ce5d693b2b92f674a1fcc24e2d558565
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 16ff097940495b613db0b43b5f071340f32ddfcdeca8dfdbdb66c63b6029d64207af9b8abcecbc3c8b1d77f405461441a512fd0e16f856e7057ffdeaf4bba156
|
7
|
+
data.tar.gz: 0fdc7bc4cbdc67a17ba7b370e59dfbb7ca4d0dde84ac7db03c41c2a66e1a4528153f5740f64619af995c3b4938e96eda4d0f1e0319c189b8382c72d154574aab
|
@@ -36,7 +36,7 @@ class Blog::Gem::BlogController < Blog::Gem::ApplicationController
|
|
36
36
|
end
|
37
37
|
format.json do
|
38
38
|
@posts = posts.published.all
|
39
|
-
render json: @posts.map{|x| {title: x.title, teaser: x.teaser, url: x.url, tags: x.tags, category: x.category, author: x.author_name, thumbnail: x.
|
39
|
+
render json: @posts.map{|x| {id: x.id, title: x.title, teaser: x.teaser, url: x.url, tags: x.tags, category: x.category, author: x.author_name, thumbnail: x.image_url}}
|
40
40
|
end
|
41
41
|
format.html do
|
42
42
|
@current_path = blogs_path
|
@@ -58,4 +58,14 @@ class Blog::Gem::BlogController < Blog::Gem::ApplicationController
|
|
58
58
|
render "layouts/application/not_found"
|
59
59
|
end
|
60
60
|
end
|
61
|
+
|
62
|
+
def api
|
63
|
+
@post = Blog::Gem::Post.find_by_id(params[:id])
|
64
|
+
if @post.present? && @post.published_at <= Time.now
|
65
|
+
render json: {status: 200, id: @post.id, title: @post.title, teaser: @post.teaser, url: @post.url, tags: @post.tags, category: @post.category, author: @post.author_name, thumbnail: @post.image_url, body: @post.body}
|
66
|
+
else
|
67
|
+
render json: {status: 404}
|
68
|
+
end
|
69
|
+
|
70
|
+
end
|
61
71
|
end
|
data/app/models/blog/gem/post.rb
CHANGED
data/config/routes.rb
CHANGED
@@ -2,6 +2,8 @@ Blog::Gem::Engine.routes.draw do
|
|
2
2
|
|
3
3
|
get "/" => "blog#index", as: :blogs
|
4
4
|
get "/feed.atom" => "blog#index", as: :blog_feed
|
5
|
+
get "/api.json" => "blog#index", as: :blog_api_index
|
6
|
+
get "/api/:id.json" => "blog#api", as: :blog_api_show
|
5
7
|
|
6
8
|
get "/tag/:tag" => "blog#index", as: :blog_tag
|
7
9
|
get "/category/:category" => "blog#index", as: :blog_category
|
data/lib/blog/gem/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: blog-gem
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Vincent Thelang
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2017-
|
12
|
+
date: 2017-09-15 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rails
|