middleman-social_image 0.0.4 → 0.0.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
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 24790c8f3ad949cc2ca924415717b87da699d84f3136d0a7c9249807f17cb3a7
|
4
|
+
data.tar.gz: fe114cadc47468ecc7839a261628814214158718628b659709ead92c3f14d654
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3858b4cbad63083aa173072fe9e316bd19f1d5bc6de862daf5e4173b9fdc979129d6807b40b73670ee9c8c34c8dfc512276ba81fc41b754c7ca14773daa223be
|
7
|
+
data.tar.gz: ceee24fb84151157e046dabc916c4eecaf6263ac2e6b30426e7cb153bc79d7f1c303bf1dc8d8917da617174b4341ae3d51252174203e986de26bf27572f95175
|
data/README.md
CHANGED
@@ -28,6 +28,7 @@ activate :social_image do |social_image|
|
|
28
28
|
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
29
|
social_image.always_generate = true # Always regenerate images. Takes a long time, but ensures any changes are reflected.
|
30
30
|
social_image.parallel = true # Generate images in parallel.
|
31
|
+
social_image.base_url = "http://localhost:4567/" # When building the site, fetch against this URL.
|
31
32
|
end
|
32
33
|
```
|
33
34
|
|
@@ -41,4 +42,4 @@ end
|
|
41
42
|
|
42
43
|
You can now refer to this image as normal within your middleman application.
|
43
44
|
|
44
|
-
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
|
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.
|
@@ -1,10 +1,11 @@
|
|
1
1
|
require "middleman-social_image/capybara"
|
2
2
|
class Middleman::SocialImage::Converter
|
3
|
-
def initialize(app, window_size, selector, always_generate)
|
3
|
+
def initialize(app, window_size, selector, always_generate, base_url)
|
4
4
|
@app = app
|
5
5
|
@window_size = window_size
|
6
6
|
@selector = selector
|
7
7
|
@always_generate = always_generate
|
8
|
+
@base_url = base_url
|
8
9
|
end
|
9
10
|
|
10
11
|
def image_path(resource)
|
@@ -17,7 +18,7 @@ class Middleman::SocialImage::Converter
|
|
17
18
|
@app.logger.debug "== social_image: skipping #{resource.path} as already in cache"
|
18
19
|
else
|
19
20
|
@app.logger.debug "== social_image: converting #{resource.path}"
|
20
|
-
session.visit(resource.url)
|
21
|
+
session.visit(File.join(@base_url, resource.url))
|
21
22
|
raise "#{resource.url} did not contain '#{@selector}'." unless session.has_selector?(@selector)
|
22
23
|
FileUtils.mkdir_p(File.dirname(image_path))
|
23
24
|
session.save_screenshot(image_path)
|
@@ -32,8 +33,6 @@ class Middleman::SocialImage::Converter
|
|
32
33
|
rack_app = ::Middleman::Rack.new(@app).to_app
|
33
34
|
session = Capybara::Session.new(:selenium_chrome_headless, rack_app)
|
34
35
|
else
|
35
|
-
protocol = @app.config.https ? "https" : "http"
|
36
|
-
Capybara.app_host = "#{protocol}://localhost:#{@app.config.port}/"
|
37
36
|
session = Capybara::Session.new(:selenium_chrome_headless)
|
38
37
|
end
|
39
38
|
session.current_window.resize_to(*@window_size.split(","))
|
@@ -5,12 +5,13 @@ class Middleman::SocialImage::Extension < ::Middleman::Extension
|
|
5
5
|
option :selector, "body > *"
|
6
6
|
option :always_generate, true
|
7
7
|
option :parallel, true
|
8
|
+
option :base_url, "http://localhost:4567/"
|
8
9
|
|
9
10
|
def initialize(app, options_hash={}, &block)
|
10
11
|
super
|
11
12
|
require "middleman-social_image/converter"
|
12
13
|
require "middleman-social_image/resource"
|
13
|
-
@converter = Middleman::SocialImage::Converter.new(app, options.window_size, options.selector, options.always_generate)
|
14
|
+
@converter = Middleman::SocialImage::Converter.new(app, options.window_size, options.selector, options.always_generate, options.base_url)
|
14
15
|
end
|
15
16
|
|
16
17
|
def manipulate_resource_list(resources)
|
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.
|
4
|
+
version: 0.0.5
|
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-
|
11
|
+
date: 2020-05-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: middleman-core
|