Working toward an openly accessable registry
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
parent
855034f14d
commit
4aaee3e419
@ -110,7 +110,7 @@ async function uploadPackage(ctx: ABC.Context) {
|
||||
if (!packageMeta) {
|
||||
packageMeta = {
|
||||
name: packageName,
|
||||
author: meta.author,
|
||||
author: ctx.customContext.user,
|
||||
description: meta.description,
|
||||
deprecated: false,
|
||||
versions: [],
|
||||
@ -157,7 +157,7 @@ async function uploadPackage(ctx: ABC.Context) {
|
||||
{
|
||||
$set: {
|
||||
versions: [...packageMeta.versions, packageVersion],
|
||||
author: meta.author || packageMeta.author,
|
||||
author: ctx.customContext.user,
|
||||
description: meta.description || packageMeta.description,
|
||||
deprecated: meta.deprecated === true,
|
||||
},
|
||||
|
@ -57,7 +57,7 @@ export default function views(g: ABC.Application) {
|
||||
.update(`${packageName}:${packageVersion}`)
|
||||
.toString("base64");
|
||||
|
||||
await ctx.render("package", { pkg });
|
||||
await ctx.render("package", { pkg, version: packageVersion });
|
||||
ctx.response.headers.set("cache-control", CACHE_CONTROL);
|
||||
ctx.response.headers.set("E-Tag", etag);
|
||||
});
|
||||
|
@ -64,6 +64,7 @@ export const basicauth = (realm: string) => (next: ABC.HandlerFunc) => (
|
||||
export function extractPackagePath(path: string): [string, string | undefined] {
|
||||
let packageName = "";
|
||||
path = path.toLowerCase();
|
||||
|
||||
if (path.startsWith("@")) {
|
||||
packageName = "@";
|
||||
path = path.slice(1);
|
||||
@ -81,7 +82,6 @@ export function extractPackagePath(path: string): [string, string | undefined] {
|
||||
if (packageVersion !== "") {
|
||||
if (!isValidVersion(packageVersion))
|
||||
throw new Error("Invalid package version!");
|
||||
else packageVersion = undefined;
|
||||
}
|
||||
|
||||
return [packageName, packageVersion];
|
||||
|
@ -5,7 +5,8 @@ const styles = new TextDecoder().decode(
|
||||
Deno.readFileSync("src/views/styles.css")
|
||||
);
|
||||
|
||||
export default function Base(d: any, children: any[]) {
|
||||
export default function Base(p: any, children: any[]) {
|
||||
const title = p.title || "DenReg";
|
||||
return (
|
||||
<html>
|
||||
<head>
|
||||
@ -18,6 +19,12 @@ export default function Base(d: any, children: any[]) {
|
||||
href="https://unpkg.com/papercss@1.6.1/dist/paper.min.css"
|
||||
/>
|
||||
<style innerHTML={styles}></style>
|
||||
<title>{title}</title>
|
||||
<meta name="Description" content="Deno package registry" />
|
||||
<meta
|
||||
name="viewport"
|
||||
content="width=device-width,initial-scale=1"
|
||||
/>
|
||||
</head>
|
||||
<body class="site">{children}</body>
|
||||
</html>
|
||||
|
@ -13,10 +13,10 @@ export function Menu({}: any, children: any) {
|
||||
return (
|
||||
<div style="grid-area: menu">
|
||||
<div class="paper">
|
||||
<div class="row flex-right">
|
||||
{/* <div class="row flex-right">
|
||||
<button class="sm-4">Login</button>
|
||||
<button class="sm-4">SignUp</button>
|
||||
</div>
|
||||
</div> */}
|
||||
<h3 class="sidebar-title" style="text-align:center">
|
||||
<a href="/" style="all:inherit;">
|
||||
DenReg
|
||||
|
@ -11,7 +11,7 @@ function Package({ pkg }: { pkg: IPackage }) {
|
||||
|
||||
return (
|
||||
<div
|
||||
class="card margin"
|
||||
class="card package-list-margin"
|
||||
onClick={"window.location.href = '/package/" + name + "'"}
|
||||
>
|
||||
<div class="card-body">
|
||||
@ -44,7 +44,7 @@ export default async function index({
|
||||
<Base>
|
||||
<Main>
|
||||
<form method="GET" action="./">
|
||||
<div class="form-group margin">
|
||||
<div class="form-group package-list-margin">
|
||||
{/* <label for="searchInput">Search</label> */}
|
||||
<div style="display:flex">
|
||||
<input
|
||||
@ -55,7 +55,7 @@ export default async function index({
|
||||
name="q"
|
||||
value={search}
|
||||
/>
|
||||
<button>Submit</button>
|
||||
<button>Search</button>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
|
@ -30,7 +30,13 @@ import { sortVersions, getFile } from "../utils.ts";
|
||||
|
||||
import { Main, Menu } from "./_default.tsx";
|
||||
|
||||
export default async function index({ pkg }: { pkg: IPackage }) {
|
||||
export default async function index({
|
||||
pkg,
|
||||
version,
|
||||
}: {
|
||||
pkg: IPackage;
|
||||
version?: string;
|
||||
}) {
|
||||
if (!pkg)
|
||||
return (
|
||||
<Base>
|
||||
@ -38,7 +44,7 @@ export default async function index({ pkg }: { pkg: IPackage }) {
|
||||
</Base>
|
||||
);
|
||||
|
||||
const readmeContent = await getFile(pkg.name, undefined, "README.md").then(
|
||||
const readmeContent = await getFile(pkg.name, version, "README.md").then(
|
||||
(res) => {
|
||||
if (res)
|
||||
return Marked.parse(new TextDecoder().decode(res.data))
|
||||
@ -48,18 +54,43 @@ export default async function index({ pkg }: { pkg: IPackage }) {
|
||||
);
|
||||
|
||||
return (
|
||||
<Base>
|
||||
<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.author}
|
||||
</h4>
|
||||
|
||||
{readmeContent !== undefined ? (
|
||||
<div innerHTML={readmeContent} />
|
||||
) : (
|
||||
<div class="alert alert-warning">No README.md found!</div>
|
||||
)}
|
||||
<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 innerHTML={readmeContent} />
|
||||
) : (
|
||||
<div class="alert alert-warning">No README.md found!</div>
|
||||
)}
|
||||
</div>
|
||||
|
||||
<div class="content" id="content2">
|
||||
<ul>
|
||||
{pkg.versions.sort(sortVersions).map((version) => (
|
||||
<li>
|
||||
<a href={`./${pkg.name}@${version}`}>{version}</a>
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</Main>
|
||||
<Menu></Menu>
|
||||
</Base>
|
||||
|
@ -7,6 +7,10 @@
|
||||
padding-right: 1rem;
|
||||
}
|
||||
|
||||
.package-list-margin {
|
||||
margin: 1rem;
|
||||
}
|
||||
|
||||
@media only screen and (max-width: 64rem) {
|
||||
.site {
|
||||
grid-template-columns: 1fr;
|
||||
@ -14,4 +18,8 @@
|
||||
"menu"
|
||||
"main";
|
||||
}
|
||||
|
||||
.package-list-margin {
|
||||
margin: 1rem 0;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user