Changeset b94c08e in Klonkt for src/views/pages/post.ejs


Ignore:
Timestamp:
06/14/2026 05:25:41 PM (3 months ago)
Author:
roboburr <roboburr@…>
Branches:
main
Children:
8afbdd6
Parents:
7963a6e
Message:

fix: all site-scoped links use siteUrlBase in hub mode

Follow-up on the feed fix (612b102). The same class of bug was still present in:

  • post.ejs: tag, edit, delete links + comment forms + comment delete + login-next -> now with siteUrlBase prefix
  • bottom-tab.ejs: "Write" FAB (/posts/new)
  • home.ejs: empty-state "Write your first post"
  • profile-sheet.ejs: "New post"
  • search.ejs: search form action

Without the prefix these fell back to the primary site in hub (404 /
wrong site). In solo siteUrlBase is empty -> behavior unchanged.

Co-Authored-By: Claude <noreply@…>

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/views/pages/post.ejs

    r7963a6e rb94c08e  
     1<%
     2// In hub-mode is de site bereikbaar onder /user/<slug>; alle site-scoped links
     3// (tag, edit, delete, comments) moeten met die prefix anders vallen ze terug op
     4// de primaire site → 404 / verkeerde site. In solo is _base = ''.
     5const _base = (typeof siteUrlBase !== 'undefined' && siteUrlBase) ? siteUrlBase : '';
     6%>
    17<article class="container post-page">
    28  <% if (post.cover_image_url) { %>
     
    3036    <div class="post-tags">
    3137      <% post.tags.forEach(t => { %>
    32         <a class="tag" href="/tag/<%= encodeURIComponent(t) %>"
    33            hx-get="/tag/<%= encodeURIComponent(t) %>?partial=1"
     38        <a class="tag" href="<%= _base %>/tag/<%= encodeURIComponent(t) %>"
     39           hx-get="<%= _base %>/tag/<%= encodeURIComponent(t) %>?partial=1"
    3440           hx-target="#pcms-main" hx-swap="innerHTML"
    35            hx-push-url="/tag/<%= encodeURIComponent(t) %>"
     41           hx-push-url="<%= _base %>/tag/<%= encodeURIComponent(t) %>"
    3642           hx-indicator="#pcms-loading">#<%= t %></a>
    3743      <% }); %>
     
    4349    <aside class="post-actions">
    4450      <% if (permissions.canEditPost(user, post, site)) { %>
    45         <a href="/posts/<%= post.slug %>/edit" class="btn"
    46            hx-get="/posts/<%= post.slug %>/edit?partial=1" hx-target="#pcms-main"
    47            hx-push-url="/posts/<%= post.slug %>/edit" hx-indicator="#pcms-loading">
     51        <a href="<%= _base %>/posts/<%= post.slug %>/edit" class="btn"
     52           hx-get="<%= _base %>/posts/<%= post.slug %>/edit?partial=1" hx-target="#pcms-main"
     53           hx-push-url="<%= _base %>/posts/<%= post.slug %>/edit" hx-indicator="#pcms-loading">
    4854          ✏️ Edit
    4955        </a>
    5056      <% } %>
    5157      <% if (permissions.canDeletePost(user, post, site)) { %>
    52         <form method="post" action="/posts/<%= post.slug %>/delete" style="display:inline" onsubmit="return confirm('Delete this post?')">
     58        <form method="post" action="<%= _base %>/posts/<%= post.slug %>/delete" style="display:inline" onsubmit="return confirm('Delete this post?')">
    5359          <button type="submit" class="btn btn-danger">🗑 Delete</button>
    5460        </form>
     
    7884
    7985    <% if (!comments || !comments.length) { %>
    80       <p class="comments-empty">No comments yet.<% if (!user) { %> <a href="/auth/login?next=<%= encodeURIComponent('/' + post.slug + '#comments') %>">Log in</a> to start the conversation.<% } %></p>
     86      <p class="comments-empty">No comments yet.<% if (!user) { %> <a href="/auth/login?next=<%= encodeURIComponent(_base + '/' + post.slug + '#comments') %>">Log in</a> to start the conversation.<% } %></p>
    8187    <% } else { %>
    8288      <ol class="comments-list">
     
    101107                <% } %>
    102108                <% if (user && permissions.canDeleteComment(user, c, site)) { %>
    103                   <form method="post" action="/comments/<%= c.id %>/delete" style="display:inline" onsubmit="return confirm('Delete this comment?')">
     109                  <form method="post" action="<%= _base %>/comments/<%= c.id %>/delete" style="display:inline" onsubmit="return confirm('Delete this comment?')">
    104110                    <button type="submit" class="comment-delete-btn">Delete</button>
    105111                  </form>
     
    109115              <!-- Inline reply form (hidden by default) -->
    110116              <% if (user) { %>
    111                 <form method="post" action="/comments" class="comment-reply-form" hidden data-reply-form-for="<%= c.id %>">
     117                <form method="post" action="<%= _base %>/comments" class="comment-reply-form" hidden data-reply-form-for="<%= c.id %>">
    112118                  <input type="hidden" name="post_slug" value="<%= post.slug %>">
    113119                  <input type="hidden" name="parent_comment_id" value="<%= c.id %>">
     
    140146                        <div class="comment-actions">
    141147                          <% if (user && permissions.canDeleteComment(user, r, site)) { %>
    142                             <form method="post" action="/comments/<%= r.id %>/delete" style="display:inline" onsubmit="return confirm('Delete this comment?')">
     148                            <form method="post" action="<%= _base %>/comments/<%= r.id %>/delete" style="display:inline" onsubmit="return confirm('Delete this comment?')">
    143149                              <button type="submit" class="comment-delete-btn">Delete</button>
    144150                            </form>
     
    158164    <!-- Top-level comment form (only for logged-in users for now) -->
    159165    <% if (user) { %>
    160       <form method="post" action="/comments" class="comment-form">
     166      <form method="post" action="<%= _base %>/comments" class="comment-form">
    161167        <input type="hidden" name="post_slug" value="<%= post.slug %>">
    162168        <label class="comment-form-label">
     
    168174    <% } else { %>
    169175      <p class="comments-login-cta">
    170         <a href="/auth/login?next=<%= encodeURIComponent('/' + post.slug + '#comments') %>" class="btn">Log in to comment</a>
     176        <a href="/auth/login?next=<%= encodeURIComponent(_base + '/' + post.slug + '#comments') %>" class="btn">Log in to comment</a>
    171177      </p>
    172178    <% } %>
Note: See TracChangeset for help on using the changeset viewer.