Compare commits
No commits in common. "258e4f8b5502a557d1252f164bc40b4b1a1c687b" and "01d9d4f28f19a4f32619625bf9e35b9cde803206" have entirely different histories.
258e4f8b55
...
01d9d4f28f
9
LICENSE
9
LICENSE
|
@ -1,9 +0,0 @@
|
||||||
The MIT License (MIT)
|
|
||||||
|
|
||||||
Copyright (c) <year> <copyright holders>
|
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
||||||
|
|
||||||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
||||||
|
|
||||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
13
README.md
13
README.md
|
@ -1,13 +0,0 @@
|
||||||
# Krll
|
|
||||||
Krll, a privacy-friendly URL shortener
|
|
||||||
|
|
||||||
https://krll.me
|
|
||||||
|
|
||||||
## Dev
|
|
||||||
Copy `.env.example` to `.env` and edit it
|
|
||||||
```
|
|
||||||
python -m venv venv
|
|
||||||
source ./venv/bin/activate/
|
|
||||||
pip install -r requirements.txt
|
|
||||||
uvicorn main:app --reload
|
|
||||||
```
|
|
|
@ -1,26 +0,0 @@
|
||||||
// yeah it's a fucking easter egg :P
|
|
||||||
export const dQw4w9WgXcQ = {
|
|
||||||
check: (url) => {
|
|
||||||
try {
|
|
||||||
const urlObj = new URL(url);
|
|
||||||
let videoId = "";
|
|
||||||
|
|
||||||
if (urlObj.host.split(".").slice(-2)[0] === "youtube") {
|
|
||||||
if (urlObj.pathname.split("/")[1] === "watch") {
|
|
||||||
videoId = urlObj.searchParams.get("v");
|
|
||||||
} else {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
} else if (urlObj.host === "youtu.be") {
|
|
||||||
videoId = urlObj.pathname.slice(1);
|
|
||||||
} else {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (videoId ==="dQw4w9WgXcQ") return true;
|
|
||||||
return false;
|
|
||||||
} catch {
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
Binary file not shown.
Before Width: | Height: | Size: 15 KiB |
|
@ -1,22 +1,37 @@
|
||||||
const url_input = document.getElementById("url");
|
const url_input = document.getElementById("url");
|
||||||
const to_shorten_btn = document.getElementById("to-shorten-btn");
|
const to_shorten_btn = document.getElementById("to-shorten-btn");
|
||||||
|
const result_container = document.getElementById("result-container");
|
||||||
const short_url = document.getElementById("short-url");
|
const short_url = document.getElementById("short-url");
|
||||||
const qr_code = document.getElementById("qr-code");
|
const qr_code = document.getElementById("qr-code");
|
||||||
const error_message = document.getElementById("error");
|
const error_message = document.getElementById("error");
|
||||||
const copy_message = document.getElementById("copied");
|
const copy_message = document.getElementById("copied");
|
||||||
|
|
||||||
const shorten = async () => {
|
to_shorten_btn.addEventListener("click", shorten);
|
||||||
const original_url = url_input.value;
|
addEventListener("keydown", (event) => {if(event.key == "Enter") shorten;});
|
||||||
|
|
||||||
|
short_url.addEventListener("click", event => {
|
||||||
|
// copy the short url to clipboard
|
||||||
|
navigator.clipboard.writeText(event.target.innerText)
|
||||||
|
.then(() => {
|
||||||
|
// show a message
|
||||||
|
copy_message.style.opacity = "1";
|
||||||
|
setTimeout(() => copy_message.style.opacity = "0", 3000);
|
||||||
|
})
|
||||||
|
.catch(error => {
|
||||||
|
alert("An error has occurred...\n" + error);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
const shorten = async () => {
|
||||||
|
const original_url = url_input.value
|
||||||
// check if the url input is empty
|
// check if the url input is empty
|
||||||
if (original_url.length === 0) {
|
if (original_url.length === 0) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const { dQw4w9WgXcQ } = await import("./dQw4w9WgXcQ.js");
|
// Easter egg: rick roll
|
||||||
if (dQw4w9WgXcQ.check(original_url)) {
|
if (rickroll.check(original_url)){
|
||||||
location.href = "https://youtu.be/dQw4w9WgXcQ";
|
window.location.replace("https://youtu.be/dQw4w9WgXcQ");
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// shorten the long url
|
// shorten the long url
|
||||||
|
@ -37,7 +52,7 @@ const shorten = async () => {
|
||||||
error_message.style.display = "block";
|
error_message.style.display = "block";
|
||||||
setTimeout(() => error_message.style.display = "none", 5000);
|
setTimeout(() => error_message.style.display = "none", 5000);
|
||||||
} else {
|
} else {
|
||||||
// some error is occured in the server!
|
// there is some problems in the server!
|
||||||
alert("Sorry, an error has occured in the server...");
|
alert("Sorry, an error has occured in the server...");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -55,18 +70,31 @@ const shorten = async () => {
|
||||||
qr_code.alt = result;
|
qr_code.alt = result;
|
||||||
}
|
}
|
||||||
|
|
||||||
to_shorten_btn.addEventListener("click", shorten);
|
const rickroll = {
|
||||||
addEventListener("keydown", (event) => { if (event.key === "Enter") shorten() });
|
check: (url)=>{
|
||||||
|
try {
|
||||||
|
const urlObj = new URL(url);
|
||||||
|
let videoId = "";
|
||||||
|
if (urlObj.host.split(".").slice(-2)[0] === "youtube") {
|
||||||
|
if (urlObj.pathname.split("/")[1] === "watch") {
|
||||||
|
videoId = urlObj.searchParams.get("v");
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (urlObj.host === "youtu.be") {
|
||||||
|
videoId = urlObj.pathname.slice(1);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
if (videoId ==="dQw4w9WgXcQ") return true
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
catch {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
short_url.addEventListener("click", event => {
|
|
||||||
// copy the short url to clipboard
|
|
||||||
navigator.clipboard.writeText(event.target.innerText)
|
|
||||||
.then(() => {
|
|
||||||
// show a message
|
|
||||||
copy_message.style.opacity = "1";
|
|
||||||
setTimeout(() => copy_message.style.opacity = "0", 3000);
|
|
||||||
})
|
|
||||||
.catch(error => {
|
|
||||||
alert("An error has occurred...\n" + error);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
{% extends "layout.html" %}
|
{% extends "layout.html" %}
|
||||||
{% block title %}About Krll{% endblock %}
|
{% block title %}Krll - URL Shortener{% endblock %}
|
||||||
|
|
||||||
{% block head %}
|
{% block head %}
|
||||||
{{ super() }}
|
{{ super() }}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
{% extends "layout.html" %}
|
{% extends "layout.html" %}
|
||||||
{% block title %}Krll URL Shortener{% endblock %}
|
{% block title %}Krll - URL Shortener{% endblock %}
|
||||||
|
|
||||||
{% block head %}
|
{% block head %}
|
||||||
{{ super() }}
|
{{ super() }}
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
<meta charset="UTF-8">
|
<meta charset="UTF-8">
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
<title>{% block title %}{% endblock %}</title>
|
<title>{% block title %}{% endblock %}</title>
|
||||||
<link rel="icon" href="{{ url_for('static', path='/favicon.ico') }}">
|
<link rel="icon" href="favicon.ico" type="image/x-icon">
|
||||||
<link rel="stylesheet" href="{{ url_for('static', path='/root.css') }}">
|
<link rel="stylesheet" href="{{ url_for('static', path='/root.css') }}">
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
</head>
|
</head>
|
||||||
|
|
Loading…
Reference in a new issue