Skip to content

Commit

Permalink
Merge branch 'master' into release/1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
BjarniRunar committed Jan 20, 2018
2 parents e682831 + aab6957 commit 3163aab
Show file tree
Hide file tree
Showing 34 changed files with 802 additions and 284 deletions.
8 changes: 6 additions & 2 deletions mailpile/config/defaults.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
_ = lambda string: string


DEV_MODE = ('rc' in APPVER or 'dev' in APPVER or 'github' in APPVER)
DEFAULT_SENDMAIL = '|/usr/sbin/sendmail -i %(rcpt)s'
CONFIG_PLUGINS = []
CONFIG_RULES = {
Expand Down Expand Up @@ -79,7 +80,8 @@
'num_results': (_('Search results per page'), int, 20),
'rescan_interval': (_('Misc. data refresh frequency'), int, 900),
'open_in_browser':p(_('Open in browser on startup'), bool, True),
'auto_mark_as_read': p(_('Automatically mark as read'), bool, True),
'auto_mark_as_read': p(_('Automatically mark e-mail as read'),
bool, True),
'web_content': (_('Download content from the web'),
["off", "anon", "on"], "unknown"),
'html5_sandbox': (_('Use HTML5 sandboxes'), bool, True),
Expand Down Expand Up @@ -110,7 +112,7 @@
str, 'none'),
'inline_pgp': (_('Use inline PGP when possible'), bool, True),
'encrypt_subject': (_('Encrypt subjects by default'), bool, True),
'default_order': (_('Default sort order'), str, 'rev-freshness'),
'default_order': (_('Default sort order'), str, 'rev-date'),
'obfuscate_index':X(_('Key to use to scramble the index'), str, ''),
'index_encrypted':X(_('Make encrypted content searchable'),
bool, False),
Expand All @@ -136,6 +138,8 @@
}],
}),
'web': (_("Web Interface Preferences"), False, {
'keybindings': (_('Enable keyboard short-cuts'), bool, False),
'developer_mode': (_('Enable developer-only features'), bool, DEV_MODE),
'setup_complete': (_('User completed setup experience'), bool, False),
'display_density': (_('Display density of interface'), str, 'comfy'),
'quoted_reply': (_('Quote replies to messages'), str, 'unset'),
Expand Down
3 changes: 2 additions & 1 deletion mailpile/config/manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -443,7 +443,8 @@ def _unlocked_load(self, session):

# Configure and load plugins as per config requests
with mailpile.i18n.i18n_disabled:
self._configure_default_plugins()
if self.loaded_config:
self._configure_default_plugins()
self.load_plugins(session)

# Now all the plugins are loaded, reset and parse again!
Expand Down
2 changes: 1 addition & 1 deletion mailpile/plugins/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ class PluginManager(object):
]
# Plugins we want, if they are discovered
WANTED = [
'autoajax', 'print', 'datadig', 'hints'
'autoajax', 'print', 'hints'
]
# Plugins that have been renamed from past releases
RENAMED = {
Expand Down
24 changes: 22 additions & 2 deletions mailpile/plugins/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -1028,6 +1028,22 @@ def errors(where):

##[ Configuration commands ]###################################################


class ListLanguages(Command):
"""List available languages"""
SYNOPSIS = (None, 'languages', 'settings/languages', '')
ORDER = ('Config', 1)
CONFIG_REQUIRED = False
IS_USER_ACTIVITY = False
HTTP_CALLABLE = ('GET', )

def command(self):
from mailpile.i18n import ListTranslations
langs = ListTranslations(self.session.config)
return self._success(_('Listed available translations'),
result=sorted([(l, langs[l]) for l in langs]))


class ConfigSet(Command):
"""Change a setting"""
SYNOPSIS = ('S', 'set', 'settings/set',
Expand Down Expand Up @@ -1660,10 +1676,14 @@ class Quit(Command):
ORDER = ("Internals", 2)
CONFIG_REQUIRED = False
RAISES = (KeyboardInterrupt,)
HTTP_CALLABLE = ('POST',)
HTTP_POST_VARS = {
'restart': 'Set to restart instead of shutting down'
}
COMMAND_SECURITY = security.CC_QUIT

def command(self):
if 'restart' in self.args:
if 'restart' in self.args or self.data.get('restart', [False])[0]:
mailpile.util.QUITTING = 'restart'
else:
mailpile.util.QUITTING = mailpile.util.QUITTING or True
Expand Down Expand Up @@ -1993,6 +2013,6 @@ def command(self, interactive=True):
BrowseOrLaunch, RunWWW, ProgramStatus, CronStatus, HealthCheck,
GpgCommand, ListDir, ChangeDir, CatFile, WritePID, Cleanup,
ConfigPrint, ConfigSet, ConfigAdd, ConfigUnset, ConfigureMailboxes,
RenderPage, Output, Pipe,
ListLanguages, RenderPage, Output, Pipe,
Help, HelpVars, HelpSplash, Quit, IdleQuit, TrustingQQQ, Abort
)
27 changes: 18 additions & 9 deletions mailpile/plugins/plugins.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class Plugins(mailpile.commands.Command):
"""List the currently available plugins."""
SYNOPSIS = (None, 'plugins', None, '[<plugins>]')
ORDER = ('Config', 9)
HTTP_CALLABLE = ()
HTTP_CALLABLE = ('GET',)

def command(self):
pm = self.session.config.plugins
Expand All @@ -34,20 +34,25 @@ def command(self):

class LoadPlugin(mailpile.commands.Command):
"""Load and enable a given plugin."""
SYNOPSIS = (None, 'plugins/load', None, '<plugin>')
SYNOPSIS = (None, 'plugins/load', 'plugins/load', '<plugin>')
ORDER = ('Config', 9)
HTTP_CALLABLE = ()
HTTP_CALLABLE = ('POST',)
HTTP_POST_VARS = {
'plugin': '<plugin name>'
}
COMMAND_SECURITY = security.CC_CHANGE_CONFIG

def command(self):
config = self.session.config
plugins = config.plugins
for plugin in self.args:
args = list(self.args) + self.data.get('plugin', [])

for plugin in args:
if plugin in plugins.LOADED:
return self._error(_('Already loaded: %s') % plugin,
info={'loaded': plugin})

for plugin in self.args:
for plugin in args:
try:
# FIXME: This fails to update the ConfigManger
if plugins.load(plugin, process_manifest=True, config=config):
Expand All @@ -66,22 +71,26 @@ def command(self):

class DisablePlugin(mailpile.commands.Command):
"""Disable a plugin."""
SYNOPSIS = (None, 'plugins/disable', None, '<plugin>')
SYNOPSIS = (None, 'plugins/disable', 'plugins/disable', '<plugin>')
ORDER = ('Config', 9)
HTTP_CALLABLE = ()
HTTP_CALLABLE = ('POST',)
HTTP_POST_VARS = {
'plugin': '<plugin name>'
}
COMMAND_SECURITY = security.CC_CHANGE_CONFIG

def command(self):
config = self.session.config
plugins = config.plugins
for plugin in self.args:
args = list(self.args) + self.data.get('plugin', [])
for plugin in args:
if plugin in plugins.REQUIRED:
return self._error(_('Required plugins can not be disabled: %s'
) % plugin)
if plugin not in config.sys.plugins:
return self._error(_('Plugin not loaded: %s') % plugin)

for plugin in self.args:
for plugin in args:
while plugin in config.sys.plugins:
config.sys.plugins.remove(plugin)

Expand Down
7 changes: 6 additions & 1 deletion mailpile/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -842,7 +842,12 @@ def dict_merge(*dicts):

def play_nice(niceness):
if hasattr(os, 'nice'):
os.nice(niceness)
try:
# Note: This fails on WSL (the "native" Ubuntu on Windows)
return os.nice(niceness)
except OSError:
pass
# FIXME: Try alternate strategies on other platforms?


def play_nice_with_threads(sleep=True, weak=False, deadline=None):
Expand Down
5 changes: 2 additions & 3 deletions mailpile/www/jinjaextensions.py
Original file line number Diff line number Diff line change
Expand Up @@ -690,9 +690,8 @@ def _random(self, sequence):
def _truthy(cls, txt, default=False):
return truthy(txt, default=default)

@classmethod
def _is_dev_version(cls):
return ('dev' in APPVER or 'github' in APPVER or 'test' in APPVER)
def _is_dev_version(self):
return (self.env.session.config.web.developer_mode)

def _is_configured(self):
return (self.env.session.config.prefs.web_content != "unknown")
Expand Down
4 changes: 3 additions & 1 deletion shared-data/contrib/datadig/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
{
"name": "datadig",
"author": "The Mailpile Team <[email protected]>",
"description": "Poor-man's data-mining: extract tabular (spreadsheet) data from e-mail.",
"description": "Poor-man's data-mining! This plugin adds a selection action for extracting data from e-mail. The extracted data can be downloaded as CSV and imported into standard spreadsheet applications.",
"display": true,
"public": true,

"config": {},
"code": {
Expand Down
3 changes: 3 additions & 0 deletions shared-data/contrib/hacks/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
{
"name": "hacks",
"author": "The Mailpile Team <[email protected]>",
"description": "Tools for hackers and developers. This plugin adds some low-level CLI commands for exploring Mailpile data structures and internals.",
"display": true,
"public": false,
"code": {
"python": ["hacks.py"],
"javascript": [],
Expand Down
7 changes: 3 additions & 4 deletions shared-data/contrib/hints/hints.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,10 @@ class hintsCommand(Command):
'/page/hints/spambayes.html',
BrokenSpambayes),

# FIXME: We should track whether the user is actually USING keyboard
# shortcuts, and not bother them if that is the case.
('keyboard', 4, 180,
_('Mailpile has keyboard short-cuts!'),
"javascript:Mailpile.plugins.hints.keybindings();"),
_('Mailpile has keyboard shortcuts!'),
"/page/hints/keyboard-shortcuts.html",
lambda cfg, cgx: not cfg.web.keybindings),

# Remind the user to manage their spam every 3 months.
# FIXME: Allow user to somehow say "I know, shutup".
Expand Down
27 changes: 27 additions & 0 deletions shared-data/contrib/hints/hints/keyboard-shortcuts.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{% extends "layouts/" + render_mode + "-tall.html" %}
{% block title %}{{_("Keyboard Shortcuts")}}{% endblock %}
{% block content %}
<div class="content-normal" style="max-width: 46em;">

<h1><span class="icon-lightbulb"></span>
{{_("Keyboard Shortcuts")}}
</h1>
<p>
{{_("Mailpile has keyboard shortcuts which let you perform common operations using only the keyboard.")}}
{{_("These are disabled by default to prevent random key presses from causing accidents.")}}
</p>
<p>
{{_("Once keyboard shortcuts have been enabled, you can press `?` at any time to get help.")}}
</p>
<p>
{{_("To enable keyboard shortcuts, visit the preferences page.")}}<br>
<a data-dismiss="modal" href="/settings/preferences.html">
<button class="button-secondary right">
<span class="icon icon-animals"></span>
{{_("Preferences")}}
</button>
</a>
</p>

</div>
{% endblock %}
4 changes: 4 additions & 0 deletions shared-data/contrib/hints/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
{
"name": "hints",
"author": "The Mailpile Team <[email protected]>",
"description": "Incremental learning! This plugin provides periodic tips and hints on how to make the most of your Mailpile.",
"display": true,
"public": true,
"code": {
"python": ["hints.py"],
"javascript": ["hints.js"]
Expand All @@ -14,6 +17,7 @@
"/page/hints/gravatar.html": {"file": "hints/gravatar.html"},
"/page/hints/spam.html": {"file": "hints/spam.html"},
"/page/hints/spambayes.html": {"file": "hints/spambayes.html"},
"/page/hints/keyboard-shortcuts.html": {"file": "hints/keyboard-shortcuts.html"},
"/page/hints/autotagging.html": {"file": "hints/autotagging.html"}
},
"user_interface": {
Expand Down
2 changes: 1 addition & 1 deletion shared-data/contrib/print
Submodule print updated 1 files
+3 −0 manifest.json
4 changes: 4 additions & 0 deletions shared-data/default-theme/html/contacts/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
</div>
{% endblock %}
{% block content %}
{% if 0 and is_dev_version() %}
<h2>
IMPORTANT: This page is unfinished. Please don't be surprised by bugs.
</h2>
Expand Down Expand Up @@ -69,5 +70,8 @@ <h5>{% if result.total > 1 %}{{result.start}} - {{result.end}} {{_("of")}} {{res
Mailpile.Contacts.init();
});
</script>
{% else %}
{{ mailpile('http/redirect', U('/')) }}
{% endif %}
{% endblock %}

2 changes: 1 addition & 1 deletion shared-data/default-theme/html/jsapi/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
{% include("jsapi/compose/body.js") %}

/* JS - Contacts */
{% if is_dev_version() %}
{% if 0 and is_dev_version() %}
{% include("jsapi/contacts/init.js") %}
{% include("jsapi/contacts/display_modes.js") %}
{% include("jsapi/contacts/events.js") %}
Expand Down
1 change: 1 addition & 0 deletions shared-data/default-theme/html/jsapi/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,7 @@ Mailpile.API = {
var advice = ((document.location.href.indexOf('/localhost:') == -1)
? '{{_("Check your network?")|escapejs}}'
: '{{_("Restart the app?")|escapejs}}');
if (status == "user") advice = "";
if (fullscreen) {
if (!$('#connection-down').length) {
var template = Mailpile.safe_template($('#template-connection-down').html());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ <h4 class="modal-title">
class="searchkey-result-item animated fadeIn">
<div class="clearfix">
<div class="avatar"
{%- if is_dev_version() %}
{%- if 0 and is_dev_version() %}
href="{{ U('/contacts/view/') }}<%= recipient.address %>/"
{%- endif %}
target="_blank">
Expand Down
2 changes: 2 additions & 0 deletions shared-data/default-theme/html/jsapi/ui/global.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,10 @@ Mailpile.render = function() {
$('#sidebar-tag-outbox').show();
}

{% if config.web.keybindings %}
// Initialize/Configure Keybindings
Mailpile.initialize_keybindings();
{% endif %}

// This fixes some of the drag-drop misbehaviours; first we disable the
// native HTML5 drag-drop of <a> elements...
Expand Down
37 changes: 5 additions & 32 deletions shared-data/default-theme/html/logs/layout.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@

{%- block contenttools %}
{%- set activities = [{
'name': 'privacy',
'name': 'settings',
'icon': 'settings',
'url': U('/settings/privacy.html'),
'text': _("Privacy"),
'description': _("Security and Privacy Settings")
'url': U('/settings/'),
'text': _("Settings"),
'description': _("Settings and Technical Tools")
},{
'name': 'notifications',
'icon': 'notifications',
Expand All @@ -19,35 +19,8 @@
'url': U('/logs/network/'),
'text': _("Network"),
'description': _("Recent Network Activity")
},{
'name': 'tls',
'icon': 'links',
'aclass': 'auto-modal auto-modal-sticky',
'url': U('/crypto/tls/getcert/'),
'text': _("TLS Certs"),
'description': _("TLS Certificate Tool")
},{
'name': 'passwords',
'icon': 'user',
'aclass': 'auto-modal auto-modal-sticky',
'url': U('/settings/set/password/'),
'text': _("Passwords"),
'description': _("Account Password Management")
},{
'name': 'keys',
'icon': 'key',
'aclass': 'auto-modal auto-modal-sticky',
'url': U('/settings/set/password/keys.html'),
'text': _("Keys"),
'description': _("Encryption Key Management")
},{
'name': 'terminal',
'icon': 'robot',
'url': 'javascript:Mailpile.Terminal.toggle("small")',
'text': _("CLI"),
'description': _("Command Line Interface")
}] %}
{%- set selection_initial_prompt = _("System activity, logs, events, troubleshooting, ...") %}
{%- set selection_initial_prompt = _("Settings, logs, events, troubleshooting, ...") %}
{%- include("partials/tools_default.html") %}
{%- endblock %}

Expand Down
Loading

0 comments on commit 3163aab

Please sign in to comment.