cube vor 1 Tag
Ursprung
Commit
ce8b6facfa
8 geänderte Dateien mit 124 neuen und 13 gelöschten Zeilen
  1. 2
    0
      .gitignore
  2. 2
    0
      README.md
  3. 3
    1
      myriad/home.py
  4. 48
    4
      myriad/manage.py
  5. 16
    0
      myriad/schema.sql
  6. 2
    0
      myriad/templates/manage/assets.html
  7. 34
    7
      myriad/templates/manage/edit.html
  8. 17
    1
      myriad/templates/page.html

+ 2
- 0
.gitignore Datei anzeigen

13
 build/
13
 build/
14
 *.egg-info/
14
 *.egg-info/
15
 /myriad/static/icons
15
 /myriad/static/icons
16
+/myriad/static/blinkies
17
+/myriad/static/stamps

+ 2
- 0
README.md Datei anzeigen

6
 
6
 
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). 
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
 # dev set up (windows)
11
 # dev set up (windows)
10
 
12
 
11
 - after cloning, run `py -3 -m venv .venv` in the root directory and then `.venv\Scripts\activate`
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
     blog = db.execute("SELECT * FROM blog WHERE member_id=(?) ORDER BY created DESC",(mid,)).fetchall()
50
     blog = db.execute("SELECT * FROM blog WHERE member_id=(?) ORDER BY created DESC",(mid,)).fetchall()
51
     icon = db.execute("SELECT icon_location FROM icons WHERE id=(?)",(member[6],)).fetchone()
51
     icon = db.execute("SELECT icon_location FROM icons WHERE id=(?)",(member[6],)).fetchone()
52
     all_icons = db.execute("SELECT icon_location FROM icons WHERE member_id=(?)",(mid,)).fetchall()
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
 @bp.route("/groups")
58
 @bp.route("/groups")
57
 def groups():
59
 def groups():

+ 48
- 4
myriad/manage.py Datei anzeigen

38
 @login_required
38
 @login_required
39
 def edit(mid):
39
 def edit(mid):
40
     db = get_db()
40
     db = get_db()
41
+    edit_location=None
41
 
42
 
42
     if request.method == "POST":
43
     if request.method == "POST":
44
+
43
         if "name" in request.form:
45
         if "name" in request.form:
44
             name = request.form['name']
46
             name = request.form['name']
45
             bio = request.form['bio']
47
             bio = request.form['bio']
49
             db.execute("UPDATE member SET member_name=(?), bio=(?), subtitle=(?), public=(?), theme=(?) WHERE id=(?)",(name, bio, subtitle, privacy, theme, mid))
51
             db.execute("UPDATE member SET member_name=(?), bio=(?), subtitle=(?), public=(?), theme=(?) WHERE id=(?)",(name, bio, subtitle, privacy, theme, mid))
50
             db.commit()
52
             db.commit()
51
 
53
 
54
+            edit_location="details"
55
+
52
         if "file" in request.files:
56
         if "file" in request.files:
53
             # here we are just saving the uploaded file to the icons folder. 
57
             # here we are just saving the uploaded file to the icons folder. 
54
             # we're not going hard on security because we expect there to only be 1 admin
58
             # we're not going hard on security because we expect there to only be 1 admin
56
             file = request.files["file"]
60
             file = request.files["file"]
57
             filename = str(uuid.uuid4()) + "." + file.filename.split(".")[1]
61
             filename = str(uuid.uuid4()) + "." + file.filename.split(".")[1]
58
             file.save(os.path.join(current_app.config["ICON_UPLOAD_FOLDER"], filename))
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
             db.commit()
64
             db.commit()
61
 
65
 
66
+            edit_location="icons"
67
+
62
         if "gid_add" in request.form:
68
         if "gid_add" in request.form:
63
             gid = request.form["gid_add"]
69
             gid = request.form["gid_add"]
64
             db.execute("INSERT INTO group_members (group_id,member_id) VALUES (?,?)",(gid,mid))
70
             db.execute("INSERT INTO group_members (group_id,member_id) VALUES (?,?)",(gid,mid))
65
             db.commit()
71
             db.commit()
66
 
72
 
73
+            edit_location="groups"
74
+
67
         elif "gid_remove" in request.form:
75
         elif "gid_remove" in request.form:
68
             gid = request.form["gid_remove"]
76
             gid = request.form["gid_remove"]
69
             db.execute("DELETE FROM group_members WHERE group_id=(?) AND member_id=(?)",(gid,mid))
77
             db.execute("DELETE FROM group_members WHERE group_id=(?) AND member_id=(?)",(gid,mid))
70
             db.commit()
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
     member = db.execute("SELECT * FROM member WHERE id=(?)",(mid,)).fetchone()
101
     member = db.execute("SELECT * FROM member WHERE id=(?)",(mid,)).fetchone()
74
     icons = db.execute("SELECT * FROM icons WHERE member_id=(?)",(mid,)).fetchall()
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
     groups = db.execute("SELECT * FROM groups").fetchall()
106
     groups = db.execute("SELECT * FROM groups").fetchall()
77
     member_groups = db.execute("SELECT * FROM group_members WHERE member_id=(?)",(mid,)).fetchall()
107
     member_groups = db.execute("SELECT * FROM group_members WHERE member_id=(?)",(mid,)).fetchall()
91
 
121
 
92
     themes = os.listdir(current_app.config["THEMES_FOLDER"])
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
 @bp.route("/set_main_icon/<mid>/<icon_id>")
126
 @bp.route("/set_main_icon/<mid>/<icon_id>")
97
 @login_required
127
 @login_required
164
         return redirect(url_for('home.full_list'))
