-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDG-Gen.html
More file actions
55 lines (47 loc) · 1.87 KB
/
DG-Gen.html
File metadata and controls
55 lines (47 loc) · 1.87 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
<html>
<head>
<title>Download Latest Version</title>
</head>
<body>
<script>
// This URL should point to your repository's API endpoint for the latest commit of a specific folder
const apiURL = 'https://api.github.com/repos/GsLibrary/StaticWebsiteTemplate/commits?path=/Latest%20Version';
function fetchLatestCommitDate() {
// Fetch the latest commit data from GitHub
fetch(apiURL)
.then(response => response.json())
.then(commits => {
if (commits.length > 0) {
// Get the date of the latest commit
const latestCommitDate = new Date(commits[0].commit.committer.date);
// Format the date as needed, e.g., YYYY-MM-DD
const formattedDate = latestCommitDate.toISOString().split('T')[0];
// Continue with setting the URL
generateAndSetUrl(formattedDate);
} else {
console.error('No commits found.');
}
}).catch(error => {
console.error('Error fetching commit data:', error);
});
}
function generateAndSetUrl(commitDate) {
// Ensure that the commitDate is URL-encoded
const encodedCommitDate = encodeURIComponent(commitDate);
const sequence = Math.round(Math.random() * 12345678);
const initName = `StaticWebTemp - ${encodedCommitDate} - `;
const fullName = encodeURIComponent(initName + sequence);
const initUrl = "https://minhaskamal.github.io/DownGit/#/home?url=https:%2F%2Fgithub.com%2FGsLibrary%2FStaticWebsiteTemplate%2Ftree%2Fmain%2FLatest%20Version";
const param = "&fileName=";
const url = initUrl + param + fullName;
sendUser(url);
}
function sendUser(url) {
// Perform the redirection
window.location.href = url;
}
// Initiate the commit date fetch and URL generation process
fetchLatestCommitDate();
</script>
</body>
</html>