1
0
Fork 0
mirror of https://github.com/SinTan1729/chhoto-url synced 2024-12-26 07:38:36 -06:00

Compare commits

...

2 commits

Author SHA1 Message Date
d278021e1b
fix: Support working inside subdirectories 2024-03-23 18:08:25 -05:00
8dbb6e9bd6
new: Added a dev tag option 2024-03-23 16:07:55 -05:00
2 changed files with 46 additions and 30 deletions

View file

@ -1,29 +1,37 @@
#!/bin/env bash
v_patch=$(cat actix/Cargo.toml | sed -rn 's/^version = "(.+)"$/\1/p')
v_minor=$(echo $v_patch | sed -rn 's/^(.+\..+)\..+$/\1/p')
v_major=$(echo $v_minor | sed -rn 's/^(.+)\..+$/\1/p')
if [ "$1" == "dev" ]; then
name="chhoto-url"
docker build -t $name .
docker tag $name sintan1729/$name:dev
docker push sintan1729/$name:dev
name="chhoto-url"
elif [ "$1" == "release" ]; then
v_patch=$(cat actix/Cargo.toml | sed -rn 's/^version = "(.+)"$/\1/p')
v_minor=$(echo $v_patch | sed -rn 's/^(.+\..+)\..+$/\1/p')
v_major=$(echo $v_minor | sed -rn 's/^(.+)\..+$/\1/p')
docker build -t $name .
name="chhoto-url"
for tag in $v_major $v_minor $v_patch latest
do
docker tag $name sintan1729/$name:$tag
done
docker build -t $name .
echo "Do you want to push these to Docker Hub?"
select yn in "Yes" "No";
do
if [ "$yn"="Yes" ]; then
for tag in $v_major $v_minor $v_patch latest
do
docker push sintan1729/$name:$tag
done
else
echo "Okay! Not pushing."
fi
break
done
for tag in $v_major $v_minor $v_patch latest
do
docker tag $name sintan1729/$name:$tag
done
echo "Do you want to push these to Docker Hub?"
select yn in "Yes" "No";
do
if [ "$yn"="Yes" ]; then
for tag in $v_major $v_minor $v_patch latest
do
docker push sintan1729/$name:$tag
done
else
echo "Okay! Not pushing."
fi
break
done
fi

View file

@ -1,22 +1,30 @@
const getSiteUrl = async () => await fetch("/api/siteurl")
const prepSubdir = (link) => {
let thisPage = new URL(window.location.href);
let subdir = thisPage.pathname;
let out = (subdir+link).replace('//','/');
console.log(out);
return (subdir+link).replace('//','/');
}
const getSiteUrl = async () => await fetch(prepSubdir("/api/siteurl"))
.then(res => res.text())
.then(text => {
if (text == "unset") {
return window.location.host;
return window.location.host.replace(/\/$/,'');
}
else {
return text;
return text.replace(/\/$/,'');
}
});
const getVersion = async () => await fetch("/api/version")
const getVersion = async () => await fetch(prepSubdir("/api/version"))
.then(res => res.text())
.then(text => {
return text;
});
const refreshData = async () => {
let reply = await fetch("/api/all").then(res => res.text());
let reply = await fetch(prepSubdir("/api/all")).then(res => res.text());
if (reply == "logged_out") {
console.log("logged_out");
document.getElementById("container").style.filter = "blur(2px)"
@ -136,7 +144,7 @@ const deleteButton = (shortUrl) => {
if (confirm("Do you want to delete the entry " + shortUrl + "?")) {
document.getElementById("alert-box")?.remove();
showAlert(" ", "black");
fetch(`/api/del/${shortUrl}`, {
fetch(prepSubdir(`/api/del/${shortUrl}`), {
method: "DELETE"
}).then(_ => refreshData());
}
@ -162,7 +170,7 @@ const submitForm = () => {
const longUrl = form.elements["longUrl"];
const shortUrl = form.elements["shortUrl"];
const url = `/api/new`;
const url = prepSubdir("/api/new");
fetch(url, {
method: "POST",
@ -188,7 +196,7 @@ const submitForm = () => {
const submitLogin = () => {
const password = document.getElementById("password");
fetch("/api/login", {
fetch(prepSubdir("/api/login"), {
method: "POST",
body: password.value
}).then(res => {