Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Audio embedding #418

Merged
merged 3 commits into from
Feb 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

- Bug fixes
- Make Stork recognize orgmode notes ([\#413](https://github.com/srid/emanote/issues/413))
- Features
- Audio embedding ([\#418](https://github.com/srid/emanote/pull/418))
- Misc
- Update Ema to simplify the live server websocket observation logic

Expand Down
5 changes: 5 additions & 0 deletions default/templates/filters/embed-audio.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<audio controls preload="metadata" src="${ema:url}">
Your browser doesn't support HTML5 audio. Here is a
<a class="text-${theme}-600 hover:underline" href="${ema:url}">link to the audio</a>
instead.
</audio>
Binary file added docs/guide/markdown/cat.ogg
Binary file not shown.
5 changes: 5 additions & 0 deletions docs/guide/markdown/embed.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,11 @@ The following is the result of using `![[death-note.mp4]]` (note that `![](death

![[death-note.mp4]]

### Audio

The following is the result of using `![[cat.ogg]]` (note that `![](cat.ogg)` also works).

![[cat.ogg]]

### PDFs

Expand Down
2 changes: 1 addition & 1 deletion emanote.cabal
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
cabal-version: 2.4
name: emanote
version: 1.0.3.2
version: 1.0.3.3
license: AGPL-3.0-only
copyright: 2022 Sridhar Ratnakumar
maintainer: [email protected]
Expand Down
14 changes: 14 additions & 0 deletions src/Emanote/Pandoc/Renderer/Embed.hs
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,9 @@ embedStaticFileRoute model altText staticFile = do
| any (`T.isSuffixOf` toText fp) videoExts -> do
pure . runEmbedTemplate "video" $ do
"ema:url" ## HI.textSplice url
| any (`T.isSuffixOf` toText fp) audioExts -> do
pure . runEmbedTemplate "audio" $ do
"ema:url" ## HI.textSplice url
| ".pdf" `T.isSuffixOf` toText fp -> do
pure . runEmbedTemplate "pdf" $ do
"ema:url" ## HI.textSplice url
Expand All @@ -108,3 +111,14 @@ videoExts =
, ".webm"
, ".ogv"
]

audioExts :: [Text]
audioExts =
[ ".aac"
, ".caf"
, ".flac"
, ".mp3"
, ".ogg"
, ".wav"
, ".wave"
]