Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/tasks/derivatives_simple.rake
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ require 'wax_tasks'

namespace :wax do
namespace :derivatives do
desc 'generate iiif derivatives from local image files'
desc 'generate simple derivatives from local image files'
task :simple do
args = ARGV.drop(1).each { |a| task a.to_sym }
args.reject! { |a| a.start_with? '-' }
Expand Down
74 changes: 74 additions & 0 deletions lib/tasks/scaffold.rake
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
# frozen_string_literal: true

require 'wax_tasks'
require 'zip'
require 'byebug'

namespace :wax do
desc 'add basic scaffolding for Wax to an existing jekyll site'
namespace :scaffold do
task :resources do
config_text = File.read("#{Dir.pwd}/_config.yml")
config = YAML::safe_load(config_text)

# CORS stanza and "scaffolded" flags are added if this is the first run
unless config["scaffolded"]
new_config = {}

# Add CORS stanza to _config.yml, if missing
new_config["webrick"] = { "header" => { "Access-Control-Allow-Origin" => "*" } }

# add framework documents to jekyll, unless this has already been done
framework = File.join(File.dirname(File.expand_path(__FILE__)), '../../wax-framework/.')
cp_r framework, Dir.pwd
new_config["scaffolded"] = true

new_yaml = new_config.to_yaml.sub("---\n", "")
config_text.sub! "\ncollections:\n", "\n#{new_yaml}"

File.open("_config.yml", "w"){ |f| f.puts config_text }
end
end
task :collection do
args = ARGV.drop(1).each { |a| task a.to_sym }
args.reject! { |a| a.start_with? '-' }
raise WaxTasks::Error::MissingArguments, Rainbow('You must specify a collection after wax:scaffold').magenta if args.empty?

config_text = File.read("#{Dir.pwd}/_config.yml")
config = YAML::safe_load(config_text)

config_text += "\ncollections:\n" unless config["collections"]

new_config = {}

args.each do |coll|
# skip if this coll is already configured
Rainbow("Collection #{coll} is already configured.").magenta if config.dig("collections", coll)
next if config.dig("collections", coll)

# Make coll images dir and metadata csv file
mkdir_p "#{Dir.pwd}/_data/raw_images/#{coll}"
File.open("#{Dir.pwd}/_data/#{coll}.csv", 'w') { |file| file.write("pid,label\n") }

new_config["collections"] ||= {}

# Add coll to new config stanzas
new_config["collections"][coll] = {
"output" => true,
"layout" => "wax_item",
"metadata" => { "source" => "#{coll}.csv" },
"images" => { "source" => "raw_images/#{coll}" }
}
end

# insert new collection(s) at top of collections list
# if this is the first scaffold run, the webrick and scaffolded
# sections will be added after collections
new_yaml = new_config.to_yaml.sub("---\n", "")
config_text.sub! "\ncollections:\n", "\n#{new_yaml}"

File.open("_config.yml", "w"){ |f| f.puts config_text }

end
end
end
3 changes: 3 additions & 0 deletions wax-framework/Rakefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
spec = Gem::Specification.find_by_name 'wax_tasks'
Dir.glob("#{spec.gem_dir}/lib/tasks/*.rake").each { |r| load r }

15 changes: 15 additions & 0 deletions wax-framework/_includes/collection_gallery.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{% assign collection = site.data[include.collection] %}

{% for item in collection %}
{% capture url %}{{ item.collection }}/{{ item.pid }}.html{% endcapture %}
{% capture manifest %}/img/derivatives/iiif/{{ item.pid }}/manifest.json{% endcapture %}

<div class='gallery-item'>
<a href='{{ url | absolute_url }}'>
<img src='{{ item.thumbnail | absolute_url }}' alt='{{ item.label | escape }}'/>
<br/>
<strong>{{ item.label }}</strong>
</a>
<p>Manifest: <a href="{{ manifest | absolute_url }}">{{ manifest | absolute_url }}</a></p>
</div>
{% endfor %}
12 changes: 12 additions & 0 deletions wax-framework/_includes/head.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
{%- seo -%}
<link rel="stylesheet" href="{{ "/assets/main.css" | relative_url }}">
{%- feed_meta -%}
{%- if jekyll.environment == 'production' and site.google_analytics -%}
{%- include google-analytics.html -%}
{%- endif -%}
<script type='text/javascript' src="{{ '/assets/jquery-3.2.1.min.js' | absolute_url }}"></script>
</head>
31 changes: 31 additions & 0 deletions wax-framework/_includes/item_metadata.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<dl class='metadata-block'>
{% for item in include.meta %}
{% if item.value contains 'page.' %}
{% assign key = item.value | remove: 'page.' %}
{% assign value = page[key] %}
{% else %}
{% assign value = item.value %}
{% endif %}

