Browse Source

More Categories: include format in repository links

master
parent
commit
f65e7aea61
  1. 3
      conf.php-dist
  2. 2
      src/addCategories.js
  3. 2
      src/repositories.php

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)
// {{ categoryFormat }} format of the file (json or yaml)
// {{ branchId }} id of the branch (not for repositoryUrl)
$repositories = array(
'default' => array(
@ -11,7 +12,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/{{ branchId }}/{{ categoryId }}.json',
'categoryUrl' => 'https://github.com/example/categories/tree/{{ branchId }}/{{ categoryId }}.{{ categoryFormat }}',
),
);

2
src/addCategories.js

@ -166,7 +166,7 @@ function addCategoriesShow (repo, options={}) {
var editLink = null
if (repo && categoryUrl) {
editLink = document.createElement('a')
editLink.href = categoryUrl.render({ repositoryId: repoId, categoryId: id, branchId: branchId })
editLink.href = categoryUrl.render({ repositoryId: repoId, categoryId: id, branchId: branchId, categoryFormat: data.format })
}
if (!repo && repositoryUrl) {
editLink = document.createElement('a')

2
src/repositories.php

@ -31,7 +31,7 @@ function getRepositories () {
if (array_key_exists('url', $repositoriesGitea)) {
$r['repositoryUrl'] = "{$repositoriesGitea['url']}/{{ repositoryId }}";
$r['categoryUrl'] = "{$repositoriesGitea['url']}/{{ repositoryId }}/src/branch/{{ branchId }}/{{ categoryId }}.json";
$r['categoryUrl'] = "{$repositoriesGitea['url']}/{{ repositoryId }}/src/branch/{{ branchId }}/{{ categoryId }}.{{ categoryFormat }}";
}
$result["{$f1}/{$f2id}"] = $r;

Loading…
Cancel
Save