forked from wgroeneveld/go-jamming
brid.gy works! ... but I used the wrong url.
This commit is contained in:
parent
e611198801
commit
94939baaf3
|
@ -40,3 +40,7 @@ Will result in a `202 Accepted` - it handles things async. Stores in `.json` fil
|
|||
|
||||
Retrieves a JSON array with relevant webmentions stored for that domain. The token should match. See `config.js` to fiddle with it yourself. Environment variables are supported, although I haven't used them yet.
|
||||
|
||||
## TODOs
|
||||
|
||||
- `published` date is not well-formatted and blindly taken over from feed
|
||||
|
||||
|
|
|
@ -71,23 +71,30 @@ function publishedNow() {
|
|||
}
|
||||
|
||||
function parseBodyAsIndiewebSite(source, target, hEntry) {
|
||||
function shorten(txt) {
|
||||
if(txt.length <= 250) return txt
|
||||
return txt.substring(0, 250) + "..."
|
||||
}
|
||||
|
||||
const authorPropName = hEntry.properties?.author?.[0]?.properties?.name?.[0]
|
||||
const authorValue = hEntry.properties?.author?.[0]?.value
|
||||
const picture = hEntry.properties?.author?.[0]?.properties?.photo?.[0]?.value
|
||||
const picture = hEntry.properties?.author?.[0]?.properties?.photo?.[0]
|
||||
const summary = hEntry.properties?.summary?.[0]
|
||||
const contentEntry = hEntry.properties?.content?.[0]?.value?.substring(0, 250) + "..."
|
||||
const contentEntry = hEntry.properties?.content?.[0]?.value
|
||||
const publishedDate = hEntry.properties?.published?.[0]
|
||||
const url = hEntry.properties?.url?.[0]
|
||||
|
||||
return {
|
||||
author: {
|
||||
name: authorPropName ? authorPropName : authorValue,
|
||||
picture
|
||||
picture: picture.value ? picture.value : picture
|
||||
},
|
||||
content: summary ? summary : contentEntry,
|
||||
content: summary ? shorten(summary) : shorten(contentEntry),
|
||||
published: publishedDate ? publishedDate : publishedNow(),
|
||||
url: url ? url : source,
|
||||
source,
|
||||
target
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function parseBodyAsNonIndiewebSite(source, target, body) {
|
||||
|
|
|
@ -0,0 +1,60 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta http-equiv="refresh" content="0;url=https://social.linux.pizza/@StampedingLonghorn/105821099684887793">
|
||||
<title><p><span class="h-card"><a href="https://chat.brainbaking.com/users/wouter" class="u-url mention">@<span>wouter</span></a></span> <br/>The cat pictures are awesome.</p></title>
|
||||
<style type="text/css">
|
||||
body {
|
||||
font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
|
||||
}
|
||||
.p-uid {
|
||||
display: none;
|
||||
}
|
||||
.u-photo {
|
||||
max-width: 50px;
|
||||
border-radius: 4px;
|
||||
}
|
||||
.e-content {
|
||||
margin-top: 10px;
|
||||
font-size: 1.3em;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<article class="h-entry">
|
||||
<span class="p-uid">tag:chat.brainbaking.com,2013:A4nxN8ytch0BW2FVXU</span>
|
||||
|
||||
<time class="dt-published" datetime="2021-03-02T16:17:18.000Z">2021-03-02T16:17:18.000Z</time>
|
||||
|
||||
<span class="p-author h-card">
|
||||
<data class="p-uid" value="tag:social.linux.pizza,2013:StampedingLonghorn"></data>
|
||||
<data class="p-numeric-id" value="A4nwg4LYyh4WgrJOXg"></data>
|
||||
<a class="p-name u-url" href="https://social.linux.pizza/@StampedingLonghorn">Stampeding Longhorn</a>
|
||||
<a class="u-url" href="https://chat.brainbaking.com/@StampedingLonghorn"></a>
|
||||
<span class="p-nickname">StampedingLonghorn</span>
|
||||
<img class="u-photo" src="https://cdn.social.linux.pizza/v1/AUTH_91eb37814936490c95da7b85993cc2ff/sociallinuxpizza/accounts/avatars/000/185/996/original/9e36da0c093cfc9b.png" alt="" />
|
||||
</span>
|
||||
|
||||
<a class="u-url" href="https://social.linux.pizza/@StampedingLonghorn/105821099684887793">https://social.linux.pizza/@StampedingLonghorn/105821099684887793</a>
|
||||
<div class="e-content p-name">
|
||||
|
||||
<p><span class="h-card"><a href="https://chat.brainbaking.com/users/wouter" class="u-url mention">@<span>wouter</span></a></span> <br/>The cat pictures are awesome. <a href="https://brainbaking.com/valid-indieweb-target.html">for jest tests!</a> </p>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
<span class="u-category h-card">
|
||||
<data class="p-uid" value="tag:chat.brainbaking.com,2013:A4f9wfZ2T2inoco70K"></data>
|
||||
<a class="p-name u-url" href="https://chat.brainbaking.com/users/wouter">wouter</a>
|
||||
|
||||
|
||||
</span>
|
||||
|
||||
<a class="u-in-reply-to" href="https://brainbaking.com/post/2021/02/my-retro-desktop-setup/"></a>
|
||||
<a class="u-in-reply-to" href="https://chat.brainbaking.com/web/statuses/A4nx1rFwKUJYSe4TqK"></a>
|
||||
|
||||
|
||||
</article>
|
||||
|
||||
</html>
|
|
@ -26,6 +26,29 @@ describe("receive webmention process tests happy path", () => {
|
|||
return `${dumpdir}/` + md5(`source=${body.source},target=${body.target}`)
|
||||
}
|
||||
|
||||
test("receive a brid.gy webmention that has a url and photo without value", async () => {
|
||||
const body = {
|
||||
source: "https://brainbaking.com/valid-bridgy-source.html",
|
||||
target: "https://brainbaking.com/valid-indieweb-target.html"
|
||||
}
|
||||
await receive(body)
|
||||
|
||||
const result = await fsp.readFile(`${asFilename(body)}.json`, 'utf-8')
|
||||
const data = JSON.parse(result)
|
||||
|
||||
expect(data).toEqual({
|
||||
author: {
|
||||
name: "Stampeding Longhorn",
|
||||
picture: "https://cdn.social.linux.pizza/v1/AUTH_91eb37814936490c95da7b85993cc2ff/sociallinuxpizza/accounts/avatars/000/185/996/original/9e36da0c093cfc9b.png"
|
||||
},
|
||||
url: "https://social.linux.pizza/@StampedingLonghorn/105821099684887793",
|
||||
content: "@wouter The cat pictures are awesome. for jest tests!",
|
||||
source: body.source,
|
||||
target: body.target,
|
||||
published: "2021-03-02T16:17:18.000Z"
|
||||
})
|
||||
})
|
||||
|
||||
test("receive saves a JSON file of indieweb-metadata if all is valid", async () => {
|
||||
const body = {
|
||||
source: "https://brainbaking.com/valid-indieweb-source.html",
|
||||
|
@ -41,7 +64,8 @@ describe("receive webmention process tests happy path", () => {
|
|||
name: "Wouter Groeneveld",
|
||||
picture: "https://brainbaking.com//img/avatar.jpg"
|
||||
},
|
||||
content: "This is cool, I just found out about valid indieweb target - so cool...",
|
||||
url: "https://brainbaking.com/notes/2021/03/06h12m41s48/",
|
||||
content: "This is cool, I just found out about valid indieweb target - so cool",
|
||||
source: body.source,
|
||||
target: body.target,
|
||||
published: "2021-03-06T12:41:00"
|
||||
|
@ -63,6 +87,7 @@ describe("receive webmention process tests happy path", () => {
|
|||
name: "Wouter Groeneveld",
|
||||
picture: "https://brainbaking.com//img/avatar.jpg"
|
||||
},
|
||||
url: "https://brainbaking.com/notes/2021/03/06h12m41s48/",
|
||||
content: "This is cool, this is a summary!",
|
||||
source: body.source,
|
||||
target: body.target,
|
||||
|
@ -115,5 +140,4 @@ describe("receive webmention process tests happy path", () => {
|
|||
expect(data.length).toBe(0)
|
||||
})
|
||||
|
||||
|
||||
})
|
||||
|
|
Loading…
Reference in New Issue