user locale, favicon
This commit is contained in:
@@ -2,6 +2,7 @@
|
|||||||
"title": "Gancio",
|
"title": "Gancio",
|
||||||
"description": "A shared agenda for local communities",
|
"description": "A shared agenda for local communities",
|
||||||
"favicon" : "../dist/favicon.ico",
|
"favicon" : "../dist/favicon.ico",
|
||||||
|
"user_locale": "./user_locale.json",
|
||||||
"baseurl": "http://localhost:13120",
|
"baseurl": "http://localhost:13120",
|
||||||
"server": {
|
"server": {
|
||||||
"host": "localhost",
|
"host": "localhost",
|
||||||
|
|||||||
@@ -1,6 +1,10 @@
|
|||||||
|
import acceptLanguage from 'accept-language'
|
||||||
export default function ({ req, app, store }) {
|
export default function ({ req, app, store }) {
|
||||||
if (process.server) {
|
if (process.server) {
|
||||||
const lang = req.acceptsLanguages('en', 'it')
|
const acceptedLanguages = req.headers['accept-language']
|
||||||
|
const supportedLanguages = ['en', 'it']
|
||||||
|
acceptLanguage.languages(supportedLanguages)
|
||||||
|
const lang = acceptLanguage.get(acceptedLanguages)
|
||||||
store.commit('setLocale', lang || 'it')
|
store.commit('setLocale', lang || 'it')
|
||||||
app.i18n.locale = store.state.locale
|
app.i18n.locale = store.state.locale
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,9 +13,9 @@ module.exports = {
|
|||||||
link: [{ rel: 'icon', type: 'image/x-icon', href: '/favicon.ico' }]
|
link: [{ rel: 'icon', type: 'image/x-icon', href: '/favicon.ico' }]
|
||||||
},
|
},
|
||||||
dev: (process.env.NODE_ENV !== 'production'),
|
dev: (process.env.NODE_ENV !== 'production'),
|
||||||
// serverMiddleware: [
|
serverMiddleware: [
|
||||||
// { path: '/api', handler: '@/server/api/index.js' }
|
{ path: '/api', handler: '~/server/api/index.js' }
|
||||||
// ],
|
],
|
||||||
|
|
||||||
server: conf.server,
|
server: conf.server,
|
||||||
|
|
||||||
@@ -81,21 +81,21 @@ module.exports = {
|
|||||||
** Build configuration
|
** Build configuration
|
||||||
*/
|
*/
|
||||||
build: {
|
build: {
|
||||||
optimization: {
|
// optimization: {
|
||||||
splitChunks: {
|
// splitChunks: {
|
||||||
cacheGroups: {
|
// cacheGroups: {
|
||||||
element: {
|
// element: {
|
||||||
test: /[\\/]node_modules[\\/](element-ui)[\\/]/,
|
// test: /[\\/]node_modules[\\/](element-ui)[\\/]/,
|
||||||
name: 'element-ui',
|
// name: 'element-ui',
|
||||||
chunks: 'all'
|
// chunks: 'all'
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
},
|
// },
|
||||||
transpile: [/^element-ui/, /^vue-awesome/],
|
transpile: [/^element-ui/, /^vue-awesome/],
|
||||||
splitChunks: {
|
// splitChunks: {
|
||||||
layouts: true
|
// layouts: true
|
||||||
},
|
// },
|
||||||
cache: true,
|
cache: true,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,9 +4,11 @@
|
|||||||
"description": "A shared agenda for local communities",
|
"description": "A shared agenda for local communities",
|
||||||
"author": "lesion",
|
"author": "lesion",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
"dev:nuxt": "cross-env NODE_ENV=development nuxt dev",
|
||||||
"dev": "cross-env NODE_ENV=development nodemon server/index.js --watch server",
|
"dev": "cross-env NODE_ENV=development nodemon server/index.js --watch server",
|
||||||
"build": "nuxt build",
|
"build": "nuxt build",
|
||||||
"start": "cross-env NODE_ENV=production node server/cli.js",
|
"start": "cross-env NODE_ENV=production node server/cli.js",
|
||||||
|
"start:nuxt": "cross-env NODE_ENV=development nuxt start",
|
||||||
"lint": "eslint --ext .js,.vue --ignore-path .gitignore .",
|
"lint": "eslint --ext .js,.vue --ignore-path .gitignore .",
|
||||||
"doc": "cd docs && bundle exec jekyll b",
|
"doc": "cd docs && bundle exec jekyll b",
|
||||||
"precommit": "npm run lint",
|
"precommit": "npm run lint",
|
||||||
@@ -38,6 +40,7 @@
|
|||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@nuxtjs/auth": "^4.6.5",
|
"@nuxtjs/auth": "^4.6.5",
|
||||||
"@nuxtjs/axios": "^5.5.3",
|
"@nuxtjs/axios": "^5.5.3",
|
||||||
|
"accept-language": "^3.0.18",
|
||||||
"axios": "^0.19.0",
|
"axios": "^0.19.0",
|
||||||
"bcryptjs": "^2.4.3",
|
"bcryptjs": "^2.4.3",
|
||||||
"body-parser": "^1.18.3",
|
"body-parser": "^1.18.3",
|
||||||
|
|||||||
@@ -102,7 +102,9 @@ export default {
|
|||||||
try {
|
try {
|
||||||
const [ id, start_datetime ] = params.id.split('_')
|
const [ id, start_datetime ] = params.id.split('_')
|
||||||
const event = await $axios.$get(`/event/${id}`)
|
const event = await $axios.$get(`/event/${id}`)
|
||||||
event.start_datetime = start_datetime*1000
|
event.start_datetime = start_datetime ? start_datetime*1000 : event.start_datetime*1000
|
||||||
|
event.end_datetime = event.end_datetime*1000
|
||||||
|
// event.start_datetime = start_datetime ? start_datetime*1000 : event.start
|
||||||
return { event, id }
|
return { event, id }
|
||||||
} catch(e) {
|
} catch(e) {
|
||||||
error({ statusCode: 404, message: 'Event not found'})
|
error({ statusCode: 404, message: 'Event not found'})
|
||||||
|
|||||||
@@ -2,17 +2,21 @@ import Vue from 'vue'
|
|||||||
import VueI18n from 'vue-i18n'
|
import VueI18n from 'vue-i18n'
|
||||||
import it from '../locales/it.js'
|
import it from '../locales/it.js'
|
||||||
import en from '../locales/en.js'
|
import en from '../locales/en.js'
|
||||||
|
import merge from 'lodash/merge'
|
||||||
|
|
||||||
Vue.use(VueI18n)
|
Vue.use(VueI18n)
|
||||||
|
|
||||||
export default ({ app, store }) => {
|
export default async ({ app, store }) => {
|
||||||
// Set i18n instance on app
|
// Set i18n instance on app
|
||||||
// This way we can use it in middleware and pages asyncData/fetch
|
// This way we can use it in middleware and pages asyncData/fetch
|
||||||
|
|
||||||
|
const user_locale = await app.$axios.$get('/settings/user_locale')
|
||||||
app.i18n = new VueI18n({
|
app.i18n = new VueI18n({
|
||||||
locale: store.state.locale,
|
locale: store.state.locale,
|
||||||
fallbackLocale: 'it',
|
fallbackLocale: 'it',
|
||||||
messages: {
|
messages: {
|
||||||
it, en
|
it: merge(it, user_locale),
|
||||||
|
en: merge(en, user_locale)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -100,8 +100,8 @@ const eventController = {
|
|||||||
order: [ [Comment, 'id', 'DESC'] ]
|
order: [ [Comment, 'id', 'DESC'] ]
|
||||||
})
|
})
|
||||||
|
|
||||||
event.start_datetime = event.start_datetime*1000
|
// event.start_datetime = event.start_datetime*1000
|
||||||
event.end_datetime = event.end_datetime*1000
|
// event.end_datetime = event.end_datetime*1000
|
||||||
|
|
||||||
if (event && (event.is_visible || is_admin)) {
|
if (event && (event.is_visible || is_admin)) {
|
||||||
res.json(event)
|
res.json(event)
|
||||||
|
|||||||
@@ -1,6 +1,13 @@
|
|||||||
const Mastodon = require('mastodon-api')
|
const Mastodon = require('mastodon-api')
|
||||||
const { setting: Setting } = require('../models')
|
const { setting: Setting } = require('../models')
|
||||||
const config = require('config')
|
const config = require('config')
|
||||||
|
const path = require('path')
|
||||||
|
const fs = require('fs')
|
||||||
|
|
||||||
|
let user_locale_path = false
|
||||||
|
if (config.user_locale && fs.existsSync(path.resolve(config.user_locale))) {
|
||||||
|
user_locale_path = path.resolve(config.user_locale)
|
||||||
|
}
|
||||||
|
|
||||||
const settingsController = {
|
const settingsController = {
|
||||||
settings: { initialized: false },
|
settings: { initialized: false },
|
||||||
@@ -38,11 +45,13 @@ const settingsController = {
|
|||||||
},
|
},
|
||||||
|
|
||||||
async getUserLocale(req, res) {
|
async getUserLocale(req, res) {
|
||||||
// console.error(res)
|
console.error(user_locale_path)
|
||||||
// load user locale specified in configuration
|
// load user locale specified in configuration
|
||||||
// res.json({ about: 'dentro user locale' })
|
if (user_locale_path) {
|
||||||
// res.sendStatus(200)
|
res.json(require(user_locale_path))
|
||||||
return false
|
} else {
|
||||||
|
res.json({})
|
||||||
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
async setRequest(req, res) {
|
async setRequest(req, res) {
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ const settingsController = require('./controller/settings')
|
|||||||
const storage = require('./storage')
|
const storage = require('./storage')
|
||||||
const upload = multer({ storage })
|
const upload = multer({ storage })
|
||||||
|
|
||||||
const api = express.Router()
|
const api = express()
|
||||||
api.use(cookieParser())
|
api.use(cookieParser())
|
||||||
api.use(bodyParser.urlencoded({ extended: false }))
|
api.use(bodyParser.urlencoded({ extended: false }))
|
||||||
api.use(bodyParser.json())
|
api.use(bodyParser.json())
|
||||||
|
|||||||
Reference in New Issue
Block a user