Minify on backend

This commit is contained in:
Ruud committed 2013-04-30 13:17:03 +02:00
1 parent 12c3fc6ce3
commit 30ec8216e1
62 files changed
+17953 -737

No files matched your search

+7 -5
View File
@@ -1,10 +1,11 @@
from couchpotato.core.event import addEvent
from couchpotato.core.helpers.encoding import ss
from couchpotato.core.helpers.variable import tryInt
from couchpotato.core.logger import CPLog
from couchpotato.core.plugins.base import Plugin
from couchpotato.environment import Env
from minify.cssmin import cssmin
from minify.jsmin import jsmin
import cssprefixer
import os
import traceback
@@ -23,7 +24,6 @@ class ClientScript(Plugin):
'script': [
'scripts/library/mootools.js',
'scripts/library/mootools_more.js',
'scripts/library/prefix_free.js',
'scripts/library/uniform.js',
'scripts/library/form_replacement/form_check.js',
'scripts/library/form_replacement/form_radio.js',
@@ -69,7 +69,8 @@ class ClientScript(Plugin):
addEvent('clientscript.get_styles', self.getStyles)
addEvent('clientscript.get_scripts', self.getScripts)
addEvent('app.load', self.minify)
if not Env.get('dev'):
addEvent('app.load', self.minify)
self.addCore()
@@ -108,9 +109,10 @@ class ClientScript(Plugin):
if file_type == 'script':
data = jsmin(f)
else:
data = cssmin(f)
data = cssprefixer.process(f, debug = False, minify = True)
data = data.replace('../images/', '../static/images/')
data = data.replace('../fonts/', '../static/fonts/')
data = data.replace('../../static/', '../static/') # Replace inside plugins
raw.append({'file': file_path, 'date': int(os.path.getmtime(file_path)), 'data': data})
@@ -120,7 +122,7 @@ class ClientScript(Plugin):
data += self.comment.get(file_type) % (r.get('file'), r.get('date'))
data += r.get('data') + '\n\n'
self.createFile(out, data.strip())
self.createFile(out, ss(data.strip()))
if not self.minified.get(file_type):
self.minified[file_type] = {}
@@ -71,13 +71,13 @@
}
.profile .types .type .handle {
background: url('./handle.png') center;
background: url('../../static/profile_plugin/handle.png') center;
display: inline-block;
height: 20px;
width: 20px;
cursor: grab;
cursor: -moz-grab;
cursor: -webkit-grab;
cursor: -moz-grab;
cursor: grab;
margin: 0;
}
@@ -105,9 +105,9 @@
}
#profile_ordering li {
cursor: grab;
cursor: -moz-grab;
cursor: -webkit-grab;
cursor: -moz-grab;
cursor: grab;
border-bottom: 1px solid rgba(255,255,255,0.2);
padding: 0 5px;
}
@@ -126,7 +126,7 @@
}
#profile_ordering li .handle {
background: url('./handle.png') center;
background: url('../../static/profile_plugin/handle.png') center;
width: 20px;
float: right;
}