Skip to content
Merged
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
9 changes: 9 additions & 0 deletions src/seed/assets/attend-events.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/seed/assets/carousel-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/seed/assets/carousel-2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/seed/assets/carousel-3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/seed/assets/carousel-4.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
9 changes: 9 additions & 0 deletions src/seed/assets/give-a-talk.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
9 changes: 9 additions & 0 deletions src/seed/assets/join-our-community.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
49 changes: 33 additions & 16 deletions src/seed/default/collections/Media.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,40 @@ import path from 'path'
import { Payload, PayloadRequest } from 'payload'
import { COLLECTIONS } from '@/constants/collections'

const mediaAssets = [
{ fileName: 'durianpy-logo.png', alt: 'DurianPy Logo', mimetype: 'image/png' },
{ fileName: 'carousel-1.png', alt: 'PyConf 2024', mimetype: 'image/png' },
{ fileName: 'carousel-2.png', alt: 'Meetup #1', mimetype: 'image/png' },
{ fileName: 'carousel-3.png', alt: 'Meetup #2', mimetype: 'image/png' },
{ fileName: 'carousel-4.png', alt: 'Meetup #3', mimetype: 'image/png' },
{ fileName: 'join-our-community.svg', alt: 'Join Our Community', mimetype: 'image/svg+xml' },
{ fileName: 'attend-events.svg', alt: 'Attend Events', mimetype: 'image/svg+xml' },
{ fileName: 'give-a-talk.svg', alt: 'Give a Talk', mimetype: 'image/svg+xml' },
]

export async function seedMedia({ payload, req }: { payload: Payload; req?: PayloadRequest }) {
const imagePath = path.resolve(process.cwd(), 'src/seed/assets/durianpy-logo.png')
const imageBuffer = fs.readFileSync(imagePath)
const createdMedia = await Promise.all(
mediaAssets.map(async (asset) => {
const assetPath = path.resolve(process.cwd(), `src/seed/assets/${asset.fileName}`)
if (!fs.existsSync(assetPath)) return null

const imageBuffer = fs.readFileSync(assetPath)

const mediaItem = await payload.create({
collection: COLLECTIONS.MEDIA,
data: {
alt: 'DurianPy Logo',
},
file: {
data: imageBuffer,
name: 'durianpy-logo.png',
mimetype: 'image/png',
size: imageBuffer.length,
},
req,
})
return payload.create({
collection: COLLECTIONS.MEDIA,
data: {
alt: asset.alt,
},
file: {
data: imageBuffer,
name: asset.fileName,
mimetype: asset.mimetype,
size: imageBuffer.length,
},
req,
})
}),
)

return [mediaItem]
return createdMedia.filter(Boolean)
}
44 changes: 34 additions & 10 deletions src/seed/durianpy-website/globals/CTASection.ts
Original file line number Diff line number Diff line change
@@ -1,32 +1,56 @@
import { Payload, PayloadRequest } from 'payload'
import { COLLECTIONS } from '@/constants/collections'
import { GLOBALS } from '@/constants/globals'

