Changeset b94c08e in Klonkt


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@…>

Location:
src/views
Files:
5 edited

Legend:

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

    r7963a6e rb94c08e  
    1111
    1212const allPosts = [...pinnedPosts, ...posts];
     13const _base = (typeof siteUrlBase !== 'undefined' && siteUrlBase) ? siteUrlBase : '';
    1314%>
    1415
     
    2627      <% if (user && permissions.canCreatePost(user, site)) { %>
    2728        <p style="margin-top:2rem">
    28           <a class="btn" href="/posts/new"
    29              hx-get="/posts/new?partial=1" hx-target="#pcms-main" hx-swap="innerHTML"
    30              hx-push-url="/posts/new" hx-indicator="#pcms-loading">
     29          <a class="btn" href="<%= _base %>/posts/new"
     30             hx-get="<%= _base %>/posts/new?partial=1" hx-target="#pcms-main" hx-swap="innerHTML"
     31             hx-push-url="<%= _base %>/posts/new" hx-indicator="#pcms-loading">
    3132            Schrijf je eerste post →
    3233          </a>
  • 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    <% } %>
  • src/views/pages/search.ejs

    r7963a6e rb94c08e  
     1<% const _base = (typeof siteUrlBase !== 'undefined' && siteUrlBase) ? siteUrlBase : ''; %>
    12<div class="container search-page">
    23  <h1>Search</h1>
    34
    4   <form method="get" action="/search" class="search-page-form">
     5  <form method="get" action="<%= _base %>/search" class="search-page-form">
    56    <input
    67      type="search"
  • src/views/partials/bottom-tab.ejs

    r7963a6e rb94c08e  
    5959  <% if (_canPost) { %>
    6060    <a class="bottom-tab-item bottom-tab-fab<%= _active === 'create' ? ' is-active' : '' %>"
    61        href="/posts/new"
    62        hx-get="/posts/new?partial=1" hx-target="#pcms-main" hx-swap="innerHTML"
    63        hx-push-url="/posts/new" hx-indicator="#pcms-loading"
     61       href="<%= _siteUrlBase %>/posts/new"
     62       hx-get="<%= _siteUrlBase %>/posts/new?partial=1" hx-target="#pcms-main" hx-swap="innerHTML"
     63       hx-push-url="<%= _siteUrlBase %>/posts/new" hx-indicator="#pcms-loading"
    6464       aria-label="Nieuwe post">
    6565      <svg class="bottom-tab-icon" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.25" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">
  • src/views/partials/profile-sheet.ejs

    r7963a6e rb94c08e  
    2121                 : (user.role === 'editor') ? 'redacteur'
    2222                 : '';
     23// Site-scoped link (post-aanmaken) heeft in hub de /user/<slug>-prefix nodig.
     24const _base = (typeof siteUrlBase !== 'undefined' && siteUrlBase) ? siteUrlBase : '';
    2325%>
    2426
     
    6466      <% if (_canPost) { %>
    6567      <li role="none">
    66         <a href="/posts/new" class="profile-sheet-item" role="menuitem" data-close-sheet
    67            hx-get="/posts/new?partial=1" hx-target="#pcms-main" hx-swap="innerHTML"
    68            hx-push-url="/posts/new" hx-indicator="#pcms-loading">
     68        <a href="<%= _base %>/posts/new" class="profile-sheet-item" role="menuitem" data-close-sheet
     69           hx-get="<%= _base %>/posts/new?partial=1" hx-target="#pcms-main" hx-swap="innerHTML"
     70           hx-push-url="<%= _base %>/posts/new" hx-indicator="#pcms-loading">
    6971          <svg class="psi-icon" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M12 20h9"/><path d="M16.5 3.5a2.121 2.121 0 0 1 3 3L7 19l-4 1 1-4L16.5 3.5z"/></svg>
    7072          <span class="psi-label">Nieuwe post</span>
Note: See TracChangeset for help on using the changeset viewer.