Add ellipses to long messages + remove access token

This commit is contained in:
idotj 2021-05-17 20:13:19 +02:00
parent d2c6190297
commit 050222abe1
5 changed files with 246 additions and 247 deletions

View File

@ -1,11 +1,11 @@
image: alpine:latest image: alpine:latest
pages: pages:
stage: deploy stage: deploy
script: script:
- echo 'Nothing to do...' - echo 'Nothing to do...'
artifacts: artifacts:
paths: paths:
- public - public
only: only:
- master - master

View File

@ -1,19 +1,19 @@
# Mastodon embed timeline # Mastodon embed timeline
Embed a mastodon feed timeine in your page, with just html, css and js. Embed a mastodon feed timeine in your page, with just html, css and js.
Working version running at: Working version running at:
https://www.idotj.com https://www.idotj.com
## User guide ## User guide
## Licensing ## Licensing
## Improve me ## Improve me
Feel free to add a chaching layer, improve the styles and add more features. Feel free to add a chaching layer, improve the styles and add more features.

View File

@ -1,52 +1,52 @@
<!doctype html> <!doctype html>
<html lang="en" dir="ltr"> <html lang="en" dir="ltr">
<head> <head>
<meta charset="utf-8"> <meta charset="utf-8">
<title>Mastodon timeline</title> <title>Mastodon timeline</title>
<meta name="author" content="i.j"> <meta name="author" content="i.j">
<meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name="viewport" content="width=device-width, initial-scale=1.0">
<!-- <base href="https://www.idotj.com/" /> --> <!-- <base href="https://www.idotj.com/" /> -->
<meta name="keywords" content="" /> <meta name="keywords" content="" />
<meta name="description" content="" /> <meta name="description" content="" />
<link rel="stylesheet" href="mastodon-timeline.css"> <link rel="stylesheet" href="mastodon-timeline.css">
<style> <style>
*{ *{
margin:0; margin:0;
padding:0; padding:0;
} }
html{ html{
height:100% height:100%
} }
body{ body{
height:100%; height:100%;
background: lightslategray; background: lightslategray;
font-size:16px; font-size:16px;
font-family: Arial, Helvetica; font-family: Arial, Helvetica;
margin:0; margin:0;
padding:0; padding:0;
} }
.dummy-container { .dummy-container {
height:calc(100% - 4rem); height:calc(100% - 4rem);
margin: 0 auto; margin: 0 auto;
max-width: 30rem; max-width: 30rem;
padding: 2rem; padding: 2rem;
} }
</style> </style>
</head> </head>
<body> <body>
<div class="dummy-container"> <div class="dummy-container">
<div id="mt-timeline" class="mt-timeline"> <div id="mt-timeline" class="mt-timeline">
<div class="mt-body"> <div class="mt-body">
<div class="loading-spinner"></div> <div class="loading-spinner"></div>
</div> </div>
</div> </div>
</div> </div>
<script src='mastodon-timeline.js'> <script src='mastodon-timeline.js'>
</script> </script>
</body> </body>
</html> </html>

View File

