Skip to content

Commit

Permalink
Merge pull request #4600 from galaxyproject/aardwolf-pyruvate
Browse files Browse the repository at this point in the history
More OpenGraph fixes
  • Loading branch information
nomadscientist authored Dec 19, 2023
2 parents e8eb1b0 + c466fff commit 9731cb3
Show file tree
Hide file tree
Showing 46 changed files with 243 additions and 164 deletions.
6 changes: 2 additions & 4 deletions 404.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
---
layout: "base"
permalink: /404.html
title: "404 Page Not Found"
---


# Oops!

## We can't seem to find the page you're looking for.
## Oops! We can't seem to find the page you're looking for.

Perhaps you are here due to a mis-typed URL

Expand Down
4 changes: 4 additions & 0 deletions _includes/help.html
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,19 @@
</a>
{% if topic %}
{% unless topic.tag_based %}
{% if topic.title %}
<a class="dropdown-item" href="{{ site.baseurl }}/topics/{{topic.name}}/faqs/" title="Check our FAQs for the {{topic.title}} topic">
{% icon question %} Topic FAQs
</a>
{% endif %}
{% endunless %}
{% elsif page.layout == 'topic' %}
{% unless page.tag_based %}
{% if page.topic_title %}
<a class="dropdown-item" href="{{ site.baseurl }}/topics/{{page.topic_name}}/faqs/" title="Check our FAQs for the {{page.topic_title}} topic">
{% icon question %} Topic FAQs
</a>
{% endif %}
{% endunless %}
{% endif %}
<a class="dropdown-item" href="{{ site.help_url }}" title="Discuss on Galaxy Help">
Expand Down
27 changes: 14 additions & 13 deletions _layouts/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,13 @@
<meta charset="utf-8">
<meta http-equiv="x-ua-compatible" content="ie=edge">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<title>{{ page.title | default: site.title }}</title>

{%- assign topic_id = page | get_topic -%}
{%- assign topic = site.data[topic_id] -%}
{%- assign og_title = site | get_og_title:page,false -%}
{%- assign og_title_rev = site | get_og_title:page,true-%}

<title>{{ og_title_rev | default: site.title }}</title>
{% if jekyll.environment == 'production' %}
{% include _includes/analytics.html %}
{% endif %}
Expand All @@ -25,17 +31,12 @@
<meta name="theme-color" content="#2c3143"/>

{{ page | generate_dublin_core: site }}
{%- assign og_desc = page.description | default: page.excerpt | default:topic.summary | default: page.content | default: "Collection of tutorials developed and maintained by the worldwide Galaxy community" -%}

{% assign topic = site.data[page.topic_name] %}
{% assign og_title = topic.title %}
{% if page.title %}
{% assign og_title = page.title %}
{% endif %}
{% assign og_desc = page.description | default:topic.summary | default: "Collection of tutorials developed and maintained by the worldwide Galaxy community" %}
<meta name="description" content="{{ og_desc | strip_html}}">
<meta name="description" content="{{ og_desc | strip_html | regex_replace:'[\n\r\s]',' ' | truncate: 1000 }}">
<meta property="og:site_name" content="Galaxy Training Network">
<meta property="og:title" content="[{% if topic.title %}{{ topic.title }}{% endif %}]{% if page.layout == "faq" %}FAQS {% elsif page.layout == "topic" %}Topic: {% endif %}{{ og_title }} {% if page.layout == "workflow-list" %}Workflows{% endif %}">
<meta property="og:description" content="{{ og_desc | strip_html}}">
<meta property="og:title" content="{{ og_title | default: page.title }}">
<meta property="og:description" content="{{ og_desc | strip_html | regex_replace:'[\n\r\s]',' ' | truncate: 1000 }}">

{%- if page.cover %}{% assign coverimage = page.cover %}
{%- elsif page.tags contains "cofest" %}{% assign coverimage = "/assets/images/cofest.png" %}
Expand All @@ -45,11 +46,11 @@
{% assign og_image = page.og_image | default: coverimage | default: topic.og_image | default: "/assets/images/GTNLogo1000.png" %}
<meta property="og:image" content="{{ og_image | prepend: site.baseurl }}">

{% if page.layout == "tutorial_hands_on" %}
{%- if page.layout == "tutorial_hands_on" -%}
<script type="application/ld+json">
{% include _includes/material.jsonld material=page topic=topic site=site %}
{%- include _includes/material.jsonld material=page topic=topic site=site -%}
</script>
{% endif %}
{%- endif -%}
</head>
<body data-spy="scroll" data-target="#toc" data-brightness="auto" data-contrast="auto">
{{ 'theme' | load_bundle }}
Expand Down
1 change: 1 addition & 0 deletions _layouts/hall-of-fame.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
---
layout: base
lang: en
title: Hall of Fame
---

