cube vor 1 Tag
Ursprung
Commit
ce8b6facfa

+ 2
- 0
.gitignore Datei anzeigen

@@ -13,3 +13,5 @@ dist/
13 13
 build/
14 14
 *.egg-info/
15 15
 /myriad/static/icons
16
+/myriad/static/blinkies
17
+/myriad/static/stamps

+ 2
- 0
README.md Datei anzeigen

@@ -6,6 +6,8 @@ logged in users are presumed to all be admins with distinction only between bein
6 6
 
7 7
 in the blog view, member privacy outweighs individual post privacy. if a private member makes a public post, it will not show up in the public feed. however, if that member switches to public, their public posts will all become publicly viewable (but private posts will remain private). 
8 8
 
9
+the blinkies and stamps stuff is literally just because i want an easy way to upload them when i find them. and im the dev so i get to decide mwa ha ha
10
+
9 11
 # dev set up (windows)
10 12
 
11 13
 - after cloning, run `py -3 -m venv .venv` in the root directory and then `.venv\Scripts\activate`

+ 3
- 1
myriad/home.py Datei anzeigen

@@ -50,8 +50,10 @@ def page(mid):
50 50
     blog = db.execute("SELECT * FROM blog WHERE member_id=(?) ORDER BY created DESC",(mid,)).fetchall()
51 51
     icon = db.execute("SELECT icon_location FROM icons WHERE id=(?)",(member[6],)).fetchone()
52 52
     all_icons = db.execute("SELECT icon_location FROM icons WHERE member_id=(?)",(mid,)).fetchall()
53
+    blinkies = db.execute("SELECT blinkie_location FROM blinkies WHERE member_id=(?)",(mid,)).fetchall()
54
+    stamps = db.execute("SELECT stamp_location FROM stamps WHERE member_id=(?)",(mid,)).fetchall()
53 55
 
54
-    return render_template('page.html', member=member, blog=blog, icon=icon, all_icons=all_icons)
56
+    return render_template('page.html', member=member, blog=blog, icon=icon, all_icons=all_icons, blinkies=blinkies, stamps=stamps)
55 57
 
56 58
 @bp.route("/groups")
57 59
 def groups():

+ 48
- 4
myriad/manage.py Datei anzeigen

@@ -38,8 +38,10 @@ def delete(mid):
38 38
 @login_required
39 39
 def edit(mid):
40 40
     db = get_db()
41
+    edit_location=None
41 42
 
42 43
     if request.method == "POST":
44
+
43 45
         if "name" in request.form:
44 46
             name = request.form['name']
45 47
             bio = request.form['bio']
@@ -49,6 +51,8 @@ def edit(mid):
49 51
             db.execute("UPDATE member SET member_name=(?), bio=(?), subtitle=(?), public=(?), theme=(?) WHERE id=(?)",(name, bio, subtitle, privacy, theme, mid))
50 52
             db.commit()
51 53
 
54
+            edit_location="details"
55
+
52 56
         if "file" in request.files:
53 57
             # here we are just saving the uploaded file to the icons folder. 
54 58
             # we're not going hard on security because we expect there to only be 1 admin
@@ -56,22 +60,48 @@ def edit(mid):
56 60
             file = request.files["file"]
57 61
             filename = str(uuid.uuid4()) + "." + file.filename.split(".")[1]
58 62
             file.save(os.path.join(current_app.config["ICON_UPLOAD_FOLDER"], filename))
59
-            db.execute("INSERT INTO icons (member_id, icon_location) VALUES (?, ?)", (mid, filename),)
63
+            db.execute("INSERT INTO icons (member_id, icon_location) VALUES (?, ?)", (mid, filename))
60 64
             db.commit()
61 65
 
66
+            edit_location="icons"
67
+
62 68
         if "gid_add" in request.form:
63 69
             gid = request.form["gid_add"]
64 70
             db.execute("INSERT INTO group_members (group_id,member_id) VALUES (?,?)",(gid,mid))
65 71
             db.commit()
66 72
 
73
+            edit_location="groups"
74
+
67 75
         elif "gid_remove" in request.form:
68 76
             gid = request.form["gid_remove"]
69 77
             db.execute("DELETE FROM group_members WHERE group_id=(?) AND member_id=(?)",(gid,mid))
70 78
             db.commit()
71 79
 
80
+            edit_location="groups"
81
+
82
+        if "blinkie" in request.files:
83
+            file = request.files["blinkie"]
84
+            filename = str(uuid.uuid4()) + "." + file.filename.split(".")[1]
85
+            file.save(os.path.join(current_app.config["BLINKIES_UPLOAD_FOLDER"], filename))
86
+            db.execute("INSERT INTO blinkies (member_id, blinkie_location) VALUES (?, ?)", (mid, filename))
87
+            db.commit()
88
+
89
+            edit_location="blinkies"
90
+
91
+        if "stamp" in request.files:
92
+            file = request.files["stamp"]
93
+            filename = str(uuid.uuid4()) + "." + file.filename.split(".")[1]
94
+            file.save(os.path.join(current_app.config["STAMPS_UPLOAD_FOLDER"], filename))
95
+            db.execute("INSERT INTO stamps (member_id, stamp_location) VALUES (?, ?)", (mid, filename))
96
+            db.commit()
97
+
98
+            edit_location="stamps"
99
+
72 100
 
