diff --git a/wiki/core/plugins/loader.py b/wiki/core/plugins/loader.py index da5a2baaa..3aff68b6a 100644 --- a/wiki/core/plugins/loader.py +++ b/wiki/core/plugins/loader.py @@ -35,4 +35,4 @@ def load(modname, verbose=False, failfast=False): get_module(app, modname, verbose, failfast) def load_wiki_plugins(): - load('wiki_plugin', verbose=False) + load('wiki_plugin', verbose=True, failfast=False) diff --git a/wiki/models/__init__.py b/wiki/models/__init__.py index 9479fb92e..e4ddee439 100644 --- a/wiki/models/__init__.py +++ b/wiki/models/__init__.py @@ -43,15 +43,6 @@ warnings.warn("django-wiki: No south in your INSTALLED_APPS. This is highly discouraged.") -###################### -# PLUGINS -###################### - -from wiki.core.plugins.loader import load_wiki_plugins - -load_wiki_plugins() - - from django.core import urlresolvers original_django_reverse = urlresolvers.reverse diff --git a/wiki/plugins/attachments/urls.py b/wiki/plugins/attachments/urls.py new file mode 100644 index 000000000..7a2373638 --- /dev/null +++ b/wiki/plugins/attachments/urls.py @@ -0,0 +1,15 @@ +from django.conf.urls import patterns, url + +from wiki.plugins.attachments import views + +urlpatterns = patterns('', + url(r'^$', views.AttachmentView.as_view(), name='attachments_index'), + url(r'^search/$', views.AttachmentSearchView.as_view(), name='attachments_search'), + url(r'^add/(?P\d+)/$', views.AttachmentAddView.as_view(), name='attachments_add'), + url(r'^replace/(?P\d+)/$', views.AttachmentReplaceView.as_view(), name='attachments_replace'), + url(r'^history/(?P\d+)/$', views.AttachmentHistoryView.as_view(), name='attachments_history'), + url(r'^download/(?P\d+)/$', views.AttachmentDownloadView.as_view(), name='attachments_download'), + url(r'^delete/(?P\d+)/$', views.AttachmentDeleteView.as_view(), name='attachments_delete'), + url(r'^download/(?P\d+)/revision/(?P\d+)/$', views.AttachmentDownloadView.as_view(), name='attachments_download'), + url(r'^change/(?P\d+)/revision/(?P\d+)/$', views.AttachmentChangeRevisionView.as_view(), name='attachments_revision_change'), +) \ No newline at end of file diff --git a/wiki/plugins/attachments/wiki_plugin.py b/wiki/plugins/attachments/wiki_plugin.py index f5d16ea7e..f15659242 100644 --- a/wiki/plugins/attachments/wiki_plugin.py +++ b/wiki/plugins/attachments/wiki_plugin.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -from django.conf.urls import patterns, url +from django.conf.urls import patterns, url, include from django.utils.translation import ugettext as _ from wiki.core.plugins import registry @@ -11,20 +11,13 @@ from wiki.plugins.notifications.settings import ARTICLE_EDIT from wiki.plugins.notifications.util import truncate_title + class AttachmentPlugin(BasePlugin): slug = settings.SLUG urlpatterns = { 'article': patterns('', - url(r'^$', views.AttachmentView.as_view(), name='attachments_index'), - url(r'^search/$', views.AttachmentSearchView.as_view(), name='attachments_search'), - url(r'^add/(?P\d+)/$', views.AttachmentAddView.as_view(), name='attachments_add'), - url(r'^replace/(?P\d+)/$', views.AttachmentReplaceView.as_view(), name='attachments_replace'), - url(r'^history/(?P\d+)/$', views.AttachmentHistoryView.as_view(), name='attachments_history'), - url(r'^download/(?P\d+)/$', views.AttachmentDownloadView.as_view(), name='attachments_download'), - url(r'^delete/(?P\d+)/$', views.AttachmentDeleteView.as_view(), name='attachments_delete'), - url(r'^download/(?P\d+)/revision/(?P\d+)/$', views.AttachmentDownloadView.as_view(), name='attachments_download'), - url(r'^change/(?P\d+)/revision/(?P\d+)/$', views.AttachmentChangeRevisionView.as_view(), name='attachments_revision_change'), + url('', include('wiki.plugins.attachments.urls')), ) } @@ -33,12 +26,18 @@ class AttachmentPlugin(BasePlugin): # List of notifications to construct signal handlers for. This # is handled inside the notifications plugin. - notifications = [{'model': models.AttachmentRevision, - 'message': lambda obj: (_(u"A file was changed: %s") if not obj.deleted else _(u"A file was deleted: %s")) % truncate_title(obj.get_filename()), - 'key': ARTICLE_EDIT, - 'created': True, - 'get_article': lambda obj: obj.attachment.article} - ] + notifications = [{ + 'model': models.AttachmentRevision, + 'message': lambda obj: ( + _(u"A file was changed: %s") + if not obj.deleted + else + _(u"A file was deleted: %s") + ) % truncate_title(obj.get_filename()), + 'key': ARTICLE_EDIT, + 'created': True, + 'get_article': lambda obj: obj.attachment.article} + ] markdown_extensions = [AttachmentExtension()] diff --git a/wiki/plugins/highlighter/THIS_PLUGIN_IS_JUST_A_TODO b/wiki/plugins/highlighter/THIS_PLUGIN_IS_JUST_A_TODO new file mode 100644 index 000000000..f60078404 --- /dev/null +++ b/wiki/plugins/highlighter/THIS_PLUGIN_IS_JUST_A_TODO @@ -0,0 +1 @@ +nothing in here, don't use it! \ No newline at end of file diff --git a/wiki/plugins/links/mdx/djangowikilinks.py b/wiki/plugins/links/mdx/djangowikilinks.py index 9de868648..01b2cd47f 100755 --- a/wiki/plugins/links/mdx/djangowikilinks.py +++ b/wiki/plugins/links/mdx/djangowikilinks.py @@ -24,6 +24,8 @@ import markdown from os import path as os_path +from wiki import models + try: # Markdown 2.1.0 changed from 2.0.3. We try importing the new version first, # but import the 2.0.3 version if it fails @@ -35,9 +37,9 @@ class WikiPathExtension(markdown.Extension): def __init__(self, configs): # set extension defaults self.config = { - 'base_url' : ['/', 'String to append to beginning of URL.'], - 'html_class' : ['wikipath', 'CSS hook. Leave blank for none.'], - 'default_level' : [2, 'The level that most articles are created at. Relative links will tend to start at that level.'] + 'base_url' : ['/', 'String to append to beginning of URL.'], + 'html_class' : ['wikipath', 'CSS hook. Leave blank for none.'], + 'default_level' : [2, 'The level that most articles are created at. Relative links will tend to start at that level.'] } # Override defaults with user settings @@ -60,7 +62,6 @@ def __init__(self, pattern, config, **kwargs): self.config = config def handleMatch(self, m) : - from wiki import models article_title = m.group('wikiTitle') absolute = False if article_title.startswith("/"): @@ -131,6 +132,3 @@ def _getMeta(self): def makeExtension(configs=None) : return WikiPathExtension(configs=configs) -if __name__ == "__main__": - import doctest - doctest.testmod() diff --git a/wiki/plugins/links/views.py b/wiki/plugins/links/views.py index f17578d84..fd47f2c32 100644 --- a/wiki/plugins/links/views.py +++ b/wiki/plugins/links/views.py @@ -2,6 +2,8 @@ from django.views.generic.base import View from django.utils.decorators import method_decorator +from wiki import models + class QueryUrlPath(View): # TODO: get_article does not actually support JSON responses @@ -11,7 +13,6 @@ def dispatch(self, request, article, *args, **kwargs): max_num = kwargs.pop('max_num', 20) # TODO: Move this import when circularity issue is resolved # https://github.com/benjaoming/django-wiki/issues/23 - from wiki import models query = request.GET.get('query', None) if query: diff --git a/wiki/plugins/notifications/forms.py b/wiki/plugins/notifications/forms.py index 44031e565..37cb86dbe 100644 --- a/wiki/plugins/notifications/forms.py +++ b/wiki/plugins/notifications/forms.py @@ -10,6 +10,7 @@ from wiki.plugins.notifications.settings import ARTICLE_EDIT from wiki.core.plugins.base import PluginSettingsFormMixin +from wiki.plugins.notifications import models class SettingsModelChoiceField(forms.ModelChoiceField): def label_from_instance(self, obj): @@ -31,7 +32,6 @@ def label_from_instance(self, obj): class SettingsModelForm(forms.ModelForm): def __init__(self, *args, **kwargs): super(SettingsModelForm, self).__init__(*args, **kwargs) - import models instance = kwargs.get('instance', None) self.__editing_instance = False if instance: @@ -120,9 +120,6 @@ class SubscriptionForm(PluginSettingsFormMixin, forms.Form): def __init__(self, article, request, *args, **kwargs): - # This has to be here to avoid unresolved imports in wiki_plugins - from wiki.plugins.notifications import models - self.article = article self.user = request.user initial = kwargs.pop('initial', None) @@ -160,9 +157,6 @@ def get_usermessage(self): def save(self, *args, **kwargs): - # This has to be here to avoid unresolved imports in wiki_plugins - from wiki.plugins.notifications import models - cd = self.cleaned_data if not self.changed_data: return diff --git a/wiki/urls.py b/wiki/urls.py index 6337831e5..ee3854add 100644 --- a/wiki/urls.py +++ b/wiki/urls.py @@ -144,3 +144,14 @@ def get_pattern(app_name="wiki", namespace="wiki", url_config_class=None): url_config_class = get_class_from_str(url_config_classname) urlpatterns = url_config_class().get_urls() return urlpatterns, app_name, namespace + + +###################### +# PLUGINS +###################### + +from wiki.core.plugins.loader import load_wiki_plugins + +load_wiki_plugins() + +