diff options
author | Simone Bortolin <simonebortolin@users.noreply.github.com> | 2022-08-20 17:42:50 +0200 |
---|---|---|
committer | Simone Bortolin <simonebortolin@users.noreply.github.com> | 2022-12-19 23:07:54 +0100 |
commit | 2328b462e73380615c64b6dea0a92709fe88c997 (patch) | |
tree | 4c4c74dade610fc179f43d517212ad858fb5e02d /_layouts/default.html | |
parent | add some iusse at zyxel (diff) | |
download | hack-gpon.github.io-2328b462e73380615c64b6dea0a92709fe88c997.tar hack-gpon.github.io-2328b462e73380615c64b6dea0a92709fe88c997.tar.gz hack-gpon.github.io-2328b462e73380615c64b6dea0a92709fe88c997.tar.bz2 hack-gpon.github.io-2328b462e73380615c64b6dea0a92709fe88c997.tar.lz hack-gpon.github.io-2328b462e73380615c64b6dea0a92709fe88c997.tar.xz hack-gpon.github.io-2328b462e73380615c64b6dea0a92709fe88c997.tar.zst hack-gpon.github.io-2328b462e73380615c64b6dea0a92709fe88c997.zip |
Diffstat (limited to '')
-rw-r--r-- | _layouts/default.html | 50 |
1 files changed, 45 insertions, 5 deletions
diff --git a/_layouts/default.html b/_layouts/default.html index 9c387a8..405a530 100644 --- a/_layouts/default.html +++ b/_layouts/default.html @@ -269,6 +269,49 @@ layout: table_wrappers {%if site.last_edit_timestamp_script and site.gh_owner_name and site.gh_repository_name and page.path %} <script> + function parseFirstCommit(commit,filename) { + fetch(commit.url).then((response) => { + return response.json(); + }).then((commits) => { + var old_filename = commits.files.filter(it => it.filename === filename && it.status === 'renamed').map(it => it.previous_filename); + if(old_filename[0] !== undefined) { + fetch("https://api.github.com/repos/{{ site.gh_owner_name }}/{{ site.gh_repository_name }}/commits?path="+old_filename[0]) + .then((response) => { + return response.json(); + }).then((commits) => { + return parseCommitsList(commits, old_filename); + }); + } + return null; + }); + + } + function parseCommitsList(commits, filename) { + var authors = commits.flatMap(x => [{...x.commit.author, ...x.author},{...x.commit.committer, ...x.committer}]).map(({date, ...keepAttrs}) => keepAttrs).filter((value, index, self) => + index === self.findIndex((t) => ( + t.login === value.login + )) && value.login !== "web-flow" + ); + + console.log("initial authors - "+filename); + console.log(authors); + + var inners = commits.map(it => (parseFirstCommit(it, filename))); + + var inner = parseFirstCommit(commits[commits.length -1], filename); + + console.log("inner authors - "+filename); + console.log(inner); + + if(inner) { + authors.push(...inner); + } + console.log("final authors - "+filename); + console.log(authors); + + + return authors; + } function setModifiedDate() { if (document.getElementById('last-modified')) { fetch("https://api.github.com/repos/{{ site.gh_owner_name }}/{{ site.gh_repository_name }}/commits?path={{ page.path }}") @@ -279,11 +322,8 @@ layout: table_wrappers var date = new Date(commits[0]['commit']['committer']['date']); var modified = date.toLocaleDateString(undefined); - var authors = commits.flatMap(x => [{...x.commit.author, ...x.author},{...x.commit.committer, ...x.committer}]).map(({date, ...keepAttrs}) => keepAttrs).filter((value, index, self) => - index === self.findIndex((t) => ( - t.login === value.login - )) && value.login !== "web-flow" - ); + var authors = parseCommitsList(commits, "{{ page.path }}"); + document.getElementById('last-modified').textContent = "Last Modified: " + modified; document.getElementById('contributors').textContent = authors.length + " "+ ( authors.length == 1? "Contributor" : "Contributors"); |