copyright/author update, beautify popup

This commit is contained in:
Vinzenz Rosenkranz 2017-08-24 17:57:49 +02:00
Родитель f2592d4e8d
Коммит 6425b39c0a
5 изменённых файлов: 79 добавлений и 40 удалений

Просмотреть файл

@ -1,12 +1,12 @@
<?php
/**
* ownCloud - maps
* Nextcloud - maps
*
* This file is licensed under the Affero General Public License version 3 or
* later. See the COPYING file.
*
* @author Sander Brand <brantje@gmail.com>, Vinzenz Rosenkranz <vinzenz.rosenkranz@gmail.com>
* @copyright Sander Brand 2014, Vinzenz Rosenkranz 2016
* @copyright Sander Brand 2014, Vinzenz Rosenkranz 2016, 2017
*/
namespace OCA\Maps\AppInfo;
@ -26,7 +26,7 @@ $l = \OC::$server->getL10N('maps');
// the icon that will be shown in the navigation
// this file needs to exist in img/
'icon' => \OC::$server->getURLGenerator()->imagePath('maps', 'app.svg'),
'icon' => \OC::$server->getURLGenerator()->imagePath('maps', 'maps.svg'),
// the title of your application. This will be used in the
// navigation or on the settings page of your app

Просмотреть файл

