Browse Source

Repositories: separate repo/category parts by '/'

master
parent
commit
f0f7478d4e
  1. 2
      repo.php
  2. 2
      src/CategoryBase.js
  3. 2
      src/OpenStreetBrowserLoader.js
  4. 4
      src/addCategories.js
  5. 16
      src/index.js
  6. 4
      src/repositories.php

2
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);
}

2
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]
}

2
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 {

4
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
}

16
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) {

4
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',
);
}

Loading…
Cancel
Save