Merge pull request #63 from Poniverse/feature/webpack

Feature/webpack
This commit is contained in:
Peter Deltchev 2016-02-16 04:16:31 -08:00
commit 0057533917
94 changed files with 274 additions and 30655 deletions

View file

@ -63,21 +63,13 @@ And then install all of the required local packages by invoking:
npm install
Finally, build all of the scripts by executing:
gulp build
During development, you should make a point to run "gulp watch". You can do this simply by executing:
Finally, to compile and serve the assets in real time, run the following (and leave it running while you develop):
gulp watch
This will watch and compile the `.less` and `.coffee` files in real time.
Configuring the servers
-----------------------
Pony.fm uses nginx, php-fpm, redis, and MySQL. You can modify the configuration of these services by locating the appropriate config file in the `vagrant` folder. Once modified, you must reload the configuration by running the appropriate shell script (`reload-config.sh`) or bat files (`reload-config.bat` and `reload-config.vmware.bat`). These scripts simply tell Vagrant to run `copy-and-restart-config.sh` on the VM.
If you need to change any other configuration file on the VM - copy the entire file over into the vagrant folder, make your changes, and update the `copy-and-restart-config.sh` script to copy the modified config back into the proper folder. All potential configuration requirements should be represented in the `vagrant` folder **and never only on the VM itself** as changes will not be preserved.
**NOTE:** currently, Redis's configuration is not reloaded by the `copy-and-restart-config.sh`

View file

