Skip to content

Commit

Permalink
BETA 1.0.1
Browse files Browse the repository at this point in the history
  • Loading branch information
albios committed May 3, 2023
1 parent 24d44a4 commit 7f88822
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 5 deletions.
6 changes: 3 additions & 3 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ app.use(compression());

app.use(express.static(path.join(__dirname, 'public')));

const fileCache = new NodeCache({ stdTTL: 300, checkperiod: 300 });
const fileCache = new NodeCache({ stdTTL: 600, checkperiod: 600 });

function rewriteURLAndRedirect(req, res, next) {
const user = '3kh0';
Expand Down Expand Up @@ -231,7 +231,7 @@ app.get('/cdn/:user/:repo/:branch/*', async (req, res) => {
const cachedFile = fileCache.get(cacheKey);

if (cachedFile) {
res.setHeader('Cache-Control', 'public, max-age=300');
res.setHeader('Cache-Control', 'public, max-age=600');
res.writeHead(cachedFile.status, { 'Content-Type': cachedFile.contentType.split(';')[0] });
res.end(cachedFile.content);
} else {
Expand Down Expand Up @@ -276,7 +276,7 @@ app.get('/cfcdn/:user/:repo/:branch/*', async (req, res) => {
return res.sendStatus(404);
}

res.setHeader('Cache-Control', 'public, max-age=300');
res.setHeader('Cache-Control', 'public, max-age=600');

const contentType = response.headers.get('content-type');
if (contentType && contentType.startsWith('image/')) {
Expand Down
4 changes: 2 additions & 2 deletions public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@
<center>
<h1 class="title">Gitloaf</h1>
<p><b>Gitloaf</b> is an open-source nodejs powered CDN that delivers files from github with their correct <b>Content-Type headers</b>, similarly to other cdns such as <a href="https://raw.githack.com">githack.</a>
You can see a list of supported file types <a href="filetypes.html">here</a>
You can see a list of supported file types <a href="filetypes.html">here</a> and view the update log <a href="updatelog.html">here</a>
</p>
<p>Current version: <b>BETA 1.0.0</b></p>
<p>Current version: <b>BETA 1.0.1</b></p>
<p>In beta versions, some or many games may not work. These issues will be fixed in later versions.</p>
<br>
<p>You can use the converter below to convert your github links into a CDN url</p>
Expand Down
47 changes: 47 additions & 0 deletions public/updatelog.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Gitloaf</title>
<link rel="stylesheet" href="styles.css">
<link href="https://fonts.googleapis.com/css?family=Roboto|Roboto+Mono&display=swap" rel="stylesheet">
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Barlow:wght@800&family=Cabin:wght@500&family=Montserrat:wght@600&family=Noto+Sans:wght@500&family=Roboto:wght@500&display=swap" rel="stylesheet">
</head>
<body>
<div class="main-container">
<center>
<h1 class="title"> <b>Gitloaf</b> version:</h1>
<p><b>BETA 1.0.1</b></p>
<p>- Changed Cache time from 5 to 10 minutes</p>
<p>- Fixed jsDelivr/Cloudflare CDN</p>
<br>
<p><b>BETA 1.0.0</b></p>
<p>RELEASE!!!</p>
</center>
<script>
(function () {
const urlPath = window.location.pathname;
const pathSegments = urlPath.split('/').filter(segment => segment.length > 0);
const [, user, repo, branch] = pathSegments;
const cdnPrefix = `/cdn/${user}/${repo}/${branch}`;

const scriptTags = document.querySelectorAll('script[src^="/js/"]');
scriptTags.forEach((script) => {
const src = script.getAttribute('src');
script.setAttribute('src', cdnPrefix + src);
});

const styleTags = document.querySelectorAll('link[href^="/css/"][rel="stylesheet"]');
styleTags.forEach((style) => {
const href = style.getAttribute('href');
style.setAttribute('href', cdnPrefix + href);
});
})();
</script>

<script src="scripts.js"></script>
</body>
</html>

0 comments on commit 7f88822

Please sign in to comment.