Add admin panel to delete URLs from the browser. Add copyright notice.
This commit is contained in:
parent
332d82e97a
commit
8288b3624e
3
.gitignore
vendored
3
.gitignore
vendored
|
@ -108,3 +108,6 @@ venv.bak/
|
||||||
|
|
||||||
# Databases
|
# Databases
|
||||||
*.db
|
*.db
|
||||||
|
|
||||||
|
# Configuration files
|
||||||
|
config.yml
|
||||||
|
|
2
LICENSE
2
LICENSE
|
@ -1,4 +1,4 @@
|
||||||
Copyright 2019 Steven Spangler
|
Copyright 2019 Steven Spangler, Kevin Alberts, I.C.T.S.V. Inter-Actief
|
||||||
|
|
||||||
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:
|
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:
|
||||||
|
|
||||||
|
|
69
config.default.yml
Normal file
69
config.default.yml
Normal file
|
@ -0,0 +1,69 @@
|
||||||
|
# String: Username to make admin API requests
|
||||||
|
# Default: 'admin'
|
||||||
|
admin_username: 'admin'
|
||||||
|
|
||||||
|
# String: Plaintext password to make admin API requests
|
||||||
|
# Safe to remove if admin_hashed_password is set
|
||||||
|
# Default: unset
|
||||||
|
#admin_password:
|
||||||
|
|
||||||
|
# String: Hashed password (bcrypt) to make admin API requests - Preferred over plaintext, use securepass.sh to generate
|
||||||
|
# Please note that authentication takes noticeably longer than using plaintext password
|
||||||
|
# Don't include the <username>: segment, just the hash
|
||||||
|
# Default: unset (required to start application)
|
||||||
|
admin_hashed_password: ''
|
||||||
|
|
||||||
|
# Boolean: Disables API. If set to true, admin_password/admin_hashed_password do not need to be set.
|
||||||
|
# Default: false
|
||||||
|
disable_api: false
|
||||||
|
|
||||||
|
# String: Secret key used for cookies (used for storage of messages)
|
||||||
|
# This should be a 12-16 character randomized string with letters, numbers, and symbols
|
||||||
|
# Default: unset (required to start application)
|
||||||
|
secret_key: ''
|
||||||
|
|
||||||
|
# String: Filename of the URL database without extension
|
||||||
|
# Default: 'urls'
|
||||||
|
database_name: 'urls'
|
||||||
|
|
||||||
|
# Integer: Length of random short URLs by default
|
||||||
|
# Default: 4
|
||||||
|
random_length: 5
|
||||||
|
|
||||||
|
# String: Allowed URL characters
|
||||||
|
# Default: ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_
|
||||||
|
allowed_chars: 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_©®‼⁉⃣™ℹ↔↕↖↗↘↙↩↪⌚⌛⌨⏏⏩⏪⏫⏬⏭⏮⏯⏰⏱⏲⏳⏸⏹⏺Ⓜ▪▫▶◀◻◼◽◾☀☁☂☃☄☎☑☔☕☘☝☠☢☣☦☪☮☯☸☹☺♀♂♈♉♊♋♌♍♎♏♐♑♒♓♟♠♣♥♦♨♻♾♿⚒⚓⚔⚕⚖⚗⚙⚛⚜⚠⚡⚪⚫⚰⚱⚽⚾⛄⛅⛈⛎⛏⛑⛓⛔⛩⛪⛰⛱⛲⛳⛴⛵⛷⛸⛹⛺⛽✂✅✈✉✊✋✌✍✏✒✔✖✝✡✨✳✴❄❇❌❎❓❔❕❗❣❤➕➖➗➡➰➿⤴⤵⬅⬆⬇⬛⬜⭐⭕〰〽㊗㊙️🀄🃏🅰🅱🅾🅿🆎🆑🆒🆓🆔🆕🆖🆗🆘🆙🆚🇦🇧🇨🇩🇪🇫🇬🇭🇮🇯🇰🇱🇲🇳🇴🇵🇶🇷🇸🇹🇺🇻🇼🇽🇾🇿🈁🈂🈚🈯🈲🈳🈴🈵🈶🈷🈸🈹🈺🉐🉑🌀🌁🌂🌃🌄🌅🌆🌇🌈🌉🌊🌋🌌🌍🌎🌏🌐🌑🌒🌓🌔🌕🌖🌗🌘🌙🌚🌛🌜🌝🌞🌟🌠🌡🌤🌥🌦🌧🌨🌩🌪🌫🌬🌭🌮🌯🌰🌱🌲🌳🌴🌵🌶🌷🌸🌹🌺🌻🌼🌽🌾🌿🍀🍁🍂🍃🍄🍅🍆🍇🍈🍉🍊🍋🍌🍍🍎🍏🍐🍑🍒🍓🍔🍕🍖🍗🍘🍙🍚🍛🍜🍝🍞🍟🍠🍡🍢🍣🍤🍥🍦🍧🍨🍩🍪🍫🍬🍭🍮🍯🍰🍱🍲🍳🍴🍵🍶🍷🍸🍹🍺🍻🍼🍽🍾🍿🎀🎁🎂🎄🎅🎆🎇🎈🎉🎊🎋🎌🎍🎎🎏🎐🎑🎒🎓🎖🎗🎙🎚🎛🎞🎟🎠🎡🎢🎣🎤🎥🎦🎧🎨🎩🎪🎫🎬🎭🎮🎯🎰🎱🎲🎳🎴🎵🎶🎷🎸🎹🎺🎻🎼🎽🎾🎿🏀🏁🏂🏃🏄🏅🏆🏇🏈🏉🏊🏋🏌🏍🏎🏏🏐🏑🏒🏓🏔🏕🏖🏗🏘🏙🏚🏛🏜🏝🏞🏟🏠🏡🏢🏣🏤🏥🏦🏧🏨🏩🏪🏫🏬🏭🏮🏯🏰🏳🏴🏵🏷🏸🏹🏺🏻🏼🏽🏾🏿🐀🐁🐂🐃🐄🐅🐆🐇🐈🐉🐊🐋🐌🐍🐎🐏🐐🐑🐒🐓🐔🐕🐖🐗🐘🐙🐚🐛🐜🐝🐞🐟🐠🐡🐢🐣🐤🐥🐦🐧🐨🐩🐪🐫🐬🐭🐮🐯🐰🐱🐲🐳🐴🐵🐶🐷🐸🐹🐺🐻🐼🐽🐾🐿👀👁👂👃👄👅👆👇👈👉👊👋👌👍👎👏👐👑👒👓👔👕👖👗👘👙👚👛👜👝👞👟👠👡👢👣👤👥👦👧👨👩👪👫👬👭👮👯👰👱👲👳👴👵👶👷👸👹👺👻👼👽👿💀💁💂💃💄💅💆💇💈💉💊💋💌💍💎💏💐💑💒💓💔💕💖💗💘💙💚💛💜💝💞💟💠💡💢💣💤💥💦💧💨💩💪💫💬💭💮💯💰💱💲💳💴💵💶💷💸💹💺💻💼💽💾💿📀📁📂📃📄📅📆📇📈📉📊📋📌📍📎📏📐📑📒📓📔📕📖📗📘📙📚📛📜📝📞📟📠📡📢📣📤📥📦📧📨📩📪📫📬📭📮📯📰📱📲📳📴📵📶📷📸📹📺📻📼📽📿🔀🔁🔂🔃🔄🔅🔆🔇🔈🔉🔊🔋🔌🔍🔎🔏🔐🔑🔒🔓🔔🔕🔖🔗🔘🔙🔚🔛🔜🔝🔞🔟🔠🔡🔢🔣🔤🔥🔦🔧🔨🔩🔪🔫🔬🔭🔮🔯🔰🔱🔲🔳🔴🔵🔶🔷🔸🔹🔺🔻🔼🔽🕉🕊🕋🕌🕍🕎🕐🕑🕒🕓🕔🕕🕖🕗🕘🕙🕚🕛🕜🕝🕞🕟🕠🕡🕢🕣🕤🕥🕦🕧🕯🕰🕳🕴🕵🕶🕷🕸🕹🕺🖇🖊🖋🖌🖍🖐🖕🖖🖤🖥🖨🖱🖲🖼🗂🗃🗄🗑🗒🗓🗜🗝🗞🗡🗣🗨🗯🗳🗺🗻🗼🗽🗾🗿😀😁😂😃😄😅😆😇😈😉😊😋😌😍😎😏😐😑😒😓😔😕😖😗😘😙😚😛😜😝😞😟😠😡😢😣😤😥😦😧😨😩😪😫😬😭😮😯😰😱😲😳😴😵😶😷😸😹😺😻😼😽😾😿🙀🙁🙂🙃🙄🙅🙆🙇🙈🙉🙊🙋🙌🙍🙎🙏🚀🚁🚂🚃🚄🚅🚆🚇🚈🚉🚊🚋🚌🚍🚎🚏🚐🚑🚒🚓🚔🚕🚖🚗🚘🚙🚚🚛🚜🚝🚞🚟🚠🚡🚢🚣🚤🚥🚦🚧🚨🚩🚪🚫🚬🚭🚮🚯🚰🚱🚲🚳🚴🚵🚶🚷🚸🚹🚺🚻🚼🚽🚾🚿🛀🛁🛂🛃🛄🛅🛋🛌🛍🛎🛏🛐🛑🛒🛠🛡🛢🛣🛤🛥🛩🛫🛬🛰🛳🛴🛵🛶🛷🛸🛹🤐🤑🤒🤓🤔🤕🤖🤗🤘🤙🤚🤛🤜🤝🤞🤟🤠🤡🤢🤣🤤🤥🤦🤧🤨🤩🤪🤫🤬🤭🤮🤯🤰🤱🤲🤳🤴🤵🤶🤷🤸🤹🤺🤼🤽🤾🥀🥁🥂🥃🥄🥅🥇🥈🥉🥊🥋🥌🥍🥎🥏🥐🥑🥒🥓🥔🥕🥖🥗🥘🥙🥚🥛🥜🥝🥞🥟🥠🥡🥢🥣🥤🥥🥦🥧🥨🥩🥪🥫🥬🥭🥮🥯🥰🥳🥴🥵🥶🥺🥼🥽🥾🥿🦀🦁🦂🦃🦄🦅🦆🦇🦈🦉🦊🦋🦌🦍🦎🦏🦐🦑🦒🦓🦔🦕🦖🦗🦘🦙🦚🦛🦜🦝🦞🦟🦠🦡🦢🦰🦱🦲🦳🦴🦵🦶🦷🦸🦹🧀🧁🧂🧐🧑🧒🧓🧔🧕🧖🧗🧘🧙🧚🧛🧜🧝🧞🧟🧠🧡🧢🧣🧤🧥🧦🧧🧨🧩🧪🧫🧬🧭🧮🧯🧰🧱🧲🧳🧴🧵🧶🧷🧸🧹🧺🧻🧼🧽🧾🧿'
|
||||||
|
|
||||||
|
|
||||||
|
# Amount of time in seconds to spend generating random short URLs until timeout
|
||||||
|
# Default: 5
|
||||||
|
random_gen_timeout: 5
|
||||||
|
|
||||||
|
# String: Name shown on tab while on site and on page header
|
||||||
|
# Default: 'liteshort'
|
||||||
|
site_name: 'I.C.T.S.V. Inter-/Actief/ URL Shortener'
|
||||||
|
|
||||||
|
# String: Domain where the shortlinks will be served from. Useful if using the web interface on a subdomain.
|
||||||
|
# If not set, it is automatically taken from the URL the shorten request is sent to.
|
||||||
|
# If you don't know, leave unset
|
||||||
|
# Default: unset
|
||||||
|
site_domain:
|
||||||
|
|
||||||
|
# String: Subdomain to host the web interface on.
|
||||||
|
# Useful if you want the shorturls on the short domain but the web interface on a subdomain.
|
||||||
|
# If you don't know, leave unset
|
||||||
|
# Default: unset
|
||||||
|
subdomain:
|
||||||
|
|
||||||
|
# String: URL which takes you to the most recent short URL's destination
|
||||||
|
# Short URLs cannot be created with this string if set
|
||||||
|
# Default: l
|
||||||
|
latest: 'l'
|
||||||
|
|
||||||
|
# Boolean: Show link to project repository on GitHub at bottom right corner of page
|
||||||
|
# Default: true
|
||||||
|
show_github_link: false
|
||||||
|
|
||||||
|
# Integer: How many items to show per page in the admin interface
|
||||||
|
# Default: 20
|
||||||
|
admin_links_per_page: 20
|
65
config.yml
65
config.yml
|
@ -1,65 +0,0 @@
|
||||||
# String: Username to make admin API requests
|
|
||||||
# Default: 'admin'
|
|
||||||
admin_username: 'admin'
|
|
||||||
|
|
||||||
# String: Plaintext password to make admin API requests
|
|
||||||
# Safe to remove if admin_hashed_password is set
|
|
||||||
# Default: unset
|
|
||||||
#admin_password:
|
|
||||||
|
|
||||||
# String: Hashed password (bcrypt) to make admin API requests - Preferred over plaintext, use securepass.sh to generate
|
|
||||||
# Please note that authentication takes noticeably longer than using plaintext password
|
|
||||||
# Don't include the <username>: segment, just the hash
|
|
||||||
# Default: unset (required to start application)
|
|
||||||
admin_hashed_password:
|
|
||||||
|
|
||||||
# Boolean: Disables API. If set to true, admin_password/admin_hashed_password do not need to be set.
|
|
||||||
# Default: false
|
|
||||||
disable_api: false
|
|
||||||
|
|
||||||
# String: Secret key used for cookies (used for storage of messages)
|
|
||||||
# This should be a 12-16 character randomized string with letters, numbers, and symbols
|
|
||||||
# Default: unset (required to start application)
|
|
||||||
secret_key:
|
|
||||||
|
|
||||||
# String: Filename of the URL database without extension
|
|
||||||
# Default: 'urls'
|
|
||||||
database_name: 'urls'
|
|
||||||
|
|
||||||
# Integer: Length of random short URLs by default
|
|
||||||
# Default: 4
|
|
||||||
random_length: 4
|
|
||||||
|
|
||||||
# String: Allowed URL characters
|
|
||||||
# Default: ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_
|
|
||||||
allowed_chars: 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_'
|
|
||||||
|
|
||||||
# Amount of time in seconds to spend generating random short URLs until timeout
|
|
||||||
# Default: 5
|
|
||||||
random_gen_timeout: 5
|
|
||||||
|
|
||||||
# String: Name shown on tab while on site and on page header
|
|
||||||
# Default: 'liteshort'
|
|
||||||
site_name: 'liteshort'
|
|
||||||
|
|
||||||
# String: Domain where the shortlinks will be served from. Useful if using the web interface on a subdomain.
|
|
||||||
# If not set, it is automatically taken from the URL the shorten request is sent to.
|
|
||||||
# If you don't know, leave unset
|
|
||||||
# Default: unset
|
|
||||||
site_domain:
|
|
||||||
|
|
||||||
# String: Subdomain to host the web interface on.
|
|
||||||
# Useful if you want the shorturls on the short domain but the web interface on a subdomain.
|
|
||||||
# If you don't know, leave unset
|
|
||||||
# Default: unset
|
|
||||||
subdomain:
|
|
||||||
|
|
||||||
# String: URL which takes you to the most recent short URL's destination
|
|
||||||
# Short URLs cannot be created with this string if set
|
|
||||||
# Default: l
|
|
||||||
latest: 'l'
|
|
||||||
|
|
||||||
# Boolean: Show link to project repository on GitHub at bottom right corner of page
|
|
||||||
# Default: true
|
|
||||||
show_github_link: true
|
|
||||||
|
|
83
liteshort.py
83
liteshort.py
|
@ -1,9 +1,10 @@
|
||||||
# Copyright (c) 2019 Steven Spangler <132@ikl.sh>
|
# Copyright (c) 2019 Steven Spangler <132@ikl.sh>, Kevin Alberts <kevin@kevinalberts.nl>
|
||||||
# This file is part of liteshort by 132ikl
|
# This file is part of liteshort by 132ikl
|
||||||
# This software is license under the MIT license. It should be included in your copy of this software.
|
# This software is license under the MIT license. It should be included in your copy of this software.
|
||||||
# A copy of the MIT license can be obtained at https://mit-license.org/
|
# A copy of the MIT license can be obtained at https://mit-license.org/
|
||||||
|
|
||||||
from flask import Flask, current_app, flash, g, jsonify, make_response, redirect, render_template, request, send_from_directory, url_for
|
from flask import Flask, current_app, flash, g, jsonify, make_response, redirect, render_template, request, \
|
||||||
|
send_from_directory, url_for, session
|
||||||
import bcrypt
|
import bcrypt
|
||||||
import os
|
import os
|
||||||
import random
|
import random
|
||||||
|
@ -22,13 +23,14 @@ def load_config():
|
||||||
req_options = {'admin_username': 'admin', 'database_name': "urls", 'random_length': 4,
|
req_options = {'admin_username': 'admin', 'database_name': "urls", 'random_length': 4,
|
||||||
'allowed_chars': 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_',
|
'allowed_chars': 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_',
|
||||||
'random_gen_timeout': 5, 'site_name': 'liteshort', 'site_domain': None, 'show_github_link': True,
|
'random_gen_timeout': 5, 'site_name': 'liteshort', 'site_domain': None, 'show_github_link': True,
|
||||||
'secret_key': None, 'disable_api': False, 'subdomain': '', 'latest': 'l'
|
'secret_key': None, 'disable_api': False, 'subdomain': '', 'latest': 'l', 'admin_links_per_page': 20
|
||||||
}
|
}
|
||||||
|
|
||||||
config_types = {'admin_username': str, 'database_name': str, 'random_length': int,
|
config_types = {'admin_username': str, 'database_name': str, 'random_length': int,
|
||||||
'allowed_chars': str, 'random_gen_timeout': int, 'site_name': str,
|
'allowed_chars': str, 'random_gen_timeout': int, 'site_name': str,
|
||||||
'site_domain': (str, type(None)), 'show_github_link': bool, 'secret_key': str,
|
'site_domain': (str, type(None)), 'show_github_link': bool, 'secret_key': str,
|
||||||
'disable_api': bool, 'subdomain': (str, type(None)), 'latest': (str, type(None))
|
'disable_api': bool, 'subdomain': (str, type(None)), 'latest': (str, type(None)),
|
||||||
|
'admin_links_per_page': int
|
||||||
}
|
}
|
||||||
|
|
||||||
for option in req_options.keys():
|
for option in req_options.keys():
|
||||||
|
@ -128,6 +130,26 @@ def list_shortlinks():
|
||||||
return result
|
return result
|
||||||
|
|
||||||
|
|
||||||
|
def list_shortlinks_page(page, limit=50):
|
||||||
|
assert page >= 1
|
||||||
|
assert type(page) == int
|
||||||
|
assert type(limit) == int
|
||||||
|
start_index = (page - 1) * limit
|
||||||
|
result = query_db('SELECT * FROM urls ORDER BY short LIMIT ? OFFSET ?', (limit, start_index), False, None)
|
||||||
|
result = nested_list_to_dict(result)
|
||||||
|
return result
|
||||||
|
|
||||||
|
|
||||||
|
def get_num_pages(limit=50):
|
||||||
|
assert type(limit) == int
|
||||||
|
result = query_db('SELECT COUNT(*) FROM urls', (), False, None)
|
||||||
|
items = result[0][0]
|
||||||
|
page_count = result[0][0] // limit
|
||||||
|
if page_count * limit < items:
|
||||||
|
page_count += 1
|
||||||
|
return page_count, items
|
||||||
|
|
||||||
|
|
||||||
def nested_list_to_dict(l):
|
def nested_list_to_dict(l):
|
||||||
d = {}
|
d = {}
|
||||||
for nl in l:
|
for nl in l:
|
||||||
|
@ -300,5 +322,58 @@ def main_post():
|
||||||
return response(request, None, 'Long URL required')
|
return response(request, None, 'Long URL required')
|
||||||
|
|
||||||
|
|
||||||
|
@app.route('/login', methods=['POST'])
|
||||||
|
def login():
|
||||||
|
if 'admin_hashed_password' not in app.config or app.config['admin_hashed_password'] is None:
|
||||||
|
raise AssertionError("Login is disabled.")
|
||||||
|
|
||||||
|
if authenticate(request.form['username'], request.form['password']):
|
||||||
|
session['logged_in'] = True
|
||||||
|
else:
|
||||||
|
flash('Wrong password!', 'error')
|
||||||
|
return make_response(redirect(url_for('admin')))
|
||||||
|
|
||||||
|
|
||||||
|
@app.route('/logout')
|
||||||
|
def logout():
|
||||||
|
if 'logged_in' in session and session['logged_in']:
|
||||||
|
session['logged_in'] = False
|
||||||
|
return make_response(redirect(url_for('admin')))
|
||||||
|
|
||||||
|
|
||||||
|
@app.route('/delete/<short>')
|
||||||
|
def delete(short):
|
||||||
|
if 'logged_in' in session and session['logged_in']:
|
||||||
|
success = delete_url(short)
|
||||||
|
if success:
|
||||||
|
flash("Link '/{}' deleted.".format(short), "success")
|
||||||
|
else:
|
||||||
|
flash("Failed to delete URL.".format(short), "error")
|
||||||
|
page = request.args.get('page', '1')
|
||||||
|
return make_response(redirect(url_for('admin')+"?page="+page))
|
||||||
|
else:
|
||||||
|
return make_response(redirect(url_for('admin')))
|
||||||
|
|
||||||
|
|
||||||
|
@app.route('/admin')
|
||||||
|
def admin():
|
||||||
|
if 'logged_in' in session and session['logged_in']:
|
||||||
|
page_count, num_items = get_num_pages(app.config['admin_links_per_page'])
|
||||||
|
page = request.args.get('page', '1')
|
||||||
|
try:
|
||||||
|
page = int(page)
|
||||||
|
if page > page_count:
|
||||||
|
return make_response(redirect(url_for('admin')+"?page="+str(page_count)))
|
||||||
|
if page < 1:
|
||||||
|
return make_response(redirect(url_for('admin')+"?page=1"))
|
||||||
|
except ValueError:
|
||||||
|
page = 1
|
||||||
|
|
||||||
|
urls = list_shortlinks_page(page, app.config['admin_links_per_page'])
|
||||||
|
return render_template('admin.html', urls=urls, page=page, page_count=page_count, num_items=num_items)
|
||||||
|
else:
|
||||||
|
return render_template('login.html')
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
app.run()
|
app.run()
|
||||||
|
|
74
static/admin.css
Normal file
74
static/admin.css
Normal file
|
@ -0,0 +1,74 @@
|
||||||
|
/*
|
||||||
|
Copyright (c) 2019 Kevin Alberts <kevin@kevinalberts.nl>
|
||||||
|
This software is license under the MIT license. It should be included in your copy of this software.
|
||||||
|
A copy of the MIT license can be obtained at https://mit-license.org/
|
||||||
|
*/
|
||||||
|
.paginator-link {
|
||||||
|
display: inline-block;
|
||||||
|
padding: 8px;
|
||||||
|
margin: 2px;
|
||||||
|
background: #1D428A;
|
||||||
|
border: 1px solid #1D428A;
|
||||||
|
color: white;
|
||||||
|
}
|
||||||
|
|
||||||
|
.paginator-link {
|
||||||
|
text-decoration: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.paginator-link:hover {
|
||||||
|
border: 1px solid #1D428A;
|
||||||
|
color: white;
|
||||||
|
background: #2450A8;
|
||||||
|
}
|
||||||
|
|
||||||
|
.paginator-current {
|
||||||
|
display: inline-block;
|
||||||
|
padding: 8px;
|
||||||
|
margin: 2px;
|
||||||
|
border: 1px solid #1D428A;
|
||||||
|
background: white;
|
||||||
|
color: #1D428A;
|
||||||
|
}
|
||||||
|
|
||||||
|
#box-title .small {
|
||||||
|
font-size: 2rem
|
||||||
|
}
|
||||||
|
|
||||||
|
#content_admin {
|
||||||
|
width: 1200px;
|
||||||
|
}
|
||||||
|
|
||||||
|
#link-table {
|
||||||
|
border-collapse: separate;
|
||||||
|
border-spacing: 0;
|
||||||
|
margin-top: 1rem;
|
||||||
|
margin-bottom: 2rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
#link-table .link-table-header {
|
||||||
|
background-color: #1D428A;
|
||||||
|
color: white;
|
||||||
|
}
|
||||||
|
|
||||||
|
#link-table .link-table-center {
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
#link-table tr:hover {
|
||||||
|
background-color: rgba(0, 0, 0, 0.1);
|
||||||
|
}
|
||||||
|
#link-table tr.link-table-header:hover {
|
||||||
|
background-color: #1D428A;
|
||||||
|
color: white;
|
||||||
|
}
|
||||||
|
|
||||||
|
#link-table .link-table-header th {
|
||||||
|
text-align: left;
|
||||||
|
font-size: 1.1rem;
|
||||||
|
padding: 0.5rem 1rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
#link-table th, #link-table td {
|
||||||
|
padding: 0.2rem 1rem;
|
||||||
|
}
|
|
@ -1,3 +1,8 @@
|
||||||
|
/*
|
||||||
|
Copyright (c) 2019 Kevin Alberts <kevin@kevinalberts.nl>
|
||||||
|
This software is license under the MIT license. It should be included in your copy of this software.
|
||||||
|
A copy of the MIT license can be obtained at https://mit-license.org/
|
||||||
|
*/
|
||||||
body{
|
body{
|
||||||
margin: 0 0 2rem;
|
margin: 0 0 2rem;
|
||||||
background-color: #f4f4f4;
|
background-color: #f4f4f4;
|
||||||
|
@ -34,6 +39,11 @@ body{
|
||||||
line-height: 2.75rem;
|
line-height: 2.75rem;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#title a {
|
||||||
|
color: white;
|
||||||
|
text-decoration: none;
|
||||||
|
}
|
||||||
|
|
||||||
#middle {
|
#middle {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
display: flex;
|
display: flex;
|
||||||
|
@ -103,6 +113,21 @@ body{
|
||||||
border-bottom: 1px solid rgba(0, 0, 0, 0.5);
|
border-bottom: 1px solid rgba(0, 0, 0, 0.5);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#username, #password {
|
||||||
|
/*width: 1%;*/
|
||||||
|
min-width: 40px;
|
||||||
|
flex: 1 1 auto;
|
||||||
|
font-size: 1.75rem;
|
||||||
|
color: black;
|
||||||
|
position: relative;
|
||||||
|
padding: 0.5rem;
|
||||||
|
|
||||||
|
margin-top: 1rem;
|
||||||
|
margin-bottom: 1rem;
|
||||||
|
|
||||||
|
border: 1px solid rgba(0, 0, 0, 0.5);
|
||||||
|
}
|
||||||
|
|
||||||
#submit {
|
#submit {
|
||||||
background-color: #077821;
|
background-color: #077821;
|
||||||
color: white;
|
color: white;
|
||||||
|
@ -194,3 +219,13 @@ body{
|
||||||
color: #2450A8;
|
color: #2450A8;
|
||||||
text-decoration: underline;
|
text-decoration: underline;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#copyright {
|
||||||
|
margin-top: 2rem;
|
||||||
|
font-size: 0.9rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
#copyright span {
|
||||||
|
text-align: center;
|
||||||
|
display: block;
|
||||||
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
Copyright (c) 2019 Steven Spangler <132@ikl.sh>
|
Copyright (c) 2019 Steven Spangler <132@ikl.sh>, Kevin Alberts <kevin@kevinalberts.nl>
|
||||||
This file is part of liteshort by 132ikl
|
This file is part of liteshort by 132ikl
|
||||||
This software is license under the MIT license. It should be included in your copy of this software.
|
This software is license under the MIT license. It should be included in your copy of this software.
|
||||||
A copy of the MIT license can be obtained at https://mit-license.org/
|
A copy of the MIT license can be obtained at https://mit-license.org/
|
||||||
|
|
100
templates/admin.html
Normal file
100
templates/admin.html
Normal file
|
@ -0,0 +1,100 @@
|
||||||
|
<!--
|
||||||
|
Copyright (c) 2019 Steven Spangler <132@ikl.sh>, Kevin Alberts <kevin@kevinalberts.nl>
|
||||||
|
This file is part of liteshort by 132ikl
|
||||||
|
This software is license under the MIT license. It should be included in your copy of this software.
|
||||||
|
A copy of the MIT license can be obtained at https://mit-license.org/
|
||||||
|
-->
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<title>URL Admin - {{ config.site_name }}</title>
|
||||||
|
<link href="https://fonts.googleapis.com/css?family=Open+Sans" rel="stylesheet">
|
||||||
|
<link rel="stylesheet" href="{{ url_for('static', filename='ia.css') }}">
|
||||||
|
<link rel="stylesheet" href="{{ url_for('static', filename='admin.css') }}">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<div id="top">
|
||||||
|
<div id="header">
|
||||||
|
<div id="logo" class="drop-shadow">
|
||||||
|
<a href="{{ url_for('main') }}">
|
||||||
|
<img src="{{ url_for('static', filename='ictsv-logo-white.svg') }}" alt="logo">
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
<div id="title" class="drop-shadow">
|
||||||
|
<a href="{{ url_for('main') }}">
|
||||||
|
I.C.T.S.V. URL Shortener
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div id="middle">
|
||||||
|
<div id="content_admin">
|
||||||
|
<div class="clearfix"></div>
|
||||||
|
<div id="box" class="align-self-center col-xl-4 col-lg-4 col-md-6 col-sm-10 col-xs-12">
|
||||||
|
<h3 id="box-title">URL Admin <span class="small">(<a href="{{ url_for('logout') }}">Logout</a>)</span></h3>
|
||||||
|
|
||||||
|
{% with messages = get_flashed_messages(with_categories=true) %}
|
||||||
|
{% if messages %}
|
||||||
|
{% for category, message in messages %}
|
||||||
|
{% if category == 'success' %}
|
||||||
|
<div class="success">
|
||||||
|
✓ {{ message }}
|
||||||
|
</div>
|
||||||
|
{% elif category == 'error' %}
|
||||||
|
<div class="error">
|
||||||
|
✖ {{ message }}
|
||||||
|
</div>
|
||||||
|
{% endif %}
|
||||||
|
{% endfor %}
|
||||||
|
{% endif %}
|
||||||
|
{% endwith %}
|
||||||
|
|
||||||
|
<p>There are {{ num_items }} links in the database.</p>
|
||||||
|
|
||||||
|
<div class="paginator">
|
||||||
|
{% for i in range(1, page_count + 1) %}
|
||||||
|
{% if i == page %}
|
||||||
|
<span class="paginator-current">{{ i }}</span>
|
||||||
|
{% else %}
|
||||||
|
<a class="paginator-link" href="?page={{ i }}">{{ i }}</a>
|
||||||
|
{% endif %}
|
||||||
|
{% endfor %}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<table id="link-table">
|
||||||
|
<tr class="link-table-header">
|
||||||
|
<th>Short link</th>
|
||||||
|
<th>Long link</th>
|
||||||
|
<th>Delete?</th>
|
||||||
|
</tr>
|
||||||
|
{% for long, short in urls.items() %}
|
||||||
|
<tr>
|
||||||
|
<td>{{ short }}</td>
|
||||||
|
<td>{{ long }}</td>
|
||||||
|
<td class="link-table-center">
|
||||||
|
<a href="{{ url_for('delete', short=short) }}?page={{ page }}">X</a>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
{% else %}
|
||||||
|
<tr>
|
||||||
|
<td colspan="2">No links yet.</td>
|
||||||
|
</tr>
|
||||||
|
{% endfor %}
|
||||||
|
</table>
|
||||||
|
|
||||||
|
<div class="paginator">
|
||||||
|
{% for i in range(1, page_count + 1) %}
|
||||||
|
{% if i == page %}
|
||||||
|
<span class="paginator-current">{{ i }}</span>
|
||||||
|
{% else %}
|
||||||
|
<a class="paginator-link" href="?page={{ i }}">{{ i }}</a>
|
||||||
|
{% endif %}
|
||||||
|
{% endfor %}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</body>
|
||||||
|
</html>
|
67
templates/login.html
Normal file
67
templates/login.html
Normal file
|
@ -0,0 +1,67 @@
|
||||||
|
<!--
|
||||||
|
Copyright (c) 2019 Steven Spangler <132@ikl.sh>, Kevin Alberts <kevin@kevinalberts.nl>
|
||||||
|
This file is part of liteshort by 132ikl
|
||||||
|
This software is license under the MIT license. It should be included in your copy of this software.
|
||||||
|
A copy of the MIT license can be obtained at https://mit-license.org/
|
||||||
|
-->
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<title>Admin Login - {{ config.site_name }}</title>
|
||||||
|
<link href="https://fonts.googleapis.com/css?family=Open+Sans" rel="stylesheet">
|
||||||
|
<link rel="stylesheet" href="{{ url_for('static', filename='ia.css') }}">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<div id="top">
|
||||||
|
<div id="header">
|
||||||
|
<div id="logo" class="drop-shadow">
|
||||||
|
<a href="{{ url_for('main') }}">
|
||||||
|
<img src="{{ url_for('static', filename='ictsv-logo-white.svg') }}" alt="logo">
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
<div id="title" class="drop-shadow">
|
||||||
|
<a href="{{ url_for('main') }}">
|
||||||
|
I.C.T.S.V. URL Shortener
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div id="middle">
|
||||||
|
<div id="content">
|
||||||
|
<div class="clearfix"></div>
|
||||||
|
<div id="box" class="align-self-center col-xl-4 col-lg-4 col-md-6 col-sm-10 col-xs-12">
|
||||||
|
<div class="form">
|
||||||
|
<h3 id="box-title">Admin Login</h3>
|
||||||
|
<form action="{{ url_for('login') }}" method="POST">
|
||||||
|
<div id="username-box">
|
||||||
|
<input id="username" name="username" type="text" placeholder="Username">
|
||||||
|
</div>
|
||||||
|
<div id="password-box">
|
||||||
|
<input id="password" name="password" type="password" placeholder="Password">
|
||||||
|
</div>
|
||||||
|
<button id="submit" type="submit" class="btn btn-primary" formmethod="post">Login</button>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{% with messages = get_flashed_messages(with_categories=true) %}
|
||||||
|
{% if messages %}
|
||||||
|
{% for category, message in messages %}
|
||||||
|
{% if category == 'success' %}
|
||||||
|
<div class="success">
|
||||||
|
✓ {{ message }}
|
||||||
|
</div>
|
||||||
|
{% elif category == 'error' %}
|
||||||
|
<div class="error">
|
||||||
|
✖ {{ message }}
|
||||||
|
</div>
|
||||||
|
{% endif %}
|
||||||
|
{% endfor %}
|
||||||
|
{% endif %}
|
||||||
|
{% endwith %}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</body>
|
||||||
|
</html>
|
|
@ -1,5 +1,5 @@
|
||||||
<!--
|
<!--
|
||||||
Copyright (c) 2019 Steven Spangler <132@ikl.sh>
|
Copyright (c) 2019 Steven Spangler <132@ikl.sh>, Kevin Alberts <kevin@kevinalberts.nl>
|
||||||
This file is part of liteshort by 132ikl
|
This file is part of liteshort by 132ikl
|
||||||
This software is license under the MIT license. It should be included in your copy of this software.
|
This software is license under the MIT license. It should be included in your copy of this software.
|
||||||
A copy of the MIT license can be obtained at https://mit-license.org/
|
A copy of the MIT license can be obtained at https://mit-license.org/
|
||||||
|
@ -17,10 +17,14 @@ A copy of the MIT license can be obtained at https://mit-license.org/
|
||||||
<div id="top">
|
<div id="top">
|
||||||
<div id="header">
|
<div id="header">
|
||||||
<div id="logo" class="drop-shadow">
|
<div id="logo" class="drop-shadow">
|
||||||
<img src="{{ url_for('static', filename='ictsv-logo-white.svg') }}" alt="logo">
|
<a href="{{ url_for('main') }}">
|
||||||
|
<img src="{{ url_for('static', filename='ictsv-logo-white.svg') }}" alt="logo">
|
||||||
|
</a>
|
||||||
</div>
|
</div>
|
||||||
<div id="title" class="drop-shadow">
|
<div id="title" class="drop-shadow">
|
||||||
I.C.T.S.V. URL Shortener
|
<a href="{{ url_for('main') }}">
|
||||||
|
I.C.T.S.V. URL Shortener
|
||||||
|
</a>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -62,6 +66,14 @@ A copy of the MIT license can be obtained at https://mit-license.org/
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% endwith %}
|
{% endwith %}
|
||||||
|
|
||||||
|
<p id="copyright">
|
||||||
|
<span>This URL shortening service is provided by <a href="https://inter-actief.net/">I.C.T.S.V. Inter-<i>Actief</i></a>.</span>
|
||||||
|
<span>URLs may be deleted or modified by us if deemed necessary.</span>
|
||||||
|
<span>No personal information is processed by this application.</span>
|
||||||
|
<span> </span>
|
||||||
|
<span>© <a href="https://inter-actief.net/">I.C.T.S.V. Inter-<i>Actief</i></a> and <a href="https://gitlab.ia.utwente.nl/WWW/ia-short">individual contributors</a>. Based on <a href="https://github.com/132ikl/liteshort">liteshort</a>.</span>
|
||||||
|
</p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
Loading…
Reference in a new issue