~cadence/Frames

6ebd9c1a3b167f5ff75762355f256cd4270357e0 — Cadence Ember 1 year, 9 months ago 9ec92c3
Add button to open/close all CWs on page
4 files changed, 14 insertions(+), 8 deletions(-)

M api/view.js
M pug/feed.pug
M pug/includes/post.pug
M pug/post.pug
M api/view.js => api/view.js +3 -1
@@ 21,11 21,13 @@ module.exports = [
					post: db.prepare("SELECT * FROM Posts WHERE handle = ? AND id = ?").get(handle, id)
				})
			} else {
				const openAllCWs = url.searchParams.has("open-cws")
				return render(200, "pug/feed.pug", {
					viewer,
					handle,
					isSelf: handle === viewer.row.handle,
					posts: db.prepare("SELECT * FROM Posts WHERE handle = ? ORDER BY id DESC").all(handle)
					posts: db.prepare("SELECT * FROM Posts WHERE handle = ? ORDER BY id DESC").all(handle),
					openAllCWs
				})
			}
		} catch (e) {

M pug/feed.pug => pug/feed.pug +5 -1
@@ 12,6 12,10 @@ block main
      button= `[Sign out]`
  unless isSelf
    div You are viewing #[span.highlight #{handle}]
  if openAllCWs
    div: a(href="?") [Close all CWs]
  else if posts.some(p => p.cw)
    div: a(href="?open-cws") [Open all CWs]

  if isSelf
    details.publish-frame


@@ 32,6 36,6 @@ block main

        button.pop-button Publish
  each post in posts
    +post(post)
    +post(post, {openAllCWs})
  else
    .no-posts No frames, yet.

M pug/includes/post.pug => pug/includes/post.pug +5 -5
@@ 1,19 1,19 @@
mixin post(post, isSelf)
mixin post(post, options = {})
  .post
    - const url = `/view/${post.handle}/${post.id}`
    .post__author
      a(href=url).post__link #{post.handle} at #{new Date(+post.id).toISOString().replace("T", " ").slice(0, -8)}
    if isSelf
    if options.showDelete
      form(method="post" action=`${url}/delete`).single-button-form.post__delete
        button= `[Delete post forever]`
    +post-optional-cw(post)
    +post-optional-cw(post, options)
      if post.content
        .post__content= post.content
      a(href=post.url): img(src=post.url).post__image

mixin post-optional-cw(post)
mixin post-optional-cw(post, options)
  if post.cw
    details
    details(open=options.openAllCWs)
      summary.post__cw CW: #{post.cw}
      block
  else

M pug/post.pug => pug/post.pug +1 -1
@@ 13,6 13,6 @@ block main
  div You are #[span.highlight viewing a frame] from #{handle}
  if post
    div #[a(href=`/view/${handle}`) View all frames] from #{handle}
    +post(post, isSelf)
    +post(post, {showDelete: isSelf})
  else
    div.highlight Frame not found.