diff --git a/README.md b/README.md index da93933..cdbfe97 100644 --- a/README.md +++ b/README.md @@ -19,14 +19,14 @@ First you need to install python and virtualenv with your favourite package mana Create and activate virtualenv: ```shell -sudo apt install python virtualenv +sudo apt install python3 virtualenv uwsgi uwsgi-plugin-python nginx virtualenv -p python3 . . bin/activate ``` Install the dependencies: ```shell -pip install tweepy pytoml requests Mastodon.py +pip install tweepy pytoml requests Mastodon.py bottle ``` Configure the bot: diff --git a/frontend/login.py b/frontend/login.py new file mode 100644 index 0000000..6dffb8b --- /dev/null +++ b/frontend/login.py @@ -0,0 +1,90 @@ +#!/usr/bin/env python3 + +import bottle +import sqlite3 + +class Datagetter(object): + def __init__(self): + self.db = "../../../ticketfrei.sqlite" + self.conn = self.create_connection(self.db) + self.cur = self.conn.cursor() + + def create_connection(self, db_file): + """ create a database connection to the SQLite database + specified by the db_file + :param db_file: database file + :return: Connection object or None + """ + try: + conn = sqlite3.connect(db_file) + return conn + except sqlite3.Error as e: + print(e) + return None + +app = application = bottle.Bottle() + +@app.route('/login', method="POST") +def login(): + """ + Login to the ticketfrei account with credentials from the user table. + + :return: bot.py Session Cookie + """ + uname = bottle.request.forms.get('uname') + psw = bottle.request.forms.get('psw') + if psw == db.cur.execute("SELECT pass FROM user WHERE email=?;", (uname, )): + # :todo Generate Session Cookie and give to user + return bottle.static_file("../static/bot.html", root="../static") + else: + return "Wrong Credentials." + +@app.route('/register', method="POST") +def register(): + """ + Login to the ticketfrei account with credentials from the user table. + + :return: bot.py Session Cookie + """ + uname = bottle.request.forms.get('email') + psw = bottle.request.forms.get('psw') + pswrepeat = bottle.request.forms.get('psw-repeat') + if pswrepeat != psw: + return "ERROR: Passwords don't match. Try again." + + # :todo send confirmation Mail with encoded email+passphrase to email + return "We Sent you an E-Mail. Please click on the confirmation link." + +@app.route('/static/') +def static(filename): + """ + Serve static files + """ + return bottle.static_file(filename, root='../static') + + +@app.route('/') +def show_index(): + """ + The front "index" page + :return: /static/index.html + """ + return bottle.static_file("../static/index.html", root='../static') + + +class StripPathMiddleware(object): + """ + Get that slash out of the request + """ + def __init__(self, a): + self.a = a + + def __call__(self, e, h): + e['PATH_INFO'] = e['PATH_INFO'].rstrip('/') + return self.a(e, h) + + +if __name__ == "__main__": + global db + db = Datagetter() + bottle.run(app=StripPathMiddleware(app), host='0.0.0.0', port=8080) \ No newline at end of file diff --git a/static/bot.html b/static/bot.html new file mode 100644 index 0000000..0141658 --- /dev/null +++ b/static/bot.html @@ -0,0 +1,15 @@ + + Ticketfrei + + + + +
+ Ticketfrei Logo + + +
+ + \ No newline at end of file diff --git a/static/css/style.css b/static/css/style.css new file mode 100644 index 0000000..90a7178 --- /dev/null +++ b/static/css/style.css @@ -0,0 +1,64 @@ +body { + font-family: Verdana, Arial, Helvetica, sans-serif; + font-size: 15px; + line-height: 1.5em; + background-position: center top; + margin: 0; +} + +.area { + background-color: #FFF; + max-width: 600px; + margin-left: auto; + margin-right: auto; + text-align: center; +} + +.text { + padding: 2em; +} + +h1, h2 { + text-align: left; + margin-top: 0; +} + +p { + text-align: left; +} + +/* Set a style for all buttons */ +button { + background-color: #4CAF50; + color: white; + padding: 14px 20px; + margin: 8px 0; + border: none; + cursor: pointer; + font-size: 120%; +} + +button:hover { + opacity: 0.8; +} + +input[type=text], input[type=password] { + width: 100%; + padding: 12px 20px; + margin: 8px 0; + display: inline-block; + border: 1px solid #ccc; + box-sizing: border-box; +} + +.container { + text-align: center; + padding: 4em; + padding-top: 0; + padding-bottom: 0; + float: none; +} + +.footer { + padding: 2em; +} \ No newline at end of file diff --git a/static/img/ticketfrei_logo.png b/static/img/ticketfrei_logo.png new file mode 100644 index 0000000..21977c4 Binary files /dev/null and b/static/img/ticketfrei_logo.png differ diff --git a/static/img/wallpaper.png b/static/img/wallpaper.png new file mode 100644 index 0000000..7382a4b Binary files /dev/null and b/static/img/wallpaper.png differ diff --git a/static/index.html b/static/index.html new file mode 100644 index 0000000..6e2a37c --- /dev/null +++ b/static/index.html @@ -0,0 +1,76 @@ + + Ticketfrei + + + +
+ +

Ticketfrei

+ +
+
+ + + + + + + + Remember me + + + + + Forgot password? + + +
+
+ +
+

Features

+

sum is simply dummy text of the printing and typesetting + industry. Lorem Ipsum has been the industry's standard + dummy text ever since the 1500s, when an unknown printer + took a galley of type and scrambled it to make a type + specimen book. It has survived not only five centuries, + but also the leap into electronic typesetting, remaining + essentially unchanged. It was popularised in the 1960s + with the release of Letraset sheets containing Lorem + Ipsum passages, and more recently with desktop publishing + software like Aldus PageMaker including versions of Lorem + Ipsum.

+

How to get Ticketfrei to my city?

+

sum is simply dummy text of the printing and typesetting + industry. Lorem Ipsum has been the industry's standard + dummy text ever since the 1500s, when an unknown printer + took a galley of type and scrambled it to make a type + specimen book. It has survived not only five centuries, + but also the leap into electronic typesetting, remaining + essentially unchanged. It was popularised in the 1960s + with the release of Letraset sheets containing Lorem + Ipsum passages, and more recently with desktop publishing + software like Aldus PageMaker including versions of Lorem + Ipsum.

+ +

Our Mission

+

Contrary to popular belief, Lorem Ipsum is not simply random + text. It has roots in a piece of classical Latin literature + from 45 BC, making it over 2000 years old. Richard + McClintock, a Latin professor at Hampden-Sydney College in + Virginia, looked up one of the more obscure Latin words, + consectetur, from a Lorem Ipsum passage, and going through + the cites of the word in classical literature, discovered + the undoubtable source. Lorem Ipsum comes from sections + 1.10.32 and 1.10.33 of "de Finibus Bonorum et Malorum" + (The Extremes of Good and Evil) by Cicero, written in 45 + BC. This book is a treatise on the theory of ethics, very + popular during the Renaissance. The first line of Lorem + Ipsum, "Lorem ipsum dolor sit amet..", comes from a line + in section 1.10.32.

+
+ +
+ \ No newline at end of file diff --git a/static/register.html b/static/register.html new file mode 100644 index 0000000..6ee8c7b --- /dev/null +++ b/static/register.html @@ -0,0 +1,31 @@ + + Ticketfrei + + + +
+ +

Ticketfrei

+
+
+ + + + + + + + +

By creating an account you agree to our Terms & Privacy.

+ +
+ +
+
+
+ + +
+ \ No newline at end of file