Skip to content

Commit

Permalink
Merge branch 'main' into coydog-powan
Browse files Browse the repository at this point in the history
  • Loading branch information
hexylena authored Jun 24, 2024
2 parents 346bced + 9ac3c3d commit 2551112
Show file tree
Hide file tree
Showing 40 changed files with 133,645 additions and 103 deletions.
2 changes: 1 addition & 1 deletion _layouts/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
{%- elsif page.tags contains "gat" %}{% assign coverimage = "assets/images/gat.png" %}
{%- else %}{% assign coverimage = "assets/images/GTNLogo1000.png" %}{% endif %}
{% assign og_image = page.og_image | default: page['cover-image'] | default: topic.og_image | default: coverimage | default: "assets/images/GTNLogo1000.png" %}
<meta property="og:image" content="{% if og_image contains 'https://' %}{{ og_image }}{% else %}{{ site.baseurl }}/{{ og_image }}{% endif %}">
<meta property="og:image" content="{% if og_image contains 'https://' %}{{ og_image }}{% else %}{{ site.url }}{{ site.baseurl }}/{{ og_image }}{% endif %}">

{%- if page.layout == "tutorial_hands_on" -%}
<script type="application/ld+json">
Expand Down
10 changes: 10 additions & 0 deletions _plugins/api.rb
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,12 @@ def generate(site)
page2.data['layout'] = nil
site.pages << page2

# Feedback Data
page2 = PageWithoutAFile.new(site, '', 'api/', 'feedback2.json')
page2.content = JSON.generate(site.data['feedback2'])
page2.data['layout'] = nil
site.pages << page2

# Contributors
Jekyll.logger.debug '[GTN/API] Contributors, Funders, Organisations'
%w[contributors funders organisations].each do |type|
Expand Down Expand Up @@ -375,6 +381,8 @@ def generate(site)
path = File.join(site.dest, 'api', directory, 'slides.json')
p = material.dup
p.delete('ref')
p.delete('ref_tutorials')
p.delete('ref_slides')
p['contributors'] = Gtn::Contributors.get_contributors(p).dup.map { |c| mapContributor(site, c) }

# Here we un-do the tutorial metadata priority, and overwrite with
Expand All @@ -392,6 +400,8 @@ def generate(site)
path = File.join(site.dest, 'api', directory, 'tutorial.json')
p = material.dup
p.delete('ref')
p.delete('ref_tutorials')
p.delete('ref_slides')
p['contributors'] = Gtn::Contributors.get_contributors(p).dup.map { |c| mapContributor(site, c) }
if !Dir.exist?(File.dirname(path))
FileUtils.mkdir_p(File.dirname(path))
Expand Down
46 changes: 46 additions & 0 deletions _plugins/feeds.rb
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,33 @@ def markdownify(site, text)
'workflows' => '🛠️',
}

def generate_opml(site, groups)
builder = Nokogiri::XML::Builder.new(encoding: 'UTF-8') do |xml|
# Set stylesheet
xml.opml(version: '2.0') do
xml.head do
xml.title('Galaxy Training Network')
xml.dateCreated(DateTime.now.rfc3339)
xml.dateModified(DateTime.now.rfc3339)
xml.ownerEmail('[email protected]')
end
xml.body do
groups.each do |group, items|
xml.outline(text: group) do
items.each do |item|
xml.outline(text: item[:title], type: 'rss', version: 'RSS', xmlUrl: item[:url], htmlUrl: item[:url])
end
end
end
end
end
end

opml_path = File.join(site.dest, 'feeds', 'gtn.opml')
finalised = Nokogiri::XML builder.to_xml
File.write(opml_path, finalised.to_xml)
end

def generate_topic_feeds(site, topic, bucket)
mats = bucket.select { |x| x[3].include?(topic) }
feed_path = File.join(site.dest, 'topics', topic, 'feed.xml')
Expand Down Expand Up @@ -476,18 +503,37 @@ def generate_event_feeds(site)
# Basically like `PageWithoutAFile`
Jekyll::Hooks.register :site, :post_write do |site|
if Jekyll.env == 'production'
opml = {}
generate_event_feeds(site)
opml['GTN Events'] = [
{title: 'Events', url: "#{site.config['url']}#{site.baseurl}/events/feed.xml"}
]

bucket = all_date_sorted_materials(site)
bucket.freeze

opml['GTN Topics'] = []
opml['GTN Topics - Digests'] = []
TopicFilter.list_topics(site).each do |topic|
generate_topic_feeds(site, topic, bucket)
opml['GTN Topics'] <<
{title: "#{topic} all changes", url: "#{site.config['url']}#{site.baseurl}/topic/feed.xml"}

