Commit 1e99d844 authored by Aral Balkan's avatar Aral Balkan

Now gets site configuration data from data.json

(The site URL is currently hardcoded to aral.localtunnel.me)
parent 0c075fc5
......@@ -2,14 +2,25 @@ const path = require('path')
module.exports = {
loading: {
color: '#92D3CE'
},
color: '#92D3CE'
},
rootDir: path.resolve(__dirname),
dev: process.env.NODE_ENV !== 'production',
head: {
meta: [
{ charset: 'utf-8' },
{ name: 'viewport', content: 'width=device-width, initial-scale=1, viewport-fit=cover' }
]
},
modules: [
'@nuxtjs/axios'
],
axios: {
// No special configuration yet.
}
}
......@@ -79,6 +79,26 @@
"radix-router": "3.0.1"
}
},
"@nuxtjs/axios": {
"version": "5.0.1",
"resolved": "https://registry.npmjs.org/@nuxtjs/axios/-/axios-5.0.1.tgz",
"integrity": "sha512-x88MNgV+Kn7P9Vvrhs2lKXmJDCh0NuYO3Zt/33U3QZiiE/z7JtQG+eVzuRsAi1emHCjqaP/Oatp/Rxz3aCSI8g==",
"requires": {
"@nuxtjs/proxy": "1.1.4",
"axios": "0.17.1",
"axios-retry": "3.0.2",
"chalk": "2.3.0",
"debug": "3.1.0"
}
},
"@nuxtjs/proxy": {
"version": "1.1.4",
"resolved": "https://registry.npmjs.org/@nuxtjs/proxy/-/proxy-1.1.4.tgz",
"integrity": "sha512-mLOpi46POTncRTf0XmdTSaEirSa8Ps6P3Az/GyqoSwZkVHZfQuVXA3HamqhQS4JEe9H5Oq8StReSIGPeGl74bQ==",
"requires": {
"http-proxy-middleware": "0.17.4"
}
},
"@nuxtjs/youch": {
"version": "4.2.3",
"resolved": "https://registry.npmjs.org/@nuxtjs/youch/-/youch-4.2.3.tgz",
......@@ -412,6 +432,23 @@
"integrity": "sha1-g+9cqGCysy5KDe7e6MdxudtXRx4=",
"dev": true
},
"axios": {
"version": "0.17.1",
"resolved": "https://registry.npmjs.org/axios/-/axios-0.17.1.tgz",
"integrity": "sha1-LY4+XQvb1zJ/kbyBT1xXZg+Bgk0=",
"requires": {
"follow-redirects": "1.4.1",
"is-buffer": "1.1.6"
}
},
"axios-retry": {
"version": "3.0.2",
"resolved": "https://registry.npmjs.org/axios-retry/-/axios-retry-3.0.2.tgz",
"integrity": "sha512-cX5sYst14esQAWIkyK5jrwHuS/XKLfgY7s2G9QktCPoAWEi00smMFtByIidfJVAgp0gFD41e7nxiAxIqW8ZO8A==",
"requires": {
"is-retry-allowed": "1.1.0"
}
},
"babel-code-frame": {
"version": "6.26.0",
"resolved": "https://registry.npmjs.org/babel-code-frame/-/babel-code-frame-6.26.0.tgz",
......@@ -4059,6 +4096,14 @@
"readable-stream": "2.3.3"
}
},
"follow-redirects": {
"version": "1.4.1",
"resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.4.1.tgz",
"integrity": "sha512-uxYePVPogtya1ktGnAAXOacnbIuRMB4dkvqeNz2qTtTQsuzSfbDolV+wMMKxAmCx0bLgAKLbBOkjItMbbkR1vg==",
"requires": {
"debug": "3.1.0"
}
},
"for-in": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/for-in/-/for-in-1.0.2.tgz",
......@@ -5507,6 +5552,132 @@
}
}
},
"http-proxy": {
"version": "1.16.2",
"resolved": "https://registry.npmjs.org/http-proxy/-/http-proxy-1.16.2.tgz",
"integrity": "sha1-Bt/ykpUr9k2+hHH6nfcwZtTzd0I=",
"requires": {
"eventemitter3": "1.2.0",
"requires-port": "1.0.0"
},
"dependencies": {
"eventemitter3": {
"version": "1.2.0",
"resolved": "https://registry.npmjs.org/eventemitter3/-/eventemitter3-1.2.0.tgz",
"integrity": "sha1-HIaZHYFq0eUEdQ5zh0Ik7PO+xQg="
}
}
},
"http-proxy-middleware": {
"version": "0.17.4",
"resolved": "https://registry.npmjs.org/http-proxy-middleware/-/http-proxy-middleware-0.17.4.tgz",
"integrity": "sha1-ZC6ISIUdZvCdTxJJEoRtuutBuDM=",
"requires": {
"http-proxy": "1.16.2",
"is-glob": "3.1.0",
"lodash": "4.17.4",
"micromatch": "2.3.11"
},
"dependencies": {
"arr-diff": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/arr-diff/-/arr-diff-2.0.0.tgz",
"integrity": "sha1-jzuCf5Vai9ZpaX5KQlasPOrjVs8=",
"requires": {
"arr-flatten": "1.1.0"
}
},
"array-unique": {
"version": "0.2.1",
"resolved": "https://registry.npmjs.org/array-unique/-/array-unique-0.2.1.tgz",
"integrity": "sha1-odl8yvy8JiXMcPrc6zalDFiwGlM="
},
"braces": {
"version": "1.8.5",
"resolved": "https://registry.npmjs.org/braces/-/braces-1.8.5.tgz",
"integrity": "sha1-uneWLhLf+WnWt2cR6RS3N4V79qc=",
"requires": {
"expand-range": "1.8.2",
"preserve": "0.2.0",
"repeat-element": "1.1.2"
}
},
"expand-brackets": {
"version": "0.1.5",
"resolved": "https://registry.npmjs.org/expand-brackets/-/expand-brackets-0.1.5.tgz",
"integrity": "sha1-3wcoTjQqgHzXM6xa9yQR5YHRF3s=",
"requires": {
"is-posix-bracket": "0.1.1"
}
},
"extglob": {
"version": "0.3.2",
"resolved": "https://registry.npmjs.org/extglob/-/extglob-0.3.2.tgz",
"integrity": "sha1-Lhj/PS9JqydlzskCPwEdqo2DSaE=",
"requires": {
"is-extglob": "1.0.0"
},
"dependencies": {
"is-extglob": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/is-extglob/-/is-extglob-1.0.0.tgz",
"integrity": "sha1-rEaBd8SUNAWgkvyPKXYMb/xiBsA="
}
}
},
"is-glob": {
"version": "3.1.0",
"resolved": "https://registry.npmjs.org/is-glob/-/is-glob-3.1.0.tgz",
"integrity": "sha1-e6WuJCF4BKxwcHuWkiVnSGzD6Eo=",
"requires": {
"is-extglob": "2.1.1"
}
},
"kind-of": {
"version": "3.2.2",
"resolved": "https://registry.npmjs.org/kind-of/-/kind-of-3.2.2.tgz",
"integrity": "sha1-MeohpzS6ubuw8yRm2JOupR5KPGQ=",
"requires": {
"is-buffer": "1.1.6"
}
},
"micromatch": {
"version": "2.3.11",
"resolved": "https://registry.npmjs.org/micromatch/-/micromatch-2.3.11.tgz",
"integrity": "sha1-hmd8l9FyCzY0MdBNDRUpO9OMFWU=",
"requires": {
"arr-diff": "2.0.0",
"array-unique": "0.2.1",
"braces": "1.8.5",
"expand-brackets": "0.1.5",
"extglob": "0.3.2",
"filename-regex": "2.0.1",
"is-extglob": "1.0.0",
"is-glob": "2.0.1",
"kind-of": "3.2.2",
"normalize-path": "2.1.1",
"object.omit": "2.0.1",
"parse-glob": "3.0.4",
"regex-cache": "0.4.4"
},
"dependencies": {
"is-extglob": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/is-extglob/-/is-extglob-1.0.0.tgz",
"integrity": "sha1-rEaBd8SUNAWgkvyPKXYMb/xiBsA="
},
"is-glob": {
"version": "2.0.1",
"resolved": "https://registry.npmjs.org/is-glob/-/is-glob-2.0.1.tgz",
"integrity": "sha1-0Jb5JqPe1WAPP9/ZEZjLCIjC2GM=",
"requires": {
"is-extglob": "1.0.0"
}
}
}
}
}
},
"http-signature": {
"version": "1.2.0",
"resolved": "https://registry.npmjs.org/http-signature/-/http-signature-1.2.0.tgz",
......@@ -5914,8 +6085,7 @@
"is-retry-allowed": {
"version": "1.1.0",
"resolved": "https://registry.npmjs.org/is-retry-allowed/-/is-retry-allowed-1.1.0.tgz",
"integrity": "sha1-EaBgVotnM5REAz0BJaYaINVk+zQ=",
"dev": true
"integrity": "sha1-EaBgVotnM5REAz0BJaYaINVk+zQ="
},
"is-stream": {
"version": "1.1.0",
......@@ -10587,6 +10757,11 @@
"resolve-from": "1.0.1"
}
},
"requires-port": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/requires-port/-/requires-port-1.0.0.tgz",
"integrity": "sha1-kl0mAdOaxIXgkc8NpcbmlNw9yv8="
},
"resolve": {
"version": "1.5.0",
"resolved": "https://registry.npmjs.org/resolve/-/resolve-1.5.0.tgz",
......
......@@ -3,8 +3,8 @@
<header>
<div class='header-material'>
<img class='profile-image' src='~/assets/profile-image.png' alt='Profile image'>
<h1>Aral Balkan</h1>
<h2>Cyborg Rights Activist</h2>
<h1>{{title}}</h1>
<h2>{{bio}}</h2>
</div>
</header>
<div class='shade'></div>
......@@ -20,6 +20,16 @@
</div>
</template>
<script>
export default {
computed: {
title () { return this.$store.state.title },
bio () { return this.$store.state.bio }
}
}
</script>
<style>
.header-material {
text-align: center;
......
module.exports = function (app) { // eslint-disable-line no-unused-vars
const siteConfiguration = require('./site-configuration/site-configuration.service.js');
module.exports = function (app) {
app.configure(siteConfiguration);
}
/* eslint-disable no-unused-vars */
const winston = require('../../lib/log')
const fs = require('fs')
const util = require('util')
const readFile = util.promisify(fs.readFile)
const path = require('path')
class Service {
constructor (options) {
this.options = options || {}
}
async find (params) {
const pathToData = path.normalize(path.join(__dirname, '../../../assets/data.json'))
const data = await readFile(pathToData, 'utf8')
const siteConfiguration = JSON.parse(data)
return siteConfiguration
}
}
module.exports = function (options) {
return new Service(options)
}
module.exports.Service = Service
module.exports = {
before: {
all: [],
find: [],
get: [],
create: [],
update: [],
patch: [],
remove: []
},
after: {
all: [],
find: [],
get: [],
create: [],
update: [],
patch: [],
remove: []
},
error: {
all: [],
find: [],
get: [],
create: [],
update: [],
patch: [],
remove: []
}
}
// Initializes the `site-configuration` service on path `/site-configuration`
const createService = require('./site-configuration.class.js');
const hooks = require('./site-configuration.hooks');
module.exports = function (app) {
const paginate = app.get('paginate');
const options = {
name: 'site-configuration',
paginate
};
// Initialize our service with any options it requires
app.use('/site-configuration', createService(options));
// Get our initialized service so that we can register hooks and filters
const service = app.service('site-configuration');
service.hooks(hooks);
};
export const state = () => ({
title: 'Hello, world',
bio: 'How lovely to be here :)'
})
export const mutations = {
title (state, text) {
state.title = text
},
bio (state, text) {
state.bio = text
}
}
export const actions = {
async nuxtServerInit ({ commit }, { app }) {
const siteConfiguration = await app.$axios.$get('https://aral.localtunnel.me/site-configuration')
commit('title', siteConfiguration.title)
commit('bio', siteConfiguration.bio)
}
}
const assert = require('assert');
const app = require('../../server/app');
describe('\'site-configuration\' service', () => {
it('registered the service', () => {
const service = app.service('site-configuration');
assert.ok(service, 'Registered the service');
});
});
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment