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

Add support for providing alt text #4

Open
wants to merge 3 commits into
base: glitch
Choose a base branch
from
Open
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
17 changes: 10 additions & 7 deletions server.js
Original file line number Diff line number Diff line change
Expand Up @@ -178,18 +178,21 @@ app.get('/preview/:id', requireGfycatToken, (request, response) => {

/* Login needed here */
app.post('/post', requireLogin, (request, response) => {
var props = { photo: [ request.body.originalUrl ] }
if (request.body.inReplyTo) {
props['in-reply-to'] = [ request.body.inReplyTo ]
var params = {
h: 'entry',
photo: request.body.originalUrl
}
if (request.body.inReplyTo && request.body.inReplyTo.length != 0) {
params['in-reply-to'] = request.body.inReplyTo
}
if (request.body.altText && request.body.altText.length != 0) {
params['mp-photo-alt'] = request.body.altText
}
const micropub = new Micropub({
token: request.session.user.token,
micropubEndpoint: request.session.user.micropubEndpoint
})
micropub.create({
type: ['h-entry'],
properties: props
})
micropub.create(params, 'form')
.then((url) => response.redirect(url))
.catch((err) => console.log(err))
})
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