generate_matrix_feed(site, bucket, group_by: 'month', filter_by: topic)
opml['GTN Topics - Digests'] <<
{title: "#{topic} monthly changes", url: "#{site.config['url']}#{site.baseurl}/feeds/#{topic}-month.xml"}
end

generate_matrix_feed(site, bucket, group_by: 'day')
generate_matrix_feed(site, bucket, group_by: 'week')
generate_matrix_feed(site, bucket, group_by: 'month')

opml['GTN Digests'] = [
{title: "GTN daily changes", url: "#{site.config['url']}#{site.baseurl}/feeds/matrix-daily.xml"},
{title: "GTN weekly changes", url: "#{site.config['url']}#{site.baseurl}/feeds/matrix-weekly.xml"},
{title: "GTN monthly changes", url: "#{site.config['url']}#{site.baseurl}/feeds/matrix-monthly.xml"}
]

generate_opml(site, opml)
end
end
57 changes: 55 additions & 2 deletions _plugins/gtn/supported.rb
Original file line number Diff line number Diff line change
Expand Up @@ -121,8 +121,61 @@ def test_exact
end
end
else
server = ARGV[0]
workflow = ARGV[1]

def short_id(tool_id)
if tool_id.count('/') > 4
tool_id.split('/')[0..-2].join('/')
else
tool_id
end
end

require 'json'
pp ARGV
pp Gtn::Supported.calculate(JSON.parse(File.open('metadata/public-server-tools.json')), ARGV)
tool_list = JSON.parse(`curl -s #{server}/api/tools?in_panel=False`).map{|x| x['id']}
puts "Found #{tool_list.length} tools in #{server}"

version_smash = tool_list.map{|x|
if x.count('/') > 4
[x.split('/')[0..-2].join('/'), x.split('/')[-1]]
else
[x, []]
end
}
version_smash = version_smash.group_by{|x, y| x}.to_a.map{|k, v| [k, v.map{|x, y| y}]}.to_h

workflow_tools = JSON.parse(File.open(workflow).read)['steps'].map{|_, x| x['tool_id']}
workflow_tools.select!{|x| x && x.length.positive?}
puts "Found #{workflow_tools.length} tools in the #{workflow}"

workflow_tools.each do |tool|
if tool_list.include?(tool)
puts "✅ #{tool} is supported"
else
if version_smash.key?(short_id(tool))
puts "❔ #{tool} is not supported, but #{version_smash[short_id(tool)]} are"
else
puts "❌ #{tool} is not supported"
end
end
end

metadata = {
"servers" => [{"url" => server, "name" => "CLI Tested Server"}],
"tools" => {}
}
version_smash.each do |k, v|
if k.count('/') > 3
metadata["tools"][k] = v.map{|x| [x, [0]]}.to_h
else
metadata["tools"][k] = {
"_" => [0]
}
end
end

puts "GTN Rendering:"
pp Gtn::Supported.calculate(metadata, workflow_tools)
end
end
4 changes: 2 additions & 2 deletions _plugins/jekyll-topic-filter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -661,6 +661,7 @@ def self.resolve_material(site, material)
'modified' => File.mtime(wf_path),
'mermaid' => mermaid(wf_json),
'graph_dot' => graph_dot(wf_json),
'workflow_tools' => extract_workflow_tool_list(wf_json).uniq,
}
end
end
Expand All @@ -678,8 +679,7 @@ def self.resolve_material(site, material)
page_obj['workflows']&.each do |wf|
wf_path = "#{folder}/workflows/#{wf['workflow']}"

wf_data = JSON.parse(File.read(wf_path))
page_obj['tools'] += extract_workflow_tool_list(wf_data)
page_obj['tools'] += wf['workflow_tools']
end
page_obj['tools'] = page_obj['tools'].flatten.sort.uniq

Expand Down
2 changes: 1 addition & 1 deletion _plugins/sitemap.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ def _build(site)
'http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd" ' \
'xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">'

site.pages.reject { |t| t.path =~ /ipynb$/ }.each do |t|
site.pages.reject { |t| t.path =~ /ipynb$/ || t.path =~ /api\/ga4gh\/trs\/v2/}.each do |t|
begin
d = Gtn::ModificationTimes.obtain_time(t.path)
d.format = '%FT%T%:z'
Expand Down
Binary file added assets/branding/gtn-heart-venn.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 2551112

Please sign in to comment.