diff options
| author | s-ol <s+removethis@s-ol.nu> | 2022-03-28 13:58:08 +0000 |
|---|---|---|
| committer | s-ol <s+removethis@s-ol.nu> | 2022-03-28 14:24:26 +0000 |
| commit | 269d9986c12e277eb6fd5241f34c027c439f84ae (patch) | |
| tree | 748f965272ada1293b5d5f12420f9f7cb069c0fa /root/$mmm/plugins/youtube/converts: text$lua -> table.lua | |
| parent | move layout into user content (diff) | |
| download | mmm-269d9986c12e277eb6fd5241f34c027c439f84ae.tar.gz mmm-269d9986c12e277eb6fd5241f34c027c439f84ae.zip | |
fix plugins in example root
Diffstat (limited to 'root/$mmm/plugins/youtube/converts: text$lua -> table.lua')
| -rw-r--r-- | root/$mmm/plugins/youtube/converts: text$lua -> table.lua | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/root/$mmm/plugins/youtube/converts: text$lua -> table.lua b/root/$mmm/plugins/youtube/converts: text$lua -> table.lua new file mode 100644 index 0000000..de5b8a8 --- /dev/null +++ b/root/$mmm/plugins/youtube/converts: text$lua -> table.lua @@ -0,0 +1,24 @@ +local iframe +iframe = require('mmm.dom').iframe +return { + { + inp = 'URL -> youtube/video', + out = 'mmm/dom', + cost = -4, + transform = function(self, link) + local id = link:match('youtu%.be/([^/]+)') + id = id or link:match('youtube.com/watch.*[?&]v=([^&]+)') + id = id or link:match('youtube.com/[ev]/([^/]+)') + id = id or link:match('youtube.com/embed/([^/]+)') + assert(id, "couldn't parse youtube URL: '" .. tostring(link) .. "'") + return iframe({ + width = 560, + height = 315, + border = 0, + frameborder = 0, + allowfullscreen = true, + src = "//www.youtube.com/embed/" .. tostring(id) + }) + end + } +} |
