Skip to content

Commit e190028

Browse files
committed
Issue #41: Prepare for thumbnails to work.
1 parent 4246e46 commit e190028

File tree

62 files changed

+135
-36
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

62 files changed

+135
-36
lines changed

.github/workflows/github-pages.yml

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
# GitHub Action for Jekyll
2+
#
3+
# Runs jekyll build on master and pushes output to gh-pages branch.
4+
# (Then GitHub deploys that static content.)
5+
6+
name: Build & Deploy to GitHub Pages
7+
8+
on:
9+
push:
10+
branches:
11+
- master
12+
13+
jobs:
14+
github-pages:
15+
runs-on: ubuntu-latest
16+
container: ruby:2-buster
17+
steps:
18+
- uses: actions/checkout@v2
19+
- uses: actions/cache@v1
20+
with:
21+
path: site/vendor/bundle
22+
key: ${{ runner.os }}-gems-${{ hashFiles('**/Gemfile.lock') }}
23+
24+
- name: Install Ruby dependencies.
25+
run: |
26+
gem install bundler
27+
bundle install
28+
working-directory: site
29+
30+
- name: Build static site with Jekyll.
31+
run: bundle exec jekyll build
32+
working-directory: site
33+
34+
- name: Deploy static site to gh-pages branch.
35+
uses: peaceiris/actions-gh-pages@v3
36+
with:
37+
github_token: ${{ secrets.GITHUB_TOKEN }}
38+
publish_dir: ./site/_site

CONTRIBUTING.md

Lines changed: 2 additions & 2 deletions

Gemfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,4 @@ source "https://rubygems.org"
55
git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
66

77
gem 'github-pages', group: :jekyll_plugins
8+
gem "smartcropper", "~> 0.7.1"

Gemfile.lock

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -222,6 +222,7 @@ GEM
222222
rb-inotify (0.10.1)
223223
ffi (~> 1.0)
224224
rexml (3.2.4)
225+
rmagick (4.1.2)
225226
rouge (3.23.0)
226227
ruby-enum (0.8.0)
227228
i18n
@@ -238,6 +239,8 @@ GEM
238239
faraday (> 0.8, < 2.0)
239240
simpleidn (0.1.1)
240241
unf (~> 0.1.4)
242+
smartcropper (0.7.1)
243+
rmagick (> 2.11.0)
241244
terminal-table (1.8.0)
242245
unicode-display_width (~> 1.1, >= 1.1.1)
243246
thread_safe (0.3.6)
@@ -256,6 +259,7 @@ PLATFORMS
256259

257260
DEPENDENCIES
258261
github-pages
262+
smartcropper (~> 0.7.1)
259263

260264
BUNDLED WITH
261265
2.1.4

_cards_adapter/exacq-ti-xio3130-2-port-pcie-switch.md

Lines changed: 1 addition & 1 deletion

_cards_adapter/hlt-1x-16x-extension-cable.md

Lines changed: 1 addition & 1 deletion

_cards_adapter/iocrest-si-pex60016-2-port-pcie-switch.md

Lines changed: 1 addition & 1 deletion

_cards_adapter/pce164p-no3-ver-006-riser.md

Lines changed: 1 addition & 1 deletion

_cards_adapter/pce164p-no3-ver-888-riser.md

Lines changed: 1 addition & 1 deletion

_cards_adapter/pce164p-no6-ver-008s-riser.md

Lines changed: 1 addition & 1 deletion

_cards_gpu/evga-geforce-gtx-750ti.md

Lines changed: 1 addition & 1 deletion

_cards_gpu/sapphire-radeon-rx550-2gb.md

Lines changed: 1 addition & 1 deletion

_cards_gpu/visiontek-radeon-5450-1gb.md

Lines changed: 1 addition & 1 deletion

_cards_gpu/zotac-geforce-gt710-1gb.md

Lines changed: 1 addition & 1 deletion

_cards_m2/mzhou-nvme-m2-ssd-m-key-adapter.md

Lines changed: 1 addition & 1 deletion

_cards_m2/ngff-m-key-ssd-adapter.md

Lines changed: 1 addition & 1 deletion

