This commit is contained in:
Kameron Kenny 2024-07-01 08:55:21 -04:00
parent b2dbf8e2ef
commit 5b8278491b
No known key found for this signature in database
GPG Key ID: E5006629839D2276
18 changed files with 2837 additions and 1 deletions

28
Gemfile Normal file
View File

@ -0,0 +1,28 @@
source "https://rubygems.org"
# Hello! This is where you manage which Jekyll version is used to run.
# When you want to use a different version, change it below, save the
# file and run `bundle install`. Run Jekyll with `bundle exec`, like so:
#
# bundle exec jekyll serve
#
# This will help ensure the proper Jekyll version is running.
# Happy Jekylling!
gem "jekyll", "~> 3.6.0"
# # This is the default theme for new Jekyll sites. You may change this to anything you like.
# gem "minima", "~> 2.0"
# If you want to use GitHub Pages, remove the "gem "jekyll"" above and
# uncomment the line below. To upgrade, run `bundle update github-pages`.
# gem "github-pages", group: :jekyll_plugins
# If you have any plugins, put them here!
group :jekyll_plugins do
gem "jekyll-feed", "~> 0.6"
end
# Windows does not include zoneinfo files, so bundle the tzinfo-data gem
gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby]
gem 'jekyll-gallery-generator'

View File