73 101
     member = db.execute("SELECT * FROM member WHERE id=(?)",(mid,)).fetchone()
74 102
     icons = db.execute("SELECT * FROM icons WHERE member_id=(?)",(mid,)).fetchall()
103
+    blinkies = db.execute("SELECT * FROM blinkies WHERE member_id=(?)",(mid,)).fetchall()
104
+    stamps = db.execute("SELECT * FROM stamps WHERE member_id=(?)",(mid,)).fetchall()
75 105
 
76 106
     groups = db.execute("SELECT * FROM groups").fetchall()
77 107
     member_groups = db.execute("SELECT * FROM group_members WHERE member_id=(?)",(mid,)).fetchall()
@@ -91,7 +121,7 @@ def edit(mid):
91 121
 
92 122
     themes = os.listdir(current_app.config["THEMES_FOLDER"])
93 123
 
94
-    return render_template("manage/edit.html", member=member, icons=icons, unjoined_groups=unjoined_groups, joined_groups=joined_groups, themes=themes)
124
+    return render_template("manage/edit.html", member=member, icons=icons, unjoined_groups=unjoined_groups, joined_groups=joined_groups, themes=themes, edit_location=edit_location, blinkies=blinkies, stamps=stamps)
95 125
 
96 126
 @bp.route("/set_main_icon/<mid>/<icon_id>")
97 127
 @login_required
@@ -164,10 +194,21 @@ def remove_home(mid,location):
164 194
         return redirect(url_for('home.full_list'))
165 195
 
166 196
 
167
-@bp.route("/assets")
197
+@bp.route("/assets", methods=('GET', 'POST'))
168 198
 @login_required
169 199
 def assets():
170 200
     db = get_db()
201
+
202
+    if "blinkie" in request.files:
203
+        file = request.files["blinkie"]
204
+        filename = file.filename
205
+        file.save(os.path.join(current_app.config["BLINKIES_UPLOAD_FOLDER"], filename))
206
+
207
+    if "stamp" in request.files:
208
+        file = request.files["stamp"]
209
+        filename = file.filename
210
+        file.save(os.path.join(current_app.config["STAMPS_UPLOAD_FOLDER"], filename))
211
+
171 212
     icons = db.execute("SELECT * FROM icons").fetchall()
172 213
     icon_storage = os.listdir(current_app.config["ICON_UPLOAD_FOLDER"])
173 214
     
@@ -188,7 +229,10 @@ def assets():
188 229
         if not in_storage:
189 230
             unlinked_icons.append(i)
190 231
 
191
-    return render_template("manage/assets.html", icons=unlinked_icons, icon_storage=i_storage)
232
+    blinkies = os.listdir(current_app.config["BLINKIES_UPLOAD_FOLDER"])
233
+    stamps = os.listdir(current_app.config["STAMPS_UPLOAD_FOLDER"])
234
+
235
+    return render_template("manage/assets.html", icons=unlinked_icons, icon_storage=i_storage, blinkies=blinkies, stamps=stamps)
192 236
 
193 237
 @bp.route("/delete_idb")
194 238
 @login_required

+ 16
- 0
myriad/schema.sql Datei anzeigen

@@ -4,6 +4,8 @@ DROP TABLE IF EXISTS icons;
4 4
 DROP TABLE IF EXISTS groups;
5 5
 DROP TABLE IF EXISTS group_members;
6 6
 DROP TABLE IF EXISTS blog;
7
+DROP TABLE IF EXISTS blinkies;
8
+DROP TABLE IF EXISTS stamps;
7 9
 
