Skip to content

Commit

Permalink
Make class naming intuitively illogical (issue #547)
Browse files Browse the repository at this point in the history
  • Loading branch information
BjarniRunar committed Apr 16, 2014
1 parent 4d2fb2e commit 3631ed6
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 14 deletions.
12 changes: 11 additions & 1 deletion mailpile/plugins/__init__.py
Expand Up @@ -146,8 +146,13 @@ def _load(self, plugin_name, process_manifest=False, config=None):
path = os.path.join(dirname, filename)
if filename == '.':
self._import(full_name, dirname)
continue
elif filename.endswith('.py'):
subname = filename[:-3].replace('/', '.')
# FIXME: Is this a good idea?
if full_name.endswith('.'+subname):
self._import(full_name, path)
continue
elif os.path.isdir(path):
subname = filename.replace('/', '.')
else:
Expand Down Expand Up @@ -253,7 +258,12 @@ def _process_manifest_pass_two(self, full_name,
# Register javascript classes
for fn in manifest.get('code', {}).get('javascript', []):
class_name = fn.replace('/', '.').rsplit('.', 1)[0]
self.register_js(full_name, class_name,
# FIXME: Is this a good idea?
if full_name.endswith('.'+class_name):
parent, class_name = full_name.rsplit('.', 1)
else:
parent = full_name
self.register_js(parent, class_name,
os.path.join(plugin_path, fn))

# Register CSS files
Expand Down
4 changes: 2 additions & 2 deletions plugins/demos/demos.js
@@ -1,5 +1,5 @@
/* This is the demo plugin's javascript code!
The name of the returned class will be `mailpile.plugins.demos.demos`.
The name of the returned class will be `mailpile.plugins.demos`.
*/
return {
/* These methods are exposed to the app for various things. */
Expand All @@ -13,6 +13,6 @@ return {
'enhance' it. Here we just give it a click handler, but fancier
plugins could set up event listeners and update the element
itself based on other app activities. */
$(element).click(new_mailpile.plugins.demos.demos.activity_click);
$(element).click(new_mailpile.plugins.demos.activity_click);
}
};
15 changes: 8 additions & 7 deletions plugins/demos/manifest.json
Expand Up @@ -13,8 +13,9 @@
"author": "The Mailpile Team <team@mailpile.is>",

"code": {
# Python modules end up in the namespace mailpile.plugins.<plugin>,
# so the file demos.py becomes mailpile.plugins.demos.demos. If
# Python modules end up in the namespace mailpile.plugins.<plugin>.
# Generally, the file stuff.py becomes mailpile.plugins.demos.stuff,
# with the exception that demos.py goes straight to the root. If
# a directory is given (including "." for the plugin root dir), an
# __init__.py file is loaded per normal Pythonic conventions.
"python": ["demos.py"],
Expand Down Expand Up @@ -61,19 +62,19 @@
# These are our Python-related hooks
"commands": [
{
"class": "demos.md5sumCommand",
"class": "md5sumCommand",
"url": "md5sum",
"name": "md5sum"
}
],
"contacts": {
"importers": ["demos.DemoVCardImporter"],
"importers": ["DemoVCardImporter"],
"exporters": [],
"context": []
},
"periodic_jobs": {
"fast": [{"interval": 5, "class": "demos.TickJob"}],
"slow": [{"interval": 15, "class": "demos.TickJob"}]
"fast": [{"interval": 5, "class": "TickJob"}],
"slow": [{"interval": 15, "class": "TickJob"}]
},
"keyword_extractors": [
],
Expand All @@ -93,7 +94,7 @@
"text": "Demo",
"icon": "/static/img/demos.png",
"description": "Demonstrate the pluggable activities",
"setup": "demos.activity_setup",
"setup": "activity_setup",
"url": "#could-be-a-fallback"
}
],
Expand Down
8 changes: 4 additions & 4 deletions plugins/hacks/manifest.json
Expand Up @@ -18,19 +18,19 @@
# These are our Python-related hooks
"commands": [
{
"class": "hacks.Hacks",
"class": "Hacks",
"name": "hacks"
},
{
"class": "hacks.FixIndex",
"class": "FixIndex",
"name": "hacks/fixindex"
},
{
"class": "hacks.PyCLI",
"class": "PyCLI",
"name": "hacks/pycli"
},
{
"class": "hacks.ViewMetadata",
"class": "ViewMetadata",
"name": "hacks/metadata"
}
]
Expand Down

0 comments on commit 3631ed6

Please sign in to comment.