diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..52167bd --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +build/farmOS-map.js diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..4d83fdc --- /dev/null +++ b/Dockerfile @@ -0,0 +1,12 @@ +# Inherit from the official node.js image. +FROM node + +# Set the working directory to /usr/src/app. +WORKDIR /usr/src/app + +# Install dependencies. +COPY package.json package.json +RUN npm install + +# Copy source files needed for running npm build. +COPY src/ . diff --git a/README.md b/README.md new file mode 100644 index 0000000..16f62f8 --- /dev/null +++ b/README.md @@ -0,0 +1,25 @@ +# farmOS Map + +[![Licence](https://img.shields.io/badge/Licence-GPL%203.0-blue.svg)](https://opensource.org/licenses/GPL-3.0/) +[![Release](https://img.shields.io/github/release/farmOS/farmOS-map.svg?style=flat)](https://github.com/farmOS/farmOS-map/releases) +[![Last commit](https://img.shields.io/github/last-commit/farmOS/farmOS-map.svg?style=flat)](https://github.com/farmOS/farmOS-map/commits) +[![Twitter](https://img.shields.io/twitter/follow/farmOSorg.svg?label=%40farmOSorg&style=flat)](https://twitter.com/farmOSorg) +[![Chat](https://img.shields.io/matrix/farmOS:matrix.org.svg)](https://riot.im/app/#/room/#farmOS:matrix.org) + +farmOS Map is an [OpenLayers](https://openlayers.org/) map for farmOS. + +For more information on farmOS, visit [farmOS.org](https://farmOS.org). + +## Setup + +1. Clone the repository. +2. Run `./build.sh` +3. Open `build/index.html` in a browser. + +## Maintainers + + * Michael Stenta (m.stenta) - https://github.com/mstenta + +This project has been sponsored by: + + * [Farmier](https://farmier.com) diff --git a/build.sh b/build.sh new file mode 100755 index 0000000..a5d46ff --- /dev/null +++ b/build.sh @@ -0,0 +1,10 @@ +#!/bin/bash + +# Touch build/farmOS-map.js to ensure that it is owned by this user. +touch build/farmOS-map.js + +# Build the farmos-map Docker image. +sudo docker build -t farmos-map . + +# Build farmOS-map.js with NPM. +sudo docker run -it --rm -v "$PWD/build":/usr/src/app/build farmos-map npm run build diff --git a/build/index.html b/build/index.html new file mode 100644 index 0000000..6352938 --- /dev/null +++ b/build/index.html @@ -0,0 +1,24 @@ + + + + + farmOS Map + + + + +
+ + + diff --git a/package.json b/package.json new file mode 100644 index 0000000..da05fda --- /dev/null +++ b/package.json @@ -0,0 +1,15 @@ +{ + "name": "farmOS-map", + "version": "0.0.1", + "description": "OpenLayers map used in farmOS.", + "scripts": { + "build": "webpack --config webpack.config.js --mode production" + }, + "devDependencies": { + "webpack": "^4.29.6", + "webpack-command": "^0.3.0" + }, + "dependencies": { + "ol": "^5.3.0" + } +} diff --git a/src/main.js b/src/main.js new file mode 100644 index 0000000..f3f5127 --- /dev/null +++ b/src/main.js @@ -0,0 +1,18 @@ +import { Map, View } from 'ol'; +import TileLayer from 'ol/layer/Tile'; +import XYZ from 'ol/source/XYZ'; + +new Map({ + target: 'map', + layers: [ + new TileLayer({ + source: new XYZ({ + url: 'https://{a-c}.tile.openstreetmap.org/{z}/{x}/{y}.png', + }), + }), + ], + view: new View({ + center: [0, 0], + zoom: 2, + }), +}); diff --git a/src/webpack.config.js b/src/webpack.config.js new file mode 100644 index 0000000..d2c1824 --- /dev/null +++ b/src/webpack.config.js @@ -0,0 +1,9 @@ +const webpack = require('webpack'); + +module.exports = { + entry: './main.js', + output: { + path: __dirname + '/build', + filename: 'farmOS-map.js' + }, +};