Initial commit

This commit is contained in:
Lucas Verney 2018-06-25 18:29:57 +02:00
commit 2d27e72b33
40 changed files with 7996 additions and 0 deletions

12
.babelrc Normal file
View File

@ -0,0 +1,12 @@
{
"presets": [
["env", {
"modules": false,
"targets": {
"browsers": ["> 1%", "last 2 versions", "not ie <= 8"]
}
}],
"stage-2"
],
"plugins": ["transform-vue-jsx", "transform-runtime"]
}

9
.editorconfig Normal file
View File

@ -0,0 +1,9 @@
root = true
[*]
charset = utf-8
indent_style = space
indent_size = 2
end_of_line = lf
insert_final_newline = true
trim_trailing_whitespace = true

4
.eslintignore Normal file
View File

@ -0,0 +1,4 @@
/build/
/config/
/dist/
/*.js

48
.eslintrc.js Normal file
View File

@ -0,0 +1,48 @@
// https://eslint.org/docs/user-guide/configuring
module.exports = {
root: true,
parser: 'babel-eslint',
parserOptions: {
sourceType: 'module'
},
env: {
browser: true,
},
// https://github.com/standard/standard/blob/master/docs/RULES-en.md
extends: 'airbnb-base',
// required to lint *.vue files
plugins: [
'html'
],
// check if imports actually resolve
'settings': {
'import/resolver': {
'webpack': {
'config': 'build/webpack.base.conf.js'
}
}
},
// add your custom rules here
rules: {
// allow async-await
'generator-star-spacing': 'off',
// allow debugger during development
'no-debugger': process.env.NODE_ENV === 'production' ? 'error' : 'off',
// Use 4 spaces indent
'indent': ['error', 4],
'import/prefer-default-export': 'off',
'no-console': 'off',
'no-underscore-dangle': 'off',
// Ignore assignment to state
'no-param-reassign': [
"error",
{
"props": true,
"ignorePropertyModificationsFor": ["state"]
}
],
'no-bitwise': 'off',
'function-paren-newline': 'off',
}
}

16
.gitignore vendored Normal file
View File

@ -0,0 +1,16 @@
.DS_Store
node_modules/
/dist/
npm-debug.log*
yarn-debug.log*
yarn-error.log*
*.db
*.pyc
# Editor directories and files
.idea
.vscode
*.suo
*.ntvs*
*.njsproj
*.sln

10
.postcssrc.js Normal file
View File

@ -0,0 +1,10 @@
// https://github.com/michael-ciniawsky/postcss-load-config
module.exports = {
"plugins": {
"postcss-import": {},
"postcss-url": {},
// to edit target browsers: use "browserslist" field in package.json
"autoprefixer": {}
}
}

28
README.md Normal file
View File

@ -0,0 +1,28 @@
# cyclassist
> A Vue.js project
## Build Setup
``` bash
# install dependencies
npm install
# serve with hot reload at localhost:8080
npm run dev
# build for production with minification
npm run build
# build for production and view the bundle analyzer report
npm run build --report
```
For a detailed explanation on how things work, check out the [guide](http://vuejs-templates.github.io/webpack/) and [docs for vue-loader](http://vuejs.github.io/vue-loader).
## Serving from a subdirectory
```
PUBLIC_PATH=https://.../foobar yarn build
```

41
build/build.js Normal file
View File

@ -0,0 +1,41 @@
'use strict'
require('./check-versions')()
process.env.NODE_ENV = 'production'
const ora = require('ora')
const rm = require('rimraf')
const path = require('path')
const chalk = require('chalk')
const webpack = require('webpack')
const config = require('../config')
const webpackConfig = require('./webpack.prod.conf')
const spinner = ora('building for production...')
spinner.start()
rm(path.join(config.build.assetsRoot, config.build.assetsSubDirectory), err => {
if (err) throw err
webpack(webpackConfig, (err, stats) => {
spinner.stop()
if (err) throw err
process.stdout.write(stats.toString({
colors: true,
modules: false,
children: false, // If you are using ts-loader, setting this to true will make TypeScript errors show up during build.
chunks: false,
chunkModules: false
}) + '\n\n')
if (stats.hasErrors()) {
console.log(chalk.red(' Build failed with errors.\n'))
process.exit(1)
}
console.log(chalk.cyan(' Build complete.\n'))
console.log(chalk.yellow(
' Tip: built files are meant to be served over an HTTP server.\n' +
' Opening index.html over file:// won\'t work.\n'
))
})
})

54
build/check-versions.js Normal file
View File

@ -0,0 +1,54 @@
'use strict'
const chalk = require('chalk')
const semver = require('semver')
const packageConfig = require('../package.json')
const shell = require('shelljs')
function exec (cmd) {
return require('child_process').execSync(cmd).toString().trim()
}
const versionRequirements = [
{
name: 'node',
currentVersion: semver.clean(process.version),
versionRequirement: packageConfig.engines.node
}
]
if (shell.which('npm')) {
versionRequirements.push({
name: 'npm',
currentVersion: exec('npm --version'),
versionRequirement: packageConfig.engines.npm
})
}
module.exports = function () {
const warnings = []
for (let i = 0; i < versionRequirements.length; i++) {
const mod = versionRequirements[i]
if (!semver.satisfies(mod.currentVersion, mod.versionRequirement)) {
warnings.push(mod.name + ': ' +
chalk.red(mod.currentVersion) + ' should be ' +
chalk.green(mod.versionRequirement)
)
}
}
if (warnings.length) {
console.log('')
console.log(chalk.yellow('To use this template, you must update following to modules:'))
console.log()
for (let i = 0; i < warnings.length; i++) {
const warning = warnings[i]
console.log(' ' + warning)
}
console.log()
process.exit(1)
}
}

BIN
build/logo.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.7 KiB

101
build/utils.js Normal file
View File

@ -0,0 +1,101 @@
'use strict'
const path = require('path')
const config = require('../config')
const ExtractTextPlugin = require('extract-text-webpack-plugin')
const packageConfig = require('../package.json')
exports.assetsPath = function (_path) {
const assetsSubDirectory = process.env.NODE_ENV === 'production'
? config.build.assetsSubDirectory
: config.dev.assetsSubDirectory
return path.posix.join(assetsSubDirectory, _path)
}
exports.cssLoaders = function (options) {
options = options || {}
const cssLoader = {
loader: 'css-loader',
options: {
sourceMap: options.sourceMap
}
}
const postcssLoader = {
loader: 'postcss-loader',
options: {
sourceMap: options.sourceMap
}
}
// generate loader string to be used with extract text plugin
function generateLoaders (loader, loaderOptions) {
const loaders = options.usePostCSS ? [cssLoader, postcssLoader] : [cssLoader]
if (loader) {
loaders.push({
loader: loader + '-loader',
options: Object.assign({}, loaderOptions, {
sourceMap: options.sourceMap
})
})
}
// Extract CSS when that option is specified
// (which is the case during production build)
if (options.extract) {
return ExtractTextPlugin.extract({
use: loaders,
fallback: 'vue-style-loader'
})
} else {
return ['vue-style-loader'].concat(loaders)
}
}
// https://vue-loader.vuejs.org/en/configurations/extract-css.html
return {
css: generateLoaders(),
postcss: generateLoaders(),
less: generateLoaders('less'),
sass: generateLoaders('sass', { indentedSyntax: true }),
scss: generateLoaders('sass'),
stylus: generateLoaders('stylus'),
styl: generateLoaders('stylus')
}
}
// Generate loaders for standalone style files (outside of .vue)
exports.styleLoaders = function (options) {
const output = []
const loaders = exports.cssLoaders(options)
for (const extension in loaders) {
const loader = loaders[extension]
output.push({
test: new RegExp('\\.' + extension + '$'),
use: loader
})
}
return output
}
exports.createNotifierCallback = () => {
const notifier = require('node-notifier')
return (severity, errors) => {
if (severity !== 'error') return
const error = errors[0]
const filename = error.file && error.file.split('!').pop()
notifier.notify({
title: packageConfig.name,
message: severity + ': ' + error.name,
subtitle: filename || '',
icon: path.join(__dirname, 'logo.png')
})
}
}

22
build/vue-loader.conf.js Normal file
View File

@ -0,0 +1,22 @@
'use strict'
const utils = require('./utils')
const config = require('../config')
const isProduction = process.env.NODE_ENV === 'production'
const sourceMapEnabled = isProduction
? config.build.productionSourceMap
: config.dev.cssSourceMap
module.exports = {
loaders: utils.cssLoaders({
sourceMap: sourceMapEnabled,
extract: isProduction
}),
cssSourceMap: sourceMapEnabled,
cacheBusting: config.dev.cacheBusting,
transformToRequire: {
video: ['src', 'poster'],
source: 'src',
img: 'src',
image: 'xlink:href'
}
}

View File

@ -0,0 +1,92 @@
'use strict'
const path = require('path')
const utils = require('./utils')
const config = require('../config')
const vueLoaderConfig = require('./vue-loader.conf')
function resolve (dir) {
return path.join(__dirname, '..', dir)
}
const createLintingRule = () => ({
test: /\.(js|vue)$/,
loader: 'eslint-loader',
enforce: 'pre',
include: [resolve('src'), resolve('test')],
options: {
formatter: require('eslint-friendly-formatter'),
emitWarning: !config.dev.showEslintErrorsInOverlay
}
})
module.exports = {
context: path.resolve(__dirname, '../'),
entry: {
app: './src/main.js'
},
output: {
path: config.build.assetsRoot,
filename: '[name].js',
publicPath: process.env.NODE_ENV === 'production'
? config.build.assetsPublicPath
: config.dev.assetsPublicPath
},
resolve: {
extensions: ['.js', '.vue', '.json'],
alias: {
'vue$': 'vue/dist/vue.esm.js',
'@': resolve('src'),
}
},
module: {
rules: [
...(config.dev.useEslint ? [createLintingRule()] : []),
{
test: /\.vue$/,
loader: 'vue-loader',
options: vueLoaderConfig
},
{
test: /\.js$/,
loader: 'babel-loader',
include: [resolve('src'), resolve('test'), resolve('node_modules/webpack-dev-server/client')]
},
{
test: /\.(png|jpe?g|gif|svg)(\?.*)?$/,
loader: 'url-loader',
options: {
limit: 10000,
name: utils.assetsPath('img/[name].[hash:7].[ext]')
}
},
{
test: /\.(mp4|webm|ogg|mp3|wav|flac|aac)(\?.*)?$/,
loader: 'url-loader',
options: {
limit: 10000,
name: utils.assetsPath('media/[name].[hash:7].[ext]')
}
},
{
test: /\.(woff2?|eot|ttf|otf)(\?.*)?$/,
loader: 'url-loader',
options: {
limit: 10000,
name: utils.assetsPath('fonts/[name].[hash:7].[ext]')
}
}
]
},
node: {
// prevent webpack from injecting useless setImmediate polyfill because Vue
// source contains it (although only uses it if it's native).
setImmediate: false,
// prevent webpack from injecting mocks to Node native modules
// that does not make sense for the client
dgram: 'empty',
fs: 'empty',
net: 'empty',
tls: 'empty',
child_process: 'empty'
}
}

95
build/webpack.dev.conf.js Executable file
View File

@ -0,0 +1,95 @@
'use strict'
const utils = require('./utils')
const webpack = require('webpack')
const config = require('../config')
const merge = require('webpack-merge')
const path = require('path')
const baseWebpackConfig = require('./webpack.base.conf')
const CopyWebpackPlugin = require('copy-webpack-plugin')
const HtmlWebpackPlugin = require('html-webpack-plugin')
const FriendlyErrorsPlugin = require('friendly-errors-webpack-plugin')
const portfinder = require('portfinder')
const HOST = process.env.HOST
const PORT = process.env.PORT && Number(process.env.PORT)
const devWebpackConfig = merge(baseWebpackConfig, {
module: {
rules: utils.styleLoaders({ sourceMap: config.dev.cssSourceMap, usePostCSS: true })
},
// cheap-module-eval-source-map is faster for development
devtool: config.dev.devtool,
// these devServer options should be customized in /config/index.js
devServer: {
clientLogLevel: 'warning',
historyApiFallback: {
rewrites: [
{ from: /.*/, to: path.posix.join(config.dev.assetsPublicPath, 'index.html') },
],
},
hot: true,
contentBase: false, // since we use CopyWebpackPlugin.
compress: true,
host: HOST || config.dev.host,
port: PORT || config.dev.port,
open: config.dev.autoOpenBrowser,
overlay: config.dev.errorOverlay
? { warnings: false, errors: true }
: false,
publicPath: config.dev.assetsPublicPath,
proxy: config.dev.proxyTable,
quiet: true, // necessary for FriendlyErrorsPlugin
watchOptions: {
poll: config.dev.poll,
}
},
plugins: [
new webpack.DefinePlugin({
'process.env': require('../config/dev.env')
}),
new webpack.HotModuleReplacementPlugin(),
new webpack.NamedModulesPlugin(), // HMR shows correct file names in console on update.
new webpack.NoEmitOnErrorsPlugin(),
// https://github.com/ampedandwired/html-webpack-plugin
new HtmlWebpackPlugin({
filename: 'index.html',
template: 'index.html',
inject: true
}),
// copy custom static assets
new CopyWebpackPlugin([
{
from: path.resolve(__dirname, '../static'),
to: config.dev.assetsSubDirectory,
ignore: ['.*']
}
])
]
})
module.exports = new Promise((resolve, reject) => {
portfinder.basePort = process.env.PORT || config.dev.port
portfinder.getPort((err, port) => {
if (err) {
reject(err)
} else {
// publish the new Port, necessary for e2e tests
process.env.PORT = port
// add port to devServer config
devWebpackConfig.devServer.port = port
// Add FriendlyErrorsPlugin
devWebpackConfig.plugins.push(new FriendlyErrorsPlugin({
compilationSuccessInfo: {
messages: [`Your application is running here: http://${devWebpackConfig.devServer.host}:${port}`],
},
onErrors: config.dev.notifyOnErrors
? utils.createNotifierCallback()
: undefined
}))
resolve(devWebpackConfig)
}
})
})

