Set # for share on fediverse

This commit is contained in:
Damien Broqua 2024-08-05 17:54:11 +02:00
parent 948ccf9419
commit e3f47a7bf7
7 changed files with 34 additions and 8 deletions

View file

@ -41,8 +41,8 @@ if (typeof item !== "undefined") {
this.shareMessageTransformed = message this.shareMessageTransformed = message
.replaceAll("{artist}", this.item.artists[0].name) .replaceAll("{artist}", this.item.artists[0].name)
.replaceAll("{format}", this.item.formats[0].name) .replaceAll("{format}", this.item.formats[0].name)
.replaceAll("{genres}", this.item.genres.join()) .replaceAll("{genres}", this.item.genres.join(", "))
.replaceAll("{styles}", this.item.styles.join()) .replaceAll("{styles}", this.item.styles.join(", "))
.replaceAll("{year}", this.item.year) .replaceAll("{year}", this.item.year)
.replaceAll("{video}", video) .replaceAll("{video}", video)
.replaceAll("{album}", this.item.title); .replaceAll("{album}", this.item.title);

View file

@ -34,6 +34,23 @@ export const sendResponse = (req, res, data) => {
} }
}; };
export const setHashTags = (arr) => {
let hashTags = "";
for (let i = 0; i < arr.length; i += 1) {
let currentHash = `${hashTags ? ", " : ""} #`;
const currentItem = arr[i].split(" ");
for (let j = 0; j < currentItem.length; j += 1) {
currentHash +=
currentItem[j].toLowerCase().charAt(0).toUpperCase() +
currentItem[j].toLowerCase().slice(1);
}
hashTags += currentHash;
}
return hashTags;
};
export default (res, page) => { export default (res, page) => {
res.status(200).render("index", page.render()); res.status(200).render("index", page.render());
}; };

View file

@ -13,6 +13,7 @@ import UsersModel from "../models/users";
import ErrorEvent from "../libs/error"; import ErrorEvent from "../libs/error";
import { getAlbumDetails, getAllDistincts } from "../helpers"; import { getAlbumDetails, getAllDistincts } from "../helpers";
import { setHashTags } from "../libs/format";
/** /**
* Classe permettant la gestion des albums d'un utilisateur * Classe permettant la gestion des albums d'un utilisateur
@ -86,8 +87,9 @@ class Albums extends Pages {
) )
.replaceAll("{artist}", data.artists[0].name) .replaceAll("{artist}", data.artists[0].name)
.replaceAll("{format}", data.formats[0].name) .replaceAll("{format}", data.formats[0].name)
.replaceAll("{genres}", data.genres.join()) .replaceAll("{#genres}", setHashTags(data.genres))
.replaceAll("{styles}", data.styles.join()) .replaceAll("{styles}", data.styles.join(", "))
.replaceAll("{#styles}", setHashTags(data.styles))
.replaceAll("{year}", data.year) .replaceAll("{year}", data.year)
.replaceAll("{video}", video) .replaceAll("{video}", video)
.replaceAll("{album}", data.title)} .replaceAll("{album}", data.title)}

View file

@ -123,8 +123,8 @@ class Export {
ws.cell(currentRow, 1).string(artists_sort).style(style); ws.cell(currentRow, 1).string(artists_sort).style(style);
ws.cell(currentRow, 2).string(title).style(style); ws.cell(currentRow, 2).string(title).style(style);
ws.cell(currentRow, 3).string(genres.join()).style(style); ws.cell(currentRow, 3).string(genres.join(", ")).style(style);
ws.cell(currentRow, 4).string(styles.join()).style(style); ws.cell(currentRow, 4).string(styles.join(", ")).style(style);
if (country) { if (country) {
ws.cell(currentRow, 5).string(country).style(style); ws.cell(currentRow, 5).string(country).style(style);
} }

View file

@ -13,6 +13,7 @@ import UsersModel from "../models/users";
import ErrorEvent from "../libs/error"; import ErrorEvent from "../libs/error";
import { getAlbumDetails, getAllDistincts } from "../helpers"; import { getAlbumDetails, getAllDistincts } from "../helpers";
import { setHashTags } from "../libs/format";
/** /**
* Classe permettant la gestion da la liste de souhaits d'un utilisateur * Classe permettant la gestion da la liste de souhaits d'un utilisateur
@ -86,8 +87,10 @@ class Wantlist extends Pages {
) )
.replaceAll("{artist}", data.artists[0].name) .replaceAll("{artist}", data.artists[0].name)
.replaceAll("{format}", data.formats[0].name) .replaceAll("{format}", data.formats[0].name)
.replaceAll("{genres}", data.genres.join()) .replaceAll("{genres}", data.genres.join(", "))
.replaceAll("{styles}", data.styles.join()) .replaceAll("{#genres}", setHashTags(data.genres))
.replaceAll("{styles}", data.styles.join(", "))
.replaceAll("{#styles}", setHashTags(data.styles))
.replaceAll("{year}", data.year) .replaceAll("{year}", data.year)
.replaceAll("{video}", video) .replaceAll("{video}", video)
.replaceAll("{album}", data.title)} .replaceAll("{album}", data.title)}

View file

@ -125,7 +125,9 @@
<li>{year}, exemple: 1984</li> <li>{year}, exemple: 1984</li>
<li>{video}, exemple : https://www.youtube.com/watch?v=Qx0s8OqgBIw</li> <li>{video}, exemple : https://www.youtube.com/watch?v=Qx0s8OqgBIw</li>
<li>{genres}, exemple : Rock</li> <li>{genres}, exemple : Rock</li>
<li>{#genres}, exemple : #rock</li>
<li>{styles}, exemple : Hard Rock, Heavy Metal</li> <li>{styles}, exemple : Hard Rock, Heavy Metal</li>
<li>{#styles}, exemple : #hardRock, #heavyMetal</li>
</ul> </ul>
</small> </small>
</div> </div>

View file

@ -80,7 +80,9 @@
<li>{year}, exemple: 1984</li> <li>{year}, exemple: 1984</li>
<li>{video}, exemple : https://www.youtube.com/watch?v=Qx0s8OqgBIw</li> <li>{video}, exemple : https://www.youtube.com/watch?v=Qx0s8OqgBIw</li>
<li>{genres}, exemple : Rock</li> <li>{genres}, exemple : Rock</li>
<li>{#genres}, exemple : #rock</li>
<li>{styles}, exemple : Hard Rock, Heavy Metal</li> <li>{styles}, exemple : Hard Rock, Heavy Metal</li>
<li>{#styles}, exemple : #hardRock, #heavyMetal</li>
</ul> </ul>
</small> </small>
</div> </div>