{% assign contributors = site.data['contributors'] %}
Expand Down
15 changes: 8 additions & 7 deletions _plugins/api.rb
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ def generateVersion(site)
# Returns:
# nil
def generateLibrary(site)
puts '[GTN/API] Data Library'
Jekyll.logger.info '[GTN/API] Data Library'
page2 = PageWithoutAFile.new(site, '', 'api/', 'data-library.yaml')
data_libraries = Dir.glob('topics/**/data-library.yaml')
data_libraries.map! { |x| YAML.load_file(x) }
Expand All @@ -123,9 +123,10 @@ def generate(site)
# TODO:
# generateLibrary(site)

Jekyll.logger.info '[GTN/API] Generating API'
# Full Bibliography
Gtn::Scholar.load_bib(site)
puts '[GTN/API] Bibliography'
Jekyll.logger.debug '[GTN/API] Bibliography'
page3 = PageWithoutAFile.new(site, '', 'api/', 'gtn.bib')
page3.content = site.config['cached_global_bib'].to_s
page3.data['layout'] = nil
Expand Down Expand Up @@ -156,7 +157,7 @@ def generate(site)
site.pages << page2

# Contributors
puts '[GTN/API] Contributors, Funders, Organisations'
Jekyll.logger.debug '[GTN/API] Contributors, Funders, Organisations'
%w[contributors funders organisations].each do |type|
page2 = PageWithoutAFile.new(site, '', 'api/', "#{type}.json")
page2.content = JSON.pretty_generate(site.data[type].map { |c, _| mapContributor(site, c) })
Expand Down Expand Up @@ -196,7 +197,7 @@ def generate(site)
site.pages << page2

# Trigger the topic cache to generate if it hasn't already
puts '[GTN/API] Tutorials'
Jekyll.logger.debug '[GTN/API] Tutorials'
TopicFilter.topic_filter(site, 'does-not-matter')
TopicFilter.list_topics(site).map do |topic|
out = site.data[topic].dup
Expand Down Expand Up @@ -238,7 +239,7 @@ def generate(site)
end

topics = {}
puts '[GTN/API] Topics'
Jekyll.logger.debug '[GTN/API] Topics'
# Individual Topic Indexes
site.data.each_pair do |k, v|
if v.is_a?(Hash) && v.key?('type') && v.key?('editorial_board')
Expand Down Expand Up @@ -277,7 +278,7 @@ def generate(site)
page2.data['layout'] = nil
site.pages << page2

puts '[GTN/API] Tutorial and Slide pages'
Jekyll.logger.debug '[GTN/API] Tutorial and Slide pages'

TopicFilter.list_all_materials(site).each do |material|
directory = material['dir']
Expand Down Expand Up @@ -316,7 +317,7 @@ def generate(site)
site.pages << page2

# Top Tools
puts '[GTN/API] Top Tools'
Jekyll.logger.debug '[GTN/API] Top Tools'
page2 = PageWithoutAFile.new(site, '', 'api/', 'top-tools.json')
page2.content = JSON.pretty_generate(TopicFilter.list_materials_by_tool(site))
page2.data['layout'] = nil
Expand Down
4 changes: 2 additions & 2 deletions _plugins/by-tag-pages.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def generate(site)
'hidden' => true,
}

topic_index = PageWithoutAFile.new(site, '', "tags/#{tag}", 'index.md')
topic_index = PageWithoutAFile.new(site, '', "tags/#{Jekyll::Utils.slugify(tag)}", 'index.md')
topic_index.content = ''
topic_index.data['layout'] = 'topic'
topic_index.data['topic_name'] = "by_tag_#{tag}"
Expand All @@ -33,7 +33,7 @@ def generate(site)

Jekyll.logger.info '[GTN/SyntheticTopics] Generating By-Tag Embeds'
TopicFilter.list_all_tags(site).map do |tag|
topic_index = PageWithoutAFile.new(site, '', "tags/#{tag}", 'embed.html')
topic_index = PageWithoutAFile.new(site, '', "tags/#{Jekyll::Utils.slugify(tag)}", 'embed.html')
topic_index.content = ''
topic_index.data['layout'] = 'topic-embed'
topic_index.data['topic_name'] = "by_tag_#{tag}"
Expand Down
57 changes: 57 additions & 0 deletions _plugins/gtn.rb
Original file line number Diff line number Diff line change
Expand Up @@ -397,6 +397,63 @@ def get_topic(page)
page['path'].split('/')[1]
end

