Browse Source

Migrated from grunt to django-compressor

crawlers/norma
Felipe Martín 7 years ago
parent
commit
b86d599f19
  1. 2
      .gitignore
  2. 3
      config/requirements.txt
  3. 113
      gruntfile.coffee
  4. 14
      shelfzilla/settings/base.py
  5. 2
      shelfzilla/themes/bootflat/static/less/layout.less
  6. 28
      shelfzilla/themes/bootflat/templates/_layout.html

2
.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

3
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

113
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"]

14
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

2
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;
}

28
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 %}
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="{% static "css/style.css" %}" />
{% block extra_css %}{% endblock %}
{% compress css %}
{% block stylesheets %}
<link rel="stylesheet" href="{% static "bower/Bootflat/css/bootstrap.min.css" %}" type="text/css" />
<link rel="stylesheet" href="{% static "bower/Bootflat/bootflat/css/bootflat.css" %}" type="text/css" />
<link rel="stylesheet" href="{% static "bower/nprogress/nprogress.css" %}" type="text/css" />
<link rel="stylesheet" href="{% static "bower/toastr/toastr.css" %}" type="text/css" />
<link rel="stylesheet" href="{% static "less/app.less" %}" type="text/less" />
{% endblock %}
{% endcompress %}
<title>{% block page_title %}ShelfZilla{% endblock %}</title>
</head>
<body>
@ -86,11 +93,22 @@
</div>
{% block footer %}{% endblock %}
{% compress js %}
{% block javascript %}
<script type="text/javascript">
var USE_PJAX = {{ site_config.use_pjax|lower }};
</script>
<script src="{% static "js/site.js" %}"></script>
{% block extra_js %}{% endblock %}
<script type="text/javascript" src="{% static "bower/jquery/dist/jquery.js" %}"></script>
<script type="text/javascript" src="{% static "bower/Bootflat/js/bootstrap.min.js" %}"></script>
<script type="text/javascript" src="{% static "bower/jquery-pjax/jquery.pjax.js" %}"></script>
<script type="text/javascript" src="{% static "bower/nprogress/nprogress.js" %}"></script>
<script type="text/javascript" src="{% static "bower/toastr/toastr.js" %}"></script>
<script type="text/javascript" src="{% static "bower/EventEmitter/EventEmitter.js" %}"></script>
<script type="text/javascript" src="{% static "bower/eventie/eventie.js" %}"></script>
<script type="text/javascript" src="{% static "bower/imagesloaded/imagesloaded.js" %}"></script>
<script type="text/coffeescript" src="{% static "coffee/main.coffee" %}"></script>
{% endblock %}
{% endcompress %}
{% if social_config.google_analytics %}
{% include "_includes/google_analytics.html" %}