1
0
Fork 0
mirror of https://github.com/Lynnesbian/FediBooks/ synced 2024-11-25 16:48:58 +00:00

Compare commits

..

5 commits

5 changed files with 78 additions and 6 deletions

View file

@ -84,6 +84,9 @@ def scrape_posts(account):
c.close()
print("Finished {}".format(handle))
def make_post(bot):
pass
print("Establishing DB connection")
db = MySQLdb.connect(
host = cfg['db_host'],
@ -93,12 +96,26 @@ db = MySQLdb.connect(
)
print("Downloading posts")
cursor = db.cursor()
cursor.execute("SELECT `handle`, `outbox` FROM `fedi_accounts` ORDER BY RAND()")
accounts = cursor.fetchall()
cursor.close()
with Pool(8) as p:
p.map(scrape_posts, accounts)
print("Generating posts")
cursor.execute("""
SELECT
bots.handle, credentials.client_id, credentials.client_secret, credentials.secret
FROM
bots,
credentials
WHERE
bots.credentials_id = credentials.id
AND bots.enabled = TRUE;
""")
bots = cursor.fetchall()
with Pool(8) as p:
p.map(make_post, bots)
#TODO: other cron tasks should be done here, like updating profile pictures

View file

@ -44,6 +44,9 @@ body {
.full-width {
width: 100%;
}
.no-margin {
margin: 0;
}
.panel-icon {
width: 100px;
@ -113,7 +116,7 @@ input.button, button.button {
background-color: #777;
}
.btn-large {
.btn-large, button.btn-large {
font-size: 1.6em;
}
@ -150,14 +153,15 @@ label.important {
font-weight: 300;
display: block;
}
input, select {
input, select, textarea {
font-size: 1.2em;
line-height: 1.4em;
border: 3px grey solid;
border-radius: none;
padding: 3px;
font-family: "Roboto", sans-serif;
}
input:focus, select:focus {
input:focus, select:focus, textarea:focus {
border: 3px mediumpurple solid;
}

View file

@ -1,3 +1,6 @@
{% if error != None %}
<div class="error"><i class="fas fa-exclamation-triangle"></i> {{ error }}</div>
<div class="error">
<i class="fas fa-exclamation-triangle"></i> {{ error }}
<p class='tiny no-margin'><a class='button btn-small btn-dangerous' href='/issue/bug'><i class="fas fa-exclamation-circle"></i> Report bug</a></p>
</div>
{% endif %}

37
templates/report_bug.html Normal file
View file

@ -0,0 +1,37 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>FediBooks</title>
{% include 'imports.html' %}
</head>
<body>
<div class="container centred">
<h1 class="thin centred">Report a bug</h1>
</div>
<div class="container centred">
<form method='POST'>
<label for="title" class="important">Bug title</label>
<p>A short, concise description of what happened.</p>
<input name="title" class="full-width" type="text" placeholder="I can't delete my bot">
<label for="description" class="important">Description</label>
<p>A more detailed description of what happened, including the steps you took that caused this issue to appear.</p>
<textarea name="description" class="full-width" placeholder="I clicked the delete bot button and clicked confirm, but the bot was still there afterwards."></textarea>
<label for="comments" class="important">Further comments</label>
<p>If you'd like to, you may add a comment here with any additional information.</p>
<textarea name="comments" class="full-width" placeholder="This started happening when I disabled replies on all my bots."></textarea>
<div class="container centred">
<a href="/" class="button btn-large btn-secondary"><i class="fas fa-times"></i> Cancel</a>
<button class="button btn-large btn-primary"><i class="fas fa-exclamation-circle"></i> Submit bug report</button>
</div>
</form>
</div>
{% include 'footer.html' %}
</body>
</html>

View file

@ -395,6 +395,10 @@ def do_login():
session['error'] = "Incorrect login information."
return redirect(url_for("show_login_page"), 303)
@app.route("/issue/bug")
def report_bug():
return render_template("report_bug.html")
@app.route("/img/bot_generic.png")
def img_bot_generic():
return send_file("static/bot_generic.png", mimetype="image/png")
@ -404,3 +408,10 @@ def bot_check(bot):
c = mysql.connection.cursor()
c.execute("SELECT COUNT(*) FROM `bots` WHERE `handle` = %s AND `user_id` = %s", (bot, session['user_id']))
return c.fetchone()[0] == 1
@app.before_request
def login_check():
if request.path not in ['/', '/about', '/welcome', '/login', '/signup', '/do/login', '/do/signup', '/static/style.css']:
# page requires authentication
if 'user_id' not in session:
return redirect(url_for('home'))