Skip to content

Commit

Permalink
Initial commit.
Browse files Browse the repository at this point in the history
  • Loading branch information
mstenta committed Jul 11, 2019
0 parents commit 14bf276
Show file tree
Hide file tree
Showing 8 changed files with 114 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
build/farmOS-map.js
12 changes: 12 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -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/ .
25 changes: 25 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -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)
10 changes: 10 additions & 0 deletions build.sh
Original file line number Diff line number Diff line change
@@ -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
24 changes: 24 additions & 0 deletions build/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>farmOS Map</title>
<link rel="stylesheet" href="https://openlayers.org/en/latest/css/ol.css" type="text/css">
<style>
html, body {
margin: 0;
height: 100%;
}
#map {
position: absolute;
top: 0;
bottom: 0;
width: 100%;
}
</style>
</head>
<body>
<div id="map"></div>
<script src="./farmOS-map.js"></script>
</body>
</html>
15 changes: 15 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -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"
}
}
18 changes: 18 additions & 0 deletions src/main.js
Original file line number Diff line number Diff line change
@@ -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,
}),
});
9 changes: 9 additions & 0 deletions src/webpack.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
const webpack = require('webpack');

module.exports = {
entry: './main.js',
output: {
path: __dirname + '/build',
filename: 'farmOS-map.js'
},
};

0 comments on commit 14bf276

Please sign in to comment.