jaedb / Iris

Discover, explore and manage your music library across multiple sources with this beautiful web-based interface. Iris is a Mopidy frontend extension.
Apache License 2.0
1.14k stars 133 forks source link

Improve artist biography and album wiki rendering #621

Closed orontee closed 3 years ago

orontee commented 4 years ago

Is your feature request related to a problem? Please describe. When reading an artist biography or album wiki, I dislike the rendering because URL are unparsed and unclickable.

Not directly related, I also noticed that the publish date of album wiki is not displayed.

Describe the solution you'd like I'd like to have the HTML underlying the biography to be cleaned up and then safely rendered.

I suggest to set the innerHTML without escaping but after a clean up based on a third-party library like sanitize-html.

orontee commented 4 years ago

What do you think of biographies and wikis following the language choice of the user?

It shouldn't be difficult to implement since Last.fm API support a lang parameter in album.getInfo() and artist.getInfo()...

jaedb commented 4 years ago

Nice work on the date fix.

I think applying user-selected language to biographies a great idea. What is the fallback policy like for LastFM, if we provide a missing language?

sanitize-html also looks great. Before we introduce another plugin (the Iris bundle is already quite large) I would be keen to understand from your perspective why we need it. In what use case does the current solution not work well?

orontee commented 4 years ago

I think applying user-selected language to biographies a great idea. What is the fallback policy like for LastFM, if we provide a missing language?

Good point. I'll have to check that.

In what use case does the current solution not work well?

Well, it's more of a matter of taste. See the attached screen capture with current rendering (right side) and rendering with parsed URLs (left side). But clearly we can achieve this without the library but an adequate regexp. So if URLs rendering is something important to you, I can implement it with a regexp. It'll be safe if we worry not to accept other HTML elements, or other properties than href.

Capture d’écran du 2020-10-11 15-33-11

orontee commented 4 years ago

I think applying user-selected language to biographies a great idea. What is the fallback policy like for LastFM, if we provide a missing language?

It'll be empty. Example request english then japaneese infos for "Abdullah Ibrahim":

$ curl 'https://ws.audioscrobbler.com/2.0/?format=json&method=artist.getInfo&mbid=fd64e185-9973-44d5-ad09-5d5562804292&api_key=...&lang=en'  --compressed | jq '.artist.bio.content'
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100  8793  100  8793    0     0  11060      0 --:--:-- --:--:-- --:--:-- 11046
"Abdullah Ibrahim (born 1934, Cape Town, South Africa), formerly known as Adolph Johannes Brand, and as Dollar Brand (from a popular brand of cigarettes), is a South African pianist and composer. His music reflects many of the musical influences of his childhood in the multicultural port areas of Cape Town, ranging from traditional African songs to the gospel of the AME Church and ragas, to more modern jazz and other Western styles. He first received piano lessons at the age of seven, was an avid consumer of jazz records brought by American sailors, and was playing jazz professionally by 1949. In 1959 and 1960, he played alongside Kippie Moeketsi with The Jazz Epistles in Sophiatown before joining the European tour of the musical King Kong.\n\nIn 1962 during a tour of Europe, Duke Ellington heard “The Dollar Brand Trio” playing in Zürich's “Africana Club”. As a result, a recording was set up with Reprise Records; “Duke Ellington presents The Dollar Brand Trio”. The Dollar Brand Trio (with Johnny Gertze on bass and Makaya Ntshoko on drums) subsequently played at many European festivals, as well as on radio and television. \n\nHe briefly returned to South Africa in the mid-1970s after his conversion to Islam (and the resultant change of name from Dollar Brand to Abdullah Ibrahim); however, he soon returned to New York in 1976, as he found the political conditions too oppressive. While in South Africa, however, he made a series of recordings with noted Cape Town jazz players (including Basil Coetzee and Robbie Jansen). This included Coetzee's masterpiece, \"Mannenberg\", acknowledged by most as one of South Africa's greatest musical compositions; the recording soon became an unofficial soundtrack to the anti-apartheid resistance.\n\nAbdullah Ibrahim has written the soundtracks for a number of films, including the award winning Chocolat and, more recently, No Fear, No Die. Since the end of apartheid, he now lives in South Africa and divides his time between his global concert circuit, New York, and South Africa.\n\nAbdullah Ibrahim is a towering figure in South African music, an artist who brings together all its traditions with a deeply felt understanding of American jazz, from the orchestral richness of Duke Ellington's compositions for big band to the groundbreaking innovations of Ornette Coleman and the 1960s avant-garde.\n\nIbrahim has worked as a solo performer, typically in mesmerising unbroken concerts that echo the unstoppable impetus of the old marabi performers. He also performs regularly with trios and quartets and larger orchestral units. Since his triumphant return to South Africa in the early 1990s, he has been feted with symphony orchestra performances, one of which was in honour of Nelson Mandela's installation as President. He has also founded a school for South African musicians in Cape Town.\n\nWith his wife, the jazz singer Sathima Bea Benjamin, he is father to the New York underground rapper Jean Grae, as well as to a son, Tsakwe. <a href=\"https://www.last.fm/music/Abdullah+Ibrahim\">Read more on Last.fm</a>. User-contributed text is available under the Creative Commons By-SA License; additional terms may apply."
matthias@carbon:~/Sources/Iris (fix_biography_rendering ✕$ =)
↳ curl 'https://ws.audioscrobbler.com/2.0/?format=json&method=artist.getInfo&mbid=fd64e185-9973-44d5-ad09-5d5562804292&api_key=...&lang=jp' --compressed | jq '.artist.bio.content'
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100  5106  100  5106    0     0   4830      0  0:00:01  0:00:01 --:--:--  4830
""