mirror of
https://github.com/Poniverse/Pony.fm.git
synced 2024-11-22 04:58:01 +01:00
#27: Improved title tags; added a "meta" service for managing them and meta descriptions.
This commit is contained in:
parent
804d1fd3d4
commit
5d70fc9fd1
9 changed files with 57 additions and 17 deletions
|
@ -70,10 +70,10 @@ if window.pfm.environment == 'production'
|
|||
]
|
||||
|
||||
ponyfm.run [
|
||||
'$rootScope',
|
||||
($rootScope) ->
|
||||
'$rootScope', 'meta',
|
||||
($rootScope, meta) ->
|
||||
$rootScope.$on '$stateChangeStart', (event, toState, toParams, fromState, fromParams) ->
|
||||
$rootScope.description = ''
|
||||
meta.reset()
|
||||
]
|
||||
|
||||
ponyfm.config [
|
||||
|
|
|
@ -21,14 +21,15 @@ window.pfm.preloaders['album'] = [
|
|||
]
|
||||
|
||||
module.exports = angular.module('ponyfm').controller "album", [
|
||||
'$scope', '$rootScope', 'albums', '$state', 'playlists', 'auth', '$dialog', 'download-cached', '$window', '$timeout'
|
||||
($scope, $rootScope, albums, $state, playlists, auth, $dialog, cachedAlbum, $window, $timeout) ->
|
||||
'$scope', 'meta', 'albums', '$state', 'playlists', 'auth', '$dialog', 'download-cached', '$window', '$timeout'
|
||||
($scope, meta, albums, $state, playlists, auth, $dialog, cachedAlbum, $window, $timeout) ->
|
||||
album = null
|
||||
|
||||
albums.fetch($state.params.id).done (albumResponse) ->
|
||||
$scope.album = albumResponse.album
|
||||
album = albumResponse.album
|
||||
$rootScope.description = "Listen to #{album.title}, the album by #{album.user.name}, and more on the largest pony music site."
|
||||
meta.setTitle("#{album.title} | #{album.user.name}")
|
||||
meta.setDescription("Listen to #{album.title}, the album by #{album.user.name}, and more on the largest pony music site.")
|
||||
|
||||
$scope.playlists = []
|
||||
|
||||
|
|
|
@ -22,6 +22,7 @@ window.pfm.preloaders['dashboard'] = [
|
|||
module.exports = angular.module('ponyfm').controller "dashboard", [
|
||||
'$scope', 'dashboard', 'auth', '$http'
|
||||
($scope, dashboard, auth, $http) ->
|
||||
|
||||
$scope.recentTracks = null
|
||||
$scope.popularTracks = null
|
||||
|
||||
|
|
|
@ -20,8 +20,10 @@ window.pfm.preloaders['home'] = [
|
|||
]
|
||||
|
||||
module.exports = angular.module('ponyfm').controller "home", [
|
||||
'$scope', 'dashboard'
|
||||
($scope, dashboard) ->
|
||||
'$scope', 'meta', 'dashboard'
|
||||
($scope, meta, dashboard) ->
|
||||
meta.reset()
|
||||
|
||||
$scope.recentTracks = null
|
||||
$scope.popularTracks = null
|
||||
|
||||
|
|
|
@ -21,14 +21,15 @@ window.pfm.preloaders['playlist'] = [
|
|||
]
|
||||
|
||||
module.exports = angular.module('ponyfm').controller 'playlist', [
|
||||
'$scope', '$rootScope', '$state', 'playlists', '$dialog', 'download-cached', '$window', '$timeout'
|
||||
($scope, $rootScope, $state, playlists, $dialog, cachedPlaylist, $window, $timeout) ->
|
||||
'$scope', 'meta', '$state', 'playlists', '$dialog', 'download-cached', '$window', '$timeout'
|
||||
($scope, meta, $state, playlists, $dialog, cachedPlaylist, $window, $timeout) ->
|
||||
playlist = null
|
||||
|
||||
playlists.fetch($state.params.id).done (playlistResponse) ->
|
||||
$scope.playlist = playlistResponse
|
||||
playlist = playlistResponse
|
||||
$rootScope.description = "Listen to #{playlist.title} by #{playlist.user.name} on the largest pony music site"
|
||||
meta.setTitle("#{playlist.title} | #{playlist.user.name}")
|
||||
meta.setDescription("Listen to \"#{playlist.title}\", a playlist by #{playlist.user.name}, on the largest pony music site.")
|
||||
|
||||
$scope.share = () ->
|
||||
dialog = $dialog.dialog
|
||||
|
|
|
@ -15,15 +15,16 @@
|
|||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
module.exports = angular.module('ponyfm').controller "track", [
|
||||
'$scope', '$rootScope', 'tracks', '$state', 'playlists', 'auth', 'favourites', '$dialog', 'download-cached', '$window', '$timeout'
|
||||
($scope, $rootScope, tracks, $state, playlists, auth, favourites, $dialog, cachedTrack, $window, $timeout) ->
|
||||
'$scope', 'meta', 'tracks', '$state', 'playlists', 'auth', 'favourites', '$dialog', 'download-cached', '$window', '$timeout'
|
||||
($scope, meta, tracks, $state, playlists, auth, favourites, $dialog, cachedTrack, $window, $timeout) ->
|
||||
$scope.track
|
||||
$scope.trackId = parseInt($state.params.id)
|
||||
|
||||
updateTrackData = (forceUpdate = false) ->
|
||||
tracks.fetch($scope.trackId, forceUpdate).done (trackResponse) ->
|
||||
$scope.track = trackResponse.track
|
||||
$rootScope.description = "Listen to #{$scope.track.title} by #{$scope.track.user.name} on the largest pony music site"
|
||||
meta.setTitle("#{$scope.track.title} | #{$scope.track.user.name}")
|
||||
meta.setDescription("Listen to \"#{$scope.track.title}\" by #{$scope.track.user.name} on the largest pony music site.")
|
||||
|
||||
updateTrackData()
|
||||
|
||||
|
|
|
@ -21,8 +21,10 @@ window.pfm.preloaders['tracks'] = [
|
|||
]
|
||||
|
||||
module.exports = angular.module('ponyfm').controller "tracks", [
|
||||
'$scope', 'tracks', '$state', 'focus'
|
||||
($scope, tracks, $state, focus) ->
|
||||
'$scope', 'tracks', '$state', 'focus', 'meta'
|
||||
($scope, tracks, $state, focus, meta) ->
|
||||
meta.setTitle('Browse Tracks')
|
||||
|
||||
$scope.recentTracks = null
|
||||
$scope.query = tracks.mainQuery
|
||||
$scope.filters = tracks.filters
|
||||
|
|
32
resources/assets/scripts/app/services/meta.coffee
Normal file
32
resources/assets/scripts/app/services/meta.coffee
Normal file
|
@ -0,0 +1,32 @@
|
|||
# Pony.fm - A community for pony fan music.
|
||||
# Copyright (C) 2016 Peter Deltchev
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU Affero General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU Affero General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU Affero General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
module.exports = angular.module('ponyfm').factory('meta', [
|
||||
'$rootScope'
|
||||
($rootScope) ->
|
||||
self =
|
||||
reset: () ->
|
||||
this.setTitle('Pony.fm - Unlimited Pony Music Hosting', false)
|
||||
this.setDescription('Pony.fm is the world\'s largest collection of My Little Pony fan music. Enjoy unlimited uploads, streaming, and downloads!')
|
||||
|
||||
setTitle: (title, withSuffix=true) ->
|
||||
$rootScope.title = title
|
||||
if withSuffix
|
||||
$rootScope.title += ' - Pony.fm'
|
||||
|
||||
setDescription: (description) ->
|
||||
$rootScope.description = description
|
||||
])
|
|
@ -19,7 +19,7 @@
|
|||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
|
||||
<title>Pony.fm</title>
|
||||
<title ng-bind="title">Pony.fm</title>
|
||||
<meta name="description" content="@{{ description }}" />
|
||||
<meta name="viewport" content="width=device-width" />
|
||||
<base href="/" />
|
||||
|
|
Loading…
Reference in a new issue