Albums: Use album slug in URL #15

Signed-off-by: Michael Mayer <michael@liquidbytes.net>
This commit is contained in:
Michael Mayer 2019-12-03 23:55:24 +01:00
parent 1213ee5f2a
commit 6f3593ec9a
5 changed files with 9 additions and 4 deletions

View file

@ -90,7 +90,7 @@
</v-list-tile>
<v-list-tile v-for="(album, index) in config.albums"
:key="index" :to="{ name: 'albums_view', params: { id: album.ID } }">
:key="index" :to="{ name: 'albums_view', params: { id: album.ID, slug: album.AlbumSlug } }">
<v-list-tile-content>
<v-list-tile-title v-if="album.AlbumName">{{ album.AlbumName }}</v-list-tile-title>
<v-list-tile-title v-else>Untitled</v-list-tile-title>

View file

@ -156,7 +156,7 @@
},
openAlbum(index) {
const album = this.results[index];
this.$router.push({name: "albums_view", params: {id: album.ID}});
this.$router.push({name: "albums_view", params: {id: album.ID, slug: album.AlbumSlug}});
},
loadMore() {
if (this.scrollDisabled) return;

View file

@ -37,7 +37,7 @@ export default [
},
{
name: "albums_view",
path: "/albums/:id",
path: "/albums/:id/:slug",
component: AlbumsView,
meta: {area: "View Album"},
},

View file

@ -98,7 +98,7 @@ func UpdateAlbum(router *gin.RouterGroup, conf *config.Config) {
return
}
m.AlbumName = params.AlbumName
m.Rename(params.AlbumName)
conf.Db().Save(&m)
event.Publish("config.updated", event.Data(conf.ClientConfig()))

View file

@ -45,3 +45,8 @@ func NewAlbum(albumName string) *Album {
return result
}
func (m *Album) Rename(albumName string) {
m.AlbumName = strings.TrimSpace(albumName)
m.AlbumSlug = slug.Make(m.AlbumName)
}