Skip to content

Commit

Permalink
Rename/reorg: static/default -> shared-data/default-theme
Browse files Browse the repository at this point in the history
  • Loading branch information
BjarniRunar committed Jan 3, 2016
1 parent 92ece6c commit 3caad9f
Show file tree
Hide file tree
Showing 275 changed files with 69 additions and 61 deletions.
26 changes: 13 additions & 13 deletions Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@ module.exports = function(grunt) {
separator: ';'
},
src: [
'static/default/js/libraries.js',
'static/default/js/jquery.js',
'static/default/js/moxie.js',
'static/default/js/plupload.js',
'shared-data/default-theme/js/libraries.js',
'shared-data/default-theme/js/jquery.js',
'shared-data/default-theme/js/moxie.js',
'shared-data/default-theme/js/plupload.js',
'bower_components/underscore/underscore.js',
'bower_components/jquery-timer/jquery.timer.js',
'bower_components/jquery-autosize/jquery.autosize.js',
'bower_components/mousetrap/mousetrap.js',
'static/default/js/mousetrap.global.bind.js',
'shared-data/default-theme/js/mousetrap.global.bind.js',
'bower_components/jquery.ui/ui/jquery.ui.core.js',
'bower_components/jquery.ui/ui/jquery.ui.widget.js',
'bower_components/jquery.ui/ui/jquery.ui.mouse.js',
Expand All @@ -35,7 +35,7 @@ module.exports = function(grunt) {
'bower_components/select2/select2.js',
'bower_components/dompurify/dist/purify.min.js'
],
dest: 'static/default/js/libraries.min.js'
dest: 'shared-data/default-theme/js/libraries.min.js'
}
},
uglify: {
Expand All @@ -44,7 +44,7 @@ module.exports = function(grunt) {
},
js: {
files: {
'static/default/js/libraries.min.js': ['static/default/js/libraries.min.js']
'shared-data/default-theme/js/libraries.min.js': ['static/default/js/libraries.min.js']
}
}
},
Expand All @@ -54,24 +54,24 @@ module.exports = function(grunt) {
},
style: {
files: {
"static/default/css/default.css": "static/default/less/default.less"
"shared-data/default-theme/css/default.css": "static/default/less/default.less"
}
}
},
watch: {
js: {
files: ['static/default/js/*.js'],
files: ['shared-data/default-theme/js/*.js'],
tasks: ['concat:js', 'uglify:js'],
options: {
livereload: true,
}
},
css: {
files: [
'static/default/less/config.less',
'static/default/less/default.less',
'static/default/less/app/*.less',
'static/default/less/libraries/*.less'
'shared-data/default-theme/less/config.less',
'shared-data/default-theme/less/default.less',
'shared-data/default-theme/less/app/*.less',
'shared-data/default-theme/less/libraries/*.less'
],
tasks: ['less:style'],
options: {
Expand Down
2 changes: 1 addition & 1 deletion MANIFEST.in
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,4 @@ include scripts/make-messages.sh
include scripts/mailpile-test.py
include scripts/test-sendmail.sh
include scripts/setup-test.sh
recursive-include static *
recursive-include shared-data *
16 changes: 8 additions & 8 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -129,18 +129,18 @@ bower_components:

js: bower_components
# Warning: Horrible hack to extract rules from Gruntfile.js
rm -f static/default/js/libraries.min.js
rm -f shared-data/default-theme/js/libraries.min.js
cat `cat Gruntfile.js \
|sed -e '1,/concat:/d ' \
|sed -e '1,/src:/d' -e '/dest:/,$$d' \
|grep / \
|sed -e "s/[',]/ /g"` \
>> static/default/js/mailpile-min.js.tmp
uglify -s static/default/js/mailpile-min.js.tmp \
-o static/default/js/libraries.min.js
#@cp -va static/default/js/mailpile-min.js.tmp \
# static/default/js/libraries.min.js
@rm -f static/default/js/mailpile-min.js.tmp
>> shared-data/default-theme/js/mailpile-min.js.tmp
uglify -s shared-data/default-theme/js/mailpile-min.js.tmp \
-o shared-data/default-theme/js/libraries.min.js
#@cp -va shared-data/default-theme/js/mailpile-min.js.tmp \
# shared-data/default-theme/js/libraries.min.js
@rm -f shared-data/default-theme/js/mailpile-min.js.tmp

less: less-compiler bower_components
@make -s -f scripts/less-compiler.mk
Expand All @@ -155,7 +155,7 @@ less-loop: less-compiler
less-compiler:
bower install
@cp scripts/less-compiler.in scripts/less-compiler.mk
@find static/default/less/ -name '*.less' \
@find shared-data/default-theme/less/ -name '*.less' \
|perl -npe s'/^/\t/' \
|perl -npe 's/$$/\\/' \
>>scripts/less-compiler.mk
Expand Down
1 change: 0 additions & 1 deletion default-theme

This file was deleted.

2 changes: 1 addition & 1 deletion install_hooks.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ def symlink_develop(config):
os.symlink(
os.path.join(
os.path.dirname(os.path.realpath(__file__)),
'static'
'shared-data'
),
os.path.join(sys.prefix, 'share', 'mailpile')
)
42 changes: 34 additions & 8 deletions mailpile/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -1165,15 +1165,19 @@ class MailpileJinjaLoader(BaseLoader):
def __init__(self, config):
self.config = config

def get_template_path(self, tpl):
return self.config.data_file_and_mimetype('html_theme', tpl)[0]

def get_source(self, environment, template):
tpl = os.path.join('html', template)
path, mt = self.config.data_file_and_mimetype('html_theme', tpl)

path = self.get_template_path(tpl)
if not path:
raise TemplateNotFound(tpl)

mtime = os.path.getmtime(path)
unchanged = lambda: (
path == self.config.data_file_and_mimetype('html_theme', tpl)[0]
path == self.get_template_path(tpl)[0]
and mtime == os.path.getmtime(path))

with file(path) as f:
Expand Down Expand Up @@ -1222,12 +1226,34 @@ def DEFAULT_WORKDIR(self):

return os.path.join(basedir, 'Mailpile', profile)

def __init__(self, workdir=None, rules={}):
ConfigDict.__init__(self, _rules=rules, _magic=False)
@classmethod
def DEFAULT_SHARED_DATADIR(self):
env_share = os.getenv('MAILPILE_SHARED')
if env_share is not None:
return env_share

# Check if we've been installed to /usr/local (or equivalent)
usr_local = os.path.join(sys.prefix, 'local')
if __file__.startswith(usr_local):
return os.path.join(usr_local, 'share', 'mailpile')

# If not, assume /usr/ (sys.prefix for virtualenv)
if __file__.startswith(sys.prefix):
return os.path.join(sys.prefix, 'share', 'mailpile')

# Else assume dev mode, source tree layout
return os.path.join(os.path.dirname(__file__), '..', 'shared-data')

def __init__(self, workdir=None, shareddatadir=None, rules={}):
ConfigDict.__init__(self, _rules=rules, _magic=False)

self.workdir = os.path.abspath(workdir or self.DEFAULT_WORKDIR())
mailpile.vfs.register_alias('/Mailpile', self.workdir)

self.shareddatadir = os.path.abspath(shareddatadir or
self.DEFAULT_SHARED_DATADIR())
mailpile.vfs.register_alias('/Share', self.shareddatadir)

self.vfs_root = MailpileVfsRoot(self)
mailpile.vfs.register_handler(0000, self.vfs_root)

Expand Down Expand Up @@ -2051,6 +2077,7 @@ def getLocaleDirectory(self):
"""Get the gettext translation object, no matter where our CWD is"""
# NOTE: MO files are loaded from the directory where the
# scripts reside in
# FIXME: This needs changing
return os.path.join(os.path.dirname(__file__), "locale")

def data_directory(self, ftype, mode='rb', mkdir=False):
Expand All @@ -2059,7 +2086,7 @@ def data_directory(self, ftype, mode='rb', mkdir=False):
data, optionally creating the directory if it is missing.
>>> p = cfg.data_directory('html_theme', mode='r', mkdir=False)
>>> p == os.path.abspath('mailpile/www/default')
>>> p == os.path.abspath('shared-data/default-theme')
True
"""
# This should raise a KeyError if the ftype is unrecognized
Expand All @@ -2071,16 +2098,15 @@ def data_directory(self, ftype, mode='rb', mkdir=False):
if mkdir and not os.path.exists(cpath):
os.mkdir(cpath)
else:
bpath = os.path.join(os.path.dirname(__file__),
'..', bpath)
bpath = os.path.join(self.shareddatadir, bpath)
return os.path.abspath(bpath)

def data_file_and_mimetype(self, ftype, fpath, *args, **kwargs):
# The theme gets precedence
core_path = self.data_directory(ftype, *args, **kwargs)
path, mimetype = os.path.join(core_path, fpath), None

# If there's nothing there, check our plugins
# If there's still nothing there, check our plugins
if not os.path.exists(path):
from mailpile.plugins import PluginManager
path, mimetype = PluginManager().get_web_asset(fpath, path)
Expand Down
8 changes: 1 addition & 7 deletions mailpile/defaults.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,6 @@
from mailpile.config import PublicConfigRule as p
from mailpile.config import KeyConfigRule as k

def get_share_path():
local_path = os.path.join(sys.prefix, 'local', 'share', 'mailpile')
if os.path.exists(local_path):
return local_path
return os.path.join(sys.prefix, 'share', 'mailpile')

_ = lambda string: string


Expand Down Expand Up @@ -60,7 +54,7 @@ def get_share_path():
'plugins': [_('Plugins to load on startup'),
CONFIG_PLUGINS, []],
'path': [_('Locations of assorted data'), False, {
'html_theme': [_('Default theme'), 'dir', os.path.join(get_share_path(), 'default')],
'html_theme': [_('User interface theme'), 'dir', 'default-theme'],
'vcards': [_('Location of vCards'), 'dir', 'vcards'],
'event_log': [_('Location of event log'), 'dir', 'logs'],
}],
Expand Down
16 changes: 8 additions & 8 deletions scripts/less-compiler.in
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
PATH:=$(PATH):/Applications/CodeKit.app/Contents/Resources/engines/less/bin/

all: mailpile/www/default/css/default.css \
mailpile/www/default/css/print.css
all: shared-data/default-theme/css/default.css \
shared-data/default-theme/css/print.css
@true

mailpile/www/default/css/default.css: .less-deps
@(cd mailpile/www/default/less && \
shared-data/default-theme/css/default.css: .less-deps
@(cd shared-data/default-theme/less && \
#lessc --02 -x default.less \
lessc default.less \
|perl -npe 's,(libraries|app)/,,g' \
|perl -npe 's,/mailpile/www/,../,g' \
>../css/default.css)
@ls -l mailpile/www/default/css/default.css
@ls -l shared-data/default-theme/css/default.css

mailpile/www/default/css/print.css: .less-deps
@(cd mailpile/www/default/less && lessc -x print.less >../css/print.css)
@ls -l mailpile/www/default/css/print.css
shared-data/default-theme/css/print.css: .less-deps
@(cd shared-data/default-theme/less && lessc -x print.less >../css/print.css)
@ls -l shared-data/default-theme/css/print.css

.less-deps: scripts/less-compiler.in \
12 changes: 0 additions & 12 deletions scripts/mailpile
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,4 @@ mailpile_root = os.path.dirname( # Mailpile root
sys.path.append(mailpile_root)

from mailpile.app import Main
from mailpile import defaults

# Override the config path
html_theme_path = defaults.CONFIG_RULES['sys'][2]['path'][2]['html_theme']
new_html_theme_path = (
html_theme_path[0],
html_theme_path[1],
os.path.join(mailpile_root, 'static', 'default')
)
defaults.CONFIG_RULES['sys'][2]['path'][2]['html_theme'] = new_html_theme_path


Main(sys.argv[1:])
3 changes: 2 additions & 1 deletion scripts/mailpile-admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,8 @@ def get_os_settings(args):
'mailpile': (distutils.spawn.find_executable('mailpile') or os.path.join(mp_root, 'mp')),
'mailpile-root': mp_root,
'mailpile-admin': os.path.realpath(sys.argv[0]),
'mailpile-static': os.path.join(mp_root, 'mailpile', 'www', 'default'),
'mailpile-static': os.path.join(mp_root, 'mailpile',
'shared-data', 'default-theme'),
'mailpile-www': os.path.join(mpa_root, 'www'),
'mailpile-conf': os.path.join(mpa_root, 'mailpile.conf')}

Expand Down
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ keywords =
[files]
packages = mailpile
data_files =
share/mailpile = static/*
share/mailpile = shared-data/*

[entry_points]
console_scripts =
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 comments on commit 3caad9f

Please sign in to comment.