mirror of
https://github.com/foo-dogsquared/asciidoctor-foodogsquared-extensions.git
synced 2025-01-30 22:57:56 +00:00
Change default behavior for creating network requests when caption is unset
This commit is contained in:
parent
bfbea57d6b
commit
924fd9eac5
@ -16,10 +16,8 @@ class FDroidLinkInlineMacro < Asciidoctor::Extensions::InlineMacroProcessor
|
||||
app_id = target
|
||||
app_metadata_uri = %(https://gitlab.com/fdroid/fdroiddata/-/raw/master/metadata/#{app_id}.yml)
|
||||
|
||||
if attrs['caption'].nil?
|
||||
metadata = OpenURI.open_uri(app_metadata_uri) { |f| YAML.safe_load(f.read) }
|
||||
attrs['caption'] = metadata['AutoName']
|
||||
end
|
||||
metadata = OpenURI.open_uri(app_metadata_uri) { |f| YAML.safe_load(f.read) }
|
||||
attrs['caption'] ||= metadata['AutoName']
|
||||
|
||||
url = %(https://f-droid.org/#{attrs['lang']}/packages/#{app_id})
|
||||
doc.register :links, url
|
||||
|
@ -23,10 +23,8 @@ class FlathubLinkInlineMacro < Asciidoctor::Extensions::InlineMacroProcessor
|
||||
'User-Agent' => ::Asciidoctor::FoodogsquaredCustomExtensions::USER_AGENT
|
||||
}
|
||||
|
||||
if attrs['caption'].nil?
|
||||
metadata = OpenURI.open_uri(app_metadata_uri, headers) { |f| JSON.parse(f.read) }
|
||||
attrs['caption'] = metadata['name']
|
||||
end
|
||||
metadata = OpenURI.open_uri(app_metadata_uri, headers) { |f| JSON.parse(f.read) }
|
||||
attrs['caption'] ||= metadata['name']
|
||||
|
||||
url = %(https://flathub.org/apps/#{app_id})
|
||||
doc.register :links, url
|
||||
|
@ -23,17 +23,15 @@ class MusicBrainzLinkInlineMacro < Asciidoctor::Extensions::InlineMacroProcessor
|
||||
|
||||
uri = %(#{root_endpoint}/#{attrs['type']}/#{target})
|
||||
|
||||
if attrs['caption'].nil?
|
||||
metadata = OpenURI.open_uri(uri, headers) { |f| JSON.parse(f.read) }
|
||||
attrs['caption'] ||= case attrs['type']
|
||||
when 'artist', 'area', 'events', 'genre', 'instrument', 'label', 'place', 'series'
|
||||
metadata['name']
|
||||
when 'recording', 'release-group', 'release', 'cdstub', 'work'
|
||||
metadata['title']
|
||||
when 'url'
|
||||
metadata['resource']
|
||||
end
|
||||
end
|
||||
metadata = OpenURI.open_uri(uri, headers) { |f| JSON.parse(f.read) }
|
||||
attrs['caption'] ||= case attrs['type']
|
||||
when 'artist', 'area', 'events', 'genre', 'instrument', 'label', 'place', 'series'
|
||||
metadata['name']
|
||||
when 'recording', 'release-group', 'release', 'cdstub', 'work'
|
||||
metadata['title']
|
||||
when 'url'
|
||||
metadata['resource']
|
||||
end
|
||||
|
||||
target = %(https://musicbrainz.org/#{attrs['type']}/#{target})
|
||||
doc.register :links, target
|
||||
|
Loading…
Reference in New Issue
Block a user