145
build/webpack.prod.conf.js Normal file
View File

@ -0,0 +1,145 @@
'use strict'
const path = require('path')
const utils = require('./utils')
const webpack = require('webpack')
const config = require('../config')
const merge = require('webpack-merge')
const baseWebpackConfig = require('./webpack.base.conf')
const CopyWebpackPlugin = require('copy-webpack-plugin')
const HtmlWebpackPlugin = require('html-webpack-plugin')
const ExtractTextPlugin = require('extract-text-webpack-plugin')
const OptimizeCSSPlugin = require('optimize-css-assets-webpack-plugin')
const UglifyJsPlugin = require('uglifyjs-webpack-plugin')
const env = require('../config/prod.env')
const webpackConfig = merge(baseWebpackConfig, {
module: {
rules: utils.styleLoaders({
sourceMap: config.build.productionSourceMap,
extract: true,
usePostCSS: true
})
},
devtool: config.build.productionSourceMap ? config.build.devtool : false,
output: {
path: config.build.assetsRoot,
filename: utils.assetsPath('js/[name].[chunkhash].js'),
chunkFilename: utils.assetsPath('js/[id].[chunkhash].js')
},
plugins: [
// http://vuejs.github.io/vue-loader/en/workflow/production.html
new webpack.DefinePlugin({
'process.env': env
}),
new UglifyJsPlugin({
uglifyOptions: {
compress: {
warnings: false
}
},
sourceMap: config.build.productionSourceMap,
parallel: true
}),
// extract css into its own file
new ExtractTextPlugin({
filename: utils.assetsPath('css/[name].[contenthash].css'),
// Setting the following option to `false` will not extract CSS from codesplit chunks.
// Their CSS will instead be inserted dynamically with style-loader when the codesplit chunk has been loaded by webpack.
// It's currently set to `true` because we are seeing that sourcemaps are included in the codesplit bundle as well when it's `false`,
// increasing file size: https://github.com/vuejs-templates/webpack/issues/1110
allChunks: true,
}),
// Compress extracted CSS. We are using this plugin so that possible
// duplicated CSS from different components can be deduped.
new OptimizeCSSPlugin({
cssProcessorOptions: config.build.productionSourceMap
? { safe: true, map: { inline: false } }
: { safe: true }
}),
// generate dist index.html with correct asset hash for caching.
// you can customize output by editing /index.html
// see https://github.com/ampedandwired/html-webpack-plugin
new HtmlWebpackPlugin({
filename: config.build.index,
template: 'index.html',
inject: true,
minify: {
removeComments: true,
collapseWhitespace: true,
removeAttributeQuotes: true
// more options:
// https://github.com/kangax/html-minifier#options-quick-reference
},
// necessary to consistently work with multiple chunks via CommonsChunkPlugin
chunksSortMode: 'dependency'
}),
// keep module.id stable when vendor modules does not change
new webpack.HashedModuleIdsPlugin(),
// enable scope hoisting
new webpack.optimize.ModuleConcatenationPlugin(),
// split vendor js into its own file
new webpack.optimize.CommonsChunkPlugin({
name: 'vendor',
minChunks (module) {
// any required modules inside node_modules are extracted to vendor
return (
module.resource &&
/\.js$/.test(module.resource) &&
module.resource.indexOf(
path.join(__dirname, '../node_modules')
) === 0
)
}
}),
// extract webpack runtime and module manifest to its own file in order to
// prevent vendor hash from being updated whenever app bundle is updated
new webpack.optimize.CommonsChunkPlugin({
name: 'manifest',
minChunks: Infinity
}),
// This instance extracts shared chunks from code splitted chunks and bundles them
// in a separate chunk, similar to the vendor chunk
// see: https://webpack.js.org/plugins/commons-chunk-plugin/#extra-async-commons-chunk
new webpack.optimize.CommonsChunkPlugin({
name: 'app',
async: 'vendor-async',
children: true,
minChunks: 3
}),
// copy custom static assets
new CopyWebpackPlugin([
{
from: path.resolve(__dirname, '../static'),
to: config.build.assetsSubDirectory,
ignore: ['.*']
}
])
]
})
if (config.build.productionGzip) {
const CompressionWebpackPlugin = require('compression-webpack-plugin')
webpackConfig.plugins.push(
new CompressionWebpackPlugin({
asset: '[path].gz[query]',
algorithm: 'gzip',
test: new RegExp(
'\\.(' +
config.build.productionGzipExtensions.join('|') +
')$'
),
threshold: 10240,
minRatio: 0.8
})
)
}
if (config.build.bundleAnalyzerReport) {
const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin
webpackConfig.plugins.push(new BundleAnalyzerPlugin())
}
module.exports = webpackConfig