8 10
 CREATE TABLE user (
9 11
   id INTEGER PRIMARY KEY AUTOINCREMENT,
@@ -57,4 +59,18 @@ CREATE TABLE blog (
57 59
   content TEXT,
58 60
   public BOOLEAN NOT NULL DEFAULT 1,
59 61
   FOREIGN KEY (member_id) REFERENCES member (id)
62
+);
63
+
64
+CREATE TABLE blinkies (
65
+  id INTEGER PRIMARY KEY AUTOINCREMENT,
66
+  member_id INTEGER NOT NULL,
67
+  blinkie_location TEXT NOT NULL,
68
+  FOREIGN KEY (member_id) REFERENCES member (id)
69
+);
70
+
71
+CREATE TABLE stamps (
72
+  id INTEGER PRIMARY KEY AUTOINCREMENT,
73
+  member_id INTEGER NOT NULL,
74
+  stamp_location TEXT NOT NULL,
75
+  FOREIGN KEY (member_id) REFERENCES member (id)
60 76
 );

+ 2
- 0
myriad/templates/manage/assets.html Datei anzeigen

@@ -36,8 +36,10 @@
36 36
   {% endif %}
37 37
 
38 38
   <div class="heading big">Blinkies</div>
39
+  
39 40
 
40 41
   <div class="heading big">Stamps</div>
41 42
 
43
+
42 44
   </div>
43 45
 {% endblock %}

+ 34
- 7
myriad/templates/manage/edit.html Datei anzeigen

@@ -7,13 +7,12 @@
7 7
 {% block content %}
8 8
 <div class="container">
9 9
 
10
-  
11 10
   <a href="{{url_for('home.page', mid=member[0])}}">View {{member[3]}}'s page</a>
12 11
   <br class="clear" />
13 12
 
14 13
   <div class="heading">Edit Details</div>
15 14
 
16
-  <form method="post">
15
+  <form method="post" id="details">
17 16
     <label for="name">Name</label>
18 17
     <input name="name" id="name" value="{{ member[3] }}" required><br>
19 18
     <label for="subtitle">Subtitle</label>
@@ -36,9 +35,10 @@
36 35
 
37 36
   <a href="{{ url_for('manage.delete', mid=member[0]) }}" class="danger">Delete member</a> - WARNING: this is permanent and cannot be undone!
38 37
 
38
+
39 39
   <div class="heading">Manage groups</div>
40 40
 
41
-  <form method="post">
41
+  <form method="post" id="groups">
42 42
     <select name="gid_add" id="gid_add">
43 43
       {% for group in unjoined_groups %}
44 44
       <option value="{{group[0]}}">{{group[1]}}</option>
@@ -58,22 +58,49 @@
58 58
 
59 59
 
60 60
   <div class="heading">Manage Icons</div>
61
-  <form method="post" enctype="multipart/form-data">
61
+  <form method="post" enctype="multipart/form-data" id="icons">
62 62
       <input type="file" name="file">
63 63
       <input type="submit" value="Upload New Icon">
64 64
   </form>
65 65
 
66
-  <div id="manage_icons">
66
+  <div id="manage_icons" id="icons">
67 67
     {% for icon in icons %}
68
-
69 68
       <img class="icon" src="{{ url_for('static', filename='icons/'+icon[2]) }}">
70 69
       <br class="clear" />
71 70
       <a href="{{ url_for('manage.set_main_icon', mid=member[0], icon_id=icon[0]) }}">Set Main Icon</a> &#9734 <a href="{{ url_for('manage.delete_icon', mid=member[0], icon_id=icon[0]) }}">Delete Icon</a>
72 71
       <br class="clear" />
73 72
       <hr>
74
-
75 73
     {% endfor %}
76 74
   </div>
77 75
 
76
+
77
+
78
+  <div class="heading">Manage Blinkies</div>
79
+  <form method="post" enctype="multipart/form-data" id="blinkies">
80
+      <input type="file" name="blinkie">
81
+      <input type="submit" value="Upload to Blinkies">
82
+  </form>
83
+
84
+  {% for blinkie in blinkies %}
85
+      <img src="{{ url_for('static', filename='blinkies/'+blinkie[2]) }}">
86
+    {% endfor %}
87
+  
88
+
89
+  <div class="heading">Manage Stamps</div>
90
+  <form method="post" enctype="multipart/form-data" id="stamps">
91
+      <input type="file" name="stamp">
92
+      <input type="submit" value="Upload to Stamps">
93
+  </form>
94
+
95
+  {% for stamp in stamps %}
96
+      <img src="{{ url_for('static', filename='stamps/'+stamp[2]) }}">
97
+    {% endfor %}
98
+  
99
+
100
+
101
+  {% if edit_location %}
102
+  <script>document.getElementById('{{edit_location}}').scrollIntoView();</script>
103
+  {% endif %}
104
+
78 105
 </div>
79 106
 {% endblock %}

+ 17
- 1
myriad/templates/page.html Datei anzeigen

@@ -47,11 +47,27 @@
47 47
     {% endif %}
48 48
 
49 49
     {% if all_icons|length > 1 %}
50
-    <div class="heading big">{{member[3]}}'s icons</div>
50
+    <div class="heading big">Icons</div>
51 51
     {% for i in all_icons %}
52 52
     <img class="icon" src="{{ url_for('static', filename='icons/'+i[0]) }}">
53 53
     {% endfor %}
54 54
     {% endif %}
55
+    <br class="clear" />
56
+
57
+    {% if blinkies|length > 0 %}
58
+    <div class="heading big">Blinkies</div>
59
+    {% for blinkie in blinkies %}
60
+    <img src="{{ url_for('static', filename='blinkies/'+blinkie[0]) }}">
61
+    {% endfor %}
62
+    {% endif %}
63
+    <br class="clear" />
64
+
65
+    {% if stamps|length > 0 %}
66
+    <div class="heading big">Stamps</div>
67
+    {% for stamp in stamps %}
68
+    <img src="{{ url_for('static', filename='stamps/'+stamp[0]) }}">
69
+    {% endfor %}
70
+    {% endif %}
55 71
 
56 72
 
57 73
     {% endif %}