adding list all urls, cleaning up
This commit is contained in:
@@ -1,3 +1,4 @@
|
|||||||
tiny0/__pycache__
|
tiny0/__pycache__
|
||||||
tiny0/database.db
|
tiny0/database.db
|
||||||
venv
|
venv
|
||||||
|
.venv
|
||||||
Binary file not shown.
+22
-5
@@ -10,6 +10,7 @@ from tiny0.config import WEBSITE_DOMAIN
|
|||||||
def index():
|
def index():
|
||||||
# Create a instance of the form
|
# Create a instance of the form
|
||||||
form = URLForm()
|
form = URLForm()
|
||||||
|
base_url = url_for('index', _external=True).split('://')[1]
|
||||||
|
|
||||||
# If the form was valid
|
# If the form was valid
|
||||||
if form.validate_on_submit():
|
if form.validate_on_submit():
|
||||||
@@ -38,7 +39,7 @@ def index():
|
|||||||
# Else if the form was invalid or not submitted
|
# Else if the form was invalid or not submitted
|
||||||
else:
|
else:
|
||||||
# Return the index page with the form
|
# Return the index page with the form
|
||||||
return render_template("index.html", form=form)
|
return render_template("index.html", form=form, base_url=base_url)
|
||||||
|
|
||||||
# Shortened url route
|
# Shortened url route
|
||||||
@app.route("/<token>")
|
@app.route("/<token>")
|
||||||
@@ -118,10 +119,26 @@ def report():
|
|||||||
# Return the report page with the form
|
# Return the report page with the form
|
||||||
return render_template("report.html", form=form)
|
return render_template("report.html", form=form)
|
||||||
|
|
||||||
# Donate route
|
# url list_urls route
|
||||||
@app.route("/donate")
|
@app.route("/list_urls", methods=['GET', 'POST'])
|
||||||
def donate():
|
def list_urls():
|
||||||
return render_template("donate.html")
|
try:
|
||||||
|
#queried = URL.query.order_by(URL.id.desc()).all()
|
||||||
|
with app.app_context():
|
||||||
|
queried = (
|
||||||
|
db.session.query(URL, Reports.message)
|
||||||
|
.outerjoin(Reports, URL.token == Reports.token)
|
||||||
|
.order_by(URL.id.desc())
|
||||||
|
.all()
|
||||||
|
)
|
||||||
|
# Return the list_all page with the form
|
||||||
|
base_url = url_for('index', _external=True).split('://')[1]
|
||||||
|
return render_template("list_all.html", queried=queried,base_url=base_url)
|
||||||
|
|
||||||
|
# Else if the form was invalid or not submitted
|
||||||
|
except Exception as err:
|
||||||
|
# Return 500 error
|
||||||
|
return render_template("error.html", error_code=500, error_message=err), 500
|
||||||
|
|
||||||
# Removed url route
|
# Removed url route
|
||||||
@app.route("/removed")
|
@app.route("/removed")
|
||||||
|
|||||||
@@ -1,10 +0,0 @@
|
|||||||
{% extends "layout.html" %}
|
|
||||||
|
|
||||||
{% block body %}
|
|
||||||
<div class="donation">
|
|
||||||
<h1>Patreon</h1>
|
|
||||||
<h2><a href="https://www.patreon.com/xemeds" target="_blank">patreon.com/xemeds</a></h2>
|
|
||||||
<h1>Bitcoin</h1>
|
|
||||||
<p>1Mg55rPVuQ2P8zKsCcLdsmgqH24uLXfLbR</p>
|
|
||||||
</div>
|
|
||||||
{% endblock %}
|
|
||||||
@@ -6,7 +6,7 @@
|
|||||||
{{ form.hidden_tag() }}
|
{{ form.hidden_tag() }}
|
||||||
{{ form.url(placeholder="Enter the URL here", autofocus=true, class="feedback-input") }}
|
{{ form.url(placeholder="Enter the URL here", autofocus=true, class="feedback-input") }}
|
||||||
<div class="token">
|
<div class="token">
|
||||||
<h3>tiny0.cc/</h3>
|
<h3>{{ base_url }}</h3>
|
||||||
{{ form.token(placeholder="Use custom alias (optional)", class="feedback-input") }}
|
{{ form.token(placeholder="Use custom alias (optional)", class="feedback-input") }}
|
||||||
</div>
|
</div>
|
||||||
{{ form.submit(class="button") }}
|
{{ form.submit(class="button") }}
|
||||||
|
|||||||
@@ -13,17 +13,17 @@
|
|||||||
<script src="https://code.jquery.com/jquery-3.4.1.js"></script>
|
<script src="https://code.jquery.com/jquery-3.4.1.js"></script>
|
||||||
<script src="https://kit.fontawesome.com/a076d05399.js"></script>
|
<script src="https://kit.fontawesome.com/a076d05399.js"></script>
|
||||||
|
|
||||||
<title>tiny0 - Custom URL Shortener</title>
|
<title>URL Shortener</title>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<nav>
|
<nav>
|
||||||
<ul>
|
<ul>
|
||||||
<li class="logo">tiny0 - URL Shortener</li>
|
<li class="logo">URL Shortener</li>
|
||||||
<li class="items"><a href="{{ url_for('index') }}">Shortener</a></li>
|
<li class="items"><a href="{{ url_for('index') }}">Shortener</a></li>
|
||||||
|
<li class="items"><a href="{{ url_for('list_urls') }}">List All</a></li>
|
||||||
<li class="items"><a href="{{ url_for('tracker') }}">Tracker</a></li>
|
<li class="items"><a href="{{ url_for('tracker') }}">Tracker</a></li>
|
||||||
<li class="items"><a href="{{ url_for('lookup') }}">Lookup</a></li>
|
<li class="items"><a href="{{ url_for('lookup') }}">Lookup</a></li>
|
||||||
<li class="items"><a href="{{ url_for('report') }}">Report</a></li>
|
<li class="items"><a href="{{ url_for('report') }}">Report</a></li>
|
||||||
<li class="items"><a href="{{ url_for('donate') }}">Donate</a></li>
|
|
||||||
<li class="btn"><a href="#"><i class="fas fa-bars"></i></a></li>
|
<li class="btn"><a href="#"><i class="fas fa-bars"></i></a></li>
|
||||||
</ul>
|
</ul>
|
||||||
</nav>
|
</nav>
|
||||||
|
|||||||
@@ -0,0 +1,39 @@
|
|||||||
|
{% extends "layout.html" %}
|
||||||
|
|
||||||
|
{% block body %}
|
||||||
|
|
||||||
|
<div class="url-form">
|
||||||
|
<h1>< List of shortened URL's ></h1>
|
||||||
|
<table>
|
||||||
|
<tr>
|
||||||
|
<th class="clicks"><b>Original URL</b></th>
|
||||||
|
<th class="clicks"><b>Shortened URL</b></th>
|
||||||
|
<th class="clicks"><b>Clicks</b></th>
|
||||||
|
<th class="clicks"><b>Reported?</b></th>
|
||||||
|
</tr>
|
||||||
|
{% if queried and base_url %}
|
||||||
|
{% for url, message in queried %}
|
||||||
|
<tr>
|
||||||
|
<td class="feedback-input">{{ url.url }}</td>
|
||||||
|
<td class="feedback-input">{{ base_url }}{{ url.token }}</td>
|
||||||
|
<td class="feedback-input">{{ url.clicks }}</td>
|
||||||
|
<td class="feedback-input">
|
||||||
|
{% if message %}
|
||||||
|
<span class="report-message" title="{{ message }}">Reported!</span>
|
||||||
|
{% endif %}
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
{% endfor %}
|
||||||
|
{% endif %}
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<style>
|
||||||
|
/* Add some CSS for the tooltip styling */
|
||||||
|
.report-message {
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
|
||||||
|
</style>
|
||||||
|
|
||||||
|
{% endblock %}
|
||||||
@@ -2,10 +2,10 @@
|
|||||||
|
|
||||||
{% block body %}
|
{% block body %}
|
||||||
<form method="POST" action="" class="url-form">
|
<form method="POST" action="" class="url-form">
|
||||||
<h1>< Report ></h1>
|
<h1>< Report the link ></h1>
|
||||||
{{ form.hidden_tag() }}
|
{{ form.hidden_tag() }}
|
||||||
{{ form.url(placeholder="Enter the short URL", autofocus=true, class="feedback-input") }}
|
{{ form.url(placeholder="Enter the short URL", autofocus=true, class="feedback-input") }}
|
||||||
{{ form.message(placeholder="Enter a short message explaining the reason of your report", class="feedback-input") }}
|
{{ form.message(placeholder="Enter a short message explaining the reason of you reporting the url", class="feedback-input") }}
|
||||||
{{ form.submit(class="button") }}
|
{{ form.submit(class="button") }}
|
||||||
{% if form.errors %}
|
{% if form.errors %}
|
||||||
<div class="form-errors">
|
<div class="form-errors">
|
||||||
|
|||||||
Reference in New Issue
Block a user