Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
galaxyproject
GitHub Repository: galaxyproject/training-material
Path: blob/main/_plugins/generator-workflows.rb
1677 views
1
# frozen_string_literal: true
2
3
require './_plugins/gtn'
4
5
module Jekyll
6
##
7
# {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.
8
#
9
# We use generators for lots of purposes, e.g.
10
#
11
# Real Generators, the way Jekyll intended:
12
#
13
# - Jekyll::Generators::PlaintextSlidesGenerator - turns slides.html into plain text non-JS versions.
14
# - Jekyll::Generators::RecordingPageGenerator - emits a webpage for every tutorial that has recordings, in the GTN
15
# - Jekyll::Generators::WorkflowPageGenerator - emits a webpage for every workflow in the GTN
16
# - Jekyll::Generators::AuthorPageGenerator - emits a hall-of-fame entry for every contributor, organisation, and grant listed in our site metadata.
17
# - Jekyll::Generators::RmarkdownGenerator - outputs the RMarkdown notebooks for tutorials that want them.
18
# - Jekyll::Generators::SitemapGenerator2 - alternative for the jekyll-sitemap plugin that's a bit faster.
19
# - Jekyll::Generators::SyntheticTopicGenerator - our synthetic tag based topics
20
# - Jekyll::Generators::TagPageGenerator - topic page for every tag
21
# - Jekyll::Generators::WorkflowPageGenerator
22
#
23
# Muck with page contents generators (probably should be hooks):
24
#
25
# - Jekyll::Generators::Abbreviate - turns +{something}+ into an abbreviation tag
26
# - Jekyll::Generators::Figurify - handles our modified markdown for images
27
# - Jekyll::Generators::Boxify - turns +<box-title>blah</box-title> ... {: .box}+ into GTN boxes.
28
#
29
# Other generators (also probably should be hooks):
30
#
31
# - Jekyll::Generators::EnvironmentVariablesGenerator - adds git revision, tags, and other environment variables to the site object
32
module Generators
33
34
##
35
# This class generates the GTN's workflow pages.
36
class WorkflowPageGenerator < Generator
37
safe true
38
39
##
40
# Params
41
# +site+:: The site object
42
def generate(site)
43
Jekyll.logger.info "[GTN/Workflows] Generating workflow pages"
44
materials = Gtn::TopicFilter
45
.list_all_materials(site)
46
47
# [{"workflow"=>"Calling_variants_in_non-diploid_systems.ga",
48
# "tests"=>true,
49
# "url"=>"https://training.galaxyproject.org/training-material/topics/variant-analysis/tutorials/non-dip/workflows/Calling_variants_in_non-diploid_systems.ga",
50
# "path"=>"topics/variant-analysis/tutorials/non-dip/workflows/Calling_variants_in_non-diploid_systems.ga",
51
# "wfid"=>"variant-analysis-non-dip",
52
# "wfname"=>"calling-variants-in-non-diploid-systems",
53
# "trs_endpoint"=>"https://training.galaxyproject.org/training-material/api/ga4gh/trs/v2/tools/variant-analysis-non-dip/versions/calling-variants-in-non-diploid-systems",
54
# "license"=>nil,
55
# "parent_id"=>"variant-analysis/non-dip",
56
# "topic_id"=>"variant-analysis",
57
# "tutorial_id"=>"non-dip",
58
# "creators"=>[],
59
# "name"=>"Calling variants in non-diploid systems",
60
# "title"=>"Calling variants in non-diploid systems",
61
# "test_results"=>nil,
62
# "modified"=>2024-03-18 12:38:46.293831071 +0100,
63
# "mermaid"=>
64
# "graph_dot"=>
65
# }]
66
# /api/workflows/#{topic_id}/#{tutorial_id}/#{wfid}/rocrate.zip
67
shortlinks = site.data['shortlinks']['id'].invert
68
69
materials.each do |material|
70
(material['workflows'] || []).each do |workflow|
71
page2 = PageWithoutAFile.new(site, '', '', "#{workflow['path'].gsub(/.ga$/, '.html')}")
72
path = File.join('/', workflow['path'].gsub(/.ga$/, '.html'))
73
page2.content = nil
74
page2.data['title'] = workflow['title']
75
page2.data['layout'] = 'workflow'
76
page2.data['material'] = material
77
page2.data['workflow'] = workflow
78
page2.data['js_requirements'] = {'mathjax' => false, 'mermaid' => true}
79
page2.data['short_id'] = shortlinks[path]
80
page2.data['redirect_from'] = ["/short/#{shortlinks[path]}"]
81
site.pages << page2
82
end
83
end
84
end
85
end
86
end
87
end
88
89
90