7
config/dev.env.js Normal file
View File

@ -0,0 +1,7 @@
'use strict'
const merge = require('webpack-merge')
const prodEnv = require('./prod.env')
module.exports = merge(prodEnv, {
NODE_ENV: '"development"',
})

76
config/index.js Normal file
View File

@ -0,0 +1,76 @@
'use strict'
// Template version: 1.2.8
// see http://vuejs-templates.github.io/webpack for documentation.
const path = require('path')
module.exports = {
dev: {
// Paths
assetsSubDirectory: 'static',
assetsPublicPath: process.env.PUBLIC_PATH || '/',
proxyTable: {},
// Various Dev Server settings
host: 'localhost', // can be overwritten by process.env.HOST
port: 8080, // can be overwritten by process.env.PORT, if port is in use, a free one will be determined
autoOpenBrowser: false,
errorOverlay: true,
notifyOnErrors: true,
poll: false, // https://webpack.js.org/configuration/dev-server/#devserver-watchoptions-
// Use Eslint Loader?
// If true, your code will be linted during bundling and
// linting errors and warnings will be shown in the console.
useEslint: true,
// If true, eslint errors and warnings will also be shown in the error overlay
// in the browser.
showEslintErrorsInOverlay: false,
/**
* Source Maps
*/
// https://webpack.js.org/configuration/devtool/#development
devtool: 'cheap-module-eval-source-map',
// If you have problems debugging vue-files in devtools,
// set this to false - it *may* help
// https://vue-loader.vuejs.org/en/options.html#cachebusting
cacheBusting: true,
cssSourceMap: true,
},
build: {
// Template for index.html
index: path.resolve(__dirname, '../dist/index.html'),
// Paths
assetsRoot: path.resolve(__dirname, '../dist'),
assetsSubDirectory: 'static',
assetsPublicPath: process.env.PUBLIC_PATH || '/',
/**
* Source Maps
*/
productionSourceMap: true,
// https://webpack.js.org/configuration/devtool/#production
devtool: '#source-map',
// Gzip off by default as many popular static hosts such as
// Surge or Netlify already gzip all static assets for you.
// Before setting to `true`, make sure to:
// npm install --save-dev compression-webpack-plugin
productionGzip: false,
productionGzipExtensions: ['js', 'css'],
// Run the build command with an extra argument to
// View the bundle analyzer report after build finishes:
// `npm run build --report`
// Set to `true` or `false` to always turn it on or off
bundleAnalyzerReport: process.env.npm_config_report
}
}

4
config/prod.env.js Normal file
View File

@ -0,0 +1,4 @@
'use strict'
module.exports = {
NODE_ENV: '"production"',
}

12
index.html Normal file
View File

@ -0,0 +1,12 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width,initial-scale=1.0">
<title>cyclassist</title>
</head>
<body>
<div id="app"></div>
<!-- built files will be auto injected -->
</body>
</html>

81
package.json Normal file
View File

