Skip to content

Commit

Permalink
Merge branch 'galaxyproject:main' into ampvis2_tutorialfirst_upload
Browse files Browse the repository at this point in the history
  • Loading branch information
lenaarenot authored Jun 4, 2024
2 parents e2dfb8c + 88d822b commit 3e51bc5
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 15 deletions.
21 changes: 10 additions & 11 deletions _plugins/gtn.rb
Original file line number Diff line number Diff line change
Expand Up @@ -815,17 +815,6 @@ def find_learningpaths_including_topic(site, topic_id)
Liquid::Template.register_filter(Jekyll::GtnFunctions)

##
# This does post-modification to every page
# Mapping the authors to their human names, and copying the cover (when present) to 'image'
#
# This exists because the jekyll-feed plugin expects those fields to look like that.
Jekyll::Hooks.register :posts, :pre_render do |post, _out|
post.data['author'] = Gtn::Contributors.get_authors(post.data).map do |c|
Gtn::Contributors.fetch_name(post.site, c)
end.join(', ')
post.data['image'] = post.data['cover']
end

# We're going to do some find and replace, to replace `@gtn:contributorName` with a link to their profile.
Jekyll::Hooks.register :site, :pre_render do |site|
site.posts.docs.each do |post|
Expand Down Expand Up @@ -960,6 +949,16 @@ def find_learningpaths_including_topic(site, topic_id)
end

end

# This exists because the jekyll-feed plugin expects those fields to look like that.
posts.each do |post|
post.data['author'] = Gtn::Contributors.get_authors(post.data).map do |c|
Gtn::Contributors.fetch_name(post.site, c)
end.join(', ')
if post.data.key? 'cover'
post.data['image'] = post.data['cover']
end
end
end

if $PROGRAM_NAME == __FILE__
Expand Down
8 changes: 4 additions & 4 deletions _plugins/gtn/contributors.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,12 @@ def self.get_contributors(data)
# +Array+ of contributor IDs
def self.get_authors(data)
if data.key?('contributors')
data['contributors']
data['contributors'] || []
elsif data.key?('contributions')
data['contributions']['authorship']
data['contributions']['authorship'] || []
else
[]
end

[]
end

##
Expand Down

0 comments on commit 3e51bc5

Please sign in to comment.