Compare commits

..

No commits in common. "develop" and "1.5" have entirely different histories.
develop ... 1.5

31 changed files with 370 additions and 19080 deletions

View file

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

View file

@ -1,8 +1,6 @@
Vue.createApp({ Vue.createApp({
data() { data() {
return { return {
// eslint-disable-next-line no-undef
share: canPublish,
q: "", q: "",
year: "", year: "",
country: "", country: "",
@ -115,7 +113,6 @@ Vue.createApp({
format, format,
genre, genre,
style, style,
inCollection,
} = results[i]; } = results[i];
items.push({ items.push({
id, id,
@ -126,7 +123,6 @@ Vue.createApp({
format, format,
genre, genre,
style, style,
inCollection,
}); });
} }
@ -171,10 +167,7 @@ Vue.createApp({
this.submitting = true; this.submitting = true;
return axios return axios
.post("/api/v1/albums", { .post("/api/v1/albums", this.details)
album: this.details,
share: this.share,
})
.then(() => { .then(() => {
window.location.href = "/ma-collection"; window.location.href = "/ma-collection";
}) })

View file

@ -25,10 +25,6 @@ Vue.createApp({
// eslint-disable-next-line no-undef // eslint-disable-next-line no-undef
isPublicCollection, isPublicCollection,
// eslint-disable-next-line no-undef // eslint-disable-next-line no-undef
userId,
// eslint-disable-next-line no-undef
vueType,
// eslint-disable-next-line no-undef
query, query,
}; };
}, },
@ -85,10 +81,6 @@ Vue.createApp({
if (this.style) { if (this.style) {
url += `&style=${this.formatParams(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 axios
.get(url) .get(url)
@ -175,11 +167,10 @@ Vue.createApp({
this.toggleModal(); this.toggleModal();
}, },
deleteItem() { deleteItem() {
// eslint-disable-next-line no-undef if ( vueType === 'private' ) {
if (vueType !== "private") {
return false; return false;
} }
return axios axios
.delete(`/api/v1/albums/${this.itemId}`) .delete(`/api/v1/albums/${this.itemId}`)
.then(() => { .then(() => {
this.fetch(); this.fetch();
@ -195,11 +186,10 @@ Vue.createApp({
}); });
}, },
shareCollection() { shareCollection() {
// eslint-disable-next-line no-undef if ( vueType === 'private' ) {
if (vueType !== "private") {
return false; return false;
} }
return axios axios
.patch(`/api/v1/me`, { .patch(`/api/v1/me`, {
isPublicCollection: !this.isPublicCollection, isPublicCollection: !this.isPublicCollection,
}) })
@ -229,16 +219,19 @@ Vue.createApp({
}); });
}, },
renderAlbumTitle(item) { renderAlbumTitle(item) {
let render = ""; let render = '';
for (let i = 0; i < item.artists.length; i += 1) { for ( let i = 0 ; i < item.artists.length ; i += 1 ) {
const { name, join } = item.artists[i]; const {
render += `${name} ${join ? `${join} ` : ""}`; name,
join,
} = item.artists[i];
render += `${name} ${join ? `${join} ` : ''}`;
} }
render += `- ${item.title}`; render += `- ${item.title}`;
return render; return render;
}, }
}, },
}).mount("#collection"); }).mount("#collection");

View file

@ -1,4 +1,3 @@
if (typeof email !== "undefined" && typeof username !== "undefined") { if (typeof email !== "undefined" && typeof username !== "undefined") {
Vue.createApp({ Vue.createApp({
data() { data() {

View file

@ -4,8 +4,6 @@ if (typeof item !== "undefined") {
return { return {
// eslint-disable-next-line no-undef // eslint-disable-next-line no-undef
item, item,
// eslint-disable-next-line no-undef
canShareItem,
tracklist: [], tracklist: [],
identifiers: [], identifiers: [],
modalIsVisible: false, modalIsVisible: false,
@ -14,11 +12,6 @@ if (typeof item !== "undefined") {
preview: null, preview: null,
index: null, index: null,
showModalDelete: false, showModalDelete: false,
showModalShare: false,
shareMessage: "",
shareMessageTransformed: "",
shareMessageLength: 0,
shareSubmiting: false,
}; };
}, },
created() { created() {
@ -30,26 +23,6 @@ if (typeof item !== "undefined") {
destroyed() { destroyed() {
window.removeEventListener("keydown", this.changeImage); window.removeEventListener("keydown", this.changeImage);
}, },
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("{year}", this.item.year)
.replaceAll("{video}", video)
.replaceAll("{album}", this.item.title);
this.shareMessageLength = this.shareMessageTransformed.replace(
video,
new Array(36).join("#")
).length;
},
},
methods: { methods: {
setIdentifiers() { setIdentifiers() {
this.identifiers = []; this.identifiers = [];
@ -216,33 +189,6 @@ if (typeof item !== "undefined") {
goToArtist() { goToArtist() {
return ""; 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"); }).mount("#ma-collection-details");
} }

View file

@ -1,106 +0,0 @@
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");

18175
package-lock.json generated

File diff suppressed because it is too large Load diff

View file

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

View file

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

View file

@ -37,9 +37,6 @@ $button-alternate-color: #01103C;
$pagination-border-color: $nord3; $pagination-border-color: $nord3;
$pagination-hover-color: rgb(115, 151, 186); $pagination-hover-color: rgb(115, 151, 186);
$close-background: rgba(10,10,10,.6);
$close-background-dark: rgba(240,240,240,.6);
:root { :root {
--default-color: #{$white}; --default-color: #{$white};
--bg-color: #{darken($white, 5%)}; --bg-color: #{darken($white, 5%)};
@ -61,8 +58,6 @@ $close-background-dark: rgba(240,240,240,.6);
--button-link-text-color: #2C364A; --button-link-text-color: #2C364A;
--close-background: #{$close-background};
--loader-img: url('/img/loading-light.gif'); --loader-img: url('/img/loading-light.gif');
--nord0: #{$nord0}; --nord0: #{$nord0};
@ -104,7 +99,5 @@ $close-background-dark: rgba(240,240,240,.6);
--button-link-text-color: #{$white}; --button-link-text-color: #{$white};
--close-background: #{$nord3};
--loader-img: url('/img/loading-dark.gif'); --loader-img: url('/img/loading-dark.gif');
} }

View file

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

View file

@ -31,12 +31,13 @@
max-width: 100%; max-width: 100%;
width: 100%; width: 100%;
background-color: var(--input-color); background-color: var(--input-color);
border: 1px solid var(--input-active-color) !important; border: 1px solid transparent !important;
color: var(--input-font-color); color: var(--input-font-color);
@include transition() {} @include transition() {}
&:focus-visible { &:focus-visible {
outline: unset; outline: unset;
border-color: var(--input-active-color) !important;
} }
} }

View file

@ -1,4 +1,28 @@
@import '../node_modules/knacss/sass/knacss.scss'; // @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";
// SPÉCIFIQUE AU SITE // SPÉCIFIQUE AU SITE
@import './fonts'; @import './fonts';

View file

@ -45,44 +45,33 @@
.modal { .modal {
button.close { button.close {
height: 42px; height: 36px;
max-height: 42px; max-height: 36px;
max-width: 42px; max-width: 36px;
min-height: 42px; min-height: 36px;
min-width: 42px; min-width: 36px;
width: 42px; width: 36px;
position: absolute; position: absolute;
background-color: var(--close-background); background-color: rgba(10,10,10,.6);
right: 12px; right: 12px;
top: 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 { .navigation {
position: absolute;
top: 50%;
cursor: pointer; cursor: pointer;
i { z-index: 10;
font-size: 1rem;
color: $nord4;
@include respond-to("small-up") { &.previous {
font-size: 2rem; left: 12px;
} }
&.next {
right: 12px;
}
i {
font-size: 2rem;
color: $nord4;
} }
} }
} }

View file

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

View file

@ -1,25 +1,21 @@
.navbar { .navbar {
min-height: 3.5rem; min-height: 3.25rem;
background-color: var(--navbar-color); background-color: var(--navbar-color);
box-shadow: rgba(216, 222, 233, 0.15) 0px 5px 10px 0px; box-shadow: rgba(216, 222, 233, 0.15) 0px 5px 10px 0px;
color: rgba(0,0,0,.7); color: rgba(0,0,0,.7);
position: fixed; position: fixed;
z-index: 1; z-index: 30;
top: 0; top: 0;
right: 0; right: 0;
left: 0; left: 0;
@include transition() {} @include transition() {}
@include respond-to("medium-up") { @include respond-to("medium-up") {
min-height: 3.25rem;
align-items: stretch; align-items: stretch;
display: flex; display: flex;
} }
&.container {
max-width: 1330px;
margin: 0 auto;
}
.navbar-brand { .navbar-brand {
align-items: stretch; align-items: stretch;
display: flex; display: flex;
@ -131,6 +127,7 @@
min-width: 100%; min-width: 100%;
position: absolute; position: absolute;
top: 100%; top: 100%;
z-index: 20;
} }
&:hover { &:hover {
@ -281,6 +278,7 @@
min-width: 100%; min-width: 100%;
position: absolute; position: absolute;
top: 100%; top: 100%;
z-index: 20;
.navbar-item { .navbar-item {
white-space: nowrap; white-space: nowrap;

View file

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

View file

@ -37,7 +37,7 @@ mongoose
const sess = { const sess = {
cookie: { cookie: {
maxAge: 604800000, // INFO: 7 jours maxAge: 86400000,
}, },
secret, secret,
saveUninitialized: false, saveUninitialized: false,

View file

@ -33,11 +33,6 @@ export const getAlbumDetails = async (id) => {
const res = await dis.getRelease(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; return res;
}; };

View file

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

View file

@ -25,21 +25,9 @@ class Albums extends Pages {
*/ */
static async postAddOne(req) { static async postAddOne(req) {
const { body, user } = 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 = { const data = {
...albumDetails, ...body,
discogsId: albumDetails.id, discogsId: body.id,
User: user._id, User: user._id,
}; };
data.released = data.released data.released = data.released
@ -55,9 +43,6 @@ class Albums extends Pages {
model: "Albums", model: "Albums",
id: album._id, id: album._id,
}; };
const job = new JobsModel(jobData);
job.save();
try { try {
const User = await UsersModel.findOne({ _id: user._id }); const User = await UsersModel.findOne({ _id: user._id });
@ -66,7 +51,7 @@ class Albums extends Pages {
const { publish, token, url, message } = mastodonConfig; const { publish, token, url, message } = mastodonConfig;
if (share && publish && url && token) { if (publish && url && token) {
const M = new Mastodon({ const M = new Mastodon({
access_token: token, access_token: token,
api_url: url, api_url: url,
@ -74,7 +59,7 @@ class Albums extends Pages {
const video = const video =
data.videos && data.videos.length > 0 data.videos && data.videos.length > 0
? data.videos[0].uri ? data.videso[0].uri
: ""; : "";
const status = `${( const status = `${(
@ -104,10 +89,6 @@ Publié automatiquement via #musictopus`;
const { data: buff } = await axios.get( const { data: buff } = await axios.get(
data.images[i].uri, 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", responseType: "arraybuffer",
} }
); );
@ -129,6 +110,10 @@ Publié automatiquement via #musictopus`;
await M.post("statuses", { status, media_ids }); await M.post("statuses", { status, media_ids });
} }
const job = new JobsModel(jobData);
job.save();
} catch (err) { } catch (err) {
throw new ErrorEvent( throw new ErrorEvent(
500, 500,
@ -179,8 +164,6 @@ Publié automatiquement via #musictopus`;
genre, genre,
style, style,
userId: collectionUserId, userId: collectionUserId,
discogsIds,
discogsId,
} = this.req.query; } = this.req.query;
let userId = this.req.user?._id; let userId = this.req.user?._id;
@ -230,13 +213,6 @@ Publié automatiquement via #musictopus`;
userId = userIsSharingCollection._id; userId = userIsSharingCollection._id;
} }
if (discogsIds) {
where.discogsId = { $in: discogsIds };
}
if (discogsId) {
where.discogsId = Number(discogsId);
}
const count = await AlbumsModel.count({ const count = await AlbumsModel.count({
User: userId, User: userId,
...where, ...where,
@ -285,27 +261,6 @@ Publié automatiquement via #musictopus`;
} }
} }
/**
* 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 * Méthode permettant de mettre à jour un album
* *
@ -330,9 +285,7 @@ Publié automatiquement via #musictopus`;
const values = await getAlbumDetails(album.discogsId); const values = await getAlbumDetails(album.discogsId);
await AlbumsModel.findOneAndUpdate(query, values, { new: true }); return AlbumsModel.findOneAndUpdate(query, values, { new: true });
return this.getOne();
} }
/** /**
@ -341,7 +294,7 @@ Publié automatiquement via #musictopus`;
*/ */
async deleteOne() { async deleteOne() {
const res = await AlbumsModel.findOneAndDelete({ const res = await AlbumsModel.findOneAndDelete({
User: this.req.user._id, user: this.req.user._id,
_id: this.req.params.itemId, _id: this.req.params.itemId,
}); });
@ -356,83 +309,6 @@ 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" * Méthode permettant de créer la page "ma-collection"
*/ */
@ -467,7 +343,19 @@ Publié automatiquement via #musictopus`;
* Méthode permettant d'afficher le détails d'un album * Méthode permettant d'afficher le détails d'un album
*/ */
async loadItem() { async loadItem() {
const item = await this.getOne(); 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,
};
this.setPageContent("item", item); this.setPageContent("item", item);
this.setPageTitle( this.setPageTitle(
@ -475,31 +363,6 @@ 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 de créer la page "collection/:userId" * Méthode permettant de créer la page "collection/:userId"
*/ */

View file

@ -37,18 +37,12 @@ class Me extends Pages {
} }
} }
if (value.mastodon !== undefined) { user.mastodon = value.mastodon;
user.mastodon = value.mastodon;
}
if (value.password) { if (value.password) {
user.salt = value.password; user.salt = value.password;
} }
if (value.isPublicCollection !== undefined) {
user.isPublicCollection = value.isPublicCollection;
}
user.save(); user.save();
await new Promise((resolve, reject) => { await new Promise((resolve, reject) => {

View file

@ -68,17 +68,4 @@ 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; export default router;

View file

@ -3,7 +3,6 @@ import { ensureLoggedIn } from "connect-ensure-login";
import { sendResponse } from "../../../libs/format"; import { sendResponse } from "../../../libs/format";
import { searchSong, getAlbumDetails } from "../../../helpers"; import { searchSong, getAlbumDetails } from "../../../helpers";
import Albums from "../../../middleware/Albums";
// eslint-disable-next-line new-cap // eslint-disable-next-line new-cap
const router = express.Router(); const router = express.Router();
@ -17,30 +16,6 @@ router.route("/").get(ensureLoggedIn("/connexion"), async (req, res, next) => {
req.query.country || null 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); sendResponse(req, res, data);
} catch (err) { } catch (err) {
next(err); next(err);

View file

@ -24,20 +24,6 @@ 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 router
.route("/exporter") .route("/exporter")
.get(ensureLoggedIn("/connexion"), async (req, res, next) => { .get(ensureLoggedIn("/connexion"), async (req, res, next) => {
@ -46,19 +32,6 @@ router
page.setPageTitle("Exporter ma collection"); 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); render(res, page);
} catch (err) { } catch (err) {
next(err); next(err);

View file

@ -1,133 +0,0 @@
<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<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" /> <link href="/css/main.css" rel="stylesheet" />
<script defer src="/js/libs.js"></script>
<script defer src="/js/main.js"></script>
<% if ( config.matomoUrl ) { %> <% if ( config.matomoUrl ) { %>
<!-- Matomo --> <!-- Matomo -->
<script> <script>
@ -35,94 +38,86 @@
<% } %> <% } %>
</head> </head>
<body> <body>
<nav class="navbar"> <nav class="navbar" aria-label="Navigation principale">
<nav class="navbar container" aria-label="Navigation principale"> <div class="navbar-brand">
<div class="navbar-brand"> <a class="navbar-item" href="/">
<a class="navbar-item" href="/"> <img src="/img/logo.png" alt="Logo MusicTopus">
<img src="/img/logo.png" alt="Logo MusicTopus"> <span>MusicTopus</span>
<span>MusicTopus</span> </a>
</a>
<a role="button" class="navbar-burger" aria-label="Afficher le menu" aria-expanded="false" data-target="navbar"> <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> <span aria-hidden="true"></span>
<span aria-hidden="true"></span> <span aria-hidden="true"></span>
</a> </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>
<% } %>
<div id="navbar" class="navbar-menu"> <div class="navbar-end">
<a class="navbar-item" href="/nous-contacter">
Nous contacter
</a>
<% if ( user ) { %> <% if ( user ) { %>
<div class="navbar-start"> <div class="navbar-item has-dropdown">
<div class="navbar-item"> <a class="navbar-link">
<div class="buttons"> <i class="icon-user"></i>
<a class="button is-primary" href="/ajouter-un-album"> <span>
<i class="icon-plus"></i> <%= user.username %>
<span> </span>
Ajouter un album </a>
</span>
</a> <div class="navbar-dropdown">
</div> <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>
</div> </div>
</div> </div>
<% } %> <% } %>
<div class="navbar-item apparence">
<div class="navbar-end"> <div class="theme-switch-wrapper">
<a class="navbar-item" href="/nous-contacter"> <label class="theme-switch" for="checkbox" aria-label="Passer du thème clair au thème sombre et inversement">
Nous contacter <input type="checkbox" id="checkbox" />
</a> <div class="slider round"></div>
<% if ( user ) { %> </label>
<div class="navbar-item has-dropdown"> </div>
<a class="navbar-link"> </div>
<i class="icon-user"></i> <div class="navbar-item">
<span> <div class="buttons">
<%= user.username %> <% if ( !user ) { %>
</span> <a class="button is-primary" href="/connexion">
<strong>Connexion</strong>
</a> </a>
<% } else { %>
<div class="navbar-dropdown"> <a class="button is-danger" href="/se-deconnecter">
<a class="navbar-item" href="/mon-compte"> Déconnexion
Mon compte </a>
</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/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> </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>
<% 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> </div>
</nav> </div>
</nav> </nav>
<div id="toastr"> <div id="toastr">
@ -179,7 +174,7 @@
<footer class="footer layout-hero"> <footer class="footer layout-hero">
<p> <p>
<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>. <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>.
Logo réalisé par Brunus avec <a href="https://inkscape.org/fr/" target="_blank" rel="noopener noreferrer">Inkscape <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 /> <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>. 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>.
@ -187,8 +182,5 @@
Fait avec ❤️ à Bordeaux. Fait avec ❤️ à Bordeaux.
</p> </p>
</footer> </footer>
<script defer src="/js/libs.js"></script>
<script defer src="/js/main.js"></script>
</body> </body>
</html> </html>

View file

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

View file

@ -105,11 +105,12 @@
</div> </div>
<div class="field"> <div class="field">
<label for="mastodon.message">Message</label> <label for="mastodon.message">Message</label>
<textarea <input
type="text"
name="mastodon.message" name="mastodon.message"
id="mastodon.message" id="mastodon.message"
v-model="formData.mastodon.message" v-model="formData.mastodon.message"
></textarea> />
<small> <small>
Variables possibles : Variables possibles :
<ul> <ul>
@ -139,5 +140,5 @@
<script> <script>
const email = '<%= user.email %>'; const email = '<%= user.email %>';
const username = '<%= user.username %>'; const username = '<%= user.username %>';
const mastodon = <%- JSON.stringify(user.mastodon || {publish: false, url: '', token: '', message: ''}) %>; const mastodon = <%- JSON.stringify(user.mastodon) %>;
</script> </script>

View file

@ -8,7 +8,6 @@
- {{item.title}} - {{item.title}}
<i class="icon-trash" title="Supprimer cette fiche" @click="showConfirmDelete()"></i> <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-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> </h1>
<div class="grid sm:grid-cols-3 gap-16"> <div class="grid sm:grid-cols-3 gap-16">
<div class="text-center"> <div class="text-center">
@ -21,22 +20,152 @@
</div> </div>
</div> </div>
<hr /> <hr />
<%- include('../../../components/album.ejs') %> <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>
<div class="modal" :class="{'is-visible': modalIsVisible}"> <div class="modal" :class="{'is-visible': modalIsVisible}">
<div class="modal-background"></div> <div class="modal-background"></div>
<button type="button" aria-label="Fermer" class="close" @click="toggleModal"></button> <button type="button" aria-label="Fermer" class="close" @click="toggleModal"></button>
<div class="carousel"> <button type="button" aria-label="Image précédente" class="navigation previous" @click="previous" v-if="index > 0">
<button type="button" aria-label="Image précédente" class="navigation previous" @click="previous"> <i class="icon-left-open"></i>
<i class="icon-left-open"></i> </button>
</button> <button type="button" aria-label="Image suivante" class="navigation next" @click="next" v-if="index + 1 < item.images.length">
<div class="text-center"> <i class="icon-right-open"></i>
<img :src="preview" /> </button>
</div> <div class="modal-card">
<button type="button" aria-label="Image suivante" class="navigation next" @click="next"> <img :src="preview" />
<i class="icon-right-open"></i>
</button>
</div> </div>
</div> </div>
@ -53,46 +182,8 @@
</footer> </footer>
</div> </div>
</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>
</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> </main>
<script> <script>
const item = <%- JSON.stringify(page.item) %>; const item = <%- JSON.stringify(page.item) %>;
const canShareItem = <%= user.mastodon?.publish || false %>;
</script> </script>

View file

@ -1,43 +0,0 @@
<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>