Skip to content

Commit 0fefd00

Browse files
committed
Feed and fonts added
1 parent da43e22 commit 0fefd00

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

52 files changed

+246
-98
lines changed

Diff for: .idea/flask-retromemes-app.iml

+12
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: .idea/inspectionProfiles/profiles_settings.xml

+6
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: .idea/misc.xml

+7
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: .idea/modules.xml

+8
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: app.py

+38-13
Original file line numberDiff line numberDiff line change
@@ -52,23 +52,46 @@ def upload_meme():
5252
@app.route("/feed", methods=['GET', 'POST'])
5353
@app.route("/index", methods=['GET', 'POST'])
5454
@app.route("/main", methods=['GET', 'POST'])
55-
def show_feed():
56-
return render_template("index.html")
55+
def show_feed(page=1):
56+
if request.method == "GET" and request.args.get('page'):
57+
page = int(request.args.get('page'))
58+
dataposts = list(get_all_tabledata(create_connection('C:\\Users\\79246\\PycharmProjects\\flask-retromemes-app\\'
59+
'database\\memes_testdata.db'), 'Post'))
60+
pages = len(dataposts) // PAGES_POSTS
61+
if len(dataposts) % PAGES_POSTS != 0:
62+
pages += 1
63+
posts = []
64+
limit = page * PAGES_POSTS
65+
if limit > len(dataposts):
66+
limit = len(dataposts)
67+
# Generate posts
68+
for i in range((page - 1) * PAGES_POSTS, limit):
69+
author_name = get_username_bId(dataposts[i][1], 'C:\\Users\\79246\\PycharmProjects\\flask-retromemes-app\\'
70+
'database\\memes_testdata.db')
71+
avatar = get_user_avatar_bId(dataposts[i][1], 'C:\\Users\\79246\\PycharmProjects\\flask-retromemes-app\\'
72+
'database\\memes_testdata.db')
73+
post = {'avatar': AVATAR_FOLDER + avatar, 'author_id': dataposts[i][1],
74+
'author_name': author_name, 'date': dataposts[i][4], 'comment': dataposts[i][2],
75+
'image': MEMES_FOLDER + dataposts[i][3], }
76+
posts.append(post)
77+
return render_template("index.html", posts=posts, pages=pages)
5778

5879

5980
@app.route('/admin', methods=['GET', 'POST'])
6081
@app.route('/adminpannel', methods=['GET', 'POST'])
6182
@app.route('/adminpanel', methods=['GET', 'POST'])
6283
def admin_panel():
63-
try:
64-
username = session['login']
65-
connection = create_connection(DATABASE_PATH)
66-
if is_user_admin(connection, username, 'login'):
67-
return render_template('admin.html')
68-
return generate_notadmin_page()
69-
except:
70-
return generate_notadmin_page()
71-
84+
if request.method == 'POST':
85+
print(list(request.form))
86+
# try:
87+
# username = session['login']
88+
# connection = create_connection(DATABASE_PATH)
89+
# if is_user_admin(connection, username, 'login'):
90+
# return render_template('admin.html')
91+
# return generate_notadmin_page()
92+
# except:
93+
# return generate_notadmin_page()
94+
return render_template('admin.html')
7295

7396
# Handling of 404 error
7497
@app.errorhandler(404)
@@ -116,15 +139,17 @@ def login_user():
116139
login = request.form.get('login')
117140
password = request.form.get('password')
118141
con = sl.connect(DATABASE_PATH)
119-
sql = f"SELECT password,id FROM users WHERE `login`='{login}'"
142+
sql = f"SELECT password,id, admin FROM users WHERE `login`='{login}'"
120143
result = list(con.execute(sql))
121144
if password == result[0][0]:
122145
session['login'] = login
123146
session['id'] = result[0][1]
147+
session['admin'] = result[0][2]
148+
redirect('show_feed')
124149
return render_template('auth.html')
125150

126151

127152
# Programm run
128153
if __name__ == '__main__':
129154
#create_testdata_database(DATABASE_PATH, "C:\\Users\\Glaster\\Desktop\\memes\\")
130-
app.run(host="0.0.0.0")
155+
app.run(host="0.0.0.0", debug=True)

Diff for: database/memes.db

0 Bytes
Binary file not shown.

Diff for: memes.db

Whitespace-only changes.

Diff for: modules/constants.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,11 @@
88
DATABASE_PATH = os.getcwd() + '\\' + "database" + '\\' + "memes.db"
99
UPLOAD_FOLDER = os.getcwd() + '\\' + "static\\images\\uploaded_memes\\"
1010
DEFAULT_AVATAR = os.getcwd() + "\\static\\images\\ava.png"
11+
AVATAR_FOLDER = 'images/avatars/'
12+
MEMES_FOLDER = 'images/uploaded_memes/'
1113
ALLOWED_EXTENSIONS = {'png', 'jpg', 'jpeg'}
1214

13-
15+
PAGES_POSTS = 10
1416

1517
USED_TABLES = [USERS_TABLENAME, POSTS_TABLENAME, RATES_TABLENAME, HISTORY_TABLENAME]
1618

Diff for: modules/database.py

