From 0305c721ba04976e04979073a0ff1567bdc5154f Mon Sep 17 00:00:00 2001 From: Matjaz Date: Wed, 2 Mar 2022 21:11:43 +0100 Subject: [PATCH] delo na profilih --- public/stylesheets/style.css | 16 +++++++++ routes/user.js | 17 ++++++--- views/index.ejs | 32 +++-------------- views/login.ejs | 8 ++--- views/me.ejs | 32 +++-------------- views/partials/_messages.ejs | 5 +-- views/partials/_sidebar_menu.ejs | 1 + views/partials/_toot.ejs | 5 +-- views/partials/_user_dropdown.ejs | 27 +++++++++++++++ views/partials/_user_timeline.ejs | 9 +++-- views/register.ejs | 12 +++---- views/settings.ejs | 57 ++++++++++++------------------- views/user.ejs | 32 +++-------------- 13 files changed, 112 insertions(+), 141 deletions(-) create mode 100644 views/partials/_user_dropdown.ejs diff --git a/public/stylesheets/style.css b/public/stylesheets/style.css index e087c81..ef69f7d 100644 --- a/public/stylesheets/style.css +++ b/public/stylesheets/style.css @@ -582,6 +582,14 @@ Ensure the default browser behavior of the `hidden` attribute. height: 9rem; } +.h-12 { + height: 3rem; +} + +.h-24 { + height: 6rem; +} + .max-h-40 { max-height: 10rem; } @@ -602,6 +610,14 @@ Ensure the default browser behavior of the `hidden` attribute. width: 100%; } +.w-12 { + width: 3rem; +} + +.w-24 { + width: 6rem; +} + .max-w-lg { max-width: 32rem; } diff --git a/routes/user.js b/routes/user.js index 01553a9..b8ca884 100644 --- a/routes/user.js +++ b/routes/user.js @@ -43,13 +43,22 @@ router.get('/settings', async function(req, res, next) { router.post('/settings', async function(req, res, next) { var sessionId = req.cookies.sessionid; var auth = await lib.getAuthUser(sessionId); + var newData = {}; + if(req.body.bio != '') { + newData.bio = req.body.bio; + } + if(req.body.name != '') { + newData.name = req.body.name; + } + if(req.files) { + if(req.files.avatar.data) { + newData.avatar = req.files.avatar.data; + } + } if(auth) { console.log(req); console.log(req.files); - await auth.update({ - 'bio': req.body.bio, - 'avatar': req.files.avatar.data, - }); + await auth.update(newData); res.redirect('/user/settings'); } else { res.redirect('/login'); diff --git a/views/index.ejs b/views/index.ejs index 617252e..39cb995 100644 --- a/views/index.ejs +++ b/views/index.ejs @@ -32,38 +32,14 @@
- <%= auth.name %> + <%= auth.name %>
<%= auth.name %>
<%= auth.email %>
- - - -
- - -
- - - + <%- include('partials/_user_dropdown.ejs') %>
@@ -85,7 +61,7 @@ class="lg:flex-1 lg:mx-3 max-w-xl min-w-md dark:bg-gray-600 dark:text-white scrollbar-thin scrollbar-thumb-gray-900 scrollbar-track-gray-700 overflow-y-scroll">
-
Home
+
Home
@@ -93,7 +69,7 @@
- <%= auth.name %> + <%= auth.name %>
diff --git a/views/me.ejs b/views/me.ejs index 91be890..f5ed344 100644 --- a/views/me.ejs +++ b/views/me.ejs @@ -32,38 +32,14 @@
- <%= auth.name %> + <%= auth.name %>
<%= auth.name %>
<%= auth.email %>
- - - -
- - -
- - - + <%- include('partials/_user_dropdown.ejs') %>
@@ -85,7 +61,7 @@ class="lg:flex-1 lg:mx-3 max-w-xl min-w-md dark:bg-gray-600 dark:text-white scrollbar-thin scrollbar-thumb-gray-900 scrollbar-track-gray-700 overflow-y-scroll">
-
Home
+
@@ -93,7 +69,7 @@
- <%= auth.name %> + <%= auth.name %>
+ + +
+ + +
+ \ No newline at end of file diff --git a/views/partials/_user_timeline.ejs b/views/partials/_user_timeline.ejs index d5f21af..b11b296 100644 --- a/views/partials/_user_timeline.ejs +++ b/views/partials/_user_timeline.ejs @@ -1,17 +1,20 @@ + <% for(var i = 0; i < messages.length; i++) {%>
- <%= user.name %> + <%= user.name %>
- <%= user.name %> + <%= user.name %>

- <%= messages[i].body%> + <% messages[i].body.split('\n').forEach(line => { %> + <%= line %>
+ <% }) %>

Posted on: <%= messages[i].createdAt %> diff --git a/views/register.ejs b/views/register.ejs index 31f2612..9c9e8d5 100644 --- a/views/register.ejs +++ b/views/register.ejs @@ -17,18 +17,18 @@
diff --git a/views/settings.ejs b/views/settings.ejs index bff1881..4b4f8d8 100644 --- a/views/settings.ejs +++ b/views/settings.ejs @@ -32,38 +32,14 @@
- <%= auth.name %> + <%= auth.name %>
<%= auth.name %>
<%= auth.email %>
- - - -
- - -
- - - + <%- include('partials/_user_dropdown.ejs') %>
@@ -85,7 +61,7 @@ class="lg:flex-1 lg:mx-3 max-w-xl min-w-md dark:bg-gray-600 dark:text-white scrollbar-thin scrollbar-thumb-gray-900 scrollbar-track-gray-700 overflow-y-scroll">
-
Home
+
@@ -93,7 +69,7 @@
- <%= auth.name %> + <%= auth.name %>
+
+ + +
+
+ +
+
+ +
+
+ +
diff --git a/views/user.ejs b/views/user.ejs index 2b3ea6a..8c8632f 100644 --- a/views/user.ejs +++ b/views/user.ejs @@ -32,38 +32,14 @@
- <%= auth.name %> + <%= auth.name %>
<%= auth.name %>
<%= auth.email %>
- - - -
- - -
- - - + <%- include('partials/_user_dropdown.ejs') %>
@@ -85,7 +61,7 @@ class="lg:flex-1 lg:mx-3 max-w-xl min-w-md dark:bg-gray-600 dark:text-white scrollbar-thin scrollbar-thumb-gray-900 scrollbar-track-gray-700 overflow-y-scroll">
-
Home
+
@@ -93,7 +69,7 @@
- <%= user.name %> + <%= user.name %>