Skip to content

Commit 2de3fc2

Browse files
committed
feat: add actual tumblr support
1 parent b925a11 commit 2de3fc2

File tree

4 files changed

+37
-8
lines changed

4 files changed

+37
-8
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
# ghostposter
22

33
Ingest a Ghost webhook and post to the major social media platforms.
4-
So far, this supports Bluesky, Twitter and Mastodon. Tumblr support coming as soon as i can get my account unlocked (dunno what's up with that...)
4+
So far, this supports Bluesky, Twitter, Mastodon and Tumblr.

src/app.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ async function post(post) {
2121
postHandlers?.bsky(post);
2222
postHandlers?.twitter(post);
2323
postHandlers?.masto(post);
24+
postHandlers?.tumblr(post);
2425
}
2526

2627
// parses the webhook and returns some text and the link
@@ -72,4 +73,21 @@ app.post("/hook", express.json(), (req, res) => {
7273

7374
app.listen(port, () => {
7475
console.log(`ghostposter listening on http://localhost:${port}/hook`);
76+
});
77+
excerpt: "Well, not entirely. But they're pretty uncommon now, in 1.1.2",
78+
reading_time: 0,
79+
og_image: null,
80+
og_title: null,
81+
og_description: null,
82+
twitter_image: null,
83+
twitter_title: null,
84+
twitter_description: null,
85+
meta_title: null,
86+
meta_description: null,
87+
email_subject: null,
88+
frontmatter: null,
89+
feature_image_alt: "image alt text",
90+
feature_image_caption:
91+
'<span style="white-space: pre-wrap;">Photo by </span><a href="https://unsplash.com/@berkayekener?utm_source=ghost&amp;utm_medium=referral&amp;utm_campaign=api-credit"><span style="white-space: pre-wrap;">Berkay Ekener</span></a><span style="white-space: pre-wrap;"> / </span><a href="https://unsplash.com/?utm_source=ghost&amp;utm_medium=referral&amp;utm_campaign=api-credit"><span style="white-space: pre-wrap;">Unsplash</span></a>',
92+
email_only: false,
7593
});

src/lib/postHandlers.js

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import * as bsky from "./bsky.js";
22
import * as twitter from "./twitter.js";
33
import * as masto from "./masto.js";
4-
//import * as tumblr from "./tumblr.js";
4+
import * as tumblr from "./tumblr.js";
55

66
export default async function setUpPostHandlers() {
77
const postHandlers = {};
@@ -39,5 +39,16 @@ export default async function setUpPostHandlers() {
3939
console.log("[ERROR] Masto:\n", e);
4040
}
4141

42+
// tumblr
43+
try {
44+
const client = await tumblr.login();
45+
46+
postHandlers.tumblr = (post) => {
47+
tumblr.post(client, post);
48+
};
49+
} catch (e) {
50+
console.log("[ERROR] Tumblr:\n", e);
51+
}
52+
4253
return postHandlers;
4354
}

src/lib/tumblr.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,25 +2,25 @@ import * as tumblr from "tumblr.js";
22

33
export async function login() {
44
const client = tumblr.createClient({
5-
consumer_key: "<consumer key>",
6-
consumer_secret: "<consumer secret>",
7-
token: "<oauth token>",
8-
token_secret: "<oauth token secret>",
5+
consumer_key: process.env.TUMBLR_CONSUMER_KEY,
6+
consumer_secret: process.env.TUMBLR_CONSUMER_SECRET,
7+
token: process.env.TUMBLR_TOKEN,
8+
token_secret: process.env.TUMBLR_TOKEN_SECRET,
99
});
1010

1111
return client;
1212
}
1313

1414
export async function post(client, post) {
15-
await client.createPost(blogName, {
15+
await client.createPost(process.env.TUMBLR_BLOG_NAME, {
1616
content: [
1717
{
1818
type: "text",
1919
text: post.title,
2020
},
2121
{
2222
type: "text",
23-
text: "post.url",
23+
text: post.url,
2424
formatting: [
2525
{
2626
start: 0,

0 commit comments

Comments
 (0)