From b33dcfd8c6368bb3d8b7f432b61d0aa5a708ae6c Mon Sep 17 00:00:00 2001 From: Kelvin Date: Sun, 6 Sep 2015 18:21:11 +0100 Subject: [PATCH] Update namespaces --- app/Album.php | 2 +- app/Genre.php | 2 +- app/Http/Controllers/AccountController.php | 4 +- app/Http/Controllers/AlbumsController.php | 7 +- .../Api/Mobile/TracksController.php | 2 +- .../Controllers/Api/V1/TracksController.php | 2 +- .../Controllers/Api/Web/AccountController.php | 5 +- .../Controllers/Api/Web/AlbumsController.php | 5 +- .../Controllers/Api/Web/ArtistsController.php | 5 +- .../Controllers/Api/Web/AuthController.php | 2 +- .../Api/Web/CommentsController.php | 5 +- .../Api/Web/DashboardController.php | 5 +- .../Api/Web/FavouritesController.php | 5 +- .../Controllers/Api/Web/FollowController.php | 5 +- .../Controllers/Api/Web/ImagesController.php | 5 +- .../Api/Web/PlaylistsController.php | 5 +- .../Api/Web/ProfilerController.php | 2 +- .../Api/Web/TaxonomiesController.php | 5 +- .../Controllers/Api/Web/TracksController.php | 5 +- app/Http/Controllers/ApiControllerBase.php | 4 +- app/Http/Controllers/ArtistsController.php | 5 +- app/Http/Controllers/AuthController.php | 10 +- app/Http/Controllers/ContentController.php | 4 +- app/Http/Controllers/FavouritesController.php | 4 +- app/Http/Controllers/HomeController.php | 4 +- app/Http/Controllers/ImagesController.php | 6 +- app/Http/Controllers/PlaylistsController.php | 6 +- app/Http/Controllers/TracksController.php | 8 +- app/Http/Controllers/UploaderController.php | 4 +- app/Http/Controllers/UsersController.php | 5 +- app/Library/Assets.php | 5 +- app/Playlist.php | 2 +- composer.json | 3 +- config/app.php | 2 +- gulpfile.js | 188 ++++++++++++++++-- package.json | 32 ++- resources/views/shared/_app_layout.blade.php | 4 +- resources/views/tracks/embed.blade.php | 4 +- 38 files changed, 308 insertions(+), 70 deletions(-) diff --git a/app/Album.php b/app/Album.php index 67d1dd19..40b2757c 100644 --- a/app/Album.php +++ b/app/Album.php @@ -8,7 +8,7 @@ use Illuminate\Database\Eloquent\SoftDeletes; use Illuminate\Support\Facades\Auth; use Illuminate\Support\Facades\Cache; use Illuminate\Support\Facades\URL; -use Traits\SlugTrait; +use App\Traits\SlugTrait; class Album extends Model { diff --git a/app/Genre.php b/app/Genre.php index 573011c5..f9af2769 100644 --- a/app/Genre.php +++ b/app/Genre.php @@ -3,7 +3,7 @@ namespace App; use Illuminate\Database\Eloquent\Model; -use Traits\SlugTrait; +use App\Traits\SlugTrait; class Genre extends Model { diff --git a/app/Http/Controllers/AccountController.php b/app/Http/Controllers/AccountController.php index 0c97a3d5..d60410c6 100644 --- a/app/Http/Controllers/AccountController.php +++ b/app/Http/Controllers/AccountController.php @@ -1,8 +1,10 @@ 'single', + 'log' => 'daily', /* |-------------------------------------------------------------------------- diff --git a/gulpfile.js b/gulpfile.js index dc6f1ebb..d655858d 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -1,16 +1,178 @@ -var elixir = require('laravel-elixir'); +var gulp = require("gulp"), + plug = require("gulp-load-plugins")(), + argv = require("yargs").argv; -/* - |-------------------------------------------------------------------------- - | Elixir Asset Management - |-------------------------------------------------------------------------- - | - | Elixir provides a clean, fluent API for defining some basic Gulp tasks - | for your Laravel application. By default, we are compiling the Sass - | file for our application, as well as publishing vendor resources. - | - */ +var plumberOptions = { + errorHandler: plug.notify.onError("Error: <%= error.message %>") +}; -elixir(function(mix) { - mix.sass('app.scss'); +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) { + paths.push("resources/assets/scripts/debug/**/*.{coffee,js}"); + + // 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()) + .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(plug.sourcemaps.write({ + includeContent: false, + sourceRoot: "/dev-scripts/" + })) + .pipe(gulp.dest("public/build/scripts")); }); + +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.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/embed/*.coffee" + ]; + + 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(gulp.dest("public/build/scripts")); +}); + +gulp.task("styles-app", function() { + var includedStyles = [ + "resources/assets/styles/base/jquery-ui.css", + "resources/assets/styles/base/colorbox.css", + "resources/assets/styles/app.less" + ]; + + if (!argv.production) { + includedStyles.push("resources/assets/styles/profiler.less"); + includedStyles.push("resources/assets/styles/prettify.css"); + + // 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 css file + includedStyles.push("resources/assets/styles/embed.css"); + + // Remove app.less from the cache so that it gets recompiled + var styleCache = plug.cached.caches.styles; + for (var file in styleCache) { + if (!styleCache.hasOwnProperty(file)) + continue; + + if (!endsWith(file, "app.less")) + continue; + + delete styleCache[file]; + } + } + + // note that we're not doing autoprefixer on dev builds for now to shave off roughly 600-700 milliseconds per + // build. It's already taking forever to recompile the less + + return argv.production + // Production pipeline + ? gulp.src(includedStyles, {base: "resources/assets/styles"}) + .pipe(plug.plumber(plumberOptions)) + .pipe(plug.if(/\.less/, plug.less())) + .pipe(plug.autoprefixer({browsers: ["last 2 versions"], cascade: false})) + .pipe(plug.concat("app.css")) + .pipe(plug.minifyCss()) + .pipe(gulp.dest("public/build/styles")) + // Development pipeline + : gulp.src(includedStyles, {base: "resources/assets/styles"}) + .pipe(plug.plumber(plumberOptions)) + .pipe(plug.cached("styles")) + .pipe(plug.sourcemaps.init()) + .pipe(plug.if(/\.less/, plug.less())) + .pipe(plug.sourcemaps.write({ + includeContent: false, + sourceRoot: "/dev-styles/" + })) + .pipe(gulp.dest("public/build/styles")) + .pipe(plug.livereload()); +}); + +gulp.task("styles-embed", function() { + // note that this task should really only ever be invoked for production + // since development-mode watches and builds include the embed styles + // already + + return gulp.src(["resources/assets/styles/embed.less"], {base: "resources/assets/styles"}) + .pipe(plug.less()) + .pipe(plug.autoprefixer({browsers: ["last 2 versions"], cascade: false})) + .pipe(plug.concat("embed.css")) + .pipe(plug.minifyCss()) + .pipe(gulp.dest("public/build/styles")); +}); + +gulp.task('copy:templates', function() { + gulp.src([ + 'public/templates/**/*.html' + ]) + .pipe(plug.angularTemplatecache({ + module: "ponyfm", + root: "/templates" + })) + .pipe(gulp.dest('public/build/scripts')); +}); + +gulp.task('build', [ + 'scripts-app', + 'styles-app', + 'scripts-embed', + 'styles-embed', +]); + +gulp.task("watch", function() { + plug.livereload.listen(); + gulp.watch("resources/assets/scripts/**/*.{coffee,js}", ["scripts-app"]); + gulp.watch("resources/assets/styles/**/*.{css,less}", ["styles-app"]); +}); + +function endsWith(str, suffix) { + return str.indexOf(suffix, str.length - suffix.length) !== -1; +} \ No newline at end of file diff --git a/package.json b/package.json index b1b4a6e6..275d9d85 100644 --- a/package.json +++ b/package.json @@ -1,10 +1,30 @@ { - "private": true, - "devDependencies": { - "gulp": "^3.8.8" + "name": "pony.fm", + "version": "1.0.0", + "repository": { + "type": "git", + "url": "ssh://git@phabricator.poniverse.net/diffusion/PF/pony-fm.git" }, - "dependencies": { - "laravel-elixir": "^2.0.0", - "bootstrap-sass": "^3.0.0" + "packages": {}, + "dependencies": {}, + "devDependencies": { + "gulp": "^3.8.11", + "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-if": "^1.2.5", + "gulp-less": "^3.0.3", + "gulp-livereload": "^3.8.0", + "gulp-load-plugins": "^0.10.0", + "gulp-minify-css": "^1.1.0", + "gulp-notify": "^2.2.0", + "gulp-order": "^1.1.1", + "gulp-plumber": "^1.0.0", + "gulp-sourcemaps": "^1.5.1", + "gulp-uglify": "^1.2.0", + "gulp-util": "^3.0.4", + "yargs": "^3.7.2" } } diff --git a/resources/views/shared/_app_layout.blade.php b/resources/views/shared/_app_layout.blade.php index 1a1cf180..10869add 100644 --- a/resources/views/shared/_app_layout.blade.php +++ b/resources/views/shared/_app_layout.blade.php @@ -92,7 +92,7 @@ @section('styles') - {{ Assets::styleIncludes() }} + {!! Assets::styleIncludes() !!} @endsection @section('scripts') @@ -123,7 +123,7 @@ })(); - {{ Assets::scriptIncludes() }} + {!! Assets::scriptIncludes() !!} @if (!Config::get("app.debug")) diff --git a/resources/views/tracks/embed.blade.php b/resources/views/tracks/embed.blade.php index 53e9d4b4..958ef98c 100644 --- a/resources/views/tracks/embed.blade.php +++ b/resources/views/tracks/embed.blade.php @@ -12,7 +12,7 @@ - {{ Assets::styleIncludes('embed') }} + {!! Assets::styleIncludes('embed') !!} @if($track->explicit && !(Auth::check() && Auth::user()->can_see_explicit_content)) @@ -50,7 +50,7 @@ var pfm = {token: '{{ Session::token() }}'} - {{ Assets::scriptIncludes('embed') }} + {!! Assets::scriptIncludes('embed') !!}