Skip to content

Commit

Permalink
init
Browse files Browse the repository at this point in the history
  • Loading branch information
mnyrop committed Oct 22, 2024
1 parent ba30108 commit 7accd41
Show file tree
Hide file tree
Showing 9 changed files with 12,266 additions and 56 deletions.
22 changes: 22 additions & 0 deletions .github/workflows/gh-pages-deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: github pages deploy

on:
push:
branches:
- main
paths-ignore:
- 'docs/**'
- 'README.md'

jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 1
- name: deploy
uses: peaceiris/actions-gh-pages@v4
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./build
57 changes: 1 addition & 56 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,56 +1 @@
*.gem
*.rbc
/.config
/coverage/
/InstalledFiles
/pkg/
/spec/reports/
/spec/examples.txt
/test/tmp/
/test/version_tmp/
/tmp/

# Used by dotenv library to load environment variables.
# .env

# Ignore Byebug command history file.
.byebug_history

## Specific to RubyMotion:
.dat*
.repl_history
build/
*.bridgesupport
build-iPhoneOS/
build-iPhoneSimulator/

## Specific to RubyMotion (use of CocoaPods):
#
# We recommend against adding the Pods directory to your .gitignore. However
# you should judge for yourself, the pros and cons are mentioned at:
# https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control
#
# vendor/Pods/

## Documentation cache and generated files:
/.yardoc/
/_yardoc/
/doc/
/rdoc/

## Environment normalization:
/.bundle/
/vendor/bundle
/lib/bundler/man/

# for a library or gem, you might want to ignore these files since the code is
# intended to run in multiple environments; otherwise, check them in:
# Gemfile.lock
# .ruby-version
# .ruby-gemset

# unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
.rvmrc

# Used by RuboCop. Remote config files pulled in from inherit_from directive.
# .rubocop-https?--*
.DS_Store
7 changes: 7 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
source 'https://rubygems.org'

gem 'base64'
gem 'httparty'
gem 'liquid'
gem 'ostruct'
gem 'rake'
30 changes: 30 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
GEM
remote: https://rubygems.org/
specs:
base64 (0.2.0)
bigdecimal (3.1.8)
csv (3.3.0)
httparty (0.22.0)
csv
mini_mime (>= 1.0.0)
multi_xml (>= 0.5.2)
liquid (5.5.1)
mini_mime (1.1.5)
multi_xml (0.7.1)
bigdecimal (~> 3.1)
ostruct (0.6.0)
rake (13.2.1)

PLATFORMS
arm64-darwin-23
ruby

DEPENDENCIES
base64
httparty
liquid
ostruct
rake

BUNDLED WITH
2.5.16
62 changes: 62 additions & 0 deletions Rakefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
require 'httparty'
require 'json'
require 'liquid'

OG_IDS = [
'OG-2024-USCIS',
'OG-2024-SF-NARA',
'OG-2024-KC-NARA',
'OG-2023-KC-NARA',
'OG-2022-KC-NARA',
'OG-2021-USCIS'
]
INDEX_PATH = './build/index.json'
HTML_PATH = './build/index.html'
TEMPLATE_PATH = './lib/template.html'

def formatted_datetime(time = Time.now)
fmt_date = "#{time.month}/#{time.day}/#{time.year}"
fmt_time = "#{time.hour}:#{time.min.to_s.rjust(2, '0')}#{time.zone}"
"#{fmt_date} at #{fmt_time}"
end

namespace :build do
desc 'build aggregated index'
task :index do
index = []

OG_IDS.each do |og_id|
url = "https://migrants-and-the-state.github.io/#{og_id.downcase}/index.json"
hashes = JSON.parse HTTParty.get(url).body
puts "Adding #{hashes.length} items from #{og_id} to the index"
hashes.each { |hash| index << hash }
end

puts "Writing aggregated index with #{index.length} items to #{INDEX_PATH}"
File.open(INDEX_PATH, 'w') { |file| file.write JSON.pretty_generate(index) }
puts "\nDone ✓\n"
end