+6-1
Original file line numberDiff line numberDiff line change
@@ -230,6 +230,12 @@ def get_username_bId(user_id, db_file):
230230
result = connection.execute(sql_querry).fetchall()[0][0]
231231
return result
232232

233+
def get_user_avatar_bId(user_id, db_file):
234+
connection = create_connection(db_file)
235+
sql_query = f"SELECT avatar FROM users WHERE id={user_id}"
236+
result = connection.execute(sql_query).fetchall()[0][0]
237+
return result
238+
233239

234240
def delete_post_bID(post_id, connection, basic_path):
235241
"""Delete post by it's id"""
@@ -278,7 +284,6 @@ def synthesize_admin(connection, admin_name, isAdmin = 1):
278284
add_user(connection, user)
279285
connection.commit()
280286

281-
282287
def synthesize_user(connection, user_name):
283288
"""Synthesizes user"""
284289
synthesize_admin(connection, user_name, 0)

Diff for: static/fonts/Montserrat-Black.ttf

193 KB
Binary file not shown.

Diff for: static/fonts/Montserrat-BlackItalic.ttf

198 KB
Binary file not shown.

Diff for: static/fonts/Montserrat-Bold.ttf

193 KB
Binary file not shown.

Diff for: static/fonts/Montserrat-BoldItalic.ttf

198 KB
Binary file not shown.

Diff for: static/fonts/Montserrat-ExtraBold.ttf

194 KB
Binary file not shown.

Diff for: static/fonts/Montserrat-ExtraBoldItalic.ttf

198 KB
Binary file not shown.

Diff for: static/fonts/Montserrat-ExtraLight.ttf

193 KB
Binary file not shown.

Diff for: static/fonts/Montserrat-ExtraLightItalic.ttf

198 KB
Binary file not shown.

Diff for: static/fonts/Montserrat-Italic.ttf

198 KB
Binary file not shown.

Diff for: static/fonts/Montserrat-Light.ttf

193 KB
Binary file not shown.

Diff for: static/fonts/Montserrat-LightItalic.ttf

198 KB
Binary file not shown.

Diff for: static/fonts/Montserrat-Medium.ttf

193 KB
Binary file not shown.

Diff for: static/fonts/Montserrat-MediumItalic.ttf

198 KB
Binary file not shown.

Diff for: static/fonts/Montserrat-Regular.ttf

193 KB
Binary file not shown.

Diff for: static/fonts/Montserrat-SemiBold.ttf

194 KB
Binary file not shown.

Diff for: static/fonts/Montserrat-SemiBoldItalic.ttf

198 KB
Binary file not shown.

Diff for: static/fonts/Montserrat-Thin.ttf

193 KB
Binary file not shown.

Diff for: static/fonts/Montserrat-ThinItalic.ttf

197 KB
Binary file not shown.

Diff for: static/fonts/RobotoCondensed-Bold.ttf

162 KB
Binary file not shown.

Diff for: static/fonts/RobotoCondensed-BoldItalic.ttf

168 KB
Binary file not shown.

Diff for: static/fonts/RobotoCondensed-Italic.ttf

168 KB
Binary file not shown.

Diff for: static/fonts/RobotoCondensed-Light.ttf

161 KB
Binary file not shown.

Diff for: static/fonts/RobotoCondensed-LightItalic.ttf

168 KB
Binary file not shown.

Diff for: static/fonts/RobotoCondensed-Regular.ttf

163 KB
Binary file not shown.

Diff for: static/styles/admin-mobile.css

+20-6
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44
grid-template-columns: repeat(6, 1fr);
55
}
66

7-
main > div:first-child {
8-
margin: 0 15px;
9-
grid-column: 1/7;
7+
main > div:nth-of-type(2) {
8+
margin: 15px;
9+
grid-column: 1/6;
1010
grid-template-columns: repeat(6, 1fr);
1111
}
1212

@@ -20,19 +20,33 @@
2020
}
2121

2222
.name {
23-
grid-column: 3/7;
23+
grid-column: 2/7;
24+
grid-template-columns: repeat(6, 1fr);
25+
}
26+
27+
.name > div:first-child {
28+
grid-column: 1/7;
29+
font-size: 13pt;
30+
}
31+
32+
.name > div:last-child {
33+
grid-column: 1/6;
34+
width: 60px;
35+
height: 20px;
36+
font-size: 10pt;
2437
}
2538

2639
.exit {
27-
grid-column: 5/7;
40+
grid-column: 6/7;
41+
margin: 15px;
2842
}
2943

3044
.user_avatar > img {
3145
width: 50px;
3246
height: 50px;
3347
}
3448

35-
form {
49+
#adminpanel {
3650
grid-column: 1/7;
3751
margin: 15px;
3852
}

Diff for: static/styles/admin.css

+27-19
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
1+
@import url("font.css");
2+
13
body {
24
padding: 0;
35
margin: 0;
46
background-color: #d4d4d4;
57
box-sizing: border-box;
68
max-width: 100%;
79
max-height: 100%;
10+
811
}
912