194
         return redirect(url_for('home.full_list'))
165
 
195
 
166
 
196
 
167
-@bp.route("/assets")
197
+@bp.route("/assets", methods=('GET', 'POST'))
168
 @login_required
198
 @login_required
169
 def assets():
199
 def assets():
170
     db = get_db()
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
     icons = db.execute("SELECT * FROM icons").fetchall()
212
     icons = db.execute("SELECT * FROM icons").fetchall()
172
     icon_storage = os.listdir(current_app.config["ICON_UPLOAD_FOLDER"])
213
     icon_storage = os.listdir(current_app.config["ICON_UPLOAD_FOLDER"])
173
     
214
     
188
         if not in_storage:
229
         if not in_storage:
189
             unlinked_icons.append(i)
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
 @bp.route("/delete_idb")
237
 @bp.route("/delete_idb")
194
 @login_required
238
 @login_required

+ 16
- 0
myriad/schema.sql Datei anzeigen

4
 DROP TABLE IF EXISTS groups;
4
 DROP TABLE IF EXISTS groups;
5
 DROP TABLE IF EXISTS group_members;
5
 DROP TABLE IF EXISTS group_members;
6
 DROP TABLE IF EXISTS blog;
6
 DROP TABLE IF EXISTS blog;
7
+DROP TABLE IF EXISTS blinkies;
8
+DROP TABLE IF EXISTS stamps;
7
 
9
 
8
 CREATE TABLE user (
10
 CREATE TABLE user (
9
   id INTEGER PRIMARY KEY AUTOINCREMENT,
11
   id INTEGER PRIMARY KEY AUTOINCREMENT,
57
   content TEXT,
59
   content TEXT,
58
   public BOOLEAN NOT NULL DEFAULT 1,
60
   public BOOLEAN NOT NULL DEFAULT 1,
59
   FOREIGN KEY (member_id) REFERENCES member (id)
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
   {% endif %}
36
   {% endif %}
37
 
37
 
38
   <div class="heading big">Blinkies</div>
38
   <div class="heading big">Blinkies</div>
39
+  
39
 
40
 
40
   <div class="heading big">Stamps</div>
41
   <div class="heading big">Stamps</div>
41
 
42
 
43
+
42
   </div>
44
   </div>
43
 {% endblock %}
45
 {% endblock %}

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

7
 {% block content %}
7
 {% block content %}
8
 <div class="container">
8
 <div class="container">
9
 
9
 
10
-  
11
   <a href="{{url_for('home.page', mid=member[0])}}">View {{member[3]}}'s page</a>
10
   <a href="{{url_for('home.page', mid=member[0])}}">View {{member[3]}}'s page</a>
12
   <br class="clear" />
11
   <br class="clear" />
13
 
12
 
14
   <div class="heading">Edit Details</div>
13
   <div class="heading">Edit Details</div>
15
 
14
 
16
-  <form method="post">
15
+  <form method="post" id="details">
17
     <label for="name">Name</label>
16
     <label for="name">Name</label>
18
     <input name="name" id="name" value="{{ member[3] }}" required><br>
17
     <input name="name" id="name" value="{{ member[3] }}" required><br>
19
     <label for="subtitle">Subtitle</label>
18
     <label for="subtitle">Subtitle</label>
36
 
35
 
37
   <a href="{{ url_for('manage.delete', mid=member[0]) }}" class="danger">Delete member</a> - WARNING: this is permanent and cannot be undone!
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
   <div class="heading">Manage groups</div>
39
   <div class="heading">Manage groups</div>
40
 
40
 
41
-  <form method="post">
41
+  <form method="post" id="groups">
42
     <select name="gid_add" id="gid_add">
42
     <select name="gid_add" id="gid_add">
43
       {% for group in unjoined_groups %}
43
       {% for group in unjoined_groups %}
44
       <option value="{{group[0]}}">{{group[1]}}</option>
44
       <option value="{{group[0]}}">{{group[1]}}</option>
58
 
58
 
59
 
59
 
60
   <div class="heading">Manage Icons</div>
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
       <input type="file" name="file">
62
       <input type="file" name="file">
63
       <input type="submit" value="Upload New Icon">
63
       <input type="submit" value="Upload New Icon">
64
   </form>
64
   </form>
65
 
65
 
66
-  <div id="manage_icons">
66
+  <div id="manage_icons" id="icons">
67
     {% for icon in icons %}
67
     {% for icon in icons %}
68
-
69
       <img class="icon" src="{{ url_for('static', filename='icons/'+icon[2]) }}">
68
       <img class="icon" src="{{ url_for('static', filename='icons/'+icon[2]) }}">
70
       <br class="clear" />
69
       <br class="clear" />
71
       <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>
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
       <br class="clear" />
71
       <br class="clear" />
73
       <hr>
72
       <hr>
74
-
75
     {% endfor %}
73
     {% endfor %}
76
   </div>
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
 </div>
105
 </div>
79
 {% endblock %}
106
 {% endblock %}

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

47
     {% endif %}
47
     {% endif %}
48
 
48
 
49
     {% if all_icons|length > 1 %}
49
     {% if all_icons|length > 1 %}
50
-    <div class="heading big">{{member[3]}}'s icons</div>
50
+    <div class="heading big">Icons</div>
51
     {% for i in all_icons %}
51
     {% for i in all_icons %}
52
     <img class="icon" src="{{ url_for('static', filename='icons/'+i[0]) }}">
52
     <img class="icon" src="{{ url_for('static', filename='icons/'+i[0]) }}">
53
     {% endfor %}
53
     {% endfor %}
54
     {% endif %}
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
     {% endif %}
73
     {% endif %}