def get_og_desc(site, page); end

def get_og_title(site, page, reverse)
og_title = []
topic_id = page['path'].gsub(%r{^\./}, '').split('/')[1]

if site.data.key?(topic_id)
if site.data[topic_id].is_a?(Hash) && site.data[topic_id].key?('title')
og_title = [site.data[topic_id]['title']]
else
Jekyll.logger.warn "Missing title for #{topic_id}"
end
end

if page['layout'] == 'topic'
og_title.push 'Tutorial List'
return og_title.join(' / ')
end

material_id = page['path'].gsub(%r{^\./}, '').split('/')[3]
material = nil
material = fetch_tutorial_material(site, topic_id, material_id) if site.data.key? topic_id

og_title.push material['title'] if !material.nil?

case page['layout']
when 'workflow-list'
og_title.push 'Workflows'
when 'faq-page', 'faqs'
if page['path'] =~ %r{faqs/gtn}
og_title.push 'GTN FAQs'
elsif page['path'] =~ %r{faqs/galaxy}
og_title.push 'Galaxy FAQs'
else
og_title.push 'FAQs'
end
when 'faq'
og_title.push "FAQ: #{page['title']}"
when 'learning-pathway'
og_title.push "Learning Pathway: #{page['title']}"
when 'tutorial_hands_on'
og_title[-1]&.prepend 'Hands-on: '
when /slides/
og_title[-1]&.prepend 'Slide Deck: '
else
og_title.push page['title']
end

Jekyll.logger.debug "Material #{page['layout']} :: #{page['path']} => #{topic_id}/#{material_id} => #{og_title}"

if reverse.to_s == 'true'
og_title.compact.reverse.join(' / ')
else
og_title.compact.join(' / ')
end
end

