jekyll-auto-image 1.0.0 → 1.0.1

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: 18c13b5cac681464310ff3fbb71d4b75fb7a98e8
4
- data.tar.gz: 9e07cff0479b14b9f746730b28fd35a3931f9d56
3
+ metadata.gz: 49577f6130bb371d0fe562df357da1c586e4e526
4
+ data.tar.gz: 0bc3a6173dafdb5b3d2dcd4c9900ab83405ddfe3
5
5
  SHA512:
6
- metadata.gz: 954ac3e60846a664cfe7777f8d70307903acf292f67e00904a917592269adf1a5453ee19870beca89c3863066f0f0f58347a1ed53ce8e5cb5a9d4c4246a268c3
7
- data.tar.gz: 2dc96f8639b9cbb1440d70182c5563532fa2bf7232355b133f14f34e4646fd5c12deb3f6eb8db889c06f579a3ec7cb2cd394fccafeb2935e866397b8e4b40283
6
+ metadata.gz: d76a3d41f7d247311ab5b514f6c72e29caa40fb0ea346016e0f8dfce2f68ffc2f2a2f9beac7300d5660387ba5da3fbd80e69aa8902014b48a40d2e7193cb5362
7
+ data.tar.gz: e69962785332153f623c4de95c732f3636ba32f098cb39ce98646067e9e441a1292568e0513bb65843aa0b2170cd10d42ebccd1a9234e64e25e763ec1dd5bd6d
data/README.md CHANGED
@@ -2,28 +2,36 @@
2
2
 
3
3
  jekyll plugin that makes available the first image of a post in the template as a variable.
4
4
 
5
+ By installing the plugin you will be able to access the first image of a page through `{{ @page.image }}`.
6
+
5
7
  This plugin is useful if you want to:
6
8
 
7
- * list the posts of your jekyll site including an image
8
- * setting the twitter card image
9
+ * Include an image on your list of posts
10
+ * Set a twitter card image for a post (see example below)
11
+
9
12
 
10
13
  # Install
11
14
 
12
- Copy `auto-image.rb` into your jekyll `_plugins` directory
15
+ Add to your Gemfile:
13
16
 
17
+ ```
18
+ gem 'jekyll-auto-image'
19
+ ```
20
+ or run
14
21
 
15
- # Usage
22
+ ```
23
+ $ gem install jekyll-auto-image
24
+ ```
16
25
 
17
- In each post/page, the plugin will set `{{ page.image }}` following this fallback rules:
18
26
 
19
- 1. Front matter `image` value
20
- 2. First image in the post/page contents
21
- 3. Default site image (defined in `_config.yml`)
22
- 4. Nothing (false)
27
+ Then, add to your `_config.yml`:
23
28
 
24
- Basically, the plugin will return the front matter image value if set. If it is not set, then it will look for the first image asset that is defined in your post content. If the post does not have any image, then it will set the site.image defined in _config.yml.
29
+ ```yaml
30
+ gems:
31
+ - jekyll-auto-image
32
+ ```
25
33
 
26
- To set the default image for all pages/posts, add to the `_config.yml` file the following line:
34
+ The plugin allows you to set a default image for all pages/posts. To do that, add to your `_config.yml`:
27
35
 
28
36
  ```yaml
29
37
  # _config.yml
@@ -31,6 +39,18 @@ To set the default image for all pages/posts, add to the `_config.yml` file the
31
39
  image: /path/to/your/default/image.png
32
40
  ```
33
41
 
42
+ # Usage
43
+
44
+ In each post/page, the plugin will set `{{ page.image }}` following this fallback rules:
45
+
46
+ 1. Front matter `image` value
47
+ 2. First image in the post/page contents
48
+ 3. Default site image (defined in `_config.yml`)
49
+ 4. nil
50
+
51
+ Basically, the plugin will return the front matter image value if set. If it is not set, then it will look for the first image asset that is defined in your post content. If the post does not have any image, then it will set the site.image defined in _config.yml.
52
+
53
+
34
54
  ### Example of usage
35
55
 
36
56
  Example post 1:
@@ -41,7 +61,7 @@ layout: post
41
61
  title: Post 1
42
62
  ---
43
63
 
44
- This is my example post
64
+ This is my example post. It includes an image in the contents.
45
65
 
46
66
  ![first image](/assets/first_image.png)
47
67
 
@@ -55,13 +75,16 @@ title: Post 2
55
75
  image: /assets/front_matter_image.png
56
76
  ---
57
77
 
58
- This is my example post
78
+ This is my second example post, because the
79
+ post includes the front matter image, the plugin
80
+ will return it instead of the first image in the
81
+ contents.
59
82
 
60
83
  ![first image](/assets/first_image.png)
61
84
 
62
85
  ```
63
86
 
64
- Template:
87
+ ####Template example
65
88
 
66
89
  ```liquid
67
90
  {% for post in site.posts %}
