add markdown support for documents and verify repo url shape

This commit is contained in:
William Bell committed 2024-03-17 23:59:28 +00:00
1 parent 60f3281568
commit 5f0bfb8c61
6 files changed
+21 -13

No files matched your search

+1 -1
View File
@@ -1 +1 @@
[{"Name":"bleach.ar","Version":"1.0.0","URL":"https://isotope.wbell.dev/isotope-download?version=1.0.0\u0026name=bleach.ar","Remote":"isotope.wbell.dev"},{"Name":"shlex.ar","Version":"1.0.1","URL":"https://isotope.wbell.dev/isotope-download?name=shlex.ar\u0026version=1.0.1","Remote":"isotope.wbell.dev"},{"Name":"neon.ar","Version":"beta1.0.2","URL":"https://isotope.wbell.dev/isotope-download?name=neon.ar\u0026version=beta1.0.2","Remote":"isotope.wbell.dev"},{"Name":"url.ar","Version":"1.0.1","URL":"https://isotope.wbell.dev/isotope-download?name=url.ar\u0026version=1.0.1","Remote":"isotope.wbell.dev"},{"Name":"http.ar","Version":"1.1.2","URL":"https://isotope.wbell.dev/isotope-download?name=http.ar\u0026version=1.1.2","Remote":"isotope.wbell.dev"}]
[{"Name":"bleach.ar","Version":"1.0.0","URL":"https://isotope.wbell.dev/isotope-download?name=bleach.ar\u0026version=1.0.0","Remote":"isotope.wbell.dev"},{"Name":"shlex.ar","Version":"1.0.1","URL":"https://isotope.wbell.dev/isotope-download?name=shlex.ar\u0026version=1.0.1","Remote":"isotope.wbell.dev"},{"Name":"neon.ar","Version":"beta1.0.2","URL":"https://isotope.wbell.dev/isotope-download?name=neon.ar\u0026version=beta1.0.2","Remote":"isotope.wbell.dev"},{"Name":"url.ar","Version":"1.0.2","URL":"https://isotope.wbell.dev/isotope-download?name=url.ar\u0026version=1.0.2","Remote":"isotope.wbell.dev"},{"Name":"http.ar","Version":"1.1.2","URL":"https://isotope.wbell.dev/isotope-download?name=http.ar\u0026version=1.1.2","Remote":"isotope.wbell.dev"},{"Name":"markdown.ar","Version":"beta1.0.1","URL":"https://isotope.wbell.dev/isotope-download?name=markdown.ar\u0026version=beta1.0.1","Remote":"isotope.wbell.dev"}]
+2 -1
View File
@@ -6,6 +6,7 @@ import "bleach.ar" as bleach
import "shlex.ar" as shlex
import "render" as render
import "commaNumbers" as *
import "markdown.ar" as markdown
let package(req, res) = do
let acc = account.getByToken(req.cookies.get_value("token", ""))
@@ -54,5 +55,5 @@ let package(req, res) = do
let edit = ""
if (acc != null && acc.id == author.id) do
edit = "<a style=\"float: right\" href='/package/edit?"+url.queryStr({name:name})+"'><h2>Edit</h2></a>"
res.renderTemplate("package.html", {name:name, description: package.get_value("description", ""), 'short-description': package.get_value("short-description", ""), 'downloads': commaSeperatedNumber(package.get_value("downloads", 0)), keywords:package.get_value("keywords", []).join(', '), repository:package.get_value("repository", "https://github.com/"), license: package.get_value("license", "Unspecified"), author: author.username, authorPage: '/author?'+url.queryStr({id:author.id}), version:version, versions:versions.join(""), command:command, commandComma:command.replace("'", "\\'"), editButton: edit})
res.renderTemplate("package.html", {name:name, description: markdown.markdown(package.get_value("description", "")), 'short-description': package.get_value("short-description", ""), 'downloads': commaSeperatedNumber(package.get_value("downloads", 0)), keywords:package.get_value("keywords", []).join(', '), repository:package.get_value("repository", "https://github.com/"), license: package.get_value("license", "Unspecified"), author: author.username, authorPage: '/author?'+url.queryStr({id:author.id}), version:version, versions:versions.join(""), command:command, commandComma:command.replace("'", "\\'"), editButton: edit})
app.get("/package", package)
+3 -2
View File
@@ -29,8 +29,9 @@ let newPackage(req, res) = do
if (license == "") do
errResp("License cannot be empty")
return
if (repository == "") do
errResp("Repository cannot be empty")
let repositoryURL = url.URL(repository)
if (not (repositoryURL.protocol && repositoryURL.host && repositoryURL.path)) do
errResp("upload a valid repository URL")
return
if (keywords == "") do
errResp("Keywords cannot be empty")
+4 -2
View File
@@ -31,8 +31,10 @@ let editPackage(req, res) = do
if (license == "") do
errResp("License cannot be empty")
return
if (repository == "") do
errResp("Repository cannot be empty")
let repositoryURL = url.URL(repository)
term.log(repositoryURL, repository)
if (not (repositoryURL.protocol && repositoryURL.host && repositoryURL.path)) do
errResp("upload a valid repository URL")
return
if (keywords == "") do
errResp("Keywords cannot be empty")
+9 -6
View File
@@ -185,6 +185,15 @@ input:focus {
color: var(--accent) !important;
}
.md_pre {
background-color: var(--secondary);
border-radius: 10px;
padding: 1rem;
border: 1px solid var(--primary);
overflow-x: auto;
}
.copyable-pre {
background-color: var(--secondary);
border-radius: 10px;
@@ -205,12 +214,6 @@ input:focus {
word-wrap: break-word;
}
.description {
font-family: 'Trebuchet MS';
white-space: pre-wrap;
word-wrap: break-word;
}
.form {
width: 100%;
max-width: 500px;
+2 -1
View File
@@ -60,7 +60,6 @@
<div class="info">
{{%editButton}}
<h1>{{name}}@{{version}}</h1>
<pre class="description">{{description}}</pre>
<div class="split"></div>
<div class="atributes">
<div>
@@ -83,6 +82,8 @@
onclick="copyToClipboard(event.target.dataset.command)"
data-command="{{command}}"
>{{command}}<div style="float: right;margin-left: 1rem;">📋 Click to Copy</div></pre>
<div class="split"></div>
<div>{{%description}}</div>
</div>
<div class="versions">
<h2>{{downloads}} download(s)</h2>