From 35d21d63aec8f0ce6092f6b18abf7c4ba38ccd4a Mon Sep 17 00:00:00 2001 From: Chris Vitalos Date: Wed, 11 Oct 2023 20:28:45 -0400 Subject: [PATCH] commit mastodon-timeline to test --- test/css/mastodon-timeline-3.8.1-2.css | 459 ------------------------- test/css/mastodon-timeline-3.8.1.css | 339 ------------------ test/css/mastodon-timeline.css | 11 +- test/js/mastodon-timeline.js | 72 ++-- 4 files changed, 62 insertions(+), 819 deletions(-) delete mode 100644 test/css/mastodon-timeline-3.8.1-2.css delete mode 100644 test/css/mastodon-timeline-3.8.1.css diff --git a/test/css/mastodon-timeline-3.8.1-2.css b/test/css/mastodon-timeline-3.8.1-2.css deleted file mode 100644 index 61a89de..0000000 --- a/test/css/mastodon-timeline-3.8.1-2.css +++ /dev/null @@ -1,459 +0,0 @@ -/* Mastodon embed feed timeline 3.8.1-2 */ -/* More info at: */ -/* https://gitlab.com/idotj/mastodon-embed-feed-timeline */ - - -/* Main container */ -.mt-timeline { - height: calc(100% - 4rem); - padding: .5rem .5rem; - position: relative; - background: white; -} - -.mt-timeline a:link, -.mt-timeline a:active, -.mt-timeline a { - text-decoration: none; - color: #0000EE; -} - -.mt-timeline a:visited { - color: #551ABB; -} - -.mt-body { - height: 100%; - overflow-y: auto; - white-space: pre-wrap; - word-wrap: break-word; -} - -.mt-body .invisible { - display: none; -} - -/* Toot container */ -.mt-toot { - margin: 0 0 0 0; - padding: 1rem 1rem 1rem 1rem; - position: relative; - min-height: 60px; - background-color: transparent; - border-bottom: 1px solid #dee2e6; -} - -.mt-toot:hover { - cursor: pointer; - background-color: rgba(124, 124, 124, 0.2); -} - -.mt-toot p:last-child { - margin-bottom: 0; -} - -/* User icon */ -.mt-user { - display: inline-block; - font-weight: normal; - position: absolute; - top: 26px; - left: 75px; -} - -.mt-avatar { - position: absolute; - top: 20px; - left: 15px; - width: 50px; - height: 50px; - background-color: transparent; - background-repeat: no-repeat; - background-position: 50% 50%; - background-size: contain; - background-color: #fff; - border-radius: 5px; -} - -.mt-avatar-boosted { - position: absolute; - top: 20px; - left: 15px; - width: 50px; - height: 50px; -} - -.mt-avatar-booster { - position: absolute; - top: 20px; - left: 15px; - width: 50px; - height: 50px; -} - -/* Message */ -.toot-text { - margin-bottom: 0.25rem; - color: black; - padding-top: 60px; -} - -.toot-text .ellipsis::after { - content: '...'; -} - -.mt-error { - color: darkred; - background: lightpink; - margin: 5px; - padding: 10px; -} - -/* Poll */ -.toot-poll { - margin-bottom: 0.25rem; - color: black; -} - -.toot-poll ul { - list-style: none; - padding: 0; - margin: 0; -} - -.toot-poll ul li:not(:last-child) { - margin-bottom: 0.25rem; -} - -.toot-poll ul li:before { - content: "◯"; - padding-right: 0.5rem; -} - -/* Medias */ -.toot-media { - overflow: hidden; - margin-bottom: 0.25rem; -} - -.toot-media-preview { - position: relative; - margin-top: 0.25rem; - height: auto; - text-align: center; - width: 100%; -} - -.toot-media-spoiler>img { - filter: blur(2rem); -} - -.toot-media-preview a { - display: block; - position: absolute; - top: 0; - right: 0; - bottom: 0; - left: 0; -} - -.img-ratio14_7 { - position: relative; - padding-top: 48.95%; - /* 14:7 */ - width: 100%; -} - -.img-ratio14_7>img { - width: 100%; - height: auto; - position: absolute; - top: 50%; - left: 50%; - transform: translate(-50%, -50%); - text-align: center; -} - -/* Date */ -.toot-date { - font-size: 0.75rem; - opacity: 0.5; -} - -/* Loading-spinner */ -.loading-spinner { - height: 100%; - background-image: url("data:image/svg+xml;charset=utf8,%3Csvg xmlns:svg='http://www.w3.org/2000/svg' xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www.w3.org/1999/xlink' version='1.0' viewBox='0 0 128 128' %3E%3Cg%3E%3Cpath d='M64 128A64 64 0 0 1 18.34 19.16L21.16 22a60 60 0 1 0 52.8-17.17l.62-3.95A64 64 0 0 1 64 128z' fill='%23404040'/%3E%3CanimateTransform attributeName='transform' type='rotate' from='0 64 64' to='360 64 64' dur='1000ms' repeatCount='indefinite'%3E%3C/animateTransform%3E%3C/g%3E%3C/svg%3E"); - background-repeat: no-repeat; - background-position: center center; - background-color: transparent; - background-size: min(2.5rem, calc(100% - 0.5rem)); -} - -/* See more btn */ -.mt-seeMore { - margin: 2rem auto; - padding: 0 2rem; - text-align: center; -} - -/* Hidden element */ -.visually-hidden { - position: absolute !important; - width: 1px !important; - height: 1px !important; - padding: 0 !important; - margin: -1px !important; - overflow: hidden !important; - clip: rect(0, 0, 0, 0) !important; - white-space: nowrap !important; - border: 0 !important; -} - -.toot-text blockquote { - border-left: 4px solid #777696; - margin-left: 0; - /* Reset the default margin */ - padding-left: 8px; - /* Add padding for the quoted text */ -} - -/* Mastodon embed feed timeline v3.8.1-2 */ -/* More info at: */ -/* https://gitlab.com/idotj/mastodon-embed-feed-timeline */ - -/* Variables */ -:root { - --text-max-lines: none; -} - -/* Theme colors */ -:root, -html[data-theme="light"] { - --bg-color: #fff; - --bg-hover-color: #d9e1e8; - --line-gray-color: #c0cdd9; - --content-text: #000; - --link-color: #3a3bff; - --error-text-color: #8b0000; -} - -html[data-theme="dark"] { - --bg-color: #fff; - --bg-hover-color: #d9e1e8; - --line-gray-color: #c0cdd9; - --content-text: #000; - --link-color: #3a3bff; - --error-text-color: #8b0000; -} - -/* Main container */ -.mt-timeline { - height: 100%; - overflow-y: auto; - position: relative; - background: var(--bg-color); - scrollbar-color: var(--bg-hover-color) rgba(0, 0, 0, 0.1); -} - -.mt-timeline a:not(.toot-preview-link):hover { - text-decoration: underline; -} - -.mt-timeline::-webkit-scrollbar { - width: 0.75rem; - height: 0.75rem; -} - -.mt-timeline::-webkit-scrollbar-corner { - background: transparent; -} - -.mt-timeline::-webkit-scrollbar-thumb { - border: 0 var(--content-text); - border-radius: 2rem; - background: var(--bg-hover-color); -} - -.mt-timeline::-webkit-scrollbar-track { - border: 0 var(--content-text); - border-radius: 0; - background: rgba(0, 0, 0, 0.1); -} - -.mt-toot:hover, -.mt-toot:focus { - cursor: pointer; - background-color: var(--bg-hover-color); -} - -/* User icon */ -.mt-avatar { - position: absolute; - top: 1rem; - left: 15px; - width: 3rem; - height: 3rem; - background-repeat: no-repeat; - background-position: 50% 50%; - background-size: contain; - background-color: var(--bg-color); - border-radius: 5px; -} - -.mt-user { - display: table; - font-weight: 600; - margin-bottom: 1rem; -} - -.mt-user>a { - color: var(--link-color) !important; - top: 27px; - font-weight: normal; -} - -/* Text */ -.toot-text { - margin-bottom: 0.25rem; - color: var(--content-text); -} - -.toot-text .spoiler-link { - display: inline-block; -} - -.toot-text .spoiler-text-hidden { - display: none; -} - -.toot-text.truncate { - display: -webkit-box; - overflow: hidden; - -webkit-line-clamp: var(--text-max-lines); - -webkit-box-orient: vertical; -} - -.toot-text:not(.truncate) .ellipsis::after { - content: "..."; -} - -.mt-error-icon { - font-size: 2rem; -} - -.mt-error-message { - padding: 1rem 0; -} - -.toot-poll ul li { - font-size: 0.9rem; - margin-bottom: 0.5rem; -} - -.toot-media>.spoiler-link { - position: absolute; - top: 50%; - left: 50%; - z-index: 1; - transform: translate(-50%, -50%); -} - -/* Preview link */ -.toot-preview-link { - min-height: 4rem; - display: flex; - flex-direction: row; - flex-wrap: wrap; - border: 1px solid var(--line-gray-color); - border-radius: 0.5rem; - color: var(--link-color); - font-size: 1.0rem; - margin: 1rem 0 0.5rem 0; - overflow: hidden; -} - -.toot-preview-image { - width: 100%; - align-self: stretch; -} - -.toot-preview-image img { - display: block; - width: 100%; - height: 100%; - object-fit: cover; -} - -.toot-preview-noImage { - width: 40%; - font-size: 1.5rem; - align-self: center; - text-align: center; -} - -.toot-preview-content { - width: 60%; - display: flex; - align-self: center; - flex-direction: column; - padding: 0.5rem 1rem; - gap: 0.5rem; -} - -.toot-preview-title { - font-weight: 600; -} - -/* Spoiler button */ -.spoiler-link { - border-radius: 2px; - background-color: var(--line-gray-color); - border: 0; - color: var(--content-text); - font-weight: 700; - font-size: 0.7rem; - padding: 0 0.35rem; - text-transform: uppercase; - line-height: 1.25rem; - cursor: pointer; - vertical-align: top; -} - -/* Loading-spinner */ -.mt-body>.loading-spinner { - position: absolute; - width: 3rem; - height: 3rem; - margin: auto; - top: calc(50% - 1.5rem); - right: calc(50% - 1.5rem); -} - -.loading-spinner { - background-image: url("data:image/svg+xml;charset=utf8,%3Csvg xmlns:svg='http://www.w3.org/2000/svg' xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www.w3.org/1999/xlink' version='1.0' viewBox='0 0 128 128' %3E%3Cg%3E%3Cpath d='M64 128A64 64 0 0 1 18.34 19.16L21.16 22a60 60 0 1 0 52.8-17.17l.62-3.95A64 64 0 0 1 64 128z' fill='%23404040'/%3E%3CanimateTransform attributeName='transform' type='rotate' from='0 64 64' to='360 64 64' dur='1000ms' repeatCount='indefinite'%3E%3C/animateTransform%3E%3C/g%3E%3C/svg%3E"); - background-repeat: no-repeat; - background-position: center center; - background-color: transparent; - background-size: min(2.5rem, calc(100% - 0.5rem)); -} - -/* Footer (See more link) */ -.mt-footer { - margin: 1rem auto 2rem auto; - padding: 0 2rem; - text-align: center; -} - -/* Hidden element */ -.visually-hidden { - position: absolute !important; - width: 1px !important; - height: 1px !important; - padding: 0 !important; - margin: -1px !important; - overflow: hidden !important; - clip: rect(0, 0, 0, 0) !important; - white-space: nowrap !important; - border: 0 !important; -} diff --git a/test/css/mastodon-timeline-3.8.1.css b/test/css/mastodon-timeline-3.8.1.css deleted file mode 100644 index 77df6d6..0000000 --- a/test/css/mastodon-timeline-3.8.1.css +++ /dev/null @@ -1,339 +0,0 @@ -/* Mastodon embed feed timeline v3.8.1 */ -/* More info at: */ -/* https://gitlab.com/idotj/mastodon-embed-feed-timeline */ - -/* Variables */ -:root { - --text-max-lines: none; -} - -/* Theme colors */ -:root, -html[data-theme="light"] { - --bg-color: #fff; - --bg-hover-color: #d9e1e8; - --line-gray-color: #c0cdd9; - --content-text: #000; - --link-color: #3a3bff; - --error-text-color: #8b0000; -} -html[data-theme="dark"] { - --bg-color: #282c37; - --bg-hover-color: #313543; - --line-gray-color: #393f4f; - --content-text: #fff; - --link-color: #8c8dff; - --error-text-color: #fe6c6c; -} - -/* Main container */ -.mt-timeline { - height: 100%; - overflow-y: auto; - position: relative; - background: var(--bg-color); - scrollbar-color: var(--bg-hover-color) rgba(0, 0, 0, 0.1); -} -.mt-timeline a:link, -.mt-timeline a:active, -.mt-timeline a { - text-decoration: none; - color: var(--link-color); -} -.mt-timeline a:not(.toot-preview-link):hover { - text-decoration: underline; -} -.mt-timeline::-webkit-scrollbar { - width: 0.75rem; - height: 0.75rem; -} -.mt-timeline::-webkit-scrollbar-corner { - background: transparent; -} -.mt-timeline::-webkit-scrollbar-thumb { - border: 0 var(--content-text); - border-radius: 2rem; - background: var(--bg-hover-color); -} -.mt-timeline::-webkit-scrollbar-track { - border: 0 var(--content-text); - border-radius: 0; - background: rgba(0, 0, 0, 0.1); -} - -.mt-body { - padding: 1rem 1.5rem; - white-space: pre-wrap; - word-wrap: break-word; -} -.mt-body .invisible { - font-size: 0; - line-height: 0; - display: inline-block; - width: 0; - height: 0; - position: absolute; -} - -/* Toot container */ -.mt-toot { - margin: 0.25rem; - padding: 1rem 0.5rem 1.5rem 4rem; - position: relative; - min-height: 3.75rem; - background-color: transparent; - border-bottom: 1px solid var(--line-gray-color); -} -.mt-toot:hover, -.mt-toot:focus { - cursor: pointer; - background-color: var(--bg-hover-color); -} -.mt-toot p:last-child { - margin-bottom: 0; -} - -/* User icon */ -.mt-avatar { - position: absolute; - top: 1rem; - left: 5px; - width: 3rem; - height: 3rem; - background-repeat: no-repeat; - background-position: 50% 50%; - background-size: contain; - background-color: var(--bg-color); - border-radius: 5px; -} -.mt-avatar-boosted { - width: 2.5rem; - height: 2.5rem; -} -.mt-avatar-booster { - width: 1.5rem; - height: 1.5rem; - top: 1.5rem; - left: 1.5rem; -} -.mt-user { - display: table; - font-weight: 600; - margin-bottom: 1rem; -} -.mt-user > a { - color: var(--content-text) !important; -} - -/* Text */ -.toot-text { - margin-bottom: 0.25rem; - color: var(--content-text); -} -.toot-text .spoiler-link { - display: inline-block; -} -.toot-text .spoiler-text-hidden { - display: none; -} -.toot-text.truncate { - display: -webkit-box; - overflow: hidden; - -webkit-line-clamp: var(--text-max-lines); - -webkit-box-orient: vertical; -} -.toot-text:not(.truncate) .ellipsis::after { - content: "..."; -} - -.toot-text blockquote { - border-left: 4px solid var(--line-gray-color); - margin-left: 0; - padding-left: 8px; -} - -.mt-error { - position: absolute; - display: flex; - flex-direction: column; - height: calc(100% - 3.5rem); - width: calc(100% - 4.5rem); - justify-content: center; - align-items: center; - color: var(--error-text-color); - padding: 0.75rem; - text-align: center; -} - -.mt-error-icon { - font-size: 2rem; -} -.mt-error-message { - padding: 1rem 0; -} - -/* Poll */ -.toot-poll { - margin-bottom: 0.25rem; - color: var(--content-text); -} -.toot-poll ul { - list-style: none; - padding: 0; - margin: 0; -} -.toot-poll ul li { - font-size: 0.9rem; - margin-bottom: 0.5rem; -} -.toot-poll ul li:not(:last-child) { - margin-bottom: 0.25rem; -} -.toot-poll ul li:before { - content: "◯"; - padding-right: 0.5rem; -} - -/* Medias */ -.toot-media { - overflow: hidden; - margin-bottom: 0.5rem; -} -.toot-media-preview { - position: relative; - margin-top: 0.25rem; - height: auto; - text-align: center; - width: 100%; -} -.toot-media > .spoiler-link { - position: absolute; - top: 50%; - left: 50%; - z-index: 1; - transform: translate(-50%, -50%); -} -.toot-media-spoiler > img { - filter: blur(2rem); -} -.toot-media-preview a { - display: block; - position: absolute; - top: 0; - right: 0; - bottom: 0; - left: 0; -} - -.img-ratio14_7 { - position: relative; - padding-top: 56.95%; - width: 100%; -} -.img-ratio14_7 > img { - width: 100%; - height: auto; - position: absolute; - top: 50%; - left: 50%; - transform: translate(-50%, -50%); - text-align: center; -} - -/* Preview link */ -.toot-preview-link { - min-height: 4rem; - display: flex; - flex-direction: row; - - border: 1px solid var(--line-gray-color); - border-radius: 0.5rem; - color: var(--link-color); - font-size: 0.8rem; - margin: 1rem 0 0.5rem 0; - overflow: hidden; -} -.toot-preview-image { - width: 40%; - align-self: stretch; -} -.toot-preview-image img { - display: block; - width: 100%; - height: 100%; - object-fit: cover; -} -.toot-preview-noImage { - width: 40%; - font-size: 1.5rem; - align-self: center; - text-align: center; -} -.toot-preview-content { - width: 60%; - display: flex; - align-self: center; - flex-direction: column; - padding: 0.5rem 1rem; - gap: 0.5rem; -} -.toot-preview-title { - font-weight: 600; -} - -/* Spoiler button */ -.spoiler-link { - border-radius: 2px; - background-color: var(--line-gray-color); - border: 0; - color: var(--content-text); - font-weight: 700; - font-size: 0.7rem; - padding: 0 0.35rem; - text-transform: uppercase; - line-height: 1.25rem; - cursor: pointer; - vertical-align: top; -} - -/* Date */ -.toot-date { - font-size: 0.75rem; -} - -/* Loading-spinner */ -.mt-body > .loading-spinner { - position: absolute; - width: 3rem; - height: 3rem; - margin: auto; - top: calc(50% - 1.5rem); - right: calc(50% - 1.5rem); -} -.loading-spinner { - background-image: url("data:image/svg+xml;charset=utf8,%3Csvg xmlns:svg='http://www.w3.org/2000/svg' xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www.w3.org/1999/xlink' version='1.0' viewBox='0 0 128 128' %3E%3Cg%3E%3Cpath d='M64 128A64 64 0 0 1 18.34 19.16L21.16 22a60 60 0 1 0 52.8-17.17l.62-3.95A64 64 0 0 1 64 128z' fill='%23404040'/%3E%3CanimateTransform attributeName='transform' type='rotate' from='0 64 64' to='360 64 64' dur='1000ms' repeatCount='indefinite'%3E%3C/animateTransform%3E%3C/g%3E%3C/svg%3E"); - background-repeat: no-repeat; - background-position: center center; - background-color: transparent; - background-size: min(2.5rem, calc(100% - 0.5rem)); -} - -/* Footer (See more link) */ -.mt-footer { - margin: 1rem auto 2rem auto; - padding: 0 2rem; - text-align: center; -} - -/* Hidden element */ -.visually-hidden { - position: absolute !important; - width: 1px !important; - height: 1px !important; - padding: 0 !important; - margin: -1px !important; - overflow: hidden !important; - clip: rect(0, 0, 0, 0) !important; - white-space: nowrap !important; - border: 0 !important; -} diff --git a/test/css/mastodon-timeline.css b/test/css/mastodon-timeline.css index 9cededb..5b9d616 100644 --- a/test/css/mastodon-timeline.css +++ b/test/css/mastodon-timeline.css @@ -1,4 +1,4 @@ -/* Mastodon embed feed timeline v3.10.0-3 */ +/* Mastodon embed feed timeline v3.10.1-1 */ /* More info at: */ /* https://gitlab.com/clvgt12/mastodon-embed-feed-timeline */ @@ -216,6 +216,9 @@ text-decoration: underline; font-size: 0.9rem; margin-bottom: 0.5rem; } +.mt-toot-poll.mt-toot-poll-expired ul li { + color: var(--contrast-gray-color); +} .mt-toot-poll ul li:not(:last-child) { margin-bottom: 0.25rem; } @@ -223,6 +226,10 @@ text-decoration: underline; content: "◯"; padding-right: 0.5rem; } +.mt-toot-poll.mt-toot-poll-expired ul li:before { + content: ""; + padding-right: 0; +} /* Medias */ .mt-toot-media { @@ -253,6 +260,7 @@ text-decoration: underline; left: 50%; transform: translate(-50%, -50%); text-align: center; + color: var(--content-text); } /* Preview link */ @@ -276,6 +284,7 @@ text-decoration: underline; width: 100%; height: 100%; object-fit: cover; + color: var(--content-text); } .mt-toot-preview-noImage { width: 40%; diff --git a/test/js/mastodon-timeline.js b/test/js/mastodon-timeline.js index 82a5dfb..e15dafc 100644 --- a/test/js/mastodon-timeline.js +++ b/test/js/mastodon-timeline.js @@ -1,5 +1,5 @@ /** - * Mastodon embed feed timeline v3.10.0-3 + * Mastodon embed feed timeline v3.10.1-1 * More info at: * https://gitlab.com/idotj/mastodon-embed-feed-timeline */ @@ -183,7 +183,7 @@ MastodonApi.prototype.buildTimeline = async function () { } else if (this.TIMELINE_TYPE === "local") { linkSeeMorePath = "public/local"; } - let linkSeeMore = + const linkSeeMore = '" + '
' + '' +
-      c.account.username +
+      this.replaceQuotes(c.account.username) +
       ' avatar' + "
" + "" + @@ -471,7 +471,7 @@ MastodonApi.prototype.assambleToot = function (c, i) { // Date formattedDate = this.formatDate(date); - let timestamp = + const timestamp = '
' + '"; } poll = - '
' + "
    " + pollOption + "
" + "
"; + '
' + + "
    " + + pollOption + + "
" + + "
"; } // Counter bar let counterBar = ""; if (!this.HIDE_COUNTER_BAR) { - let repliesCount = + const repliesCount = '
' + '' + c.replies_count + "
"; - let reblogCount = + const reblogCount = '
' + '' + c.reblogs_count + "
"; - let favoritesCount = + const favoritesCount = '
' + '' + c.favourites_count + @@ -606,7 +612,7 @@ MastodonApi.prototype.assambleToot = function (c, i) { } // Add all to main toot container - let toot = + const toot = '
' + "
"; @@ -751,7 +757,7 @@ MastodonApi.prototype.placeMedias = function (m, s) { * @returns {string} Preview link in HTML format */ MastodonApi.prototype.placePreviewLink = function (c) { - let card = + const card = '
' + @@ -760,18 +766,24 @@ MastodonApi.prototype.placePreviewLink = function (c) { this.SPINNER_CLASS + '">
' + '" alt="' + + this.replaceQuotes(c.image_description) + + '" loading="lazy" />' : '
') + "" + '
' + (c.provider_name - ? '' + c.provider_name + "" + ? '' + + this.parseHTMLstring(c.provider_name) + + "" : "") + '' + c.title + "" + (c.author_name - ? 'By ' + c.author_name + "" + ? '' + + this.parseHTMLstring(c.author_name) + + "" : "") + "
" + "
"; @@ -800,7 +812,7 @@ MastodonApi.prototype.formatDate = function (d) { "Dec", ]; - let date = new Date(d); + const date = new Date(d); const displayDate = monthNames[date.getMonth()] + @@ -812,6 +824,26 @@ MastodonApi.prototype.formatDate = function (d) { return displayDate; }; +/** + * Parse HTML string + * @param {string} s HTML string + * @returns {string} Plain text + */ +MastodonApi.prototype.parseHTMLstring = function (s) { + const parser = new DOMParser(); + const txt = parser.parseFromString(s, "text/html"); + return txt.body.textContent; +}; + +/** + * Replace quotes + * @param {string} s String + * @returns {string} String + */ +MastodonApi.prototype.replaceQuotes = function (s) { + return s.replace('"', "'"); +}; + /** * Add/Remove event listener for loading spinner */