export async function seedCTASection({ payload, req }: { payload: Payload; req?: PayloadRequest }) {
const { docs: mediaDocs } = await payload.find({
collection: 'media',
const { docs: joinDocs } = await payload.find({
collection: COLLECTIONS.MEDIA,
where: { alt: { equals: 'Join Our Community' } },
limit: 1,
req,
})
const mediaId = mediaDocs[0]?.id
const { docs: attendDocs } = await payload.find({
collection: COLLECTIONS.MEDIA,
where: { alt: { equals: 'Attend Events' } },
limit: 1,
req,
})
const { docs: giveTalkDocs } = await payload.find({
collection: COLLECTIONS.MEDIA,
where: { alt: { equals: 'Give a Talk' } },
limit: 1,
req,
})

const joinIcon = joinDocs[0]?.id
const attendIcon = attendDocs[0]?.id
const giveTalkIcon = giveTalkDocs[0]?.id

await payload.updateGlobal({
slug: GLOBALS.DURIANPY_WEBSITE_CTA_SECTION,
data: {
cards: [
{
link: 'https://durianpy.org/join',
whiteText: 'Join our',
link: 'https://www.meetup.com/durianpy/',
whiteText: 'Join Our',
yellowText: 'Community',
icon: mediaId,
icon: joinIcon,
},
{
link: 'https://durianpy.org/sponsor',
whiteText: 'Become a',
yellowText: 'Sponsor',
icon: mediaId,
link: 'https://www.meetup.com/durianpy/events/',
whiteText: 'Attend',
yellowText: 'Events',
icon: attendIcon,
},
{
link: 'https://forms.gle/x2cc6CrRhbhDeaxe9',
whiteText: 'Give a',
yellowText: 'Talk',
icon: giveTalkIcon,
},
],
_status: 'published',
},
req,
})
}
26 changes: 19 additions & 7 deletions src/seed/durianpy-website/globals/Carousel.ts
Original file line number Diff line number Diff line change
@@ -1,21 +1,33 @@
import { Payload, PayloadRequest } from 'payload'
import { COLLECTIONS } from '@/constants/collections'
import { GLOBALS } from '@/constants/globals'

export async function seedCarousel({ payload, req }: { payload: Payload; req?: PayloadRequest }) {
const { docs: mediaDocs } = await payload.find({
collection: 'media',
limit: 1,
const { docs: carouselMedia } = await payload.find({
collection: COLLECTIONS.MEDIA,
where: {
or: [
{ alt: { equals: 'PyConf 2024' } },
{ alt: { equals: 'Meetup #1' } },
{ alt: { equals: 'Meetup #2' } },
{ alt: { equals: 'Meetup #3' } },
],
},
sort: 'createdAt',
limit: 10,
req,
})
const mediaId = mediaDocs[0]?.id

const photos = carouselMedia.map((media) => ({ image: media.id }))

await payload.updateGlobal({
slug: GLOBALS.DURIANPY_WEBSITE_CAROUSEL,
data: {
title: 'Our Community',
subtitle: 'See what we are up to in Davao',
photos: [{ image: mediaId }, { image: mediaId }],
title: 'Davao Python Community',
subtitle: 'where Pythonistas and enthusiasts gather to discuss trends and share knowledge',
photos: photos.length > 0 ? photos : [{ image: carouselMedia[0]?.id }],
_status: 'published',
},
req,
})
}
145 changes: 143 additions & 2 deletions src/seed/durianpy-website/globals/CodeOfConduct.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,27 +11,167 @@ export async function seedCodeOfConduct({
await payload.updateGlobal({
slug: GLOBALS.DURIANPY_WEBSITE_CODE_OF_CONDUCT,
data: {
reportFormUrl: 'https://forms.gle/example',
reportFormUrl: 'https://forms.gle/R4MXsc2brwHEmgrE7',
content: {
root: {
type: 'root',
format: '',
indent: 0,
version: 1,
direction: 'ltr',
children: [
{
type: 'heading',
tag: 'h1',
format: '',
indent: 0,
version: 1,
direction: 'ltr',
children: [
{
type: 'text',
text: 'Code of Conduct',
format: 0,
detail: 0,
mode: 'normal',
style: '',
version: 1,
},
],
},
{
type: 'heading',
tag: 'h2',
format: '',
indent: 0,
version: 1,
direction: 'ltr',
children: [
{
type: 'text',
text: 'We value respect and inclusivity in all events.',
format: 0,
detail: 0,
mode: 'normal',
style: '',
version: 1,
},
],
},
{
type: 'paragraph',
format: '',
indent: 0,
version: 1,
direction: 'ltr',
children: [
{
type: 'text',
text: 'The Python community is made up of members from around the globe with a diverse set of skills, personalities, and experiences. It is through these differences that our community experiences great successes and continued growth.',
format: 0,
detail: 0,
mode: 'normal',
style: '',
version: 1,
},
],
},
{
type: 'paragraph',
format: '',
indent: 0,
version: 1,
direction: 'ltr',
children: [
{
type: 'text',
text: 'To clarify our expectations, all participants, including attendees, speakers, exhibitors, organizers, and volunteers at any DurianPy event, must adhere to the following ',
format: 0,
detail: 0,
mode: 'normal',
text: 'DurianPy is dedicated to providing a harassment-free community experience for everyone.',
style: '',
version: 1,
},
{
type: 'link',
fields: {
linkType: 'custom',
url: 'https://policies.python.org/python.org/code-of-conduct/',
newTab: true,
},
format: '',
indent: 0,
version: 2,
direction: 'ltr',
children: [
{
type: 'text',
text: 'Code of Conduct',
format: 0,
detail: 0,
mode: 'normal',
style: '',
version: 1,
},
],
},
{
type: 'text',
text: '.',
format: 0,
detail: 0,
mode: 'normal',
style: '',
version: 1,
},
],
},
{
type: 'paragraph',
format: '',
indent: 0,
version: 1,
direction: 'ltr',
children: [
{
type: 'text',
text: 'If you witness or experience any violations of the Code of Conduct, please report them using the ',
format: 0,
detail: 0,
mode: 'normal',
style: '',
version: 1,
},
{
type: 'link',
fields: {
linkType: 'custom',
url: 'https://forms.gle/R4MXsc2brwHEmgrE7',
newTab: true,
},
format: '',
indent: 0,
version: 2,
direction: 'ltr',
children: [
{
type: 'text',
text: 'Code of Conduct Report Form',
format: 0,
detail: 0,
mode: 'normal',
style: '',
version: 1,
},
],
},
{
type: 'text',
text: '.',
format: 0,
detail: 0,
mode: 'normal',
style: '',
version: 1,
},
],
Expand All @@ -41,5 +181,6 @@ export async function seedCodeOfConduct({
},
_status: 'published',
},
req,
})
}
Loading
Loading