@ -1,165 +1,164 @@
/* Mastodon embed timeline */ /* Mastodon embed timeline */
/* main container */ /* Main container */
.mt-timeline { .mt-timeline {
height: calc(100% - 4rem); height: calc(100% - 4rem);
padding: 2rem 3rem; padding: 2rem 3rem;
position: relative; position: relative;
background: lightgray; background: lightgray;
} }
.mt-timeline a:link, .mt-timeline a:link,
.mt-timeline a:active, .mt-timeline a:active,
.mt-timeline a { .mt-timeline a {
text-decoration: none; text-decoration: none;
color: darkblue; color: darkblue;
} }
.mt-body { .mt-body {
height: 100%; height: 100%;
overflow-y: auto; overflow-y: auto;
white-space: pre-wrap; white-space: pre-wrap;
word-wrap: break-word; word-wrap: break-word;
} }
.mt-body .invisible { .mt-body .invisible {
display: none; display: none;
} }
/* toots messages */ /* Toot container */
.mt-toot { .mt-toot {
margin: 0 0.5rem 0 0; margin: 0 0.5rem 0 0;
padding: 1rem 0 2rem 65px; padding: 1rem 0 2rem 65px;
position: relative; position: relative;
min-height: 60px; min-height: 60px;
background-color: transparent; background-color: transparent;
border-bottom: 1px solid #dee2e6; border-bottom: 1px solid #dee2e6;
} }
.mt-toot:hover {
.mt-toot:hover { cursor: pointer;
cursor: pointer; background-color: rgba(124, 124, 124, 0.2);
background-color: rgba(124, 124, 124, 0.2); }
} .mt-toot p:last-child {
margin-bottom: 0;
.mt-toot p:last-child { }
margin-bottom: 0;
} /* User icon */
.mt-user {
.mt-user { display: table;
display: table; font-weight: 600;
font-weight: 600; }
} .mt-avatar {
position: absolute;
.mt-avatar { top: 20px;
position: absolute; left: 5px;
top: 20px; width: 50px;
left: 5px; height: 50px;
width: 50px; background-color: transparent;
height: 50px; background-repeat: no-repeat;
background-color: transparent; background-position: 50% 50%;
background-repeat: no-repeat; background-size: contain;
background-position: 50% 50%; background-color: #fff;
background-size: contain; border-radius: 5px;
background-color: #fff; }
border-radius: 5px; .mt-avatar-boosted {
} width: 40px;
height: 40px;
.mt-avatar-boosted { }
width: 40px; .mt-avatar-booster {
height: 40px; width: 25px;
} height: 25px;
top: 25px;
.mt-avatar-booster { left: 25px;
width: 25px; }
height: 25px;
top: 25px; /* Message */
left: 25px; .toot-text {
} margin-bottom: 0.25rem;
}
.toot-text { .toot-text .ellipsis::after{
margin-bottom: 0.25rem; content:'...';
} }
.mt-error {
.mt-error { color: darkred;
color: darkred; background: lightpink;
background: lightpink; margin: 5px;
margin: 5px; padding: 10px;
padding: 10px; }
}
/* Poll */
/* poll */ .toot-poll {
.toot-poll { margin-bottom: 0.25rem;
margin-bottom: 0.25rem; }
} .toot-poll ul{
.toot-poll ul{ list-style: none;
list-style: none; padding: 0;
padding: 0; margin: 0;
margin: 0; }
} .toot-poll ul li:not(:last-child){
.toot-poll ul li:not(:last-child){ margin-bottom: 0.25rem;
margin-bottom: 0.25rem; }
} .toot-poll ul li:before {
.toot-poll ul li:before { content: "◯";
content: "◯"; padding-right: 0.5rem;
padding-right: 0.5rem; }
}
/* Medias */
/* medias */ .toot-media {
.toot-media { overflow: hidden;
overflow: hidden; margin-bottom: 0.25rem;
margin-bottom: 0.25rem; }
} .toot-media-preview {
.toot-media-preview { position: relative;
position: relative; margin-top: 0.25rem;
margin-top: 0.25rem; height: auto;
height: auto; text-align: center;
text-align: center; width: 100%;
width: 100%; }
} .toot-media-spoiler > img {
.toot-media-spoiler > img { filter: blur(2rem);
filter: blur(2rem); }
} .toot-media-preview a {
.toot-media-preview a { display: block;
display: block; position: absolute;
position: absolute; top: 0;
top: 0; right: 0;
right: 0; bottom: 0;
bottom: 0; left: 0;
left: 0; }
} .img-ratio14_7 {
.img-ratio14_7 { position: relative;
position: relative; padding-top: 48.95%; /* 14:7 */
padding-top: 48.95%; /* 14:7 */ width: 100%;
width: 100%; }
} .img-ratio14_7 > img {
.img-ratio14_7 > img { width: 100%;
width: 100%; height: auto;
height: auto; position: absolute;
position: absolute; top: 50%;
top: 50%; left: 50%;
left: 50%; transform: translate(-50%, -50%);
transform: translate(-50%, -50%); text-align: center;
text-align: center; }
}
/* Date */
/* date */ .toot-date {
.toot-date { font-size: 0.75rem;
font-size: 0.75rem; opacity: 0.5;
opacity: 0.5; }
}
/* Loading-spinner */
/* loading-spinner */ .loading-spinner {
.loading-spinner { height: 100%;
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-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-repeat: no-repeat; background-position: center center;
background-position: center center; background-color: transparent;
background-color: transparent; background-size: min(2.5rem, calc(100% - 0.5rem));
background-size: min(2.5rem, calc(100% - 0.5rem)); }
}
/* See more btn */
/* see more btn */ .mt-seeMore{
.mt-seeMore{ margin: 2rem auto;
margin: 2rem auto; padding: 0 2rem;
padding: 0 2rem; text-align: center;
text-align: center; }
}

View File

@ -20,7 +20,6 @@ let MastodonApi = function (params_) {
// Endpoint access settings // Endpoint access settings
this.INSTANCE_URI = params_.instance_uri; this.INSTANCE_URI = params_.instance_uri;
this.ACCESS_TOKEN = params_.access_token;
this.ACCOUNT_ID = params_.account_id; this.ACCOUNT_ID = params_.account_id;
this.PROFILE_NAME = params_.profile_name; this.PROFILE_NAME = params_.profile_name;
this.TOOTS_LIMIT = params_.toots_limit || 20; this.TOOTS_LIMIT = params_.toots_limit || 20;
@ -71,6 +70,7 @@ MastodonApi.prototype.getToots = function () {
let allHashtags = document.querySelectorAll("#mt-timeline .hashtag"); let allHashtags = document.querySelectorAll("#mt-timeline .hashtag");
for(let j=0; j<allHashtags.length; j++) { for(let j=0; j<allHashtags.length; j++) {
allHashtags[j].target = "_blank"; allHashtags[j].target = "_blank";
allHashtags[j].rel = "tag noopener noreferrer";
} }
// Insert button to visit account page, after last toot // Insert button to visit account page, after last toot