Compare commits
2 commits
79cb6ffa54
...
aa4e98d475
Author | SHA1 | Date | |
---|---|---|---|
aa4e98d475 | |||
6f40492a35 |
3 changed files with 47 additions and 31 deletions
|
@ -30,13 +30,21 @@ h2 {
|
||||||
height:300px;
|
height:300px;
|
||||||
width:300px;
|
width:300px;
|
||||||
}
|
}
|
||||||
form {
|
form, .profilecard {
|
||||||
background-color: #444b5d;
|
background-color: #444b5d;
|
||||||
display:inline-block;
|
display:inline-block;
|
||||||
padding:50px;
|
padding:50px;
|
||||||
border-radius:5px;
|
border-radius:5px;
|
||||||
font-size:1.4em;
|
font-size:1.4em;
|
||||||
}
|
}
|
||||||
|
.profilecard {
|
||||||
|
padding: 30px;
|
||||||
|
margin: 20px;
|
||||||
|
width: 300px;
|
||||||
|
overflow:hidden;
|
||||||
|
white-space: nowrap;
|
||||||
|
text-overflow:ellipsis;
|
||||||
|
}
|
||||||
input {
|
input {
|
||||||
margin:20px;
|
margin:20px;
|
||||||
font-size:1.2em;
|
font-size:1.2em;
|
||||||
|
@ -57,13 +65,19 @@ button:hover, .button:hover{
|
||||||
background-color:#2b90d9;
|
background-color:#2b90d9;
|
||||||
color:white;
|
color:white;
|
||||||
}
|
}
|
||||||
#form-avi {
|
#form-avi, .pc-avi {
|
||||||
height: 128px;
|
height: 128px;
|
||||||
width:128px;
|
width:128px;
|
||||||
margin:0 auto 15px;
|
margin:0 auto 15px;
|
||||||
background-size:cover;
|
background-size:cover;
|
||||||
border-radius:16px;
|
border-radius:16px;
|
||||||
}
|
}
|
||||||
#form-avi-label {
|
#form-avi-label, .pc-avi-label {
|
||||||
font-size:0.6em;
|
font-size:0.6em;
|
||||||
|
text-overflow:ellipsis;
|
||||||
|
}
|
||||||
|
.pc-title {
|
||||||
|
margin: 20px auto;
|
||||||
|
font-size:1.8em;
|
||||||
|
font-weight:300;
|
||||||
}
|
}
|
|
@ -9,13 +9,13 @@
|
||||||
<!-- <div id='logo-main'></div> -->
|
<!-- <div id='logo-main'></div> -->
|
||||||
<div class='profilecard left'>
|
<div class='profilecard left'>
|
||||||
<div class='pc-title'>Mastodon</div>
|
<div class='pc-title'>Mastodon</div>
|
||||||
<div id='pc-avi' style={{ mabg }}></div>
|
<div class='pc-avi' style={{ mabg }}></div>
|
||||||
<span id='pc-avi-label'>{{ session['acct'] }}</span><br /><br />
|
<span class='pc-avi-label'>{{ session['acct'] }}</span><br /><br />
|
||||||
</div>
|
</div>
|
||||||
<div class='profilecard right'>
|
<div class='profilecard right'>
|
||||||
<div class='pc-title'>Curious Cat</div>
|
<div class='pc-title'>Curious Cat</div>
|
||||||
<div id='pc-avi' style={{ ccbg }}></div>
|
<div class='pc-avi' style={{ ccbg }}></div>
|
||||||
<span id='pc-avi-label'>{{ session['cc'] }}</span><br /><br />
|
<span class='pc-avi-label'>{{ session['cc'] }}</span><br /><br />
|
||||||
</div>
|
</div>
|
||||||
{% include 'footer.html' %}
|
{% include 'footer.html' %}
|
||||||
</body>
|
</body>
|
||||||
|
|
50
web.py
50
web.py
|
@ -21,24 +21,24 @@ db = mysql.connector.connect(user=cfg['dbuser'], password=cfg['dbpass'], databas
|
||||||
c = db.cursor()
|
c = db.cursor()
|
||||||
dc = db.cursor(dictionary=True)
|
dc = db.cursor(dictionary=True)
|
||||||
# MariaDB [curiousgreg]> DESCRIBE data;
|
# MariaDB [curiousgreg]> DESCRIBE data;
|
||||||
# +---------------------+--------------+------+-----+-------------------------------------------+-----------------------------+
|
# +---------------------+--------------+------+-----+------------------------------------------------+-----------------------------+
|
||||||
# | Field | Type | Null | Key | Default | Extra |
|
# | Field | Type | Null | Key | Default | Extra |
|
||||||
# +---------------------+--------------+------+-----+-------------------------------------------+-----------------------------+
|
# +---------------------+--------------+------+-----+------------------------------------------------+-----------------------------+
|
||||||
# | username | varchar(64) | NO | PRI | NULL | |
|
# | username | varchar(64) | NO | PRI | NULL | |
|
||||||
# | instance | varchar(128) | NO | PRI | NULL | |
|
# | instance | varchar(128) | NO | PRI | NULL | |
|
||||||
# | password | tinytext | NO | | NULL | |
|
# | password | tinytext | NO | | NULL | |
|
||||||
# | avi | text | NO | | NULL | |
|
# | avi | text | NO | | NULL | |
|
||||||
# | secret | tinytext | NO | | NULL | |
|
# | secret | tinytext | NO | | NULL | |
|
||||||
# | client_id | varchar(128) | NO | | NULL | |
|
# | client_id | varchar(128) | NO | | NULL | |
|
||||||
# | client_secret | tinytext | NO | | NULL | |
|
# | client_secret | tinytext | NO | | NULL | |
|
||||||
# | cc | tinytext | YES | | NULL | |
|
# | cc | tinytext | YES | | NULL | |
|
||||||
# | ccavi | varchar(128) | YES | | https://lynnesbian.space/res/ceres/cc.png | |
|
# | ccavi | varchar(128) | YES | | https://lynnesbian.space/res/ceres/cc-smol.png | |
|
||||||
# | latest_post | tinytext | YES | | NULL | |
|
# | latest_post | tinytext | YES | | NULL | |
|
||||||
# | latest_timestamp | timestamp | NO | | CURRENT_TIMESTAMP | on update CURRENT_TIMESTAMP |
|
# | latest_timestamp | timestamp | NO | | CURRENT_TIMESTAMP | on update CURRENT_TIMESTAMP |
|
||||||
# | time_between_checks | int(11) | YES | | NULL | |
|
# | time_between_checks | int(11) | YES | | NULL | |
|
||||||
# | settings | longtext | YES | | NULL | |
|
# | settings | longtext | YES | | NULL | |
|
||||||
# +---------------------+--------------+------+-----+-------------------------------------------+-----------------------------+
|
# +---------------------+--------------+------+-----+------------------------------------------------+-----------------------------+
|
||||||
c.execute("CREATE TABLE IF NOT EXISTS `data` (username VARCHAR(64) NOT NULL, instance VARCHAR(128) NOT NULL, password TINYTEXT NOT NULL, avi TEXT NOT NULL, secret TINYTEXT NOT NULL, client_id VARCHAR(128) NOT NULL, client_secret TINYTEXT NOT NULL, cc TINYTEXT, ccavi VARCHAR(128) DEFAULT 'https://lynnesbian.space/res/ceres/cc.png', latest_post TINYTEXT, latest_timestamp TIMESTAMP, time_between_checks INT, settings LONGTEXT, PRIMARY KEY(username, instance))")
|
c.execute("CREATE TABLE IF NOT EXISTS `data` (username VARCHAR(64) NOT NULL, instance VARCHAR(128) NOT NULL, password TINYTEXT NOT NULL, avi TEXT NOT NULL, secret TINYTEXT NOT NULL, client_id VARCHAR(128) NOT NULL, client_secret TINYTEXT NOT NULL, cc TINYTEXT, ccavi VARCHAR(128) DEFAULT 'https://lynnesbian.space/res/ceres/cc-smol.png', latest_post TINYTEXT, latest_timestamp TIMESTAMP, time_between_checks INT, settings LONGTEXT, PRIMARY KEY(username, instance))")
|
||||||
|
|
||||||
app = Flask(cfg['name'])
|
app = Flask(cfg['name'])
|
||||||
app.secret_key = cfg['flask_key']
|
app.secret_key = cfg['flask_key']
|
||||||
|
@ -55,12 +55,14 @@ def home():
|
||||||
if 'acct' in session:
|
if 'acct' in session:
|
||||||
if 'cc' not in session:
|
if 'cc' not in session:
|
||||||
session['cc'] = "None"
|
session['cc'] = "None"
|
||||||
if session['cc'] == "None":
|
if session['cc'] == "None" or 'ccavi' not in session:
|
||||||
#every time home is rendered without cc being set
|
#every time home is rendered without cc being set
|
||||||
c.execute("SELECT cc FROM `data` WHERE client_id LIKE %s AND instance LIKE %s", (session['client_id'], session['instance']))
|
c.execute("SELECT cc, ccavi FROM `data` WHERE client_id LIKE %s AND instance LIKE %s", (session['client_id'], session['instance']))
|
||||||
cc = c.fetchone()[0]
|
cc = c.fetchone()
|
||||||
if cc != '':
|
if cc[0] != '':
|
||||||
session['cc'] = cc
|
session['cc'] = cc[0]
|
||||||
|
session['ccavi'] = cc[1]
|
||||||
|
|
||||||
|
|
||||||
if 'last_avi_update' not in session or session['last_avi_update'] + (24 * 60 * 60) < time.time():
|
if 'last_avi_update' not in session or session['last_avi_update'] + (24 * 60 * 60) < time.time():
|
||||||
#avatars haven't been updated for over 24 hours, update them now
|
#avatars haven't been updated for over 24 hours, update them now
|
||||||
|
@ -75,7 +77,7 @@ def home():
|
||||||
c.execute("UPDATE data SET avi = %s, ccavi = %s WHERE client_id LIKE %s AND instance LIKE %s", (session['avi'], session['ccavi'], session['client_id'], session['instance']))
|
c.execute("UPDATE data SET avi = %s, ccavi = %s WHERE client_id LIKE %s AND instance LIKE %s", (session['avi'], session['ccavi'], session['client_id'], session['instance']))
|
||||||
else:
|
else:
|
||||||
c.execute("UPDATE data SET avi = %s WHERE client_id LIKE %s AND instance LIKE %s", (session['avi'], session['client_id'], session['instance']))
|
c.execute("UPDATE data SET avi = %s WHERE client_id LIKE %s AND instance LIKE %s", (session['avi'], session['client_id'], session['instance']))
|
||||||
return render_template("home.html")
|
return render_template("home.html", mabg="background-image:url('{}')".format(session['avi']), ccbg="background-image:url('{}')".format(session['ccavi']))
|
||||||
else:
|
else:
|
||||||
return redirect(url_for('main'))
|
return redirect(url_for('main'))
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue