Skip to content

Commit

Permalink
share attachments exist and fixed attachment bug
Browse files Browse the repository at this point in the history
  • Loading branch information
3r1s-s committed Jun 17, 2024
1 parent 744bc84 commit e268505
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 4 deletions.
3 changes: 3 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"liveServer.settings.port": 5501
}
2 changes: 1 addition & 1 deletion markdown.js
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ function attach(attachment) {
let embeddedElement;

if (attachment.mime.includes("image")) {
if (whitelist.some(source => link.includes(source)) || settingsstuff().imagewhitelist) {
if (whitelist.some(source => link.includes(source))) {
const element = document.createElement("div");
element.classList.add("image-outer");

Expand Down
21 changes: 18 additions & 3 deletions share/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ async function loadsharedpost() {
}
}

function settingsstuff() {
return false;
}

function loadpost(p) {
let user, content;
let bridged = bridges.includes(p.u);
Expand Down Expand Up @@ -105,10 +109,21 @@ function loadpost(p) {

const links = content.match(/(?:https?|ftp):\/\/[^\s(){}[\]]+/g);
const embd = embed(links);
if (embd) {
embd.forEach(embeddedElement => {
wrapperDiv.appendChild(embeddedElement);
if (embd || p.attachments) {
const embedsDiv = document.createElement('div');
embedsDiv.classList.add('embeds');
if (embd) {
embd.forEach(embeddedElement => {
embedsDiv.appendChild(embeddedElement);
});
}

p.attachments.forEach(attachment => {
const g = attach(attachment);
embedsDiv.appendChild(g);
});

wrapperDiv.appendChild(embedsDiv);
}

loadPfp(user).then(pfpElement => {
Expand Down
2 changes: 2 additions & 0 deletions share/styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ bridge {

.embed {
border-radius: 5px;
max-width: 300px;
max-height: 300px;
}

.info {
Expand Down

0 comments on commit e268505

Please sign in to comment.