@ -0,0 +1,81 @@
{
"name": "cyclassist",
"version": "1.0.0",
"description": "A Vue.js project",
"author": "Phyks (Lucas Verney) <phyks@phyks.me>",
"private": true,
"scripts": {
"dev": "webpack-dev-server --inline --progress --config build/webpack.dev.conf.js",
"start": "npm run dev",
"lint": "eslint --ext .js,.vue src",
"build": "node build/build.js"
},
"dependencies": {
"es6-promise": "^4.2.4",
"isomorphic-fetch": "^2.2.1",
"leaflet": "^1.3.1",
"leaflet-tracksymbol": "^1.0.8",
"material-icons": "^0.2.3",
"roboto-fontface": "^0.9.0",
"vue": "^2.5.2",
"vue-i18n": "^7.8.1",
"vue-router": "^3.0.1",
"vue2-leaflet": "^1.0.2",
"vue2-leaflet-tracksymbol": "^1.0.10",
"vuetify": "^1.0.0"
},
"devDependencies": {
"autoprefixer": "^7.1.2",
"babel-core": "^6.22.1",
"babel-eslint": "^7.1.1",
"babel-helper-vue-jsx-merge-props": "^2.0.3",
"babel-loader": "^7.1.1",
"babel-plugin-syntax-jsx": "^6.18.0",
"babel-plugin-transform-runtime": "^6.22.0",
"babel-plugin-transform-vue-jsx": "^3.5.0",
"babel-preset-env": "^1.3.2",
"babel-preset-stage-2": "^6.22.0",
"chalk": "^2.0.1",
"copy-webpack-plugin": "^4.0.1",
"css-loader": "^0.28.0",
"eslint": "^3.19.0",
"eslint-config-airbnb-base": "^11.3.0",
"eslint-friendly-formatter": "^3.0.0",
"eslint-import-resolver-webpack": "^0.8.3",
"eslint-loader": "^1.7.1",
"eslint-plugin-html": "^3.0.0",
"eslint-plugin-import": "^2.7.0",
"extract-text-webpack-plugin": "^3.0.0",
"file-loader": "^1.1.4",
"friendly-errors-webpack-plugin": "^1.6.1",
"html-webpack-plugin": "^2.30.1",
"node-notifier": "^5.1.2",
"optimize-css-assets-webpack-plugin": "^3.2.0",
"ora": "^1.2.0",
"portfinder": "^1.0.13",
"postcss-import": "^11.0.0",
"postcss-loader": "^2.0.8",
"postcss-url": "^7.2.1",
"rimraf": "^2.6.0",
"semver": "^5.3.0",
"shelljs": "^0.7.6",
"uglifyjs-webpack-plugin": "^1.1.1",
"url-loader": "^0.5.8",
"vue-loader": "^13.3.0",
"vue-style-loader": "^3.0.1",
"vue-template-compiler": "^2.5.2",
"webpack": "^3.6.0",
"webpack-bundle-analyzer": "^2.9.0",
"webpack-dev-server": "^2.9.1",
"webpack-merge": "^4.1.0"
},
"engines": {
"node": ">= 6.0.0",
"npm": ">= 3.0.0"
},
"browserslist": [
"> 1%",
"last 2 versions",
"not ie <= 8"
]
}

3
requirements.txt Normal file
View File

@ -0,0 +1,3 @@
arrow
bottle
peewee

0
server/__init__.py Normal file
View File

71
server/__main__.py Normal file
View File

@ -0,0 +1,71 @@
#!/usr/bin/env python
# coding: utf-8
import json
import arrow
import bottle
import peewee
db = peewee.SqliteDatabase('reports.db')
class Report(peewee.Model):
type = peewee.CharField(max_length=255)
lat = peewee.DoubleField()
lng = peewee.DoubleField()
datetime = peewee.DateTimeField(
default=arrow.utcnow().replace(microsecond=0)
)
class Meta:
database = db
@bottle.hook('after_request')
def enable_cors():
"""
Add CORS headers at each request.
"""
# The str() call is required as we import unicode_literal and WSGI
# headers list should have plain str type.
bottle.response.headers[str('Access-Control-Allow-Origin')] = str('*')
bottle.response.headers[str('Access-Control-Allow-Methods')] = str(
'PUT, GET, POST, DELETE, OPTIONS, PATCH'
)
bottle.response.headers[str('Access-Control-Allow-Headers')] = str(
'Origin, Accept, Content-Type, X-Requested-With, X-CSRF-Token'
)
@bottle.route('/api/v1/reports', ["POST", "OPTIONS"])
def postReport():
"""
Add a new report in database.
"""
if bottle.request.method == 'OPTIONS':
return {}
try:
payload = json.load(bottle.request.body)
except ValueError:
bottle.abort(400, "Invalid JSON payload.")
try:
Report.create(
type=payload['type'],
lat=payload['lat'],
lng=payload['lng']
)
except KeyError:
bottle.abort(400, "Invalid JSON payload.")
return {
"status": "ok"
}
if __name__ == "__main__":
db.connect()
db.create_tables([Report])
bottle.run(host='0.0.0.0', port='8081')

52
src/App.vue Normal file
View File

@ -0,0 +1,52 @@
<template>
<v-app>
<v-toolbar
app
>
<router-link :to="{ name: 'Map' }" class="noLinkDecoration">
<v-toolbar-title v-text="title" class="ma-0"></v-toolbar-title>
</router-link>
<v-spacer></v-spacer>
<v-menu offset-y class="menu">
<v-btn slot="activator" icon>
<v-icon>more_vert</v-icon>
</v-btn>
<v-list>
<v-list-tile @click="">
<v-list-tile-title @click="goToAbout">{{ $t("menu.About") }}</v-list-tile-title>
</v-list-tile>
</v-list>
</v-menu>
</v-toolbar>
<v-content>
<router-view/>
</v-content>
</v-app>
</template>
<script>
export default {
data() {
return {
title: 'Cycl\'Assist',
};
},
name: 'App',
methods: {
goToAbout() {
this.$router.push({ name: 'About' });
},
},
};
</script>
<style scoped>
.menu {
z-index: 2000 !important;
}
.noLinkDecoration {
color: rgba(0, 0, 0, .87);
text-decoration: none;
}
</style>

20
src/api/index.js Normal file
View File

@ -0,0 +1,20 @@
require('es6-promise').polyfill();
require('isomorphic-fetch');
// With trailing slash
export const BASE_URL = process.env.API_BASE_URL || 'http://127.0.0.1:8081/'; // TODO
export function saveReport(type, lat, lng) {
return fetch(`${BASE_URL}api/v1/reports`, {
method: 'POST',
body: JSON.stringify({
type,
lat,
lng,
}),
});
}
export function getReports() {
// TODO
}

147
src/assets/gcum.svg Normal file
View File

