From d77cfb3e6910bcf4075bb8f0097099b0223166b0 Mon Sep 17 00:00:00 2001 From: Ruud Date: Fri, 5 Dec 2014 22:30:19 +0100 Subject: [PATCH] Start CP via grunt --- Gruntfile.js | 25 +++++++++++------------ couchpotato/core/_base/clientscript.py | 36 +--------------------------------- couchpotato/static/scripts/reloader.js | 24 ----------------------- couchpotato/templates/index.html | 20 +++++++++---------- 4 files changed, 24 insertions(+), 81 deletions(-) delete mode 100644 couchpotato/static/scripts/reloader.js diff --git a/Gruntfile.js b/Gruntfile.js index 09d4e52..f678448 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -2,6 +2,8 @@ module.exports = function(grunt){ + require('time-grunt')(grunt); + // Configurable paths var config = { tmp: '.tmp', @@ -68,32 +70,30 @@ module.exports = function(grunt){ } }, + shell: { + runCouchPotato: { + command: 'python CouchPotato.py' + } + }, + // COOL TASKS ============================================================== watch: { scss: { files: ['<%= config.base %>/**/*.{scss,sass}'], - tasks: ['sass:server', 'autoprefixer', 'cssmin'], - options: { - 'livereload': true - } + tasks: ['sass:server', 'autoprefixer', 'cssmin'] }, js: { files: [ '<%= config.base %>/**/*.js' ], - tasks: ['jshint'], - options: { - 'livereload': true - } + tasks: ['jshint'] }, livereload: { options: { livereload: 35729 }, files: [ - '<%= config.base %>/{,*/}*.html', - '<%= config.tmp %>/styles/{,*/}*.css', - '<%= config.base %>/images/{,*/}*' + '<%= config.css_dest %>' ] } }, @@ -102,7 +102,7 @@ module.exports = function(grunt){ options: { logConcurrentOutput: true }, - tasks: ['sass:server', 'autoprefixer', 'cssmin', 'watch'] + tasks: ['shell:runCouchPotato', 'sass:server', 'autoprefixer', 'cssmin', 'watch'] } }); @@ -114,6 +114,7 @@ module.exports = function(grunt){ grunt.loadNpmTasks('grunt-contrib-watch'); grunt.loadNpmTasks('grunt-autoprefixer'); grunt.loadNpmTasks('grunt-concurrent'); + grunt.loadNpmTasks('grunt-shell'); grunt.registerTask('default', ['concurrent']); diff --git a/couchpotato/core/_base/clientscript.py b/couchpotato/core/_base/clientscript.py index 2074ad2..c6b1e46 100644 --- a/couchpotato/core/_base/clientscript.py +++ b/couchpotato/core/_base/clientscript.py @@ -109,7 +109,6 @@ class ClientScript(Plugin): data_combined = '' - raw = [] new_paths = [] for x in paths: file_path, url_path = x @@ -117,14 +116,7 @@ class ClientScript(Plugin): f = open(file_path, 'r').read() if not Env.get('dev'): - - if file_type == 'script': - data = f - else: - data = self.prefix(f) - data = data.replace('../images/', '../static/images/') - data = data.replace('../fonts/', '../static/fonts/') - data = data.replace('../../static/', '../static/') # Replace inside plugins + data = f data_combined += self.comment.get(file_type) % (ss(file_path), int(os.path.getmtime(file_path))) data_combined += data + '\n\n' @@ -172,29 +164,3 @@ class ClientScript(Plugin): if not self.paths[type].get(location): self.paths[type][location] = [] self.paths[type][location].append((file_path, api_path)) - - prefix_properties = ['border-radius', 'transform', 'transition', 'box-shadow'] - prefix_tags = ['ms', 'moz', 'webkit'] - - def prefix(self, data): - - trimmed_data = re.sub('(\t|\n|\r)+', '', data) - - new_data = '' - colon_split = trimmed_data.split(';') - for splt in colon_split: - curl_split = splt.strip().split('{') - for curly in curl_split: - curly = curly.strip() - for prop in self.prefix_properties: - if curly[:len(prop) + 1] == prop + ':': - for tag in self.prefix_tags: - new_data += ' -%s-%s; ' % (tag, curly) - - new_data += curly + (' { ' if len(curl_split) > 1 else ' ') - - new_data += '; ' - - new_data = new_data.replace('{ ;', '; ').replace('} ;', '} ') - - return new_data diff --git a/couchpotato/static/scripts/reloader.js b/couchpotato/static/scripts/reloader.js deleted file mode 100644 index 3f35f9e..0000000 --- a/couchpotato/static/scripts/reloader.js +++ /dev/null @@ -1,24 +0,0 @@ -var ReloaderBase = new Class({ - - initialize: function(){ - var self = this; - - App.on('watcher.changed', self.reloadFile.bind(self)); - - }, - - reloadFile: function(data){ - var self = this, - urls = data.data; - - urls.each(function(url){ - var without_timestamp = url.split('?')[0], - old_links = document.getElement('[data-url^=\''+without_timestamp+'\']'); - - old_links.set('href', old_links.get('href') + 1); - }); - } - -}); - -var Reloader = new ReloaderBase(); diff --git a/couchpotato/templates/index.html b/couchpotato/templates/index.html index d3dc4d9..be44514 100644 --- a/couchpotato/templates/index.html +++ b/couchpotato/templates/index.html @@ -2,7 +2,7 @@ - + @@ -21,22 +21,22 @@ {% if Env.get('dev') %} - + {% end %} - +