diff --git a/.gitignore b/.gitignore index f95bb52..87f5cd3 100644 --- a/.gitignore +++ b/.gitignore @@ -16,6 +16,8 @@ db.sqlite3 # Bootflat shelfzilla/themes/bootflat/static/css/*.css shelfzilla/themes/bootflat/static/js/*.js +shelfzilla/themes/bootflat/static/bower/* +**/CACHE/* # Bower bower_components diff --git a/config/requirements.txt b/config/requirements.txt index e2b50b9..ad9df07 100644 --- a/config/requirements.txt +++ b/config/requirements.txt @@ -11,6 +11,9 @@ django-import-export==0.2.2 # Fixes longerusername==0.4 +# Statics +django-compressor==1.4 + # DDBB dj-database-url==0.3.0 psycopg2==2.5.2 diff --git a/gruntfile.coffee b/gruntfile.coffee index db4ec1d..511795c 100644 --- a/gruntfile.coffee +++ b/gruntfile.coffee @@ -3,93 +3,6 @@ module.exports = (grunt) -> grunt.initConfig pkg: grunt.file.readJSON 'package.json' - bower: - dev: - dest: "static_components/" - js_dest: 'static_components/js', - css_dest: 'static_components/css' - options: - packageSpecific: - Bootflat: - dest: 'static_components/fonts', - files: [ - 'css/bootstrap.min.css', - 'bootflat/css/bootflat.min.css', - 'bootflat/img/check_flat/default.png', - 'bootflat/js/icheck.min.js', - 'js/bootstrap.min.js', - 'fonts/glyphicons-halflings-regular.eot', - 'fonts/glyphicons-halflings-regular.svg', - 'fonts/glyphicons-halflings-regular.ttf', - 'fonts/glyphicons-halflings-regular.woff', - ] - nprogress: - files: [ - 'nprogress.css', - ] - - less: - options: - ieCompat: true - compress: true - development: - files: - "shelfzilla/themes/bootflat/static/css/app.css": "shelfzilla/themes/bootflat/static/less/app.less" - - coffee: - development: - files: - 'shelfzilla/themes/bootflat/static/js/main.full.js': 'shelfzilla/themes/bootflat/static/coffee/main.coffee' - - - concat: - options: - separator: ';' - js: - src: [ - "static_components/js/jquery.js", - "static_components/js/vegas.js", - "static_components/js/bootstrap.min.js", - "static_components/js/icheck.min.js", - "static_components/js/jquery-pjax.js", - "static_components/js/nprogress.js", - "static_components/js/toastr.js", - "static_components/js/eventEmitter.js", - "static_components/js/eventie.js", - "static_components/js/imagesloaded.js", - "shelfzilla/themes/bootflat/static/js/main.full.js", - ] - dest: "shelfzilla/themes/bootflat/static/js/site.js" - css: - src: [ - "shelfzilla/themes/bootflat/static/css/app.css", - "static_components/css/bootstrap.min.css", - "static_components/css/bootflat.min.css", - "static_components/css/nprogress.css", - "static_components/css/toastr.css", - ] - dest: "shelfzilla/themes/bootflat/static/css/style.css" - - uglify: - development: - files: - 'shelfzilla/themes/bootflat/static/js/site.js': 'shelfzilla/themes/bootflat/static/js/site.js' - - clean: - development: - src: [ - "shelfzilla/themes/bootflat/static/js/*.full.js", - ] - production: - src: [ - "shelfzilla/themes/bootflat/static/js/*.full.js", - ] - release: - src: [ - "shelfzilla/themes/bootflat/static/less", - "shelfzilla/themes/bootflat/static/coffee", - ] - watch: options: livereload: true @@ -98,35 +11,15 @@ module.exports = (grunt) -> tasks: [] less: files: ['shelfzilla/themes/bootflat/static/less/*.less'] - tasks: ['less', 'concat:css'] + tasks: [] coffee: files: ['shelfzilla/themes/bootflat/static/coffee/*.coffee'] - tasks: ['coffee', 'concat:js', 'clean:development'] + tasks: [] # Modules - grunt.loadNpmTasks 'grunt-contrib-less' - grunt.loadNpmTasks 'grunt-contrib-coffee' - grunt.loadNpmTasks 'grunt-contrib-uglify' grunt.loadNpmTasks 'grunt-contrib-watch' - grunt.loadNpmTasks 'grunt-contrib-concat' - grunt.loadNpmTasks 'grunt-contrib-clean' - grunt.loadNpmTasks 'grunt-contrib-clean' grunt.loadNpmTasks 'grunt-bower' # Tasks - grunt.registerTask 'default', [ - "bower", - "less", "coffee", "concat", "clean:development", - "watch" - ] - - grunt.registerTask 'compile', [ - "bower", - "less", "coffee", "concat", 'uglify', "clean:development" - ] - - grunt.registerTask 'build', [ - "bower", - "less", "coffee", "concat", "uglify", 'clean:production' - ] + grunt.registerTask 'default', ["watch"] diff --git a/shelfzilla/settings/base.py b/shelfzilla/settings/base.py index 9bee60b..9bbf19c 100644 --- a/shelfzilla/settings/base.py +++ b/shelfzilla/settings/base.py @@ -56,6 +56,9 @@ INSTALLED_APPS = ( 'south', 'import_export', + # Staticfiles + "compressor", + # Apps 'shelfzilla.apps._admin', 'shelfzilla.apps.config', @@ -153,6 +156,17 @@ STATICFILES_DIRS = ( os.path.join(BASE_DIR, "themes", "bootflat", "static"), ) +STATICFILES_FINDERS = ( + 'django.contrib.staticfiles.finders.FileSystemFinder', + 'django.contrib.staticfiles.finders.AppDirectoriesFinder', + 'compressor.finders.CompressorFinder', +) + +COMPRESS_PRECOMPILERS = ( + ('text/less', 'lessc {infile} {outfile}'), + ('text/coffeescript', 'coffee --compile --stdio --no-header'), +) + # Max username length (longerusername) MAX_USERNAME_LENGTH = 75 diff --git a/shelfzilla/themes/bootflat/static/less/layout.less b/shelfzilla/themes/bootflat/static/less/layout.less index a376914..bd7c642 100644 --- a/shelfzilla/themes/bootflat/static/less/layout.less +++ b/shelfzilla/themes/bootflat/static/less/layout.less @@ -1,6 +1,6 @@ body { background-color: rgb(241, 242, 246) !important; - background-image: url('../backgrounds/triangify.png'); + background-image: url('../../backgrounds/triangify.png'); background-position: center top; background-attachment: fixed; } diff --git a/shelfzilla/themes/bootflat/templates/_layout.html b/shelfzilla/themes/bootflat/templates/_layout.html index 828199c..107e436 100644 --- a/shelfzilla/themes/bootflat/templates/_layout.html +++ b/shelfzilla/themes/bootflat/templates/_layout.html @@ -1,12 +1,19 @@ -{% load i18n solo_tags staticfiles %} +{% load i18n solo_tags staticfiles compress %} {% get_solo 'config.SiteConfiguration' as site_config %} {% get_solo 'config.SocialConfiguration' as social_config %} - - {% block extra_css %}{% endblock %} + {% compress css %} + {% block stylesheets %} + + + + + + {% endblock %} + {% endcompress %} {% block page_title %}ShelfZilla{% endblock %} @@ -86,11 +93,22 @@ {% block footer %}{% endblock %} + {% compress js %} + {% block javascript %} - - {% block extra_js %}{% endblock %} + + + + + + + + + + {% endblock %} + {% endcompress %} {% if social_config.google_analytics %} {% include "_includes/google_analytics.html" %}