feat(#171): supports display raw content

This commit is contained in:
tdurieux
2023-03-29 13:05:13 +02:00
parent 38d3e54d0b
commit f1fe8eff14
3 changed files with 12 additions and 4 deletions
+6
View File
@@ -20,6 +20,12 @@
ng-href="{{url}}" ng-href="{{url}}"
target="__self" target="__self"
class="btn btn-outline-primary btn-sm" class="btn btn-outline-primary btn-sm"
>View raw</a
>
<a
ng-href="{{url}}?download=true"
target="__self"
class="btn btn-outline-primary btn-sm"
>Download file</a >Download file</a
> >
<a <a
+2
View File
@@ -31,9 +31,11 @@ router.get(
object: f, object: f,
}); });
} }
if (req.query.download) {
res.attachment( res.attachment(
anonymizedPath.substring(anonymizedPath.lastIndexOf("/") + 1) anonymizedPath.substring(anonymizedPath.lastIndexOf("/") + 1)
); );
}
// cache the file for 5min // cache the file for 5min
res.header("Cache-Control", "max-age=300"); res.header("Cache-Control", "max-age=300");
await Promise.all([repo.countView(), f.send(res)]); await Promise.all([repo.countView(), f.send(res)]);
+1 -1
View File
@@ -126,7 +126,7 @@ export default async function start() {
res.json({ res.json({
nbRepositories, nbRepositories,
nbUsers: users.length, nbUsers: users.length,
nbPageViews: nbPageViews[0].total, nbPageViews: nbPageViews[0]?.total || 0,
nbPullRequests, nbPullRequests,
}); });
}); });