Skip to content

Commit

Permalink
Merge pull request #40 from mnyrop/chore/rake-from-theme-20
Browse files Browse the repository at this point in the history
init global rake tasks from theme
  • Loading branch information
mnyrop committed Jul 26, 2021
2 parents 0b2cc0b + 6f64468 commit 3c8d494
Show file tree
Hide file tree
Showing 4 changed files with 105 additions and 4 deletions.
8 changes: 4 additions & 4 deletions iiifc-theme.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,15 @@ Gem::Specification.new do |spec|
spec.metadata["plugin_type"] = "theme"

spec.files = `git ls-files -z`.split("\x0").select do |f|
f.match(%r!^(assets|_(includes|layouts|sass|data)/|(LICENSE|README)((\.(txt|md|markdown)|$)))!i)
f.match(%r!^(assets|lib|_(includes|layouts|sass|data)/|(LICENSE|README)((\.(txt|md|markdown)|$)))!i)
end

spec.add_runtime_dependency "jekyll", ">= 4.0", "< 5.0"
spec.add_runtime_dependency "html-proofer"
spec.add_runtime_dependency "jekyll", ">= 4.0", "< 4.2"
spec.add_runtime_dependency "jekyll-data"
spec.add_runtime_dependency "jekyll-gzip"
spec.add_runtime_dependency "jekyll-redirect-from"
spec.add_runtime_dependency "jekyll-sitemap"
spec.add_runtime_dependency "jekyll-liquify"

spec.add_development_dependency "bundler"
spec.add_runtime_dependency "rake"
end
9 changes: 9 additions & 0 deletions lib/iiifc.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
require 'fileutils'
require 'html-proofer'
require 'yaml'

SITE_DIR = './_site'
CONFIG = YAML.load_file './_config.yml'
SITE_ID = ENV['SITE_ID'] || CONFIG.fetch('site_id', 'root')

module Iiifc ; end
33 changes: 33 additions & 0 deletions lib/tasks/build.rake
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
require 'iiifc'

namespace :build do
def build(dest=nil, baseurl=nil)
sh "bundle exec jekyll clean"
cmd = "bundle exec jekyll build"
cmd += " -d '#{dest}'" unless dest.nil?
cmd += " --baseurl '#{baseurl}'" unless baseurl.nil?
sh cmd
end

desc 'Clean and build with branch preview URL overrides'
task :preview do
branch = `git rev-parse --abbrev-ref HEAD`.strip
baseurl = "/#{SITE_ID}/#{branch}"
dest = SITE_DIR + baseurl

build dest=dest, baseurl=baseurl
end

desc 'Clean and build with CI test overrides'
task :ci do
baseurl = '/test/extra-test'
dest = SITE_DIR + baseurl

build dest=dest, baseurl=baseurl
end

desc 'Clean and build with no overrrides'
task :default do
build
end
end
59 changes: 59 additions & 0 deletions lib/tasks/test.rake
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
require 'iiifc'

namespace :test do
desc 'Check html'
task :html do
opts = {
check_html: true,
assume_extension: true,
validation: {
report_mismatched_tags: true,
report_invalid_tags: true
},
checks_to_ignore: ['LinkCheck']
}
HTMLProofer.check_directory(SITE_DIR, opts).run
end

namespace :links do
desc 'Check for internal link errors'
task :internal do
puts 'Checking for internal link errors'
opts = {
checks_to_ignore: ['ImageCheck', 'HtmlCheck', 'ScriptCheck'],
disable_external: true,
internal_domains: ['localhost:4000']
}
HTMLProofer.check_directory(SITE_DIR, opts).run
end

desc 'Check for *iiif.io* link errors'
task :iiif do
puts 'Checking for link errors in *iiif.io* sites'
opts = {
checks_to_ignore: ['ImageCheck', 'HtmlCheck', 'ScriptCheck'],
url_ignore: [/^((?!iiif\.io).)*$/, 'github'] # temporarily ignore iiif.io github repo errors
}
HTMLProofer.check_directory(SITE_DIR, opts).run
end

desc 'Check for external link rot'
task :external do
puts 'Checking for external link errors'
opts = {
external_only: true,
http_status_ignore: [429],
enforce_https: true,
only_4xx: true,
checks_to_ignore: ['ImageCheck', 'HtmlCheck', 'ScriptCheck'],
url_ignore: [/.*iiif\.io.*/]
}
HTMLProofer.check_directory(SITE_DIR, opts).run
end

desc 'Run rspec tests (if they exist)'
task :spec do

end
end
end

0 comments on commit 3c8d494

Please sign in to comment.