_cards_m2/xiwai-ngff-m-key-m2-ssd-adapter.md

Lines changed: 1 addition & 1 deletion

_cards_network/asus-pce-ac51-wifi-5.md

Lines changed: 1 addition & 1 deletion

_cards_network/asus-xg-c100c-10g.md

Lines changed: 1 addition & 1 deletion

_cards_network/edup-intel-ax200-wifi-6.md

Lines changed: 1 addition & 1 deletion

_cards_network/intel-i340-t4-4-port-1g.md

Lines changed: 1 addition & 1 deletion

_cards_network/mellanox-connectx-2-mnpa19-xtr-sfp-10g.md

Lines changed: 1 addition & 1 deletion

_cards_network/rosewill-rc20001-25gbe.md

Lines changed: 1 addition & 1 deletion

_cards_storage/asm1061-2-port-adapter.md

Lines changed: 1 addition & 1 deletion

_cards_storage/ibm-servraid-br10i-lsi-sas3082e-r-sas-raid.md

Lines changed: 1 addition & 1 deletion

_cards_storage/iocrest-sata-3-marvell-9215.md

Lines changed: 1 addition & 1 deletion

_cards_storage/teratrend-2-port-sata-3-marvell-88se9130.md

Lines changed: 1 addition & 1 deletion

_cards_usb/a-adwits-vl805.md

Lines changed: 1 addition & 1 deletion

_cards_usb/inateck-pcie-usb3.md

Lines changed: 1 addition & 1 deletion

_cards_usb/syba-sd-pex20199.md

Lines changed: 1 addition & 1 deletion

_config.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ theme: jekyll-theme-slate
33
title: Raspberry Pi PCIe Devices
44
url: https://pipci.jeffgeerling.com/
55
fathom_analytics: true
6+
67
collections:
78
cards_adapter:
89
output: true

_layouts/card.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ <h1 id="card_title">{{ page.title }}</h1>
3333

3434
<div class="card_picture">
3535
{% if page.picture %}
36-
<a href="/images/card-pictures/{{ page.picture }}"><img src="/images/card-pictures/{{ page.picture }}" alt="{{ page.title }}"></a>
36+
<a href="{{ page.picture }}"><img src="{{ page.picture }}" alt="{{ page.title }}"></a>
3737
{% else %}
3838
<p><em>There is no picture for this card yet.</em></p>
3939
{% endif %}

_plugins/image_thumbnail.rb

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# image_thumbnail.rb
2+
3+
module Jekyll
4+
module ImageThumbnail
5+
def image_thumbnail(input)
6+
input.sub("/images/", "/images/thumbnail/")
7+
end
8+
end
9+
end
10+
11+
Liquid::Template.register_filter(Jekyll::ImageThumbnail)

_plugins/post_thumbnail_generator.rb

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
# post_thumbnail_generator.rb
2+
require "smartcropper"
3+
4+
module Jekyll
5+
6+
class PostThumbnailImage < StaticFile
7+
def initialize(site, base, dir, name)
8+
@site = site
9+
@base = base
10+
@dir = dir
11+
@dest_dir = File.join("images", "thumbnail")
12+
@name = name
13+
end
14+
15+
def destination(dest)
16+
File.join(dest, @dest_dir, @name)
17+
end
18+
19+
def write(dest)
20+
dest_path = destination(dest)
21+
22+
return false if File.exist?(dest_path) and !modified?
23+
@@mtimes[path] = mtime
24+
25+
FileUtils.mkdir_p(File.dirname(dest_path))
26+
SmartCropper.from_file(path).smart_crop_and_scale(200, 200).write(dest_path)
27+
28+
true
29+
end
30+
end
31+
32+
class PostThumbnailGenerator < Generator
33+
def generate(site)
34+
# TODO: cards_m2, cards_network, cards_storage, etc...
35+
site.cards_gpu.each {|post|
36+
if post.data.has_key?("picture")
37+
site.static_files << PostThumbnailImage.new(site, site.source, "_images", File.basename(post.data["image"]))
38+
end
39+
}
40+
end
41+
end
42+
43+
end

card-template.md

Lines changed: 1 addition & 1 deletion

0 commit comments

Comments
 (0)