Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

restructure, packaging, doc updates

  • Loading branch information...
commit 0cb0f57c91bdacd17b4072af2160d8e58f3991cc 1 parent 8331813
Marc Harter wavded authored
33 Makefile
... ... @@ -1,17 +1,34 @@
1   -.PHONY: watch tmux tmux_setup deploy_live
2 1 project=wheredat
3   -path=/var/www/wheredat
4   -instance=\033[32;01m${project}\033[m
  2 +instance=\033[36;01m${project}\033[m
5 3
6 4 watch:
7   - @always app.js
  5 + @if ! which supervisor > /dev/null; then echo "supervisor required, installing..."; sudo npm install -g supervisor; fi
  6 + @supervisor -e html,js,css -n exit server.js
8 7
9   -deploy_live: serverA = sawyer@172.25.20.111
  8 +tmux_setup:
  9 + @tmux new-session -s ${project} -d -n workspace
  10 + @tmux split-window -t ${project} -h
  11 + @tmux split-window -t ${project} -v
  12 + @tmux select-pane -t ${project}:1.0
  13 + @tmux select-pane -t ${project}:1.1
  14 + @tmux resize-pane -t ${project} -D 2
  15 + @tmux select-layout -t ${project} main-vertical
  16 + @tmux send-keys -t ${project}:1.0 'vim' C-m
  17 + @tmux send-keys -t ${project}:1.2 'make' C-m
  18 + @tmux select-pane -t ${project}:1.0
  19 + @tmux resize-pane -t ${project} -R 40
  20 +
  21 +tmux:
  22 + @if ! tmux has-session -t ${project}; then exec make tmux_setup; fi
  23 + @tmux attach -t ${project}
  24 +
  25 +# sample deployment script (assumes upstart as daemon)
  26 +deploy_live: serverA = sawyer@172.25.20.120
10 27 deploy_live: serverB = sawyer@172.25.20.120
11 28 deploy_live:
12   - @rsync -az --exclude=".git" --delete * ${serverA}:${path}
13   - @rsync -az --exclude=".git" --delete * ${serverB}:${path}
14   - @echo -e " ${instance} | copied files to ${serverA} and ${serverB}"
  29 + @ssh ${serverA} "sudo npm install -g ${project}"
  30 + @ssh ${serverB} "sudo npm install -g ${project}"
  31 + @echo -e " ${instance} | updated ${project} on ${serverA} and ${serverB}"
15 32 @ssh ${serverA} "sudo restart ${project}"
16 33 @ssh ${serverB} "sudo restart ${project}"
17 34 @echo -e " ${instance} | restarting app on ${serverA} and ${serverB}"
44 app.js
... ... @@ -1,44 +0,0 @@
1   -"use strict"
2   -var http = require('http')
3   -var fs = require('fs')
4   -
5   -process.chdir(__dirname)
6   -
7   -function makeIndex() {
8   - var index = fs.readFileSync('index.html').toString()
9   - .replace("<link href='lib.css' rel='stylesheet'>", '<style>' + fs.readFileSync('lib.css').toString() + '</style>')
10   - .replace("<script src='lib.js'></script>", '<script>' + fs.readFileSync('lib.js').toString() + '</script>')
11   - .replace("<script src='wheredat.js'></script>", '<script>' + fs.readFileSync('wheredat.js').toString() + '</script>')
12   - return new Buffer(index)
13   -}
14   -
15   -var index = makeIndex()
16   -var example = fs.readFileSync('example.html')
17   -
18   -var icons = {
19   - '/img/marker.png': fs.readFileSync('img/marker.png'),
20   - '/img/marker-shadow.png': fs.readFileSync('img/marker-shadow.png'),
21   - '/img/popup-close.png': fs.readFileSync('img/popup-close.png'),
22   - '/img/zoom-in.png': fs.readFileSync('img/zoom-in.png'),
23   - '/img/zoom-out.png': fs.readFileSync('img/zoom-out.png')
24   -}
25   -
26   -var iecss = fs.readFileSync('lib-ie.css')
27   -
28   -http.createServer(function (req, res) {
29   - if (req.url.match(/img/)) {
30   - res.writeHead(200, { 'Content-Type': 'image/png' })
31   - res.end(icons[req.url])
32   - }
33   - else if (req.url === '/lib-ie.css') {
34   - res.writeHead(200, { 'Content-Type': 'text/css' })
35   - res.end(iecss)
36   - }
37   - else {
38   - res.writeHead(200, { 'Content-Type': 'text/html' })
39   - if (req.url === '/example.html')
40   - res.end(example)
41   - else
42   - res.end(index)
43   - }
44   -}).listen(8002)
6 index.html
... ... @@ -1,8 +1,8 @@
1 1 <!doctype html>
2 2 <title>... wheredat ...</title>
3 3 <meta http-equiv='X-UA-Compatible' content='IE=Edge,chrome=1'/>
4   -<link href='lib.css' rel='stylesheet'>
5   -<!--[if lte IE 8]><link rel="stylesheet" href="lib-ie.css" /><![endif]-->
  4 +<link href='leaflet/leaflet.css' rel='stylesheet'>
  5 +<!--[if lte IE 8]><link rel="stylesheet" href="leaflet/leaflet-ie.css" /><![endif]-->
6 6 <style>
7 7 html, body { padding: 0; margin: 0; overflow: hidden }
8 8 html, body, #map { width: 100%; height: 100% }
@@ -23,5 +23,5 @@
23 23 }
24 24 </style>
25 25 <div id="map"></div><div id="address"></div>
26   -<script src='lib.js'></script>
  26 +<script src='leaflet/leaflet.js'></script>
27 27 <script src='wheredat.js'></script>
0  img/marker-shadow.png → leaflet/img/marker-shadow.png
File renamed without changes
0  img/marker.png → leaflet/img/marker.png
File renamed without changes
0  img/popup-close.png → leaflet/img/popup-close.png
File renamed without changes
0  img/zoom-in.png → leaflet/img/zoom-in.png
File renamed without changes
0  img/zoom-out.png → leaflet/img/zoom-out.png
File renamed without changes
0  lib-ie.css → leaflet/leaflet-ie.css
File renamed without changes
2  leaflet/leaflet.css
... ... @@ -0,0 +1,2 @@
  1 +/* Leaflet */
  2 +.leaflet-map-pane, .leaflet-tile, .leaflet-marker-icon, .leaflet-marker-shadow, .leaflet-tile-pane, .leaflet-overlay-pane, .leaflet-shadow-pane, .leaflet-marker-pane, .leaflet-popup-pane, .leaflet-overlay-pane svg, .leaflet-zoom-box, .leaflet-image-layer { position: absolute; } .leaflet-container { overflow: hidden; } .leaflet-tile-pane { -webkit-transform: translate3d(0,0,0); } .leaflet-tile, .leaflet-marker-icon, .leaflet-marker-shadow { -moz-user-select: none; -webkit-user-select: none; user-select: none; } .leaflet-marker-icon, .leaflet-marker-shadow { display: block; } .leaflet-clickable { cursor: pointer; } .leaflet-container img { max-width: auto; } .leaflet-tile-pane { z-index: 2; } .leaflet-overlay-pane { z-index: 3; } .leaflet-shadow-pane { z-index: 4; } .leaflet-marker-pane { z-index: 5; } .leaflet-popup-pane { z-index: 6; } .leaflet-zoom-box { width: 0; height: 0; } .leaflet-tile { visibility: hidden; } .leaflet-tile-loaded { visibility: inherit; } a.leaflet-active { outline: 2px solid orange; } .leaflet-control { position: relative; z-index: 7; } .leaflet-top, .leaflet-bottom { position: absolute; } .leaflet-top { top: 0; } .leaflet-right { right: 0; } .leaflet-bottom { bottom: 0; } .leaflet-left { left: 0; } .leaflet-control { float: left; clear: both; } .leaflet-right .leaflet-control { float: right; } .leaflet-top .leaflet-control { margin-top: 10px; } .leaflet-bottom .leaflet-control { margin-bottom: 10px; } .leaflet-left .leaflet-control { margin-left: 10px; } .leaflet-right .leaflet-control { margin-right: 10px; } .leaflet-control-zoom { padding: 5px; background: rgba(0, 0, 0, 0.25); -moz-border-radius: 7px; -webkit-border-radius: 7px; border-radius: 7px; } .leaflet-control-zoom a { display: block; width: 19px; height: 19px; background-position: 50% 50%; background-repeat: no-repeat; background-color: rgba(255, 255, 255, 0.75); -moz-border-radius: 4px; -webkit-border-radius: 4px; border-radius: 4px; } .leaflet-control-zoom a:hover { background-color: #fff; } .leaflet-big-buttons .leaflet-control-zoom a { width: 27px; height: 27px; } .leaflet-control-zoom-in { background-image: url(img/zoom-in.png); margin-bottom: 5px; } .leaflet-control-zoom-out { background-image: url(img/zoom-out.png); } .leaflet-container .leaflet-control-attribution { margin: 0; padding: 0 5px; font: 11px/1.5 "Helvetica Neue", Arial, Helvetica, sans-serif; color: #333; background-color: rgba(255, 255, 255, 0.7); -moz-box-shadow: 0 0 7px #ccc; -webkit-box-shadow: 0 0 7px #ccc; box-shadow: 0 0 7px #ccc; } .leaflet-fade-anim .leaflet-tile { opacity: 0; -webkit-transition: opacity 0.2s linear; -moz-transition: opacity 0.2s linear; -o-transition: opacity 0.2s linear; transition: opacity 0.2s linear; } .leaflet-fade-anim .leaflet-tile-loaded { opacity: 1; } .leaflet-fade-anim .leaflet-popup { opacity: 0; -webkit-transition: opacity 0.2s linear; -moz-transition: opacity 0.2s linear; -o-transition: opacity 0.2s linear; transition: opacity 0.2s linear; } .leaflet-fade-anim .leaflet-map-pane .leaflet-popup { opacity: 1; } .leaflet-zoom-anim .leaflet-tile { -webkit-transition: none; -moz-transition: none; -o-transition: none; transition: none; } .leaflet-zoom-anim .leaflet-objects-pane { visibility: hidden; } .leaflet-popup { position: absolute; text-align: center; -webkit-transform: translate3d(0,0,0); } .leaflet-popup-content-wrapper { padding: 1px; text-align: left; } .leaflet-popup-content { margin: 19px; } .leaflet-popup-tip-container { margin: 0 auto; width: 40px; height: 16px; position: relative; overflow: hidden; } .leaflet-popup-tip { width: 15px; height: 15px; padding: 1px; margin: -8px auto 0; -moz-transform: rotate(45deg); -webkit-transform: rotate(45deg); -ms-transform: rotate(45deg); -o-transform: rotate(45deg); transform: rotate(45deg); } .leaflet-popup-close-button { position: absolute; top: 9px; right: 9px; width: 10px; height: 10px; overflow: hidden; } .leaflet-popup-content p { margin: 18px 0; } /* Visual appearance */ .leaflet-container { background: #ddd; } .leaflet-container a { color: #0078A8; } .leaflet-zoom-box { border: 2px dotted #05f; background: white; opacity: 0.5; } .leaflet-popup-content-wrapper, .leaflet-popup-tip { background: white; box-shadow: 0 1px 10px #888; -moz-box-shadow: 0 1px 10px #888; -webkit-box-shadow: 0 1px 14px #999; } .leaflet-popup-content-wrapper { -moz-border-radius: 20px; -webkit-border-radius: 20px; border-radius: 20px; } .leaflet-popup-content { font: 12px/1.4 "Helvetica Neue", Arial, Helvetica, sans-serif; } .leaflet-popup-close-button { background: white url(img/popup-close.png); }
0  lib.js → leaflet/leaflet.js
File renamed without changes
2  lib.css
... ... @@ -1,2 +0,0 @@
1   -/* Leaflet */
2   -.leaflet-map-pane, .leaflet-tile, .leaflet-marker-icon, .leaflet-marker-shadow, .leaflet-tile-pane, .leaflet-overlay-pane, .leaflet-shadow-pane, .leaflet-marker-pane, .leaflet-popup-pane, .leaflet-overlay-pane svg, .leaflet-zoom-box, .leaflet-image-layer { position: absolute; } .leaflet-container { overflow: hidden; } .leaflet-tile-pane { -webkit-transform: translate3d(0,0,0); } .leaflet-tile, .leaflet-marker-icon, .leaflet-marker-shadow { -moz-user-select: none; -webkit-user-select: none; user-select: none; } .leaflet-marker-icon, .leaflet-marker-shadow { display: block; } .leaflet-clickable { cursor: pointer; } .leaflet-container img { max-width: auto; } .leaflet-tile-pane { z-index: 2; } .leaflet-overlay-pane { z-index: 3; } .leaflet-shadow-pane { z-index: 4; } .leaflet-marker-pane { z-index: 5; } .leaflet-popup-pane { z-index: 6; } .leaflet-zoom-box { width: 0; height: 0; } .leaflet-tile { visibility: hidden; } .leaflet-tile-loaded { visibility: inherit; } a.leaflet-active { outline: 2px solid orange; } .leaflet-control { position: relative; z-index: 7; } .leaflet-top, .leaflet-bottom { position: absolute; } .leaflet-top { top: 0; } .leaflet-right { right: 0; } .leaflet-bottom { bottom: 0; } .leaflet-left { left: 0; } .leaflet-control { float: left; clear: both; } .leaflet-right .leaflet-control { float: right; } .leaflet-top .leaflet-control { margin-top: 10px; } .leaflet-bottom .leaflet-control { margin-bottom: 10px; } .leaflet-left .leaflet-control { margin-left: 10px; } .leaflet-right .leaflet-control { margin-right: 10px; } .leaflet-control-zoom { padding: 5px; background: rgba(0, 0, 0, 0.25); -moz-border-radius: 7px; -webkit-border-radius: 7px; border-radius: 7px; } .leaflet-control-zoom a { display: block; width: 19px; height: 19px; background-position: 50% 50%; background-repeat: no-repeat; background-color: rgba(255, 255, 255, 0.75); -moz-border-radius: 4px; -webkit-border-radius: 4px; border-radius: 4px; } .leaflet-control-zoom a:hover { background-color: #fff; } .leaflet-big-buttons .leaflet-control-zoom a { width: 27px; height: 27px; } .leaflet-control-zoom-in { background-image: url(/img/zoom-in.png); margin-bottom: 5px; } .leaflet-control-zoom-out { background-image: url(/img/zoom-out.png); } .leaflet-container .leaflet-control-attribution { margin: 0; padding: 0 5px; font: 11px/1.5 "Helvetica Neue", Arial, Helvetica, sans-serif; color: #333; background-color: rgba(255, 255, 255, 0.7); -moz-box-shadow: 0 0 7px #ccc; -webkit-box-shadow: 0 0 7px #ccc; box-shadow: 0 0 7px #ccc; } .leaflet-fade-anim .leaflet-tile { opacity: 0; -webkit-transition: opacity 0.2s linear; -moz-transition: opacity 0.2s linear; -o-transition: opacity 0.2s linear; transition: opacity 0.2s linear; } .leaflet-fade-anim .leaflet-tile-loaded { opacity: 1; } .leaflet-fade-anim .leaflet-popup { opacity: 0; -webkit-transition: opacity 0.2s linear; -moz-transition: opacity 0.2s linear; -o-transition: opacity 0.2s linear; transition: opacity 0.2s linear; } .leaflet-fade-anim .leaflet-map-pane .leaflet-popup { opacity: 1; } .leaflet-zoom-anim .leaflet-tile { -webkit-transition: none; -moz-transition: none; -o-transition: none; transition: none; } .leaflet-zoom-anim .leaflet-objects-pane { visibility: hidden; } .leaflet-popup { position: absolute; text-align: center; -webkit-transform: translate3d(0,0,0); } .leaflet-popup-content-wrapper { padding: 1px; text-align: left; } .leaflet-popup-content { margin: 19px; } .leaflet-popup-tip-container { margin: 0 auto; width: 40px; height: 16px; position: relative; overflow: hidden; } .leaflet-popup-tip { width: 15px; height: 15px; padding: 1px; margin: -8px auto 0; -moz-transform: rotate(45deg); -webkit-transform: rotate(45deg); -ms-transform: rotate(45deg); -o-transform: rotate(45deg); transform: rotate(45deg); } .leaflet-popup-close-button { position: absolute; top: 9px; right: 9px; width: 10px; height: 10px; overflow: hidden; } .leaflet-popup-content p { margin: 18px 0; } /* Visual appearance */ .leaflet-container { background: #ddd; } .leaflet-container a { color: #0078A8; } .leaflet-zoom-box { border: 2px dotted #05f; background: white; opacity: 0.5; } .leaflet-popup-content-wrapper, .leaflet-popup-tip { background: white; box-shadow: 0 1px 10px #888; -moz-box-shadow: 0 1px 10px #888; -webkit-box-shadow: 0 1px 14px #999; } .leaflet-popup-content-wrapper { -moz-border-radius: 20px; -webkit-border-radius: 20px; border-radius: 20px; } .leaflet-popup-content { font: 12px/1.4 "Helvetica Neue", Arial, Helvetica, sans-serif; } .leaflet-popup-close-button { background: white url(/img/popup-close.png); }
15 package.json
... ... @@ -0,0 +1,15 @@
  1 +{
  2 + "author": "Marc Harter <wavded@gmail.com> (wavded.com)",
  3 + "name": "wheredat",
  4 + "description": "A simple, easy to use, geocoding interface for web applications",
  5 + "keywords": ["leaflet","geocode","bing","widget"],
  6 + "version": "0.2.1",
  7 + "homepage": "http://wheredat.adc4gis.com",
  8 + "bin": { "wheredat": "server.js" },
  9 + "repository": {
  10 + "type": "git",
  11 + "url": "git://github.com/applieddataconsultants/wheredat.git"
  12 + },
  13 + "main": "server.js",
  14 + "engines": { "node": "*" }
  15 +}
15 readme.md
Source Rendered
@@ -18,8 +18,11 @@ Another one of its goals is to be extremely light weight and quick to load.
18 18
19 19 Built to be served with [node.js](http://nodejs.org/) although you can serve the files up statically as well.
20 20
21   -```
22   -node app.js
  21 +For node do:
  22 +
  23 +```sh
  24 +sudo npm install -g wheredat
  25 +wheredat [port]
23 26 ```
24 27
25 28 ### Request Params
@@ -56,6 +59,14 @@ The data returned will look like:
56 59 }
57 60 ```
58 61
  62 +Or if unable to geocode:
  63 +
  64 +```json
  65 +{
  66 + error: 'wheredat was unable to geocode'
  67 +}
  68 +```
  69 +
59 70 This data will return whenever a geocode or reverse geocode happens (e.g.
60 71 whenever the point is moved or when the map is initially loaded).
61 72
46 server.js
... ... @@ -0,0 +1,46 @@
  1 +#!/usr/bin/env node
  2 +
  3 +const http = require('http')
  4 +const fs = require('fs')
  5 +const port = process.argv[2] || 8002
  6 +
  7 +process.chdir(__dirname)
  8 +
  9 +function makeIndex() {
  10 + var index = fs.readFileSync('index.html').toString()
  11 + .replace("<link href='leaflet/leaflet.css' rel='stylesheet'>", '<style>' + fs.readFileSync('./leaflet/leaflet.css').toString() + '</style>')
  12 + .replace("<script src='leaflet/leaflet.js'></script>", '<script>' + fs.readFileSync('./leaflet/leaflet.js').toString() + '</script>')
  13 + .replace("<script src='wheredat.js'></script>", '<script>' + fs.readFileSync('wheredat.js').toString() + '</script>')
  14 + return new Buffer(index)
  15 +}
  16 +
  17 +var index = makeIndex()
  18 +var example = fs.readFileSync('example.html')
  19 +
  20 +var icons = {
  21 + '/img/marker.png': fs.readFileSync('./leaflet/img/marker.png'),
  22 + '/img/marker-shadow.png': fs.readFileSync('./leaflet/img/marker-shadow.png'),
  23 + '/img/popup-close.png': fs.readFileSync('./leaflet/img/popup-close.png'),
  24 + '/img/zoom-in.png': fs.readFileSync('./leaflet/img/zoom-in.png'),
  25 + '/img/zoom-out.png': fs.readFileSync('./leaflet/img/zoom-out.png')
  26 +}
  27 +
  28 +var iecss = fs.readFileSync('./leaflet/leaflet-ie.css')
  29 +
  30 +http.createServer(function (req, res) {
  31 + if (req.url.match(/img/)) {
  32 + res.writeHead(200, { 'Content-Type': 'image/png' })
  33 + res.end(icons[req.url])
  34 + }
  35 + else if (req.url === '/leaflet/leaflet-ie.css') {
  36 + res.writeHead(200, { 'Content-Type': 'text/css' })
  37 + res.end(iecss)
  38 + }
  39 + else {
  40 + res.writeHead(200, { 'Content-Type': 'text/html' })
  41 + if (req.url === '/example.html')
  42 + res.end(example)
  43 + else
  44 + res.end(index)
  45 + }
  46 +}).listen(port)

0 comments on commit 0cb0f57

Please sign in to comment.
Something went wrong with that request. Please try again.