diff options
-rw-r--r-- | layouts/page/index.html | 7 | ||||
-rw-r--r-- | static/commits.js | 21 |
2 files changed, 25 insertions, 3 deletions
diff --git a/layouts/page/index.html b/layouts/page/index.html index 3aa7497..ec8a704 100644 --- a/layouts/page/index.html +++ b/layouts/page/index.html @@ -9,9 +9,10 @@ </ul> <hr> <h3>Latest Package Changes</h3> -<ul> - <script src="https://git.carbslinux.org/exports/repository.js"></script> -</ul> +<script type="text/javascript"> + {{ os.ReadFile "/static/commits.js" | safeJS }} +</script> +<div id="commits"></div> <hr> <h2>News</h2> <a href="{{"news/index.xml"|relURL}}">RSS Feed</a> | diff --git a/static/commits.js b/static/commits.js new file mode 100644 index 0000000..6a919ca --- /dev/null +++ b/static/commits.js @@ -0,0 +1,21 @@ +function createListItem(commit) { + const li = document.createElement('li'); + const a = document.createElement('a'); + a.setAttribute('href', `https://git.carbslinux.org/repository/commit/?id=${commit.id}`); + a.textContent = `${commit.log}` + li.appendChild(a); + return li; +} + +fetch('https://git.carbslinux.org/exports/repository.json') + .then(response => response.json()) + .then(data => { + const commits = data["latest-commits"]; + const list = document.createElement('ul'); + for (let i = 0; i < commits.length; i++) { + const commit = commits[i]; + const item = createListItem(commit); + list.appendChild(item); + } + document.getElementById("commits").appendChild(list); + }); |