1013
main {
@@ -20,7 +23,7 @@ main {
2023
padding-bottom: 30px;
2124
}
2225

23-
main > div:first-child {
26+
main > div:nth-of-type(2) {
2427
grid-column: 1/12;
2528
margin: 30px;
2629
display: grid;
@@ -40,7 +43,7 @@ main > div:first-child {
4043
}
4144

4245
.name {
43-
grid-column: 4/9;
46+
grid-column: 4/10;
4447
display: grid;
4548
grid-template-columns: repeat(12, 1fr);
4649
grid-column-gap: 20px;
@@ -65,7 +68,7 @@ main > div:first-child {
6568
}
6669

6770
.exit {
68-
grid-column: 12/13;
71+
grid-column: 11/13;
6972
background-color: #ecf1f6;
7073
width: 80px;
7174
height: 20px;
@@ -74,9 +77,14 @@ main > div:first-child {
7477
border-color: rgba(27,31,36,0.15);
7578
border-radius: 4px;
7679
margin: 30px;
80+
cursor: pointer;
81+
}
82+
83+
#exitform {
84+
display: none;
7785
}
7886

79-
form {
87+
#adminpanel {
8088
grid-column: 1/13;
8189
margin: 30px;
8290
background-color: #d6d1d1;
@@ -87,71 +95,71 @@ form {
8795
grid-column-gap: 20px;
8896
}
8997

90-
form > div:first-child {
98+
#adminpanel > div:first-child {
9199
font-size: 14pt;
92100
font-weight: 600;
93101
margin-top: 15px;
94102
text-align: center;
95103
grid-column: 1/13;
96104
}
97105

98-
form > div:last-child {
106+
#adminpanel > div:last-child {
99107
grid-column: 1/13;
100108
margin-top: 15px;
101109
}
102110

103-
form > .actions > input {
111+
#adminpanel > .actions > input {
104112
padding: 5px;
105113
border-radius: 5px;
106114
border: 1px;
107115
box-shadow:0 0 15px 4px rgba(0,0,0,0.06);
108116
}
109117

110-
form > .actions > input[name="type[ban]"] {
118+
#adminpanel > .actions > input[name="type[ban]"] {
111119
background-color: #e20000;
112120
}
113121

114-
form > .actions > input[name="type[ban]"]:hover {
122+
#adminpanel > .actions > input[name="type[ban]"]:hover {
115123
background-color: #cc0909;
116124
}
117125

118-
form > .actions > input[name="type[unban]"] {
126+
#adminpanel > .actions > input[name="type[unban]"] {
119127
background-color: #0cb61a;
120128
}
121129

122-
form > .actions > input[name="type[unban]"]:hover {
130+
#adminpanel > .actions > input[name="type[unban]"]:hover {
123131
background-color: #0e9b1a;
124132
}
125133

126-
form > .actions > input[name="type[delete]"] {
134+
#adminpanel > .actions > input[name="type[delete]"] {
127135
background-color: #cf1d1d;
128136
}
129137

130-
form > .actions > input[name="type[delete]"]:hover {
138+
#adminpanel > .actions > input[name="type[delete]"]:hover {
131139
background-color: #bb2e2e;
132140
}
133141

134-
form > .actions > input[name="type[makeadmin]"] {
142+
#adminpanel > .actions > input[name="type[makeadmin]"] {
135143
background-color: #e20000;
136144
}
137145

138-
form > .actions > input[name="type[makeadmin]"]:hover {
146+
#adminpanel > .actions > input[name="type[makeadmin]"]:hover {
139147
background-color: #cc0909;
140148
}
141149

142-
form > .actions > input[name="type[makemoderator]"] {
150+
#adminpanel > .actions > input[name="type[makemoderator]"] {
143151
background-color: #0b6dc9;
144152
}
145153

146-
form > .actions > input[name="type[makemoderator]"]:hover {
154+
#adminpanel > .actions > input[name="type[makemoderator]"]:hover {
147155
background-color: #0c59a1;
148156
}
149157

150-
form > .actions > input[name="type[makeuser]"] {
158+
#adminpanel > .actions > input[name="type[makeuser]"] {
151159
background-color: #5ea4c5;
152160
}
153161

154-
form > .actions > input[name="type[makeuser]"]:hover {
162+
#adminpanel > .actions > input[name="type[makeuser]"]:hover {
155163
background-color: #417c97;
156164
}
157165

Diff for: static/styles/auth-mobile.css

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
main > div {
88
grid-column: 2/6;
9-
padding: 5px 10px;
9+
padding: 10px;
1010
font-size: 10pt;
1111
}
1212

Diff for: static/styles/auth.css

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
@import url("font.css");
2+
13
body {
24
padding: 0;
35
margin: 0;

Diff for: static/styles/font.css

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
h1, nav {
2+
font-family: "Montserrat";
3+
}
4+
5+
body {
6+
font-family: "Roboto";
7+
}
8+
9+
10+
@font-face {
11+
font-family: "Montserrat";
12+
src: url("../fonts/Montserrat-Light.ttf");
13+
}
14+
15+
@font-face {
16+
font-family: "Roboto";
17+
src: url("../fonts/RobotoCondensed-Regular.ttf")
18+
}

0 commit comments

Comments
 (0)