Skip to content

Commit

Permalink
feat(home): add releases changelogs & page content mngt ✨
Browse files Browse the repository at this point in the history
  • Loading branch information
PierreBrisorgueil committed Jul 18, 2020
1 parent ba9c247 commit 8823c7a
Show file tree
Hide file tree
Showing 8 changed files with 322 additions and 157 deletions.
6 changes: 0 additions & 6 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ All notable changes to this project will be documented in this file. See [standa

## 0.1.0 (2020-05-14)


### Features

* **all:** init ✨ ([8e1e976](https://github.com/weareopensource/Vue/commit/8e1e9768111622bfb9998c09a4850db453d536b0))
Expand All @@ -28,7 +27,6 @@ All notable changes to this project will be documented in this file. See [standa
* **tasks:** init tasks list :) ✨ ([7459d8a](https://github.com/weareopensource/Vue/commit/7459d8a5185fcf4fe50ea4fee5bb80d055b168d3))
* **tasks:** simplify example ✨ ([3b83f72](https://github.com/weareopensource/Vue/commit/3b83f72337214c3204222f251b9d146d3aff5e8d))


### Bug Fixes

* package.json, package-lock.json & .snyk to reduce vulnerabilities ([0265838](https://github.com/weareopensource/Vue/commit/0265838b9ed596b2ad32a7c9bcf0239553b4e0ac))
Expand All @@ -55,7 +53,3 @@ All notable changes to this project will be documented in this file. See [standa
* package.json & package-lock.json to reduce vulnerabilities ([a11f1b5](https://github.com/weareopensource/Vue/commit/a11f1b5e4a3d0f08c370e97006cc4e46284e7fcc))
* package.json & package-lock.json to reduce vulnerabilities ([4eecc65](https://github.com/weareopensource/Vue/commit/4eecc65854431f1c6d7e15270924fab7c75f45db))
* package.json, package-lock.json & .snyk to reduce vulnerabilities ([e5b7bf8](https://github.com/weareopensource/Vue/commit/e5b7bf8b4e93404b8ddf3857a1be511a45c11d29))

# Changelog

All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
9 changes: 5 additions & 4 deletions src/config/defaults/development.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ module.exports = {
port: '3000',
base: 'api',
endPoints: {
core: 'core',
auth: 'auth',
users: 'users',
tasks: 'tasks',
Expand Down Expand Up @@ -156,10 +157,10 @@ module.exports = {
},
{
title: 'About',
items: [{
label: 'GDPR / RGPD',
icon: 'fa-lock',
url: 'https://weareopensource.me',
items: [{ // set null to hide
label: 'Changelogs',
icon: 'fa-clipboard-list',
url: '/changelogs',
}],
},
{
Expand Down
124 changes: 124 additions & 0 deletions src/modules/home/components/home.banner.component.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
<template>
<section id="hero">
<v-row no-gutters>
<v-img
:min-height="'calc(100vh/' + ratio + ' - ' + $vuetify.application.top + 'px)'"
:max-height="'calc(100vh/' + ratio + ' - ' + $vuetify.application.top + 'px)'"
:src="
config.home.temporalBackground
? generateTemporalBackground()
: require('@/assets/images/background.jpg')
"
>
<v-theme-provider dark>
<v-container fill-height>
<v-row align="center" class="white--text mx-auto" justify="center">
<v-col class="white--text text-center" cols="12" tag="h1">
<span
v-if="app.title"
:class="[$vuetify.breakpoint.smAndDown ? 'display-3' : 'display-4']"
class="font-weight-black"
>{{ app.title }}</span
>
<br />
<span
v-if="app.subtitle"
class="font-weight-light"
:class="[$vuetify.breakpoint.smAndDown ? 'display-1' : 'display-1']"
>{{ app.subtitle }}</span
>
</v-col>
<v-col class="white--text text-center" cols="12">
<v-btn
class="align-self-end"
fab
outlined
@click="$vuetify.goTo('#about-me')"
data-aos="fade-up"
>
<v-icon>fa-angle-down</v-icon>
</v-btn>
</v-col>
<v-col
align="center"
class="white--text text-center"
cols="11"
xs="10"
sm="9"
md="7"
lg="6"
xl="5"
style="bottom: 10%; position: absolute; opacity:75%;"
data-aos="fade-up"
v-if="config.home.subscriptions && subscribe"
>
<v-text-field
v-model="email"
:flat="config.vuetify.theme.flat"
:rules="[rules.email]"
:append-icon="'fa-envelope'"
@click:append="createSubscription"
@keydown.enter="createSubscription"
height="55"
name="Mail"
placeholder="Stay informed by email."
class="centered-input"
solo
rounded
light
></v-text-field>
</v-col>
</v-row>
</v-container>
</v-theme-provider>
</v-img>
</v-row>
</section>
</template>

<script>
/**
* Module dependencies.
*/
import { mapGetters } from 'vuex';
/**
* Export default
*/
export default {
name: 'homeBannerComponent',
props: ['ratio', 'subscribe', 'app'],
data() {
return {
valid: false,
password: 'Password',
rules: {
email: (v) => /\S+@\S+\.\S+/.test(v) || '',
},
};
},
computed: {
...mapGetters(['theme', 'subscription']),
email: {
get() {
return this.subscription.email;
},
set(email) {
this.save = true;
this.$store.commit('subscription_update', { email });
},
},
},
methods: {
generateTemporalBackground() {
return `${this.config.home.temporalBackground}/${`0${new Date().getHours()}`.slice(-2)}.jpg`;
},
createSubscription() {
if (this.rules.email(this.subscription.email)) {
this.$store
.dispatch('createSubscription', this.subscription)
.catch((err) => console.log(err));
}
},
},
};
</script>
56 changes: 56 additions & 0 deletions src/modules/home/components/home.links.component.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
<template>
<section
id="features"
class="py-12"
:style="{ background: config.vuetify.theme.themes[theme].surface }"
v-if="links.length > 0"
>
<v-container>
<v-row>
<v-col
v-for="({ items, title }, i) in links.filter(section => section.items)"
:key="i"
cols="12"
:md="12 / links.filter(section => section.items).length"
>
<v-card
:flat="config.vuetify.theme.flat"
:style="{ background: config.vuetify.theme.themes[theme].surface }"
>
<v-card-title class="justify-center text--secondary" v-text="title"></v-card-title>
<v-list dense :style="{ background: config.vuetify.theme.themes[theme].surface }">
<v-list-item-group color="primary">
<v-list-item v-for="(item, i) in items" :key="i">
<v-list-item-content>
<a :href="item.url">
<v-list-item-title class="text-center">
<v-icon class="pr-2" small>{{ item.icon }}</v-icon> {{ item.label }}
</v-list-item-title>
</a>
</v-list-item-content>
</v-list-item>
</v-list-item-group>
</v-list>
</v-card>
</v-col>
</v-row>
</v-container>
</section>
</template>

<script>
/**
* Module dependencies.
*/
import { mapGetters } from 'vuex';
/**
* Export default
*/
export default {
name: 'homeLinksComponent',
props: ['links'],
computed: {
...mapGetters(['theme']),
},
};
</script>
13 changes: 11 additions & 2 deletions src/modules/home/router/home.router.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
* Module dependencies.
*/
import home from '@/modules/home/views/home.view.vue';
import pages from '@/modules/home/views/pages.view.vue';

/**
* Router configuration
Expand All @@ -14,8 +15,16 @@ export default [
meta: {
icon: 'home',
},
},
{
}, {
path: '/changelogs',
name: 'changelogs',
component: pages,
meta: {
display: false, // hide any time
title: 'Changelogs',
data: 'getChangelogs', // array of {title: ..., markdown: ...}
},
}, {
path: '*',
redirect: { name: 'Home' },
meta: {
Expand Down
38 changes: 24 additions & 14 deletions src/modules/home/stores/home.store.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ const whitelists = ['email', 'news'];
* Getters: get state
*/
const getters = {
contents: (state) => state.contents,
news: (state) => state.news,
subscription: (state) => state.subscription,
contact: (state) => state.contact,
Expand All @@ -24,6 +25,17 @@ const getters = {
* Actions
*/
const actions = {
getChangelogs: async ({ commit }) => {
try {
const changelogs = await Vue.prototype.axios.get(`${api}/${config.api.endPoints.core}/changelogs`);
commit('contents_set', changelogs.data.data.map((item) => ({
title: item.title,
markdown: decodeURIComponent(Array.prototype.map.call(atob(item.data.content), (c) => `%${(`00${c.charCodeAt(0).toString(16)}`).slice(-2)}`).join('')),
})));
} catch (err) {
commit('error', err);
}
},
getNews: async ({ commit }) => {
try {
const ghost = new GhostContentAPI({
Expand All @@ -34,7 +46,7 @@ const actions = {
const res = await ghost.posts.browse({ limit: 3 });
commit('news_set', res);
} catch (err) {
commit('news_error', err);
commit('error', err);
}
},
createSubscription: async ({ commit }, params) => {
Expand All @@ -44,19 +56,21 @@ const actions = {
const res = await Vue.prototype.axios.post(`${api}/${config.api.endPoints.subscriptions}/`, obj);
commit('subscription_set', res.data.data);
} catch (err) {
commit('subscription_error', err);
commit('error', err);
}
},
getStatistics: async ({ commit }) => {
try {
const tasks = await Vue.prototype.axios.get(`${api}/${config.api.endPoints.tasks}/stats`);
const releases = await Vue.prototype.axios.get(`${api}/${config.api.endPoints.core}/releases`);
const users = await Vue.prototype.axios.get(`${api}/${config.api.endPoints.users}/stats`);
commit('statistics_set', {
tasks: tasks.data.data,
releases: releases.data.data,
users: users.data.data,
});
} catch (err) {
commit('statistics_error', err);
commit('error', err);
}
},
};
Expand All @@ -65,37 +79,32 @@ const actions = {
* Mutation: change state in a Vuex store is by committing a mutation
*/
const mutations = {
// news
news_error(err) {
error(err) {
console.log(err);
},
// news
contents_set(state, data) {
state.contents = data;
},
// news
news_set(state, data) {
state.news = data;
},
// mail
subscription_error(err) {
console.log(err);
},
subscription_set(state, data) {
state.subscription = data;
},
subscription_update(state, data) {
_.merge(state.subscription, data);
},
// mail
contact_error(err) {
console.log(err);
},
contact_set(state, data) {
state.contact = data;
},
contact_update(state, data) {
_.merge(state.contact, data);
},
// statistics
statistics_error(err) {
console.log(err);
},
statistics_set(state, data) {
state.statistics = data;
},
Expand All @@ -105,6 +114,7 @@ const mutations = {
* State
*/
const state = {
contents: [],
news: [],
subscription: {},
contact: {},
Expand Down
Loading

0 comments on commit 8823c7a

Please sign in to comment.