improved template variables for working with ForgeRoot
This commit is contained in:
parent
838489079e
commit
0eece2a92e
2 changed files with 14 additions and 9 deletions
|
@ -23,8 +23,10 @@
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<h1>git.example.com</h1>
|
<h1>git.example.com</h1>
|
||||||
<h2>{{ repository_name }}</h2>
|
<h2>{{ repository_path_parent }}
|
||||||
<p>clone url: git://git.example.com{{ forge_url_path }}{{ repository_path }}</p>
|
{% if repository_path_parent %} / {% endif %}
|
||||||
|
{{ repository_name }}</h2>
|
||||||
|
<p>clone url: git://git.example.com/{{ repository_path }}</p>
|
||||||
<nav>
|
<nav>
|
||||||
{% if readme_file %}
|
{% if readme_file %}
|
||||||
<a href="{{ relative_root }}{{ readme_file }}.html">about</a>
|
<a href="{{ relative_root }}{{ readme_file }}.html">about</a>
|
||||||
|
|
17
main.scm
17
main.scm
|
@ -308,15 +308,17 @@
|
||||||
(let* ((version-ident "$Id$")
|
(let* ((version-ident "$Id$")
|
||||||
(source-files-list (git-repository->paths-list))
|
(source-files-list (git-repository->paths-list))
|
||||||
(forge-root (string-append (string-chomp (or (config "forgeroot") "") "/") "/"))
|
(forge-root (string-append (string-chomp (or (config "forgeroot") "") "/") "/"))
|
||||||
;; should begin and end with "/"
|
(repository-path (or (config "path")
|
||||||
(forge-url-path (string-append (string-chomp (or (config "forgeurlpath") "") "/") "/"))
|
(and (not (equal? forge-root "/"))
|
||||||
|
(string-prefix? forge-root html-repo-path)
|
||||||
|
(string-drop html-repo-path (string-length forge-root)))
|
||||||
|
(pathname-strip-directory html-repo-path)))
|
||||||
(template-alist
|
(template-alist
|
||||||
`(;; variables provided to template at all times. beware: ersatz
|
`(;; variables provided to template at all times. beware: ersatz
|
||||||
;; templates break if you attempt to use a variable with a hyphen.
|
;; templates break if you attempt to use a variable with a hyphen.
|
||||||
|
|
||||||
;; the list of all files in the git repo
|
;; the list of all files in the git repo
|
||||||
(source_files_list . ,source-files-list)
|
(source_files_list . ,source-files-list)
|
||||||
(forge_url_path . ,forge-url-path)
|
|
||||||
;; the description of the repo, taken from: env, config, cgit-like
|
;; the description of the repo, taken from: env, config, cgit-like
|
||||||
;; description file
|
;; description file
|
||||||
(repository_description . ,(or (config "description")
|
(repository_description . ,(or (config "description")
|
||||||
|
@ -330,10 +332,11 @@
|
||||||
(string-chomp ".git")
|
(string-chomp ".git")
|
||||||
(pathname-strip-directory))))
|
(pathname-strip-directory))))
|
||||||
;; the path from the forge root to the repository
|
;; the path from the forge root to the repository
|
||||||
(repository_path . ,(or (config "path")
|
(repository_path . ,repository-path)
|
||||||
(if (string-prefix? forge-root html-repo-path)
|
;; the repository_path with the last path element removed
|
||||||
(string-drop html-repo-path (string-length forge-root))
|
(repository_path_parent . ,(or (pathname-directory repository-path) ""))
|
||||||
(pathname-strip-directory html-repo-path))))
|
;; the repository_path_parent as a list of path components
|
||||||
|
(repository_ancestors . ,(or (string-split (or (pathname-directory repository-path) "") "/") '()))
|
||||||
;; the first README file found among these, if any.
|
;; the first README file found among these, if any.
|
||||||
(readme_file . ,(find (cut member <> source-files-list)
|
(readme_file . ,(find (cut member <> source-files-list)
|
||||||
'("README.md" "README" "README.txt")))
|
'("README.md" "README" "README.txt")))
|
||||||
|
|
Loading…
Reference in a new issue