Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rework and using opening_hours build with rollup #44

Merged
merged 9 commits into from
Mar 19, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
---

install:
- 'sudo apt-get update -qq'
- 'sudo apt-get install -qq oracle-java8-installer'
- 'sudo update-java-alternatives -s java-8-oracle'
- 'sudo pip install html5validator'

script:
- "make check"
8 changes: 8 additions & 0 deletions .yamllint
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---

extends: default

rules:
line-length:
max: 1000
level: warning
18 changes: 15 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
@@ -8,6 +8,13 @@ list:
@$(MAKE) -pRrq -f $(lastword $(MAKEFILE_LIST)) : 2>/dev/null | awk -v RS= -F: '/^# File/,/^# Finished Make data base/ {if ($$1 !~ "^[#.]") {print $$1}}' | sort | egrep -v -e '^[^[:alnum:]]' -e '^$@$$' | sed 's/^/ /'
## }}}

.PHONY: check
check: check-html

.PHONY: check-html
check-html:
html5validator --root . --blacklist js opening_hours.js --ignore-re 'Start tag seen without seeing a doctype first'

## Make this project ready to be served by a webserver.
.PHONY: ready-for-hosting
ready-for-hosting: dependencies-get
@@ -18,11 +25,12 @@ opening_hours+deps.min.js:
$(MAKE) --directory opening_hours.js/ opening_hours+deps.min.js

taginfo.json: ./opening_hours.js/gen_taginfo_json.js ./opening_hours.js/related_tags.txt taginfo_template.json
$< --key-file ./opening_hours.js/related_tags.txt --template-file taginfo_template.json > "$@"
opening_hours_map --key-file ./opening_hours.js/related_tags.txt --template-file taginfo_template.json > "$@"

.PHONY: dependencies-get
dependencies-get: js/OpenLayers-$(OpenLayersVersion)/OpenLayers.js
git submodule update --init --recursive
git submodule update --init
cd opening_hours.js/ && git verify-commit HEAD && git submodule update --init --recursive

js/OpenLayers-$(OpenLayersVersion)/OpenLayers.js:
-wget --no-clobber -O js/OpenLayers-$(OpenLayersVersion).tar.gz https://github.com/openlayers/openlayers/releases/download/release-$(OpenLayersVersion)/OpenLayers-$(OpenLayersVersion).tar.gz
@@ -35,6 +43,10 @@ deploy-on-all-servers: deploy-on-openingh.openstreetmap.de deploy-on-ypid.de
deploy-on-openingh.openstreetmap.de: opening_hours+deps.min.js
rsync --archive * gauss.osm.de:~/www -v

