Skip to content

Commit

Permalink
Setup for Archive PyCon TW 2023 (#459)
Browse files Browse the repository at this point in the history
* Setup for Archive PyCon TW 2023

* Fix VenueMap File

* Fix Linter Error

* Remove Not Related Line
  • Loading branch information
rockleona authored Dec 19, 2023
1 parent 3185c0a commit 0293e46
Show file tree
Hide file tree
Showing 13 changed files with 165 additions and 56 deletions.
File renamed without changes.
59 changes: 59 additions & 0 deletions nuxt.config.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,68 @@
import axios from 'axios'
const DEFAULT_BASE_URL = 'https://tw.pycon.org/prs'
const DEFAULT_ROUTER_BASE = '/2023/'
const DEFAULT_BUILD_TARGET = 'static'
const DEFAULT_VUE_DEVTOOL = false

export default {
generate: {
async routes() {
const config = {
headers: {
authorization: `Token ${process.env.AUTH_TOKEN}`,
},
}
const talks = await axios.get(
`${DEFAULT_BASE_URL}/api/events/speeches/?event_types=talk,sponsored`,
config,
)
const tutorials = await axios.get(
`${DEFAULT_BASE_URL}/api/events/speeches/?event_types=tutorial`,
config,
)
const getAllDetailTalks = async () => {
const data = await Promise.all(
talks.data.map(async (talk) => {
return await axios
.get(
`${DEFAULT_BASE_URL}/api/events/speeches/${talk.event_type}/${talk.id}/`,
config,
)
.then((response) => response.data)
}),
)
return data
}
const getAllDetailTutorials = async () => {
const data = await Promise.all(
tutorials.data.map(async (tutorial) => {
return await axios
.get(
`${DEFAULT_BASE_URL}/api/events/speeches/${tutorial.event_type}/${tutorial.id}/`,
config,
)
.then((response) => response.data)
}),
)
return data
}

const detailTalks = await getAllDetailTalks()
const detailTutorials = await getAllDetailTutorials()

const routes = [
...detailTalks.map((talk) => ({
route: `/conference/${talk.event_type}/${talk.id}`,
payload: talk,
})),
...detailTutorials.map((tutorial) => ({
route: `/conference/${tutorial.event_type}/${tutorial.id}`,
payload: tutorial,
})),
]
return routes
},
},
vue: {
config: {
devtools: process.env.VUE_DEVTOOL || DEFAULT_VUE_DEVTOOL,
Expand Down
28 changes: 23 additions & 5 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"dev": "nuxt",
"build": "nuxt build",
"start": "nuxt start",
"generate": "nuxt generate",
"preview": "nuxt preview",
"serve": "npm run build && npm run start",
"lint:js": "eslint --ext .js,.vue --ignore-path .gitignore .",
"lint": "npm run lint:js",
Expand All @@ -23,6 +23,7 @@
"@nuxtjs/markdownit": "^2.0.0",
"@nuxtjs/sitemap": "^2.4.0",
"@tailwindcss/aspect-ratio": "^0.2.1",
"axios": "^0.27.2",
"core-js": "^3.6.5",
"dayjs": "^1.10.6",
"leaflet": "^1.9.4",
Expand Down
15 changes: 8 additions & 7 deletions pages/about/sponsor.vue
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@
</template>

<script>
import { mapState } from 'vuex'
import I18nPageWrapper from '@/components/core/i18n/PageWrapper'
import CoreH1 from '@/components/core/titles/H1'
import i18n from '@/i18n/about/sponsor.i18n'
Expand All @@ -59,18 +58,20 @@ export default {
const ccip = context.query.ccip // to determine if it's opass mobile app
return ccip ? 'ccip' : 'default'
},
async asyncData({ store, payload }) {
if (payload) return { sponsorsData: payload }
await store.dispatch('$getSponsorsData')
const sponsorsData = store.state.sponsorsData
return {
sponsorsData,
}
},
data() {
return {
isOpened: false,
selectedSponsor: {},
}
},
computed: {
...mapState(['sponsorsData']),
},
created() {
this.$store.dispatch('$getSponsorsData')
},
methods: {
showModal(sponsor) {
this.isOpened = true
Expand Down
17 changes: 13 additions & 4 deletions pages/conference/_eventType/_id.vue
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,19 @@ export default {
MarkdownRenderer,
RelatedCardCollection,
},
async asyncData({ store, params, payload }) {
if (payload && Object.keys(payload).length !== 0) {
return {
speechData: payload,
}
}
await store.dispatch('$getSpeechData', {
eventType: params.eventType,
eventId: params.id,
})
const speechData = store.state.speechData
return { speechData }
},
data() {
return {
eventType: '',
Expand All @@ -207,10 +220,6 @@ export default {
...mapState(['speechData']),
},
async created() {
await this.$store.dispatch('$getSpeechData', {
eventType: this.$route.params.eventType,
eventId: this.$route.params.id,
})
await this.processData()
this.$root.$emit('initTabs')
await this.$store.dispatch('$getRelatedData', this.data.category)
Expand Down
23 changes: 12 additions & 11 deletions pages/conference/_eventType/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -73,16 +73,25 @@ export default {
SpeechCardCollection,
Banner,
},
asyncData({ redirect, params }) {
async asyncData({ redirect, store, params, payload }) {
const eventType = params.eventType
if (!['talks', 'tutorials'].includes(eventType)) {
redirect('/')
}
if (payload && Object.keys(payload).length !== 0)
return { eventType, speechesData: payload }
await store.dispatch('$getSpeechesData', eventType)
const speechesData = store.state.speechesData.map((speech) => ({
...speech,
begin_time: speech.begin_time ? new Date(speech.begin_time) : null,
}))
return {
eventType,
speechesData,
}
},
data() {
return {
eventType: '',
speechesData: [],
checkedCategories: [],
aboutBanner: AboutBanner,
}
Expand Down Expand Up @@ -133,14 +142,6 @@ export default {
return false
},
},
async mounted() {
this.eventType = this.$route.params.eventType
await this.$store.dispatch('$getSpeechesData', this.eventType)
this.speechesData = this.$store.state.speechesData.map((speech) => ({
...speech,
begin_time: speech.begin_time ? new Date(speech.begin_time) : null,
}))
},
methods: {
metaInfo() {
return {
Expand Down
19 changes: 11 additions & 8 deletions pages/conference/keynotes.vue
Original file line number Diff line number Diff line change
Expand Up @@ -141,9 +141,19 @@ export default {
GithubIcon,
TwitterIcon,
},
async asyncData({ store, app, payload }) {
if (payload) return { keynotesData: payload }
await store.dispatch('$getKeynotesData')
const keynotesData = store.state.keynotesData.map((keynote) => ({
...keynote,
id: app.$makeId(),
}))
return {
keynotesData,
}
},
data() {
return {
keynotesData: [],
aboutBanner: AboutBanner,
}
},
Expand All @@ -159,13 +169,6 @@ export default {
}
},
},
async mounted() {
await this.$store.dispatch('$getKeynotesData')
this.keynotesData = this.$store.state.keynotesData.map((keynote) => ({
...keynote,
id: this.$makeId(),
}))
},
methods: {
getKeynoteId(keynote) {
if (keynote.speaker.name_en_us) {
Expand Down
9 changes: 7 additions & 2 deletions pages/conference/schedule.vue
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,12 @@ export default {
ScheduleEvent,
ScheduleTick,
},
async asyncData({ store, payload }) {
if (payload) return { schedulesData: payload }
await store.dispatch('$getSchedulesData')
const schedulesData = store.state.schedulesData
return { schedulesData }
},
data() {
return {
selectedDayIndex: 0,
Expand Down Expand Up @@ -132,8 +138,7 @@ export default {
this.makeRooms()
},
},
async created() {
await this.$store.dispatch('$getSchedulesData')
created() {
this.processData()
},
activated() {
Expand Down
17 changes: 10 additions & 7 deletions pages/events/jobs-gather.vue
Original file line number Diff line number Diff line change
Expand Up @@ -45,19 +45,22 @@ export default {
JobsCardCollection,
JobsPanel,
},
async asyncData({ store, app, payload }) {
if (payload) return { jobsData: payload }
await store.dispatch('$getJobsData')
const jobsData = store.state.jobsData.map((sponsor) => ({
...sponsor,
id: app.$makeId(),
}))
return { jobsData }
},
data() {
return {
selectedSponsor: {},
jobsData: [],
pivot: 0,
}
},
async mounted() {
await this.$store.dispatch('$getJobsData')
this.jobsData = this.$store.state.jobsData.map((sponsor) => ({
...sponsor,
id: this.$makeId(),
}))
mounted() {
this.setSelectedSponsor(this.jobsData[0])
this.setPivot()
},
Expand Down
17 changes: 10 additions & 7 deletions pages/events/jobs.vue
Original file line number Diff line number Diff line change
Expand Up @@ -39,19 +39,22 @@ export default {
JobsCardCollection,
JobsPanel,
},
async asyncData({ store, app, payload }) {
if (payload) return { jobsData: payload }
await store.dispatch('$getJobsData')
const jobsData = store.state.jobsData.map((sponsor) => ({
...sponsor,
id: app.$makeId(),
}))
return { jobsData }
},
data() {
return {
selectedSponsor: {},
jobsData: [],
pivot: 0,
}
},
async mounted() {
await this.$store.dispatch('$getJobsData')
this.jobsData = this.$store.state.jobsData.map((sponsor) => ({
...sponsor,
id: this.$makeId(),
}))
mounted() {
if (this.jobsData.length > 0) {
this.setSelectedSponsor(this.jobsData[0])
}
Expand Down
11 changes: 8 additions & 3 deletions pages/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,14 @@ export default {
I18nPageWrapper,
Intro,
},
async asyncData({ store, payload }) {
if (payload) return { sponsorsData: payload }
await store.dispatch('$getSponsorsData')
const sponsorsData = store.state.sponsorsData
return {
sponsorsData,
}
},
data() {
return {
isOpened: false,
Expand Down Expand Up @@ -178,9 +186,6 @@ export default {
return this.$store.state.configs.showIndexSponsorSection
},
},
created() {
this.$store.dispatch('$getSponsorsData')
},
methods: {
showModal(sponsor) {
this.isOpened = true
Expand Down
Loading

0 comments on commit 0293e46

Please sign in to comment.