@ -0,0 +1,147 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
id="svg8"
version="1.1"
viewBox="0 0 52.916666 26.458334"
height="100"
width="200"
sodipodi:docname="obstacle.svg"
inkscape:version="0.92.2 5c3e80d, 2017-08-06">
<sodipodi:namedview
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1"
objecttolerance="10"
gridtolerance="10"
guidetolerance="10"
inkscape:pageopacity="0"
inkscape:pageshadow="2"
inkscape:window-width="1916"
inkscape:window-height="1041"
id="namedview884"
showgrid="false"
inkscape:zoom="3.435"
inkscape:cx="22.296447"
inkscape:cy="16.085255"
inkscape:window-x="0"
inkscape:window-y="37"
inkscape:window-maximized="0"
inkscape:current-layer="layer1" />
<defs
id="defs2" />
<metadata
id="metadata5">
<rdf:RDF>
<cc:Work
rdf:about="">
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
<dc:title />
</cc:Work>
</rdf:RDF>
</metadata>
<g
transform="translate(0,-270.54165)"
id="layer1">
<g
id="layer1-6"
transform="matrix(0,-0.09010182,0.09010182,0,-14.971939,321.52926)">
<rect
style="opacity:0.99800002;fill:#231f20;fill-opacity:1;fill-rule:nonzero;stroke:#ffffff;stroke-width:0;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:0.77287065"
id="rect4136"
width="205.71428"
height="417.14291"
x="279.74295"
y="311.09451"
ry="26.981987"
rx="82.600098" />
<rect
style="opacity:0.99800002;fill:#231f20;fill-opacity:1;fill-rule:nonzero;stroke:#ffffff;stroke-width:0;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:0.77287065"
id="rect4138"
width="206.07112"
height="315.1676"
x="280.14145"
y="431.77679"
rx="30.126019"
ry="38.8909" />
<path
style="fill:none;fill-rule:evenodd;stroke:#231f20;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
d="M 331.42857,377.36221 C 378.57143,363.79078 450,373.07649 450,373.07649 l -8.57143,60 h -100 l -9.28572,-52.85714 h 1.42858 z"
id="path4140" />
<path
style="fill:none;fill-rule:evenodd;stroke:#231f20;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
d="m 325.10647,448.44447 c 51.42857,-25 124.28571,-7.85714 124.28571,-7.85714 l -22.85714,70 -80,-0.71429 z"
id="path4142" />
<path
style="opacity:0.99800002;fill:none;fill-opacity:1;fill-rule:nonzero;stroke:#ffffff;stroke-width:0;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:0.77287065"
d="m 303.82209,745.69644 c -9.80734,-3.02858 -18.08768,-12.63143 -21.93158,-25.43443 -1.21307,-4.04041 -1.2892,-13.81396 -1.47025,-188.74669 l -0.19094,-184.48564 1.52464,-3.54411 c 1.00125,-2.32747 3.15974,-5.07869 6.28775,-8.01436 17.40981,-16.33933 62.93969,-26.20028 108.75284,-23.55389 43.92414,2.53727 77.08927,14.20562 85.9746,30.24809 l 2.12437,3.83555 0.53235,84.28571 c 0.29279,46.35714 0.44453,129.76786 0.33719,185.35714 -0.21629,112.01593 0.16279,103.22653 -4.89694,113.53905 -2.7649,5.63528 -9.46708,12.57863 -14.54403,15.06737 l -3.57143,1.75073 -78.57143,0.12345 c -43.21428,0.0679 -79.375,-0.12468 -80.35714,-0.42797 z"
id="path4144" />
<path
style="opacity:0.99800002;fill:none;fill-opacity:1;fill-rule:nonzero;stroke:#ffffff;stroke-width:0;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:0.77287065"
d="m 303.82209,745.69644 c -9.80734,-3.02858 -18.08768,-12.63143 -21.93158,-25.43443 -1.21307,-4.04041 -1.2892,-13.81396 -1.47025,-188.74669 l -0.19094,-184.48564 1.52464,-3.54411 c 1.00125,-2.32747 3.15974,-5.07869 6.28775,-8.01436 17.40981,-16.33933 62.93969,-26.20028 108.75284,-23.55389 43.92414,2.53727 77.08927,14.20562 85.9746,30.24809 l 2.12437,3.83555 0.53235,84.28571 c 0.29279,46.35714 0.44453,129.76786 0.33719,185.35714 -0.21629,112.01593 0.16279,103.22653 -4.89694,113.53905 -2.7649,5.63528 -9.46708,12.57863 -14.54403,15.06737 l -3.57143,1.75073 -78.57143,0.12345 c -43.21428,0.0679 -79.375,-0.12468 -80.35714,-0.42797 z"
id="path4146" />
<path
style="opacity:0.99800002;fill:none;fill-opacity:1;fill-rule:nonzero;stroke:#ffffff;stroke-width:0;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:0.77287065"
d="m 303.82209,745.69644 c -9.80734,-3.02858 -18.08768,-12.63143 -21.93158,-25.43443 -1.21307,-4.04041 -1.2892,-13.81396 -1.47025,-188.74669 l -0.19094,-184.48564 1.52464,-3.54411 c 1.00125,-2.32747 3.15974,-5.07869 6.28775,-8.01436 17.40981,-16.33933 62.93969,-26.20028 108.75284,-23.55389 43.92414,2.53727 77.08927,14.20562 85.9746,30.24809 l 2.12437,3.83555 0.53235,84.28571 c 0.29279,46.35714 0.44453,129.76786 0.33719,185.35714 -0.21629,112.01593 0.16279,103.22653 -4.89694,113.53905 -2.7649,5.63528 -9.46708,12.57863 -14.54403,15.06737 l -3.57143,1.75073 -78.57143,0.12345 c -43.21428,0.0679 -79.375,-0.12468 -80.35714,-0.42797 z"
id="path4148" />
<path
style="fill:#ffffff;fill-opacity:1;fill-rule:evenodd;stroke:#231f20;stroke-width:1.2476511px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
d="m 303.24036,420.31238 c 79.72325,-30.81221 159.43908,0.52898 159.43908,0.52898 l -27.13272,78.13931 -105.21688,0.7877 z"
id="path4152" />
<path
style="fill:#ffffff;fill-opacity:1;fill-rule:evenodd;stroke:#231f20;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
d="m 294.12237,450.39219 0.42244,114.18283 28.93312,5.1884 -0.0784,-63.74925 z"
id="path4156" />
<path
style="fill:#ffffff;fill-opacity:1;fill-rule:evenodd;stroke:#231f20;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
d="m 295.49018,657.06797 -0.87993,-83.51205 28.84382,5.20489 10e-6,61.74557 z"
id="path4156-17" />
<path
style="fill:#ffffff;fill-opacity:1;fill-rule:evenodd;stroke:#231f20;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
d="m 313.11041,684.43623 136.84084,0.50508 -14.64285,-32.5 -105.41227,-0.50509 z"
id="path4152-7" />
<path
style="fill:#ffffff;fill-opacity:1;fill-rule:evenodd;stroke:#231f20;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
d="m 471.75636,450.05562 -0.10677,114.43537 -28.93312,5.1884 -0.30424,-63.75625 z"
id="path4156-8" />
<path
style="fill:#ffffff;fill-opacity:1;fill-rule:evenodd;stroke:#231f20;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
d="m 470.70422,656.98394 0.87993,-83.51205 -28.84382,5.20489 -10e-6,61.74557 z"
id="path4156-17-0" />
<path
style="fill:none;fill-rule:evenodd;stroke:#ffffff;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
d="m 279.71068,337.56407 c 11.61675,0 18.22075,0 28.22075,-5 10,-5 15,-18.60364 15,-18.60364"
id="path4298" />
<path
style="fill:none;fill-rule:evenodd;stroke:#ffffff;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
d="m 485.4792,337.55068 c -11.61675,0 -18.22075,0 -28.22075,-5 -10,-5 -15,-18.60364 -15,-18.60364"
id="path4298-1" />
</g>
<g
transform="matrix(0,0.22831338,-0.22831338,0,11.761749,281.5442)"
id="g1611">
<path
style="fill:none"
d="M 0,0 H 48 V 48 H 0 Z"
id="path1597"
inkscape:connector-curvature="0" />
<path
style="fill:#231f20;fill-opacity:1"
d="m 32,9.6 c 1.98,0 3.6,-1.61 3.6,-3.6 0,-1.99 -1.62,-3.6 -3.6,-3.6 -1.99,0 -3.6,1.61 -3.6,3.6 0,1.99 1.61,3.6 3.6,3.6 z M 38,24 c -5.52,0 -10,4.48 -10,10 0,5.52 4.48,10 10,10 5.52,0 10,-4.48 10,-10 0,-5.52 -4.48,-10 -10,-10 z m 0,17 c -3.87,0 -7,-3.13 -7,-7 0,-3.87 3.13,-7 7,-7 3.87,0 7,3.13 7,7 0,3.87 -3.13,7 -7,7 z M 29.6,20 H 38 V 16.4 H 31.6 L 27.73,9.87 C 27.14,8.87 26.05,8.2 24.8,8.2 c -0.94,0 -1.79,0.38 -2.4,1 L 15,16.59 c -0.62,0.62 -1,1.47 -1,2.41 0,1.26 0.67,2.32 1.7,2.94 L 22.4,26 V 36 H 26 V 23.04 L 21.5,19.7 26.14,15.04 Z M 10,24 C 4.48,24 0,28.48 0,34 0,39.52 4.48,44 10,44 15.52,44 20,39.52 20,34 20,28.48 15.52,24 10,24 Z m 0,17 c -3.87,0 -7,-3.13 -7,-7 0,-3.87 3.13,-7 7,-7 3.87,0 7,3.13 7,7 0,3.87 -3.13,7 -7,7 z"
id="path1599"
inkscape:connector-curvature="0" />
</g>
<path
id="path5302"
d="M 1.0299374,274.54935 H 51.276607"
style="fill:none;fill-opacity:1;fill-rule:evenodd;stroke:#231f20;stroke-width:1.32291663;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:5.29166667, 5.29166667;stroke-dashoffset:0;stroke-opacity:1" />
</g>
</svg>

