source: Klonkt/src/views/pages/download.ejs@ 17197a9

main
Last change on this file since 17197a9 was 17197a9, checked in by roboburr <roboburr@…>, 3 months ago

fix(download): track var 't' shadowed the i18n t() -> 500 on /download/:id

The download capture view had 'var t = dlTrack' at the top level, which
corrupted the shared EJS locals -> chrome/topnav called t() = 't is not a
function'. Renamed to 'tr'. (Same class of bug as the earlier search.ejs issue.)

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

  • Property mode set to 100644
File size: 3.1 KB
Line 
1<%
2 var _ready_h1 = t('dl.ready_title');
3 var _ready_sub = t('dl.ready_sub');
4 var _manual = t('dl.manual');
5 var _capture_sub = t('dl.capture_sub');
6 var _email_ph = t('dl.email_ph');
7 var _download_btn = t('dl.download_btn');
8%>
9<%
10 var tr = (typeof dlTrack !== 'undefined') ? dlTrack : {};
11 var st = (typeof dlState !== 'undefined') ? dlState : 'form';
12 var fileUrl = siteUrlBase + '/download/' + tr.id + '/bestand';
13%>
14<section class="dl">
15 <div class="dl-card">
16 <div class="dl-head">
17 <% if (tr.cover_url) { %><span class="dl-cover" style="background-image:url('<%= tr.cover_url %>')"></span><% } else { %><span class="dl-cover dl-cover-empty">♪</span><% } %>
18 <div>
19 <div class="dl-title"><%= tr.title %></div>
20 <% if (tr.artist) { %><div class="dl-artist"><%= tr.artist %></div><% } %>
21 </div>
22 </div>
23
24 <% if (st === 'ready') { %>
25 <h1 class="dl-h1"><%= _ready_h1 %></h1>
26 <p class="dl-sub"><%= _ready_sub %></p>
27 <p><a class="dl-go" href="<%= fileUrl %>"><%= _manual %></a></p>
28 <script>
29 // Auto-start de download (zelfde-origin attachment-link).
30 setTimeout(function(){ try { window.location.href = <%- JSON.stringify(fileUrl) %>; } catch(e){} }, 600);
31 </script>
32 <% } else { %>
33 <h1 class="dl-h1"><%= _download_btn %> <%= tr.title %></h1>
34 <p class="dl-sub"><%= _capture_sub %></p>
35 <% if (typeof dlError !== 'undefined' && dlError) { %><p class="dl-err"><%= dlError %></p><% } %>
36 <form method="POST" action="<%= siteUrlBase %>/download/<%= tr.id %>" class="dl-form">
37 <input type="email" name="email" required placeholder="<%= _email_ph %>" value="<%= (typeof dlPrefill!=='undefined')?dlPrefill:'' %>" autocomplete="email">
38 <button type="submit" class="dl-go">⬇ <%= _download_btn %></button>
39 </form>
40 <% } %>
41 </div>
42</section>
43
44<style>
45 .dl { max-width: 520px; margin: 0 auto; padding: 48px 18px; }
46 .dl-card { border: 1px solid rgba(128,128,128,.2); border-radius: 18px; padding: 28px; }
47 .dl-head { display: flex; align-items: center; gap: 14px; margin-bottom: 18px; }
48 .dl-cover { width: 56px; height: 56px; border-radius: 10px; background-size: cover; background-position: center; display: grid; place-items: center; flex: 0 0 auto; }
49 .dl-cover-empty { background: var(--accent,#6b8f71); color: #fff; opacity: .85; }
50 .dl-title { font-weight: 700; font-size: 17px; }
51 .dl-artist { opacity: .65; font-size: 13px; }
52 .dl-h1 { font-size: clamp(22px,4.5vw,30px); margin: 0 0 8px; }
53 .dl-sub { opacity: .85; line-height: 1.55; margin: 0 0 18px; }
54 .dl-err { color: #c43c3c; margin: 0 0 12px; }
55 .dl-form { display: flex; gap: 10px; flex-wrap: wrap; }
56 .dl-form input { flex: 1 1 200px; padding: 12px 14px; border-radius: 10px; border: 1px solid rgba(128,128,128,.4); background: transparent; color: inherit; font-size: 15px; }
57 .dl-go { padding: 12px 20px; border-radius: 10px; border: none; background: var(--accent,#6b8f71); color: #fff; font-weight: 600; font-size: 15px; cursor: pointer; text-decoration: none; display: inline-block; }
58</style>
Note: See TracBrowser for help on using the repository browser.