@@ -71,7 +94,7 @@ image: {{ post.image }}
71
94
  <hr>
72
95
  ```
73
96
 
74
- HTML output:
97
+ #### Output HTML Rendered:
75
98
 
76
99
  ```html
77
100
  title: Post 1
@@ -85,7 +108,11 @@ image: /assets/front_matter_image.png
85
108
  ```
86
109
  ### Example using twitter cards
87
110
 
88
- You can define a set of `<meta>` elements in your head.html, so when sharing a post in twitter it is displayed in a cool way. You have more info in [twitter's developers page](https://dev.twitter.com/cards/types)
111
+ Another use of this plugin is to create a [twitter card](https://dev.twitter.com/cards/getting-started).
112
+
113
+ You can define a set of `<meta>` elements in your `head.html` template, so when sharing a post in twitter, the tweet displays it in cool way. You have more info in [twitter's developers page](https://dev.twitter.com/cards/types)
114
+
115
+ Here you have a sample:
89
116
 
90
117
  ```html
91
118
  <!-- twitter card -->
@@ -102,10 +129,6 @@ You can define a set of `<meta>` elements in your head.html, so when sharing a p
102
129
 
103
130
  You can validate how it will look using the [cards validator](https://cards-dev.twitter.com/validator)
104
131
 
105
- # To Do List
106
-
107
- * Make the plugin a gem, so it can be installed using `gem install`
108
- * add tests cases (see [https://github.com/ivantsepp/jekyll-autolink_email](https://github.com/ivantsepp/jekyll-autolink_email))
109
132
 
110
133
  # Contributing
111
134
 
@@ -116,8 +139,12 @@ You can validate how it will look using the [cards validator](https://cards-dev.
116
139
  4. Create a new Pull Request
117
140
 
118
141
 
142
+ The tests are based on the code of [https://github.com/ivantsepp/jekyll-autolink_email](https://github.com/ivantsepp/jekyll-autolink_email)
143
+
144
+
119
145
  # License
120
146
 
121
- Copyright (c) 2015 Juan M. Merlos. (@merlos) Distributed under MIT License
147
+ Copyright (c) 2015 Juan M. Merlos. (@merlos) [www.merlos.org](http://www.merlos.org) Distributed under MIT License
148
+
149
+
122
150
 
123
- [www.merlos.org](http://www.merlos.org)
@@ -1,11 +1,11 @@
1
1
  # coding: utf-8
2
2
  lib = File.expand_path('../lib', __FILE__)
3
3
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
- require 'jekyll/auto/image/version'
4
+ require 'jekyll-auto-image/version'
5
5
 
6
6
  Gem::Specification.new do |spec|
7
7
  spec.name = "jekyll-auto-image"
8
- spec.version = Jekyll::Auto::Image::VERSION
8
+ spec.version = Jekyll::AutoImage::VERSION
9
9
  spec.authors = ["merlos"]
10
10
  spec.email = ["jmmerlos@merlos.org"]
11
11
  spec.summary = %q{jekyll plugin that makes available the first image of a post in the template}
@@ -13,7 +13,7 @@ Gem::Specification.new do |spec|
13
13
  spec.homepage = "https://github.com/merlos/jekyll-auto-image"
14
14
  spec.license = "MIT"
15
15
 
16
- spec.files = `git ls-files -z`.split("\x0")
16
+ spec.files = `git ls-files`.split($/)
17
17
  spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
18
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
19
  spec.require_paths = ["lib"]
@@ -1,4 +1,4 @@
1
- require "jekyll/auto/image/version"
1
+ require "jekyll-auto-image/version"
2
2
  require "jekyll"
3
3
 
4
4
  module Jekyll
@@ -0,0 +1,5 @@
1
+ module Jekyll
2
+ module AutoImage
3
+ VERSION = "1.0.1"
4
+ end
5
+ end
data/test/helper.rb CHANGED
@@ -3,4 +3,4 @@ require 'minitest/unit'
3
3
  require 'shoulda'
4
4
  require 'mocha/mini_test'
5
5
  require 'jekyll'
6
- require 'jekyll/auto/image'
6
+ require 'jekyll-auto-image'
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jekyll-auto-image
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - merlos
@@ -94,8 +94,8 @@ files:
94
94
  - README.md
95
95
  - Rakefile
96
96
  - jekyll-auto-image.gemspec
97
- - lib/jekyll/auto/image.rb
98
- - lib/jekyll/auto/image/version.rb
97
+ - lib/jekyll-auto-image.rb
98
+ - lib/jekyll-auto-image/version.rb
99
99
  - test/fixtures/_posts/contents-image.md
100
100
  - test/fixtures/contents-html.html
101
101
  - test/fixtures/contents-image.md
@@ -1,7 +0,0 @@
1
- module Jekyll
2
- module Auto
3
- module Image
4
- VERSION = "1.0.0"
5
- end
6
- end
7
- end