|
6 | 6 |
|
7 | 7 | <h1 class="text-xl pb-5"><?= $item['name'] ?></h1> |
8 | 8 |
|
9 | | - <p><img src="/image?<?= 'item_id='.$item['id'] ?: 'feed_id'.$feed['id'] ?>" class="mx-auto w-3/5 border-solid border-neutral-800 border"></p> |
| 9 | + <div class="media-container"> |
| 10 | + <img src="/image?<?= 'item_id='.$item['id'] ?: 'feed_id'.$feed['id'] ?>" class="album-art"> |
| 11 | + <audio autoplay controls src="/audio?item_id=<?= $item['id'] ?>" class="player"></audio> |
| 12 | + </div> |
10 | 13 |
|
11 | | -<p><audio autoplay controls src="/audio?item_id=<?= $item['id'] ?>" class="w-full m-4 h-13"></audio></p> |
12 | | - |
13 | | - <p><?= $item['description'] ?></p> |
| 14 | + <div id="item-desc"> |
| 15 | + <?= $item['description'] ?> |
| 16 | + </div> |
14 | 17 |
|
15 | 18 | </div> |
16 | 19 |
|
17 | 20 | <style type="text/css"> |
18 | | - #item-desc a {color: rgb(253, 230, 138);} |
19 | | - #item-desc p {padding-bottom: 1em;} |
| 21 | + #item-desc { |
| 22 | + max-width: 65ch; |
| 23 | + margin: 0 auto; |
| 24 | + line-height: 1.6; |
| 25 | + font-size: 1.05rem; |
| 26 | + } |
| 27 | + #item-desc a { |
| 28 | + color: rgb(253, 230, 138); |
| 29 | + text-decoration: underline; |
| 30 | + } |
| 31 | + #item-desc p { |
| 32 | + margin-bottom: 1em; |
| 33 | + } |
| 34 | + |
| 35 | + .media-container { |
| 36 | + max-width: 380px; |
| 37 | + margin: 0 auto 2rem; |
| 38 | + border-radius: 8px; |
| 39 | + box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4); |
| 40 | + overflow: hidden; /* ensure rounded corners apply to children */ |
| 41 | + } |
| 42 | + |
| 43 | + .album-art { |
| 44 | + display: block; |
| 45 | + width: 100%; |
| 46 | + height: auto; |
| 47 | + } |
| 48 | + |
| 49 | + .player { |
| 50 | + width: 100%; |
| 51 | + margin: 0; |
| 52 | + border: none; |
| 53 | + background-color: #1f2937; /* neutral-800 */ |
| 54 | + } |
| 55 | + |
| 56 | + /* Darker controls */ |
| 57 | + .player::-webkit-media-controls-panel { |
| 58 | + background-color: #1f2937; |
| 59 | + color: rgb(253, 230, 138); |
| 60 | + } |
| 61 | + |
| 62 | + @media (max-width: 640px) { |
| 63 | + .media-container { |
| 64 | + max-width: 90%; |
| 65 | + } |
| 66 | + } |
20 | 67 | </style> |
21 | 68 | <script type="text/javascript"> |
22 | 69 | (function() { |
|
41 | 88 | fetch('/set_playback', {method: 'POST', body: params}); |
42 | 89 | } |
43 | 90 | }, interval); |
| 91 | + |
| 92 | + // Convert bare URLs inside #item-desc to clickable links that open in new tab |
| 93 | + (function linkifyDesc() { |
| 94 | + const container = document.getElementById('item-desc'); |
| 95 | + if (!container) return; |
| 96 | + |
| 97 | + const urlRegex = /https?:\/\/[^\s]+/g; |
| 98 | + |
| 99 | + function linkifyNode(node) { |
| 100 | + // Process only text nodes |
| 101 | + if (node.nodeType === Node.TEXT_NODE) { |
| 102 | + const text = node.textContent; |
| 103 | + if (!text) return; |
| 104 | + if (urlRegex.test(text)) { |
| 105 | + const span = document.createElement('span'); |
| 106 | + span.innerHTML = text.replace(urlRegex, url => `<a href="${url}" target="_blank" rel="noopener noreferrer">${url}</a>`); |
| 107 | + node.replaceWith(...span.childNodes); |
| 108 | + } |
| 109 | + } else if (node.nodeType === Node.ELEMENT_NODE && node.tagName !== 'A') { |
| 110 | + // Recurse into child nodes but skip existing anchors |
| 111 | + Array.from(node.childNodes).forEach(linkifyNode); |
| 112 | + } |
| 113 | + } |
| 114 | + |
| 115 | + Array.from(container.childNodes).forEach(linkifyNode); |
| 116 | + })(); |
| 117 | + |
| 118 | + // Ensure any existing links open in a new window/tab |
| 119 | + document.querySelectorAll('#item-desc a').forEach(link => { |
| 120 | + link.setAttribute('target', '_blank'); |
| 121 | + link.setAttribute('rel', 'noopener noreferrer'); |
| 122 | + }); |
44 | 123 | })(); |
45 | 124 | </script> |
0 commit comments