Added the url page and changed the title to an anchor tag

This commit is contained in:
xemeds
2020-07-20 14:09:03 +00:00
parent 0db137daf5
commit 2de586b87b
5 changed files with 81 additions and 50 deletions
+1 -1
View File
@@ -12,7 +12,7 @@ def index():
# If the form was valid # If the form was valid
if form.validate_on_submit(): if form.validate_on_submit():
return "Valid URL: " + form.url.data return render_template("url.html", url=form.url.data)
# If the form was invalid or not submitted # If the form was invalid or not submitted
else: else:
+11 -5
View File
@@ -9,7 +9,7 @@ body {
} }
.header { .headers {
position: absolute; position: absolute;
margin-left: auto; margin-left: auto;
margin-right: auto; margin-right: auto;
@@ -19,9 +19,15 @@ body {
text-align: center; text-align: center;
} }
.title { .title:link {
color: #ffffff; color: #bb86fc;
text-decoration: none;
font-size: 50px; font-size: 50px;
font-weight: bold;
}
.title:hover {
color: #7b59a5;
} }
.desc { .desc {
@@ -61,7 +67,7 @@ body {
border-color: #7b59a5; border-color: #7b59a5;
} }
.submit { .button {
background: #bb86fc; background: #bb86fc;
border: 2px solid #bb86fc; border: 2px solid #bb86fc;
border-radius: 3px; border-radius: 3px;
@@ -71,7 +77,7 @@ body {
margin: 0 3% 0 1%; margin: 0 3% 0 1%;
} }
.submit:hover { .button:hover {
background: #7b59a5; background: #7b59a5;
border-color: #7b59a5; border-color: #7b59a5;
} }
+42 -41
View File
@@ -3,58 +3,59 @@
{% block body %} {% block body %}
{% if form.url.errors %} {% if form.url.errors %}
<body> <body>
<div class="header"> <div class="headers">
<h1 class="title">tiny0</h1> <a class="title" href="{{ url_for('index') }}">tiny0</a>
<h1 class="desc">Custom URL Shortener</h1> <h1 class="desc">Custom URL Shortener</h1>
</div> </div>
{% else %} {% else %}
<body onload="typeTitle()"> <body onload="typeTitle()">
<div class="header"> <div class="headers">
<h1 id="title" class="title"></h1> <a class="title" id="title" href="{{ url_for('index') }}"></a>
<h1 id="desc" class="desc"></h1> <h1 id="desc" class="desc"></h1>
</div> </div>
{% endif %} {% endif %}
<div class="container">
<form method="POST" action="">
{{ form.hidden_tag() }}
<div class="inputs">
{{ form.url(placeholder="Enter the URL here", class="url") }}
{{ form.submit(class="button") }}
</div>
</form>
{% if form.url.errors %}
{% for error in form.url.errors %}
<p class="error-message">{{ error }}</p>
{% endfor %}
{% endif %}
</div>
<div class="container"> {% if not form.url.errors %}
<form method="POST" action=""> <script>
{{ form.hidden_tag() }} var i = 0;
<div class="inputs"> var title_text = "tiny0";
{{ form.url(placeholder="Enter the URL here", class="url") }} var desc_text = "Custom URL Shortener";
{{ form.submit(class="submit") }} var speed = 120;
</div>
</form>
{% if form.url.errors %}
{% for error in form.url.errors %}
<p class="error-message">{{ error }}</p>
{% endfor %}
{% endif %}
</div>
<script> function typeTitle() {
var i = 0; if (i < title_text.length) {
var title_text = "tiny0"; document.getElementById("title").innerHTML += title_text.charAt(i);
var desc_text = "Custom URL Shortener"; i++;
var speed = 120; setTimeout(typeTitle, speed);
}
function typeTitle() { else {
if (i < title_text.length) { i = 0;
document.getElementById("title").innerHTML += title_text.charAt(i); setTimeout(typeDesc, 200)
i++; }
setTimeout(typeTitle, speed);
} }
else {
i = 0;
setTimeout(typeDesc, 200)
}
}
function typeDesc() { function typeDesc() {
if (i < desc_text.length) { if (i < desc_text.length) {
document.getElementById("desc").innerHTML += desc_text.charAt(i); document.getElementById("desc").innerHTML += desc_text.charAt(i);
i++; i++;
setTimeout(typeDesc, speed); setTimeout(typeDesc, speed);
}
} }
} </script>
</script> {% endif %}
</body> </body>
{% endblock %} {% endblock %}
+1 -3
View File
@@ -11,9 +11,7 @@
<div id="page-container"> <div id="page-container">
<div id="content-wrap"> <div id="content-wrap">
{% block body %}{% endblock %}
{% block body %}{% endblock %}
</div> </div>
</div> </div>
+26
View File
@@ -0,0 +1,26 @@
{% extends "layout.html" %}
{% block body %}
<body>
<div class="headers">
<a class="title" href="{{ url_for('index') }}">tiny0</a>
<h1 class="desc">Custom URL Shortener</h1>
</div>
<div class="container">
<div class="inputs">
<input type="text" value="{{ url }}" id="url" class="url" readonly>
<button onclick="copyURL()" class="button">Copy</button>
</div>
</div>
<script>
function copyURL() {
var url = document.getElementById("url");
url.select();
url.setSelectionRange(0, 99999)
document.execCommand("copy");
}
</script>
</body>
{% endblock %}