diff --git a/app/lib/express.js b/app/lib/express.js index b1cde2e..847c9aa 100644 --- a/app/lib/express.js +++ b/app/lib/express.js @@ -350,6 +350,10 @@ router.get("/profile/:id(*)", async (req, res) => { return res.redirect("/"); } + if (isPhone(req)) { + return res.redirect(`/mobile/profile/${id}`); + } + const [profile, posts, friends, friendshipStatus] = await Promise.all([ queries.getProfile(ssbServer, id), queries.getPosts(ssbServer, { id }), @@ -360,6 +364,33 @@ router.get("/profile/:id(*)", async (req, res) => { res.render("profile", { profile, posts, friends, friendshipStatus }); }); +router.get("/mobile/profile/:id(*)", async (req, res) => { + const id = req.params.id; + + if (id == req.context.profile.id) { + return res.redirect("/"); + } + + if (!isPhone(req)) { + return res.redirect(`/profile/${id}`); + } + + const [profile, posts, friends, friendshipStatus] = await Promise.all([ + queries.getProfile(ssbServer, id), + queries.getPosts(ssbServer, { id }), + queries.getFriends(ssbServer, { id }), + queries.getFriendshipStatus(ssbServer, req.context.profile.id, id), + ]); + + res.render("mobile/profile", { + profile, + posts, + friends, + friendshipStatus, + layout: "mobile/_layout", + }); +}); + router.post("/profile/:id(*)/add_friend", async (req, res) => { const id = req.params.id; if (id == req.context.profile.id) { diff --git a/app/public/mobile_style.css b/app/public/mobile_style.css index 182ca3b..42f8641 100644 --- a/app/public/mobile_style.css +++ b/app/public/mobile_style.css @@ -127,3 +127,21 @@ nav a.selected { min-width: auto; flex-grow: 1; } + +.tabs { + border-bottom: 1px solid #5f5f5f; +} + +.tab-title { + border: 1px solid #5f5f5f; + background: #eee; + border-radius: 5px 5px 0 0; + margin-bottom: -1px; + height: 32px; +} + +.tab-title.tab-selected { + background: #fff; + border-bottom: none; + height: 33px; +} diff --git a/app/views/_friendship_button.ejs b/app/views/_friendship_button.ejs new file mode 100644 index 0000000..46da38c --- /dev/null +++ b/app/views/_friendship_button.ejs @@ -0,0 +1,24 @@ +<% if (friendshipStatus == "no_relation") { %> +
+<% } else if (friendshipStatus == "friends") { %> + +<% } else if (friendshipStatus == "request_sent") { %> + +<% } else if (friendshipStatus == "request_received") { %> + + +<% } else if (friendshipStatus == "request_rejected") { %> + +<% } %> \ No newline at end of file diff --git a/app/views/home.ejs b/app/views/home.ejs index 9691f1a..f22196d 100644 --- a/app/views/home.ejs +++ b/app/views/home.ejs @@ -20,7 +20,7 @@