mirror of
https://github.com/Open-Argon/isotope-server.git
synced 2026-10-28 09:43:51 +00:00
improve home page and add limits to name and version
This commit is contained in:
1 parent
5e85b2cd76
commit
ec50750d2f
10 files changed
+95
-8
No files matched your search
@@ -1,3 +1,6 @@
|
||||
URL="https://change-me.com"
|
||||
domain="change-me.com"
|
||||
port="7030" # default port for the server
|
||||
URL="https://change-me.com" # all urls should be in the format https://change-me.com
|
||||
domain="change-me.com" # domain name
|
||||
port="7030" # default port for the server
|
||||
|
||||
discord_URL="https://discord.gg/XKN79yDa5t" # discord invite link
|
||||
source_code_URL="https://github.com/Open-Argon/isotope-server" # source code link
|
||||
@@ -1,6 +1,9 @@
|
||||
let url = env.get_value("URL","https://isotope.wbell.dev")
|
||||
term.log("URL: "+url)
|
||||
let default_domain = "isotope.wbell.dev"
|
||||
let domain = env.get_value("domain","isotope.wbell.dev")
|
||||
let discord_URL = env.get_value("discord_URL","https://discord.com/invite/XKN79yDa5t")
|
||||
let source_code_URL = env.get_value("source_code_URL","https://github.com/Open-Argon/isotope-server")
|
||||
term.log("domain: "+domain)
|
||||
let port = number(env.get_value("PORT", 7030))
|
||||
term.log("port: "+port)
|
||||
|
||||
+10
-3
@@ -5,11 +5,18 @@ let savePath = path.join([program.cwd, 'data', "packages-db.json"])
|
||||
|
||||
let changes = {n: 0, last: 0}
|
||||
|
||||
let validVersion(version) = do
|
||||
if (version.length < 1 || version.length > 16) return false
|
||||
for (i from 0 to version.length) do
|
||||
if (i > 0 && i < version.length-1 && version[i] not in "abcdefghijklmnopqrstuvwxyz0123456789-.") return false
|
||||
else if (version[i] not in "abcdefghijklmnopqrstuvwxyz0123456789") return false
|
||||
return true
|
||||
|
||||
let validName(name) = do
|
||||
if (name.length < 3) return false
|
||||
if (name.length > 32) return false
|
||||
if (name.length < 3 || name.length > 32) return false
|
||||
for (i from 0 to name.length) do
|
||||
if (name[i] not in "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-.") return false
|
||||
if (i > 0 && i < name.length-1 && name[i] not in "abcdefghijklmnopqrstuvwxyz0123456789-.") return false
|
||||
else if (name[i] not in "abcdefghijklmnopqrstuvwxyz0123456789") return false
|
||||
return true
|
||||
|
||||
let makeChange() = changes.n += 1
|
||||
|
||||
@@ -4,6 +4,11 @@ import "database" as *
|
||||
|
||||
let download(req, res) = do
|
||||
let name = req.query.get_value("name", null)
|
||||
if (name == null) do
|
||||
res.code = 400
|
||||
res.send("Name is required")
|
||||
return
|
||||
name = name.toLower()
|
||||
let version = req.query.get_value("version", "latest")
|
||||
let package = packages.get_value(name)
|
||||
if (package == null) do
|
||||
|
||||
@@ -19,6 +19,10 @@ let push(req, res) = do
|
||||
if (package == null) do
|
||||
res.code = 404
|
||||
return res.send("Package not found")
|
||||
if (version not in package.versions.keys() && not validName(version)) do
|
||||
res.code = 400
|
||||
res.send("Invalid version type")
|
||||
return
|
||||
let acc = account.getByToken(req.headers.get_value("isotope-auth", ""))
|
||||
if (acc == null) do
|
||||
res.code = 403
|
||||
|
||||
@@ -5,6 +5,11 @@ import "url.ar" as urllib
|
||||
|
||||
let search(req, res) = do
|
||||
let name = req.query.get_value("name", null)
|
||||
if (name == null) do
|
||||
res.code = 400
|
||||
res.send("Name is required")
|
||||
return
|
||||
name = name.toLower()
|
||||
let version = req.query.get_value("version", "latest")
|
||||
let package = packages.get_value(name)
|
||||
if (package == null) do
|
||||
|
||||
@@ -1,6 +1,12 @@
|
||||
import "server" as *
|
||||
import "database" as *
|
||||
import "config" as config
|
||||
|
||||
let home(req, res) = do
|
||||
res.renderTemplate("index.html", {})
|
||||
let push_command = "isotope package push"
|
||||
let push_command_latest = "isotope package push --latest"
|
||||
if (config.default_domain != config.domain) do
|
||||
push_command += " " + config.domain
|
||||
push_command_latest += " " + config.domain
|
||||
res.renderTemplate("index.html", {discord_URL: config.discord_URL, source_code_URL: config.source_code_URL, push_command: push_command, push_command_quote: push_command.replace("'", "\\'"), push_command_latest: push_command_latest, push_command_latest_quote: push_command_latest.replace("'", "\\'")})
|
||||
app.get("/", home)
|
||||
@@ -1,4 +1,5 @@
|
||||
import "server" as *
|
||||
import "config" as config
|
||||
import "database" as *
|
||||
import "url.ar" as url
|
||||
import "bleach.ar" as bleach
|
||||
@@ -17,7 +18,12 @@ let package(req, res) = do
|
||||
let version = req.query.get_value("version", "latest")
|
||||
let commandName = name
|
||||
if (version != "latest") commandName += "@"+version
|
||||
let command = shlex.join(["isotope", "install", commandName])
|
||||
let command = ["isotope", "install"]
|
||||
if (config.default_domain != config.domain) do
|
||||
command.append("--remote")
|
||||
command.append(config.domain)
|
||||
command.append(commandName)
|
||||
command = shlex.join(command)
|
||||
let package = packages.get_value(name)
|
||||
if (package == null && version == "latest") do
|
||||
package = {versions:{}, order:{}, name:name}
|
||||
|
||||
@@ -14,6 +14,7 @@ body {
|
||||
padding: 0;
|
||||
color: var(--text);
|
||||
background-color: var(--background);
|
||||
margin-bottom: 2rem;
|
||||
}
|
||||
|
||||
a {
|
||||
|
||||
@@ -45,6 +45,8 @@
|
||||
<meta name="msapplication-TileColor" content="#0b1d28" />
|
||||
<meta name="msapplication-TileImage" content="/mstile-144x144.png" />
|
||||
<meta name="theme-color" content="#0b1d28" />
|
||||
<meta name="description" content="The official package manager for Argon" />
|
||||
<script src="/script.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<div class="content">
|
||||
@@ -132,6 +134,51 @@
|
||||
<input type="submit" value="Search" class="button" />
|
||||
</form>
|
||||
</div>
|
||||
<div>
|
||||
<h1>What is Isotope?</h1>
|
||||
<p>
|
||||
Isotope is the official package manager for
|
||||
<a
|
||||
style="color: var(--primary)"
|
||||
href="https://argon.wbell.dev/"
|
||||
>Argon</a
|
||||
>. It is a simple, fast, and secure package manager for
|
||||
Argon. It is designed to be easy to use and easy to install.
|
||||
</p>
|
||||
<h1>How do I install Isotope?</h1>
|
||||
<p>
|
||||
Isotope comes pre-packaged with <a href="https://github.com/Open-Argon/argon-v3"
|
||||
style="color: var(--primary)">Open Argon's official distribution of the Argon programming language</a>.
|
||||
If you would like to compile Isotope from source, you can find the source code at <a href="https://github.com/Open-Argon/Isotope"
|
||||
style="color: var(--primary)">https://github.com/Open-Argon/Isotope</a> and follow the instructions in the README.
|
||||
</p>
|
||||
<h1>How do I use Isotope?</h1>
|
||||
<p>to access the help menu in isotope, run the following command inside the terminal:</p>
|
||||
<pre class="copyable-pre" onclick="copyToClipboard('isotope help')" data-command="isotope --help">isotope help<div style="float: right;margin-left: 1rem;">📋 Click to Copy</div></pre>
|
||||
<p>If you need any further assistance, please feel free to reach out to us on our <a href="{{discord_URL}}" style="color: var(--primary)">Discord server</a>.</p>
|
||||
<h1>How do I host my own Isotope Server?</h1>
|
||||
<p>
|
||||
If you would like to host your own Isotope server, you can find the source code at <a href="{{source_code_URL}}">{{source_code_URL}}</a>.
|
||||
All you need to do is follow the instructions in the README. If you need any further assistance, please feel free to reach out to us on our <a href="{{discord_URL}}" style="color: var(--primary)">Discord server</a>.
|
||||
</p>
|
||||
<h1>How do I make and upload a package to Isotope?</h1>
|
||||
<p>
|
||||
If you would like to upload a package to Isotope, <a href="/login">login</a> or <a href="/register">register</a> then create an empty folder and run the following command inside the terminal:
|
||||
</p>
|
||||
<pre class="copyable-pre" onclick="copyToClipboard('isotope init')" data-command="isotope create">isotope init<div style="float: right;margin-left: 1rem;">📋 Click to Copy</div></pre>
|
||||
<p>Edit "argon-package.json" and choose a name and version of your package. Note: all names and versions sent to this server have to be lowercase alpha-numeric characters, and can also include "-" and ".". The first and last characters can only be alpha-numeric. All names have to be between 3 and 32 characters long, and all versions types cannot be greater than 16 characters long.</p>
|
||||
<p>Then make a folder called "src" inside the folder you just created, and write all your code inside the folder. Remember, for a package, its recommended to name the main file "init.ar".</p>
|
||||
<p>Once you have written your code, run the following command inside the terminal:</p>
|
||||
<pre class="copyable-pre" onclick="copyToClipboard('isotope package build')" data-command="isotope create">isotope package build<div style="float: right;margin-left: 1rem;">📋 Click to Copy</div></pre>
|
||||
<p>make sure you are in the same folder as "argon-package.json".</p>
|
||||
<p>Then run the following command inside the terminal:</p>
|
||||
<pre class="copyable-pre" onclick="copyToClipboard('{{push_command_quote}}')" data-command="isotope create">{{push_command}}<div style="float: right;margin-left: 1rem;">📋 Click to Copy</div></pre>
|
||||
<p>again, make sure you are in the same folder as "argon-package.json".</p>
|
||||
<p>If you are ready to make a full stable release, run the following command:</p>
|
||||
<pre class="copyable-pre" onclick="copyToClipboard('{{push_command_latest_quote}}')" data-command="isotope create">{{push_command_latest}}<div style="float: right;margin-left: 1rem;">📋 Click to Copy</div></pre>
|
||||
<p>again, make sure you are in the same folder as "argon-package.json".</p>
|
||||
<p>If you need any further assistance, please feel free to reach out to us on our <a href="{{discord_URL}}" style="color: var(--primary)">Discord server</a>.</p>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
Reference in new issue
Block a user