From f0f7478d4ecbf147d7b0d1e29ca86d957241ed2a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stephan=20B=C3=B6sch-Plepelits?= Date: Mon, 25 Dec 2017 19:09:29 +0100 Subject: [PATCH] Repositories: separate repo/category parts by '/' --- repo.php | 2 +- src/CategoryBase.js | 2 +- src/OpenStreetBrowserLoader.js | 2 +- src/addCategories.js | 4 ++-- src/index.js | 16 +++++++++------- src/repositories.php | 4 ++-- 6 files changed, 16 insertions(+), 14 deletions(-) diff --git a/repo.php b/repo.php index ca51897d..7231a38e 100644 --- a/repo.php +++ b/repo.php @@ -16,7 +16,7 @@ if (!isset($_REQUEST['repo'])) { $repo = getRepo($repoId, $repoData); print $c++ ? ',' : ''; - print json_encode($repoId) . ':'; + print json_encode($repoId, JSON_UNESCAPED_UNICODE|JSON_UNESCAPED_SLASHES) . ':'; print json_encode($repo->info(), JSON_UNESCAPED_UNICODE|JSON_UNESCAPED_SLASHES|JSON_FORCE_OBJECT); } diff --git a/src/CategoryBase.js b/src/CategoryBase.js index b437ad47..da6639e3 100644 --- a/src/CategoryBase.js +++ b/src/CategoryBase.js @@ -15,7 +15,7 @@ function CategoryBase (id, data) { this.repoId = null var m - if (m = this.id.match(/^(.+)\.([^\.]+)$/)) { + if (m = this.id.match(/^(.+)\/([^\/]+)$/)) { this.repoId = m[1] } diff --git a/src/OpenStreetBrowserLoader.js b/src/OpenStreetBrowserLoader.js index f9b0e83a..1e1301f1 100644 --- a/src/OpenStreetBrowserLoader.js +++ b/src/OpenStreetBrowserLoader.js @@ -27,7 +27,7 @@ OpenStreetBrowserLoader.prototype.getCategory = function (id, options, callback) var repo var categoryId var m - if (m = id.match(/^(.*)\.([^\.]*)/)) { + if (m = id.match(/^(.*)\/([^\/]*)/)) { repo = m[1] categoryId = m[2] } else { diff --git a/src/addCategories.js b/src/addCategories.js index aa1fca98..f5882c60 100644 --- a/src/addCategories.js +++ b/src/addCategories.js @@ -53,7 +53,7 @@ function addCategoriesShow (repo) { var a = document.createElement('a') if (repo) { - a.href = '#categories=' + repo + '.' + id + a.href = '#categories=' + repo + '/' + id a.onclick = function () { addCategoriesHide() } @@ -71,7 +71,7 @@ function addCategoriesShow (repo) { if (config.urlCategoriesEditor) { a = document.createElement('a') if (repo) { - a.href = config.urlCategoriesEditor + '?id=' + repo + '.' + id + a.href = config.urlCategoriesEditor + '?id=' + repo + '/' + id } else { a.href = config.urlCategoriesEditor + '?repo=' + id } diff --git a/src/index.js b/src/index.js index e1bb5a9f..78047fb8 100644 --- a/src/index.js +++ b/src/index.js @@ -173,15 +173,17 @@ function show (id, options, callback) { document.getElementById('contentDetails').innerHTML = 'Loading ...' } - id = id.split('/') - - if (id.length < 2) { + var m = id.match(/^(.*)\/([nwr]\d+)(\/details)?$/) + if (!m) { return callback(new Error('unknown request')) } - OpenStreetBrowserLoader.getCategory(id[0], function (err, category) { + var categoryId = m[1] + var featureId = m[2] + + OpenStreetBrowserLoader.getCategory(categoryId, function (err, category) { if (err) { - return callback(new Error('error loading category "' + id[0] + '": ' + err)) + return callback(new Error('error loading category "' + categoryId + '": ' + err)) } if (!category.parentDom) { @@ -189,12 +191,12 @@ function show (id, options, callback) { } category.show( - id[1], + featureId, { }, function (err, data) { if (err) { - return callback(new Error('error loading object "' + id[0] + '/' + id[1] + '": ' + err)) + return callback(new Error('error loading object "' + categoryId + '/' + featureId + '": ' + err)) } if (!map._popup || map._popup !== data.popup) { diff --git a/src/repositories.php b/src/repositories.php index 7ce2cc8b..aea8c1c4 100644 --- a/src/repositories.php +++ b/src/repositories.php @@ -23,8 +23,8 @@ function getRepositories () { if (substr($f2, 0, 1) !== '.') { $f2id = substr($f2, 0, -4); - $repositories["{$f1}.{$f2id}"] = array( - 'path' => "{$p}/{$f1}/{$f2}", + $repositories["{$f1}/{$f2id}"] = array( + 'path' => "{$config['repositories_gitea']}/{$f1}/{$f2}", 'type' => 'git', ); }