desc 'build html'
task :html do
vars = {
'items' => JSON.load(File.open(INDEX_PATH)),
'formatted_date' => formatted_datetime
}
template = Liquid::Template.parse File.open(TEMPLATE_PATH).read

puts "Writing html dashboard to #{HTML_PATH}"
File.open(HTML_PATH, 'w') { |file| file.write template.render(vars) }
puts "\nDone ✓\n"
end

desc 'build everything'
task :all do
Rake::Task['build:index'].execute
Rake::Task['build:html'].execute
end
end

task :default => ['build:all']


Empty file added build/.gitkeep
Empty file.
6,067 changes: 6,067 additions & 0 deletions build/index.html

Large diffs are not rendered by default.

6,010 changes: 6,010 additions & 0 deletions build/index.json

Large diffs are not rendered by default.

67 changes: 67 additions & 0 deletions lib/template.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
<!DOCTYPE html>
<html lang='en'>
<head>
<meta charset='UTF-8'>
<meta http-equiv='X-UA-Compatible' content='ie=edge'>
<meta name='viewport' content='width=device-width, initial-scale=1.0'>
<title>M/S Aggregate Order Group Index</title>
<link rel='stylesheet' href='https://cdn.jsdelivr.net/npm/bulma@0.9.4/css/bulma.min.css'>
<link rel='stylesheet' href='https://cdn.datatables.net/1.12.1/css/jquery.dataTables.min.css'>
</head>
<body>
<section class='hero is-info'>
<div class='hero-body'>
<div class='container'>
<h1 class='title'>M/S Aggregate Order Group Index</h1>
<p class='is-5 is-grey'>Last updated {{ formatted_date }}</p>
<p class='tags mt-5'>
<!-- <a target='_blank' class='tag is-danger is-light' href='{{ iiif_collection_url }}'>iiif collection</a> -->
<a target='_blank' class='tag is-link is-light' href='index.json'>index.json</a>
</p>
</div>
</div>
</section>
<section class='section'>
<div class='container'>
<h2 class='is-size-4 mb-3'>Items ({{ items.size }})</h2>
{% if items.size > 1000 %}<p>(Limiting display to first 1000)</p>{% endif %}
<div class='table-container'>
<table id='table' class='table display is-hoverable is-striped is-bordered'>
<thead>
<tr>
<td>item id</td>
<td>label</td>
<td>thumbnnail</td>
<td>iiif manifest</td>
<td>view in viewpoint</td>
</tr>
</thead>
<tbody>
{% for item in items | limit: 1000 %}
<tr>
<td><b>{{ item.id }}</b></td>
<td>{{ item.label }}</td>
<td><a target='_blank' href='{{ item.thumbnail_url }}'><img style="height:100px;width:auto" class='lazy' data-original="{{ item.thumbnail_url }}"/></a></td>
<td><a target='_blank' href='{{ item.manifest_url }}'><img alt='Thumbnail {{ item.label }}' src='https://upload.wikimedia.org/wikipedia/commons/e/e8/International_Image_Interoperability_Framework_logo.png' style="width:25px"/></a></td>
<td><a target='_blank' class='is-size-7' href='{{ item.viewpoint_url }}'>{{ item.viewpoint_url }}</a></td>
</tr>
{% endfor %}
</tbody>
</table>
</table>
</div>
</section>
<script src='https://code.jquery.com/jquery-3.5.1.js'></script>
<script src='https://cdnjs.cloudflare.com/ajax/libs/jquery.lazyload/1.9.1/jquery.lazyload.min.js'></script>
<script src='https://cdn.datatables.net/1.12.1/js/jquery.dataTables.min.js'></script>
<script>
$(document).ready(function () {
$('#table').DataTable( {
drawCallback: function(){
$('img.lazy').lazyload();
}
});
});
</script>
</body>
</html>

0 comments on commit 7accd41

Please sign in to comment.