Skip to content

Commit

Permalink
added album hashtags
Browse files Browse the repository at this point in the history
  • Loading branch information
RocketMan committed Oct 17, 2023
1 parent 30ee166 commit 9b6f135
Show file tree
Hide file tree
Showing 4 changed files with 53 additions and 1 deletion.
34 changes: 34 additions & 0 deletions css/zoostyle.css
Original file line number Diff line number Diff line change
Expand Up @@ -1486,6 +1486,7 @@ a:hover.copy {
}
.album-info.with-thumb {
max-width: calc(100% - 140px);
padding-bottom: 0;
}

.album-thumb {
Expand All @@ -1501,6 +1502,39 @@ a:hover.copy {
object-position: center 10%;
}

.album-hashtag-area {
padding-top: 15px;
max-width: 400px;
}

.with-thumb .album-hashtag-area {
height: 60px;
vertical-align: bottom;
}

.album-hashtag {
border-radius: 6px;
border: 1px solid #333;
padding: 2px 8px;
margin-right: 2px;
line-height: 2;
}
.album-hashtag.palette-0 {
background-color: #bdd0c4;
}
.album-hashtag.palette-1 {
background-color: #bad7f3;
}
.album-hashtag.palette-2 {
background-color: #ffd6a5;
}
.album-hashtag.palette-3 {
background-color: #f7e1d3;
}
.album-hashtag.palette-4 {
background-color: #dfccf1;
}

div.toggle-time-entry {
position: relative;
float: right;
Expand Down
2 changes: 1 addition & 1 deletion engine/impl/Library.php
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ class LibraryImpl extends DBO implements ILibrary {
"FROM reviews r " .
"LEFT JOIN albumvol av ON r.tag = av.tag " .
"LEFT JOIN airnames an ON r.airname = an.id " .
"WHERE private = 0 AND r.airname IS NOT NULL AND " .
"WHERE private = 0 AND " .
"MATCH (review) AGAINST(? IN BOOLEAN MODE) " .
"ORDER BY r.created DESC" ],
[ "tracks", "albumrec", "tracknames", "track",
Expand Down
11 changes: 11 additions & 0 deletions ui/Search.php
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,17 @@ public function searchByAlbumKey($key = null) {
$reviews = Engine::api(IReview::class)->getReviews($tag, 1, "", $loggedIn);
$this->addVar("reviews", $reviews);

// hashtags
$hashtags = array_reduce($reviews, function($carry, $review) {
return preg_match_all('/#[\pL_]+/', $review['review'], $matches) ?
array_merge($carry, $matches[0]) : $carry;
}, []);
$hashtags = array_unique(array_map('strtolower', $hashtags));
$index = array_map(function($tag) {
return hexdec(hash('crc32', $tag)) % 5;
}, $hashtags);
$this->addVar("hashtags", array_combine($hashtags, $index));

// tracks
$tracks = $libraryApi->search($albums[0]['iscoll'] ? ILibrary::COLL_KEY : ILibrary::TRACK_KEY, 0, 200, $tag);

Expand Down
7 changes: 7 additions & 0 deletions ui/templates/default/album/info.html
Original file line number Diff line number Diff line change
Expand Up @@ -67,5 +67,12 @@
<a href="?action=searchReviewEdit&amp;tag={{ album.tag }}" class="nav"><b>Write a review of this album</b></a>
{% endif ~%}
</td></tr>
{% if hashtags | length %}
<tr><td colspan='5' class='album-hashtag-area'>
{% for tag, index in hashtags %}
<span class='album-hashtag palette-{{ index }}'>{{ tag }}</span>
{% endfor %}
</td></tr>
{% endif %}
</table>
<br>

0 comments on commit 9b6f135

Please sign in to comment.