-
Notifications
You must be signed in to change notification settings - Fork 65
Social media automation: data sources and assets. #1215
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
Open
nikoshell
wants to merge
11
commits into
ep2025
Choose a base branch
from
ep2025-buffer
base: ep2025
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
4d1c7d1
Add csv and media images.
nikoshell 49f8806
Merge branch 'ep2025' into ep2025-buffer
nikoshell f426f87
Update csv.
nikoshell dc9b8da
Update buffer posts.
nikoshell ff1c193
Merge branch 'ep2025' into ep2025-buffer
nikoshell 99e374e
Update message.
nikoshell d7d0b44
Merge branch 'ep2025' into ep2025-buffer
nikoshell bfdca1b
Improve handlers.
nikoshell e7d3ac0
Improve handlers.
nikoshell 5b85771
Improve message.
nikoshell abedb20
Improve message.
nikoshell File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,170 @@ | ||
import { getCollection, getEntry } from "astro:content"; | ||
import type { APIRoute } from "astro"; | ||
|
||
// Get @username from Twitter URL | ||
function getTwitterUsername(url: string): string | undefined { | ||
if (!url) return undefined; | ||
const username = url.split("/").pop(); | ||
return (username ?? url).startsWith("@") ? username : `@${username}`; | ||
} | ||
|
||
// Get @username from Bluesky URL | ||
function getBlueskyUsername(url: string): string | undefined { | ||
if (!url) return undefined; | ||
const username = url.split("/").pop()?.replace(/^@/, ""); | ||
return username ? `@${username}` : undefined; | ||
} | ||
|
||
// Get Bluesky profile link from username | ||
function getBlueskyProfileLink(username: string): string { | ||
// Remove any leading @ if present | ||
const cleanUsername = username.replace(/^@/, ""); | ||
return `https://bsky.app/profile/${cleanUsername}`; | ||
} | ||
|
||
// Get @username@instance.tld from Mastodon URL | ||
function getMastodonUsername(url: string): string | undefined { | ||
if (!url) return undefined; | ||
const match = url.match(/https?:\/\/([^\/]+)\/@([^\/]+)(\/|\?|$)/); | ||
return match ? `@${match[2]}@${match[1]}` : undefined; | ||
} | ||
|
||
function getLinkedInUsernameHandler(url: string): string | undefined { | ||
if (!url) return undefined; | ||
const match = url.match(/https?:\/\/([^\/]+)\/in\/([^\/]+)(\/|\?|$)/); | ||
if (match) { | ||
try { | ||
return `https://www.linkedin.com/in/${decodeURIComponent(match[2])}`; | ||
} catch { | ||
return `https://www.linkedin.com/in/${match[2]}`; | ||
} | ||
} | ||
return undefined; | ||
} | ||
|
||
export const GET: APIRoute = async ({ params, request }) => { | ||
const limit = Infinity; | ||
const speakers = await getCollection("speakers"); | ||
const exclude = [ | ||
"sebastian-ramirez", | ||
"savannah-ostrowski", | ||
"nerea-luis", | ||
"petr-baudis", | ||
"brett-cannon", | ||
]; | ||
const records: any[] = []; | ||
|
||
const charLimits: Record<string, number> = { | ||
instagram: 2200, | ||
x: 280, | ||
linkedin: 3000, | ||
bsky: 300, | ||
fosstodon: 500, | ||
}; | ||
|
||
// Tailor message templates for each platform using appropriate handle formats | ||
const message_template = { | ||
instagram: ({ name, talkTitle, talkUrl }) => | ||
`Join ${name} at EuroPython for "${talkTitle}".`, | ||
|
||
x: ({ name, handle, talkTitle, talkUrl }) => | ||
handle | ||
? `Join ${name} (${handle}) at EuroPython for "${talkTitle}". Talk: ${talkUrl}` | ||
: `Join ${name} at EuroPython for "${talkTitle}". Talk: ${talkUrl}`, | ||
|
||
linkedin: ({ name, handle, talkTitle, talkUrl }) => | ||
`Join ${name} at EuroPython for "${talkTitle}".`, | ||
|
||
bsky: ({ name, handle, talkTitle, talkUrl }) => | ||
handle | ||
? `Join ${name} (${handle}) at EuroPython for "${talkTitle}". Talk: ${talkUrl}` | ||
: `Join ${name} at EuroPython for "${talkTitle}". Talk: ${talkUrl}`, | ||
|
||
fosstodon: ({ name, handle, talkTitle, talkUrl }) => | ||
handle | ||
? `Join ${name} (${handle}) at EuroPython for "${talkTitle}". talk: ${talkUrl}` | ||
: `Join ${name} at EuroPython for "${talkTitle}". Talk: ${talkUrl}`, | ||
}; | ||
|
||
const trimToLimit = (text: string, limit: number) => | ||
text.length <= limit ? text : text.slice(0, limit - 1) + "…"; | ||
|
||
for (const speaker of speakers) { | ||
if (records.length >= limit) break; | ||
if (exclude.includes(speaker.id)) continue; | ||
|
||
const { | ||
name, | ||
twitter_url, | ||
linkedin_url, | ||
bluesky_url, | ||
mastodon_url, | ||
submissions, | ||
} = speaker.data; | ||
|
||
const sessions = await Promise.all( | ||
submissions.map((session) => getEntry("sessions", session.id)) | ||
); | ||
|
||
const validSessions = sessions.filter( | ||
(session) => session && session.data.title | ||
); | ||
|
||
if (validSessions.length === 0) continue; | ||
|
||
const talkTitle = validSessions[0]?.data.title || "an exciting topic"; | ||
const talkCode = validSessions[0]?.data.code; | ||
const talkUrl = `https://ep2025.europython.eu/${talkCode}`; | ||
const speakerImage = `https://ep2025-buffer.ep-preview.click/media/social-${speaker.id}.png`; | ||
const fallbackUrl = `https://ep2025.europython.eu/speaker/${speaker.id}`; | ||
|
||
// Extract handles for each platform | ||
const handles = { | ||
x: getTwitterUsername(twitter_url || ""), | ||
linkedin: getLinkedInUsernameHandler(linkedin_url || ""), | ||
bsky: getBlueskyUsername(bluesky_url || ""), | ||
fosstodon: getMastodonUsername(mastodon_url || ""), | ||
}; | ||
|
||
// Generate appropriate messages for each platform | ||
const generateMessage = (platform: keyof typeof message_template) => { | ||
const templateFn = message_template[platform]; | ||
const handle = | ||
platform === "instagram" | ||
? undefined | ||
: handles[platform as keyof typeof handles]; | ||
|
||
const full = templateFn({ | ||
name, | ||
handle, | ||
talkTitle, | ||
talkUrl: platform === "instagram" ? fallbackUrl : talkUrl, | ||
}); | ||
|
||
const limit = charLimits[platform]; | ||
return trimToLimit(full, limit); | ||
}; | ||
|
||
const record = { | ||
name, | ||
image: speakerImage, | ||
handles: handles, | ||
channel: { | ||
instagram: generateMessage("instagram"), | ||
x: generateMessage("x"), | ||
linkedin: generateMessage("linkedin"), | ||
bsky: generateMessage("bsky"), | ||
fosstodon: generateMessage("fosstodon"), | ||
}, | ||
}; | ||
|
||
records.push(record); | ||
} | ||
|
||
return new Response(JSON.stringify(records, null, 2), { | ||
status: 200, | ||
headers: { | ||
"Content-Type": "application/json", | ||
}, | ||
}); | ||
}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
import { getCollection, getEntry } from "astro:content"; | ||
export async function GET({ params, request }) { | ||
const speakers = await getCollection("speakers"); | ||
|
||
const header = [ | ||
"Talk Title", | ||
"Speaker Name", | ||
"Speaker Photo URL", | ||
"Primary Social ULR", | ||
"X URL", | ||
"LinkedIn URL", | ||
"Bluesky URL", | ||
"Mastodon URL", | ||
]; | ||
|
||
const exclude = [ | ||
"sebastian-ramirez", | ||
"savannah-ostrowski", | ||
"nerea-luis", | ||
"petr-baudis", | ||
"brett-cannon", | ||
]; | ||
|
||
const rows: string[][] = []; | ||
|
||
for (const speaker of speakers) { | ||
if (exclude.includes(speaker.id)) continue; | ||
|
||
const { | ||
name, | ||
twitter_url, | ||
linkedin_url, | ||
bluesky_url, | ||
mastodon_url, | ||
submissions, | ||
} = speaker.data; | ||
|
||
const sessions = await Promise.all( | ||
submissions.map((session) => getEntry("sessions", session.id)) | ||
); | ||
|
||
for (const session of sessions) { | ||
if (session) { | ||
const speaker_page = `https://ep2025.europython.eu/speaker/${speaker.id}`; | ||
rows.push([ | ||
session.data.title || "", | ||
name, | ||
`https://ep2025-buffer.ep-preview.click/media/social-${speaker.id}.png`, | ||
twitter_url || linkedin_url || mastodon_url || speaker_page, | ||
twitter_url ?? speaker_page, | ||
linkedin_url ?? speaker_page, | ||
bluesky_url ?? speaker_page, | ||
mastodon_url ?? speaker_page, | ||
]); | ||
} | ||
} | ||
} | ||
|
||
const csvLines = [header, ...rows] | ||
.map((row) => | ||
row | ||
.map((field) => | ||
field.includes('"') || field.includes(",") || field.includes("\n") | ||
? `"${field.replace(/"/g, '""')}"` | ||
: field | ||
) | ||
.join(",") | ||
) | ||
.join("\r\n"); | ||
|
||
return new Response(csvLines, { | ||
status: 200, | ||
headers: { | ||
"Content-Type": "text/csv; charset=utf-8", | ||
"Content-Disposition": 'attachment; filename="social_media.csv"', | ||
}, | ||
}); | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.