@ -17,39 +17,59 @@
height: 100%;
}
.location-header {
font-weight: bold;
.inline-wrapper {
display: flex;
}
span.location-city {
.location-icon {
height: 20px;
margin-top: 5px;
}
.location-header {
font-weight: bold;
word-wrap: break-word;
word-break: break-all;
}
.location-city {
color: gray;
}
span.poi-open {
color: green;
.poi-open, .poi-closed, .poi-closes {
font-weight: 600;
}
span.poi-closed {
color: red;
.poi-open {
color: #46ba61;
}
span.poi-closes-15, span.poi-opens-60 {
color: rgb(228, 130, 0);
.poi-closed {
color: #e9322d;
}
span.poi-closes-30, span.poi-opens-30 {
color: rgb(228, 212, 0);
.poi-closes {
color: #ffcc44;
}
span.poi-closes-60, span.poi-opens-15 {
color: rgb(52, 228, 0);
.poi-opens {
}
table.opening-hours-table td.opening-hours-day {
.popup-icon {
height: 20px;
margin-right: 5px;
}
.opening-hours-table {
margin-left: 25px;
}
.opening-hours-table .opening-hours-day {
padding-right: 5px;
}
table.opening-hours-table td.opening-hours-hours {
.opening-hours-table .opening-hours-hours {
padding-left: 5px;
}
@ -57,14 +77,14 @@ tr.selected td {
font-weight: bold;
}
p.opening-hours {
.opening-hours {
padding-left: 5px;
margin-top: 5px !important;
margin-bottom: 5px !important;
}
/* Overriden Leaflet Styles */
div.leaflet-top.leaflet-left {
.leaflet-top.leaflet-left {
top: 50px;
}
.leaflet-popup-content h2, .leaflet-popup-content h3 {

Просмотреть файл

@ -23,6 +23,12 @@
}
});
var helpers = {
beautifyUrl: function(url) {
return url.replace(/^(?:\w+:|)\/\/(?:www\.|)(.*[^\/])\/*$/, '$1');
}
};
var mapController = {
searchMarker: {},
map: {},
@ -129,12 +135,13 @@
}
var header = '<h2 class="location-header">' + unformattedHeader + '</h2>';
if(result.icon) header = '<div class="inline-wrapper"><img class="location-icon" src="' + result.icon + '" />' + header + '</div>';
var desc = '<span class="location-city">' + unformattedDesc + '</span>';
// Add extras to parsed desc
var extras = result.extratags;
if(extras.opening_hours) {
desc += '<h3>Opening Hours</h3>';
desc += '<div class="inline-wrapper"><img class="popup-icon" src="'+OC.filePath('maps', 'img', 'recent.svg')+'" />';
var oh = new opening_hours(extras.opening_hours, result);
var isCurrentlyOpen = oh.getState();
var changeDt = oh.getNextChange();
@ -142,24 +149,17 @@
var dtDiff = changeDt.getTime() - currentDt.getTime();
dtDiff = dtDiff / 60000; // get diff in minutes
if(oh.getState()) { // is open?
desc += '<span class="poi-open">open</span>';
if(dtDiff <= 15) {
desc += '<span class="poi-closes-15">closes in less than 15 minutes</span>';
} else if(dtDiff <= 30) {
desc += '<span class="poi-closes-30">closes in less than 30 minutes</span>';
} else if(dtDiff <= 60) {
desc += '<span class="poi-closes-60">closes in less than 1 hour</span>';
desc += '<span class="poi-open">Open</span>';
if(dtDiff <= 60) {
desc += '<span class="poi-closes">,&nbsp;closes in ' + dtDiff + ' minutes</span>';
} else {
desc += '<span>&nbsp;until ' + changeDt.toLocaleTimeString() + '</span>';
}
} else {
desc += '<span class="poi-closed">closed</span>';
if(dtDiff <= 15) {
desc += '<span class="poi-opens-15">opens in less than 15 minutes</span>';
} else if(dtDiff <= 30) {
desc += '<span class="poi-opens-30">opens in less than 30 minutes</span>';
} else if(dtDiff <= 60) {
desc += '<span class="poi-opens-60">opens in less than 1 hour</span>';
}
desc += '<span class="poi-closed">Closed</span>';
desc += '<span class="poi-opens">opens at ' + changeDt.toLocaleTimeString() + '</span>';
}
desc += '</div>';
var todayStart = currentDt;
todayStart.setHours(0);
todayStart.setMinutes(0);
@ -190,7 +190,13 @@
desc += '</table>';
}
if(extras.website) {
desc += '<p><a href="' + extras.website + '" target="_blank">' + extras.website + '</a></p>';
desc += '<div class="inline-wrapper"><img class="popup-icon" src="'+OC.filePath('maps', 'img', 'link.svg')+'" /><a href="' + extras.website + '" target="_blank">' + helpers.beautifyUrl(extras.website) + '</a></div>';
}
if(extras.phone) {
desc += '<div class="inline-wrapper"><img class="popup-icon" src="'+OC.filePath('maps', 'img', 'link.svg')+'" /><a href="tel:' + extras.phone + '" target="_blank">' + extras.phone + '</a></div>';
}
if(extras.email) {
desc += '<div class="inline-wrapper"><img class="popup-icon" src="'+OC.filePath('maps', 'img', 'mail.svg')+'" /><a href="mailto:' + extras.email + '" target="_blank">' + extras.email + '</a></div>';
}
return header + desc;

Просмотреть файл

@ -1,4 +1,14 @@
<?php
/**
* Nextcloud - maps
*
* This file is licensed under the Affero General Public License version 3 or
* later. See the COPYING file.
*
* @authorVinzenz Rosenkranz <vinzenz.rosenkranz@gmail.com>
* @copyright Vinzenz Rosenkranz 2017
*/
namespace OCA\Maps\Controller;
use OCP\IRequest;
@ -31,6 +41,9 @@ class PageController extends Controller {
$csp = new \OCP\AppFramework\Http\ContentSecurityPolicy();
// map tiles
$csp->addAllowedImageDomain('https://*.tile.openstreetmap.org');
// poi images
$csp->addAllowedImageDomain('https://nominatim.openstreetmap.org');
// search and geocoder
$csp->addAllowedConnectDomain('https://nominatim.openstreetmap.org');
$response->setContentSecurityPolicy($csp);
}

Просмотреть файл

@ -1,8 +1,6 @@
<?php
/**
* @author Vinzenz Rosenkranz <vinzenz.rosenkranz@gmail.com>
*
* Maps
* Nextcloud - Maps
*
* This code is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License, version 3,
@ -16,6 +14,8 @@
* You should have received a copy of the GNU Affero General Public License, version 3,
* along with this program. If not, see <http://www.gnu.org/licenses/>
*
* @author Vinzenz Rosenkranz <vinzenz.rosenkranz@gmail.com>
* @copyright Vinzenz Rosenkranz 2017
*/
style('maps', '../node_modules/leaflet/dist/leaflet');