summaryrefslogtreecommitdiffstats
path: root/_layouts
diff options
context:
space:
mode:
Diffstat (limited to '_layouts')
-rw-r--r--_layouts/default.html50
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");