middleman-social_image 0.0.5 → 0.0.6

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 24790c8f3ad949cc2ca924415717b87da699d84f3136d0a7c9249807f17cb3a7
4
- data.tar.gz: fe114cadc47468ecc7839a261628814214158718628b659709ead92c3f14d654
3
+ metadata.gz: 4b33a5a00bdde76bcf00c4c872bcc525e691874adf5bd95a12d92e52f38974e4
4
+ data.tar.gz: 992ac18e68e3f25e9f9bd8c1ef0b3af7a253e75aef05a442b63ed6278a769323
5
5
  SHA512:
6
- metadata.gz: 3858b4cbad63083aa173072fe9e316bd19f1d5bc6de862daf5e4173b9fdc979129d6807b40b73670ee9c8c34c8dfc512276ba81fc41b754c7ca14773daa223be
7
- data.tar.gz: ceee24fb84151157e046dabc916c4eecaf6263ac2e6b30426e7cb153bc79d7f1c303bf1dc8d8917da617174b4341ae3d51252174203e986de26bf27572f95175
6
+ metadata.gz: 86ea9bb9a3bb9759e770e1633058c2390594096d182fd68b221c3e67abf0b8fa95800cce97ac0b3eb23a2dc1623cc3c89e451be6b11a12a80c0faa50bb2cff44
7
+ data.tar.gz: ab6aaf979d769b23ec82ee5d056fd7d6f604b7f298d088472b4ef32a824602ba58555e2f867ff53d466f93f44b978b5ca9e3b42f325c6f7fa4f2e66dbf98e668
data/.gitignore CHANGED
@@ -9,3 +9,4 @@
9
9
 
10
10
  # rspec failure tracking
11
11
  .rspec_status
12
+ Gemfile.lock
data/README.md CHANGED
@@ -1,6 +1,12 @@
1
1
  # Middleman::SocialImage
2
2
 
3
- Use HTML and CSS to dynamically generate static images for Open Graph (Facebook, LinkedIn) and Twitter cards in a Middleman application. Image is generated by using Google Chrome in headless mode to screenshot a page served by middleman. Originally created for [tokyodev](https://www.tokyodev.com/), which lists internationally-friendly software developer jobs in Japan.
3
+ Use HTML and CSS to generate images when building your Middleman site. The intended use case is for generating images for use with [the Open Graph protocol](https://ogp.me/), which will be included when someone shares your page on Facebook, Twitter, etc.
4
+
5
+ Example of an image generated with this extension:
6
+
7
+ ![](https://www.tokyodev.com/2020/05/29/generating-social-images-with-static-site-generators/social-image-714b5c6e.png)
8
+
9
+ For more background, see [generating social images with static site generators](https://www.tokyodev.com/2020/05/29/generating-social-images-with-static-site-generators/).
4
10
 
5
11
  ## Installation
6
12
 
@@ -26,7 +32,6 @@ Optionally, you can configure this extension with the following (defaults are sh
26
32
  activate :social_image do |social_image|
27
33
  social_image.window_size = '1200,600' # The size of the screenshot
28
34
  social_image.selector = 'body > *' # Used to test that the social image url has loaded properly. The more specific this is, the better the chance of catching errors.
29
- social_image.always_generate = true # Always regenerate images. Takes a long time, but ensures any changes are reflected.
30
35
  social_image.parallel = true # Generate images in parallel.
31
36
  social_image.base_url = "http://localhost:4567/" # When building the site, fetch against this URL.
32
37
  end
@@ -42,4 +47,4 @@ end
42
47
 
43
48
  You can now refer to this image as normal within your middleman application.
44
49
 
45
- In preview mode, you don't need any other special setup. However, to generate the images in build, you also need to be running the preview server. While you can use `bundle exec middleman server`, using a concurrent server like puma can speed up the generation incredibly.
50
+ In preview mode, you don't need any other special setup. However, to generate the images in build, you also need to be running the preview server. While you can use `bundle exec middleman server`, using a concurrent server like puma can speed up the generation incredibly. To do this, you'll need to [create a config.ru file](https://middlemanapp.com/basics/start-new-site/#config-ru).
@@ -1,10 +1,9 @@
1
1
  require "middleman-social_image/capybara"
2
2
  class Middleman::SocialImage::Converter
3
- def initialize(app, window_size, selector, always_generate, base_url)
3
+ def initialize(app, window_size, selector, base_url)
4
4
  @app = app
5
5
  @window_size = window_size
6
6
  @selector = selector
7
- @always_generate = always_generate
8
7
  @base_url = base_url
9
8
  end
10
9
 
@@ -14,15 +13,11 @@ class Middleman::SocialImage::Converter
14
13
 
15
14
  def convert(resource)
16
15
  image_path = image_path(resource)
17
- if File.exist?(image_path) && !@always_generate
18
- @app.logger.debug "== social_image: skipping #{resource.path} as already in cache"
19
- else
20
- @app.logger.debug "== social_image: converting #{resource.path}"
21
- session.visit(File.join(@base_url, resource.url))
22
- raise "#{resource.url} did not contain '#{@selector}'." unless session.has_selector?(@selector)
23
- FileUtils.mkdir_p(File.dirname(image_path))
24
- session.save_screenshot(image_path)
25
- end
16
+ @app.logger.debug "== social_image: converting #{resource.path}"
17
+ session.visit(File.join(@base_url, resource.url))
18
+ raise "#{resource.url} did not contain '#{@selector}'." unless session.has_selector?(@selector)
19
+ FileUtils.mkdir_p(File.dirname(image_path))
20
+ session.save_screenshot(image_path)
26
21
  end
27
22
 
28
23
  private
@@ -3,7 +3,6 @@ require 'middleman-core'
3
3
  class Middleman::SocialImage::Extension < ::Middleman::Extension
4
4
  option :window_size, '1200,600'
5
5
  option :selector, "body > *"
6
- option :always_generate, true
7
6
  option :parallel, true
8
7
  option :base_url, "http://localhost:4567/"
9
8
 
@@ -11,7 +10,7 @@ class Middleman::SocialImage::Extension < ::Middleman::Extension
11
10
  super
12
11
  require "middleman-social_image/converter"
13
12
  require "middleman-social_image/resource"
14
- @converter = Middleman::SocialImage::Converter.new(app, options.window_size, options.selector, options.always_generate, options.base_url)
13
+ @converter = Middleman::SocialImage::Converter.new(app, options.window_size, options.selector, options.base_url)
15
14
  end
16
15
 
17
16
  def manipulate_resource_list(resources)
@@ -1,5 +1,5 @@
1
1
  module Middleman
2
2
  module SocialImage
3
- VERSION = '0.0.5'.freeze
3
+ VERSION = '0.0.6'.freeze
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: middleman-social_image
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.5
4
+ version: 0.0.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Paul McMahon
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-05-27 00:00:00.000000000 Z
11
+ date: 2020-06-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: middleman-core