-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
6255666
commit 4b92ea4
Showing
78 changed files
with
1,284 additions
and
20,310 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 = '<script src="https://gist.github.com/' | ||
.. user | ||
.. '/' | ||
.. gist_id | ||
.. '.js' | ||
.. file_fragment | ||
.. '"></script>' | ||
|
||
return pandoc.RawInline('html', html) | ||
else | ||
return pandoc.Null() | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 = '<div style="position: relative; padding-bottom: 56.25%; height: 0;"><iframe src="https://www.loom.com/embed/' | ||
.. videoid | ||
.. '" frameborder="0" webkitallowfullscreen mozallowfullscreen allowfullscreen style="position: absolute; top: 0; left: 0; width: 100%; height: 100%;"></iframe></div>' | ||
|
||
return pandoc.RawInline('html', html) | ||
else | ||
return pandoc.Null() | ||
end | ||
end | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 = '<div style="position: relative; padding-bottom: 56.25%; height: 0;"> <iframe src="'.. status_url ..'/embed" class="mastodon-embed" style="max-width: 100%; border: 0;" width="100%" height="400" allowfullscreen="allowfullscreen"></iframe><script src="https://mastodon.social/embed.js" async="async"></script></div> ' | ||
|
||
return pandoc.RawInline('html', html) | ||
else | ||
return pandoc.Null() | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 = '<div id="tweet-' | ||
.. id | ||
.. '"></div><script>tweet=' | ||
.. api_resp | ||
.. ';document.getElementById("tweet-' | ||
.. id | ||
.. '").innerHTML = tweet["html"];</script>' | ||
|
||
return pandoc.RawInline('html', tweet_data) | ||
else | ||
return pandoc.Null() | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 = '<div style="position: relative; padding-bottom: 56.25%; height: 0; overflow: hidden;"> <iframe src="https://player.vimeo.com/video/' | ||
.. videoid | ||
.. '" style="position: absolute; top: 0; left: 0; width: 100%; height: 100%; border:0;" title="vimeo video" webkitallowfullscreen mozallowfullscreen allowfullscreen></iframe> </div> ' | ||
|
||
return pandoc.RawInline('html', html) | ||
else | ||
return pandoc.Null() | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 = '<div id="youtube-frame" style="position: relative; padding-bottom: 56.25%; /* 16:9 */ height: 0;"><iframe width="100%" height="" style="position: absolute; top: 0; left: 0; width: 100%; height: 100%;" src="https://www.youtube.com/embed/' | ||
.. videoid | ||
.. '" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe></div>' | ||
|
||
return pandoc.RawInline('html', html) | ||
else | ||
return pandoc.Null() | ||
end | ||
end |
Oops, something went wrong.