Adding basic file browsing support
Some checks failed
continuous-integration/drone/push Build is failing

This commit is contained in:
Fabian Stamm
2020-10-14 02:52:02 +02:00
parent 78c40e4819
commit 46d8f8b289
48 changed files with 1097 additions and 70 deletions

View File

@ -1,9 +1,9 @@
/// <reference path="../types/jsx.d.ts" />
import { React, Fragment, Marked } from "../deps.ts";
import Base from "./_base.tsx";
import DB, { IPackage } from "../db.ts";
import { sortVersions, getFile } from "../utils.ts";
import type { IPackage } from "../db.ts";
import { sortVersions, getFile, getAbsolutePackageVersion } from "../utils.ts";
import PkgHeader from "./_pkgheader.tsx";
// function Package({ pkg }: { pkg: IPackage }) {
// const { name, versions, author } = pkg;
@ -44,6 +44,7 @@ export default async function index({
</Base>
);
version = getAbsolutePackageVersion(pkg, version);
const readmeContent = await getFile(pkg.name, version, "README.md").then(
(res) => {
if (res)
@ -56,23 +57,13 @@ export default async function index({
return (
<Base title={"DenReg - " + pkg.name}>
<Main>
<h2 style="margin-bottom: 0">Package: {pkg.name}</h2>
<h4 class="text-muted" style="margin-top: 0; margin-left: .5rem">
By {pkg.owner}
</h4>
<PkgHeader pkg={pkg} version={version} />
<div class="tabs">
<input id="tab1" type="radio" name="tabs" checked />
<label for="tab1">Readme</label>
<input id="tab2" type="radio" name="tabs" />
<label for="tab2">Versions</label>
{/*
<input id="tab3" type="radio" name="tabs" />
<label for="tab3">Tab 3</label>
<input id="tab4" type="radio" name="tabs" />
<label for="tab4">Tab 4</label> */}
<div class="content" id="content1">
{readmeContent !== undefined ? (
<div
@ -95,7 +86,11 @@ export default async function index({
</div>
</div>
</Main>
<Menu></Menu>
<Menu>
<a href={`/browse/${pkg.name}${version ? "@" + version : ""}/`}>
Browse Files
</a>
</Menu>
</Base>
);
}