After

Width:  |  Height:  |  Size: 9.1 KiB

81
src/assets/obstacle.svg Normal file
View File

@ -0,0 +1,81 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
id="svg8"
version="1.1"
viewBox="0 0 52.916666 26.458334"
height="100"
width="200"
sodipodi:docname="obstacle.svg"
inkscape:version="0.92.2 5c3e80d, 2017-08-06">
<sodipodi:namedview
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1"
objecttolerance="10"
gridtolerance="10"
guidetolerance="10"
inkscape:pageopacity="0"
inkscape:pageshadow="2"
inkscape:window-width="1920"
inkscape:window-height="1080"
id="namedview884"
showgrid="false"
inkscape:zoom="3.435"
inkscape:cx="215.13828"
inkscape:cy="16.085255"
inkscape:window-x="0"
inkscape:window-y="0"
inkscape:window-maximized="0"
inkscape:current-layer="layer1" />
<defs
id="defs2" />
<metadata
id="metadata5">
<rdf:RDF>
<cc:Work
rdf:about="">
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
<dc:title />
</cc:Work>
</rdf:RDF>
</metadata>
<g
transform="translate(0,-270.54165)"
id="layer1">
<g
transform="matrix(0,0.22831338,-0.22831338,0,11.761749,282.52054)"
id="g1611"
style="stroke:none;stroke-opacity:1">
<path
style="fill:none;stroke:none;stroke-opacity:1"
d="M 0,0 H 48 V 48 H 0 Z"
id="path1597"
inkscape:connector-curvature="0" />
<path
style="fill:#231f20;fill-opacity:1;stroke:none;stroke-opacity:1"
d="m 32,9.6 c 1.98,0 3.6,-1.61 3.6,-3.6 0,-1.99 -1.62,-3.6 -3.6,-3.6 -1.99,0 -3.6,1.61 -3.6,3.6 0,1.99 1.61,3.6 3.6,3.6 z M 38,24 c -5.52,0 -10,4.48 -10,10 0,5.52 4.48,10 10,10 5.52,0 10,-4.48 10,-10 0,-5.52 -4.48,-10 -10,-10 z m 0,17 c -3.87,0 -7,-3.13 -7,-7 0,-3.87 3.13,-7 7,-7 3.87,0 7,3.13 7,7 0,3.87 -3.13,7 -7,7 z M 29.6,20 H 38 V 16.4 H 31.6 L 27.73,9.87 C 27.14,8.87 26.05,8.2 24.8,8.2 c -0.94,0 -1.79,0.38 -2.4,1 L 15,16.59 c -0.62,0.62 -1,1.47 -1,2.41 0,1.26 0.67,2.32 1.7,2.94 L 22.4,26 V 36 H 26 V 23.04 L 21.5,19.7 26.14,15.04 Z M 10,24 C 4.48,24 0,28.48 0,34 0,39.52 4.48,44 10,44 15.52,44 20,39.52 20,34 20,28.48 15.52,24 10,24 Z m 0,17 c -3.87,0 -7,-3.13 -7,-7 0,-3.87 3.13,-7 7,-7 3.87,0 7,3.13 7,7 0,3.87 -3.13,7 -7,7 z"
id="path1599"
inkscape:connector-curvature="0" />
</g>
<path
id="path5302"
d="M 0.2596802,277.74573 H 55.590047"
style="fill:none;fill-opacity:1;fill-rule:evenodd;stroke:#231f20;stroke-width:1.45679581;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:5.82718337, 5.82718337;stroke-dashoffset:0;stroke-opacity:1"
inkscape:connector-curvature="0" />
<path
style="fill:#231f20;fill-opacity:1;fill-rule:evenodd;stroke:#231f20;stroke-width:0.26458332px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
d="M 24.879306,296.84593 38.127729,279.20704 H 52.608564 V 296.8751"
id="path890"
inkscape:connector-curvature="0"
sodipodi:nodetypes="cccc" />
</g>
</svg>

After

Width:  |  Height:  |  Size: 3.4 KiB

87
src/assets/pothole.svg Normal file
View File

