Browse Source

addCategories: include branch in source code link

master
parent
commit
250d0076b5
  1. 3
      conf.php-dist
  2. 5
      src/addCategories.js

3
conf.php-dist

@ -3,6 +3,7 @@
// repositoryUrl and categoryUrl are twig templates, which take the following input values:
// {{ repositoryId }} id of the repository
// {{ categoryId }} id of the category (not for repositoryUrl)
// {{ branchId }} id of the branch (not for repositoryUrl)
$repositories = array(
'default' => array(
'path' => 'node_modules/openstreetbrowser-categories-main',
@ -10,7 +11,7 @@ $repositories = array(
// public URL of repository
'repositoryUrl' => 'https://github.com/example/categories',
// public URL of source of a category in repository
'categoryUrl' => 'https://github.com/example/categories/tree/master/{{ categoryId }}.json',
'categoryUrl' => 'https://github.com/example/categories/tree/{{ branchId }}/{{ categoryId }}.json',
),
);

5
src/addCategories.js

@ -17,6 +17,9 @@ function addCategoriesShow (repo, options={}) {
[ repoId, branchId ] = repo.split(/~/)
}
if (!branchId) {
branchId = 'master'
}
content.innerHTML = '<h3>' + lang('more_categories') + '</h3>' + '<i class="fa fa-spinner fa-pulse fa-fw"></i> ' + lang('loading')
@ -163,7 +166,7 @@ function addCategoriesShow (repo, options={}) {
var editLink = null
if (repo && categoryUrl) {
editLink = document.createElement('a')
editLink.href = categoryUrl.render({ repositoryId: repo, categoryId: id })
editLink.href = categoryUrl.render({ repositoryId: repoId, categoryId: id, branchId: branchId })
}
if (!repo && repositoryUrl) {
editLink = document.createElement('a')

Loading…
Cancel
Save