{% comment %}
Only display non-empty values
{% endcomment %}
{% if value | strip != '' %}
{% if item.type == 'link' %}
{% if key == 'manifest' %}
{%- capture value -%}
<a href="{{ value | absolute_url }}" target="_blank" rel="noreferrer">{{ value | absolute_url }}</a>
{%- endcapture -%}
{% else %}
{%- capture value -%}
<a href="{{ value | absolute_url }}" target="_blank" rel="noreferrer">
{{ value | absolute_url | remove: 'https://' | remove: 'http://' | split: "/" | first }}
</a>
{%- endcapture -%}
{% endif %}
{% endif %}
<dt>{{ item.label }}</dt>
<dd>{{ value | strip }}</dd>
{% endif %}
{% endfor %}
</dl>
23 changes: 23 additions & 0 deletions wax-framework/_includes/item_pagination.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{% assign links = site[page.collection] | sort: 'order' | map: 'url' %}
{% for link in links %}
{% if link == page.url %}
{% if forloop.first %}
{% assign prevlink = links | last %}
{% assign nextlink = links[forloop.index] %}
{% elsif forloop.last %}
{% assign prevlink = prev %}
{% assign nextlink = links | first %}
{% else %}
{% assign prevlink = prev %}
{% assign nextlink = links[forloop.index] %}
{% endif %}
{% endif %}
{% assign prev = link %}
{% endfor %}

{% if prevlink and nextlink %}
<script type='text/javascript'>
$('#prevlink').append(`<a href='{{ prevlink | absolute_url }}' display='none'>&#8249;</a>`);
$('#nextlink').append(`<a href='{{ nextlink | absolute_url }}' display='none'>&#8250;</a>`);
</script>
{% endif %}
27 changes: 27 additions & 0 deletions wax-framework/_includes/osd_iiif_image_viewer.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<div id="osd" class="image-viewer"></div>
<script async defer src="{{ '/assets/openseadragon/openseadragon.min.js' | absolute_url }}"></script>

<script>
$(document).ready(function () {
var manifestUrl = "{{ include.pid | prepend: "/img/derivatives/iiif/" | append: "/manifest.json" | absolute_url }}";
$.getJSON(manifestUrl, function(data) {
var tileSources = [];
$.each(data.sequences[0].canvases, function(k, val) {
tileSources.push(val.images[0].resource.service['@id'] + '/info.json');
});
OpenSeadragon({
id: "osd",
sequenceMode: true,
prefixUrl: "{{ '/assets/openseadragon/images/' | absolute_url }}",
tileSources: tileSources,
homeFillsViewer: false,
showReferenceStrip: true,
showRotationControl: true,
// Enable touch rotation on tactile devices
gestureSettingsTouch: {
pinchRotate: true
}
});
});
});
</script>
41 changes: 41 additions & 0 deletions wax-framework/_layouts/generic_collection_item.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
---
layout: default
---

{% comment %}
The block below controls the image viewer
{% endcomment %}

<h3 alt="{{ page.label }}" class='item-label'>{{ page.label }}</h3>

{% if page.image_viewer %}
{% assign viewer = page.image_viewer %}
{% elsif layout.image_viewer %}
{% assign viewer = layout.image_viewer %}
{% endif %}

{% if viewer %}
<div class='item-view'>
<span class='pagination-link' id='prevlink'></span>
{% if viewer == 'openseadragon' %}
{% include osd_iiif_image_viewer.html pid=page.pid prevlink=prevlink nextlink=nextlink %}
{% else %}
{% include simple_image_viewer.html full_image=page.full prevlink=prevlink nextlink=nextlink %}
{% endif %}
<span class='pagination-link' id='nextlink'></span>
</div>
{% unless layout.pagination == false %}{% include item_pagination.html %}{% endunless %}
{% endif %}

{% comment %}
The block below controls the item metadata table
{% endcomment %}

{% if layout.meta.size %}
{% assign metadata = layout.meta %}
{% elsif page.meta.size %}
{% assign metadata = page.meta %}
{% endif %}
{% if metadata.size %}
{% include item_metadata.html meta=metadata %}
{% endif %}
8 changes: 8 additions & 0 deletions wax-framework/_layouts/wax_item.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
layout: generic_collection_item
image_viewer: 'openseadragon'
pagination: true
meta:
- label: 'Label'
value: page.label
---
7 changes: 7 additions & 0 deletions wax-framework/assets/bootstrap/bootstrap.min.js

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions wax-framework/assets/bootstrap/bootstrap.min.js.map

Large diffs are not rendered by default.

Loading