jekyll-waxify 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (111) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +14 -0
  3. data/.rspec +3 -0
  4. data/.rubocop.yml +13 -0
  5. data/CHANGELOG.md +19 -0
  6. data/CODE_OF_CONDUCT.md +84 -0
  7. data/Gemfile +14 -0
  8. data/LICENSE +21 -0
  9. data/LICENSE.txt +21 -0
  10. data/README.md +82 -0
  11. data/Rakefile +12 -0
  12. data/bin/console +15 -0
  13. data/bin/setup +8 -0
  14. data/jekyll-waxify.gemspec +35 -0
  15. data/lib/jekyll/commands/waxify.rb +33 -0
  16. data/lib/jekyll/waxify.rb +14 -0
  17. data/lib/jekyll/waxify/jekyll_config.rb +101 -0
  18. data/lib/jekyll/waxify/version.rb +7 -0
  19. data/wax-framework/Rakefile +3 -0
  20. data/wax-framework/_includes/collection_gallery.html +12 -0
  21. data/wax-framework/_includes/head.html +12 -0
  22. data/wax-framework/_includes/item_metadata.html +31 -0
  23. data/wax-framework/_includes/item_pagination.html +23 -0
  24. data/wax-framework/_includes/osd_iiif_image_viewer.html +27 -0
  25. data/wax-framework/_layouts/generic_collection_item.html +41 -0
  26. data/wax-framework/_layouts/wax_item.html +8 -0
  27. data/wax-framework/assets/bootstrap/bootstrap.min.js +7 -0
  28. data/wax-framework/assets/bootstrap/bootstrap.min.js.map +1 -0
  29. data/wax-framework/assets/datatables/datatables.css +24 -0
  30. data/wax-framework/assets/datatables/datatables.min.js +325 -0
  31. data/wax-framework/assets/elasticlunr.min.js +10 -0
  32. data/wax-framework/assets/jquery-3.2.1.min.js +4 -0
  33. data/wax-framework/assets/main.scss +23 -0
  34. data/wax-framework/assets/openseadragon/alt-buttons/fullpage_grouphover.png +0 -0
  35. data/wax-framework/assets/openseadragon/alt-buttons/fullpage_hover.png +0 -0
  36. data/wax-framework/assets/openseadragon/alt-buttons/fullpage_pressed.png +0 -0
  37. data/wax-framework/assets/openseadragon/alt-buttons/fullpage_rest.png +0 -0
  38. data/wax-framework/assets/openseadragon/alt-buttons/home_grouphover.png +0 -0
  39. data/wax-framework/assets/openseadragon/alt-buttons/home_hover.png +0 -0
  40. data/wax-framework/assets/openseadragon/alt-buttons/home_pressed.png +0 -0
  41. data/wax-framework/assets/openseadragon/alt-buttons/home_rest.png +0 -0
  42. data/wax-framework/assets/openseadragon/alt-buttons/next_grouphover.png +0 -0
  43. data/wax-framework/assets/openseadragon/alt-buttons/next_hover.png +0 -0
  44. data/wax-framework/assets/openseadragon/alt-buttons/next_pressed.png +0 -0
  45. data/wax-framework/assets/openseadragon/alt-buttons/next_rest.png +0 -0
  46. data/wax-framework/assets/openseadragon/alt-buttons/previous_grouphover.png +0 -0
  47. data/wax-framework/assets/openseadragon/alt-buttons/previous_hover.png +0 -0
  48. data/wax-framework/assets/openseadragon/alt-buttons/previous_pressed.png +0 -0
  49. data/wax-framework/assets/openseadragon/alt-buttons/previous_rest.png +0 -0
  50. data/wax-framework/assets/openseadragon/alt-buttons/rotateleft_grouphover.png +0 -0
  51. data/wax-framework/assets/openseadragon/alt-buttons/rotateleft_hover.png +0 -0
  52. data/wax-framework/assets/openseadragon/alt-buttons/rotateleft_pressed.png +0 -0
  53. data/wax-framework/assets/openseadragon/alt-buttons/rotateleft_rest.png +0 -0
  54. data/wax-framework/assets/openseadragon/alt-buttons/rotateright_grouphover.png +0 -0
  55. data/wax-framework/assets/openseadragon/alt-buttons/rotateright_hover.png +0 -0
  56. data/wax-framework/assets/openseadragon/alt-buttons/rotateright_pressed.png +0 -0
  57. data/wax-framework/assets/openseadragon/alt-buttons/rotateright_rest.png +0 -0
  58. data/wax-framework/assets/openseadragon/alt-buttons/zoomin_grouphover.png +0 -0
  59. data/wax-framework/assets/openseadragon/alt-buttons/zoomin_hover.png +0 -0
  60. data/wax-framework/assets/openseadragon/alt-buttons/zoomin_pressed.png +0 -0
  61. data/wax-framework/assets/openseadragon/alt-buttons/zoomin_rest.png +0 -0
  62. data/wax-framework/assets/openseadragon/alt-buttons/zoomout_grouphover.png +0 -0
  63. data/wax-framework/assets/openseadragon/alt-buttons/zoomout_hover.png +0 -0
  64. data/wax-framework/assets/openseadragon/alt-buttons/zoomout_pressed.png +0 -0
  65. data/wax-framework/assets/openseadragon/alt-buttons/zoomout_rest.png +0 -0
  66. data/wax-framework/assets/openseadragon/images/button_grouphover.png +0 -0
  67. data/wax-framework/assets/openseadragon/images/button_hover.png +0 -0
  68. data/wax-framework/assets/openseadragon/images/button_pressed.png +0 -0
  69. data/wax-framework/assets/openseadragon/images/button_rest.png +0 -0
  70. data/wax-framework/assets/openseadragon/images/flip_grouphover.png +0 -0
  71. data/wax-framework/assets/openseadragon/images/flip_hover.png +0 -0
  72. data/wax-framework/assets/openseadragon/images/flip_pressed.png +0 -0
  73. data/wax-framework/assets/openseadragon/images/flip_rest.png +0 -0
  74. data/wax-framework/assets/openseadragon/images/fullpage_grouphover.png +0 -0
  75. data/wax-framework/assets/openseadragon/images/fullpage_hover.png +0 -0
  76. data/wax-framework/assets/openseadragon/images/fullpage_pressed.png +0 -0
  77. data/wax-framework/assets/openseadragon/images/fullpage_rest.png +0 -0
  78. data/wax-framework/assets/openseadragon/images/home_grouphover.png +0 -0
  79. data/wax-framework/assets/openseadragon/images/home_hover.png +0 -0
  80. data/wax-framework/assets/openseadragon/images/home_pressed.png +0 -0
  81. data/wax-framework/assets/openseadragon/images/home_rest.png +0 -0
  82. data/wax-framework/assets/openseadragon/images/next_grouphover.png +0 -0
  83. data/wax-framework/assets/openseadragon/images/next_hover.png +0 -0
  84. data/wax-framework/assets/openseadragon/images/next_pressed.png +0 -0
  85. data/wax-framework/assets/openseadragon/images/next_rest.png +0 -0
  86. data/wax-framework/assets/openseadragon/images/previous_grouphover.png +0 -0
  87. data/wax-framework/assets/openseadragon/images/previous_hover.png +0 -0
  88. data/wax-framework/assets/openseadragon/images/previous_pressed.png +0 -0
  89. data/wax-framework/assets/openseadragon/images/previous_rest.png +0 -0
  90. data/wax-framework/assets/openseadragon/images/rotateleft_grouphover.png +0 -0
  91. data/wax-framework/assets/openseadragon/images/rotateleft_hover.png +0 -0
  92. data/wax-framework/assets/openseadragon/images/rotateleft_pressed.png +0 -0
  93. data/wax-framework/assets/openseadragon/images/rotateleft_rest.png +0 -0
  94. data/wax-framework/assets/openseadragon/images/rotateright_grouphover.png +0 -0
  95. data/wax-framework/assets/openseadragon/images/rotateright_hover.png +0 -0
  96. data/wax-framework/assets/openseadragon/images/rotateright_pressed.png +0 -0
  97. data/wax-framework/assets/openseadragon/images/rotateright_rest.png +0 -0
  98. data/wax-framework/assets/openseadragon/images/zoomin_grouphover.png +0 -0
  99. data/wax-framework/assets/openseadragon/images/zoomin_hover.png +0 -0
  100. data/wax-framework/assets/openseadragon/images/zoomin_pressed.png +0 -0
  101. data/wax-framework/assets/openseadragon/images/zoomin_rest.png +0 -0
  102. data/wax-framework/assets/openseadragon/images/zoomout_grouphover.png +0 -0
  103. data/wax-framework/assets/openseadragon/images/zoomout_hover.png +0 -0
  104. data/wax-framework/assets/openseadragon/images/zoomout_pressed.png +0 -0
  105. data/wax-framework/assets/openseadragon/images/zoomout_rest.png +0 -0
  106. data/wax-framework/assets/openseadragon/openseadragon.min.js +9 -0
  107. data/wax-framework/assets/openseadragon/openseadragon.min.js.map +1 -0
  108. data/wax-framework/assets/popper.min.js +4 -0
  109. data/wax-framework/assets/search-ui.js +64 -0
  110. data/wax-framework/collections.markdown +15 -0
  111. metadata +281 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 06235b80d0b3b3c71a6cd10496561a8823bad187f02465bf4d68f0b738d7c365
