mirror of
https://github.com/Lynnesbian/FediBooks/
synced 2024-11-26 00:58:59 +00:00
Compare commits
No commits in common. "487939fec08553f68e875ca782a84b45de2fcdca" and "c38f01b07adb8a701b749d72ac4c2dee38ded0ca" have entirely different histories.
487939fec0
...
c38f01b07a
5 changed files with 6 additions and 78 deletions
21
service.py
21
service.py
|
@ -84,9 +84,6 @@ 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'],
|
||||||
|
@ -96,26 +93,12 @@ 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,9 +44,6 @@ body {
|
||||||
.full-width {
|
.full-width {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
}
|
}
|
||||||
.no-margin {
|
|
||||||
margin: 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
.panel-icon {
|
.panel-icon {
|
||||||
width: 100px;
|
width: 100px;
|
||||||
|
@ -116,7 +113,7 @@ input.button, button.button {
|
||||||
background-color: #777;
|
background-color: #777;
|
||||||
}
|
}
|
||||||
|
|
||||||
.btn-large, button.btn-large {
|
.btn-large {
|
||||||
font-size: 1.6em;
|
font-size: 1.6em;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -153,15 +150,14 @@ label.important {
|
||||||
font-weight: 300;
|
font-weight: 300;
|
||||||
display: block;
|
display: block;
|
||||||
}
|
}
|
||||||
input, select, textarea {
|
input, select {
|
||||||
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, textarea:focus {
|
input:focus, select:focus {
|
||||||
border: 3px mediumpurple solid;
|
border: 3px mediumpurple solid;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,3 @@
|
||||||
{% if error != None %}
|
{% if error != None %}
|
||||||
<div class="error">
|
<div class="error"><i class="fas fa-exclamation-triangle"></i> {{ error }}</div>
|
||||||
<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 %}
|
||||||
|
|
|
@ -1,37 +0,0 @@
|
||||||
<!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,10 +395,6 @@ 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")
|
||||||
|
@ -408,10 +404,3 @@ 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