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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 3c8be1e8a9b818f43d06abb0b07621dc08861e22
4
- data.tar.gz: a162c1a89fabe91d31115580f481f64487e2cbc4
3
+ metadata.gz: e3c22297d35a71ec554f05a2a8e69ea270b95098
4
+ data.tar.gz: 6dc8d1b4ce5d693b2b92f674a1fcc24e2d558565
5
5
  SHA512:
6
- metadata.gz: 3a815ebbfb453880d2af5d1050df5f2be3646d9c3e4fc629435a0dc20e808bd4cac4b8f0c01bc77e55ce7c585f0b15b120b4b1a2ded88eafedae4ad451207e22
7
- data.tar.gz: 86c06fe8d14940efae29d11974e604630807e93d53013e9bc1ff2e1343842749ce3c5bfe231c62d118a10c4a0feae0f2bb2e81c28e6d5c2c4d296f94d8b1e973
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.thumbnail.url(:medium)}}
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
@@ -25,6 +25,10 @@ class Blog::Gem::Post < Blog::Gem::ApplicationRecord
25
25
  end
26
26
  end
27
27
 
28
+ def image_url
29
+ "#{Blog::Gem.url}#{thumbnail.url(:medium)}"
30
+ end
31
+
28
32
  def to_path
29
33
  "#{Blog::Gem.path}/#{url}"
30
34
  end
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
@@ -1,5 +1,5 @@
1
1
  module Blog
2
2
  module Gem
3
- VERSION = '0.1.4'
3
+ VERSION = '0.1.5'
4
4
  end
5
5
  end
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
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-08-28 00:00:00.000000000 Z
12
+ date: 2017-09-15 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rails