Path: blob/main/_plugins/generator-workflows.rb
1677 views
# frozen_string_literal: true12require './_plugins/gtn'34module Jekyll5##6# {Jekyll Generators}[https://jekyllrb.com/docs/plugins/generators/] are a way to let you generate files at runtime, without needing them to exist on disk.7#8# We use generators for lots of purposes, e.g.9#10# Real Generators, the way Jekyll intended:11#12# - Jekyll::Generators::PlaintextSlidesGenerator - turns slides.html into plain text non-JS versions.13# - Jekyll::Generators::RecordingPageGenerator - emits a webpage for every tutorial that has recordings, in the GTN14# - Jekyll::Generators::WorkflowPageGenerator - emits a webpage for every workflow in the GTN15# - Jekyll::Generators::AuthorPageGenerator - emits a hall-of-fame entry for every contributor, organisation, and grant listed in our site metadata.16# - Jekyll::Generators::RmarkdownGenerator - outputs the RMarkdown notebooks for tutorials that want them.17# - Jekyll::Generators::SitemapGenerator2 - alternative for the jekyll-sitemap plugin that's a bit faster.18# - Jekyll::Generators::SyntheticTopicGenerator - our synthetic tag based topics19# - Jekyll::Generators::TagPageGenerator - topic page for every tag20# - Jekyll::Generators::WorkflowPageGenerator21#22# Muck with page contents generators (probably should be hooks):23#24# - Jekyll::Generators::Abbreviate - turns +{something}+ into an abbreviation tag25# - Jekyll::Generators::Figurify - handles our modified markdown for images26# - Jekyll::Generators::Boxify - turns +<box-title>blah</box-title> ... {: .box}+ into GTN boxes.27#28# Other generators (also probably should be hooks):29#30# - Jekyll::Generators::EnvironmentVariablesGenerator - adds git revision, tags, and other environment variables to the site object31module Generators3233##34# This class generates the GTN's workflow pages.35class WorkflowPageGenerator < Generator36safe true3738##39# Params40# +site+:: The site object41def generate(site)42Jekyll.logger.info "[GTN/Workflows] Generating workflow pages"43materials = Gtn::TopicFilter44.list_all_materials(site)4546# [{"workflow"=>"Calling_variants_in_non-diploid_systems.ga",47# "tests"=>true,48# "url"=>"https://training.galaxyproject.org/training-material/topics/variant-analysis/tutorials/non-dip/workflows/Calling_variants_in_non-diploid_systems.ga",49# "path"=>"topics/variant-analysis/tutorials/non-dip/workflows/Calling_variants_in_non-diploid_systems.ga",50# "wfid"=>"variant-analysis-non-dip",51# "wfname"=>"calling-variants-in-non-diploid-systems",52# "trs_endpoint"=>"https://training.galaxyproject.org/training-material/api/ga4gh/trs/v2/tools/variant-analysis-non-dip/versions/calling-variants-in-non-diploid-systems",53# "license"=>nil,54# "parent_id"=>"variant-analysis/non-dip",55# "topic_id"=>"variant-analysis",56# "tutorial_id"=>"non-dip",57# "creators"=>[],58# "name"=>"Calling variants in non-diploid systems",59# "title"=>"Calling variants in non-diploid systems",60# "test_results"=>nil,61# "modified"=>2024-03-18 12:38:46.293831071 +0100,62# "mermaid"=>63# "graph_dot"=>64# }]65# /api/workflows/#{topic_id}/#{tutorial_id}/#{wfid}/rocrate.zip66shortlinks = site.data['shortlinks']['id'].invert6768materials.each do |material|69(material['workflows'] || []).each do |workflow|70page2 = PageWithoutAFile.new(site, '', '', "#{workflow['path'].gsub(/.ga$/, '.html')}")71path = File.join('/', workflow['path'].gsub(/.ga$/, '.html'))72page2.content = nil73page2.data['title'] = workflow['title']74page2.data['layout'] = 'workflow'75page2.data['material'] = material76page2.data['workflow'] = workflow77page2.data['js_requirements'] = {'mathjax' => false, 'mermaid' => true}78page2.data['short_id'] = shortlinks[path]79page2.data['redirect_from'] = ["/short/#{shortlinks[path]}"]80site.pages << page281end82end83end84end85end86end87888990