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) {
|
if (!packageMeta) {
|
||||||
packageMeta = {
|
packageMeta = {
|
||||||
name: packageName,
|
name: packageName,
|
||||||
author: meta.author,
|
author: ctx.customContext.user,
|
||||||
description: meta.description,
|
description: meta.description,
|
||||||
deprecated: false,
|
deprecated: false,
|
||||||
versions: [],
|
versions: [],
|
||||||
@ -157,7 +157,7 @@ async function uploadPackage(ctx: ABC.Context) {
|
|||||||
{
|
{
|
||||||
$set: {
|
$set: {
|
||||||
versions: [...packageMeta.versions, packageVersion],
|
versions: [...packageMeta.versions, packageVersion],
|
||||||
author: meta.author || packageMeta.author,
|
author: ctx.customContext.user,
|
||||||
description: meta.description || packageMeta.description,
|
description: meta.description || packageMeta.description,
|
||||||
deprecated: meta.deprecated === true,
|
deprecated: meta.deprecated === true,
|
||||||
},
|
},
|
||||||
|
@ -57,7 +57,7 @@ export default function views(g: ABC.Application) {
|
|||||||
.update(`${packageName}:${packageVersion}`)
|
.update(`${packageName}:${packageVersion}`)
|
||||||
.toString("base64");
|
.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("cache-control", CACHE_CONTROL);
|
||||||
ctx.response.headers.set("E-Tag", etag);
|
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] {
|
export function extractPackagePath(path: string): [string, string | undefined] {
|
||||||
let packageName = "";
|
let packageName = "";
|
||||||
path = path.toLowerCase();
|
path = path.toLowerCase();
|
||||||
|
|
||||||
if (path.startsWith("@")) {
|
if (path.startsWith("@")) {
|
||||||
packageName = "@";
|
packageName = "@";
|
||||||
path = path.slice(1);
|
path = path.slice(1);
|
||||||
@ -81,7 +82,6 @@ export function extractPackagePath(path: string): [string, string | undefined] {
|
|||||||
if (packageVersion !== "") {
|
if (packageVersion !== "") {
|
||||||
if (!isValidVersion(packageVersion))
|
if (!isValidVersion(packageVersion))
|
||||||
throw new Error("Invalid package version!");
|
throw new Error("Invalid package version!");
|
||||||
else packageVersion = undefined;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return [packageName, packageVersion];
|
return [packageName, packageVersion];
|
||||||
|
@ -5,7 +5,8 @@ const styles = new TextDecoder().decode(
|
|||||||
Deno.readFileSync("src/views/styles.css")
|
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 (
|
return (
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<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"
|
href="https://unpkg.com/papercss@1.6.1/dist/paper.min.css"
|
||||||
/>
|
/>
|
||||||
<style innerHTML={styles}></style>
|
<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>
|
</head>
|
||||||
<body class="site">{children}</body>
|
<body class="site">{children}</body>
|
||||||
</html>
|
</html>
|
||||||
|
@ -13,10 +13,10 @@ export function Menu({}: any, children: any) {
|
|||||||
return (
|
return (
|
||||||
<div style="grid-area: menu">
|
<div style="grid-area: menu">
|
||||||
<div class="paper">
|
<div class="paper">
|
||||||
<div class="row flex-right">
|
{/* <div class="row flex-right">
|
||||||
<button class="sm-4">Login</button>
|
<button class="sm-4">Login</button>
|
||||||
<button class="sm-4">SignUp</button>
|
<button class="sm-4">SignUp</button>
|
||||||
</div>
|
</div> */}
|
||||||
<h3 class="sidebar-title" style="text-align:center">
|
<h3 class="sidebar-title" style="text-align:center">
|
||||||
<a href="/" style="all:inherit;">
|
<a href="/" style="all:inherit;">
|
||||||
DenReg
|
DenReg
|
||||||
|
@ -11,7 +11,7 @@ function Package({ pkg }: { pkg: IPackage }) {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
class="card margin"
|
class="card package-list-margin"
|
||||||
onClick={"window.location.href = '/package/" + name + "'"}
|
onClick={"window.location.href = '/package/" + name + "'"}
|
||||||
>
|
>
|
||||||
<div class="card-body">
|
<div class="card-body">
|
||||||
@ -44,7 +44,7 @@ export default async function index({
|
|||||||
<Base>
|
<Base>
|
||||||
<Main>
|
<Main>
|
||||||
<form method="GET" action="./">
|
<form method="GET" action="./">
|
||||||
<div class="form-group margin">
|
<div class="form-group package-list-margin">
|
||||||
{/* <label for="searchInput">Search</label> */}
|
{/* <label for="searchInput">Search</label> */}
|
||||||
<div style="display:flex">
|
<div style="display:flex">
|
||||||
<input
|
<input
|
||||||
@ -55,7 +55,7 @@ export default async function index({
|
|||||||
name="q"
|
name="q"
|
||||||
value={search}
|
value={search}
|
||||||
/>
|
/>
|
||||||
<button>Submit</button>
|
<button>Search</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
|
@ -30,7 +30,13 @@ import { sortVersions, getFile } from "../utils.ts";
|
|||||||
|
|
||||||
import { Main, Menu } from "./_default.tsx";
|
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)
|
if (!pkg)
|
||||||
return (
|
return (
|
||||||
<Base>
|
<Base>
|
||||||
@ -38,7 +44,7 @@ export default async function index({ pkg }: { pkg: IPackage }) {
|
|||||||
</Base>
|
</Base>
|
||||||
);
|
);
|
||||||
|
|
||||||
const readmeContent = await getFile(pkg.name, undefined, "README.md").then(
|
const readmeContent = await getFile(pkg.name, version, "README.md").then(
|
||||||
(res) => {
|
(res) => {
|
||||||
if (res)
|
if (res)
|
||||||
return Marked.parse(new TextDecoder().decode(res.data))
|
return Marked.parse(new TextDecoder().decode(res.data))
|
||||||
@ -48,18 +54,43 @@ export default async function index({ pkg }: { pkg: IPackage }) {
|
|||||||
);
|
);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Base>
|
<Base title={"DenReg - " + pkg.name}>
|
||||||
<Main>
|
<Main>
|
||||||
<h2 style="margin-bottom: 0">Package: {pkg.name}</h2>
|
<h2 style="margin-bottom: 0">Package: {pkg.name}</h2>
|
||||||
<h4 class="text-muted" style="margin-top: 0; margin-left: .5rem">
|
<h4 class="text-muted" style="margin-top: 0; margin-left: .5rem">
|
||||||
By {pkg.author}
|
By {pkg.author}
|
||||||
</h4>
|
</h4>
|
||||||
|
|
||||||
{readmeContent !== undefined ? (
|
<div class="tabs">
|
||||||
<div innerHTML={readmeContent} />
|
<input id="tab1" type="radio" name="tabs" checked />
|
||||||
) : (
|
<label for="tab1">Readme</label>
|
||||||
<div class="alert alert-warning">No README.md found!</div>
|
|
||||||
)}
|
<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>
|
</Main>
|
||||||
<Menu></Menu>
|
<Menu></Menu>
|
||||||
</Base>
|
</Base>
|
||||||
|
@ -7,6 +7,10 @@
|
|||||||
padding-right: 1rem;
|
padding-right: 1rem;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.package-list-margin {
|
||||||
|
margin: 1rem;
|
||||||
|
}
|
||||||
|
|
||||||
@media only screen and (max-width: 64rem) {
|
@media only screen and (max-width: 64rem) {
|
||||||
.site {
|
.site {
|
||||||
grid-template-columns: 1fr;
|
grid-template-columns: 1fr;
|
||||||
@ -14,4 +18,8 @@
|
|||||||
"menu"
|
"menu"
|
||||||
"main";
|
"main";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.package-list-margin {
|
||||||
|
margin: 1rem 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user