@ -20,21 +20,26 @@
class Assets
{
public static function scriptIncludes($area = 'app')
{
if (!Config::get("app.debug")) {
return '<script src="/build/scripts/' . $area . '.js?' . filemtime(public_path("/build/scripts/${area}.js")) . '"></script>';
public static function scriptIncludes(string $area) {
$scriptTags = '';
if ('app' === $area) {
$scripts = ['app.js', 'templates.js'];
} elseif ('embed' === $area) {
$scripts = ['embed.js'];
} else {
throw new InvalidArgumentException('A valid app area must be specified!');
}
$scripts = self::mergeGlobs(self::getScriptsForArea($area));
$retVal = "";
foreach ($scripts as $script) {
$filename = self::replaceExtensionWith($script, ".coffee", ".js");
$retVal .= "<script src='/build/$filename?" . filemtime(public_path("/build/${filename}")) . "'></script>";
foreach ($scripts as $filename) {
$scriptTags .= "<script src='/build/scripts/{$filename}?" . filemtime(public_path("build/scripts/{$filename}")) . "'></script>";
}
return $retVal;
if (Config::get("app.debug")) {
$scriptTags .= '<script src="http://localhost:61999/webpack-dev-server.js"></script>';
}
return $scriptTags;
}
public static function styleIncludes($area = 'app')
@ -84,41 +89,6 @@ class Assets
return $files;
}
private static function getScriptsForArea($area)
{
if ($area == 'app') {
return [
"scripts/base/jquery-2.0.2.js",
"scripts/base/angular.js",
"scripts/base/marked.js",
"scripts/base/*.{coffee,js}",
"scripts/shared/*.{coffee,js}",
"scripts/app/*.{coffee,js}",
"scripts/app/services/*.{coffee,js}",
"scripts/app/filters/*.{coffee,js}",
"scripts/app/directives/*.{coffee,js}",
"scripts/app/controllers/*.{coffee,js}",
"scripts/**/*.{coffee,js}"
];
} else {
if ($area == 'embed') {
return [
"scripts/base/jquery-2.0.2.js",
"scripts/base/jquery.cookie.js",
"scripts/base/jquery.viewport.js",
"scripts/base/underscore.js",
"scripts/base/moment.js",
"scripts/base/jquery.timeago.js",
"scripts/base/soundmanager2-nodebug.js",
"scripts/shared/jquery-extensions.js",
"scripts/embed/*.coffee"
];
}
}
throw new Exception();
}
private static function getStylesForArea($area)
{
if ($area == 'app') {

View file

@ -17,9 +17,16 @@
*/
var gulp = require("gulp"),
gutil = require("gulp-util"),
plug = require("gulp-load-plugins")(),
argv = require("yargs").argv,
header = require("gulp-header");
header = require("gulp-header"),
webpack = require("webpack"),
WebpackDevServer = require("webpack-dev-server"),
webpackDevConfig = require("./webpack.dev.config.js"),
webpackProductionConfig = require("./webpack.production.config.js"),
webpackStream = require('webpack-stream'),
_ = require("underscore");
var plumberOptions = {
errorHandler: plug.notify.onError("Error: <%= error.message %>")
@ -47,81 +54,31 @@ var licenseHeader = [
""
].join('\n');
gulp.task("scripts-app", function () {
var paths = [
"resources/assets/scripts/app/**/*.{coffee,js}",
"resources/assets/scripts/base/**/*.{coffee,js}",
"resources/assets/scripts/shared/**/*.{coffee,js}"
];
if (!argv.production) {
// we also want to add the embed stuff, since we're in development mode
// we want to watch embed files and re-compile them. However, we want
// to leave this path out in production so that embed files are not bloating
// the js file
paths.push("resources/assets/scripts/embed/**/*.{coffee,js}");
}
return argv.production
// Production pipeline
? gulp.src(paths, {base: "resources/assets/scripts"})
.pipe(plug.plumber(plumberOptions))
.pipe(plug.order([
"resources/assets/scripts/base/jquery-2.0.2.js",
"resources/assets/scripts/base/angular.js",
"resources/assets/scripts/base/*.{coffee,js}",
"resources/assets/scripts/shared/*.{coffee,js}",
"resources/assets/scripts/app/*.{coffee,js}",
"resources/assets/scripts/app/services/*.{coffee,js}",
"resources/assets/scripts/app/filters/*.{coffee,js}",
"resources/assets/scripts/app/directives/*.{coffee,js}",
"resources/assets/scripts/app/controllers/*.{coffee,js}",
"resources/assets/scripts/**/*.{coffee,js}"
], {base: "."}))
.pipe(plug.if(/\.coffee/, plug.coffee()))
.pipe(plug.concat("app.js"))
.pipe(plug.uglify())
gulp.task("webpack-build", function() {
return gulp.src(_.values(webpackProductionConfig.entry))
.pipe(webpackStream(webpackProductionConfig))
.pipe(header(licenseHeader))
.pipe(gulp.dest("public/build/scripts"))
// Development/watch pipeline
: gulp.src(paths, {base: "resources/assets/scripts"})
.pipe(plug.plumber(plumberOptions))
.pipe(plug.cached('scripts'))
.pipe(plug.sourcemaps.init())
.pipe(plug.if(/\.coffee/, plug.coffee()))
.pipe(header(licenseHeader))
.pipe(plug.sourcemaps.write())
.pipe(gulp.dest("public/build/scripts"));
.pipe(gulp.dest('public'));
});
gulp.task("scripts-embed", function () {
// note that this task should really only ever be invoked for production
// since development-mode watches and builds include the embed scripts
// already
var includedScripts = [
"resources/assets/scripts/base/jquery-2.0.2.js",
"resources/assets/scripts/base/jquery.cookie.js",
"resources/assets/scripts/base/jquery.viewport.js",
"resources/assets/scripts/base/underscore.js",
"resources/assets/scripts/base/moment.js",
"resources/assets/scripts/base/jquery.timeago.js",
"resources/assets/scripts/base/soundmanager2-nodebug.js",
"resources/assets/scripts/shared/jquery-extensions.js",
"resources/assets/scripts/embed/*.coffee"
];
gulp.task("webpack-dev-server", function () {
// Starts a webpack-dev-server
var compiler = webpack(webpackDevConfig);
return gulp.src(includedScripts, {base: "resources/assets/scripts"})
.pipe(plug.plumber(plumberOptions))
.pipe(plug.if(/\.coffee/, plug.coffee()))
.pipe(plug.order(includedScripts, {base: "."}))
.pipe(plug.concat("embed.js"))
.pipe(plug.uglify())
.pipe(header(licenseHeader))
.pipe(gulp.dest("public/build/scripts"));
new WebpackDevServer(compiler, {
// server and middleware options, currently blank
}).listen(61999, "localhost", function (err) {
if (err)
throw new gutil.PluginError("webpack-dev-server", err);
// Server listening
gutil.log("[webpack-dev-server]", "http://localhost:61999/webpack-dev-server/index.html");
});
});
gulp.task("styles-app", function () {
var includedStyles = [
"resources/assets/styles/base/jquery-ui.css",
@ -208,18 +165,19 @@ gulp.task('copy:templates', function () {
});
gulp.task('build', [
'scripts-app',
'webpack-build',
'copy:templates',
'styles-app',
'scripts-embed',
'styles-embed'
]);
gulp.task("watch", ["build"], function () {
plug.livereload.listen();
gulp.watch("resources/assets/scripts/**/*.{coffee,js}", ["scripts-app"]);
gulp.task("watch-legacy", ["build"], function () {
gulp.watch("resources/assets/styles/**/*.{css,less}", ["styles-app"]);
});
gulp.task("watch", ["webpack-dev-server", "watch-legacy"], function () {});
function endsWith(str, suffix) {
return str.indexOf(suffix, str.length - suffix.length) !== -1;
}

View file

@ -1,22 +1,23 @@
{
"name": "pony.fm",
"version": "1.0.0",
"license": "AGPL",
"license": "AGPL-3.0",
"repository": {
"type": "git",
"url": "ssh://git@phabricator.poniverse.net/diffusion/PF/pony-fm.git"
},
"packages": {},
"dependencies": {
"gulp-header": "^1.7.1"
},
"dependencies": {},
"devDependencies": {
"angular": "^1.5.0",
"coffee-loader": "^0.7.2",
"gulp": "^3.9.0",
"gulp-angular-templatecache": "^1.6.0",
"gulp-autoprefixer": "^2.2.0",
"gulp-cached": "^1.0.4",
"gulp-coffee": "^2.3.1",
"gulp-concat": "^2.5.2",
"gulp-header": "^1.7.1",
"gulp-if": "^1.2.5",
"gulp-less": "^3.0.3",
"gulp-livereload": "^3.8.0",
@ -27,7 +28,15 @@
"gulp-plumber": "^1.0.0",
"gulp-sourcemaps": "^1.5.1",
"gulp-uglify": "^1.2.0",
"gulp-util": "^3.0.4",
"gulp-util": "^3.0.7",
"gulp-webpack": "^1.5.0",
"jquery": "^2.2.0",
"jquery-ui": "^1.10.5",
"script-loader": "^0.6.1",
"underscore": "^1.8.3",
"webpack": "^1.12.13",
"webpack-dev-server": "^1.14.1",
"webpack-stream": "^3.1.0",
"yargs": "^3.7.2"
}
}

View file

@ -14,25 +14,69 @@
# 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/>.
# Some notes on what's going on here:
#
# - Webpack resolves all of these require statements.
#
# - jQuery is loaded before Angular so it replaces jqLite.
#
# - "script!" is used with dependencies that expect to interact with the global state.
#
# - The "ponyfm" module in this file must be initialized before the controllers
# and other Angular modules are brought in; they expect the "ponyfm" module to exist.
require 'script!../base/jquery-2.0.2'
require 'script!../base/jquery-ui'
angular = require 'angular'
require 'script!../base/angular-ui-date'
require '../base/angular-ui-router'
require '../base/angular-ui-sortable'
require '../base/angularytics'
require '../base/jquery.colorbox'
require '../base/jquery.cookie'
require '../base/jquery.timeago'
require '../base/jquery.viewport'
require 'script!../base/marked'
require 'script!../base/moment'
require '../base/soundmanager2-nodebug'
require 'script!../base/tumblr'
require '../base/ui-bootstrap-tpls-0.4.0'
require '../shared/pfm-angular-marked'
require '../shared/pfm-angular-sanitize'
require '../shared/init.coffee'
ponyfm = angular.module 'ponyfm', ['ui.bootstrap', 'ui.state', 'ui.date', 'ui.sortable', 'angularytics', 'ngSanitize', 'hc.marked']
window.pfm.preloaders = {}
module = angular.module 'ponyfm', ['ui.bootstrap', 'ui.state', 'ui.date', 'ui.sortable', 'angularytics', 'ngSanitize', 'hc.marked']
# Inspired by: https://stackoverflow.com/a/30652110/3225811
requireDirectory = (r) ->
r.keys().forEach(r)
requireDirectory(require.context('./controllers/', false, /\.coffee$/));
requireDirectory(require.context('./directives/', false, /\.coffee$/));
requireDirectory(require.context('./filters/', false, /\.coffee$/));
requireDirectory(require.context('./services/', false, /\.coffee$/));
if window.pfm.environment == 'production'
module.run [
ponyfm.run [
'Angularytics',
(analytics) ->
analytics.init()
]
module.run [
ponyfm.run [
'$rootScope',
($rootScope) ->
$rootScope.$on '$stateChangeStart', (event, toState, toParams, fromState, fromParams) ->
$rootScope.description = ''
]
module.config [
ponyfm.config [
'$locationProvider', '$stateProvider', '$dialogProvider', 'AngularyticsProvider', '$httpProvider', '$sceDelegateProvider', 'markedProvider'
(location, state, $dialogProvider, analytics, $httpProvider, $sceDelegateProvider, markedProvider) ->
@ -330,3 +374,5 @@ module.config [
backdropClick: false
]
module.exports = ponyfm

View file

@ -24,7 +24,7 @@ window.pfm.preloaders['account-albums-edit'] = [
$.when.all defs
]
angular.module('ponyfm').controller "account-albums-edit", [
module.exports = angular.module('ponyfm').controller "account-albums-edit", [
'$scope', '$state', '$dialog', 'account-albums'
($scope, $state, $dialog, albums) ->
$scope.isNew = $state.params.album_id == undefined

View file

@ -20,7 +20,7 @@ window.pfm.preloaders['account-albums'] = [
$.when.all [tracks.refresh('published=true&in_album=false', true), albums.refresh(true)]
]
angular.module('ponyfm').controller "account-albums", [
module.exports = angular.module('ponyfm').controller "account-albums", [
'$scope', '$state', 'account-albums', 'account-tracks'
($scope, $state, albums, tracks) ->

View file

@ -14,7 +14,7 @@
# 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/>.
angular.module('ponyfm').controller "account-image-select", [
module.exports = angular.module('ponyfm').controller "account-image-select", [
'$scope'
($scope) ->
$scope.images = []

View file

@ -19,7 +19,7 @@ window.pfm.preloaders['account-playlists'] = [
(playlists) -> playlists.refreshOwned true
]
angular.module('ponyfm').controller "account-playlists", [
module.exports = angular.module('ponyfm').controller "account-playlists", [
'$scope', 'auth', '$dialog', 'playlists'
($scope, auth, $dialog, playlists) ->
$scope.playlists = []

View file

@ -14,7 +14,7 @@
# 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/>.
angular.module('ponyfm').controller "account-settings", [
module.exports = angular.module('ponyfm').controller "account-settings", [
'$scope', 'auth'
($scope, auth) ->
$scope.settings = {}

View file

@ -14,7 +14,7 @@
# 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/>.
angular.module('ponyfm').controller "account-track", [
module.exports = angular.module('ponyfm').controller "account-track", [
'$scope', '$state'
($scope, $state) ->
# All the fun stuff happens in the pfmTrackEditor directive.

View file

@ -20,7 +20,7 @@ window.pfm.preloaders['account-tracks'] = [
$.when.all [tracks.refresh(null, true), albums.refresh(true), taxonomies.refresh()]
]
angular.module('ponyfm').controller "account-tracks", [
module.exports = angular.module('ponyfm').controller "account-tracks", [
'$scope', '$state', 'taxonomies', '$dialog', 'lightbox', 'account-albums', 'account-tracks'
($scope, $state, taxonomies, $dialog, lightbox, albums, tracks) ->
$scope.data =

View file

@ -14,7 +14,7 @@
# 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/>.
angular.module('ponyfm').controller 'admin-genres', [
module.exports = angular.module('ponyfm').controller 'admin-genres', [
'$scope', '$state', 'admin-genres'
($scope, $state, genres) ->

View file

@ -20,7 +20,7 @@ window.pfm.preloaders['album'] = [
$.when.all [albums.fetch $state.params.id, playlists.refreshOwned(true)]
]
angular.module('ponyfm').controller "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) ->
album = null

View file

@ -20,7 +20,7 @@ window.pfm.preloaders['albums-list'] = [
albums.fetchList($state.params.page, true)
]
angular.module('ponyfm').controller "albums-list", [
module.exports = angular.module('ponyfm').controller "albums-list", [
'$scope', 'albums', '$state'
($scope, albums, $state) ->
albums.fetchList($state.params.page).done (list) ->

View file

@ -14,7 +14,7 @@
# 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/>.
angular.module('ponyfm').controller "albums", [
module.exports = angular.module('ponyfm').controller "albums", [
'$scope', 'albums', '$state'
($scope, albums, $state) ->

View file

@ -14,7 +14,7 @@
# 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/>.
angular.module('ponyfm').controller "application", [
module.exports = angular.module('ponyfm').controller "application", [
'$scope', 'auth', '$location', 'upload', '$state', '$stateParams', '$injector', '$rootScope', 'playlists'
($scope, auth, $location, upload, $state, $stateParams, $injector, $rootScope, playlists) ->
$scope.auth = auth.data

View file

@ -20,7 +20,7 @@ window.pfm.preloaders['artist-content'] = [
$.when.all [artists.fetch($state.params.slug), artists.fetchContent($state.params.slug, true)]
]
angular.module('ponyfm').controller "artist-content", [
module.exports = angular.module('ponyfm').controller "artist-content", [
'$scope', 'artists', '$state'
($scope, artists, $state) ->
artists.fetchContent($state.params.slug)

View file

@ -20,7 +20,7 @@ window.pfm.preloaders['artist-favourites'] = [
$.when.all [artists.fetch($state.params.slug), artists.fetchFavourites($state.params.slug, true)]
]
angular.module('ponyfm').controller "artist-favourites", [
module.exports = angular.module('ponyfm').controller "artist-favourites", [
'$scope', 'artists', '$state'
($scope, artists, $state) ->
artists.fetchFavourites($state.params.slug).done (artistResponse) ->

View file

@ -20,7 +20,7 @@ window.pfm.preloaders['artist-profile'] = [
artists.fetch $state.params.slug, true
]
angular.module('ponyfm').controller "artist-profile", [
module.exports = angular.module('ponyfm').controller "artist-profile", [
'$scope', 'artists', '$state'
($scope, artists, $state) ->
]

View file

@ -20,7 +20,7 @@ window.pfm.preloaders['artist'] = [
artists.fetch $state.params.slug, true
]
angular.module('ponyfm').controller "artist", [
module.exports = angular.module('ponyfm').controller "artist", [
'$scope', 'artists', '$state', 'follow'
($scope, artists, $state, follow) ->
artists.fetch($state.params.slug)

View file

@ -20,7 +20,7 @@ window.pfm.preloaders['artists-list'] = [
artists.fetchList($state.params.page, true)
]
angular.module('ponyfm').controller "artists-list", [
module.exports = angular.module('ponyfm').controller "artists-list", [
'$scope', 'artists', '$state'
($scope, artists, $state) ->
artists.fetchList($state.params.page).done (list) ->

View file

@ -14,7 +14,7 @@
# 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/>.
angular.module('ponyfm').controller "artists", [
module.exports = angular.module('ponyfm').controller "artists", [
'$scope', 'artists', '$state'
($scope, artists, $state) ->

View file

@ -14,7 +14,7 @@
# 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/>.
angular.module('ponyfm').controller "credits", [
module.exports = angular.module('ponyfm').controller "credits", [
'$scope', 'dialog',
($scope, dialog) ->
$scope.close = () -> dialog.close(null)

View file

@ -19,7 +19,7 @@ window.pfm.preloaders['dashboard'] = [
(dashboard) -> dashboard.refresh(true)
]
angular.module('ponyfm').controller "dashboard", [
module.exports = angular.module('ponyfm').controller "dashboard", [
'$scope', 'dashboard', 'auth', '$http'
($scope, dashboard, auth, $http) ->
$scope.recentTracks = null

View file

@ -20,7 +20,7 @@ window.pfm.preloaders['favourites-albums'] = [
favourites.fetchAlbums(true)
]
angular.module('ponyfm').controller "favourites-albums", [
module.exports = angular.module('ponyfm').controller "favourites-albums", [
'$scope', 'favourites'
($scope, favourites) ->
favourites.fetchAlbums().done (res) ->

View file

@ -20,7 +20,7 @@ window.pfm.preloaders['favourites-playlists'] = [
favourites.fetchPlaylists(true)
]
angular.module('ponyfm').controller "favourites-playlists", [
module.exports = angular.module('ponyfm').controller "favourites-playlists", [
'$scope', 'favourites'
($scope, favourites) ->
favourites.fetchPlaylists().done (res) ->

View file

@ -20,7 +20,7 @@ window.pfm.preloaders['favourites-tracks'] = [
favourites.fetchTracks(true)
]
angular.module('ponyfm').controller "favourites-tracks", [
module.exports = angular.module('ponyfm').controller "favourites-tracks", [
'$scope', 'favourites'
($scope, favourites) ->
favourites.fetchTracks().done (res) ->

View file

@ -19,7 +19,7 @@ window.pfm.preloaders['home'] = [
(dashboard) -> dashboard.refresh(true)
]
angular.module('ponyfm').controller "home", [
module.exports = angular.module('ponyfm').controller "home", [
'$scope', 'dashboard'
($scope, dashboard) ->
$scope.recentTracks = null

View file

@ -14,7 +14,7 @@
# 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/>.
angular.module('ponyfm').controller "login", [
module.exports = angular.module('ponyfm').controller "login", [
'$scope', 'auth'
($scope, auth) ->

View file

@ -14,7 +14,7 @@
# 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/>.
angular.module('ponyfm').controller "playlist-form", [
module.exports = angular.module('ponyfm').controller "playlist-form", [
'$scope', 'dialog', 'playlists', 'playlist'
($scope, dialog, playlists, playlist) ->
$scope.isLoading = false

View file

@ -20,7 +20,7 @@ window.pfm.preloaders['playlist'] = [
playlists.fetch $state.params.id, true
]
angular.module('ponyfm').controller '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) ->
playlist = null

View file

@ -20,7 +20,7 @@ window.pfm.preloaders['playlists-list'] = [
playlists.fetchList($state.params.page, true)
]
angular.module('ponyfm').controller "playlists-list", [
module.exports = angular.module('ponyfm').controller "playlists-list", [
'$scope', 'playlists', '$state',
($scope, playlists, $state) ->
playlists.fetchList($state.params.page).done (searchResults) ->

View file

@ -14,7 +14,7 @@
# 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/>.
angular.module('ponyfm').controller "playlists", [
module.exports = angular.module('ponyfm').controller "playlists", [
'$scope', 'playlists', '$state'
($scope, playlists, $state) ->

View file

@ -14,7 +14,7 @@
# 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/>.
angular.module('ponyfm').controller "sidebar", [
module.exports = angular.module('ponyfm').controller "sidebar", [
'$scope', '$dialog', 'playlists'
($scope, $dialog, playlists) ->
$scope.playlists = playlists.pinnedPlaylists

View file

@ -15,7 +15,7 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
angular.module('ponyfm').controller "track-edit", [
module.exports = angular.module('ponyfm').controller "track-edit", [
'$scope', '$state'
($scope, $state) ->
# All the fun stuff happens in the pfmTrackEditor directive.

View file

@ -20,7 +20,7 @@ window.pfm.preloaders['track-show'] = [
$.when.all [tracks.fetch $state.params.id, playlists.refreshOwned(true)]
]
angular.module('ponyfm').controller "track-show", [
module.exports = angular.module('ponyfm').controller "track-show", [
'$scope', 'tracks', '$state', 'playlists', 'auth', 'favourites', '$dialog'
($scope, tracks, $state, playlists, auth, favourites, $dialog) ->
]

View file

@ -14,7 +14,7 @@
# 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/>.
angular.module('ponyfm').controller "track", [
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.track

View file

@ -25,7 +25,7 @@ window.pfm.preloaders['tracks-list'] = [
)
]
angular.module('ponyfm').controller "tracks-list", [
module.exports = angular.module('ponyfm').controller "tracks-list", [
'$scope', 'tracks', '$state',
($scope, tracks, $state) ->
tracks.mainQuery.fetch().done (searchResults) ->

View file

@ -20,7 +20,7 @@ window.pfm.preloaders['tracks'] = [
tracks.loadFilters()
]
angular.module('ponyfm').controller "tracks", [
module.exports = angular.module('ponyfm').controller "tracks", [
'$scope', 'tracks', '$state', 'focus'
($scope, tracks, $state, focus) ->
$scope.recentTracks = null

View file

@ -14,7 +14,7 @@
# 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/>.
angular.module('ponyfm').controller "uploader", [
module.exports = angular.module('ponyfm').controller "uploader", [
'$scope', 'auth', 'upload', '$state'
($scope, auth, upload, $state) ->
$scope.data = upload

View file

@ -14,7 +14,7 @@
# 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/>.
angular.module('ponyfm').directive 'pfmAlbumsList', () ->
module.exports = angular.module('ponyfm').directive 'pfmAlbumsList', () ->
restrict: 'E'
replace: true
templateUrl: '/templates/directives/albums-list.html'

View file

@ -16,7 +16,7 @@
# Based on http://stackoverflow.com/questions/14641791/how-to-use-colorbox-with-angular-js
angular.module('ponyfm').directive 'colorbox', ->
module.exports = angular.module('ponyfm').directive 'colorbox', ->
restrict: 'AC'
link: (scope, element, attrs) ->
$(element).colorbox({maxWidth:'90%', maxHeight:'90%'})

View file

@ -14,7 +14,7 @@
# 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/>.
angular.module('ponyfm').directive 'pfmComments', () ->
module.exports = angular.module('ponyfm').directive 'pfmComments', () ->
restrict: 'E'
templateUrl: '/templates/directives/comments.html'
scope:

View file

@ -14,7 +14,7 @@
# 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/>.
angular.module('ponyfm').directive 'pfmEatClick', () ->
module.exports = angular.module('ponyfm').directive 'pfmEatClick', () ->
(scope, element) ->
$(element).click (e) ->
e.preventDefault()

View file

@ -14,7 +14,7 @@
# 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/>.
angular.module('ponyfm').directive 'pfmFavouriteButton', () ->
module.exports = angular.module('ponyfm').directive 'pfmFavouriteButton', () ->
restrict: 'E'
templateUrl: '/templates/directives/favourite-button.html'
scope:

View file

@ -14,7 +14,7 @@
# 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/>.
angular.module('ponyfm').directive 'pfmImageUpload', () ->
module.exports = angular.module('ponyfm').directive 'pfmImageUpload', () ->
$image = null
$uploader = null

View file

@ -17,7 +17,7 @@
# This directive calls the given function when Enter is pressed in a
# standalone input field.
angular.module('ponyfm').directive 'pfmOnEnter', () ->
module.exports = angular.module('ponyfm').directive 'pfmOnEnter', () ->
(scope, element, attrs) ->
element.bind("keyup", (event) ->
if (event.which is 13)

View file

@ -14,7 +14,7 @@
# 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/>.
angular.module('ponyfm').directive 'pfmPlayer', () ->
module.exports = angular.module('ponyfm').directive 'pfmPlayer', () ->
$element = null
restrict: 'E'

View file

@ -14,7 +14,7 @@
# 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/>.
angular.module('ponyfm').directive 'pfmPlaylistsList', () ->
module.exports = angular.module('ponyfm').directive 'pfmPlaylistsList', () ->
restrict: 'E'
replace: true
templateUrl: '/templates/directives/playlists-list.html'

View file

@ -14,7 +14,7 @@
# 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/>.
angular.module('ponyfm').directive 'pfmPopup', () ->
module.exports = angular.module('ponyfm').directive 'pfmPopup', () ->
(scope, element, attrs) ->
align = 'left'
elementId = attrs.pfmPopup

View file

@ -14,7 +14,7 @@
# 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/>.
angular.module('ponyfm').directive 'pfmProgressBar', () ->
module.exports = angular.module('ponyfm').directive 'pfmProgressBar', () ->
(scope, element, attrs) ->
scope.$watch attrs.pfmProgressBar, (val) ->
return if !val?

View file

@ -14,7 +14,7 @@
# 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/>.
angular.module('ponyfm').directive 'pfmScrollRecorder', () ->
module.exports = angular.module('ponyfm').directive 'pfmScrollRecorder', () ->
(scope, element, attrs) ->
timeout = null
onScroll = null

View file

@ -14,7 +14,7 @@
# 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/>.
angular.module('ponyfm').directive 'pfmSearch', () ->
module.exports = angular.module('ponyfm').directive 'pfmSearch', () ->
restrict: 'E'
templateUrl: '/templates/directives/search.html'
scope:

View file

@ -14,7 +14,7 @@
# 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/>.
angular.module('ponyfm').directive 'pfmShareButtons', () ->
module.exports = angular.module('ponyfm').directive 'pfmShareButtons', () ->
(scope, element) ->
window.setTimeout((->
Tumblr.activate_share_on_tumblr_buttons()

View file

@ -14,7 +14,7 @@
# 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/>.
angular.module('ponyfm').directive 'pfmSrcLoader', () ->
module.exports = angular.module('ponyfm').directive 'pfmSrcLoader', () ->
(scope, element, attrs) ->
size = attrs.pfmSrcSize || 'normal'
element.css {opacity: .5}

View file

@ -14,7 +14,7 @@
# 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/>.
angular.module('ponyfm').directive 'pfmTrackEditor', () ->
module.exports = angular.module('ponyfm').directive 'pfmTrackEditor', () ->
restrict: 'E'
templateUrl: '/templates/directives/track-editor.html'
scope:

View file

@ -14,7 +14,7 @@
# 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/>.
angular.module('ponyfm').directive 'pfmTrackPlayer', () ->
module.exports = angular.module('ponyfm').directive 'pfmTrackPlayer', () ->
restrict: 'E'
templateUrl: '/templates/directives/track-player.html'
scope:

View file

@ -14,7 +14,7 @@
# 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/>.
angular.module('ponyfm').directive 'pfmTracksList', () ->
module.exports = angular.module('ponyfm').directive 'pfmTracksList', () ->
restrict: 'E'
templateUrl: '/templates/directives/tracks-list.html'
replace: true

View file

@ -14,7 +14,7 @@
# 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/>.
angular.module('ponyfm').directive 'uploader', [
module.exports = angular.module('ponyfm').directive 'uploader', [
'upload'
(upload) -> (scope, element) ->
$dropzone = $(element)

View file

@ -14,7 +14,7 @@
# 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/>.
angular.module('ponyfm').directive 'pfmUsersList', () ->
module.exports = angular.module('ponyfm').directive 'pfmUsersList', () ->
restrict: 'E'
replace: true
templateUrl: '/templates/directives/users-list.html'

View file

@ -14,6 +14,6 @@
# 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/>.
angular.module('ponyfm').filter 'pfmLength', () ->
module.exports = angular.module('ponyfm').filter 'pfmLength', () ->
(input) ->
input.length

View file

@ -14,6 +14,6 @@
# 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/>.
angular.module('ponyfm').filter 'momentFromNow', () ->
module.exports = angular.module('ponyfm').filter 'momentFromNow', () ->
(input) ->
moment.utc(input).fromNow()

View file

@ -1,6 +1,6 @@
# Based on https://gist.github.com/kensnyder/49136af39457445e5982
angular.module('ponyfm').filter 'nl2br', [
module.exports = angular.module('ponyfm').filter 'nl2br', [
'$sanitize'
($sanitize) ->
tag = if /xhtml/i.test(document.doctype) then '<br />' else '<br>'

View file

@ -14,7 +14,7 @@
# 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/>.
angular.module('ponyfm').filter 'noHTML', () ->
module.exports = angular.module('ponyfm').filter 'noHTML', () ->
(input) ->
return '' if !input

View file

@ -14,7 +14,7 @@
# 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/>.
angular.module('ponyfm').filter 'secondsDisplay', () ->
module.exports = angular.module('ponyfm').filter 'secondsDisplay', () ->
(input) ->
sec_num = parseInt(input, 10)
return '00:00' if !sec_num

View file

@ -14,7 +14,7 @@
# 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/>.
angular.module('ponyfm').filter 'trust', [
module.exports = angular.module('ponyfm').filter 'trust', [
'$sce'
($sce) ->
(input) ->

View file

@ -14,7 +14,7 @@
# 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/>.
angular.module('ponyfm').factory('account-albums', [
module.exports = angular.module('ponyfm').factory('account-albums', [
'$rootScope', '$http'
($rootScope, $http) ->
def = null

View file

@ -14,7 +14,7 @@
# 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/>.
angular.module('ponyfm').factory('account-tracks', [
module.exports = angular.module('ponyfm').factory('account-tracks', [
'$rootScope', '$http'
($rootScope, $http) ->
cache = {}

View file

@ -14,7 +14,7 @@
# 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/>.
angular.module('ponyfm').factory('admin-genres', [
module.exports = angular.module('ponyfm').factory('admin-genres', [
'$rootScope', '$http'
($rootScope, $http) ->
def = null

View file

@ -14,7 +14,7 @@
# 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/>.
angular.module('ponyfm').factory('albums', [
module.exports = angular.module('ponyfm').factory('albums', [
'$rootScope', '$http'
($rootScope, $http) ->
albumPages = []

View file

@ -14,7 +14,7 @@
# 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/>.
angular.module('ponyfm').factory('artists', [
module.exports = angular.module('ponyfm').factory('artists', [
'$rootScope', '$http'
($rootScope, $http) ->
artistPage = []

View file

@ -14,7 +14,7 @@
# 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/>.
angular.module('ponyfm').factory('auth', [
module.exports = angular.module('ponyfm').factory('auth', [
'$rootScope'
($rootScope) ->
data: {isLogged: window.pfm.auth.isLogged, user: window.pfm.auth.user}

View file

@ -14,7 +14,7 @@
# 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/>.
angular.module('ponyfm').factory('comments', [
module.exports = angular.module('ponyfm').factory('comments', [
'$rootScope', '$http'
($rootScope, $http) ->
commentCache = []

View file

@ -14,7 +14,7 @@
# 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/>.
angular.module('ponyfm').factory('dashboard', [
module.exports = angular.module('ponyfm').factory('dashboard', [
'$rootScope', '$http'
($rootScope, $http) ->
def = null

View file

@ -14,7 +14,7 @@
# 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/>.
angular.module('ponyfm').factory('download-cached', [
module.exports = angular.module('ponyfm').factory('download-cached', [
'$rootScope', '$http', '$log'
($rootScope, $http, $log) ->
download = (type, id, format) ->

View file

@ -14,7 +14,7 @@
# 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/>.
angular.module('ponyfm').factory('favourites', [
module.exports = angular.module('ponyfm').factory('favourites', [
'$rootScope', '$http'
($rootScope, $http) ->
tracksDef = null

View file

@ -19,7 +19,7 @@
# using a jQuery selector.
#
# Based on: https://stackoverflow.com/a/25597540/3225811
angular.module('ponyfm').factory('focus', ['$timeout', '$window', ($timeout, $window) ->
module.exports = angular.module('ponyfm').factory('focus', ['$timeout', '$window', ($timeout, $window) ->
(selector) ->
$timeout () ->
element = $window.jQuery("#{selector}")

View file

@ -14,7 +14,7 @@
# 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/>.
angular.module('ponyfm').factory('follow', [
module.exports = angular.module('ponyfm').factory('follow', [
'$rootScope', '$http'
($rootScope, $http) ->
self =

View file

@ -14,7 +14,7 @@
# 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/>.
angular.module('ponyfm').factory('images', [
module.exports = angular.module('ponyfm').factory('images', [
'$rootScope'
($rootScope) ->
def = null

View file

@ -14,7 +14,7 @@
# 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/>.
angular.module('ponyfm').factory('lightbox', [
module.exports = angular.module('ponyfm').factory('lightbox', [
() ->
openDataUrl: (src) ->
$.colorbox

View file

@ -14,7 +14,7 @@
# 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/>.
angular.module('ponyfm').factory('player', [
module.exports = angular.module('ponyfm').factory('player', [
'$rootScope'
($rootScope) ->
readyDef = new $.Deferred()

View file

@ -14,7 +14,7 @@
# 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/>.
angular.module('ponyfm').factory('playlists', [
module.exports = angular.module('ponyfm').factory('playlists', [
'$rootScope', '$state', '$http', 'auth'
($rootScope, $state, $http, auth) ->
playlistDef = null

View file

@ -14,7 +14,7 @@
# 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/>.
angular.module('ponyfm').factory('search', [
module.exports = angular.module('ponyfm').factory('search', [
'$http'
($http) ->

View file

@ -14,7 +14,7 @@
# 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/>.
angular.module('ponyfm').factory('taxonomies', [
module.exports = angular.module('ponyfm').factory('taxonomies', [
'$rootScope', '$http'
($rootScope, $http) ->
def = null

View file

@ -14,7 +14,7 @@
# 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/>.
angular.module('ponyfm').factory('tracks', [
module.exports = angular.module('ponyfm').factory('tracks', [
'$rootScope', '$http', 'taxonomies'
($rootScope, $http, taxonomies) ->
filterDef = null

View file

@ -14,7 +14,7 @@
# 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/>.
angular.module('ponyfm').factory('upload', [
module.exports = angular.module('ponyfm').factory('upload', [
'$rootScope', '$http', '$timeout', 'account-tracks'
($rootScope, $http, $timeout, accountTracks) ->
self =

File diff suppressed because it is too large Load diff

View file

@ -14,6 +14,17 @@
# 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/>.
require 'script!../base/jquery-2.0.2'
require '../base/jquery.timeago'
require '../base/soundmanager2-nodebug'
require './favourite.coffee'
require 'script!../base/underscore'
require '../shared/layout.coffee'
require 'script!../shared/underscore-extensions'
$('.timeago').timeago()
loaderDef = new $.Deferred()

View file

@ -14,6 +14,12 @@
# 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/>.
require 'script!../base/underscore'
require './jquery-extensions'
require './layout.coffee'
require 'script!./underscore-extensions'
def = new $.Deferred()
pfm.soundManager = def.promise()

View file

@ -25,7 +25,7 @@
<script>
window.fbAsyncInit = function() {
FB.init({
appId : '186765381447538',
appId: '186765381447538',
status: true,
cookie: true,
xfbml: true
@ -158,11 +158,7 @@
</script>
@endif
{!! Assets::scriptIncludes() !!}
@if (!Config::get("app.debug"))
<script src="/build/scripts/templates.js"></script>
@endif
{!! Assets::scriptIncludes('app') !!}
@yield('app_scripts')

31
webpack.base.config.js Normal file
View file

@ -0,0 +1,31 @@
var path = require('path');
var webpack = require('webpack');
// NOTE: This is a base config; it's not meant to be used directly!
module.exports = {
module: {
loaders: [
{test: /\.coffee$/, loader: "coffee"}
],
noParse: [/pfm-angular-marked\.js/]
},
plugins: [
new webpack.ProvidePlugin({
$: "jquery",
jQuery: "jquery"
})
],
entry: {
app: './resources/assets/scripts/app/app.coffee',
embed: './resources/assets/scripts/embed/embed.coffee'
},
output: {
path: __dirname + '/public',
filename: './build/scripts/[name].js'
// publicPath should be defined in the dev config!
},
resolve: {
extensions: ["", ".webpack.js", ".web.js", ".js", ".coffee"]
}
};

12
webpack.dev.config.js Normal file
View file

@ -0,0 +1,12 @@
var path = require('path');
var webpack = require('webpack');
var _ = require('underscore');
var webpackBaseConfig = require('./webpack.base.config.js');
var config = _.clone(webpackBaseConfig);
config.devtool = 'source-map';
config.output.publicPath = 'http://localhost:61999/build/';
module.exports = config;

View file

@ -0,0 +1,16 @@
var path = require('path');
var webpack = require('webpack');
var _ = require('underscore');
var webpackBaseConfig = require('./webpack.base.config.js');
var config = _.clone(webpackBaseConfig);
config.plugins.push(
new webpack.optimize.UglifyJsPlugin({
compress: {
warnings: false
}
})
);
module.exports = config;