1. Fabian Büchler
  2. django-markupmirror

Commits

Fabian Büchler  committed f4c69a5

Introduced titles for markup types for the type selectbox.

  • Participants
  • Parent commits d7f6740
  • Branches default

Comments (0)

Files changed (11)

File .hgignore

View file
 
 dist
 build
-*.mo
 *.pyc
 *.pyo
 *.tmp*

File markupmirror/locale/de/LC_MESSAGES/django.mo

Binary file added.

File markupmirror/locale/de/LC_MESSAGES/django.po

View file
+# SOME DESCRIPTIVE TITLE.
+# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
+# This file is distributed under the same license as the PACKAGE package.
+# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
+#
+msgid ""
+msgstr ""
+"Project-Id-Version: PACKAGE VERSION\n"
+"Report-Msgid-Bugs-To: \n"
+"POT-Creation-Date: 2012-04-11 12:29+0200\n"
+"PO-Revision-Date: 2012-04-11 12:30+0100\n"
+"Last-Translator: Fabian Büchler <buechler@wienfluss.net>\n"
+"Language-Team: LANGUAGE <LL@li.org>\n"
+"Language: \n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=UTF-8\n"
+"Content-Transfer-Encoding: 8bit\n"
+"Plural-Forms: nplurals=2; plural=(n != 1)\n"
+
+#: feincms/models.py:24
+#: feincms/models.py:31
+#: feincms/models.py:32
+msgid "Markup content"
+msgstr "Markup Inhalt"
+
+#: markup/html.py:15
+msgid "HTML"
+msgstr "HTML"
+
+#: markup/markdown_.py:15
+msgid "Markdown"
+msgstr "Markdown"
+
+#: markup/plaintext.py:18
+msgid "Plain text"
+msgstr "Plaintext"
+
+#: markup/restructuredtext.py:14
+msgid "reStructuredText"
+msgstr "reStructuredText"
+
+#: markup/textile_.py:13
+msgid "Textile"
+msgstr "Textile"
+

File markupmirror/locale/en/LC_MESSAGES/django.mo

Binary file added.

File markupmirror/locale/en/LC_MESSAGES/django.po

View file
+# SOME DESCRIPTIVE TITLE.
+# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
+# This file is distributed under the same license as the PACKAGE package.
+# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
+#
+msgid ""
+msgstr ""
+"Project-Id-Version: PACKAGE VERSION\n"
+"Report-Msgid-Bugs-To: \n"
+"POT-Creation-Date: 2012-04-11 12:29+0200\n"
+"PO-Revision-Date: 2012-04-11 12:29+0100\n"
+"Last-Translator: Fabian Büchler <buechler@wienfluss.net>\n"
+"Language-Team: LANGUAGE <LL@li.org>\n"
+"Language: \n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=UTF-8\n"
+"Content-Transfer-Encoding: 8bit\n"
+
+#: feincms/models.py:24
+#: feincms/models.py:31
+#: feincms/models.py:32
+msgid "Markup content"
+msgstr "Markup content"
+
+#: markup/html.py:15
+msgid "HTML"
+msgstr "HTML"
+
+#: markup/markdown_.py:15
+msgid "Markdown"
+msgstr "Markdown"
+
+#: markup/plaintext.py:18
+msgid "Plain text"
+msgstr "Plain text"
+
+#: markup/restructuredtext.py:14
+msgid "reStructuredText"
+msgstr "reStructuredText"
+
+#: markup/textile_.py:13
+msgid "Textile"
+msgstr "Textile"
+

File markupmirror/markup/base.py

View file
 
     """
     codemirror_mode = ''
+    title = ""
 
     @classmethod
     def get_name(cls):
                 "Markups must be subclasses of "
                 "markupmirror.markup.base.BaseMarkup. %r is not."
                 % markup)
-        # check if markup was already registered
+
         markup_name = markup.get_name()
-        if markup_name in self.markups:
-            raise MarkupAlreadyRegistered(
-                "Cannot register %r. A markup with this name (%r) is "
-                "already registered." % (markup, markup_name))
-
         self.markups[markup_name] = markup()
 
     def unregister_markup(self, markup_name):
         if markup_name in self.markups:
             del self.markups[markup_name]
 
+    def has_markup(self, name):
+        return name in self.markups
+
     def get_markup(self, name):
         """Returns one markup converter by name.
-        Raises ``MarkupNotFound`` if no converter was registered by ``name``.
+        Raises ``KeyError`` if no converter was registered by ``name``.
 
         """
-        if name in self.markups:
-            return self.markups[name]
-        raise MarkupNotFound("Unknown markup %r." % name)
+        return self.markups[name]
 
-    def get_all_markups(self):
-        """Returns a dictionary of all registered markup converters."""
-        return self.markups.copy()
+    def __contains__(self, key):
+        return self.has_markup(key)
+
+    def __getitem__(self, key):
+        return self.get_markup(key)
+
+    def __delitem__(self, key):
+        self.unregister_markup(key)
 
 
 markup_pool = MarkupPool()

File markupmirror/markup/html.py

View file
+from django.utils.translation import ugettext_lazy as _
+
 from markupmirror.markup.base import BaseMarkup
 from markupmirror.markup.base import register_markup
 
 
     """
     codemirror_mode = 'text/html'
+    title = _(u"HTML")
 
 
 register_markup(HtmlMarkup)

File markupmirror/markup/markdown_.py

View file
 import logging
 
+from django.utils.translation import ugettext_lazy as _
+
 from markupmirror import settings
 from markupmirror.markup.base import BaseMarkup
 from markupmirror.markup.base import register_markup
 
     """
     codemirror_mode = 'text/x-markdown'
+    title = _(u"Markdown")
 
     def __init__(self):
         self.extensions = settings.MARKDOWN_EXTENSIONS

File markupmirror/markup/plaintext.py

View file
 from django.utils.html import linebreaks
 from django.utils.html import urlize
+from django.utils.translation import ugettext_lazy as _
 
 from markupmirror.markup.base import BaseMarkup
 from markupmirror.markup.base import register_markup
 
     """
     codemirror_mode = ''
+    title = _(u"Plain text")
 
     def convert(self, markup):
         return urlize(linebreaks(markup))

File markupmirror/markup/restructuredtext.py

View file
 from django.utils.encoding import smart_str
+from django.utils.translation import ugettext_lazy as _
 
 from markupmirror import settings
 from markupmirror.markup.base import BaseMarkup
 
     """
     codemirror_mode = 'text/x-rst'
+    title = _(u"reStructuredText")
 
     def __init__(self):
         self.filter_settings = settings.RESTRUCTUREDTEXT_FILTER

File markupmirror/markup/textile_.py

View file
+from django.utils.translation import ugettext_lazy as _
+
 from markupmirror import settings
 from markupmirror.markup.base import BaseMarkup
 from markupmirror.markup.base import register_markup
 
     """
     codemirror_mode = ''
+    title = _(u"Textile")
 
     def __init__(self):
         self.textile_settings = settings.TEXTILE_SETTINGS