mirror of
https://github.com/Lynnesbian/FediBooks/
synced 2024-11-25 16:48:58 +00:00
Compare commits
5 commits
c38f01b07a
...
487939fec0
Author | SHA1 | Date | |
---|---|---|---|
487939fec0 | |||
34db513785 | |||
e6e6ed9c28 | |||
44c7e24a53 | |||
7015431687 |
5 changed files with 78 additions and 6 deletions
21
service.py
21
service.py
|
@ -84,6 +84,9 @@ def scrape_posts(account):
|
||||||
c.close()
|
c.close()
|
||||||
print("Finished {}".format(handle))
|
print("Finished {}".format(handle))
|
||||||
|
|
||||||
|
def make_post(bot):
|
||||||
|
pass
|
||||||
|
|
||||||
print("Establishing DB connection")
|
print("Establishing DB connection")
|
||||||
db = MySQLdb.connect(
|
db = MySQLdb.connect(
|
||||||
host = cfg['db_host'],
|
host = cfg['db_host'],
|
||||||
|
@ -93,12 +96,26 @@ db = MySQLdb.connect(
|
||||||
)
|
)
|
||||||
|
|
||||||
print("Downloading posts")
|
print("Downloading posts")
|
||||||
|
|
||||||
cursor = db.cursor()
|
cursor = db.cursor()
|
||||||
cursor.execute("SELECT `handle`, `outbox` FROM `fedi_accounts` ORDER BY RAND()")
|
cursor.execute("SELECT `handle`, `outbox` FROM `fedi_accounts` ORDER BY RAND()")
|
||||||
accounts = cursor.fetchall()
|
accounts = cursor.fetchall()
|
||||||
cursor.close()
|
|
||||||
with Pool(8) as p:
|
with Pool(8) as p:
|
||||||
p.map(scrape_posts, accounts)
|
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
|
#TODO: other cron tasks should be done here, like updating profile pictures
|
||||||
|
|
|
@ -44,6 +44,9 @@ body {
|
||||||
.full-width {
|
.full-width {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
}
|
}
|
||||||
|
.no-margin {
|
||||||
|
margin: 0;
|
||||||
|
}
|
||||||
|
|
||||||
.panel-icon {
|
.panel-icon {
|
||||||
width: 100px;
|
width: 100px;
|
||||||
|
@ -113,7 +116,7 @@ input.button, button.button {
|
||||||
background-color: #777;
|
background-color: #777;
|
||||||
}
|
}
|
||||||
|
|
||||||
.btn-large {
|
.btn-large, button.btn-large {
|
||||||
font-size: 1.6em;
|
font-size: 1.6em;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -150,14 +153,15 @@ label.important {
|
||||||
font-weight: 300;
|
font-weight: 300;
|
||||||
display: block;
|
display: block;
|
||||||
}
|
}
|
||||||
input, select {
|
input, select, textarea {
|
||||||
font-size: 1.2em;
|
font-size: 1.2em;
|
||||||
line-height: 1.4em;
|
line-height: 1.4em;
|
||||||
border: 3px grey solid;
|
border: 3px grey solid;
|
||||||
border-radius: none;
|
border-radius: none;
|
||||||
padding: 3px;
|
padding: 3px;
|
||||||
|
font-family: "Roboto", sans-serif;
|
||||||
}
|
}
|
||||||
input:focus, select:focus {
|
input:focus, select:focus, textarea:focus {
|
||||||
border: 3px mediumpurple solid;
|
border: 3px mediumpurple solid;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,3 +1,6 @@
|
||||||
{% if error != None %}
|
{% 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 %}
|
{% endif %}
|
||||||
|
|
37
templates/report_bug.html
Normal file
37
templates/report_bug.html
Normal 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>
|
11
webui.py
11
webui.py
|
@ -395,6 +395,10 @@ def do_login():
|
||||||
session['error'] = "Incorrect login information."
|
session['error'] = "Incorrect login information."
|
||||||
return redirect(url_for("show_login_page"), 303)
|
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")
|
@app.route("/img/bot_generic.png")
|
||||||
def img_bot_generic():
|
def img_bot_generic():
|
||||||
return send_file("static/bot_generic.png", mimetype="image/png")
|
return send_file("static/bot_generic.png", mimetype="image/png")
|
||||||
|
@ -404,3 +408,10 @@ def bot_check(bot):
|
||||||
c = mysql.connection.cursor()
|
c = mysql.connection.cursor()
|
||||||
c.execute("SELECT COUNT(*) FROM `bots` WHERE `handle` = %s AND `user_id` = %s", (bot, session['user_id']))
|
c.execute("SELECT COUNT(*) FROM `bots` WHERE `handle` = %s AND `user_id` = %s", (bot, session['user_id']))
|
||||||
return c.fetchone()[0] == 1
|
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'))
|
||||||
|
|
Loading…
Reference in a new issue