[READ-ONLY] Mirror of https://github.com/probablykasper/lumix. Art website (unfinished)
art website
0

Configure Feed

Select the types of activity you want to include in your feed.

Ability to save settings without uploading new avatar

KH (Mar 14, 2018, 6:22 PM +0100) 62d15fda 7e8e2934

+20 -22
-1
.gitignore
··· 1 1 web/letsencrypt 2 - web/images/* 3 2 **/keys.js 4 3 db/db
+1 -1
web/js/forms.js
··· 310 310 function save() { 311 311 312 312 const data = new FormData(); 313 - data.append("image", uploadData[0], uploadData[0].name); 313 + if (window.uploadData) data.append("image", uploadData[0], uploadData[0].name); 314 314 data.append("displayname", $(".settings-form input.displayname").val()); 315 315 data.append("bio", $(".settings-form textarea.bio").val()); 316 316
+16 -18
web/node/upload-routes.js
··· 1 1 "use strict"; 2 2 const Image = require("./mongoose-models").Image; 3 + const User = require("./mongoose-models").User; 3 4 4 5 function b32() { 5 6 const length = 11; ··· 111 112 profilePictureUpload.array("image", 1)(req, res, function(err) { 112 113 if (err) { 113 114 // error when uploading 114 - console.log("ERROR UPLOADING"); 115 - console.log(err); 115 + errors.push(err); 116 116 return; 117 117 } 118 118 // success 119 119 console.log("SUCCESS UPLOADING"); 120 - req.files[0].filename; 121 - req.files[0].path; 122 120 console.log(req.files); 123 121 console.log(req.body); 122 + const updatedUser = { 123 + displayname: req.body.displayname, 124 + bio: req.body.bio, 125 + } 126 + if (req.files.length == 1) { 127 + updatedUser.profilePictureURL = "/pp/"+req.files[0].filename; 128 + } 124 129 125 - let displayname = req.body.displayname; 126 - let bio = req.body.bio; 127 - 128 - // new Image({ 129 - // userID: res.locals.userID, 130 - // filename: req.files[0].filename, 131 - // fileID: req.files[0].fileID, 132 - // title: title, 133 - // description: description, 134 - // tags: tags, 135 - // }).save((err) => { 136 - // if (err) errors.push("unknown 5"); 137 - // sendResponse(); 138 - // }); 130 + User.findOneAndUpdate({ 131 + _id: res.locals.userID 132 + }, updatedUser, (err, resultUser) => { 133 + res.json({ 134 + errors: errors, 135 + }); 136 + }); 139 137 140 138 141 139 });
+1 -1
web/pug/logged-in/settings.pug
··· 12 12 label(for="displayname") Displayname 13 13 input.form-field.displayname(type="text", name="displayname" id="displayname" value=displayname) 14 14 label(for="bio") Bio 15 - textarea.form-field.auto-resize.bio(type="text" name="bio" id="bio" rows="3" value=bio) 15 + textarea.form-field.auto-resize.bio(type="text" name="bio" id="bio" rows="3")=bio 16 16 button.button.save(tabIndex="0") Save
+1
web/server.js
··· 33 33 // static content 34 34 app.use("/", express.static(dir("static"), { redirect: false })); 35 35 app.use("/i/", express.static(dir("images"), { redirect: false })); 36 + app.use("/pp/", express.static(dir("profile-pictures"), { redirect: false })); 36 37 app.use("/", express.static(dir("static/favicon"), { redirect: false })); 37 38 38 39 const bodyParser = require("body-parser");
+1 -1
web/static/global.js
··· 492 492 function save() { 493 493 494 494 var data = new FormData(); 495 - data.append("image", uploadData[0], uploadData[0].name); 495 + if (window.uploadData) data.append("image", uploadData[0], uploadData[0].name); 496 496 data.append("displayname", $(".settings-form input.displayname").val()); 497 497 data.append("bio", $(".settings-form textarea.bio").val()); 498 498