Skip to content
This repository has been archived by the owner on Nov 26, 2022. It is now read-only.

Commit

Permalink
Add support for providing alt text
Browse files Browse the repository at this point in the history
To make published GIFs, via Micropub, more accessible, we should allow
alt text to be added to the images.

As per conversation on #3, this can't be reliably done through the
Gfycat API, so we should instead allow the user to provide this
information.

As we're using a JSON post, we need to construct an object for the
photo property as per https://micropub.spec.indieweb.org/#json-syntax

Closes #3.
  • Loading branch information
jamietanna committed Jan 16, 2021
1 parent f4e31af commit 4f5fde4
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
12 changes: 11 additions & 1 deletion server.js
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,17 @@ app.get('/preview/:id', requireGfycatToken, (request, response) => {

/* Login needed here */
app.post('/post', requireLogin, (request, response) => {
var props = { photo: [ request.body.originalUrl ] }
var photo = []
if (request.body.altText && request.body.altText.length != 0) {
photo.push({
value: request.body.originalUrl,
alt: request.body.altText
})
} else {
photo.push(request.body.originalUrl)
}
var props = { photo: photo }

if (request.body.inReplyTo) {
props['in-reply-to'] = [ request.body.inReplyTo ]
}
Expand Down
1 change: 1 addition & 0 deletions views/preview.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
</label>

<input type="hidden" name="originalUrl" value="{{ content_urls.largeGif.url }}" />
<input type="text" name="altText" placeholder="Alt text for the GIF, increase the accessibility of the post" />
{{#if ../inReplyTo }}<input type="hidden" name="inReplyTo" value="{{ ../inReplyTo }}" />{{/if}}
<input id="post-gif" type="submit" value="Post this GIF" />
</form>
Expand Down

0 comments on commit 4f5fde4

Please sign in to comment.