@ -0,0 +1,87 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
id="svg8"
version="1.1"
viewBox="0 0 52.916666 26.458333"
height="100"
width="200"
sodipodi:docname="pothole.svg"
inkscape:version="0.92.2 5c3e80d, 2017-08-06">
<sodipodi:namedview
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1"
objecttolerance="10"
gridtolerance="10"
guidetolerance="10"
inkscape:pageopacity="0"
inkscape:pageshadow="2"
inkscape:window-width="1596"
inkscape:window-height="861"
id="namedview826"
showgrid="false"
inkscape:zoom="14.877527"
inkscape:cx="86.273275"
inkscape:cy="16.427481"
inkscape:window-x="0"
inkscape:window-y="37"
inkscape:window-maximized="0"
inkscape:current-layer="g12" />
<defs
id="defs2" />
<metadata
id="metadata5">
<rdf:RDF>
<cc:Work
rdf:about="">
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
<dc:title />
</cc:Work>
</rdf:RDF>
</metadata>
<g
transform="translate(0,-270.54167)"
id="layer1">
<g
transform="matrix(0.35277777,0,0,-0.35277777,5.2364181,288.02794)"
id="g10">
<g
transform="scale(0.1)"
id="g12">
<path
id="path18"
style="fill:#231f20;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:1.76795506"
d="m 482.0259,-254.32629 1.26409,140.5807 v 0 c 6.94099,0.11669 14.39292,0.62056 21.19601,1.89172 7.1337,1.33304 14.00397,4.4411 19.03203,9.58585 6.04288,6.285073 11.13989,14.723527 15.08243,22.410594 7.63933,15.179663 19.60662,37.533679 30.17368,50.793347 17.81746,22.2939108 44.93082,36.3261736 72.61699,43.440414 31.31225,8.058347 64.53743,6.787192 94.69697,-4.8353512 25.84926,-9.84043686 47.42363,-26.6024178 64.35003,-48.4454998 9.92353,-12.879557 21.82364,-32.065401 32.57633,-44.303182 15.66231,-17.851042 37.5549,-29.280872 60.7929,-34.239982 14.75889,-3.10807 30.04286,-3.36265 44.79998,-0.24221 19.15049,3.99203 37.417,12.83181 50.84994,27.037329 12.92902,13.544302 25.08372,34.931257 36.15282,49.973014 14.5716,19.889497 33.5983,36.1317006 55.7472,46.9268329 26.6078,13.0103791 56.5252,17.4037451 85.7937,13.4594391 25.6564,-3.431596 50.0348,-13.2738013 70.5236,-29.0192128 16.3536,-12.5683942 29.8555,-28.6939092 40.3536,-46.5254962 4.0734,-6.92685 17.3136,-29.406402 21.9615,-35.946067 4.6409,-6.477788 11.3255,-11.622539 18.2665,-15.443089 6.2976,-3.47933 13.4118,-6.02165 20.6144,-6.51845 6.7465,-0.33237 13.6185,0.18564 20.1794,0.68951 v 0 l -0.3943,-140.95198 -876.6298,-0.31823 v 0" />
<rect
transform="scale(1,-1)"
y="113.71031"
x="-153.9525"
height="140.61598"
width="658.89551"
id="rect52"
style="fill:#231f20;fill-opacity:1;stroke:none;stroke-width:11.13394451;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" />
<g
transform="matrix(13.085938,0,0,-13.085938,-140.97651,471.40631)"
id="g945">
<path
style="fill:none"
d="M 0,0 H 48 V 48 H 0 Z"
id="path931" />
<path
style="fill:#231f20;fill-opacity:1"
d="m 32,9.6 c 1.98,0 3.6,-1.61 3.6,-3.6 0,-1.99 -1.62,-3.6 -3.6,-3.6 -1.99,0 -3.6,1.61 -3.6,3.6 0,1.99 1.61,3.6 3.6,3.6 z M 38,24 c -5.52,0 -10,4.48 -10,10 0,5.52 4.48,10 10,10 5.52,0 10,-4.48 10,-10 0,-5.52 -4.48,-10 -10,-10 z m 0,17 c -3.87,0 -7,-3.13 -7,-7 0,-3.87 3.13,-7 7,-7 3.87,0 7,3.13 7,7 0,3.87 -3.13,7 -7,7 z M 29.6,20 H 38 V 16.4 H 31.6 L 27.73,9.87 C 27.14,8.87 26.05,8.2 24.8,8.2 c -0.94,0 -1.79,0.38 -2.4,1 L 15,16.59 c -0.62,0.62 -1,1.47 -1,2.41 0,1.26 0.67,2.32 1.7,2.94 L 22.4,26 V 36 H 26 V 23.04 L 21.5,19.7 26.14,15.04 Z M 10,24 C 4.48,24 0,28.48 0,34 0,39.52 4.48,44 10,44 15.52,44 20,39.52 20,34 20,28.48 15.52,24 10,24 Z m 0,17 c -3.87,0 -7,-3.13 -7,-7 0,-3.87 3.13,-7 7,-7 3.87,0 7,3.13 7,7 0,3.87 -3.13,7 -7,7 z"
id="path933" />
</g>
</g>
</g>
</g>
</svg>

After

Width:  |  Height:  |  Size: 4.4 KiB

19
src/components/About.vue Normal file
View File

@ -0,0 +1,19 @@
<template>
<v-container fluid>
<v-layout row>
<v-flex xs12>
<p>This app lets you track and share issues with bike lanes.</p>
<h2 class="body-2">The available reports so far are:</h2>
<ul class="ml-3">
<li><strong>GCUM</strong>: A car poorly parked on a bike lane.</li>
<li><strong>Interrupt</strong>: An interruption of the bike lane (works, unexpected end of the bike lane, etc.).</li>
<li><strong>Pothole</strong>: A pothole in the ground.</li>
</ul>
<p class="mt-3">It is released under an <a href="">MIT license</a>. The map background is using tiles from <a href="https://www.opencyclemap.org/docs/">OpenCycleMap</a>, thanks to <a href="">OpenStreetMap contributors</a> and <a href="">Leaflet</a>.</p>
</v-flex>
</v-layout>
</v-container>
</template>

70
src/components/Map.vue Normal file
View File

@ -0,0 +1,70 @@
<template>
<div class="fill-height fill-width">
<v-lmap :center="latlng" :zoom="this.zoom" :minZoom="this.minZoom" :maxZoom="this.maxZoom" :options="{ zoomControl: false }">
<v-ltilelayer :url="tileServer" :attribution="attribution"></v-ltilelayer>
<v-lts :lat-lng="latlng" :options="markerOptions"></v-lts>
</v-lmap>
</div>
</template>
<script>
import L from 'leaflet';
import iconRetinaUrl from 'leaflet/dist/images/marker-icon-2x.png';
import iconUrl from 'leaflet/dist/images/marker-icon.png';
import shadowUrl from 'leaflet/dist/images/marker-shadow.png';
// Fix for a bug in Leaflet default icon
// see https://github.com/PaulLeCam/react-leaflet/issues/255#issuecomment-261904061
delete L.Icon.Default.prototype._getIconUrl;
L.Icon.Default.mergeOptions({
iconRetinaUrl,
iconUrl,
shadowUrl,
});
export const DEFAULT_ZOOM = 17;
export const MIN_ZOOM = 15;
export const MAX_ZOOM = 18;
export const TILE_SERVER = 'http://a.tile.opencyclemap.org/cycle/{z}/{x}/{y}.png';
export default {
props: {
heading: Number,
lat: Number,
lng: Number,
},
computed: {
latlng() {
return [this.lat, this.lng];
},
markerOptions() {
return {
fillColor: '#00ff00',
heading: this.heading,
};
},
},
data() {
return {
attribution: 'Map data © <a href="http://openstreetmap.org">OpenStreetMap</a> contributors',
zoom: DEFAULT_ZOOM,
minZoom: MIN_ZOOM,
maxZoom: MAX_ZOOM,
tileServer: TILE_SERVER,
};
},
};
</script>
<style>
.application .leaflet-bar a {
color: black;
}
</style>
<style scoped>
.fill-width {
width: 100%;
}
</style>

View File