4
+ data.tar.gz: d4c1e2990721bdd4745ca6b9390174f00f6c388ab613c7258bd9642a8cafc2aa
5
+ SHA512:
6
+ metadata.gz: e86964907ec3836709da76b96896cbea01bfa9c48e544ca006efd9bf7fbdbf213094463a41510f0a0aee46528e59253d407fd115ff22e6295263dab0ccf3e5a1
7
+ data.tar.gz: c7360294b078d908bba5d8e82b13f3385f07940d0d5f0bc4cc689923720103bce766c588aab0ac7c1763f7512f05049af2a499830d7fbec947a9f44d360b4cd3
data/.gitignore ADDED
@@ -0,0 +1,14 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
9
+
10
+ .DS_Store
11
+ Gemfile.lock
12
+
13
+ # rspec failure tracking
14
+ .rspec_status
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --color
2
+ --require spec_helper
3
+ --format documentation
data/.rubocop.yml ADDED
@@ -0,0 +1,13 @@
1
+ AllCops:
2
+ TargetRubyVersion: 2.4
3
+
4
+ Style/StringLiterals:
5
+ Enabled: true
6
+ EnforcedStyle: double_quotes
7
+
8
+ Style/StringLiteralsInInterpolation:
9
+ Enabled: true
10
+ EnforcedStyle: double_quotes
11
+
12
+ Layout/LineLength:
13
+ Max: 120
data/CHANGELOG.md ADDED
@@ -0,0 +1,19 @@
1
+ # Changelog
2
+
3
+ All notable changes to this project will be documented in this file.
4
+
5
+ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6
+ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
+
8
+ ## [Unreleased]
9
+
10
+ - Add Wax search configuration to Jekyll config
11
+ - Enable import of images when adding a new collection
12
+ - Add Wax to a configured Jekyll site safely
13
+
14
+ ## [0.1.0] - 2021-04-18
15
+
16
+ ### Added
17
+
18
+ - Add Wax infrastructure to Jekyll site
19
+ - Add Wax IIIF collection to Jekyll config and _data
@@ -0,0 +1,84 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ We as members, contributors, and leaders pledge to make participation in our community a harassment-free experience for everyone, regardless of age, body size, visible or invisible disability, ethnicity, sex characteristics, gender identity and expression, level of experience, education, socio-economic status, nationality, personal appearance, race, religion, or sexual identity and orientation.
6
+
7
+ We pledge to act and interact in ways that contribute to an open, welcoming, diverse, inclusive, and healthy community.
8
+
9
+ ## Our Standards
10
+
11
+ Examples of behavior that contributes to a positive environment for our community include:
12
+
13
+ * Demonstrating empathy and kindness toward other people
14
+ * Being respectful of differing opinions, viewpoints, and experiences
15
+ * Giving and gracefully accepting constructive feedback
16
+ * Accepting responsibility and apologizing to those affected by our mistakes, and learning from the experience
17
+ * Focusing on what is best not just for us as individuals, but for the overall community
18
+
19
+ Examples of unacceptable behavior include:
20
+
21
+ * The use of sexualized language or imagery, and sexual attention or
22
+ advances of any kind
23
+ * Trolling, insulting or derogatory comments, and personal or political attacks
24
+ * Public or private harassment
25
+ * Publishing others' private information, such as a physical or email
26
+ address, without their explicit permission
27
+ * Other conduct which could reasonably be considered inappropriate in a
28
+ professional setting
29
+
30
+ ## Enforcement Responsibilities
31
+
32
+ Community leaders are responsible for clarifying and enforcing our standards of acceptable behavior and will take appropriate and fair corrective action in response to any behavior that they deem inappropriate, threatening, offensive, or harmful.
33
+
34
+ Community leaders have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, and will communicate reasons for moderation decisions when appropriate.
35
+
36
+ ## Scope
37
+
38
+ This Code of Conduct applies within all community spaces, and also applies when an individual is officially representing the community in public spaces. Examples of representing our community include using an official e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event.
39
+
40
+ ## Enforcement
41
+
42
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be reported to the community leaders responsible for enforcement at peter.binkley@ualberta.ca. All complaints will be reviewed and investigated promptly and fairly.
43
+
44
+ All community leaders are obligated to respect the privacy and security of the reporter of any incident.
45
+
46
+ ## Enforcement Guidelines
47
+
48
+ Community leaders will follow these Community Impact Guidelines in determining the consequences for any action they deem in violation of this Code of Conduct:
49
+
50
+ ### 1. Correction
51
+
52
+ **Community Impact**: Use of inappropriate language or other behavior deemed unprofessional or unwelcome in the community.
53
+
54
+ **Consequence**: A private, written warning from community leaders, providing clarity around the nature of the violation and an explanation of why the behavior was inappropriate. A public apology may be requested.
55
+
56
+ ### 2. Warning
57
+
58
+ **Community Impact**: A violation through a single incident or series of actions.
59
+
60
+ **Consequence**: A warning with consequences for continued behavior. No interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, for a specified period of time. This includes avoiding interactions in community spaces as well as external channels like social media. Violating these terms may lead to a temporary or permanent ban.
61
+
62
+ ### 3. Temporary Ban
63
+
64
+ **Community Impact**: A serious violation of community standards, including sustained inappropriate behavior.
65
+
66
+ **Consequence**: A temporary ban from any sort of interaction or public communication with the community for a specified period of time. No public or private interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, is allowed during this period. Violating these terms may lead to a permanent ban.
67
+
68
+ ### 4. Permanent Ban
69
+
70
+ **Community Impact**: Demonstrating a pattern of violation of community standards, including sustained inappropriate behavior, harassment of an individual, or aggression toward or disparagement of classes of individuals.
71
+
72
+ **Consequence**: A permanent ban from any sort of public interaction within the community.
73
+
74
+ ## Attribution
75
+
76
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 2.0,
77
+ available at https://www.contributor-covenant.org/version/2/0/code_of_conduct.html.
78
+
79
+ Community Impact Guidelines were inspired by [Mozilla's code of conduct enforcement ladder](https://github.com/mozilla/diversity).
80
+
81
+ [homepage]: https://www.contributor-covenant.org
82
+
83
+ For answers to common questions about this code of conduct, see the FAQ at
84
+ https://www.contributor-covenant.org/faq. Translations are available at https://www.contributor-covenant.org/translations.
data/Gemfile ADDED
@@ -0,0 +1,14 @@
1
+ # frozen_string_literal: true
2
+
3
+ source "https://rubygems.org"
4
+
5
+ # Specify your gem's dependencies in jekyll-waxify.gemspec
6
+ gemspec
7
+
8
+ gem "rake", "~> 13.0"
9
+
10
+ gem "rspec", "~> 3.0"
11
+
12
+ gem "rubocop", "~> 1.7"
13
+
14
+ gem "simplecov", "0.17.1", require: false
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2021 Peter Binkley
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2021 Peter Binkley
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,82 @@
1
+ # Jekyll::Waxify
2
+ A gem-packaged Jekyll plugin that installs basic minicomp/wax components
3
+
4
+ This gem installs the simplest possible framework for [Wax](https://minicomp.github.io/wax) IIIF support in a Jekyll site. It is intended to be used in teaching, as well as to flatten the learning curve for those who are new to Wax.
5
+
6
+ This is a work in progress. If you try it on an existing Jekyll site, be sure you have a recent backup.
7
+
8
+ TODOs:
9
+
10
+ - [ ] deploy to RubyGems
11
+ - [x] provide scaffolding for Wax iiif images
12
+ - [ ] enable import of images on collection creation
13
+ - [x] refactoring
14
+ - [ ] provide scaffolding for Wax indexing
15
+ - [ ] test with mature Jekyll sites
16
+ - [x] add specs
17
+
18
+ A minimal demo site can be seen at [https://pbinkley.github.io/jekyll-waxify](https://pbinkley.github.io/jekyll-waxify).
19
+
20
+ ## Installation
21
+
22
+ In order to make the site compatible with Github Pages, use the github pages gem to manage the Jekyll version. In your Jekyll site's Gemfile, comment out the Jekyll line:
23
+
24
+ ```ruby
25
+ # gem "jekyll", "~> 4.2.0"
26
+ ```
27
+
28
+ And add these lines to the ```jekyll_plugins``` group:
29
+
30
+ ```ruby
31
+ gem 'github-pages', '~> 213'
32
+ gem 'jekyll-waxify', '0.1.0'
33
+ ```
34
+
35
+ And add this section:
36
+
37
+ ```ruby
38
+ group :development do
39
+ gem 'wax_tasks', '~> 1.1'
40
+ end
41
+ ```
42
+
43
+ And then execute:
44
+
45
+ $ bundle update
46
+
47
+ ## Usage
48
+
49
+ You can then waxify your Jekyll site and create a Wax image collection:
50
+
51
+ $ bundle exec jekyll waxify <collection name>
52
+
53
+ This creates all the scaffolding for your collection. To populate it, copy images into ```_data/raw_images/<collection name>/```, and edit the csv file ```_data/<collection name>.csv```: for each image add a row containing the file name (without extension) and a label. E.g. for a map image ```1234.tif``` the row should contain ```1234,Map of Paris```.
54
+
55
+ Now you can generate the Wax artefacts for your collection:
56
+
57
+ $ bundle exec rake wax:pages <collection name>
58
+ $ bundle exec rake wax:derivatives:iiif <collection name>
59
+
60
+ And view the site in the normal Jekyll way:
61
+
62
+ $ bundle exec jekyll serve
63
+
64
+ The "Collections" link in the tab bar will take you to your new collection.
65
+
66
+ ## Development
67
+
68
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
69
+
70
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
71
+
72
+ ## Contributing
73
+
74
+ Bug reports and pull requests are welcome on GitHub at https://github.com/pbinkley/jekyll-waxify. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/pbinkley/jekyll-waxify/blob/master/CODE_OF_CONDUCT.md).
75
+
76
+ ## License
77
+
78
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
79
+
80
+ ## Code of Conduct
81
+
82
+ Everyone interacting in the Jekyll::Waxify project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/pbinkley/jekyll-waxify/blob/master/CODE_OF_CONDUCT.md).
data/Rakefile ADDED
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "bundler/gem_tasks"
4
+ require "rspec/core/rake_task"
5
+
6
+ RSpec::Core::RakeTask.new(:spec)
7
+
8
+ require "rubocop/rake_task"
9
+
10
+ RuboCop::RakeTask.new
11
+
12
+ task default: %i[spec rubocop]
data/bin/console ADDED
@@ -0,0 +1,15 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ require "bundler/setup"
5
+ require "jekyll/waxify"
6
+
7
+ # You can add fixtures and/or initialization code here to make experimenting
8
+ # with your gem easier. You can also use a different console, if you like.
9
+
10
+ # (If you use this, don't forget to add pry to your Gemfile!)
11
+ # require "pry"
12
+ # Pry.start
13
+
14
+ require "irb"
15
+ IRB.start(__FILE__)
data/bin/setup ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,35 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "lib/jekyll/waxify/version"
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = "jekyll-waxify"
7
+ spec.version = Jekyll::Waxify::VERSION
8
+ spec.authors = ["Peter Binkley"]
9
+ spec.email = ["peter.binkley@ualberta.ca"]
10
+ spec.summary = "A Jekyll plugin that installs basic minicomp/wax components"
11
+ spec.description = "A Jekyll plugin that installs basic minicomp/wax components"
12
+ spec.homepage = "https://github.com/pbinkley/jekyll-waxify"
13
+ spec.license = "MIT"
14
+ spec.required_ruby_version = Gem::Requirement.new(">= 2.4.0")
15
+
16
+ spec.metadata["homepage_uri"] = spec.homepage
17
+ spec.metadata["source_code_uri"] = "https://github.com/pbinkley/jekyll-waxify"
18
+ spec.metadata["changelog_uri"] = "https://github.com/pbinkley/jekyll-waxify"
19
+
20
+ spec.files = Dir.chdir(File.expand_path(__dir__)) do
21
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{\A(?:test|spec|features)/}) }
22
+ end
23
+ spec.require_paths = ["lib"]
24
+
25
+ spec.add_runtime_dependency "deep_merge", "~> 1.2"
26
+ spec.add_runtime_dependency "github-pages", "~> 213"
27
+ spec.add_runtime_dependency "progress_bar", "~> 1.3"
28
+ spec.add_runtime_dependency "rainbow", "~> 3.0"
29
+ spec.add_runtime_dependency "rake", "~> 13.0"
30
+ spec.add_runtime_dependency "safe_yaml", "~> 1.0"
31
+
32
+ spec.add_development_dependency "bump", "~> 0.8"
33
+ spec.add_development_dependency "byebug", "~> 11"
34
+ spec.add_development_dependency "rspec", "~> 3"
35
+ end
@@ -0,0 +1,33 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Add wax components to a Jekyll site
4
+ module Jekyll
5
+ # Commands
6
+ module Commands
7
+ # Waxify
8
+ class WaxifyCommand < Command
9
+ def self.init_with_program(prog)
10
+ prog.command(:waxify) do |c|
11
+ c.syntax "waxify [coll]"
12
+ c.description "Add Wax components"
13
+
14
+ c.action { |args, options| process(args, options) }
15
+ end
16
+ end
17
+
18
+ def self.process(args = [], _options = [])
19
+ coll = args[0]
20
+
21
+ jekyll_config = Waxify::JekyllConfig.new(Jekyll::Waxify::WAXIFY_FRAMEWORK, Jekyll::Waxify::JEKYLL_DIR)
22
+
23
+ return if jekyll_config.waxified
24
+
25
+ jekyll_config.add_cors
26
+ jekyll_config.add_collection(coll)
27
+ jekyll_config.merge
28
+ jekyll_config.save
29
+ jekyll_config.deploy_framework
30
+ end
31
+ end
32
+ end
33
+ end
@@ -0,0 +1,14 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "jekyll/waxify/version"
4
+ require "jekyll/waxify/jekyll_config"
5
+
6
+ module Jekyll
7
+ module Waxify
8
+ WAXIFY_FRAMEWORK = File.join(File.dirname(File.expand_path(__FILE__)),
9
+ "../../wax-framework/.")
10
+ JEKYLL_DIR = Dir.pwd
11
+ end
12
+ end
13
+
14
+ require "jekyll/commands/waxify.rb"
@@ -0,0 +1,101 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "deep_merge"
4
+ require "yaml"
5
+
6
+ module Jekyll
7
+ module Waxify
8
+ # JekyllConfig: represents _config.yml in text and yaml
9
+ class JekyllConfig
10
+ attr_reader :yaml, :text, :new_config, :jekyll_dir
11
+
12
+ def initialize(framework_dir, jekyll_dir, new_config = {}, config_file = "_config.yml")
13
+ @framework_dir = framework_dir
14
+ @jekyll_dir = jekyll_dir
15
+ @config_file = config_file
16
+ @text = File.read("#{@jekyll_dir}/#{@config_file}")
17
+ @yaml = YAML.safe_load(@text)
18
+ @new_config = new_config
19
+ end
20
+
21
+ def waxified
22
+ @yaml["waxified"]
23
+ end
24
+
25
+ def deploy_framework
26
+ # copy framework documents to jekyll
27
+ FileUtils.cp_r @framework_dir, @jekyll_dir
28
+ end
29
+
30
+ def add(to_add)
31
+ @new_config.deep_merge! to_add
32
+ end
33
+
34
+ def add_cors
35
+ return if @yaml.dig("webrick", "header", "Access-Control-Allow-Origin")
36
+
37
+ # Add CORS stanza to _config.yml
38
+ add(
39
+ {
40
+ "webrick" => {
41
+ "header" => {
42
+ "Access-Control-Allow-Origin" => "*"
43
+ }
44
+ }
45
+ }
46
+ )
47
+ end
48
+
49
+ def add_collection(coll)
50
+ return unless coll
51
+
52
+ # Make coll images dir and metadata csv file
53
+ FileUtils.mkdir_p "#{@jekyll_dir}/_data/raw_images/#{coll}"
54
+ File.open("#{@jekyll_dir}/_data/#{coll}.csv", "w") { |file| file.write("pid,label\n") }
55
+
56
+ @yaml["collections"] ||= {}
57
+
58
+ return if @yaml.dig("collections", coll)
59
+
60
+ # Add coll to new config stanzas
61
+ add(
62
+ { "collections" => {
63
+ coll =>
64
+ {
65
+ "output" => true,
66
+ "layout" => "wax_item",
67
+ "metadata" => { "source" => "#{coll}.csv" },
68
+ "images" => { "source" => "raw_images/#{coll}" }
69
+ }
70
+ } }
71
+ )
72
+ end
73
+
74
+ def merge
75
+ @new_config["waxified"] = true
76
+
77
+ new_yaml = @new_config.to_yaml.sub("---\n", "")
78
+
79
+ # collection block is terminated by EOF or a new key, i.e. a line
80
+ # that begins a character other than whitespace or hash
81
+
82
+ groups = @text.match /(^collections:.*\n.+\n)(\Z|[^\s\#].*)/m
83
+
84
+ if groups.nil?
85
+ # there are no collections in initial yaml, so append new_yaml
86
+ @text += new_yaml
87
+ else
88
+ # merge collections from @new_config into collections
89
+ collections = YAML.safe_load(groups[1])
90
+ collections.deep_merge! @new_config
91
+
92
+ @text = groups.pre_match + collections.to_yaml.sub("---\n","") + groups[2]
93
+ end
94
+ end
95
+
96
+ def save
97
+ File.open(@config_file, "w") { |f| f.puts @text }
98
+ end
99
+ end
100
+ end
101
+ end