initial commit of gallery framework
This commit is contained in:
parent
b90b77858f
commit
a5c200d038
7 changed files with 158 additions and 8 deletions
89
_bin/make_gallery.rb
Executable file
89
_bin/make_gallery.rb
Executable file
|
@ -0,0 +1,89 @@
|
|||
#!/usr/bin/env ruby
|
||||
|
||||
puts "Gallery title?"
|
||||
gallery_title = gets.chomp
|
||||
gallery_slug = gallery_title.downcase.strip.gsub(' ', '-').gsub(/[^\w-]/, '')
|
||||
|
||||
puts "Getting jpg images for gallery."
|
||||
@images = Dir.glob("#{Dir.pwd}/*.jpg")
|
||||
|
||||
Dir.mkdir gallery_slug
|
||||
|
||||
@names = Array.new
|
||||
|
||||
@images.each do |image|
|
||||
basename = File.basename(image, '.jpg')
|
||||
@names.push(basename)
|
||||
puts "Resizing #{basename}."
|
||||
thumb = "convert #{image} -filter Lanczos -sampling-factor 1x1 -unsharp 1.5x1+0.7+0.02 -quality 90 -resize 300x300 -set filename:f \"%t_t\" './#{gallery_slug}/%[filename:f].jpg'"
|
||||
`#{thumb}`
|
||||
mid = "convert #{image} -filter Lanczos -sampling-factor 1x1 -unsharp 1.5x1+0.7+0.02 -quality 90 -resize 1300x1300 -set filename:f \"%t_m\" './#{gallery_slug}/%[filename:f].jpg'"
|
||||
`#{mid}`
|
||||
full = "convert #{image} -filter Lanczos -sampling-factor 1x1 -unsharp 1.5x1+0.7+0.02 -quality 90 -resize 2500x2500 -set filename:f \"%t\" './#{gallery_slug}/%[filename:f].jpg'"
|
||||
`#{full}`
|
||||
|
||||
puts "Making page for #{basename}."
|
||||
page_text = <<END
|
||||
---
|
||||
layout: default
|
||||
gallery-title: #{gallery_title}
|
||||
title:
|
||||
image-name: #{basename}
|
||||
---
|
||||
<article>
|
||||
<header>
|
||||
{% if page.gallery-title %}
|
||||
<p class="subheading"><a href="/photos">Photos</a> / <a href="../">{{page.gallery-title}}</a></p>
|
||||
{% endif %}
|
||||
|
||||
{% if page.photo-title %}
|
||||
<h1 class="post-title">{{page.photo-title}}</h1>
|
||||
{% endif %}
|
||||
</header>
|
||||
|
||||
<p>
|
||||
<a href="../#{basename}.jpg"><img src="../#{basename}_m.jpg" /></a>
|
||||
</p>
|
||||
|
||||
<p class="caption">#{basename}</p>
|
||||
</article>
|
||||
END
|
||||
File.open("./#{gallery_slug}/#{basename}.html", 'w') { |file| file.write(page_text) }
|
||||
|
||||
end
|
||||
|
||||
puts "Making gallery page."
|
||||
gallery_text = <<END
|
||||
---
|
||||
layout: default
|
||||
title: #{gallery_title}
|
||||
slug: #{gallery_slug}
|
||||
key-photo: #{@names.first}
|
||||
images:
|
||||
END
|
||||
|
||||
@names.each do |name|
|
||||
gallery_text += "- image_name: #{name}\n"
|
||||
end
|
||||
|
||||
gallery_text += <<END
|
||||
---
|
||||
|
||||
<article>
|
||||
<header>
|
||||
{% if page.gallery-title %}
|
||||
<h1 class="post-title">{{page.gallery-title}}</h1>
|
||||
{% endif %}
|
||||
</header>
|
||||
|
||||
<ul class="gallery">
|
||||
{% for image in page.images %}
|
||||
<li><a href="{{ page.url }}{{ image.image_name}}/"><img src="{{ page.url }}{{ image.image_name }}_t.jpg" /></a></li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
</article>
|
||||
END
|
||||
|
||||
File.open("./#{gallery_slug}/index.html", "w") { |file| file.write(gallery_text) }
|
||||
|
||||
puts "Gallery complete."
|
|
@ -18,6 +18,9 @@ permalink: /:year/:month/:title/
|
|||
exclude: ['Gemfile', 'Gemfile.lock']
|
||||
gems: ['jekyll-paginate']
|
||||
|
||||
# Special folders
|
||||
photos_folder: '/photos/'
|
||||
|
||||
# Build settings
|
||||
markdown: kramdown
|
||||
|
||||
|
|
|
@ -16,8 +16,8 @@
|
|||
<div class="footer-col footer-col-2">
|
||||
<ul class="footer-nav">
|
||||
<li><a href="/">Home</a></li>
|
||||
<li><a href="/about">About</a></h3></td>
|
||||
<li>Photos</li>
|
||||
<li><a href="/about">About</a></li>
|
||||
<li><a href="/photos">Photos</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -1,16 +1,12 @@
|
|||
<div class="site-header-blur"></div>
|
||||
<div id="site-header">
|
||||
|
||||
<header class="site-header">
|
||||
|
||||
<div class="site-logo">
|
||||
<a href="/"><img src="/static/logo.png" /></a>
|
||||
</div>
|
||||
<ul class="site-nav">
|
||||
<li><a href="/about">About</a></h3></td>
|
||||
<li>Photos</li>
|
||||
<li><a href="/about">About</a></li>
|
||||
<li><a href="/photos">Photos</a></li>
|
||||
</ul>
|
||||
|
||||
</header>
|
||||
|
||||
</div>
|
||||
|
|
5
_layouts/gallery-index.html
Normal file
5
_layouts/gallery-index.html
Normal file
|
@ -0,0 +1,5 @@
|
|||
---
|
||||
layout: default
|
||||
---
|
||||
|
||||
{{ page.index }}
|
41
_plugins/index_galleries.rb
Normal file
41
_plugins/index_galleries.rb
Normal file
|
@ -0,0 +1,41 @@
|
|||
module Jekyll
|
||||
class GalleryIndex < Page
|
||||
def initialize(site, base, dir, index)
|
||||
@site = site
|
||||
@base = base
|
||||
@dir = dir
|
||||
@name = 'index.html'
|
||||
|
||||
self.process(@name)
|
||||
self.read_yaml(File.join(base, '_layouts'), 'gallery-index.html')
|
||||
self.data['index'] = index
|
||||
end
|
||||
end
|
||||
class GenerateGalleryIndex < Generator
|
||||
safe true
|
||||
|
||||
def generate(site)
|
||||
galleryindex = <<END
|
||||
<article>
|
||||
<header>
|
||||
<h1 class="post-title">Photos</h1>
|
||||
</header>
|
||||
<ul>
|
||||
END
|
||||
@galleries = site.pages.select { |page|
|
||||
page.path =~ /^photos\/(.*)\/index.html$/ }
|
||||
@galleries.each { |gallery|
|
||||
galleryindex += <<END
|
||||
<li><a href="/photos/#{gallery.data['slug']}/">#{gallery.data['title']}</a></li>
|
||||
END
|
||||
}
|
||||
|
||||
galleryindex += <<END
|
||||
</ul>
|
||||
</article>
|
||||
END
|
||||
site.pages << GalleryIndex.new(site, site.source, 'photos', galleryindex)
|
||||
|
||||
end
|
||||
end
|
||||
end
|
|
@ -228,3 +228,19 @@
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
.gallery {
|
||||
list-style-type: none;
|
||||
}
|
||||
|
||||
.gallery li {
|
||||
float: left;
|
||||
padding: 10px;
|
||||
}
|
||||
|
||||
.gallery li img {
|
||||
width: 150px;
|
||||
@include media-query($on_palm) {
|
||||
width: 125px;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue