wikipedia and stripe progress

This commit is contained in:
Gamebrary 2022-04-05 18:55:36 -07:00
parent 5a94f9e1c2
commit 95d03296fa
9 changed files with 152 additions and 151 deletions

View file

@ -44,38 +44,25 @@
<b-col cols="7"> <b-col cols="7">
<!-- <pre class="text-dark small">{{ game.gog.price }}</pre> --> <!-- <pre class="text-dark small">{{ game.gog.price }}</pre> -->
<h3 class="mb-2"> <h3 class="m-0">
{{ game.name }} {{ game.name }}
<b-button v-b-toggle.my-collapse>Toggle Collapse</b-button>
<b-collapse id="my-collapse">
<b-card title="Collapsible card">
<pre>{{ game }}</pre>
<!-- <div
class="mb-1"
rounded
v-for="alternativeName in game.alternative_names"
:key="alternativeName.id"
>
<b-avatar
v-b-tooltip.hover
:title="alternativeName.comment || null"
size="sm"
:src="`/static/img/country-flags/${getCountryCode(alternativeName.comment)}.svg`"
/>
{{ alternativeName.name }}
</div> -->
</b-card>
</b-collapse>
<b-badge variant="success" v-if="game && game.steam && game.steam.metacritic">{{ game.steam.metacritic.score }}</b-badge> <b-badge variant="success" v-if="game && game.steam && game.steam.metacritic">{{ game.steam.metacritic.score }}</b-badge>
<br />
<!-- <b-badge variant="success" v-if="steamGame && steamGame.metacritic">{{ steamGame.metacritic.score }}</b-badge> -->
<b-badge v-b-modal.altNames>
<strong>Also known as:</strong>
</b-badge>
</h3> </h3>
<game-alternative-titles />
<b-badge
v-for="({ games, hex, tagTextColor }, name) in tags"
v-if="games.includes(game.id)"
:key="name"
pill
tag="small"
class="mr-1 mb-2"
:style="`background-color: ${hex}; color: ${tagTextColor}`"
v-b-modal.tags
>
{{ name }}
</b-badge>
<!-- <small> <!-- <small>
<pre class="text-dark">{{ steamGame }}</pre> <pre class="text-dark">{{ steamGame }}</pre>
</small> --> </small> -->
@ -101,7 +88,7 @@
battle-royale --> battle-royale -->
<game-genres :game="game" /> <game-genres :game="game" />
<!-- <game-description :game="game" :steam-game="steamGame" /> --> <game-description />
<game-platforms /> <game-platforms />
<!-- <game-news :game="game" /> --> <!-- <game-news :game="game" /> -->
@ -113,19 +100,6 @@
class="d-md-none" class="d-md-none"
/> />
<b-badge
v-for="({ games, hex, tagTextColor }, name) in tags"
v-if="games.includes(game.id)"
:key="name"
pill
tag="small"
class="mr-1 mb-2"
:style="`background-color: ${hex}; color: ${tagTextColor}`"
v-b-modal.tags
>
{{ name }}
</b-badge>
<!-- <template v-if="!loading"> <!-- <template v-if="!loading">
<b-skeleton v-for="n in 3" :key="n" /> <b-skeleton v-for="n in 3" :key="n" />
</template> --> </template> -->
@ -159,6 +133,7 @@
import GameGenres from '@/components/Game/GameGenres'; import GameGenres from '@/components/Game/GameGenres';
// import GameNews from '@/components/Game/GameNews'; // import GameNews from '@/components/Game/GameNews';
import GameDetails from '@/components/Game/GameDetails'; import GameDetails from '@/components/Game/GameDetails';
import GameAlternativeTitles from '@/components/Game/GameAlternativeTitles';
import GamePlatforms from '@/components/Game/GamePlatforms'; import GamePlatforms from '@/components/Game/GamePlatforms';
import GameRating from '@/components/Game/GameRating'; import GameRating from '@/components/Game/GameRating';
import GameDescription from '@/components/Game/GameDescription'; import GameDescription from '@/components/Game/GameDescription';
@ -174,6 +149,7 @@ export default {
// Timeline, // Timeline,
GameDescription, GameDescription,
GameDetails, GameDetails,
GameAlternativeTitles,
GamePlatforms, GamePlatforms,
GameRating, GameRating,
// GameImages, // GameImages,

View file

@ -0,0 +1,62 @@
<template lang="html">
<div v-if="game.alternative_names">
<strong class="small link" v-b-toggle.altTitles variant="light">{{ game.alternative_names.length }} Alternative titles</strong>
<b-collapse id="altTitles">
<div
class="mb-1 small"
rounded
variant="light"
v-for="alternativeName in game.alternative_names"
:key="alternativeName.id"
>
<b-avatar
v-b-tooltip.hover
:title="alternativeName.comment || null"
size="sm"
:src="`/static/img/country-flags/${getCountryCode(alternativeName.comment)}.svg`"
/>
{{ alternativeName.name }}
</div>
</b-collapse>
</div>
</template>
<script>
import { mapState } from 'vuex';
export default {
computed: {
...mapState(['game']),
},
methods: {
getCountryCode(alternateTitleDescription) {
if (!alternateTitleDescription) return 'un';
const description = alternateTitleDescription.toLowerCase();
if (description.includes('japanese')) return 'jp';
if (description.includes('korean')) return 'kr';
if (description.includes('portuguese')) return 'pt';
if (description.includes('brazilian')) return 'br';
if (description.includes('spanish')) return 'es';
if (description.includes('french')) return 'fr';
if (description.includes('italian')) return 'it';
if (description.includes('arabic')) return 'sa';
if (description.includes('polish')) return 'pl';
if (description.includes('russian')) return 'ru';
if (description.includes('chinese')) return 'cn';
if (description.includes('german')) return 'de';
if (description.includes('dutch')) return 'nl';
if (description.includes('european')) return 'eu';
return 'un';
},
},
};
</script>
<style lang="scss" rel="stylesheet/scss" scoped>
</style>

View file

@ -9,54 +9,31 @@
</div> </div>
<template v-else> <template v-else>
<small class="text-muted">Source: {{ source }}</small> <!-- <small class="text-muted">Source: {{ source }}</small> -->
<p <p
:class="{'break-spaces': source === 'IGDB' }" :class="{'break-spaces': source === 'IGDB' }"
v-html="description" v-html="description"
/> />
</template> </template>
<b-modal <b-card no-body>
id="wikipediaArticle" <b-tabs pills card>
scrollable <b-tab
hide-footer v-for="section in wikipediaArticle.remaining.sections"
> :key="section.id"
<template v-slot:modal-header="{ close }"> :title='section.line'
<modal-header
:title="game.name"
subtitle="Wikipedia article"
@close="close"
> >
<template v-slot:header> <b-card-text class="wiki-content" v-html="section.text" />
<b-img </b-tab>
:src="activeGameCoverUrl" </b-tabs>
:alt="game.name" </b-card>
class="float-left mr-2"
height="40"
rounded
/>
</template>
</modal-header>
</template>
<p
:class="{'break-spaces': source === 'IGDB' }"
v-html="gameDescription"
/>
</b-modal>
</div> </div>
</template> </template>
<script> <script>
import { mapGetters } from 'vuex'; import { mapGetters, mapState } from 'vuex';
export default { export default {
props: {
game: Object,
steamGame: Object,
},
data() { data() {
return { return {
wikipediaArticle: {}, wikipediaArticle: {},
@ -66,6 +43,7 @@ export default {
computed: { computed: {
...mapGetters(['activeGameCoverUrl']), ...mapGetters(['activeGameCoverUrl']),
...mapState(['game']),
description() { description() {
return this.trimmedDescription return this.trimmedDescription
@ -74,19 +52,20 @@ export default {
}, },
gameDescription() { gameDescription() {
const steamDescription = this.steamGame && this.steamGame.short_description const steamDescription = this.game && this.game.steam && this.game.steam.short_description
? this.steamGame.short_description ? this.game.steam.short_description
: null; : null;
const wikipediaDescription = this.wikipediaArticle && this.wikipediaArticle.extract
? this.wikipediaArticle.extract // const wikipediaDescription = this.wikipediaArticle && this.wikipediaArticle.lead && this.wikipediaArticle.lead.sections[0]
: null; // ? this.wikipediaArticle.lead.sections[0].text
// : null;
const igdbDescription = this.game && this.game.summary const igdbDescription = this.game && this.game.summary
? this.game.summary ? this.game.summary
: null; : null;
return steamDescription || wikipediaDescription || igdbDescription; return steamDescription || igdbDescription;
}, },
trimmedDescription() { trimmedDescription() {
@ -96,11 +75,11 @@ export default {
}, },
source() { source() {
if (this.steamGame && this.steamGame.short_description) { if (this.game.steam && this.game.steam.short_description) {
return 'Steam'; return 'Steam';
} }
return this.wikipediaArticle && this.wikipediaArticle.extract return this.wikipediaArticle && this.wikipediaArticle.lead && this.wikipediaArticle.lead[0]
? 'Wikipedia' ? 'Wikipedia'
: 'IGDB'; : 'IGDB';
}, },
@ -173,4 +152,11 @@ h2 {
.mw-empty-elt { .mw-empty-elt {
display: none; display: none;
} }
.wiki-content img {
float: left;
// border-radius: 1rem;
padding-right: 1rem;
width: auto;
}
</style> </style>

View file

@ -1,25 +1,6 @@
<template lang="html"> <template lang="html">
<div> <div>
<b-alert show variant="secondary" class="game-details"> <b-alert show variant="secondary" class="game-details">
<div v-if="game.alternative_names">
<strong>Also known as:</strong>
<div
class="mb-1"
rounded
v-for="alternativeName in game.alternative_names"
:key="alternativeName.id"
>
<b-avatar
v-b-tooltip.hover
:title="alternativeName.comment || null"
size="sm"
:src="`/static/img/country-flags/${getCountryCode(alternativeName.comment)}.svg`"
/>
{{ alternativeName.name }}
</div>
</div>
<div v-if="gameModes"> <div v-if="gameModes">
<strong>{{ $t('board.gameModal.gameModes') }}:</strong> <strong>{{ $t('board.gameModal.gameModes') }}:</strong>
<span class="text-wrap">{{ gameModes }}</span> <span class="text-wrap">{{ gameModes }}</span>
@ -131,30 +112,5 @@ export default {
return [...new Set(formattedReleaseDates)]; return [...new Set(formattedReleaseDates)];
}, },
}, },
methods: {
getCountryCode(alternateTitleDescription) {
if (!alternateTitleDescription) return 'un';
const description = alternateTitleDescription.toLowerCase();
if (description.includes('japanese')) return 'jp';
if (description.includes('korean')) return 'kr';
if (description.includes('portuguese')) return 'pt';
if (description.includes('brazilian')) return 'br';
if (description.includes('spanish')) return 'es';
if (description.includes('french')) return 'fr';
if (description.includes('italian')) return 'it';
if (description.includes('arabic')) return 'sa';
if (description.includes('polish')) return 'pl';
if (description.includes('russian')) return 'ru';
if (description.includes('chinese')) return 'cn';
if (description.includes('german')) return 'de';
if (description.includes('dutch')) return 'nl';
if (description.includes('european')) return 'eu';
return 'un';
},
},
}; };
</script> </script>

View file

@ -25,7 +25,7 @@
<div class="global-actions"> <div class="global-actions">
<portal-target name="headerActions" /> <portal-target name="headerActions" />
<b-button class="mr-2" variant="success"> <b-button class="mr-2" variant="success" :to="{ name: 'upgrade' }">
<i class="fa-solid fa-crown" /> <i class="fa-solid fa-crown" />
Upgrade Upgrade
</b-button> </b-button>

View file

@ -25,6 +25,7 @@
<template v-else> <template v-else>
<div class="notes mb-2"> <div class="notes mb-2">
<pre>{{ filteredNotes[0] }}</pre>
<note <note
v-for="(note, index) in filteredNotes" v-for="(note, index) in filteredNotes"
:key="index" :key="index"

View file

@ -3,13 +3,18 @@
<stripe-checkout <stripe-checkout
ref="checkoutRef" ref="checkoutRef"
mode="subscription" mode="subscription"
pk="pk_live_5160DvBGpsgtQXdlaEzH237I6JOkwRhfO5s6nbrK9IG9erzIbkpW610yu7qE4PUjEQAc2GXbM20egr82H1mkRN5rn00qDa5dw1L" pk="pk_test_Plr6zbTURKQbfRUkcXYP58hl"
:line-items="lineItems" :line-items="lineItems"
success-url="http://localhost:4000/#/upgrade" success-url="http://localhost:4000/#/upgrade?state=success"
cancel-url="http://localhost:4000/#/upgrade" cancel-url="http://localhost:4000/#/upgrade?state=cancel"
@loading="load" @loading="load"
/> />
<pre>{{ lineItems }}</pre>
<pre>{{ loading }}</pre>
<b-button @click="planSelected = 'monthly'">Monthly</b-button>
<b-button @click="planSelected = 'yearly'">Yearly</b-button>
</div> </div>
</template> </template>
@ -24,18 +29,39 @@ export default {
data() { data() {
return { return {
loading: false, loading: false,
lineItems: [ planSelected: null,
{ monthlyPlan: {
price: 'prod_LQ5kl5sCkdI7Kr', price: 'price_1KjFY4GpsgtQXdlaWZa44Gbj',
quantity: 1, quantity: 1,
}, },
], yearlyPlan: {
price: 'price_1KjFYeGpsgtQXdlajXFxtkDN',
quantity: 1,
},
}; };
}, },
computed: {
lineItems() {
if (this.planSelected === 'monthly') return [this.monthlyPlan];
if (this.planSelected === 'yearly') return [this.yearlyPlan];
return [{}];
},
},
watch: {
planSelected(value) {
this.$refs.checkoutRef.redirectToCheckout();
},
},
methods: { methods: {
// load(status) { // load(status) {
load() { load(value) {
console.log(value);
this.loading = value;
console.log('load');
// console.log(status); // console.log(status);
}, },
}, },

View file

@ -40,15 +40,9 @@ export default {
LOAD_WIKIPEDIA_ARTICLE(context, articleTitle) { LOAD_WIKIPEDIA_ARTICLE(context, articleTitle) {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
axios.get(`https://en.wikipedia.org/w/api.php?origin=*&action=query&prop=extracts&titles=${articleTitle}&format=json`) axios.get(`https://en.wikipedia.org/api/rest_v1/page/mobile-sections/${articleTitle}`)
.then(({ data: { query } }) => { .then(({ data }) => {
const pageIds = Object.keys(query.pages); resolve(data);
const article = pageIds.length
? query.pages[pageIds[0]]
: null;
resolve(article);
}).catch(reject); }).catch(reject);
}); });
}, },

View file

@ -84,6 +84,6 @@ $text-muted: $muted !default;
// //
$pre-color: $white !default; $pre-color: $dark !default;
// $pre-scrollable-max-height: 340px !default; // $pre-scrollable-max-height: 340px !default;
// //