Compare commits

...

68 Commits

Author SHA1 Message Date
Damien Broqua bed5139a27 Wording 2024-04-03 18:10:03 +02:00
Damien Broqua 5b2758afca Allow {genres} and {styles} for sharing album on fediverse 2024-03-16 15:42:19 +01:00
Damien Broqua 68414e3e71 Added link to artists for extra info 2024-02-04 15:40:01 +01:00
Damien Broqua d692090022 Added Escape keydown gesture 2024-02-04 15:37:42 +01:00
Damien Broqua 061e72c459 Updated statistics 2024-02-02 09:38:35 +01:00
Damien Broqua bf2e9be3b7 Added pagination size 2024-02-01 08:47:33 +01:00
Damien Broqua d4e6d23459 Updated navbar 2024-02-01 08:25:09 +01:00
Damien Broqua 0ea6a21b90 Updated pagination size 2024-01-31 14:14:19 +01:00
Damien Broqua 6b2f7b61cb Rewrote theme switcher 2024-01-31 14:12:35 +01:00
Damien Broqua f1220fc05a {DESIGN} Added statistics page 2024-01-31 10:51:00 +01:00
Damien Broqua 8d22435b90 Added statistics page 2024-01-31 10:43:50 +01:00
Damien Broqua 30bd3ebdf9 {BUGFIX} On update my account 2024-01-28 18:14:30 +01:00
Damien Broqua 5a7d9d707f Merge branch 'master' of git.darkou.fr:dbroqua/MusicTopus into develop 2024-01-28 17:27:50 +01:00
Damien Broqua 041e24e26f {BUGFIX} On share my collection 2024-01-28 17:17:07 +01:00
Damien Broqua 71c120564a {BUGFIX} On album update when no day is set for released field 2024-01-19 08:04:21 +01:00
Damien Broqua 1a9728fce6 {BUGFIX} On album update when no day is set for released field 2024-01-18 20:46:40 +01:00
Damien Broqua 2eb22bb3d6 {BUGFIX} On album update when no day is set for released field 2024-01-18 08:28:25 +01:00
Damien Broqua abcbd0f8f7 {AWS} Migration to v3 2024-01-15 21:28:15 +01:00
Damien Broqua f73d4a3093 Updated close modal button 2024-01-13 19:05:20 +01:00
Damien Broqua 0a2d5029b5 {BUGFIX} Updated css theme 2024-01-13 18:44:19 +01:00
Damien Broqua fcb527aa5e Updated css theme 2024-01-13 18:30:45 +01:00
Damien Broqua c79f1c5a74 {BUGFIX} For modal 2024-01-11 08:11:32 +01:00
Damien Broqua 960f53ab54 {BUGFIX} For image in modal 2024-01-05 12:30:54 +01:00
Damien Broqua 6994170a04 Added on-air feature 2023-12-31 18:02:02 +01:00
Damien Broqua 8e0947ed4b Updated session max age 2023-12-15 08:36:06 +01:00
Damien Broqua 736a0afa44 {WIP} Component for album details 2023-12-15 08:30:41 +01:00
Damien Broqua 209ba0f5f0 Updated navbar size 2023-12-15 08:29:55 +01:00
Damien Broqua 77de7d54ca Amélioration du rendu en mobile 2023-10-27 21:22:23 +02:00
Damien Broqua 00bb8647e1 {BUGFIX} Correction d'un bug sur l'ajout d'album 2023-10-11 07:57:55 +02:00
Damien Broqua c32b182151 Correction orthographique 2023-10-08 15:04:21 +02:00
Damien Broqua 85752c537d Import d'une collection depuis Discogs 2023-10-08 15:02:08 +02:00
Damien Broqua 3b3a4cf779 Possibilité de ne pas partager un album sur le fediverse 2023-10-07 18:52:52 +02:00
Damien Broqua 1931bd9eda www.darkou.fr => www.darkou.link 2023-09-25 09:28:53 +02:00
Damien Broqua 7b525d3e43 Merge branch 'master' of git.darkou.fr:dbroqua/MusicTopus into develop 2023-09-24 14:57:03 +02:00
Damien Broqua 81c61a0529 Info lors d'un ajout d'album déjà en collection 2023-09-24 14:53:04 +02:00
Damien Broqua e01dbd5c31 Merge branch 'master' of git.darkou.fr:dbroqua/MusicTopus into develop 2023-09-22 21:52:26 +02:00
Damien Broqua 205474a701 Possibilité de partager un album sur le fédiverse 2023-09-22 21:52:03 +02:00
Damien Broqua e28f382c6c {BUGFIX} Suppression d'un album depuis la liste 2023-09-22 08:46:43 +02:00
Damien Broqua 3626b074bd Merge branch 'master' of git.darkou.fr:dbroqua/MusicTopus into develop 2023-09-18 14:47:37 +02:00
Damien Broqua 4ea7b42d52 {BUGFIX} For getting files from discogs 2023-09-18 14:41:01 +02:00
Damien Broqua fd0a9df724 {DEBUG} Get images 2023-09-18 14:31:51 +02:00
Damien Broqua 97b8bab2f4 Merge branch 'master' of git.darkou.fr:dbroqua/MusicTopus into develop 2023-08-11 23:18:11 +02:00
Damien Broqua 15eb2c2dad Merge branch 'master' of git.darkou.fr:dbroqua/MusicTopus into develop 2023-08-02 18:11:37 +02:00
Damien Broqua ec5e43889f #88 - Améliorer le switch sur le thème 2023-08-02 16:05:08 +02:00
Damien Broqua c2ff54ecf2 @issue-86 (#90)
Reviewed-on: #90
Co-authored-by: dbroqua <contact@darkou.fr>
Co-committed-by: dbroqua <contact@darkou.fr>
2023-08-02 15:34:41 +02:00
Damien Broqua bfdb19eec1 #87 - Utiliser la police Luciole (#89)
Reviewed-on: #89
Co-authored-by: dbroqua <contact@darkou.fr>
Co-committed-by: dbroqua <contact@darkou.fr>
2023-07-27 14:52:30 +02:00
Damien Broqua 1df39410c3 Added compat with Node 18 (#85)
Reviewed-on: #85
Co-authored-by: dbroqua <contact@darkou.fr>
Co-committed-by: dbroqua <contact@darkou.fr>
2023-07-22 18:19:21 +02:00
Damien Broqua 13209a9b1d Merge branch 'master' of git.darkou.fr:dbroqua/MusicTopus into develop 2023-03-23 14:34:05 +01:00
Damien Broqua b630e73c79 #82 - Utilisateur artists plutôt que artists_sort 2023-03-23 14:30:40 +01:00
Damien Broqua c743f0d3a4 Merge branch 'master' of git.darkou.fr:dbroqua/MusicTopus into develop 2023-03-22 15:01:04 +01:00
Damien Broqua 68004646f1 #80 - Ajout des boutons début/fin sur la pagination 2023-03-22 14:56:37 +01:00
Damien Broqua 55a9656c42 #79 - Soucis de paramètres dans les filtres 2023-03-22 14:34:14 +01:00
Damien Broqua 4c442edf21 Merge branch 'master' of git.darkou.fr:dbroqua/MusicTopus into develop 2023-03-19 10:41:41 +01:00
Damien Broqua 50f01805d4 #68 - Unifier les vues pour la liste des albums 2023-03-19 10:37:20 +01:00
Damien Broqua 663eb586cf #77 - Je suis capable de trier ma collecion par date d'ajout 2023-03-19 10:03:10 +01:00
Damien Broqua c1b01ea4c0 #74 - Lors du changement de page on connait l'ordre de tri 2023-01-17 17:21:28 +01:00
Damien Broqua fe3ed3e91f #73 - Savoir sur quelle page on est 2023-01-17 17:08:41 +01:00
Damien Broqua 8822056c1f #76 - Avoir plus de détails sur le support physique sur la modale d'ajout 2023-01-17 16:54:58 +01:00
Damien Broqua dff1d2baf0 #75 - Numérotation de la tracklist 2023-01-17 16:37:13 +01:00
Damien Broqua d446735450 Utilisation de NPX 2023-01-17 16:25:15 +01:00
Damien Broqua a7e41949dc Merge branch 'master' of git.darkou.fr:dbroqua/MusicTopus into develop 2022-11-02 09:56:23 +01:00
Damien Broqua a56db99a81 #69 - Partager ma collection 2022-11-02 09:48:05 +01:00
Damien Broqua e01f01337c Lint 2022-10-28 22:56:04 +02:00
Damien Broqua 980586d8eb Correction mineure sur le refresh d'un album 2022-10-28 22:45:38 +02:00
Damien Broqua 8f9e902587 #66 - Compiler le JS avant de l'envoyer au client 2022-10-28 22:40:02 +02:00
Damien Broqua a74c67e241 #64 - Depuis un album pouvoir voir tous les albums de cet artiste 2022-10-28 22:06:56 +02:00
Damien Broqua eac7c1aa84 #65 - Afficher les notes discogs d'un album 2022-10-28 22:01:36 +02:00
Damien Broqua 748edc9cc4 #63 - Suppression d'un album 2022-10-28 21:55:31 +02:00
49 changed files with 19693 additions and 578 deletions

View File

@ -22,7 +22,13 @@ module.exports = {
camelcase: [
"error",
{
allow: ["artists_sort", "access_token", "api_url", "media_ids"],
allow: [
"artists_sort",
"access_token",
"api_url",
"media_ids",
"release_id",
],
},
],
},

View File

@ -6,6 +6,12 @@
"units_per_em": 1000,
"ascent": 850,
"glyphs": [
{
"uid": "ca90da02d2c6a3183f2458e4dc416285",
"css": "adjust",
"code": 59408,
"src": "fontawesome"
},
{
"uid": "44e04715aecbca7f266a17d5a7863c68",
"css": "plus",

View File

@ -10,6 +10,7 @@ const babel = require("gulp-babel");
const sourceJs = "javascripts/**/*.js";
const sourceRemoteJS = [
"./node_modules/vue/dist/vue.global.prod.js",
"./node_modules/chart.js/dist/chart.umd.js",
"./node_modules/axios/dist/axios.min.js",
];

View File

@ -1,6 +1,8 @@
Vue.createApp({
data() {
return {
// eslint-disable-next-line no-undef
share: canPublish,
q: "",
year: "",
country: "",
@ -76,6 +78,12 @@ Vue.createApp({
],
};
},
created() {
window.addEventListener("keydown", this.keyDown);
},
destroyed() {
window.removeEventListener("keydown", this.keyDown);
},
methods: {
search(event) {
event.preventDefault();
@ -113,6 +121,7 @@ Vue.createApp({
format,
genre,
style,
inCollection,
} = results[i];
items.push({
id,
@ -123,6 +132,7 @@ Vue.createApp({
format,
genre,
style,
inCollection,
});
}
@ -167,7 +177,10 @@ Vue.createApp({
this.submitting = true;
return axios
.post("/api/v1/albums", this.details)
.post("/api/v1/albums", {
album: this.details,
share: this.share,
})
.then(() => {
window.location.href = "/ma-collection";
})
@ -182,5 +195,13 @@ Vue.createApp({
orderedItems(items) {
return items.sort();
},
keyDown(event) {
const keycode = event.code;
if (this.modalIsVisible && keycode === "Escape") {
event.preventDefault();
this.modalIsVisible = false;
}
},
},
}).mount("#ajouter-album");

View File

@ -7,8 +7,8 @@ Vue.createApp({
total: 0,
// eslint-disable-next-line no-undef
page: query.page || 1,
totalPages: 1,
limit: 16,
totalPages: 1,
artist: "",
format: "",
year: "",
@ -25,11 +25,20 @@ Vue.createApp({
// eslint-disable-next-line no-undef
isPublicCollection,
// eslint-disable-next-line no-undef
userId,
// eslint-disable-next-line no-undef
vueType,
// eslint-disable-next-line no-undef
query,
};
},
created() {
this.fetch();
window.addEventListener("keydown", this.keyDown);
},
destroyed() {
window.removeEventListener("keydown", this.keyDown);
},
methods: {
formatParams(param) {
@ -65,7 +74,7 @@ Vue.createApp({
this.sortOrder = `${sortOrder.sort}-${sortOrder.order}`;
let url = `/api/v1/albums?page=${this.page}&limit=${this.limit}&sort=${this.sort}&order=${this.order}`;
let url = `/api/v1/albums?page=${this.page}&sort=${this.sort}&order=${this.order}`;
if (this.artist) {
url += `&artist=${this.formatParams(this.artist)}`;
}
@ -81,11 +90,16 @@ Vue.createApp({
if (this.style) {
url += `&style=${this.formatParams(this.style)}`;
}
// INFO: Cas d'une collection partagée
if (this.vueType === "public" && this.userId) {
url += `&userId=${this.userId}`;
}
axios
.get(url)
.then((response) => {
this.items = response.data.rows;
this.limit = response.data.limit;
this.total = response.data.count || 0;
this.totalPages =
parseInt(response.data.count / this.limit, 10) +
@ -167,10 +181,11 @@ Vue.createApp({
this.toggleModal();
},
deleteItem() {
if ( vueType === 'private' ) {
// eslint-disable-next-line no-undef
if (vueType !== "private") {
return false;
}
axios
return axios
.delete(`/api/v1/albums/${this.itemId}`)
.then(() => {
this.fetch();
@ -186,10 +201,11 @@ Vue.createApp({
});
},
shareCollection() {
if ( vueType === 'private' ) {
// eslint-disable-next-line no-undef
if (vueType !== "private") {
return false;
}
axios
return axios
.patch(`/api/v1/me`, {
isPublicCollection: !this.isPublicCollection,
})
@ -219,19 +235,27 @@ Vue.createApp({
});
},
renderAlbumTitle(item) {
let render = '';
let render = "";
for ( let i = 0 ; i < item.artists.length ; i += 1 ) {
const {
name,
join,
} = item.artists[i];
render += `${name} ${join ? `${join} ` : ''}`;
for (let i = 0; i < item.artists.length; i += 1) {
const { name, join } = item.artists[i];
render += `${name} ${join ? `${join} ` : ""}`;
}
render += `- ${item.title}`;
return render;
}
},
keyDown(event) {
const keycode = event.code;
if (this.showModalDelete && keycode === "Escape") {
event.preventDefault();
this.showModalDelete = false;
}
if (this.showModalShare && keycode === "Escape") {
event.preventDefault();
this.showModalShare = false;
}
},
},
}).mount("#collection");
}).mount("#collection");

View File

@ -1,4 +1,3 @@
if (typeof email !== "undefined" && typeof username !== "undefined") {
Vue.createApp({
data() {
@ -12,6 +11,8 @@ if (typeof email !== "undefined" && typeof username !== "undefined") {
password: "",
passwordConfirm: "",
// eslint-disable-next-line no-undef
pagination,
// eslint-disable-next-line no-undef
mastodon: mastodon || {
publish: false,
url: "",
@ -57,7 +58,7 @@ if (typeof email !== "undefined" && typeof username !== "undefined") {
// eslint-disable-next-line no-unused-vars
async updateProfil() {
this.errors = [];
const { oldPassword, password, passwordConfirm, mastodon } =
const { oldPassword, password, passwordConfirm, mastodon, pagination } =
this.formData;
if (password && !oldPassword) {
@ -83,6 +84,8 @@ if (typeof email !== "undefined" && typeof username !== "undefined") {
data.oldPassword = oldPassword;
}
data.pagination = pagination;
try {
await axios.patch(`/api/v1/me`, data);

View File

@ -4,6 +4,8 @@ if (typeof item !== "undefined") {
return {
// eslint-disable-next-line no-undef
item,
// eslint-disable-next-line no-undef
canShareItem,
tracklist: [],
identifiers: [],
modalIsVisible: false,
@ -12,16 +14,43 @@ if (typeof item !== "undefined") {
preview: null,
index: null,
showModalDelete: false,
showModalShare: false,
shareMessage: "",
shareMessageTransformed: "",
shareMessageLength: 0,
shareSubmiting: false,
};
},
created() {
this.setTrackList();
this.setIdentifiers();
window.addEventListener("keydown", this.changeImage);
window.addEventListener("keydown", this.keyDown);
},
destroyed() {
window.removeEventListener("keydown", this.changeImage);
window.removeEventListener("keydown", this.keyDown);
},
watch: {
shareMessage(message) {
const video =
this.item.videos && this.item.videos.length > 0
? this.item.videos[0].uri
: "";
this.shareMessageTransformed = message
.replaceAll("{artist}", this.item.artists[0].name)
.replaceAll("{format}", this.item.formats[0].name)
.replaceAll("{genres}", this.item.genres.join())
.replaceAll("{styles}", this.item.styles.join())
.replaceAll("{year}", this.item.year)
.replaceAll("{video}", video)
.replaceAll("{album}", this.item.title);
this.shareMessageLength = this.shareMessageTransformed.replace(
video,
new Array(36).join("#")
).length;
},
},
methods: {
setIdentifiers() {
@ -112,12 +141,12 @@ if (typeof item !== "undefined") {
this.setImage();
},
changeImage(event) {
event.preventDefault();
const direction = event.code;
if (
this.modalIsVisible &&
["ArrowRight", "ArrowLeft", "Escape"].indexOf(direction) !==
-1
-1
) {
switch (direction) {
case "ArrowRight":
@ -132,6 +161,20 @@ if (typeof item !== "undefined") {
return true;
},
keyDown(event) {
const keycode = event.code;
if (this.modalIsVisible) {
this.changeImage(event);
}
if (this.showModalDelete && keycode === "Escape") {
event.preventDefault();
this.showModalDelete = false;
}
if (this.showModalShare && keycode === "Escape") {
event.preventDefault();
this.showModalShare = false;
}
},
showAllIdentifiers() {
this.identifiersMode = "all";
this.setIdentifiers();
@ -189,6 +232,33 @@ if (typeof item !== "undefined") {
goToArtist() {
return "";
},
shareAlbum() {
if (this.shareSubmiting) {
return false;
}
this.shareSubmiting = true;
axios
.post(`/api/v1/albums/${this.item._id}/share`, {
message: this.shareMessageTransformed,
})
.then(() => {
showToastr("Album partagé", true);
this.shareMessage = "";
this.showModalShare = false;
})
.catch((err) => {
showToastr(
err.response?.data?.message ||
"Impossible de partager cet album",
false
);
})
.finally(() => {
this.shareSubmiting = false;
});
return true;
},
},
}).mount("#ma-collection-details");
}

View File

@ -0,0 +1,106 @@
Vue.createApp({
data() {
return {
file: "",
content: [],
parsed: false,
imported: 0,
disabled: true,
state: "default",
};
},
created() {},
destroyed() {},
methods: {
handleFileUpload(event) {
const { files } = event.target;
const [csv] = files;
this.file = csv;
this.file = csv;
// this.parseFile();
const reader = new FileReader();
reader.onload = (content) => {
this.content = [];
this.state = "parse";
const lines = content.target.result.split(/\r\n|\n/);
for (let line = 1; line < lines.length - 1; line += 1) {
this.parseLine(lines[0], lines[line]);
}
this.state = "default";
this.disabled = false;
};
reader.readAsText(csv);
},
parseLine(header, line) {
const row = {};
let currentHeaderIndex = 0;
let separant = ",";
let value = "";
for (let i = 0; i < line.length; i += 1) {
const char = line[i];
if (char !== separant) {
if (char === '"') {
separant = '"';
} else {
value += char;
}
} else if (char === '"') {
separant = ",";
} else {
row[header.split(",")[currentHeaderIndex]] = value;
currentHeaderIndex += 1;
value = "";
}
}
this.content.push(row);
},
async addOne(index) {
const { Artist, Title, release_id } = this.content[index];
try {
const res = await axios.get(
`/api/v1/albums?discogsId=${release_id}`
);
if (res.status === 204) {
await axios.post("/api/v1/albums", {
discogsId: release_id,
share: false,
});
}
this.imported += 1;
if (this.content.length > index + 1) {
await this.addOne(index + 1);
}
} catch (err) {
showToastr(
`Impossible d'ajouter l'album ${Title} de ${Artist}`
);
return false;
}
return true;
},
async importCollection(event) {
event.preventDefault();
this.disabled = true;
this.state = "submit";
this.imported = 0;
const imported = await this.addOne(0);
this.disabled = false;
this.state = imported ? "done" : "default";
},
},
}).mount("#importer");

View File

@ -1,19 +1,3 @@
/**
* Fonction permettant de sauvegarder dans le stockage local le choix du thème
* @param {String} scheme
*/
function saveColorScheme(scheme) {
localStorage.setItem("theme", scheme);
}
/**
* Fonction permettant de changer le thème du site
* @param {String} scheme
*/
function setColorScheme(scheme) {
document.documentElement.setAttribute("data-theme", scheme);
}
/**
* Fonction permettant de récupérer le thème du système
* @return {String}
@ -28,10 +12,56 @@ function getPreferredColorScheme() {
return "light";
}
/**
* @param {String} scheme
*/
function setPictoOnMenu(scheme) {
document.querySelectorAll(".icon-theme").forEach((item) => {
item.classList.add("hidden");
});
document
.querySelector(`.icon-theme.theme-${scheme}`)
.classList.remove("hidden");
}
/**
* Fonction permettant de sauvegarder dans le stockage local le choix du thème
* @param {String} scheme
*/
function saveColorScheme(scheme) {
localStorage.setItem("theme", scheme);
}
/**
* Fonction permettant de changer le thème du site
* @param {String} scheme
*/
function setColorScheme(scheme) {
document.documentElement.setAttribute(
"data-theme",
scheme === "system" ? getPreferredColorScheme() : scheme
);
setPictoOnMenu(scheme);
}
/**
* Fonction déclenchée lorsqu'un utilisateur clique sur un bouton dans le menu déroulant
* @param {Object} e
*/
function changeTheme(e) {
e.preventDefault();
const scheme = this.dataset.value;
saveColorScheme(scheme);
setColorScheme(scheme);
}
// INFO: On place un event sur le bouton
const toggleSwitch = document.querySelector(
'.theme-switch input[type="checkbox"]'
);
const buttonsTheme = document.getElementsByClassName("theme");
// INFO: On récupère du local storage (ou des préférences navigateur) le thème actuel
const currentTheme = localStorage.getItem("theme") || getPreferredColorScheme();
/**
* Event permettant de détecter les changements de thème du système
@ -44,28 +74,14 @@ if (window.matchMedia) {
if (selectedColorScheme === "system") {
const preferedColorScheme = getPreferredColorScheme();
setColorScheme(preferedColorScheme);
toggleSwitch.checked = preferedColorScheme === "dark";
}
});
}
const currentTheme = localStorage.getItem("theme") || getPreferredColorScheme();
// INFO: Au chargement de la page on détecte le thème à charger
setColorScheme(currentTheme);
toggleSwitch.checked = currentTheme === "dark";
toggleSwitch.addEventListener(
"change",
(e) => {
e.preventDefault();
const scheme = e.target.checked ? "dark" : "light";
saveColorScheme(scheme);
setColorScheme(scheme);
},
false
);
// INFO: On place un event au click sur chacun des boutons du menu
for (let i = 0; i < buttonsTheme.length; i += 1) {
buttonsTheme[i].addEventListener("click", changeTheme, false);
}

18192
package-lock.json generated Normal file

File diff suppressed because it is too large Load Diff

View File

@ -24,7 +24,7 @@
"author": {
"name": "Damien Broqua",
"email": "contact@darkou.fr",
"url": "https://www.darkou.fr"
"url": "https://www.darkou.link"
},
"license": "GPL-3.0-or-later",
"devDependencies": {
@ -39,11 +39,13 @@
"prettier": "^2.5.1"
},
"dependencies": {
"@aws-sdk/client-s3": "^3.490.0",
"@aws-sdk/lib-storage": "^3.490.0",
"@babel/cli": "^7.17.0",
"@babel/core": "^7.17.2",
"@babel/preset-env": "^7.16.11",
"aws-sdk": "^2.1110.0",
"axios": "^0.26.0",
"chart.js": "^4.4.1",
"connect-ensure-login": "^0.1.1",
"connect-flash": "^0.1.1",
"connect-mongo": "^4.6.0",

Binary file not shown.

View File

@ -1,7 +1,7 @@
<?xml version="1.0" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg xmlns="http://www.w3.org/2000/svg">
<metadata>Copyright (C) 2022 by original authors @ fontello.com</metadata>
<metadata>Copyright (C) 2024 by original authors @ fontello.com</metadata>
<defs>
<font id="icon" horiz-adv-x="1000" >
<font-face font-family="icon" font-weight="400" font-stretch="normal" units-per-em="1000" ascent="850" descent="-150" />
@ -28,6 +28,8 @@
<glyph glyph-name="refresh" unicode="&#xe80a;" d="M843 261q0-3 0-4-36-150-150-243t-267-93q-81 0-157 31t-136 88l-72-72q-11-11-25-11t-25 11-11 25v250q0 14 11 25t25 11h250q14 0 25-11t10-25-10-25l-77-77q40-36 90-57t105-20q74 0 139 37t104 99q6 10 30 66 4 13 16 13h107q8 0 13-6t5-12z m14 446v-250q0-14-10-25t-26-11h-250q-14 0-25 11t-10 25 10 25l77 77q-82 77-194 77-75 0-140-37t-104-99q-6-10-29-66-5-13-17-13h-111q-7 0-13 6t-5 12v4q36 150 151 243t268 93q81 0 158-31t137-88l72 72q11 11 25 11t26-11 10-25z" horiz-adv-x="857.1" />
<glyph glyph-name="adjust" unicode="&#xe810;" d="M429 46v608q-83 0-153-41t-110-111-41-152 41-152 110-111 153-41z m428 304q0-117-57-215t-156-156-215-58-216 58-155 156-58 215 58 215 155 156 216 58 215-58 156-156 57-215z" horiz-adv-x="857.1" />
<glyph glyph-name="spin" unicode="&#xe839;" d="M855 9c-189-190-520-172-705 13-190 190-200 494-28 695 11 13 21 26 35 34 36 23 85 18 117-13 30-31 35-76 16-112-5-9-9-15-16-22-140-151-145-379-8-516 153-153 407-121 542 34 106 122 142 297 77 451-83 198-305 291-510 222l0 1c236 82 492-24 588-252 71-167 37-355-72-493-11-15-23-29-36-42z" horiz-adv-x="1000" />
<glyph glyph-name="link-ext" unicode="&#xf08e;" d="M786 332v-178q0-67-47-114t-114-47h-464q-67 0-114 47t-47 114v464q0 66 47 113t114 48h393q7 0 12-5t5-13v-36q0-8-5-13t-12-5h-393q-37 0-63-26t-27-63v-464q0-37 27-63t63-27h464q37 0 63 27t26 63v178q0 8 5 13t13 5h36q8 0 13-5t5-13z m214 482v-285q0-15-11-25t-25-11-25 11l-98 98-364-364q-5-6-13-6t-12 6l-64 64q-6 5-6 12t6 13l364 364-98 98q-11 11-11 25t11 25 25 11h285q15 0 25-11t11-25z" horiz-adv-x="1000" />

Before

Width:  |  Height:  |  Size: 8.0 KiB

After

Width:  |  Height:  |  Size: 8.3 KiB

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -7,10 +7,18 @@
.list {
margin-top: 2rem;
.item{
.item {
img {
cursor: pointer;
}
&.in-collection {
opacity: 0.6;
small {
font-style: italic;
}
}
}
}
}

View File

@ -5,15 +5,19 @@
color: var(--font-color);
display: block;
padding: 1.25rem;
width: calc(100% - 2rem);
margin: auto;
@include transition() {}
@include respond-to("small-up") {
width: 65%;
}
@include respond-to("medium-up") {
width: 35%;
&.mini {
margin: auto;
width: calc(100% - 2rem);
@include respond-to("small-up") {
width: 65%;
}
@include respond-to("medium-up") {
width: 35%;
}
}
h1 {

View File

@ -37,11 +37,15 @@ $button-alternate-color: #01103C;
$pagination-border-color: $nord3;
$pagination-hover-color: rgb(115, 151, 186);
$close-background: rgba(10,10,10,.6);
$close-background-dark: rgba(240,240,240,.6);
:root {
--default-color: #{$white};
--bg-color: #{darken($white, 5%)};
--bg-alternate-color: #{darken($white, 8%)};
--font-color: #{$nord3};
--hover-font-color: #{lighten($nord3, 16%)};
--footer-color: #{$darken-white};
--link-color: #{$nord1};
@ -58,6 +62,8 @@ $pagination-hover-color: rgb(115, 151, 186);
--button-link-text-color: #2C364A;
--close-background: #{$close-background};
--loader-img: url('/img/loading-light.gif');
--nord0: #{$nord0};
@ -83,6 +89,7 @@ $pagination-hover-color: rgb(115, 151, 186);
--bg-color: #{lighten($nord0, 2%)};
--bg-alternate-color: #{lighten($nord3, 8%)};
--font-color: #{$nord6};
--hover-font-color: #{darken($nord6, 16%)};
--footer-color: #{$nord1};
--link-color: #{$nord4};
@ -99,5 +106,7 @@ $pagination-hover-color: rgb(115, 151, 186);
--button-link-text-color: #{$white};
--close-background: #{$nord3};
--loader-img: url('/img/loading-dark.gif');
}

View File

@ -8,6 +8,10 @@
width: calc(100% - 6rem);
margin: 2rem auto;
.header {
font-weight: 700;
}
&.info {
background-color: $warning-color;
}

View File

@ -31,13 +31,12 @@
max-width: 100%;
width: 100%;
background-color: var(--input-color);
border: 1px solid transparent !important;
border: 1px solid var(--input-active-color) !important;
color: var(--input-font-color);
@include transition() {}
&:focus-visible {
outline: unset;
border-color: var(--input-active-color) !important;
}
}
@ -71,78 +70,4 @@
background-size: 1.2rem;
padding-right: 2.4rem;
}
}
.theme-switch-wrapper {
display: flex;
align-items: center;
em {
margin-left: 10px;
font-size: 1rem;
}
}
.theme-switch {
display: inline-block;
height: 34px;
position: relative;
width: 60px;
}
.theme-switch input {
display:none;
}
.slider {
background-color: #ccc;
bottom: 0;
cursor: pointer;
left: 0;
position: absolute;
right: 0;
top: 0;
transition: .4s;
@include transition() {}
}
.slider:before {
background-color: #fff;
bottom: 4px;
content: '\f185';
height: 26px;
left: 4px;
position: absolute;
transition: .4s;
width: 26px;
padding: 0;
font-family: "icon";
font-style: normal;
font-weight: normal;
display: inline-block;
text-decoration: inherit;
text-align: center;
font-variant: normal;
text-transform: none;
}
input:checked + .slider {
background-color: $primary-color;
@include transition() {}
}
input:checked + .slider:before {
transform: translateX(26px);
content: '\f186';
background-color: var(--input-active-color);
@include transition() {}
}
.slider.round {
border-radius: 34px;
}
.slider.round:before {
border-radius: 50%;
}
}

View File

@ -1,66 +1,76 @@
@font-face {
font-family: 'icon';
src: url('/font/icon.eot?41426785');
src: url('/font/icon.eot?41426785#iefix') format('embedded-opentype'),
url('/font/icon.woff2?41426785') format('woff2'),
url('/font/icon.woff?41426785') format('woff'),
url('/font/icon.ttf?41426785') format('truetype'),
url('/font/icon.svg?41426785#icon') format('svg');
src: url('/font/icon.eot?15219908');
src: url('/font/icon.eot?15219908#iefix') format('embedded-opentype'),
url('/font/icon.woff2?15219908') format('woff2'),
url('/font/icon.woff?15219908') format('woff'),
url('/font/icon.ttf?15219908') format('truetype'),
url('/font/icon.svg?15219908#icon') format('svg');
font-weight: normal;
font-style: normal;
}
[class^="icon-"]:before, [class*=" icon-"]:before {
}
/* Chrome hack: SVG is rendered more smooth in Windozze. 100% magic, uncomment if you need it. */
/* Note, that will break hinting! In other OS-es font will be not as sharp as it could be */
/*
@media screen and (-webkit-min-device-pixel-ratio:0) {
@font-face {
font-family: 'icon';
src: url('../font/icon.svg?15219908#icon') format('svg');
}
}
*/
[class^="icon-"]:before, [class*=" icon-"]:before {
font-family: "icon";
font-style: normal;
font-weight: normal;
speak: never;
display: inline-block;
text-decoration: inherit;
width: 1em;
margin-right: .2em;
text-align: center;
/* opacity: .8; */
/* For safety - reset parent styles, that can break glyph codes*/
font-variant: normal;
text-transform: none;
/* fix buttons height, for twitter bootstrap */
line-height: 1em;
/* Animation center compensation - margins should be symmetric */
/* remove if not needed */
margin-left: .2em;
/* you can be more comfortable with increased icons size */
/* font-size: 120%; */
/* Font smoothing. That was taken from TWBS */
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
}
.icon-plus:before { content: '\e800'; } /* '' */
.icon-user:before { content: '\e801'; } /* '' */
.icon-search:before { content: '\e802'; } /* '' */
.icon-mail:before { content: '\e803'; } /* '' */
.icon-link:before { content: '\e804'; } /* '' */
.icon-heart:before { content: '\e805'; } /* '' */
.icon-eye:before { content: '\e806'; } /* '' */
.icon-left-open:before { content: '\e807'; } /* '' */
.icon-right-open:before { content: '\e808'; } /* '' */
.icon-export:before { content: '\e809'; } /* '' */
.icon-refresh:before { content: '\e80a'; } /* '' */
.icon-spin:before { content: '\e839'; } /* '' */
.icon-link-ext:before { content: '\f08e'; } /* '' */
.icon-sun:before { content: '\f185'; } /* '' */
.icon-moon:before { content: '\f186'; } /* '' */
.icon-share:before { content: '\f1e0'; } /* '' */
.icon-trash:before { content: '\f1f8'; } /* '' */
.icon-blind:before { content: '\f29d'; } /* '' */
/* Uncomment for 3D effect */
/* text-shadow: 1px 1px 1px rgba(127, 127, 127, 0.3); */
}
.animate-spin {
animation: spin 2s infinite linear;
display: inline-block;
}
@keyframes spin {
0% {
transform: rotate(0deg);
}
.icon-plus:before { content: '\e800'; } /* '' */
.icon-user:before { content: '\e801'; } /* '' */
.icon-search:before { content: '\e802'; } /* '' */
.icon-mail:before { content: '\e803'; } /* '' */
.icon-link:before { content: '\e804'; } /* '' */
.icon-heart:before { content: '\e805'; } /* '' */
.icon-eye:before { content: '\e806'; } /* '' */
.icon-left-open:before { content: '\e807'; } /* '' */
.icon-right-open:before { content: '\e808'; } /* '' */
.icon-export:before { content: '\e809'; } /* '' */
.icon-refresh:before { content: '\e80a'; } /* '' */
.icon-adjust:before { content: '\e810'; } /* '' */
.icon-spin:before { content: '\e839'; } /* '' */
.icon-link-ext:before { content: '\f08e'; } /* '' */
.icon-sun:before { content: '\f185'; } /* '' */
.icon-moon:before { content: '\f186'; } /* '' */
.icon-share:before { content: '\f1e0'; } /* '' */
.icon-trash:before { content: '\f1f8'; } /* '' */
.icon-blind:before { content: '\f29d'; } /* '' */
100% {
transform: rotate(359deg);
}
}

View File

@ -1,28 +1,4 @@
// @use '../node_modules/knacss/sass/knacss.scss';
// NOYAU
@import "../node_modules/knacss/sass/abstracts/variables-sass";
@import "../node_modules/knacss/sass/abstracts/mixins-sass";
@import "../node_modules/knacss/sass/base/reset-base";
@import "../node_modules/knacss/sass/base/reset-accessibility";
@import "../node_modules/knacss/sass/base/reset-forms";
@import "../node_modules/knacss/sass/base/reset-print";
@import "../node_modules/knacss/sass/base/layout";
// UTILITAIRES
@import "../node_modules/knacss/sass/utils/utils-global";
@import "../node_modules/knacss/sass/utils/utils-font-sizes";
@import "../node_modules/knacss/sass/utils/utils-spacers";
@import "../node_modules/knacss/sass/utils/grillade";
// COMPOSANTS (à ajouter au besoin)
// @import "../node_modules/knacss/sass/components/button";
// @import "components/burger";
// @import "../node_modules/knacss/sass/components/checkbox";
@import "../node_modules/knacss/sass/components/radio";
// @import "../node_modules/knacss/sass/components/select";
// @import "components/quote";
@import '../node_modules/knacss/sass/knacss.scss';
// SPÉCIFIQUE AU SITE
@import './fonts';
@ -40,6 +16,7 @@
@import './list';
@import './box';
@import './loader';
@import './table';
@import './error';
@import './messages.scss';

View File

@ -45,33 +45,44 @@
.modal {
button.close {
height: 36px;
max-height: 36px;
max-width: 36px;
min-height: 36px;
min-width: 36px;
width: 36px;
height: 42px;
max-height: 42px;
max-width: 42px;
min-height: 42px;
min-width: 42px;
width: 42px;
position: absolute;
background-color: rgba(10,10,10,.6);
background-color: var(--close-background);
right: 12px;
top: 12px;
&::before,
&::after {
background-color: $white;
}
}
.carousel {
display: grid;
grid-template-columns: auto 80vw auto;
z-index: 1;
text-align: center;
img {
max-width: 100%;
max-height: 80vh;
}
}
.navigation {
position: absolute;
top: 50%;
cursor: pointer;
z-index: 10;
&.previous {
left: 12px;
}
&.next {
right: 12px;
}
i {
font-size: 2rem;
font-size: 1rem;
color: $nord4;
@include respond-to("small-up") {
font-size: 2rem;
}
}
}
}

View File

@ -9,7 +9,7 @@
justify-content: center;
overflow: hidden;
position: fixed;
z-index: 40;
z-index: 2;
&.is-visible {
display: flex;
@ -84,6 +84,11 @@
width: 1200;
}
&.for-image {
display: initial;
text-align: center;
}
header,
footer {
align-items: center;
@ -116,10 +121,25 @@
border-bottom-left-radius: 6px;
border-bottom-right-radius: 6px;
border-top: 1px solid var(--border-color);
justify-content: end;
align-items: baseline;
.field {
flex-direction: row;
padding: 6px;
span {
padding-left: 6px;
}
}
.button:not(:last-child) {
margin-right: .5em;
}
}
img {
max-width: 100%;
max-height: 80vh;
}
}
}

View File

@ -1,21 +1,25 @@
.navbar {
min-height: 3.25rem;
min-height: 3.5rem;
background-color: var(--navbar-color);
box-shadow: rgba(216, 222, 233, 0.15) 0px 5px 10px 0px;
color: rgba(0,0,0,.7);
position: fixed;
z-index: 30;
z-index: 1;
top: 0;
right: 0;
left: 0;
@include transition() {}
@include respond-to("medium-up") {
min-height: 3.25rem;
align-items: stretch;
display: flex;
}
&.container {
max-width: 1330px;
margin: 0 auto;
}
.navbar-brand {
align-items: stretch;
display: flex;
@ -113,7 +117,6 @@
@include respond-to("medium-up") {
display: flex;
align-items: stretch;
color: rgba(0,0,0,.7);
.navbar-dropdown {
background-color: var(--default-color);
@ -123,11 +126,9 @@
box-shadow: 0 8px 8px rgba(10,10,10,.1);
display: none;
font-size: .875rem;
left: 0;
min-width: 100%;
position: absolute;
top: 100%;
z-index: 20;
}
&:hover {
@ -135,7 +136,7 @@
.navbar-link {
background-color: var(--default-hl-color);
color: rgba(0,0,0,.7);
color: var(--hover-font-color);
}
.navbar-dropdown {
@ -164,6 +165,29 @@
@include respond-to("medium-up") {
display: flex;
align-items: center;
&::after {
border: 3px solid transparent;
border-radius: 2px;
border-right: 0;
border-top: 0;
content: " ";
display: block;
height: .625em;
pointer-events: none;
position: absolute;
top: 50%;
transform: rotate(-45deg);
transform-origin: center;
width: .625em;
border-color: var(--secondary-color);
margin-top: -0.375em;
right: 1.125em;
@include respond-to("medium-up") {
border-color: var(--font-color);
}
}
}
.icon {
@ -174,28 +198,7 @@
width: 1.5rem;
}
&::after {
border: 3px solid transparent;
border-radius: 2px;
border-right: 0;
border-top: 0;
content: " ";
display: block;
height: .625em;
pointer-events: none;
position: absolute;
top: 50%;
transform: rotate(-45deg);
transform-origin: center;
width: .625em;
border-color: var(--secondary-color);
margin-top: -0.375em;
right: 1.125em;
@include respond-to("medium-up") {
border-color: rgba(0,0,0,.7);
}
}
}
.navbar-menu {
@ -257,7 +260,7 @@
background-color: var(--font-color);
border: none;
height: 2px;
margin: .5rem 0;
margin: .5rem 0 0 1.5rem;
}
.navbar-item {
@ -274,11 +277,14 @@
box-shadow: 0 8px 8px rgba(10,10,10,.1);
display: none;
font-size: .875rem;
left: 0;
right: 0;
min-width: 100%;
position: absolute;
top: 100%;
z-index: 20;
hr {
margin: 0.5rem 0;
}
.navbar-item {
white-space: nowrap;

23
sass/table.scss Normal file
View File

@ -0,0 +1,23 @@
table {
th,
td {
padding: 0.75rem;
text-align: left;
}
thead {
tr {
border-bottom: 2px solid var(--font-color);
}
}
tbody {
tr {
background-color: var(--default-color);
&:nth-child(2n) {
background-color: var(--bg-alternate-color);
}
}
}
}

View File

@ -3,7 +3,7 @@
min-width: 250px;
max-width: 360px;
position: fixed;
z-index: 66;
z-index: 10;
right: 30px;
top: 30px;
font-size: 17px;

View File

@ -9,7 +9,7 @@ import MongoStore from "connect-mongo";
import passportConfig from "./libs/passport";
import config, { env, mongoDbUri, secret } from "./config";
import config, { env, mongoDbUri, port, secret } from "./config";
import { isXhr } from "./helpers";
@ -37,7 +37,7 @@ mongoose
const sess = {
cookie: {
maxAge: 86400000,
maxAge: 604800000, // INFO: 7 jours
},
secret,
saveUninitialized: false,
@ -150,4 +150,6 @@ app.use((error, req, res, next) => {
}
});
console.log(`Server listening on port ${port}!`);
export default app;

View File

@ -33,6 +33,11 @@ export const getAlbumDetails = async (id) => {
const res = await dis.getRelease(id);
if (res.released && res.released.includes("-00")) {
const [year, month] = res.released.split("-");
res.released = new Date(year, parseInt(month, 10) - 1);
}
return res;
};

View File

@ -1,4 +1,5 @@
import AWS from "aws-sdk";
import { S3Client } from "@aws-sdk/client-s3";
import { Upload } from "@aws-sdk/lib-storage";
import fs from "fs";
import path from "path";
import axios from "axios";
@ -10,13 +11,9 @@ import {
s3BaseFolder,
s3Endpoint,
s3Bucket,
s3Signature,
// s3Signature,
} from "../config";
AWS.config.update({
accessKeyId: awsAccessKeyId,
secretAccessKey: awsSecretAccessKey,
});
/**
* Fonction permettant de stocker un fichier local sur S3
* @param {String} filename
@ -27,23 +24,28 @@ AWS.config.update({
*/
export const uploadFromFile = async (filename, file, deleteFile = false) => {
const data = await fs.readFileSync(file);
const base64data = Buffer.from(data, "binary");
const dest = path.join(s3BaseFolder, filename);
const s3 = new AWS.S3({
endpoint: s3Endpoint,
signatureVersion: s3Signature,
});
await s3
.putObject({
const multipartUpload = new Upload({
client: new S3Client({
region: "fr-par",
endpoint: `https://${s3Endpoint}`,
credentials: {
accessKeyId: awsAccessKeyId,
secretAccessKey: awsSecretAccessKey,
},
}),
params: {
Bucket: s3Bucket,
Key: dest,
Body: base64data,
ACL: "public-read",
})
.promise();
endpoint: s3Endpoint,
},
});
await multipartUpload.done();
if (deleteFile) {
fs.unlinkSync(file);
@ -62,11 +64,15 @@ export const uploadFromUrl = async (url) => {
const filename = `${uuid()}.jpg`;
const file = `/tmp/${filename}`;
const { data } = await axios.get(url, { responseType: "arraybuffer" });
const { data } = await axios.get(url, {
headers: {
"User-Agent":
"Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:109.0) Gecko/20100101 Firefox/117.0",
},
responseType: "arraybuffer",
});
fs.writeFileSync(file, data);
return uploadFromFile(filename, file, true);
// return s3Object;
};

View File

@ -25,9 +25,21 @@ class Albums extends Pages {
*/
static async postAddOne(req) {
const { body, user } = req;
const { share, discogsId } = body;
let albumDetails = body.album;
if (discogsId) {
albumDetails = await getAlbumDetails(discogsId);
body.id = discogsId;
}
if (!albumDetails) {
throw new ErrorEvent(406, "Aucun album à ajouter");
}
const data = {
...body,
discogsId: body.id,
...albumDetails,
discogsId: albumDetails.id,
User: user._id,
};
data.released = data.released
@ -43,6 +55,9 @@ class Albums extends Pages {
model: "Albums",
id: album._id,
};
const job = new JobsModel(jobData);
job.save();
try {
const User = await UsersModel.findOne({ _id: user._id });
@ -51,7 +66,7 @@ class Albums extends Pages {
const { publish, token, url, message } = mastodonConfig;
if (publish && url && token) {
if (share && publish && url && token) {
const M = new Mastodon({
access_token: token,
api_url: url,
@ -68,6 +83,8 @@ class Albums extends Pages {
)
.replaceAll("{artist}", data.artists[0].name)
.replaceAll("{format}", data.formats[0].name)
.replaceAll("{genres}", data.genres.join())
.replaceAll("{styles}", data.styles.join())
.replaceAll("{year}", data.year)
.replaceAll("{video}", video)
.replaceAll("{album}", data.title)}
@ -89,6 +106,10 @@ Publié automatiquement via #musictopus`;
const { data: buff } = await axios.get(
data.images[i].uri,
{
headers: {
"User-Agent":
"Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:109.0) Gecko/20100101 Firefox/117.0",
},
responseType: "arraybuffer",
}
);
@ -110,10 +131,6 @@ Publié automatiquement via #musictopus`;
await M.post("statuses", { status, media_ids });
}
const job = new JobsModel(jobData);
job.save();
} catch (err) {
throw new ErrorEvent(
500,
@ -147,6 +164,22 @@ Publié automatiquement via #musictopus`;
return distincts;
}
constructor(req, viewname) {
super(req, viewname);
this.colors = [
"#2e3440",
"#d8dee9",
"#8fbcbb",
"#5e81ac",
"#d08770",
"#bf616a",
"#ebcb8b",
"#a3be8c",
"#b48ead",
];
}
/**
* Méthode permettant de récupérer la liste des albums d'une collection
* @return {Object}
@ -154,7 +187,6 @@ Publié automatiquement via #musictopus`;
async getAll() {
const {
page,
limit,
exportFormat = "json",
sort = "artists_sort",
order = "asc",
@ -164,8 +196,12 @@ Publié automatiquement via #musictopus`;
genre,
style,
userId: collectionUserId,
discogsIds,
discogsId,
} = this.req.query;
const limit = this.req.user?.pagination || 16;
let userId = this.req.user?._id;
const where = {};
@ -213,6 +249,13 @@ Publié automatiquement via #musictopus`;
userId = userIsSharingCollection._id;
}
if (discogsIds) {
where.discogsId = { $in: discogsIds };
}
if (discogsId) {
where.discogsId = Number(discogsId);
}
const count = await AlbumsModel.count({
User: userId,
...where,
@ -256,11 +299,33 @@ Publié automatiquement via #musictopus`;
default:
return {
rows,
limit,
count,
};
}
}
/**
* Méthode permettant de récupérer le détails d'un album
*
* @return {Object}
*/
async getOne() {
const { itemId: _id } = this.req.params;
const { _id: User } = this.req.user;
const album = await AlbumsModel.findOne({
_id,
User,
});
return {
...album.toJSON(),
released: album.released
? formatDate(album.released, "MM/dd/yyyy")
: null,
};
}
/**
* Méthode permettant de mettre à jour un album
*
@ -285,7 +350,9 @@ Publié automatiquement via #musictopus`;
const values = await getAlbumDetails(album.discogsId);
return AlbumsModel.findOneAndUpdate(query, values, { new: true });
await AlbumsModel.findOneAndUpdate(query, values, { new: true });
return this.getOne();
}
/**
@ -294,7 +361,7 @@ Publié automatiquement via #musictopus`;
*/
async deleteOne() {
const res = await AlbumsModel.findOneAndDelete({
user: this.req.user._id,
User: this.req.user._id,
_id: this.req.params.itemId,
});
@ -309,6 +376,83 @@ Publié automatiquement via #musictopus`;
);
}
async shareOne() {
const { message: status } = this.req.body;
const { itemId: _id } = this.req.params;
const { _id: User } = this.req.user;
const query = {
_id,
User,
};
const album = await AlbumsModel.findOne(query);
if (!album) {
throw new ErrorEvent(
404,
"Mise à jour",
"Impossible de trouver cet album"
);
}
const { mastodon: mastodonConfig } = this.req.user;
const { publish, token, url } = mastodonConfig;
if (publish && url && token) {
const M = new Mastodon({
access_token: token,
api_url: url,
});
const media_ids = [];
if (album.images.length > 0) {
for (let i = 0; i < album.images.length; i += 1) {
if (media_ids.length === 4) {
break;
}
const filename = `${v4()}.jpg`;
const file = `/tmp/${filename}`;
// eslint-disable-next-line no-await-in-loop
const { data: buff } = await axios.get(
album.images[i].uri,
{
headers: {
"User-Agent":
"Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:109.0) Gecko/20100101 Firefox/117.0",
},
responseType: "arraybuffer",
}
);
fs.writeFileSync(file, buff);
// eslint-disable-next-line no-await-in-loop
const { data: media } = await M.post("media", {
file: fs.createReadStream(file),
});
const { id } = media;
media_ids.push(id);
fs.unlinkSync(file);
}
}
await M.post("statuses", { status, media_ids });
} else {
throw new ErrorEvent(
406,
`Vous n'avez pas configuré vos options de partage sur votre compte`
);
}
return true;
}
/**
* Méthode permettant de créer la page "ma-collection"
*/
@ -343,19 +487,7 @@ Publié automatiquement via #musictopus`;
* Méthode permettant d'afficher le détails d'un album
*/
async loadItem() {
const { itemId: _id } = this.req.params;
const { _id: User } = this.req.user;
const album = await AlbumsModel.findOne({
_id,
User,
});
const item = {
...album.toJSON(),
released: album.released
? formatDate(album.released, "MM/dd/yyyy")
: null,
};
const item = await this.getOne();
this.setPageContent("item", item);
this.setPageTitle(
@ -363,6 +495,164 @@ Publié automatiquement via #musictopus`;
);
}
/**
* Méthode permettant de choisir un album de manière aléatoire dans la collection d'un utilisateur
*/
async onAir() {
const { _id: User } = this.req.user;
const count = await AlbumsModel.count({
User,
});
const items = await AlbumsModel.find(
{
User,
},
[],
{
skip: Math.floor(Math.random() * (count + 1)),
limit: 1,
}
);
this.req.params.itemId = items[0]._id;
await this.loadItem();
}
/**
* Méthode permettant d'afficher des statistiques au sujet de ma collection
*/
async statistics() {
const { _id: User } = this.req.user;
const top = {};
const byGenres = {};
const byStyles = {};
const byFormats = {};
const top10 = [];
let byStyles10 = [];
const max = this.colors.length - 1;
const colorsCount = this.colors.length;
const albums = await AlbumsModel.find({
User,
artists: { $exists: true, $not: { $size: 0 } },
});
for (let i = 0; i < albums.length; i += 1) {
const currentFormats = [];
const { artists, genres, styles, formats } = albums[i];
// INFO: On regroupe les artistes par nom pour en faire le top10
for (let j = 0; j < artists.length; j += 1) {
const { name } = artists[j];
if (!top[name]) {
top[name] = {
name,
count: 0,
};
}
top[name].count += 1;
}
// INFO: On regroupe les genres
for (let j = 0; j < genres.length; j += 1) {
const name = genres[j];
if (!byGenres[name]) {
byGenres[name] = {
name,
count: 0,
color: this.colors[
Object.keys(byGenres).length % colorsCount
],
};
}
byGenres[name].count += 1;
}
// INFO: On regroupe les styles
for (let j = 0; j < styles.length; j += 1) {
const name = styles[j];
if (!byStyles[name]) {
byStyles[name] = {
name,
count: 0,
color: this.colors[
Object.keys(byStyles).length % colorsCount
],
};
}
byStyles[name].count += 1;
}
// INFO: On regroupe les formats
for (let j = 0; j < formats.length; j += 1) {
const { name } = formats[j];
// INFO: On évite qu'un album avec 2 vinyles soit compté 2x
if (!currentFormats.includes(name)) {
if (!byFormats[name]) {
byFormats[name] = {
name,
count: 0,
color: this.colors[
Object.keys(byFormats).length % colorsCount
],
};
}
byFormats[name].count += 1;
currentFormats.push(name);
}
}
}
// INFO: On convertit le top en tableau
Object.keys(top).forEach((index) => {
top10.push(top[index]);
});
// INFO: On convertit les styles en tableau
Object.keys(byStyles).forEach((index) => {
byStyles10.push(byStyles[index]);
});
// INFO: On ordonne les artistes par quantité d'albums
top10.sort((a, b) => (a.count > b.count ? -1 : 1));
// INFO: On ordonne les styles par quantité
byStyles10.sort((a, b) => (a.count > b.count ? -1 : 1));
const tmp = [];
// INFO: On recupère le top N des styles et on mets le reste dans le label "autre"
for (let i = 0; i < byStyles10.length; i += 1) {
if (i < max) {
tmp.push({
...byStyles10[i],
color: this.colors[max - i],
});
} else if (i === max) {
tmp.push({
name: "Autre",
count: 0,
color: this.colors[0],
});
tmp[max].count += byStyles10[i].count;
} else {
tmp[max].count += byStyles10[i].count;
}
}
byStyles10 = tmp;
this.setPageTitle("Mes statistiques");
this.setPageContent("top10", top10.splice(0, 10));
this.setPageContent("byGenres", byGenres);
this.setPageContent("byStyles", byStyles10);
this.setPageContent("byFormats", byFormats);
}
/**
* Méthode permettant de créer la page "collection/:userId"
*/
@ -385,8 +675,8 @@ Publié automatiquement via #musictopus`;
const genres = await Albums.getAllDistincts("genres", userId);
const styles = await Albums.getAllDistincts("styles", userId);
this.setPageContent("username", user.username);
this.setPageTitle(`Collection publique de ${user.username}`);
this.setPageContent("username", user.username);
this.setPageContent("artists", artists);
this.setPageContent("formats", formats);
this.setPageContent("years", years);

View File

@ -16,6 +16,7 @@ class Me extends Pages {
const { _id } = this.req.user;
const schema = Joi.object({
pagination: Joi.number(),
isPublicCollection: Joi.boolean(),
oldPassword: Joi.string(),
password: Joi.string(),
@ -37,12 +38,22 @@ class Me extends Pages {
}
}
user.mastodon = value.mastodon;
if (value.mastodon !== undefined) {
user.mastodon = value.mastodon;
}
if (value.password) {
user.salt = value.password;
}
if (value.pagination) {
user.pagination = value.pagination;
}
if (value.isPublicCollection !== undefined) {
user.isPublicCollection = value.isPublicCollection;
}
user.save();
await new Promise((resolve, reject) => {

View File

@ -25,6 +25,10 @@ const UserSchema = new mongoose.Schema(
},
hash: String,
salt: String,
pagination: {
type: Number,
default: 16,
},
isPublicCollection: {
type: Boolean,
default: false,

View File

@ -68,4 +68,17 @@ router
}
});
router
.route("/:itemId/share")
.post(ensureLoggedIn("/connexion"), async (req, res, next) => {
try {
const albums = new Albums(req);
const data = await albums.shareOne();
sendResponse(req, res, data);
} catch (err) {
next(err);
}
});
export default router;

View File

@ -3,6 +3,7 @@ import { ensureLoggedIn } from "connect-ensure-login";
import { sendResponse } from "../../../libs/format";
import { searchSong, getAlbumDetails } from "../../../helpers";
import Albums from "../../../middleware/Albums";
// eslint-disable-next-line new-cap
const router = express.Router();
@ -16,6 +17,30 @@ router.route("/").get(ensureLoggedIn("/connexion"), async (req, res, next) => {
req.query.country || null
);
const discogsIds = [];
const foundIds = [];
for (let i = 0; i < data.results.length; i += 1) {
discogsIds.push(data.results[i].id);
}
req.query.discogsIds = discogsIds;
const albums = new Albums(req);
const myAlbums = await albums.getAll();
if (myAlbums.rows) {
for (let i = 0; i < myAlbums.rows.length; i += 1) {
foundIds.push(myAlbums.rows[i].discogsId);
}
}
for (let i = 0; i < data.results.length; i += 1) {
data.results[i].inCollection = foundIds.includes(
data.results[i].id
);
}
sendResponse(req, res, data);
} catch (err) {
next(err);

View File

@ -24,6 +24,37 @@ router.route("/").get(ensureLoggedIn("/connexion"), async (req, res, next) => {
}
});
router
.route("/on-air")
.get(ensureLoggedIn("/connexion"), async (req, res, next) => {
try {
const page = new Albums(req, "mon-compte/ma-collection/details");
await page.onAir();
render(res, page);
} catch (err) {
next(err);
}
});
router
.route("/statistiques")
.get(ensureLoggedIn("/connexion"), async (req, res, next) => {
try {
const page = new Albums(
req,
"mon-compte/ma-collection/statistiques"
);
await page.statistics();
render(res, page);
} catch (err) {
next(err);
}
});
router
.route("/exporter")
.get(ensureLoggedIn("/connexion"), async (req, res, next) => {
@ -32,6 +63,19 @@ router
page.setPageTitle("Exporter ma collection");
render(res, page);
} catch (err) {
next(err);
}
});
router
.route("/importer")
.get(ensureLoggedIn("/connexion"), async (req, res, next) => {
try {
const page = new Albums(req, "mon-compte/ma-collection/importer");
page.setPageTitle("Importer une collection");
render(res, page);
} catch (err) {
next(err);

133
views/components/album.ejs Normal file
View File

@ -0,0 +1,133 @@
<div class="grid md:grid-cols-3 gap-16">
<div>
<template v-for="album in tracklist">
<strong v-if="album.title">{{album.title}}</strong>
<ul>
<li v-for="(track, index) in album.tracks" class="ml-4">
{{track.position || (index+1)}} - {{ track.title }} <template v-if="track.duration">({{track.duration}})</template>
<ul v-if="track.artists && track.artists.length > 0" class="sm-hidden">
<li v-for="extra in track.artists" class=" ml-4">
<small>{{extra.name}}</small>
</li>
</ul>
<ul v-if="track.extraartists && track.extraartists.length > 0" class="sm-hidden">
<li v-for="extra in track.extraartists" class=" ml-4">
<small>{{extra.role}} : <a :href="`/ma-collection?page=1&limit=16&sort=year&order=asc&artist=${extra.name}`">{{extra.name}}</a></small>
</li>
</ul>
</li>
</ul>
</template>
</div>
<div class="md:col-span-2">
<div class="grid grid-cols-2 gap-10">
<div>
<strong>Genres</strong>
<br />
<template v-for="(genre, index) in item.genres">
{{genre}}<template v-if="index < item.genres.length - 1">, </template>
</template>
</div>
<div>
<strong>Styles</strong>
<br />
<span v-for="(style, index) in item.styles">
{{style}}<template v-if="index < item.styles.length - 1">, </template>
</span>
</div>
</div>
<hr />
<div class="grid grid-cols-3 gap-10">
<div>
<strong>Pays</strong>
<br />
<span>{{item.country}}</span>
</div>
<div>
<strong>Année</strong>
<br />
<span>{{item.year}}</span>
</div>
<div>
<strong>Date de sortie</strong>
<br />
<span>{{item.released}}</span>
</div>
</div>
<hr />
<div class="grid gap-10">
<div>
<strong>Format<template v-if="item.formats.length > 1">s</template></strong>
<ul class="ml-4">
<li v-for="(format) in item.formats">
{{format.name}}
<template v-if="format.text">
- <i>{{format.text}}</i>
</template>
<template v-if="format.descriptions && format.descriptions.length > 0">
(<span v-for="(description, index) in format.descriptions">
{{description}}<template v-if="index < format.descriptions.length - 1">, </template>
</span>)
</template>
</li>
</ul>
</div>
</div>
<hr />
<div class="grid grid-cols-1 md:grid-cols-2 gap-10">
<div>
<strong id="identifiers">Code<template v-if="item.identifiers.length > 1">s</template> barre<template v-if="item.identifiers.length > 1">s</template></strong>
<ol class="ml-4">
<li v-for="identifier in identifiers">
{{identifier.value}} ({{identifier.type}})
</li>
</ol>
<template v-if="item.identifiers.length > identifiersPreviewLength">
<button type="button" class="button is-link" v-if="identifiersMode === 'preview'" @click="showAllIdentifiers">
Voir la suite
</button>
<button type="button" class="button is-link" v-if="identifiersMode === 'all'" @click="showLessIdentifiers">
Voir moins
</button>
</template>
</div>
<div>
<strong>Label<template v-if="item.labels.length > 1">s</template></strong>
<ol class="ml-4">
<li v-for="label in item.labels">
{{label.name}} {{label.catno}}
</li>
</ol>
<strong>Société<template v-if="item.companies.length > 1">s</template></strong>
<ol class="ml-4">
<li v-for="company in item.companies">
<strong>{{company.entity_type_name}}</strong> {{company.name}}
</li>
</ol>
</div>
</div>
<hr />
<div class="grid gap-10">
<div>
<strong>Note</strong>
<div v-html="(item.notes || '').replaceAll('\n', '<br />')"></div>
</div>
</div>
<hr />
<div class="grid gap-10">
<div>
<strong>Vidéos</strong>
<dl>
<template v-for="video in item.videos">
<dt>
<a :href="video.uri" target="_blank" rel="noopener noreferrer">{{video.title}}</a>
</dt>
<dd>
{{video.description}}
</dd>
</template>
</dl>
</div>
</div>
</div>
</div>

View File

@ -16,6 +16,9 @@
<link href="/css/main.css" rel="stylesheet" />
<script src="/js/libs.js"></script>
<script defer src="/js/main.js"></script>
<% if ( config.matomoUrl ) { %>
<!-- Matomo -->
<script>
@ -35,86 +38,120 @@
<% } %>
</head>
<body>
<nav class="navbar" aria-label="Navigation principale">
<div class="navbar-brand">
<a class="navbar-item" href="/">
<img src="/img/logo.png" alt="Logo MusicTopus">
<span>MusicTopus</span>
</a>
<a role="button" class="navbar-burger" aria-label="Afficher le menu" aria-expanded="false" data-target="navbar">
<span aria-hidden="true"></span>
<span aria-hidden="true"></span>
<span aria-hidden="true"></span>
</a>
</div>
<div id="navbar" class="navbar-menu">
<% if ( user ) { %>
<div class="navbar-start">
<div class="navbar-item">
<div class="buttons">
<a class="button is-primary" href="/ajouter-un-album">
<i class="icon-plus"></i>
<span>
Ajouter un album
</span>
</a>
</div>
</div>
</div>
<% } %>
<div class="navbar-end">
<a class="navbar-item" href="/nous-contacter">
Nous contacter
<nav class="navbar">
<nav class="navbar container" aria-label="Navigation principale">
<div class="navbar-brand">
<a class="navbar-item" href="/">
<img src="/img/logo.png" alt="Logo MusicTopus">
<span>MusicTopus</span>
</a>
<% if ( user ) { %>
<div class="navbar-item has-dropdown">
<a class="navbar-link">
<i class="icon-user"></i>
<span>
<%= user.username %>
</span>
</a>
<div class="navbar-dropdown">
<a class="navbar-item" href="/mon-compte">
Mon compte
</a>
<hr />
<a class="navbar-item" href="/ma-collection">
Ma collection
</a>
<a class="navbar-item" href="/ma-collection/exporter">
Exporter ma collection
</a>
<a role="button" class="navbar-burger" aria-label="Afficher le menu" aria-expanded="false" data-target="navbar">
<span aria-hidden="true"></span>
<span aria-hidden="true"></span>
<span aria-hidden="true"></span>
</a>
</div>
<div id="navbar" class="navbar-menu">
<% if ( user ) { %>
<div class="navbar-start">
<div class="navbar-item">
<div class="buttons">
<a class="button is-primary" href="/ajouter-un-album">
<i class="icon-plus"></i>
<span>
Ajouter un album
</span>
</a>
</div>
</div>
</div>
<% } %>
<div class="navbar-item apparence">
<div class="theme-switch-wrapper">
<label class="theme-switch" for="checkbox" aria-label="Passer du thème clair au thème sombre et inversement">
<input type="checkbox" id="checkbox" />
<div class="slider round"></div>
</label>
</div>
</div>
<div class="navbar-item">
<div class="buttons">
<% if ( !user ) { %>
<a class="button is-primary" href="/connexion">
<strong>Connexion</strong>
<div class="navbar-end">
<a class="navbar-item" href="/nous-contacter">
Nous contacter
</a>
<div class="navbar-item has-dropdown">
<a class="navbar-link">
<i class="icon-adjust theme-system icon-theme hidden"></i>
<i class="icon-sun theme-light icon-theme hidden"></i>
<i class="icon-moon theme-dark icon-theme hidden"></i>
<span>
Thème
</span>
</a>
<% } else { %>
<a class="button is-danger" href="/se-deconnecter">
Déconnexion
</a>
<% } %>
<div class="navbar-dropdown">
<button class="navbar-item theme" data-value="system">
<i class="icon-adjust"></i>
<span>
Système
</span>
</button>
<button class="navbar-item theme" data-value="light">
<i class="icon-sun"></i>
<span>
Clair
</span>
</button>
<button class="navbar-item theme" data-value="dark">
<i class="icon-moon"></i>
<span>
Sombre
</span>
</button>
</div>
</div>
<% if ( user ) { %>
<div class="navbar-item has-dropdown">
<a class="navbar-link">
<i class="icon-user"></i>
<span>
<%= user.username %>
</span>
</a>
<div class="navbar-dropdown">
<a class="navbar-item" href="/mon-compte">
Mon compte
</a>
<hr />
<a class="navbar-item" href="/ma-collection">
Ma collection
</a>
<a class="navbar-item" href="/ma-collection/on-air">
On air
</a>
<a class="navbar-item" href="/ma-collection/statistiques">
Statistiques
</a>
<a class="navbar-item" href="/ma-collection/exporter">
Exporter ma collection
</a>
<a class="navbar-item" href="/ma-collection/importer">
Importer une collection
</a>
<hr />
<a class="navbar-item is-danger" href="/se-deconnecter">
Déconnexion
</a>
</div>
</div>
<% } %>
<% if ( !user ) { %>
<div class="navbar-item">
<div class="buttons">
<a class="button is-primary" href="/connexion">
<strong>Connexion</strong>
</a>
</div>
</div>
<% } %>
</div>
</div>
</div>
</nav>
</nav>
<div id="toastr">
@ -171,7 +208,7 @@
<footer class="footer layout-hero">
<p>
<strong title="Merci Brunus ! 😜">MusicTopus</strong> par <a href="https://www.darkou.fr" target="_blank" rel="noopener noreferrer">Damien Broqua <i class="icon-link"></i></a>.
<strong title="Merci Brunus ! 😜">MusicTopus</strong> par <a href="https://www.darkou.link" target="_blank" rel="noopener noreferrer">Damien Broqua <i class="icon-link"></i></a>.
Logo réalisé par Brunus avec <a href="https://inkscape.org/fr/" target="_blank" rel="noopener noreferrer">Inkscape <i class="icon-link"></i></a>.
<br />
Le code source est sous licence <a href="https://www.gnu.org/licenses/gpl-3.0-standalone.html" target="_blank" rel="noopener noreferrer">GNU GPL-3.0-or-later <i class="icon-link"></i></a> et disponible sur <a href="https://git.darkou.fr/dbroqua/MusicTopus" target="_blank">git.darkou.fr <i class="icon-link"></i></a>.
@ -179,8 +216,5 @@
Fait avec ❤️ à Bordeaux.
</p>
</footer>
<script defer src="/js/libs.js"></script>
<script defer src="/js/main.js"></script>
</body>
</html>

View File

@ -34,8 +34,9 @@
<div class="grid grid-cols-1 md:grid-cols-2 list hover">
<div class="item" v-if="!loading" v-for="item in items">
<div v-if="!loading" v-for="item in items" class="item" :class="{'in-collection': item.inCollection}">
<a @click="loadDetails(item.id)" class="title">{{ item.artists_sort }} {{ item.title }}</a>
<small v-if="item.inCollection"> (Dans ma collection)</small>
<div class="grid grid-cols-2 md:grid-cols-4">
<div>
<img :src="item.thumb" :alt="item.title" @click="loadDetails(item.id)"/>
@ -78,7 +79,7 @@
<button aria-label="Fermer" class="close" @click="toggleModal"></button>
</header>
<section>
<div class="grid grid-cols-2 gap-16">
<div class="grid grid-cols-1 md:grid-cols-3 gap-16">
<div>
<div class="text-center">
<img :src="details.thumb %>" :alt="`Miniature pour l'album ${details.title}`" />
@ -86,56 +87,57 @@
<img v-for="image in details.images" :src="image.uri150" :alt="`Miniature de type ${image.type}`" style="max-width: 60px;" />
<hr />
</div>
<ol class="ml-4">
<li v-for="track in details.tracklist">
{{ track.title }} ({{track.duration}})
<ul v-if="track.artists && track.artists.length > 0" class="sm-hidden">
<li v-for="extra in track.artists" class=" ml-4">
<small>{{extra.role}} : {{extra.name}}</small>
</li>
</ul>
<ul class="is-unstyled">
<li v-for="track in details.tracklist" :class="{'ml-4': track.type_ === 'track'}">
<strong v-if="track.type_ === 'heading'">
{{track.title}}
</strong>
<template v-else>
{{ track.position }}
{{ track.title }} <span v-if="track.duration">({{track.duration}})</span>
<ul v-if="track.artists && track.artists.length > 0" class="sm-hidden">
<li v-for="extra in track.artists" class=" ml-4">
<small>{{extra.role}} : {{extra.name}}</small>
</li>
</ul>
</template>
</li>
</ol>
</ul>
</div>
<div>
<div class="grid grid-cols-2 gap-10">
<div>
<div class="md:col-span-2">
<div class="grid grid-cols-1 md:grid-cols-2 gap-10">
<div class="grid grid-cols-1">
<strong>Genres</strong>
<br />
<template v-for="(genre, index) in details.genres">
{{genre}}<template v-if="index < details.genres.length - 1">, </template>
</template>
</div>
<div>
<div class="grid grid-cols-1">
<strong>Styles</strong>
<br />
<span v-for="(style, index) in details.styles">
{{style}}<template v-if="index < details.styles.length - 1">, </template>
</span>
</div>
</div>
<hr />
<div class="grid grid-cols-3 gap-10">
<div>
<div class="grid grid-cols-1 md:grid-cols-3 gap-10">
<div class="grid grid-cols-2 md:grid-cols-1">
<strong>Pays</strong>
<br />
<span>{{details.country}}</span>
</div>
<div>
<div class="grid grid-cols-2 md:grid-cols-1">
<strong>Année</strong>
<br />
<span>{{details.year}}</span>
</div>
<div>
<div class="grid grid-cols-2 md:grid-cols-1">
<strong>Date de sortie</strong>
<br />
<span>{{details.released}}</span>
</div>
</div>
<hr />
<div class="grid grid-cols-2 gap-10">
<div class="grid grid-cols-1 gap-10">
<div>
<strong>Format</strong>
<strong>Format<template v-if="details?.formats?.length > 1">s</template></strong>
<ul class="ml-4">
<li v-for="(format) in details.formats">
{{format.name}}
@ -152,25 +154,26 @@
</div>
</div>
<hr />
<div class="grid grid-cols-2 gap-10">
<div class="grid grid-cols-1 md:grid-cols-2 gap-10">
<div>
<strong>Codes barres</strong>
<ol>
<strong>Code<template v-if="details?.identifiers?.length > 1">s</template> barre<template v-if="details?.identifiers?.length > 1">s</template></strong>
<ol class="ml-4">
<li v-for="identifier in details.identifiers">
{{identifier.value}} ({{identifier.type}})
</li>
</ol>
</div>
<div>
<strong>Label</strong>
<ol>
<strong>Label<template v-if="details?.labels?.length > 1">s</template></strong>
<ol class="ml-4">
<li v-for="label in details.labels">
{{label.name}}
</li>
</ol>
<strong>Société</strong>
<ol>
<li v-for="company in details.companie">
<strong>Société<template v-if="details?.companies?.length > 1">s</template></strong>
<ol class="ml-4">
<li v-for="company in details.companies">
<strong>{{company.entity_type_name}}</strong>
{{company.name}}
</li>
</ol>
@ -180,9 +183,21 @@
</div>
</section>
<footer>
<% if ( user.mastodon && user.mastodon.publish ) { %>
<div class="field">
<label for="share">Partager sur le fédiverse</label>
<span>
<input type="checkbox" id="share" name="share" v-model="share">
</span>
</div>
<% } %>
<button :class="['button is-primary', submitting ? 'is-disabled' : '']" @click="add">Ajouter</button>
<button class="button" @click="toggleModal">Annuler</button>
</footer>
</div>
</div>
</main>
</main>
<script>
const canPublish = <%- (user.mastodon && user.mastodon.publish) || false %>;
</script>

View File

@ -238,7 +238,7 @@
</div>
<h2 id="boites">Les boites</h2>
<div class="box">
<div class="box mini">
<form method="POST">
<h1>
Connexion
@ -487,14 +487,6 @@
&lt;/a&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div class="navbar-item apparence"&gt;
&lt;div class="theme-switch-wrapper"&gt;
&lt;label class="theme-switch" for="checkbox" aria-label="Passer du thème clair au thème sombre et inversement"&gt;
&lt;input type="checkbox" id="checkbox" /&gt;
&lt;div class="slider round"&gt;&lt;/div&gt;
&lt;/label&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div class="navbar-item"&gt;
&lt;div class="buttons"&gt;
&lt;a class="button is-danger" href="/se-deconnecter"&gt;

View File

@ -1,4 +1,4 @@
<div class="box">
<div class="box mini">
<form method="POST">
<h1>
Connexion

View File

@ -20,7 +20,7 @@
Pourquoi utiliser MusicTopus ?
</h2>
<p class="text-justify">
<strong>MusicTopus</strong> est indispensable lorsqu'une collection, de CD-audios et vyniles, est devenue trop importante pour qu'on puisse se souvenir de tous les albums qu'elle contient. Consulter MusicTopus peut par exemple éviter un achat en double, et de savoir qu'on a des albums à céder ou échanger.
<strong>MusicTopus</strong> est indispensable lorsqu'une collection, de CD-audios et vinyles, est devenue trop importante pour qu'on puisse se souvenir de tous les albums qu'elle contient. Consulter MusicTopus peut par exemple éviter un achat en double, et de savoir qu'on a des albums à céder ou échanger.
<br />
Il existe déjà plusieurs applications de gestion de librairies musicales mais, (au moment de l'édition de cette présentation) aucune facilement accessible via internet, par exemple lorsqu'on est chez un disquaire.
</p>

View File

@ -1,4 +1,4 @@
<div class="box">
<div class="box mini">
<form method="POST">
<h1>
Inscription

View File

@ -5,7 +5,7 @@
<form method="POST" @submit.prevent="updateProfil">
<div class="grid grid-cols-1 md:grid-cols-2 gap-10">
<div>
<div class="box">
<h2>Mes données personnelles</h2>
<div>
<div class="field">
@ -68,7 +68,7 @@
</div>
</div>
</div>
<div>
<div class="box">
<h2>Mon activité</h2>
<div>
<div class="field">
@ -118,6 +118,8 @@
<li>{format}, exemple : Cassette</li>
<li>{year}, exemple: 1984</li>
<li>{video}, exemple : https://www.youtube.com/watch?v=Qx0s8OqgBIw</li>
<li>{genres}, exemple : Rock</li>
<li>{styles}, exemple : Hard Rock, Heavy Metal</li>
</ul>
</small>
</div>
@ -126,6 +128,22 @@
</button>
</div>
</div>
<div class="box">
<h2>Mes préférences</h2>
<div>
<div class="field">
<label for="pagination">Pagination</label>
<select id="pagination" v-model="formData.pagination">
<option value="16">16 albums/page</option>
<option value="24">24 albums/page</option>
<option value="32">32 albums/page</option>
<option value="48">48 albums/page</option>
</select>
</div>
</div>
</div>
<div></div>
<button type="submit" class="button is-primary mt-10" :disabled="loading">
<span v-if="!loading">Mettre à jour</span>
@ -139,5 +157,6 @@
<script>
const email = '<%= user.email %>';
const username = '<%= user.username %>';
const pagination = "<%= user.pagination || 16 %>";
const mastodon = <%- JSON.stringify(user.mastodon || {publish: false, url: '', token: '', message: ''}) %>;
</script>
</script>

View File

@ -8,6 +8,7 @@
- {{item.title}}
<i class="icon-trash" title="Supprimer cette fiche" @click="showConfirmDelete()"></i>
<i class="icon-refresh" title="Mettre à jour les données de cette fiche" @click="updateItem()"></i>
<i class="icon-share" title="Partager cet album sur le fédiverse" @click="showModalShare = true" v-if="canShareItem"></i>
</h1>
<div class="grid sm:grid-cols-3 gap-16">
<div class="text-center">
@ -20,152 +21,22 @@
</div>
</div>
<hr />
<div class="grid md:grid-cols-3 gap-16">
<div>
<template v-for="album in tracklist">
<strong v-if="album.title">{{album.title}}</strong>
<ul>
<li v-for="(track, index) in album.tracks" class="ml-4">
{{track.position || (index+1)}} - {{ track.title }} <template v-if="track.duration">({{track.duration}})</template>
<ul v-if="track.artists && track.artists.length > 0" class="sm-hidden">
<li v-for="extra in track.artists" class=" ml-4">
<small>{{extra.name}}</small>
</li>
</ul>
<ul v-if="track.extraartists && track.extraartists.length > 0" class="sm-hidden">
<li v-for="extra in track.extraartists" class=" ml-4">
<small>{{extra.role}} : {{extra.name}}</small>
</li>
</ul>
</li>
</ul>
</template>
</div>
<div class="md:col-span-2">
<div class="grid grid-cols-2 gap-10">
<div>
<strong>Genres</strong>
<br />
<template v-for="(genre, index) in item.genres">
{{genre}}<template v-if="index < item.genres.length - 1">, </template>
</template>
</div>
<div>
<strong>Styles</strong>
<br />
<span v-for="(style, index) in item.styles">
{{style}}<template v-if="index < item.styles.length - 1">, </template>
</span>
</div>
</div>
<hr />
<div class="grid grid-cols-3 gap-10">
<div>
<strong>Pays</strong>
<br />
<span>{{item.country}}</span>
</div>
<div>
<strong>Année</strong>
<br />
<span>{{item.year}}</span>
</div>
<div>
<strong>Date de sortie</strong>
<br />
<span>{{item.released}}</span>
</div>
</div>
<hr />
<div class="grid gap-10">
<div>
<strong>Format</strong>
<ul class="ml-4">
<li v-for="(format) in item.formats">
{{format.name}}
<template v-if="format.text">
- <i>{{format.text}}</i>
</template>
<template v-if="format.descriptions && format.descriptions.length > 0">
(<span v-for="(description, index) in format.descriptions">
{{description}}<template v-if="index < format.descriptions.length - 1">, </template>
</span>)
</template>
</li>
</ul>
</div>
</div>
<hr />
<div class="grid grid-cols-2 gap-10">
<div>
<strong id="identifiers">Codes barres</strong>
<ol class="ml-4">
<li v-for="identifier in identifiers">
{{identifier.value}} ({{identifier.type}})
</li>
</ol>
<template v-if="item.identifiers.length > identifiersPreviewLength">
<button type="button" class="button is-link" v-if="identifiersMode === 'preview'" @click="showAllIdentifiers">
Voir la suite
</button>
<button type="button" class="button is-link" v-if="identifiersMode === 'all'" @click="showLessIdentifiers">
Voir moins
</button>
</template>
</div>
<div>
<strong>Label</strong>
<br />
<template v-for="label in item.labels">
{{label.name}} {{label.catno}}
<br />
</template>
<hr />
<strong>Sociétés</strong>
<br />
<template v-for="company in item.companies">
<strong>{{company.entity_type_name}}</strong> : {{company.name}}
<br />
</template>
</div>
</div>
<hr />
<div class="grid gap-10">
<div>
<strong>Note</strong>
<div v-html="(item.notes || '').replaceAll('\n', '<br />')"></div>
</div>
</div>
<hr />
<div class="grid gap-10">
<div>
<strong>Vidéos</strong>
<dl>
<template v-for="video in item.videos">
<dt>
<a :href="video.uri" target="_blank" rel="noopener noreferrer">{{video.title}}</a>
</dt>
<dd>
{{video.description}}
</dd>
</template>
</dl>
</div>
</div>
</div>
</div>
<%- include('../../../components/album.ejs') %>
<div class="modal" :class="{'is-visible': modalIsVisible}">
<div class="modal-background"></div>
<button type="button" aria-label="Fermer" class="close" @click="toggleModal"></button>
<button type="button" aria-label="Image précédente" class="navigation previous" @click="previous" v-if="index > 0">
<i class="icon-left-open"></i>
</button>
<button type="button" aria-label="Image suivante" class="navigation next" @click="next" v-if="index + 1 < item.images.length">
<i class="icon-right-open"></i>
</button>
<div class="modal-card">
<img :src="preview" />
<div class="carousel">
<button type="button" aria-label="Image précédente" class="navigation previous" @click="previous">
<i class="icon-left-open"></i>
</button>
<div class="text-center">
<img :src="preview" />
</div>
<button type="button" aria-label="Image suivante" class="navigation next" @click="next">
<i class="icon-right-open"></i>
</button>
</div>
</div>
@ -182,8 +53,48 @@
</footer>
</div>
</div>
<div class="modal" :class="{'is-visible': showModalShare}">
<div class="modal-background"></div>
<div class="modal-card">
<header>Partager un album sur le fédiverse</header>
<section>
<div class="grid grid-cols-1 md:grid-cols-2 gap-10">
<div class="field">
<label for="shareMessage">Message</label>
<textarea
name="shareMessage"
id="shareMessage"
v-model="shareMessage"
rows="6"
></textarea>
Caractères utilisés : {{ shareMessageLength }}
</div>
<div>
<small>
Variables possibles :
<ul>
<li>{artist}, exemple : Iron Maiden</li>
<li>{album}, exemple : Powerslave</li>
<li>{format}, exemple : Cassette</li>
<li>{year}, exemple: 1984</li>
<li>{video}, exemple : https://www.youtube.com/watch?v=Qx0s8OqgBIw</li>
<li>{genres}, exemple : Rock</li>
<li>{styles}, exemple : Hard Rock, Heavy Metal</li>
</ul>
</small>
</div>
</div>
</section>
<footer>
<button :class="['button is-primary', shareSubmiting ? 'is-disabled' : '']" @click="shareAlbum">Partager</button>
<button class="button" @click="showModalShare=!showModalShare">Annuler</button>
</footer>
</div>
</div>
</main>
<script>
const item = <%- JSON.stringify(page.item) %>;
const canShareItem = <%= user.mastodon?.publish || false %>;
</script>

View File

@ -0,0 +1,43 @@
<main class="layout-maxed" id="importer">
<h1>Importer une collection</h1>
<p>
Il est actuellement possible d'importer une collection provenant de discogs.
<br />
Vous devez dans un premier temps vous rendre sur la page <a href="https://www.discogs.com/fr/users/export" target="_blank" rel="noopener noreferrer">Exporter</a> de discogs.
<br />
Une fois exporter vous recevrez un mail de Discogs avec un lien de téléchargement. Une fois le fichier .zip téléchargé vous devez en extraire le fichier .csv afin de l'importer dans MusicTopus.
</p>
<p>
D'autres formats d'imports seront ajoutés par la suite, comme l'import entre 2 instances MusicTopus.
</p>
<div class="flash info">
<div class="header">
Information
</div>
<div class="body">
Si un album est déjà présent en base celui-ci sera ignoré.
</div>
</div>
<form @submit="importCollection">
<div class="field">
<label for="file">Fichier .csv</label>
<input type="file" name="file" id="file" @change="handleFileUpload( $event )" accept=".csv">
</div>
<div class="field">
<span>
Albums à impoter : <strong>{{content.length}}</strong>
</span>
</div>
<button type="submit" class="button is-primary my-16" :disabled="disabled">
<i v-if="['parse', 'submit'].includes(state)" class="icon-spin animate-spin"></i>
<span v-if="state === 'default'">Importer</span>
<span v-if="state === 'parse'">Analyse en cours...</span>
<span v-if="state === 'submit'">Importation en cours... ({{imported}}/{{content.length}})</span>
<span v-if="state === 'done'">Importatation terminée</span>
</button>
</form>
</main>

View File

@ -0,0 +1,122 @@
<main class="layout-maxed ma-collection-details" id="ma-collection-statistiques">
<h1>
Mes statistiques
</h1>
<div class="grid gap-10 grid-cols-1 md:grid-cols-2 mb-10">
<div class="md:col-span-2 box">
<h2>Mon top 10</h2>
<table>
<thead>
<tr>
<th style="width: 60px;"></th>
<th>Artiste</th>
<th style="width: 100px;">Albums</th>
</tr>
</thead>
<tbody>
<% for ( let i = 0 ; i < page.top10.length ; i += 1 ) { %>
<tr>
<td><%= i+1 %></td>
<td><%= page.top10[i].name %></td>
<td><%= page.top10[i].count %></td>
</tr>
<% } %>
</tbody>
</table>
</div>
</div>
<div class="grid gap-10 grid-cols-1 md:grid-cols-2 mb-10">
<div class="box">
<h2>Genres</h2>
<canvas id="byGenres"></canvas>
</div>
<div class="box">
<h2>Styles</h2>
<canvas id="byStyles"></canvas>
</div>
<div class="box">
<h2>Formats</h2>
<canvas id="byFormats"></canvas>
</div>
</div>
</main>
<script>
const byGenres = <%- JSON.stringify(page.byGenres) %>;
const byStyles = <%- JSON.stringify(page.byStyles) %>;
const byFormats = <%- JSON.stringify(page.byFormats) %>;
const ctxGenres= document.getElementById('byGenres');
const ctxStyles = document.getElementById('byStyles');
const ctxFormats = document.getElementById('byFormats');
const options = {
responsive: true,
plugins: {
legend: {
position: 'bottom',
},
title: {
display: false,
}
}
};
new Chart(ctxGenres, {
type: 'doughnut',
data: {
labels: Object.keys(byGenres).map((index) => {return byGenres[index].name}),
datasets: [
{
backgroundColor: Object.keys(byGenres).map((index) => {return byGenres[index].color}),
data: Object.keys(byGenres).map((index) => {return byGenres[index].count}),
},
],
},
options,
});
const styleLabels = [];
const styleBg = [];
const styleData = [];
for ( let i = 0 ; i < byStyles.length ; i += 1 ) {
const {
name,
color,
count,
} = byStyles[i];
styleLabels.push(name);
styleBg.push(color);
styleData.push(count);
}
new Chart(ctxStyles, {
type: 'doughnut',
data: {
labels: styleLabels,
datasets: [
{
backgroundColor: styleBg,
data: styleData,
},
],
},
options,
});
new Chart(ctxFormats, {
type: 'doughnut',
data: {
labels: Object.keys(byFormats).map((index) => {return byFormats[index].name}),
datasets: [
{
backgroundColor: Object.keys(byFormats).map((index) => {return byFormats[index].color}),
data: Object.keys(byFormats).map((index) => {return byFormats[index].count}),
},
],
},
options,
});
</script>

View File

@ -1,4 +1,4 @@
<section class="box" id="contact">
<section class="box mini" id="contact">
<h1>Nous contacter</h1>
<form @submit="send" <% if (config.mailMethod === 'formspree' ) { %> id="contact" method="POST" action="https://formspree.io/f/<%= config.formspreeId %>" <% } %>>
<div class="grid grid-cols-1 lg:grid-cols-2 gap-16">