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

View File

@@ -20,6 +20,12 @@
ng-href="{{url}}"
target="__self"
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
>
<a

View File

@@ -31,9 +31,11 @@ router.get(
object: f,
});
}
res.attachment(
anonymizedPath.substring(anonymizedPath.lastIndexOf("/") + 1)
);
if (req.query.download) {
res.attachment(
anonymizedPath.substring(anonymizedPath.lastIndexOf("/") + 1)
);
}
// cache the file for 5min
res.header("Cache-Control", "max-age=300");
await Promise.all([repo.countView(), f.send(res)]);

View File

@@ -126,7 +126,7 @@ export default async function start() {
res.json({
nbRepositories,
nbUsers: users.length,
nbPageViews: nbPageViews[0].total,
nbPageViews: nbPageViews[0]?.total || 0,
nbPullRequests,
});
});