diff --git a/app/lib/express.js b/app/lib/express.js index e02d0a4..abde795 100644 --- a/app/lib/express.js +++ b/app/lib/express.js @@ -493,14 +493,18 @@ router.get( } ); -router.get("/communities/:name/new", async (req, res) => { - const community = await communityData(req); +router.get( + "/communities/:name/new", + { mobileVersion: "/mobile/communities/:name/new" }, + async (req, res) => { + const community = await communityData(req); - res.render("communities/new_topic", { - community, - layout: "communities/_layout", - }); -}); + res.render("communities/new_topic", { + community, + layout: "communities/_layout", + }); + } +); router.post("/communities/:name/new", async (req, res) => { const name = req.params.name; @@ -540,21 +544,25 @@ router.post("/communities/:name/:key(*)/publish", async (req, res) => { res.redirect(`/communities/${name}/${key}`); }); -router.get("/communities/:name/:key(*)", async (req, res) => { - const name = req.params.name; - const key = "%" + req.params.key; +router.get( + "/communities/:name/:key(*)", + { mobileVersion: "/mobile/communities/:name/:key" }, + async (req, res) => { + const name = req.params.name; + const key = "%" + req.params.key; - const [community, posts] = await Promise.all([ - communityData(req), - queries.getPostWithReplies(name, key), - ]); + const [community, posts] = await Promise.all([ + communityData(req), + queries.getPostWithReplies(name, key), + ]); - res.render("communities/topic", { - posts, - community, - layout: "communities/_layout", - }); -}); + res.render("communities/topic", { + posts, + community, + layout: "communities/_layout", + }); + } +); router.get("/search", async (req, res) => { const query = req.query.query; diff --git a/app/lib/mobile-routes.js b/app/lib/mobile-routes.js index 8d96c50..acbe678 100644 --- a/app/lib/mobile-routes.js +++ b/app/lib/mobile-routes.js @@ -99,4 +99,34 @@ module.exports.setupRoutes = (router) => { }); } ); + + router.get( + "/mobile/communities/:name/new", + { desktopVersion: "/communities/:name/new" }, + async (req, res) => { + const name = req.params.name; + + res.render("mobile/communities/new_topic", { + community: { name }, + layout: "mobile/_layout", + }); + } + ); + + router.get( + "/mobile/communities/:name/:key(*)", + { desktopVersion: "/communities/:name/:key" }, + async (req, res) => { + const name = req.params.name; + const key = "%" + req.params.key; + + const posts = await queries.getPostWithReplies(name, key); + + res.render("mobile/communities/topic", { + posts, + community: { name }, + layout: "mobile/_layout", + }); + } + ); }; diff --git a/app/public/style.css b/app/public/style.css index d034913..fd5562f 100644 --- a/app/public/style.css +++ b/app/public/style.css @@ -174,6 +174,7 @@ h2 { .post-content { padding-left: 10px; + width: calc(100% - 48px); } .wall { diff --git a/app/views/mobile/communities/new_topic.ejs b/app/views/mobile/communities/new_topic.ejs new file mode 100644 index 0000000..121148c --- /dev/null +++ b/app/views/mobile/communities/new_topic.ejs @@ -0,0 +1,15 @@ +
+
+ + +
+ +
+
+
\ No newline at end of file diff --git a/app/views/mobile/communities/topic.ejs b/app/views/mobile/communities/topic.ejs new file mode 100644 index 0000000..6aaa084 --- /dev/null +++ b/app/views/mobile/communities/topic.ejs @@ -0,0 +1,25 @@ +<% if (posts.length > 0) { %> +
+

+ + ⮃  #<%= community.name %> + +

+

<%= topicTitle(posts[0].value) %>

+
+ <%- include("../../_posts", { posts: posts.map(x => x.value), dont_cut: true }) %> + +
/publish" method="POST" style="padding: 14px; border-top: 1px solid #ddd;"> + +
+ +
+
+<% } else { %> +
+

404 topic not found

+
+<% } %> \ No newline at end of file