## Custom deployment method which allows me to fully isolate the development and build environment from the server.
.PHONY: deploy-on-openingh.openstreetmap.de
deploy-on-ypid.de: opening_hours+deps.min.js
rsync --archive * [email protected]:/srv/www/osm/sites/openingh.ypid.de/public -v
rm -rf "/tmp/opening_hours_map"
mkdir --parents "/tmp/opening_hours_map"
/bin/tar --exclude-vcs --exclude='./js/*.tar.gz' --exclude='./js/OpenLayers-$(OpenLayersVersion)/doc' --exclude='./opening_hours.js/node_modules/bower' --exclude='./opening_hours.js/submodules/panieravide.github.io/id-indoor' --exclude='./opening_hours.js/submodules/panieravide.github.io/pic4carto' --no-acls -czf - . | /bin/tar -xz --directory "/tmp/opening_hours_map" -f -
qvm-copy-to-vm s-cm "/tmp/opening_hours_map"
2 changes: 1 addition & 1 deletion docs/deployment.rst
Original file line number Diff line number Diff line change
@@ -23,7 +23,7 @@ The following Webserver configuration is currently deployed:
name: [ 'openingh.ypid.de', 'openingh.openstreetmap.de' ]
owner: 'osm'
csp: True
csp_policy: "default-src 'none'; script-src 'self' 'unsafe-inline'; connect-src https://overpass-api.de https://nominatim.openstreetmap.org https://localhost:8111; img-src 'self' data: https://*.tile.openstreetmap.org https://*.tile.opencyclemap.org; style-src 'self' 'unsafe-inline'"
csp_policy: "default-src 'none'; script-src 'self' 'unsafe-inline' https://code.jquery.com; connect-src https://overpass-api.de https://nominatim.openstreetmap.org https://localhost:8111; img-src 'self' data: https://*.tile.openstreetmap.org https://*.tile.opencyclemap.org; style-src 'self' 'unsafe-inline'"
location_list:
- pattern: '/stats'
options: 'return 307 http://openingh.openstreetmap.de$request_uri;'
25 changes: 15 additions & 10 deletions index.html
Original file line number Diff line number Diff line change
@@ -1,25 +1,31 @@
<html>
<head><!-- {{{ -->
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<meta name="referrer" content="no-referrer">
<meta name="referrer" content="no-referrer" />
<title>Map with layer for the tag opening_hours based on OpenStreetMap</title>
<link rel="icon" type="image/png" href="img/favicon.png">
<link rel="icon" type="image/png" href="img/favicon.png" />
<meta name="description" content="Auswertung des Tags opening_hours auf einer Karte von OpenStreetMap" />
<script type="text/javascript" src="js/OpenLayers-2.13.1/OpenLayers.js"></script>
<script type="text/javascript" src="js/OpenStreetMap.js"></script>
<script type="text/javascript" src="js/popupmarker.js"></script>
<script type="text/javascript" src="js/loadstatus.js"></script>
<script type="text/javascript" src="js/zoomstatus.js"></script>
<script src="https://code.jquery.com/jquery-2.2.4.min.js" integrity="sha384-rY/jv8mMhqDabXSo+UCggqKtdmBfd3qC2/KvyTDNQ6PcUJXaxK1tMepoQda4g5vB" crossorigin="anonymous"></script>
<script type="text/javascript" src="opening_hours.js/opening_hours+deps.min.js"></script>
<script type="text/javascript" src="opening_hours.js/bower_components/jquery/dist/jquery.min.js"></script>
<script type="text/javascript" src="opening_hours.js/js/countryToLanguageMapping.js"></script>
<script type="text/javascript" src="opening_hours.js/js/helpers.js"></script>
<script type="text/javascript" src="js/main.js"></script>
<script type="text/javascript" src="opening_hours.js/node_modules/i18next-client/i18next.min.js"></script>
<script type="text/javascript" src="opening_hours.js/node_modules/moment/min/moment-with-locales.min.js"></script>
<script type="text/javascript" src="opening_hours.js/js/i18n-resources.js"></script>
<script type="text/javascript" src="opening_hours.js/js/opening_hours_table.js"></script>
<script type="text/javascript" src="opening_hours.js/js/helpers.js"></script>
<script type="text/javascript" src="opening_hours.js/js/countryToLanguageMapping.js"></script>
<script type="text/javascript" src="js/main.js"></script>
<link rel="stylesheet" href="opening_hours.js/css/table.css"/>
<link rel="stylesheet" href="css/default.css"/>
<script type="text/javascript">
if (document.title !== i18n.t('texts.heading map')) {
document.title = i18n.t('texts.heading map');
}
</script>
</head> <!-- }}} -->
<body><!-- {{{ -->
<noscript>You don‘t have JavaScript enabled and that is a good thing but this tool makes heavy use of JavaScript so you need to enable it in order to use this tool. If you don’t trust the code that is going to be executed that is good as well. I encourage you to read all the source code on <a href="https://github.com/opening-hours/opening_hours.js">Github</a>. Also note that every commit and all releases are GPG signed. You might want to check this out as well :) Stay safe.</noscript>
@@ -28,7 +34,6 @@

<script type="text/javascript">
document.write('<h1>' + i18n.t('texts.heading map') + '</h1>');
document.title = i18n.t('texts.heading map');
document.write(getUserSelectTranslateHTMLCode());

function submitenter(myfield,e) {
@@ -57,9 +62,8 @@
<script type="text/javascript">
document.write('<strong>' + i18n.t('texts.config POIs') + '</strong>:');
</script>
<select id="tag_selector_input" name="tag_selector_input">
</select>
<form id="userKey" action="">
<select id="tag_selector_input" name="tag_selector_input"></select>
<form id="userKey" action="#">
<input id="key" style="width:20%" name="key" onKeyPress="return submitenter(this,event)" />
</form>
<script type="text/javascript">
@@ -70,6 +74,7 @@
</script>
</div>

<p>
<script type="text/javascript">
document.write(i18n.t('texts.map is showing', { wikiUrl: wiki_url }));
document.write('<ul>');
93 changes: 44 additions & 49 deletions js/main.js
Original file line number Diff line number Diff line change
@@ -2,26 +2,28 @@ var repo_url = 'https://github.com/opening-hours/opening_hours_map';
var html_url = 'http://openingh.openstreetmap.de/';
var wiki_url = 'https://wiki.openstreetmap.org/wiki/Key:opening_hours';
var evaluation_tool_url = 'evaluation_tool/';
var map;

var nominatim_data_global = {};

var opening_hours = require('opening_hours');
/* Does not accept language change in Browser. Probably not the
* correct version as it was bundled for NodeJS.
*/
// var moment = require('moment');
var i18n = require('i18next-client');
/* Source ../opening_hours.js/related_tags.txt */
var related_tags = [
'opening_hours',
'opening_hours:kitchen',
'opening_hours:warm_kitchen',
'happy_hours',
'delivery_hours',
'opening_hours:delivery',
'lit',
'smoking_hours',
'collection_times',
'service_times',
//
// 'fee',
];

if (!document.onLoadFunctions) {
document.onLoadFunctions = new Array();
window.onload = function () { for (var i=0; document.onLoadFunctions.length>i;i++) document.onLoadFunctions[i](); }
}

var poi_layer;

var permalinkParams = {};
var permalinkObject;

function Evaluate(number, reset, value) {
window.open(evaluation_tool_url + '?EXP='+encodeURIComponent(value), '_blank');
@@ -43,34 +45,24 @@ function editPopupContent(content, lat, lon, type, id, oh_value) {
return content;
}

var tmp = 0;
/* Source ../opening_hours.js/related_tags.txt */
var related_tags = [
'opening_hours',
'opening_hours:kitchen',
'opening_hours:warm_kitchen',
'happy_hours',
'delivery_hours',
'opening_hours:delivery',
'lit',
'smoking_hours',
'collection_times',
'service_times',
//
// 'fee',
];
function createMap() {

document.onLoadFunctions.push ( function () {
var map;
var poi_layer;
var nominatim_data_global = {};
var permalinkParams = {};
var permalinkObject;

window.useUserKey = function (key) {
console.log(key);
if (related_tags.indexOf(key) !== -1) { /* Add the new key to related_tags. */
if (related_tags.indexOf(key) === -1) { /* Add the new key to related_tags. */
var opt = document.createElement('option');
opt.value = key;
opt.innerHTML = key;
var select = document.getElementById('tag_selector_input');
select.appendChild(opt);
related_tags.push(key);
select.options[select.options.length] = new Option(key, select.options.length);
} else {
document.getElementById('tag_selector_input').selectedIndex = related_tags.indexOf(key);
}
document.getElementById('tag_selector_input').selectedIndex = related_tags.indexOf(key);
};

window.keyChanged = function() {
@@ -521,22 +513,25 @@ document.onLoadFunctions.push ( function () {
return true;
}
},
}));
/* }}} */

//----------------------------------------------------------------------------
// Stelle bestimmten Bereich in maximaler Groesse dar
//----------------------------------------------------------------------------

if (!map.getCenter()) {
map.zoomToExtent(
new OpenLayers.Bounds(7.1042, 50.7362, 7.1171, 50.7417).
transform(new OpenLayers.Projection('EPSG:4326'), map.getProjectionObject())
);
}
));
/* }}} */

//----------------------------------------------------------------------------
// Stelle bestimmten Bereich in maximaler Groesse dar
//----------------------------------------------------------------------------

if (!map.getCenter()) {
map.zoomToExtent(
new OpenLayers.Bounds(7.1042, 50.7362, 7.1171, 50.7417).
transform(new OpenLayers.Projection('EPSG:4326'), map.getProjectionObject())
);
/* }}} */

document.getElementById('tag_selector_input').onchange = keyChanged;
}
/* }}} */

document.getElementById('tag_selector_input').onchange = keyChanged;

$(document).ready(function () {
createMap();
});
2 changes: 1 addition & 1 deletion opening_hours.js
Submodule opening_hours.js updated 165 files