##
# Gets the 'default' link for a material, hands on if it exists, otherwise slides.
# Params:
Expand Down
2 changes: 1 addition & 1 deletion _plugins/gtn/boxify.rb
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ def self.generate_static_title(box_type, title, lang = 'en', key, noprefix: fals
box_id = get_id(box_type, title, key)
box_title = format_box_title(title, box_type, lang, noprefix: noprefix)

puts "Static | typ=#{box_type} | t=#{title} | l=#{lang} | k=#{key}" if title.nil?
Jekyll.logger.debug "Static | typ=#{box_type} | t=#{title} | l=#{lang} | k=#{key}" if title.nil?

[box_id, %(
<div class="box-title #{box_type}-title" id="#{box_id}">
Expand Down
15 changes: 8 additions & 7 deletions _plugins/gtn/mod.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ def self.init_cache

@@TIME_CACHE = {}
@@COMMIT_COUNT_CACHE = Hash.new(0)
puts '[GTN/Time/Mod] Filling Time Cache'
Jekyll.logger.info '[GTN/Time/Mod] Filling Time Cache'
`git log --name-only --pretty='GTN_GTN:%ct'`
.split('GTN_GTN:')
.map { |x| x.split("\n\n") }
Expand Down Expand Up @@ -79,7 +79,7 @@ def self.init_cache
@@TIME_CACHE = {}
renames = {}

puts '[GTN/Time/Pub] Filling Publication Time Cache'
Jekyll.logger.info '[GTN/Time/Pub] Filling Publication Time Cache'
`git log --first-parent --name-status --diff-filter=AR --pretty='GTN_GTN:%ct' main`
.split('GTN_GTN:')
.map { |x| x.split("\n\n") }
Expand Down Expand Up @@ -125,9 +125,10 @@ def self.obtain_time(f)
# Gtn::ModificationTimes.init_cache
# pp Gtn::ModificationTimes.commit_count_cache

Gtn::PublicationTimes.init_cache
Gtn::PublicationTimes.time_cache.select do |_, v|
# Things in last 6 months
v > Time.now - (6 * 30 * 24 * 60 * 60)
end.map { |k, v| puts "#{v} #{k}" }
puts ' Moved tobin/list-recently-modified.rb'
# Gtn::PublicationTimes.init_cache
# Gtn::PublicationTimes.time_cache.select do |_, v|
# # Things in last 6 months
# v > Time.now - (6 * 30 * 24 * 60 * 60)
# end.map { |k, v| puts "#{v} #{k}" }
end
4 changes: 2 additions & 2 deletions _plugins/gtn/scholar.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def self.render_citation(key)
end

def self.discover_bib
puts '[GTN/scholar] Creating global bib cache'
Jekyll.logger.info '[GTN/scholar] Creating global bib cache'
global_bib = BibTeX::Bibliography.new
bib_paths = [Find.find('./topics'), Find.find('./faqs'), Find.find('./news')].lazy.flat_map(&:lazy).grep(/bib$/)
bib_paths.each do |path|
Expand All @@ -39,7 +39,7 @@ def self.discover_bib
global_bib << x
end
end
puts "[GTN/scholar] Done: #{global_bib.length}"
Jekyll.logger.info "[GTN/scholar] Done: #{global_bib.length}"
style = CSL::Style.load('_layouts/g3.csl')
cp = CiteProc::Processor.new style: style,
format: 'html', locale: 'en'
Expand Down
2 changes: 1 addition & 1 deletion _plugins/jekyll-boxify.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ def initialize(config) # :nodoc:
end

def generate(site) # :nodoc:
puts '[GTN/Boxify]'
Jekyll.logger.info '[GTN/Boxify]'
site.pages.each { |page| boxify page, site }
site.posts.docs.each { |post| boxify post, site }
end
Expand Down
4 changes: 2 additions & 2 deletions _plugins/jekyll-scholar.rb
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ def render(context)
res = %(<span class="citation"><a href="##{@text}">#{citation_text}</a></span>)
end
rescue StandardError => e
puts "[GTN/scholar] Could not render #{@text} from #{source_page} (#{e})"
Jekyll.logger.warn "[GTN/scholar] Could not render #{@text} from #{source_page} (#{e})"
res = %(<span>ERROR INVALID CITATION #{@text}</span>)
end

Expand Down Expand Up @@ -108,7 +108,7 @@ def render(context)
end
res = url
rescue StandardError => e
puts "[GTN/scholar] Could not render #{@text} from #{source_page} (#{e})"
Jekyll.logger.warn "[GTN/scholar] Could not render #{@text} from #{source_page} (#{e})"
res = %(<span>https://example.com/ERROR+INVALID+CITATION+#{@text}</span>)
end
res
Expand Down
10 changes: 5 additions & 5 deletions _plugins/jekyll-topic-filter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,14 @@ def self.enumerate_topics(site)
def self.fill_cache(site)
return if site.data.key?('cache_topic_filter')

puts '[GTN/TopicFilter] Begin Cache Prefill'
Jekyll.logger.debug '[GTN/TopicFilter] Begin Cache Prefill'
site.data['cache_topic_filter'] = {}

# For each topic
list_topics(site).each do |topic|
site.data['cache_topic_filter'][topic] = filter_by_topic(site, topic)
end
puts '[GTN/TopicFilter] End Cache Prefill'
Jekyll.logger.debug '[GTN/TopicFilter] End Cache Prefill'
end

##
Expand Down Expand Up @@ -183,7 +183,8 @@ def self.list_materials_structured(site, topic_name)
def self.fetch_tutorial_material(site, topic_name, tutorial_name)
fill_cache(site)
if site.data['cache_topic_filter'][topic_name].nil?
Jekyll.logger.warn "Topic cache not filled, cannot fetch tutorial material for #{topic_name}"
Jekyll.logger.warn "Cannot fetch tutorial material for #{topic_name}"
nil
else
site.data['cache_topic_filter'][topic_name].select { |p| p['tutorial_name'] == tutorial_name }[0]
end
Expand Down Expand Up @@ -582,7 +583,7 @@ def self.process_pages(site, pages)
return site.data['cache_processed_pages'] if site.data.key?('cache_processed_pages')

materials = collate_materials(site, pages).map { |_k, v| resolve_material(site, v) }
puts '[GTN/TopicFilter] Filling Materials Cache'
Jekyll.logger.info '[GTN/TopicFilter] Filling Materials Cache'
site.data['cache_processed_pages'] = materials

# Prepare short URLs
Expand Down Expand Up @@ -874,7 +875,6 @@ def recently_published_tutorials(site)
Gtn::PublicationTimes.obtain_time(y.path) <=> Gtn::PublicationTimes.obtain_time(x.path)
end

latest.each { |x| puts [x.path, Gtn::PublicationTimes.obtain_time(x.path)] }
latest.slice(0, 10)
end

Expand Down
2 changes: 1 addition & 1 deletion _plugins/jekyll-webfinger.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

Jekyll::Hooks.register :site, :post_write do |site|
# Make the directory
Jekyll.logger.info 'Generating webfinger files'
Jekyll.logger.info '[GTN/Webfinger] Generating webfinger files'
FileUtils.mkdir_p "#{site.dest}/api/fedi"

Gtn::Contributors.list(site)
Expand Down
Loading

0 comments on commit 9731cb3

Please sign in to comment.