diff --git a/docs/site_libs/quarto-contrib/twitter-0.0.1/_extension.yml b/docs/site_libs/quarto-contrib/twitter-0.0.1/_extension.yml new file mode 100644 index 000000000..d691b0501 --- /dev/null +++ b/docs/site_libs/quarto-contrib/twitter-0.0.1/_extension.yml @@ -0,0 +1,11 @@ +title: social-embeds +author: Mark Sellors +version: 0.0.2 +contributes: + shortcodes: + - gists.lua + - loom.lua + - twitter.lua + - vimeo.lua + - youtube.lua + - mastodon.lua diff --git a/docs/site_libs/quarto-contrib/twitter-0.0.1/gists.lua b/docs/site_libs/quarto-contrib/twitter-0.0.1/gists.lua new file mode 100644 index 000000000..36e801076 --- /dev/null +++ b/docs/site_libs/quarto-contrib/twitter-0.0.1/gists.lua @@ -0,0 +1,24 @@ +function gist(args) + if quarto.doc.isFormat('html') then + local user = pandoc.utils.stringify(args[1]) + local gist_id = pandoc.utils.stringify(args[2]) + local file_fragment = '' + if args[3] ~= nil then + local file = pandoc.utils.stringify(args[3]) + file_fragment = '?file=' .. file + end + + -- Assemble HTML to be returned + local html = '' + + return pandoc.RawInline('html', html) + else + return pandoc.Null() + end +end diff --git a/docs/site_libs/quarto-contrib/twitter-0.0.1/loom.lua b/docs/site_libs/quarto-contrib/twitter-0.0.1/loom.lua new file mode 100644 index 000000000..86b9130db --- /dev/null +++ b/docs/site_libs/quarto-contrib/twitter-0.0.1/loom.lua @@ -0,0 +1,15 @@ +function loom(args) + if quarto.doc.isFormat('html') then + local videoid = pandoc.utils.stringify(args[1]) + + -- Assemble HTML to be returned + local html = '
' + + return pandoc.RawInline('html', html) + else + return pandoc.Null() + end +end + diff --git a/docs/site_libs/quarto-contrib/twitter-0.0.1/mastodon.lua b/docs/site_libs/quarto-contrib/twitter-0.0.1/mastodon.lua new file mode 100644 index 000000000..17917022d --- /dev/null +++ b/docs/site_libs/quarto-contrib/twitter-0.0.1/mastodon.lua @@ -0,0 +1,12 @@ +function mastodon(args) + if quarto.doc.isFormat('html') then + local status_url = pandoc.utils.stringify(args[1]) + print(status_url) + -- Assemble HTML to be returned + local html = '
' + + return pandoc.RawInline('html', html) + else + return pandoc.Null() + end +end diff --git a/docs/site_libs/quarto-contrib/twitter-0.0.1/twitter.lua b/docs/site_libs/quarto-contrib/twitter-0.0.1/twitter.lua new file mode 100644 index 000000000..998e02fb2 --- /dev/null +++ b/docs/site_libs/quarto-contrib/twitter-0.0.1/twitter.lua @@ -0,0 +1,57 @@ +local function ensureHtmlDeps() + quarto.doc.addHtmlDependency({ + name = 'twitter', + version = '0.0.1', + scripts = { + { + path = "", + attribs = {src="https://platform.twitter.com/widgets.js"}, + afterBody = true + } + } + }) +end + +local function isEmpty(s) + return s == nil or s == '' +end + +function tweet(args, kwargs) + if quarto.doc.isFormat('html') then + ensureHtmlDeps() + + if isEmpty(args[1]) then + user = pandoc.utils.stringify(kwargs["user"]) + status_id = pandoc.utils.stringify(kwargs["id"]) + else + user = pandoc.utils.stringify(args[1]) + status_id = pandoc.utils.stringify(args[2]) + end + + -- Assemble the twitter oembed API URL from the user inputs + local tweet_embed = 'https://publish.twitter.com/oembed?url=https://twitter.com/' + .. user + .. '/status/' + .. status_id + .. '&align=center' + + print(tweet_embed) + + local mt, api_resp = pandoc.mediabag.fetch(tweet_embed) + + -- generate a random number to append to the html div ID to avoid re-use + local id = math.random(10000, 99999) + + local tweet_data = '
' + + return pandoc.RawInline('html', tweet_data) + else + return pandoc.Null() + end +end diff --git a/docs/site_libs/quarto-contrib/twitter-0.0.1/vimeo.lua b/docs/site_libs/quarto-contrib/twitter-0.0.1/vimeo.lua new file mode 100644 index 000000000..58784acf5 --- /dev/null +++ b/docs/site_libs/quarto-contrib/twitter-0.0.1/vimeo.lua @@ -0,0 +1,14 @@ +function vimeo(args) + if quarto.doc.isFormat('html') then + local videoid = pandoc.utils.stringify(args[1]) + + -- Assemble HTML to be returned + local html = '
' + + return pandoc.RawInline('html', html) + else + return pandoc.Null() + end +end diff --git a/docs/site_libs/quarto-contrib/twitter-0.0.1/youtube.lua b/docs/site_libs/quarto-contrib/twitter-0.0.1/youtube.lua new file mode 100644 index 000000000..ef5d49e32 --- /dev/null +++ b/docs/site_libs/quarto-contrib/twitter-0.0.1/youtube.lua @@ -0,0 +1,14 @@ +function youtube(args) + if quarto.doc.isFormat('html') then + local videoid = pandoc.utils.stringify(args[1]) + + -- Assemble HTML to be returned + local html = '
' + + return pandoc.RawInline('html', html) + else + return pandoc.Null() + end +end