@ -1,2 +1,56 @@
# photos.kameronkenny.com
# Jekyll Photo Gallery
I want to share my jekyll photo gallery, simple, functional, mobile friendly and most essential, pretty! The gallery is based on the design from [Henrrique Gusso](https://gus.so/) and utilizes the [jekyll gallery generator plugin](https://github.com/ggreer/jekyll-gallery-generator) to do most of the heavy lifting (with some minor changes).
![Example Image](https://i.imgur.com/vpmSx7S.png "Optional title")
## Dependencies
(copied from the plugin repo)
* [ImageMagick](http://www.imagemagick.org/)
* [RMagick](https://github.com/rmagick/rmagick)
* [exifr](https://github.com/remvee/exifr/)
* [Ruby](https://www.ruby-lang.org) >= 2.1
### Install dependencies on OS X
```bash
brew install imagemagick rbenv
rbenv install 2.4.0
rbenv global 2.4.0
gem install rmagick exifr
```
### Install dependencies on Ubuntu
```bash
apt install libmagick++-dev
gem install rmagick exifr
```
## Configuration
This plugin reads several config options from `_config.yml`. The following options are supported (default settings are shown):
```yaml
# The following options are for individual galleries.
gallery:
dir: photos # root folder with all the pictures
title: "Photos"
sort_field: "date" # sort pictures by date
title_prefix: "" # title prefix
symlink: false # false: copy images into _site. true: create symbolic links (saves disk space)
thumbnail_size: #
y: 450 #
retina: 1.5 #
galleries:
2017_Berlin: # folder name
name: "Berlin" # gallery name
date: "2017/08/01" # gallery date
best_image: 0062.jpg # best photo for gallery blur image and gallery index
```
## Thanks to
* The people behind jekyll project
* [Geoff Greer](https://github.com/ggreer) for the script
* [Gusso](https://github.com/gusso) for the design

176
_config.yml Normal file
View File

@ -0,0 +1,176 @@
title: Daniel Andrade Photo Gallery
email: daniel@danielandrade.net
description: >- # this means to ignore newlines until "baseurl:"
My own little photo gallery
baseurl: "" # the subpath of your site, e.g. /blog
url: "" # the base hostname & protocol for your site, e.g. http://example.com
twitter_username: dspillere
github_username: dansku
exclude: [node_modules, Gemfile, Gemfile.lock, gulpfile.js, deploy.sh, README.md, index.md, .gitignore]
#--------------------------------------------
gallery:
dir: photos
title: "Photos"
sort_field: "date"
title_prefix: ""
symlink: false # false: copy images into _site. true: create symbolic links (saves disk space)
thumbnail_size:
y: 450
retina: 1.5
# The following options are for individual galleries.
gallery:
dir: photos
title: "Photos"
sort_field: "date"
thumbnail_size:
y: 450
retina: 1.5
galleries:
2017_Canada:
name: "West Coast & Cadanad"
date: "2017/10/01"
best_image: 0191.jpg
2017_Berlin:
name: "Berlin"
date: "2017/08/01"
best_image: 0062.jpg
2017_Istanbul:
name: "Istanbul"
date: "2017/03/18"
best_image: 0008.jpg
2017_USA:
name: "USA"
date: "2017/01/01"
best_image: 0013.jpg
2016_Iceland:
name: "Iceland"
date: "2016/11/16"
best_image: 0020.jpg
2016_Romania:
name: "Romania"
date: "2016/11/05"
best_image: 0022.jpg
2016_Prague:
name: "Prague"
date: "2016/07/13"
best_image: 0015.jpg
2016_London:
name: "London"
date: "2016/04/15"
best_image: 0008.jpg
2016_Thailand:
name: "Thailand"
date: "2016/02/02"
best_image: 0033.jpg
2015_Las_Vegas_and_LA:
name: "Vegas & LA"
date: "2016/01/01"
best_image: 0048.jpg
2015_Suomi:
name: "Suomi"
date: "2015/12/12"
best_image: "0004.jpg"
2015_Dublin:
name: "Dublin 2015"
date: "2015/10.12"
best_image: 0014.jpg
2015_Makerfaire_Berlin:
name: "Makerfaire Berlin"
date: "2015/10/01"
best_image: 0001.jpg
2015_Great_Ocean_Road:
name: "Great Ocean Road"
date: "2015/08/12"
best_image: 0031.jpg
2015_Thailand:
name: "Thailand"
date: "2015/07/12"
best_image: 0069.jpg
2015_Perth:
name: "Perth"
date: "2015/06/12"
best_image: 0038.jpg
2015_Melbourne:
name: "Melbourne"
date: "2015/02/12"
best_image: 0031.jpg
2014_USA:
name: "USA"
date: "2014/10/12"
best_image: 0028.jpg
2014_South_America:
name: "South America"
date: "2014/08/12"
best_image: 0077.jpg
2014_EuroTrip:
name: "EuroTrip"
date: "2014/07/12"
best_image: 0040.jpg
2014_Gravata:
name: "Gravata"
date: "2014/06/12"
best_image: 0003.jpg
2014_Road_To_Patagonia:
name: "Road To Patagonia"
date: "2014/01/12"
best_image: 0038.jpg
2013_Finados_Cemiterio:
name: "Finados"
date: "2013/10/12"
best_image: 0007.jpg
2012_Milano_Design_Week:
name: "Milano Design Week"
date: "2012/10/12"
best_image: 0017.jpg
2012_Road_Trip_Around_Italy:
name: "Road Trip Around Italy"
date: "2013/09/12"
best_image: 0038.jpg
2012_Paris:
name: "Paris"
date: "2012/02/12"
best_image: 0011.jpg
2012_Rome:
name: "Rome"
date: "2012/01/12"
best_image: 0040.jpg
2012_Monaco:
name: "Monaco"
date: "2012/01/10"
best_image: 0012.jpg
2011_Budapest_and_Praga:
name: "Budapest & Praga"
date: "2011/06/12"
best_image: 0031.jpg
2011_Brasil_Papaya:
name: "Brasil Papaya"
date: "2011/10/12"
best_image: 0018.jpg
2011_Arduino_Macro:
name: "Arduino Macros"
date: "2011/10/14"
best_image: 0004.jpg
2010_Scandinavia:
name: "Scandinavia"
date: "2010/12/10"
best_image: 0008.jpg
2009_New_York:
name: "New York"
date: "2009/03/10"
best_image: 0004.jpg
2007_Argentina_and_Chile:
name: "Argentina & Chile"
date: "2007/12/12"
best_image: 0070.jpg
Tarrafa_Hackerspace:
name: "Tarrafa Hackerspace"
date: "2014/09/12"
best_image: 0012.jpg
PCB_Projects:
name: "PCB Projects"
date: "2007/10/10"
best_image: 0016.jpg

2264
_includes/assets/gallery.css Normal file

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

1
_includes/assets/gallery.min.css vendored Normal file

File diff suppressed because one or more lines are too long

4
_includes/footer.html Normal file
View File

@ -0,0 +1,4 @@
<script src="//danielandrade.net/gallery.js"></script>
</body>
</html>

30
_includes/header.html Normal file
View File

@ -0,0 +1,30 @@
<!doctype html>
<html lang=en>
<head>
<meta charset="utf-8">
<title>{{ page.title }}</title>
<meta name="viewport" content="
width=device-width,
user-scalable=no,
initial-scale=1,
minimum-scale=1,
maximum-scale=1">
<link href='//fonts.googleapis.com/css?family=Roboto:400,900' rel='stylesheet' type='text/css'>
<script type="text/javascript" src="//cdnjs.cloudflare.com/ajax/libs/jquery.lazy/1.7.4/jquery.lazy.min.js"></script>
<link rel="stylesheet" href="//danielandrade.net/gallery.css">
</head>
<body>
<script type="text/javascript">
$(function() {
$('.lazy').lazy({
effect: "fadeIn",
effectTime: 2000,
threshold: 0
});
});
</script>
{% include svg_shadow.html %}

View File

@ -0,0 +1,3 @@
<svg viewBox="0 0 20 40">
<polyline points="20,0 0,20 20,40"/>
</svg>

After

Width:  |  Height:  |  Size: 71 B

View File

@ -0,0 +1,3 @@
<svg viewBox="0 0 20 40">
<polyline points="20,0 0,20 20,40" filter="url(#shadow)"/>
</svg>

After

Width:  |  Height:  |  Size: 93 B

View File

@ -0,0 +1,3 @@
<svg viewBox="0 0 20 40">
<polyline points="0,0 20,20 0,40" filter="url(#shadow)"/>
</svg>

After

Width:  |  Height:  |  Size: 92 B

6
_includes/svg_close.html Normal file
View File

@ -0,0 +1,6 @@
<svg viewBox="0 0 30 30">
<g filter="url(#shadow)">
<line x1="0" y1="0" x2="30" y2="30" />
<line x1="0" y1="30" x2="30" y2="0" />
</g>
</svg>

After

Width:  |  Height:  |  Size: 153 B

View File

@ -0,0 +1,3 @@
<svg viewBox="0 0 50 50">
<path d="M25,0C11.2,0,0,11.2,0,25s11.2,25,25,25s25-11.2,25-25 c0-6.9-2.8-13.2-7.3-17.7"/>
</svg>

After

Width:  |  Height:  |  Size: 128 B

View File

@ -0,0 +1,8 @@
<svg class="shadow">
<defs>
<filter id="shadow">
<feOffset result="offOut" in="SourceAlpha" dy="2" />
<feBlend in="SourceGraphic" in2="offOut" mode="normal" />
</filter>
</defs>
</svg>

After

Width:  |  Height:  |  Size: 208 B

View File

@ -0,0 +1,22 @@
{% include header.html %}
<div id="gallery-list">
{% for gallery in page.galleries %}
<a href="{{ gallery['gallery'] }}">
<div class="img-container">
<div class="img" style="
background: url('{{ gallery['gallery'] }}/thumbs/{{ gallery['best_image'] }}') no-repeat center center;
background-size: cover;
"></div>
</div>
<div class="container">
<span class="title">{{ gallery["name"] }}</span>
<span class="date">{{ gallery["date"] | date: "%Y" }}</span>
</div>
</a>
{% endfor %}
</div>
{% include footer.html %}

View File

@ -0,0 +1,42 @@
{% include header.html %}
<a id="gallery-back" href="/photos">
{% include svg_arrow_back.html %}
<span>ALBUMS</span>
</a>
<h1 id="gallery-header">
<div class="container">
<a href="/{{ site.gallery.dir }}/{{ page.gallery }}">{{ page.title }}</a>
<span class="date">{{ page.date | date: "%Y" }}</span>
</div>
<img id="bg-loader" src="thumbs/{{ page.blur_image }}">
<div id="bg-source" style="background:url(thumbs/{{ page.blur_image }})"></div>
<div id="bg-wrapper"></div>
</h1>
<div id="zoom">
<div class="controls">
<a class="close">{% include svg_close.html %}</a>
<a class="arrow left">{% include svg_arrow_left.html %}</a>
<a class="arrow right">{% include svg_arrow_right.html %}</a>
</div>
<div class="container"></div>
<div class="loading">{% include svg_loading.html %}</div>
</div>
{% assign sorted_imgs = page.images | sort %}
<div id="gallery">
{% for image in sorted_imgs %}
<a class="item lazy" href="{{ image[0] }}">
<img
src="thumbs/{{ image[0] }}"
data-src="thumbs/{{ image[0] }}"
width="{{ image[1] | divided_by: site.gallery.thumbnail_size.retina }}"
height="{{ site.gallery.thumbnail_size.y | divided_by: site.gallery.thumbnail_size.retina }}" />
</a>
{% endfor %}
</div>
{% include footer.html %}

View File

@ -0,0 +1,175 @@
require 'exifr'
require 'rmagick'
include Magick
include FileUtils
$image_extensions = [".png", ".jpg", ".jpeg", ".gif"]
module Jekyll
class GalleryFile < StaticFile
def write(dest)
return false
end
end
class GalleryIndex < Page
def initialize(site, base, dir, galleries)
@site = site
@base = base
@dir = dir.gsub("source/", "")
@name = "index.html"
config = site.config["gallery"] || {}
self.process(@name)
self.read_yaml(File.join(base, "_layouts"), "gallery_index.html")
self.data["title"] = config["title"]
self.data["galleries"] = []
sort_field = config["sort_field"]
galleries.sort! {|a,b| b.data[sort_field] <=> a.data[sort_field]}
if config["sort_reverse"]
galleries.reverse!
end
galleries.each {|gallery|
unless gallery.hidden
self.data["galleries"].push(gallery.data)
end
}
end
end
class GalleryPage < Page
attr_reader :hidden
def initialize(site, base, dir, gallery_name)
@site = site
@base = base
@dest_dir = dir.gsub("source/", "")
@dir = @dest_dir
@name = "index.html"
@images = []
@hidden = false
config = site.config["gallery"] || {}
gallery_config = {}
max_size_x = 400
max_size_y = 400
symlink = config["symlink"] || false
scale_method = config["scale_method"] || "fit"
begin
max_size_x = config["thumbnail_size"]["x"]
rescue
end
begin
max_size_y = config["thumbnail_size"]["y"]
rescue
end
begin
gallery_config = config["galleries"][gallery_name] || {}
rescue
end
self.process(@name)
self.read_yaml(File.join(base, "_layouts"), "gallery_page.html")
self.data["gallery"] = gallery_name
gallery_name = gallery_name.gsub("_", " ").gsub(/\w+/) {|word| word.capitalize}
begin
gallery_name = gallery_config["name"] || gallery_name
rescue
end
self.data["date"] = gallery_config["date"]
self.data["name"] = gallery_name
self.data["title"] = "#{gallery_name}"
thumbs_dir = File.join(site.dest, @dest_dir, "thumbs")
begin
@hidden = gallery_config["hidden"] || false
rescue
end
if @hidden
self.data["sitemap"] = false
end
FileUtils.mkdir_p(thumbs_dir, :mode => 0755)
Dir.foreach(dir) do |image|
next if image.chars.first == "."
next unless image.downcase().end_with?(*$image_extensions)
@site.static_files << GalleryFile.new(site, base, File.join(@dest_dir, "thumbs"), image)
image_path = File.join(dir, image)
if symlink
link_src = site.in_source_dir(image_path)
link_dest = site.in_dest_dir(image_path)
@site.static_files.delete_if { |sf|
sf.relative_path == "/" + image_path
}
@site.static_files << GalleryFile.new(site, base, dir, image)
if File.exists?(link_dest) or File.symlink?(link_dest)
if not File.symlink?(link_dest)
puts "#{link_dest} exists but is not a symlink. Deleting."
File.delete(link_dest)
elsif File.readlink(link_dest) != link_src
puts "#{link_dest} points to the wrong file. Deleting."
File.delete(link_dest)
end
end
if not File.exists?(link_dest) and not File.symlink?(link_dest)
puts "Symlinking #{link_src} -> #{link_dest}"
File.symlink(link_src, link_dest)
end
end
thumb_path = File.join(thumbs_dir, image)
if File.file?(thumb_path) == false or File.mtime(image_path) > File.mtime(thumb_path)
begin
m_image = ImageList.new(image_path)
m_image.send("resize_to_#{scale_method}!", max_size_x, max_size_y)
puts "Writing thumbnail to #{thumb_path}"
m_image.write(thumb_path) { self.quality = 60 }
rescue e
puts "Error generating thumbnail for #{image_path}: #{e}"
puts e.backtrace
end
GC.start
end
img = Magick::Image.read(thumb_path).first
width = img.columns
@images.push([image, width])
end
site.static_files = @site.static_files
self.data["images"] = @images
self.data["best_image"] = gallery_config["best_image"]
self.data["blur_image"] = gallery_config["blur_image"] || gallery_config["best_image"]
end
end
class GalleryGenerator < Generator
safe true
def generate(site)
config = site.config["gallery"] || {}
dir = config["dir"] || "photos"
galleries = []
begin
Dir.foreach(dir) do |gallery_dir|
gallery_path = File.join(dir, gallery_dir)
if File.directory?(gallery_path) and gallery_dir.chars.first != "."
gallery = GalleryPage.new(site, site.source, gallery_path, gallery_dir)
gallery.render(site.layouts, site.site_payload)
gallery.write(site.dest)
site.pages << gallery
galleries << gallery
end
end
rescue Exception => e
puts "Error generating galleries: #{e}"
puts e.backtrace
end
gallery_index = GalleryIndex.new(site, site.source, dir, galleries)
gallery_index.render(site.layouts, site.site_payload)
gallery_index.write(site.dest)
site.pages << gallery_index
end
end
end

6
index.md Normal file
View File

@ -0,0 +1,6 @@
---
# You don't need to edit this file, it's empty on purpose.
# Edit theme's home layout instead if you wanna make some changes
# See: https://jekyllrb.com/docs/themes/#overriding-theme-defaults
layout: home
---