@ -0,0 +1,42 @@
<template>
<v-flex xs6 class="pa-2 pointer" @click.stop="handleClick">
<v-card flat>
<v-container fill-height fluid class="pa-0">
<v-layout fill-height>
<v-flex xs12 class="text-xs-center">
<img :src="imageSrc" class="icon"></img>
<p>{{ label }}</p>
</v-flex>
</v-layout>
</v-container>
</v-card>
</v-flex>
</template>
<script>
export default {
props: {
type: String,
label: String,
imageSrc: String,
save: Function,
},
methods: {
handleClick() {
return this.save(this.type);
},
},
};
</script>
<style scoped>
.icon {
max-width: 100%;
border: 2px solid #231f20;
border-radius: 10px;
}
.pointer {
cursor: pointer;
}
</style>

View File

@ -0,0 +1,76 @@
<template>
<v-bottom-sheet class="overlayDialog" v-model="isActive">
<v-card>
<v-container fluid>
<v-layout row wrap>
<ReportTile v-for="(item, type) in REPORT_TYPES" :type="type" :imageSrc="item.image" :label="$t(item.label)" :save="saveReport" :key="type"></ReportTile>
</v-layout>
</v-container>
</v-card>
</v-bottom-sheet>
</template>
<script>
import * as api from '@/api';
import GCUMIcon from '@/assets/gcum.svg';
import ObstacleIcon from '@/assets/obstacle.svg';
import PotHoleIcon from '@/assets/pothole.svg';
import ReportTile from './ReportTile.vue';
const REPORT_TYPES = {
gcum: {
label: 'reportLabels.gcum',
image: GCUMIcon,
},
interrupt: {
label: 'reportLabels.interrupt',
image: ObstacleIcon,
},
pothole: {
label: 'reportLabels.pothole',
image: PotHoleIcon,
},
};
export default {
components: {
ReportTile,
},
props: {
value: Boolean,
lat: Number,
lng: Number,
},
computed: {
isActive: {
get() {
return this.value;
},
set(val) {
this.$emit('input', val);
},
},
},
data() {
return {
REPORT_TYPES,
};
},
methods: {
saveReport(type) {
return api.saveReport(type, this.lat, this.lng)
.then(() => {
this.isActive = !this.isActive;
});
},
},
};
</script>
<style scoped>
.overlayDialog {
z-index: 1003 !important;
}
</style>

2
src/constants.js Normal file
View File

@ -0,0 +1,2 @@
export const MOCK_LOCATION = { lat: 48.866667, lng: 2.333333, heading: 20 * (Math.PI / 180) };
// export const MOCK_LOCATION = false;

15
src/i18n/en.js Normal file
View File

@ -0,0 +1,15 @@
// Keys should be sorted alphabetically
export default {
geolocation: {
enable: 'Please accept the geolocation permission request to use the app.',
unavailable: 'Sorry, geolocation is not available in your browser.',
},
menu: {
About: 'About',
},
reportLabels: {
gcum: 'GCUM',
interrupt: 'Interruption',
pothole: 'Pothole',
},
};

15
src/i18n/index.js Normal file
View File

@ -0,0 +1,15 @@
import Vue from 'vue';
import VueI18n from 'vue-i18n';
import en from './en';
Vue.use(VueI18n);
const messages = {
en,
};
export default new VueI18n({
locale: 'en',
messages,
});

33
src/main.js Normal file
View File

@ -0,0 +1,33 @@
// The Vue build version to load with the `import` command
// (runtime-only or standalone) has been set in webpack.base.conf with an alias.
import Vue from 'vue';
import Vuetify from 'vuetify';
import Vue2Leaflet from 'vue2-leaflet';
import Vue2LeafletTracksymbol from 'vue2-leaflet-tracksymbol';
import 'material-icons/iconfont/material-icons.css';
import 'roboto-fontface/css/roboto/roboto-fontface.css';
import 'leaflet/dist/leaflet.css';
import 'vuetify/dist/vuetify.min.css';
import App from './App.vue';
import router from './router';
import i18n from './i18n';
Vue.use(Vuetify);
Vue.component('v-lmap', Vue2Leaflet.LMap);
Vue.component('v-ltilelayer', Vue2Leaflet.LTileLayer);
Vue.component('v-lmarker', Vue2Leaflet.LMarker);
Vue.component('v-lpolyline', Vue2Leaflet.LPolyline);
Vue.component('v-lts', Vue2LeafletTracksymbol);
Vue.config.productionTip = false;
/* eslint-disable no-new */
new Vue({
el: '#app',
router,
i18n,
components: { App },
template: '<App/>',
});

21
src/router/index.js Normal file
View File

@ -0,0 +1,21 @@
import Vue from 'vue';
import Router from 'vue-router';
import About from '@/components/About.vue';
import Map from '@/views/Map.vue';
Vue.use(Router);
export default new Router({
routes: [
{
path: '/',
name: 'Map',
component: Map,
},
{
path: '/about',
name: 'About',
component: About,
},
],
});

115
src/views/Map.vue Normal file
View File

@ -0,0 +1,115 @@
<template>
<v-container fluid fill-height class="no-padding">
<v-layout row wrap fill-height>
<v-flex xs12 fill-height v-if="lat && lng">
<Map :lat="lat" :lng="lng" :heading="heading"></Map>
<v-btn
fixed
dark
fab
bottom
right
color="orange"
class="overlayButton"
@click.native.stop="dialog = !dialog"
>
<v-icon>report_problem</v-icon>
</v-btn>
<ReportDialog v-model="dialog" :lat="lat" :lng="lng"></ReportDialog>
</v-flex>
<v-flex xs12 fill-height v-else class="pa-3">
<p>{{ error }}</p>
<p class="text-xs-center">
<v-btn color="blue" dark @click="initializePositionWatching">Retry</v-btn>
</p>
</v-flex>
</v-layout>
</v-container>
</template>
<script>
import { MOCK_LOCATION } from '@/constants';
import Map from '@/components/Map.vue';
import ReportDialog from '@/components/ReportDialog/index.vue';
export default {
components: {
Map,
ReportDialog,
},
created() {
this.initializePositionWatching();
},
beforeDestroy() {
this.disablePositionWatching();
},
data() {
return {
dialog: false,
error: this.$t('geolocation.enable'),
heading: null,
lat: null,
lng: null,
watchID: null,
};
},
methods: {
initializePositionWatching() {
this.disablePositionWatching(); // Ensure at most one at the same time
if (!('geolocation' in navigator)) {
this.error = this.$t('geolocation.unavailable');
}
if (MOCK_LOCATION) {
this.lat = MOCK_LOCATION.lat;
this.lng = MOCK_LOCATION.lng;
this.heading = MOCK_LOCATION.heading;
} else {
this.watchID = navigator.geolocation.watchPosition(
this.setPosition,
this.handlePositionError,
{
enableHighAccuracy: true,
maximumAge: 30000,
timeout: 27000,
},
);
}
},
disablePositionWatching() {
if (this.watchID !== null) {
navigator.geolocation.clearWatch(this.watchID);
}
},
handlePositionError(error) {
this.error = `Error ${error.code}: ${error.message}`;
},
setPosition(position) {
this.lat = position.coords.latitude;
this.lng = position.coords.longitude;
if (position.coords.heading) {
this.heading = position.coords.heading;
} else {
this.heading = null;
}
},
},
};
</script>
<style scoped>
.no-padding {
padding: 0;
}
.overlayButton {
z-index: 1000 !important;
}
</style>
<style>
.overlay {
z-index: 1002 !important;
}
</style>

0
static/.gitkeep Normal file
View File

6270
yarn.lock Normal file

File diff suppressed because it is too large Load Diff