Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

We’re showing branches in this repository, but you can also compare across forks.

...
  • 12 commits
  • 123 files changed
  • 0 commit comments
  • 2 contributors
Commits on Mar 01, 2011
James Turk turn deprecation into ValueError 6fd23d5
James Turk 1.1.0 number ff14b07
Commits on Nov 28, 2012
James Turk moving towards Python 3 support 12509a6
James Turk merge against other 1.1 branch, oops 1a9e8ff
James Turk edit test to work on pre-Django 1.5 and travis to test on 1.5 2a81141
James Turk add py3 test a05c551
Commits on Dec 20, 2012
Dmitry Voronin dimka665 Module renamed
--HG--
rename : markupfield/__init__.py => markitup_field/__init__.py
rename : markupfield/fields.py => markitup_field/fields.py
rename : markupfield/markup.py => markitup_field/markup.py
rename : markupfield/tests/__init__.py => markitup_field/tests/__init__.py
rename : markupfield/tests/models.py => markitup_field/tests/models.py
rename : markupfield/tests/run_tests.sh => markitup_field/tests/run_tests.sh
rename : markupfield/tests/settings.py => markitup_field/tests/settings.py
rename : markupfield/tests/tests.py => markitup_field/tests/tests.py
rename : markupfield/widgets.py => markitup_field/widgets.py
f103730
Dmitry Voronin dimka665 Added MarkItUp editor and preview d7eb445
Commits on Dec 21, 2012
Dmitry Voronin dimka665 Update README.rst dd43ddb
Dmitry Voronin dimka665 Update distribution ae243ff
Dmitry Voronin dimka665 Fix error in README.rst.
Pypi showed it as plain text.
b110e08
Commits on Dec 29, 2012
Dmitry Voronin dimka665 setup.py fixed 8678790
Showing with 1,955 additions and 127 deletions.
  1. +11 −0 .hgignore
  2. +10 −5 .travis.yml
  3. +17 −0 AUTHORS.txt
  4. +9 −0 CHANGELOG
  5. +33 −0 LICENSE
  6. +6 −3 MANIFEST.in
  7. +51 −35 README.rst
  8. 0  {markupfield → markitup_field}/__init__.py
  9. +78 −53 {markupfield → markitup_field}/fields.py
  10. +1 −0  markitup_field/management/__init__.py
  11. +1 −0  markitup_field/management/commands/__init__.py
  12. +39 −0 markitup_field/management/commands/dice_markup_build_css.py
  13. +16 −8 {markupfield → markitup_field}/markup.py
  14. +28 −0 markitup_field/settings.py
  15. +25 −0 markitup_field/static/markitup/ajax_csrf.js
  16. +563 −0 markitup_field/static/markitup/jquery.markitup.js
  17. +5 −0 markitup_field/static/markitup/preview.css
  18. BIN  markitup_field/static/markitup/sets/default/images/bold.png
  19. BIN  markitup_field/static/markitup/sets/default/images/clean.png
  20. BIN  markitup_field/static/markitup/sets/default/images/image.png
  21. BIN  markitup_field/static/markitup/sets/default/images/italic.png
  22. BIN  markitup_field/static/markitup/sets/default/images/link.png
  23. BIN  markitup_field/static/markitup/sets/default/images/picture.png
  24. BIN  markitup_field/static/markitup/sets/default/images/preview.png
  25. BIN  markitup_field/static/markitup/sets/default/images/stroke.png
  26. +27 −0 markitup_field/static/markitup/sets/default/set.js
  27. +27 −0 markitup_field/static/markitup/sets/default/style.css
  28. BIN  markitup_field/static/markitup/sets/markdown/images/bold.png
  29. BIN  markitup_field/static/markitup/sets/markdown/images/code.png
  30. BIN  markitup_field/static/markitup/sets/markdown/images/h1.png
  31. BIN  markitup_field/static/markitup/sets/markdown/images/h2.png
  32. BIN  markitup_field/static/markitup/sets/markdown/images/h3.png
  33. BIN  markitup_field/static/markitup/sets/markdown/images/h4.png
  34. BIN  markitup_field/static/markitup/sets/markdown/images/h5.png
  35. BIN  markitup_field/static/markitup/sets/markdown/images/h6.png
  36. BIN  markitup_field/static/markitup/sets/markdown/images/italic.png
  37. BIN  markitup_field/static/markitup/sets/markdown/images/link.png
  38. BIN  markitup_field/static/markitup/sets/markdown/images/list-bullet.png
  39. BIN  markitup_field/static/markitup/sets/markdown/images/list-numeric.png
  40. BIN  markitup_field/static/markitup/sets/markdown/images/picture.png
  41. BIN  markitup_field/static/markitup/sets/markdown/images/preview.png
  42. BIN  markitup_field/static/markitup/sets/markdown/images/quotes.png
  43. +11 −0 markitup_field/static/markitup/sets/markdown/readme.txt
  44. +54 −0 markitup_field/static/markitup/sets/markdown/set.js
  45. +54 −0 markitup_field/static/markitup/sets/markdown/style.css
  46. BIN  markitup_field/static/markitup/sets/restructuredtext/images/bold.png
  47. BIN  markitup_field/static/markitup/sets/restructuredtext/images/close.png
  48. BIN  markitup_field/static/markitup/sets/restructuredtext/images/code.png
  49. BIN  markitup_field/static/markitup/sets/restructuredtext/images/h1.png
  50. BIN  markitup_field/static/markitup/sets/restructuredtext/images/h2.png
  51. BIN  markitup_field/static/markitup/sets/restructuredtext/images/h3.png
  52. BIN  markitup_field/static/markitup/sets/restructuredtext/images/h4.png
  53. BIN  markitup_field/static/markitup/sets/restructuredtext/images/h5.png
  54. BIN  markitup_field/static/markitup/sets/restructuredtext/images/h6.png
  55. BIN  markitup_field/static/markitup/sets/restructuredtext/images/italic.png
  56. BIN  markitup_field/static/markitup/sets/restructuredtext/images/link.png
  57. BIN  markitup_field/static/markitup/sets/restructuredtext/images/list-bullet.png
  58. BIN  markitup_field/static/markitup/sets/restructuredtext/images/list-numeric.png
  59. BIN  markitup_field/static/markitup/sets/restructuredtext/images/picture.png
  60. BIN  markitup_field/static/markitup/sets/restructuredtext/images/preview.png
  61. BIN  markitup_field/static/markitup/sets/restructuredtext/images/quotes.png
  62. +53 −0 markitup_field/static/markitup/sets/restructuredtext/set.js
  63. +53 −0 markitup_field/static/markitup/sets/restructuredtext/style.css
  64. +1 −0  markitup_field/static/markitup/sets/style.css
  65. BIN  markitup_field/static/markitup/sets/textile/images/bold.png
  66. BIN  markitup_field/static/markitup/sets/textile/images/code.png
  67. BIN  markitup_field/static/markitup/sets/textile/images/h1.png
  68. BIN  markitup_field/static/markitup/sets/textile/images/h2.png
  69. BIN  markitup_field/static/markitup/sets/textile/images/h3.png
  70. BIN  markitup_field/static/markitup/sets/textile/images/h4.png
  71. BIN  markitup_field/static/markitup/sets/textile/images/h5.png
  72. BIN  markitup_field/static/markitup/sets/textile/images/h6.png
  73. BIN  markitup_field/static/markitup/sets/textile/images/italic.png
  74. BIN  markitup_field/static/markitup/sets/textile/images/link.png
  75. BIN  markitup_field/static/markitup/sets/textile/images/list-bullet.png
  76. BIN  markitup_field/static/markitup/sets/textile/images/list-numeric.png
  77. BIN  markitup_field/static/markitup/sets/textile/images/paragraph.png
  78. BIN  markitup_field/static/markitup/sets/textile/images/picture.png
  79. BIN  markitup_field/static/markitup/sets/textile/images/preview.png
  80. BIN  markitup_field/static/markitup/sets/textile/images/quotes.png
  81. BIN  markitup_field/static/markitup/sets/textile/images/stroke.png
  82. +11 −0 markitup_field/static/markitup/sets/textile/readme.txt
  83. +39 −0 markitup_field/static/markitup/sets/textile/set.js
  84. +60 −0 markitup_field/static/markitup/sets/textile/style.css
  85. BIN  markitup_field/static/markitup/skins/markitup/images/bg-container.png
  86. BIN  markitup_field/static/markitup/skins/markitup/images/bg-editor-bbcode.png
  87. BIN  markitup_field/static/markitup/skins/markitup/images/bg-editor-dotclear.png
  88. BIN  markitup_field/static/markitup/skins/markitup/images/bg-editor-html.png
  89. BIN  markitup_field/static/markitup/skins/markitup/images/bg-editor-json.png
  90. BIN  markitup_field/static/markitup/skins/markitup/images/bg-editor-markdown.png
  91. BIN  markitup_field/static/markitup/skins/markitup/images/bg-editor-textile.png
  92. BIN  markitup_field/static/markitup/skins/markitup/images/bg-editor-wiki.png
  93. BIN  markitup_field/static/markitup/skins/markitup/images/bg-editor-xml.png
  94. BIN  markitup_field/static/markitup/skins/markitup/images/bg-editor.png
  95. BIN  markitup_field/static/markitup/skins/markitup/images/handle.png
  96. BIN  markitup_field/static/markitup/skins/markitup/images/menu.png
  97. BIN  markitup_field/static/markitup/skins/markitup/images/submenu.png
  98. +148 −0 markitup_field/static/markitup/skins/markitup/style.css
  99. BIN  markitup_field/static/markitup/skins/simple/images/handle.png
  100. BIN  markitup_field/static/markitup/skins/simple/images/menu.png
  101. BIN  markitup_field/static/markitup/skins/simple/images/submenu.png
  102. +118 −0 markitup_field/static/markitup/skins/simple/style.css
  103. +5 −0 markitup_field/static/markitup/templates/preview.css
  104. +11 −0 markitup_field/static/markitup/templates/preview.html
  105. +77 −0 markitup_field/static/markitup/update_widget.js
  106. +12 −0 markitup_field/templates/markitup/editor.html
  107. +2 −0  markitup_field/templates/markitup/include_all.html
  108. +2 −0  markitup_field/templates/markitup/include_css.html
  109. +6 −0 markitup_field/templates/markitup/include_js.html
  110. +11 −0 markitup_field/templates/markitup/preview.html
  111. 0  {markupfield/tests → markitup_field/templatetags}/__init__.py
  112. +67 −0 markitup_field/templatetags/markitup_tags.py
  113. 0  markitup_field/tests/__init__.py
  114. 0  {markupfield → markitup_field}/tests/models.py
  115. 0  {markupfield → markitup_field}/tests/run_tests.sh
  116. 0  {markupfield → markitup_field}/tests/settings.py
  117. 0  {markupfield → markitup_field}/tests/tests.py
  118. +8 −0 markitup_field/urls.py
  119. +9 −0 markitup_field/util.py
  120. +12 −0 markitup_field/views.py
  121. +156 −0 markitup_field/widgets.py
  122. +0 −14 markupfield/widgets.py
  123. +28 −9 setup.py
11 .hgignore
View
@@ -0,0 +1,11 @@
+syntax: glob
+
+
+.idea*
+*.pyc
+
+*.pyo
+
+build*
+dist*
+MANIFEST
15 .travis.yml
View
@@ -3,10 +3,15 @@ python:
- "2.6"
- "2.7"
env:
- - DJANGO_VERSION=1.3
- - DJANGO_VERSION=1.4
-install: pip install Django==$DJANGO_VERSION markdown docutils --use-mirrors
-script: django-admin.py test --settings=markupfield.tests.settings --pythonpath=.
+ - DJANGO_VERSION=Django==1.4.2
+ - DJANGO_VERSION=https://www.djangoproject.com/download/1.5b1/tarball/
+install: pip install $DJANGO_VERSION markdown docutils --use-mirrors
+script: django-admin.py test --settings=markitup_field.tests.settings --pythonpath=.
notifications:
email:
- - james.p.turk@gmail.com
+ - dimka665@gmail.com
+
+matrix:
+ include:
+ - python: "3.2"
+ env: DJANGO_VERSION=https://www.djangoproject.com/download/1.5b1/tarball/
17 AUTHORS.txt
View
@@ -1,6 +1,23 @@
+django-markupfield:
+
James Turk <james.p.turk@gmail.com>
Jeremy Carbaugh - design help and minor fixes
Carl J Meyer <carl@dirtcircle.com> - simplified widgets.py
Michael Fladischer - test patch & debian packaging
Javed Khan - escape_html option
Roman Vasiliev - fix for South
+
+django-markitup:
+
+Aram Dulyan Carl Meyer <carl@dirtcircle.com>
+Fursov Sergey <GeyseR85@gmail.com>
+James Turk <james.p.turk@gmail.com>
+Jannis Leidel <jannis@enn.io>
+Jeremy Carbaugh
+Mike Korobov <kmike84@gmail.com>
+Mikhael Korneev
+Sebastian Brandt
+
+django-markitup-field:
+
+Dmitry Voronin
9 CHANGELOG
View
@@ -1,3 +1,12 @@
+1.2
+==================
+ - added MarkItUp! editor and preview
+
+1.1.0
+==================
+ - markup_choices can no longer be a dict (deprecated pre-1.0)
+ - Python 3 support (experimental w/ Django 1.5)
+
1.0.2 - 25 March 2011
=====================
- fix Django 1.3 DeprecationWarning
33 LICENSE
View
@@ -28,3 +28,36 @@ PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+
+django-markitup
+==================
+
+Copyright (c) 2009-2011, Carl Meyer
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are
+met:
+
+ * Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+ * Redistributions in binary form must reproduce the above
+ copyright notice, this list of conditions and the following
+ disclaimer in the documentation and/or other materials provided
+ with the distribution.
+ * Neither the name of the author nor the names of other
+ contributors may be used to endorse or promote products derived
+ from this software without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
9 MANIFEST.in
View
@@ -1,5 +1,8 @@
-include README.rst
-include LICENSE
-include CHANGELOG
include AUTHORS.txt
+include CHANGELOG
+include LICENSE
include MANIFEST.in
+include README.rst
+
+graft markitup_field
+recursive-exclude markitup_field *.pyc *.pyo
86 README.rst
View
@@ -1,25 +1,43 @@
-==================
-django-markupfield
-==================
+=========================
+django-markitup-field
+=========================
-An implementation of a custom MarkupField for Django. A MarkupField is in
-essence a TextField with an associated markup type. The field also caches
-its rendered value on the assumption that disk space is cheaper than CPU
-cycles in a web application.
+An implementation of a custom MarkupField for Django. A MarkupField is in
+essence a TextField with an associated markup format and `MarkItUp!`_ markup
+editor widget with AJAX preview. The field also caches its rendered value on
+the assumption that disk space is cheaper than CPU cycles in a web application.
+
+Based on `django-markupfield <http://github.com/jamesturk/django-markupfield>`_
+and `django-markitup <http://github.com/carljm/django-markitup>`_.
+
+.. _MarkItUp!: http://markitup.jaysalvat.com/
Installation
============
-The recommended way to install django-markupfield is with
+The recommended way to install django-markitup-field is with
`pip <http://pypi.python.org/pypi/pip>`_
-It is not necessary to add ``'markupfield'`` to your ``INSTALLED_APPS``, it
+Install from PyPI with ``easy_install`` or ``pip``::
+
+ pip install django-markitup-field
+
+or get the `in-development version`_::
+
+ pip install django-markitup-field==tip
+
+.. _in-development version: http://github.com/dimka665/django-markitup-field
+
+It is not necessary to add ``'markitup_field'`` to your ``INSTALLED_APPS``, it
merely needs to be on your ``PYTHONPATH``.
+If you want to use AJAX-based preview, add
+``url(r'^markitup/', include('markitup.urls'))`` in your root URLconf.
+
Requirements
------------
-django-markupfield depends on a relatively current version of Django
+django-markitup-field depends on a relatively current version of Django
(tested with 1.3-1.4, may work with 1.2 but not guaranteed) and libraries for
whichever markup options you wish to include.
@@ -27,9 +45,8 @@ whichever markup options you wish to include.
Settings
========
-To best make use of MarkupField you should define the
-``MARKUP_FIELD_TYPES`` setting, a mapping of strings to callables that
-'render' a markup type::
+You can define the ``MARKUP_FILTERS`` setting, a mapping of strings
+to callables that 'render' a markup type::
import markdown
from docutils.core import publish_parts
@@ -38,17 +55,17 @@ To best make use of MarkupField you should define the
parts = publish_parts(source=markup, writer_name="html4css1")
return parts["fragment"]
- MARKUP_FIELD_TYPES = (
+ MARKUP_FILTERS = (
('markdown', markdown.markdown),
- ('ReST', render_rest),
+ ('restructuredtext', render_rest),
)
-If you do not define a ``MARKUP_FIELD_TYPES`` then one is provided with the
+If you do not define a ``MARKUP_FILTERS`` then one is provided with the
following markup types available:
html:
allows HTML, potentially unsafe
-plain:
+text:
plain text markup, calls urlize and replaces text with linebreaks
markdown:
default `markdown`_ renderer (only if `python-markdown`_ is installed)
@@ -57,10 +74,6 @@ restructuredtext:
textile:
default `textile`_ renderer (only if `textile`_ is installed)
-It is also possible to override ``MARKUP_FIELD_TYPES`` on a per-field basis
-by passing the ``markup_choices`` option to a ``MarkupField`` in your model
-declaration.
-
.. _`markdown`: http://daringfireball.net/projects/markdown/
.. _`ReST`: http://docutils.sourceforge.net/rst.html
.. _`textile`: http://hobix.com/textile/quick.html
@@ -74,7 +87,7 @@ Usage
Using MarkupField is relatively easy, it can be used in any model definition::
from django.db import models
- from markupfield.fields import MarkupField
+ from markitup_field.fields import MarkupField
class Article(models.Model):
title = models.CharField(max_length=100)
@@ -82,40 +95,43 @@ Using MarkupField is relatively easy, it can be used in any model definition::
body = MarkupField()
``Article`` objects can then be created with any markup type defined in
-``MARKUP_FIELD_TYPES``::
+``MARKUP_FORMATS``::
Article.objects.create(title='some article', slug='some-article',
- body='*fancy*', body_markup_type='markdown')
+ body='*fancy*', body_markup_format='markdown')
-You will notice that a field named ``body_markup_type`` exists that you did
-not declare, MarkupField actually creates two extra fields here
-``body_markup_type`` and ``_body_rendered``. These fields are always named
-according to the name of the declared ``MarkupField``.
+You will notice that a field named ``body_markup_format`` exists that you did
+not declare, MarkupField actually creates two extra fields. ``body_markup_format``
+This field is always named according to the name of the declared ``MarkupField``.
Arguments
---------
``MarkupField`` also takes three optional arguments. Either
-``default_markup_type`` and ``markup_type`` arguments may be specified but
+``default_markup_format`` and ``markup_format`` arguments may be specified but
not both.
-``default_markup_type``:
+``default_markup_format``:
Set a markup_type that the field will default to if one is not specified.
It is still possible to edit the markup type attribute and it will appear
by default in ModelForms.
-``markup_type``:
+``markup_format``:
Set markup type that the field will always use, ``editable=False`` is set
on the hidden field so it is not shown in ModelForms.
``markup_choices``:
A replacement list of markup choices to be used in lieu of
- ``MARKUP_FIELD_TYPES`` on a per-field basis.
+ ``MARKUP_FORMATS`` on a per-field basis.
``escape_html``:
A flag (False by default) indicating that the input should be regarded
as untrusted and as such will be run through Django's ``escape`` filter.
+``rendered_field_name``:
+ Name for field with rendered content. If it is set to None,
+ then it named <field_name>_rendered
+
Examples
~~~~~~~~
@@ -145,7 +161,7 @@ parameters:
``raw``:
The unrendered markup.
-``markup_type``:
+``markup_format``:
The markup type.
``rendered``:
The rendered HTML version of ``raw``, this attribute is read-only.
@@ -168,8 +184,8 @@ Assuming the ``Article`` model above::
<p><em>fancy</em></p>
Assignment to ``a.body`` is equivalent to assignment to ``a.body.raw`` and
-assignment to ``a.body_markup_type`` is equivalent to assignment to
-``a.body.markup_type``.
+assignment to ``a.body_markup_format`` is equivalent to assignment to
+``a.body.markup_format``.
.. note::
a.body.rendered is only updated when a.save() is called
0  markupfield/__init__.py → markitup_field/__init__.py
View
File renamed without changes
131 markupfield/fields.py → markitup_field/fields.py
View
@@ -1,29 +1,29 @@
import django
-from django.conf import settings
+#from django.conf import settings
from django.db import models
from django.utils.safestring import mark_safe
from django.utils.html import escape
-from markupfield import widgets
-from markupfield import markup
+from markitup_field import widgets
+#from markitup_field import markup
+from markitup_field import settings
_rendered_field_name = lambda name: '_%s_rendered' % name
-_markup_type_field_name = lambda name: '%s_markup_type' % name
+_markup_format_field_name = lambda name: '%s_markup_format' % name
# for fields that don't set markup_types: detected types or from settings
-_MARKUP_TYPES = getattr(settings, 'MARKUP_FIELD_TYPES', markup.DEFAULT_MARKUP_TYPES)
+#MARKUP_CHOICES = getattr(settings, 'MARKUP_FILTERS', markup.MARKUP_FILTERS)
class Markup(object):
- def __init__(self, instance, field_name, rendered_field_name,
- markup_type_field_name):
+ def __init__(self, instance, field_name, rendered_field_name, markup_format_field_name):
# instead of storing actual values store a reference to the instance
# along with field names, this makes assignment possible
self.instance = instance
self.field_name = field_name
self.rendered_field_name = rendered_field_name
- self.markup_type_field_name = markup_type_field_name
+ self.markup_format_field_name = markup_format_field_name
# raw is read/write
def _get_raw(self):
@@ -34,14 +34,15 @@ def _set_raw(self, val):
raw = property(_get_raw, _set_raw)
- # markup_type is read/write
- def _get_markup_type(self):
- return self.instance.__dict__[self.markup_type_field_name]
+ # markup_format is read/write
+ def _get_markup_format(self):
+ return self.instance.__dict__[self.markup_format_field_name]
- def _set_markup_type(self, val):
- return setattr(self.instance, self.markup_type_field_name, val)
+ def _set_markup_format(self, val):
+# return setattr(self.instance, self.markup_format_field_name, val)
+ setattr(self.instance, self.markup_format_field_name, val)
- markup_type = property(_get_markup_type, _set_markup_type)
+ markup_format = property(_get_markup_format, _set_markup_format)
# rendered is a read only property
def _get_rendered(self):
@@ -57,8 +58,8 @@ class MarkupDescriptor(object):
def __init__(self, field):
self.field = field
- self.rendered_field_name = _rendered_field_name(self.field.name)
- self.markup_type_field_name = _markup_type_field_name(self.field.name)
+ self.rendered_field_name = field.rendered_field_name
+ self.markup_format_field_name = field.markup_format_field_name
def __get__(self, instance, owner):
if instance is None:
@@ -66,44 +67,58 @@ def __get__(self, instance, owner):
markup = instance.__dict__[self.field.name]
if markup is None:
return None
- return Markup(instance, self.field.name, self.rendered_field_name,
- self.markup_type_field_name)
+ return Markup(instance, self.field.name, self.rendered_field_name, self.markup_format_field_name)
def __set__(self, obj, value):
if isinstance(value, Markup):
obj.__dict__[self.field.name] = value.raw
setattr(obj, self.rendered_field_name, value.rendered)
- setattr(obj, self.markup_type_field_name, value.markup_type)
+ setattr(obj, self.markup_format_field_name, value.markup_format)
else:
obj.__dict__[self.field.name] = value
class MarkupField(models.TextField):
- def __init__(self, verbose_name=None, name=None, markup_type=None,
- default_markup_type=None, markup_choices=_MARKUP_TYPES,
+ def __init__(self, verbose_name=None, name=None,
+ markup_format=None, default_markup_format=None, markup_choices=settings.MARKUP_CHOICES,
+ rendered_field_name=None,
escape_html=False, **kwargs):
- if markup_type and default_markup_type:
- raise ValueError('Cannot specify both markup_type and default_markup_type')
+ if markup_format and default_markup_format:
+ raise ValueError("Cannot specify both 'markup_format' and 'default_markup_format'")
- self.default_markup_type = markup_type or default_markup_type
- self.markup_type_editable = markup_type is None
+ if not default_markup_format:
+ default_markup_format = settings.MARKUP_DEFAULT_FORMAT
+
+# if render_to_field and rendered_field_name:
+# raise ValueError("Cannot specify both 'render_to_field' and 'rendered_field_name'")
+
+# if render_to_field:
+# render_to_field_class_is_child_of_field = False
+# try:
+# render_to_field_class_is_child_of_field = issubclass(render_to_field.__class__, models.Field)
+# except TypeError:
+# pass
+#
+# if not render_to_field_class_is_child_of_field:
+# raise ValueError("'render_to_field' must be Field")
+
+# self.render_to_field = render_to_field
+# print(render_to_field.)
+ self.rendered_field_name = rendered_field_name
+
+ self.default_markup_format = markup_format or default_markup_format
+ self.markup_format_editable = markup_format is None
self.escape_html = escape_html
- # pre 1.0 markup_choices might have been a dict
- if isinstance(markup_choices, dict):
- raise DeprecationWarning('passing a dictionary as markup_choices is deprecated')
- self.markup_choices_dict = markup_choices
- self.markup_choices_list = markup_choices.keys()
- else:
- self.markup_choices_list = [mc[0] for mc in markup_choices]
- self.markup_choices_dict = dict(markup_choices)
+ self.markup_choices = markup_choices
+ self.markup_choices_list = [mc[0] for mc in markup_choices]
+# self.markup_choices_dict = dict(markup_choices)
- if (self.default_markup_type and
- self.default_markup_type not in self.markup_choices_list):
- raise ValueError("Invalid default_markup_type for field '%s', allowed values: %s" %
- (name, ', '.join(self.markup_choices_list)))
+ # default_markup_format in markup_choices ?
+ if (self.default_markup_format and (self.default_markup_format not in self.markup_choices_list)):
+ raise ValueError("Invalid 'default_markup_format' for field '{}', allowed values: {}".format(name, ', '.join(self.markup_choices_list)))
# for South FakeORM compatibility: the frozen version of a
# MarkupField can't try to add a _rendered field, because the
@@ -114,32 +129,42 @@ def __init__(self, verbose_name=None, name=None, markup_type=None,
super(MarkupField, self).__init__(verbose_name, name, **kwargs)
def contribute_to_class(self, cls, name):
+ self.rendered_field_name = self.rendered_field_name or _rendered_field_name(name)
+ self.markup_format_field_name = _markup_format_field_name(name)
+
if not cls._meta.abstract:
- choices = zip(self.markup_choices_list, self.markup_choices_list)
- markup_type_field = models.CharField(max_length=30,
- choices=choices, default=self.default_markup_type,
- editable=self.markup_type_editable, blank=self.blank)
+# choices = zip(self.markup_choices_list, self.markup_choices_list)
+
+ markup_format_field = models.CharField(max_length=30, choices=self.markup_choices, default=self.default_markup_format, editable=self.markup_format_editable, blank=self.blank)
+ markup_format_field.creation_counter = self.creation_counter - 1
+ cls.add_to_class(_markup_format_field_name(name), markup_format_field)
+
+# self.creation_counter += 1
+
+# if not self.render_to_field:
rendered_field = models.TextField(editable=False)
- markup_type_field.creation_counter = self.creation_counter+1
- rendered_field.creation_counter = self.creation_counter+2
- cls.add_to_class(_markup_type_field_name(name), markup_type_field)
- cls.add_to_class(_rendered_field_name(name), rendered_field)
- super(MarkupField, self).contribute_to_class(cls, name)
+# rendered_field = models.TextField(editable=True)
+ rendered_field.creation_counter = self.creation_counter + 1
+
+ cls.add_to_class(self.rendered_field_name, rendered_field)
+ super(MarkupField, self).contribute_to_class(cls, name)
setattr(cls, self.name, MarkupDescriptor(self))
def pre_save(self, model_instance, add):
value = super(MarkupField, self).pre_save(model_instance, add)
- if value.markup_type not in self.markup_choices_list:
- raise ValueError('Invalid markup type (%s), allowed values: %s' %
- (value.markup_type,
+ if value.markup_format not in self.markup_choices_list:
+ raise ValueError('Invalid markup format (%s), allowed values: %s' %
+ (value.markup_format,
', '.join(self.markup_choices_list)))
if self.escape_html:
raw = escape(value.raw)
else:
raw = value.raw
- rendered = self.markup_choices_dict[value.markup_type](raw)
- setattr(model_instance, _rendered_field_name(self.attname), rendered)
+# rendered = self.markup_choices_dict[value.markup_format](raw)
+ rendered = settings.MARKUP_FILTERS[value.markup_format](raw)
+# setattr(model_instance, _rendered_field_name(self.attname), rendered)
+ setattr(model_instance, self.rendered_field_name, rendered)
return value.raw
def get_prep_value(self, value):
@@ -163,7 +188,7 @@ def formfield(self, **kwargs):
# register MarkupField to use the custom widget in the Admin
from django.contrib.admin.options import FORMFIELD_FOR_DBFIELD_DEFAULTS
-FORMFIELD_FOR_DBFIELD_DEFAULTS[MarkupField] = {'widget': widgets.AdminMarkupTextareaWidget}
+FORMFIELD_FOR_DBFIELD_DEFAULTS[MarkupField] = {'widget': widgets.AdminMarkupWidget}
# allow South to handle MarkupField smoothly
try:
@@ -173,6 +198,6 @@ def formfield(self, **kwargs):
# True in a frozen MarkupField, which is what we want.
add_introspection_rules(rules=[
( (MarkupField,), [], { 'rendered_field': ['rendered_field', {}], })
- ], patterns=['markupfield\.fields\.MarkupField'])
+ ], patterns=['markitup_field\.fields\.MarkupField'])
except ImportError:
pass
1  markitup_field/management/__init__.py
View
@@ -0,0 +1 @@
+__author__ = 'dimka'
1  markitup_field/management/commands/__init__.py
View
@@ -0,0 +1 @@
+__author__ = 'dimka'
39 markitup_field/management/commands/dice_markup_build_css.py
View
@@ -0,0 +1,39 @@
+
+from django.core.management.base import BaseCommand, CommandError
+
+import os
+
+from scss import Scss
+css = Scss()
+
+class Command(BaseCommand):
+# args = '<arg_x arg_y ...>'
+ help = "Builds 'style.css' of markups in one css-file using pySCSS"
+
+ def handle(self, *args, **options):
+ my_path = os.path.dirname(__file__)
+ sets_path = os.path.join(my_path, '../../static/markitup/sets/')
+ sets_path = os.path.abspath(sets_path)
+
+ style_scss = ''
+ # sets list
+ sets = [set_dir for set_dir in os.listdir(sets_path) if os.path.isdir(os.path.join(sets_path, set_dir))]
+ for set_dir in sets:
+ set_path = os.path.join(sets_path, set_dir, 'style.css')
+
+ set_css = open(set_path, 'r').read()
+ set_css = set_css.replace('url(images/', 'url({}/images/'.format(set_dir))
+
+ set_scss = '.{set_dir} {{\n{set_css}\n}}\n'.format(set_dir=set_dir, set_css=set_css)
+
+ style_scss += set_scss
+
+ style_css = css.compile(style_scss)
+
+ with open(os.path.join(sets_path, 'style.css'), 'w') as style_css_file:
+ style_css_file.write(style_css)
+
+# style_css_file = open(os.path.join(sets_path, 'style.css'), 'w')
+# style_css_file.write(style_css)
+# style_css_file.close()
+
24 markupfield/markup.py → markitup_field/markup.py
View
@@ -2,12 +2,14 @@
from django.utils.functional import curry
from django.conf import settings
-# build DEFAULT_MARKUP_TYPES
-DEFAULT_MARKUP_TYPES = [
- ('html', lambda markup: markup),
- ('plain', lambda markup: urlize(linebreaks(markup))),
-]
+# build MARKUP_FILTERS
+MARKUP_FILTERS = {
+ 'text': lambda markup: urlize(linebreaks(markup)),
+ 'html': lambda markup: markup,
+}
+
+# Pygments
try:
import pygments
PYGMENTS_INSTALLED = True
@@ -41,6 +43,8 @@ def pygments_directive(name, arguments, options, content, lineno,
except ImportError:
PYGMENTS_INSTALLED = False
+
+# Markdown
try:
import markdown
@@ -55,11 +59,13 @@ def pygments_directive(name, arguments, options, content, lineno,
pass
# whichever markdown_filter was available
- DEFAULT_MARKUP_TYPES.append(('markdown', md_filter))
+ MARKUP_FILTERS['markdown'] = md_filter
except ImportError:
pass
+
+# ReStructured Text
try:
from docutils.core import publish_parts
@@ -72,14 +78,16 @@ def render_rest(markup):
settings_overrides=overrides)
return parts["fragment"]
- DEFAULT_MARKUP_TYPES.append(('restructuredtext', render_rest))
+ MARKUP_FILTERS['restructuredtext'] = render_rest
except ImportError:
pass
+
+# Textile
try:
import textile
textile_filter =curry(textile.textile, encoding='utf-8', output='utf-8')
- DEFAULT_MARKUP_TYPES.append(('textile', textile_filter))
+ MARKUP_FILTERS['textile'] = textile_filter
except ImportError:
pass
28 markitup_field/settings.py
View
@@ -0,0 +1,28 @@
+
+from django.conf import settings
+
+from markitup_field.markup import MARKUP_FILTERS
+
+
+MARKUP_FILTERS.update(getattr(settings, 'MARKUP_FILTERS', {}))
+MARKUP_CHOICES = getattr(settings, 'MARKUP_CHOICES', None)
+
+if not MARKUP_CHOICES:
+ MARKUP_CHOICES = (
+ ('text', 'Text'),
+ ('html', 'HTML'),
+ ('markdown', 'Markdown'),
+ ('textile', 'Textile'),
+ ('restructuredtext', 'ReStructured Text'),
+ )
+
+ MARKUP_CHOICES = [markup for markup in MARKUP_CHOICES if markup[0] in MARKUP_FILTERS.keys()]
+
+MARKUP_DEFAULT_FORMAT = getattr(settings, 'MARKUP_DEFAULT_FORMAT', 'default')
+
+MARKUP_AUTO_PREVIEW = getattr(settings, 'MARKUP_AUTO_PREVIEW', False)
+
+MARKUP_SKIN = getattr(settings, 'MARKUP_SKIN', 'markitup/skins/simple')
+
+JQUERY_URL = getattr(settings, 'JQUERY_URL', 'http://ajax.googleapis.com/ajax/libs/jquery/1.6/jquery.min.js')
+
25 markitup_field/static/markitup/ajax_csrf.js
View
@@ -0,0 +1,25 @@
+(function($) {
+ // from http://docs.djangoproject.com/en/1.3/ref/contrib/csrf/#ajax
+ $('html').ajaxSend(
+ function(event, xhr, settings) {
+ function getCookie(name) {
+ var cookieValue = null;
+ if (document.cookie && document.cookie != '') {
+ var cookies = document.cookie.split(';');
+ for (var i = 0; i < cookies.length; i++) {
+ var cookie = $.trim(cookies[i]);
+ // Does this cookie string begin with the name we want?
+ if (cookie.substring(0, name.length + 1) == (name + '=')) {
+ cookieValue = decodeURIComponent(cookie.substring(name.length + 1));
+ break;
+ }
+ }
+ }
+ return cookieValue;
+ }
+ if (!(/^http:.*/.test(settings.url) || /^https:.*/.test(settings.url))) {
+ // Only send the token to relative URLs i.e. locally.
+ xhr.setRequestHeader("X-CSRFToken", getCookie('csrftoken'));
+ }
+ });
+ })(jQuery);
563 markitup_field/static/markitup/jquery.markitup.js
View
@@ -0,0 +1,563 @@
+// ----------------------------------------------------------------------------
+// markItUp! Universal MarkUp Engine, JQuery plugin
+// v 1.1.6.2
+// Dual licensed under the MIT and GPL licenses.
+// ----------------------------------------------------------------------------
+// Copyright (C) 2007-2010 Jay Salvat
+// http://markitup.jaysalvat.com/
+// ----------------------------------------------------------------------------
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
+// ----------------------------------------------------------------------------
+(function($) {
+ $.fn.markItUp = function(settings, extraSettings) {
+ var options, ctrlKey, shiftKey, altKey;
+ ctrlKey = shiftKey = altKey = false;
+
+ options = { id: '',
+ nameSpace: '',
+ root: '',
+ previewInWindow: '', // 'width=800, height=600, resizable=yes, scrollbars=yes'
+ previewAutoRefresh: true,
+ previewPosition: 'after',
+ previewTemplatePath: '~/templates/preview.html',
+ previewParserPath: '',
+ previewParserVar: 'data',
+ resizeHandle: true,
+ beforeInsert: '',
+ afterInsert: '',
+ onEnter: {},
+ onShiftEnter: {},
+ onCtrlEnter: {},
+ onTab: {},
+ markupSet: [ { /* set */ } ]
+ };
+ $.extend(options, settings, extraSettings);
+
+ // compute markItUp! path
+ if (!options.root) {
+ $('script').each(function(a, tag) {
+ miuScript = $(tag).get(0).src.match(/(.*)jquery\.markitup(\.pack)?\.js$/);
+ if (miuScript !== null) {
+ options.root = miuScript[1];
+ }
+ });
+ }
+
+ return this.each(function() {
+ var $$, textarea, levels, scrollPosition, caretPosition, caretOffset,
+ clicked, hash, header, footer, previewWindow, template, iFrame, abort;
+ $$ = $(this);
+ textarea = this;
+ levels = [];
+ abort = false;
+ scrollPosition = caretPosition = 0;
+ caretOffset = -1;
+
+ options.previewParserPath = localize(options.previewParserPath);
+ options.previewTemplatePath = localize(options.previewTemplatePath);
+
+ // apply the computed path to ~/
+ function localize(data, inText) {
+ if (inText) {
+ return data.replace(/("|')~\//g, "$1"+options.root);
+ }
+ return data.replace(/^~\//, options.root);
+ }
+
+ // init and build editor
+ function init() {
+ id = '';
+ nameSpace = '';
+ if (options.id) {
+ id = 'id="'+options.id+'"';
+ } else if ($$.attr("id")) {
+ id = 'id="markItUp'+($$.attr("id").substr(0, 1).toUpperCase())+($$.attr("id").substr(1))+'"';
+// .substr(0, 1).toUpperCase())+($$.attr("id").substr(1))+'"';
+ }
+ if (options.nameSpace) {
+ nameSpace = 'class="'+options.nameSpace+'"';
+ }
+ $$.wrap('<div '+nameSpace+'></div>');
+ $$.wrap('<div '+id+' class="markItUp"></div>');
+ $$.wrap('<div class="markItUpContainer"></div>');
+ $$.addClass("markItUpEditor");
+
+ // add the header before the textarea
+ header = $('<div class="markItUpHeader"></div>').insertBefore($$);
+ $(dropMenus(options.markupSet)).appendTo(header);
+
+ // add the footer after the textarea
+ footer = $('<div class="markItUpFooter"></div>').insertAfter($$);
+
+ // add the resize handle after textarea
+ if (options.resizeHandle === true && $.browser.safari !== true) {
+ resizeHandle = $('<div class="markItUpResizeHandle"></div>')
+ .insertAfter($$)
+ .bind("mousedown", function(e) {
+ var h = $$.height(), y = e.clientY, mouseMove, mouseUp;
+ mouseMove = function(e) {
+ $$.css("height", Math.max(20, e.clientY+h-y)+"px");
+ return false;
+ };
+ mouseUp = function(e) {
+ $("html").unbind("mousemove", mouseMove).unbind("mouseup", mouseUp);
+ return false;
+ };
+ $("html").bind("mousemove", mouseMove).bind("mouseup", mouseUp);
+ });
+ footer.append(resizeHandle);
+ }
+
+ // listen key events
+ $$.keydown(keyPressed).keyup(keyPressed);
+
+ // bind an event to catch external calls
+ $$.bind("insertion", function(e, settings) {
+ if (settings.target !== false) {
+ get();
+ }
+ if (textarea === $.markItUp.focused) {
+ markup(settings);
+ }
+ });
+
+ // remember the last focus
+ $$.focus(function() {
+ $.markItUp.focused = this;
+ });
+ }
+
+ // recursively build header with dropMenus from markupset
+ function dropMenus(markupSet) {
+ var ul = $('<ul></ul>'), i = 0;
+ $('li:hover > ul', ul).css('display', 'block');
+ $.each(markupSet, function() {
+ var button = this, t = '', title, li, j;
+ title = (button.key) ? (button.name||'')+' [Ctrl+'+button.key+']' : (button.name||'');
+ key = (button.key) ? 'accesskey="'+button.key+'"' : '';
+ if (button.separator) {
+ li = $('<li class="markItUpSeparator">'+(button.separator||'')+'</li>').appendTo(ul);
+ } else {
+ i++;
+ for (j = levels.length -1; j >= 0; j--) {
+ t += levels[j]+"-";
+ }
+ li = $('<li class="markItUpButton markItUpButton'+t+(i)+' '+(button.className||'')+'"><a href="" '+key+' title="'+title+'">'+(button.name||'')+'</a></li>')
+ .bind("contextmenu", function() { // prevent contextmenu on mac and allow ctrl+click
+ return false;
+ }).click(function() {
+ return false;
+ }).mousedown(function() {
+ if (button.call) {
+ eval(button.call)();
+ }
+ setTimeout(function() { markup(button) },1);
+ return false;
+ }).hover(function() {
+ $('> ul', this).show();
+ $(document).one('click', function() { // close dropmenu if click outside
+ $('ul ul', header).hide();
+ }
+ );
+ }, function() {
+ $('> ul', this).hide();
+ }
+ ).appendTo(ul);
+ if (button.dropMenu) {
+ levels.push(i);
+ $(li).addClass('markItUpDropMenu').append(dropMenus(button.dropMenu));
+ }
+ }
+ });
+ levels.pop();
+ return ul;
+ }
+
+ // markItUp! markups
+ function magicMarkups(string) {
+ if (string) {
+ string = string.toString();
+ string = string.replace(/\(\!\(([\s\S]*?)\)\!\)/g,
+ function(x, a) {
+ var b = a.split('|!|');
+ if (altKey === true) {
+ return (b[1] !== undefined) ? b[1] : b[0];
+ } else {
+ return (b[1] === undefined) ? "" : b[0];
+ }
+ }
+ );
+ // [![prompt]!], [![prompt:!:value]!]
+ string = string.replace(/\[\!\[([\s\S]*?)\]\!\]/g,
+ function(x, a) {
+ var b = a.split(':!:');
+ if (abort === true) {
+ return false;
+ }
+ value = prompt(b[0], (b[1]) ? b[1] : '');
+ if (value === null) {
+ abort = true;
+ }
+ return value;
+ }
+ );
+ return string;
+ }
+ return "";
+ }
+
+ // prepare action
+ function prepare(action) {
+ if ($.isFunction(action)) {
+ action = action(hash);
+ }
+ return magicMarkups(action);
+ }
+
+ // build block to insert
+ function build(string) {
+ openWith = prepare(clicked.openWith);
+ placeHolder = prepare(clicked.placeHolder);
+ replaceWith = prepare(clicked.replaceWith);
+ closeWith = prepare(clicked.closeWith);
+ if (replaceWith !== "") {
+ block = openWith + replaceWith + closeWith;
+ } else if (selection === '' && placeHolder !== '') {
+ block = openWith + placeHolder + closeWith;
+ } else {
+ block = openWith + (string||selection) + closeWith;
+ }
+ return { block:block,
+ openWith:openWith,
+ replaceWith:replaceWith,
+ placeHolder:placeHolder,
+ closeWith:closeWith
+ };
+ }
+
+ // define markup to insert
+ function markup(button) {
+ var len, j, n, i;
+ hash = clicked = button;
+ get();
+
+ $.extend(hash, { line:"",
+ root:options.root,
+ textarea:textarea,
+ selection:(selection||''),
+ caretPosition:caretPosition,
+ ctrlKey:ctrlKey,
+ shiftKey:shiftKey,
+ altKey:altKey
+ }
+ );
+ // callbacks before insertion
+ prepare(options.beforeInsert);
+ prepare(clicked.beforeInsert);
+ if (ctrlKey === true && shiftKey === true) {
+ prepare(clicked.beforeMultiInsert);
+ }
+ $.extend(hash, { line:1 });
+
+ if (ctrlKey === true && shiftKey === true) {
+ lines = selection.split(/\r?\n/);
+ for (j = 0, n = lines.length, i = 0; i < n; i++) {
+ if ($.trim(lines[i]) !== '') {
+ $.extend(hash, { line:++j, selection:lines[i] } );
+ lines[i] = build(lines[i]).block;
+ } else {
+ lines[i] = "";
+ }
+ }
+ string = { block:lines.join('\n')};
+ start = caretPosition;
+ len = string.block.length + (($.browser.opera) ? n : 0);
+ } else if (ctrlKey === true) {
+ string = build(selection);
+ start = caretPosition + string.openWith.length;
+ len = string.block.length - string.openWith.length - string.closeWith.length;
+ len -= fixIeBug(string.block);
+ } else if (shiftKey === true) {
+ string = build(selection);
+ start = caretPosition;
+ len = string.block.length;
+ len -= fixIeBug(string.block);
+ } else {
+ string = build(selection);
+ start = caretPosition + string.block.length ;
+ len = 0;
+ start -= fixIeBug(string.block);
+ }
+ if ((selection === '' && string.replaceWith === '')) {
+ caretOffset += fixOperaBug(string.block);
+
+ start = caretPosition + string.openWith.length;
+ len = string.block.length - string.openWith.length - string.closeWith.length;
+
+ caretOffset = $$.val().substring(caretPosition, $$.val().length).length;
+ caretOffset -= fixOperaBug($$.val().substring(0, caretPosition));
+ }
+ $.extend(hash, { caretPosition:caretPosition, scrollPosition:scrollPosition } );
+
+ if (string.block !== selection && abort === false) {
+ insert(string.block);
+ set(start, len);
+ } else {
+ caretOffset = -1;
+ }
+ get();
+
+ $.extend(hash, { line:'', selection:selection });
+
+ // callbacks after insertion
+ if (ctrlKey === true && shiftKey === true) {
+ prepare(clicked.afterMultiInsert);
+ }
+ prepare(clicked.afterInsert);
+ prepare(options.afterInsert);
+
+ // refresh preview if opened
+ if (previewWindow && options.previewAutoRefresh) {
+ refreshPreview();
+ }
+
+ // reinit keyevent
+ shiftKey = altKey = ctrlKey = abort = false;
+ }
+
+ // Substract linefeed in Opera
+ function fixOperaBug(string) {
+ if ($.browser.opera) {
+ return string.length - string.replace(/\n*/g, '').length;
+ }
+ return 0;
+ }
+ // Substract linefeed in IE
+ function fixIeBug(string) {
+ if ($.browser.msie) {
+ return string.length - string.replace(/\r*/g, '').length;
+ }
+ return 0;
+ }
+
+ // add markup
+ function insert(block) {
+ if (document.selection) {
+ var newSelection = document.selection.createRange();
+ newSelection.text = block;
+ } else {
+ $$.val($$.val().substring(0, caretPosition) + block + $$.val().substring(caretPosition + selection.length, $$.val().length));
+ }
+ }
+
+ // set a selection
+ function set(start, len) {
+ if (textarea.createTextRange){
+ // quick fix to make it work on Opera 9.5
+ if ($.browser.opera && $.browser.version >= 9.5 && len == 0) {
+ return false;
+ }
+ range = textarea.createTextRange();
+ range.collapse(true);
+ range.moveStart('character', start);
+ range.moveEnd('character', len);
+ range.select();
+ } else if (textarea.setSelectionRange ){
+ textarea.setSelectionRange(start, start + len);
+ }
+ textarea.scrollTop = scrollPosition;
+ textarea.focus();
+ }
+
+ // get the selection
+ function get() {
+ textarea.focus();
+
+ scrollPosition = textarea.scrollTop;
+ if (document.selection) {
+ selection = document.selection.createRange().text;
+ if ($.browser.msie) { // ie
+ var range = document.selection.createRange(), rangeCopy = range.duplicate();
+ rangeCopy.moveToElementText(textarea);
+ caretPosition = -1;
+ while(rangeCopy.inRange(range)) { // fix most of the ie bugs with linefeeds...
+ rangeCopy.moveStart('character');
+ caretPosition ++;
+ }
+ } else { // opera
+ caretPosition = textarea.selectionStart;
+ }
+ } else { // gecko & webkit
+ caretPosition = textarea.selectionStart;
+ selection = $$.val().substring(caretPosition, textarea.selectionEnd);
+ }
+ return selection;
+ }
+
+ // open preview window
+ function preview() {
+ if (!previewWindow || previewWindow.closed) {
+ if (options.previewInWindow) {
+ previewWindow = window.open('', 'preview', options.previewInWindow);
+ } else {
+ iFrame = $('<iframe class="markItUpPreviewFrame"></iframe>');
+ if (options.previewPosition == 'after') {
+ iFrame.insertAfter(footer);
+ } else {
+ iFrame.insertBefore(header);
+ }
+ previewWindow = iFrame[iFrame.length - 1].contentWindow || frame[iFrame.length - 1];
+ }
+ } else if (altKey === true) {
+ // Thx Stephen M. Redd for the IE8 fix
+ if (iFrame) {
+ iFrame.remove();
+ } else {
+ previewWindow.close();
+ }
+ previewWindow = iFrame = false;
+ }
+ if (!options.previewAutoRefresh) {
+ refreshPreview();
+ }
+ }
+
+ // refresh Preview window
+ function refreshPreview() {
+ renderPreview();
+ }
+
+ function renderPreview() {
+ var phtml;
+ if (options.previewParserPath !== '') {
+ $.ajax( {
+ type: 'POST',
+ url: options.previewParserPath,
+// data: options.previewParserVar+'='+encodeURIComponent($$.val()),
+ data: options.previewParserVar+'='+encodeURIComponent($$.val()) +
+ ';markup_format=' + get_format_from_markup_id($$.attr('id')),
+ success: function(data) {
+ writeInPreview( localize(data, 1) );
+ }
+ } );
+ } else {
+ if (!template) {
+ alert('ajax not template');
+ $.ajax( {
+ url: options.previewTemplatePath,
+ success: function(data) {
+ writeInPreview( localize(data, 1).replace(/<!-- content -->/g, $$.val()) );
+ }
+ } );
+ }
+ }
+ return false;
+ }
+
+ function writeInPreview(data) {
+ if (previewWindow.document) {
+ try {
+ sp = previewWindow.document.documentElement.scrollTop
+ } catch(e) {
+ sp = 0;
+ }
+ previewWindow.document.open();
+ previewWindow.document.write(data);
+ previewWindow.document.close();
+ previewWindow.document.documentElement.scrollTop = sp;
+ }
+ if (options.previewInWindow) {
+ previewWindow.focus();
+ }
+ }
+
+ // set keys pressed
+ function keyPressed(e) {
+ shiftKey = e.shiftKey;
+ altKey = e.altKey;
+ ctrlKey = (!(e.altKey && e.ctrlKey)) ? e.ctrlKey : false;
+
+ if (e.type === 'keydown') {
+ if (ctrlKey === true) {
+ li = $("a[accesskey="+String.fromCharCode(e.keyCode)+"]", header).parent('li');
+ if (li.length !== 0) {
+ ctrlKey = false;
+ setTimeout(function() {
+ li.triggerHandler('mousedown');
+ },1);
+ return false;
+ }
+ }
+ if (e.keyCode === 13 || e.keyCode === 10) { // Enter key
+ if (ctrlKey === true) { // Enter + Ctrl
+ ctrlKey = false;
+ markup(options.onCtrlEnter);
+ return options.onCtrlEnter.keepDefault;
+ } else if (shiftKey === true) { // Enter + Shift
+ shiftKey = false;
+ markup(options.onShiftEnter);
+ return options.onShiftEnter.keepDefault;
+ } else { // only Enter
+ markup(options.onEnter);
+ return options.onEnter.keepDefault;
+ }
+ }
+ if (e.keyCode === 9) { // Tab key
+ if (shiftKey == true || ctrlKey == true || altKey == true) { // Thx Dr Floob.
+ return false;
+ }
+ if (caretOffset !== -1) {
+ get();
+ caretOffset = $$.val().length - caretOffset;
+ set(caretOffset, 0);
+ caretOffset = -1;
+ return false;
+ } else {
+ markup(options.onTab);
+ return options.onTab.keepDefault;
+ }
+ }
+ }
+ }
+
+ init();
+ });
+ };
+
+ $.fn.markItUpRemove = function() {
+ return this.each(function() {
+ var $$ = $(this).unbind().removeClass('markItUpEditor');
+ $$.parent('div').parent('div.markItUp').parent('div').replaceWith($$);
+ }
+ );
+ };
+
+ $.markItUp = function(settings) {
+ var options = { target:false };
+ $.extend(options, settings);
+ if (options.target) {
+ return $(options.target).each(function() {
+ $(this).focus();
+ $(this).trigger('insertion', [options]);
+ });
+ } else {
+ $('textarea').trigger('insertion', [options]);
+ }
+ };
+})(jQuery);
5 markitup_field/static/markitup/preview.css
View
@@ -0,0 +1,5 @@
+/* preview style examples */
+body {
+ background-color:#EFEFEF;
+ font:70% Verdana, Arial, Helvetica, sans-serif;
+}
BIN  markitup_field/static/markitup/sets/default/images/bold.png
View
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
BIN  markitup_field/static/markitup/sets/default/images/clean.png
View
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
BIN  markitup_field/static/markitup/sets/default/images/image.png
View
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
BIN  markitup_field/static/markitup/sets/default/images/italic.png
View
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
BIN  markitup_field/static/markitup/sets/default/images/link.png
View
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
BIN  markitup_field/static/markitup/sets/default/images/picture.png
View
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
BIN  markitup_field/static/markitup/sets/default/images/preview.png
View
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
BIN  markitup_field/static/markitup/sets/default/images/stroke.png
View
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
27 markitup_field/static/markitup/sets/default/set.js
View
@@ -0,0 +1,27 @@
+// ----------------------------------------------------------------------------
+// markItUp!
+// ----------------------------------------------------------------------------
+// Copyright (C) 2008 Jay Salvat
+// http://markitup.jaysalvat.com/
+// ----------------------------------------------------------------------------
+// Html tags
+// http://en.wikipedia.org/wiki/html
+// ----------------------------------------------------------------------------
+// Basic set. Feel free to add more tags
+// ----------------------------------------------------------------------------
+mySettings = {
+ onShiftEnter: {keepDefault:false, replaceWith:'<br />\n'},
+ onCtrlEnter: {keepDefault:false, openWith:'\n<p>', closeWith:'</p>'},
+ onTab: {keepDefault:false, replaceWith:' '},
+ markupSet: [
+ {name:'Bold', key:'B', openWith:'(!(<strong>|!|<b>)!)', closeWith:'(!(</strong>|!|</b>)!)' },
+ {name:'Italic', key:'I', openWith:'(!(<em>|!|<i>)!)', closeWith:'(!(</em>|!|</i>)!)' },
+ {name:'Stroke through', key:'S', openWith:'<del>', closeWith:'</del>' },
+ {separator:'---------------' },
+ {name:'Picture', key:'P', replaceWith:'<img src="[![Source:!:http://]!]" alt="[![Alternative text]!]" />' },
+ {name:'Link', key:'L', openWith:'<a href="[![Link:!:http://]!]"(!( title="[![Title]!]")!)>', closeWith:'</a>', placeHolder:'Your text to link...' },
+ {separator:'---------------' },
+ {name:'Clean', className:'clean', replaceWith:function(markitup) { return markitup.selection.replace(/<(.*?)>/g, "") } },
+ {name:'Preview', className:'preview', call:'preview'}
+ ]
+}
27 markitup_field/static/markitup/sets/default/style.css
View
@@ -0,0 +1,27 @@
+/* -------------------------------------------------------------------
+// markItUp!
+// By Jay Salvat - http://markitup.jaysalvat.com/
+// ------------------------------------------------------------------*/
+.markItUp .markItUpButton1 a {
+ background-image:url(images/bold.png);
+}
+.markItUp .markItUpButton2 a {
+ background-image:url(images/italic.png);
+}
+.markItUp .markItUpButton3 a {
+ background-image:url(images/stroke.png);
+}
+
+.markItUp .markItUpButton4 a {
+ background-image:url(images/picture.png);
+}
+.markItUp .markItUpButton5 a {
+ background-image:url(images/link.png);
+}
+
+.markItUp .markItUpButton6 a {
+ background-image:url(images/clean.png);
+}
+.markItUp .preview a {
+ background-image:url(images/preview.png);
+}
BIN  markitup_field/static/markitup/sets/markdown/images/bold.png
View
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
BIN  markitup_field/static/markitup/sets/markdown/images/code.png
View
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
BIN  markitup_field/static/markitup/sets/markdown/images/h1.png
View
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
BIN  markitup_field/static/markitup/sets/markdown/images/h2.png
View
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
BIN  markitup_field/static/markitup/sets/markdown/images/h3.png
View
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
BIN  markitup_field/static/markitup/sets/markdown/images/h4.png
View
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
BIN  markitup_field/static/markitup/sets/markdown/images/h5.png
View
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
BIN  markitup_field/static/markitup/sets/markdown/images/h6.png
View
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
BIN  markitup_field/static/markitup/sets/markdown/images/italic.png
View
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
BIN  markitup_field/static/markitup/sets/markdown/images/link.png
View
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
BIN  markitup_field/static/markitup/sets/markdown/images/list-bullet.png
View
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
BIN  markitup_field/static/markitup/sets/markdown/images/list-numeric.png
View
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
BIN  markitup_field/static/markitup/sets/markdown/images/picture.png
View
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
BIN  markitup_field/static/markitup/sets/markdown/images/preview.png
View
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
BIN  markitup_field/static/markitup/sets/markdown/images/quotes.png
View
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
11 markitup_field/static/markitup/sets/markdown/readme.txt
View
@@ -0,0 +1,11 @@
+Markup language:
+Markdown
+
+Description:
+A basic Markdown markup set with Headings, Bold, Italic, Picture, Link, List, Quotes, Code, Preview button.
+
+Install:
+- Download the zip file
+- Unzip it in your markItUp! sets folder
+- Modify your JS link to point at this set.js
+- Modify your CSS link to point at this style.css
54 markitup_field/static/markitup/sets/markdown/set.js
View
@@ -0,0 +1,54 @@
+// -------------------------------------------------------------------
+// markItUp!
+// -------------------------------------------------------------------
+// Copyright (C) 2008 Jay Salvat
+// http://markitup.jaysalvat.com/
+// -------------------------------------------------------------------
+// MarkDown tags example
+// http://en.wikipedia.org/wiki/Markdown
+// http://daringfireball.net/projects/markdown/
+// -------------------------------------------------------------------
+// Feel free to add more tags
+// -------------------------------------------------------------------
+//alert('markdown set js');
+mySettings = {
+ onShiftEnter: {keepDefault:false, openWith:'\n\n'},
+ markupSet: [
+ {name:'First Level Heading', key:'1', placeHolder:'Your title here...', closeWith:function(markItUp) { return miu.markdownTitle(markItUp, '=') } },
+ {name:'Second Level Heading', key:'2', placeHolder:'Your title here...', closeWith:function(markItUp) { return miu.markdownTitle(markItUp, '-') } },
+ {name:'Heading 3', key:'3', openWith:'### ', placeHolder:'Your title here...' },
+ {name:'Heading 4', key:'4', openWith:'#### ', placeHolder:'Your title here...' },
+ {name:'Heading 5', key:'5', openWith:'##### ', placeHolder:'Your title here...' },
+ {name:'Heading 6', key:'6', openWith:'###### ', placeHolder:'Your title here...' },
+ {separator:'---------------' },
+ {name:'Bold', key:'B', openWith:'**', closeWith:'**'},
+ {name:'Italic', key:'I', openWith:'_', closeWith:'_'},
+ {separator:'---------------' },
+ {name:'Bulleted List', openWith:'- ' },
+ {name:'Numeric List', openWith:function(markItUp) {
+ return markItUp.line+'. ';
+ }},
+ {separator:'---------------' },
+ {name:'Picture', key:'P', replaceWith:'![[![Alternative text]!]]([![Url:!:http://]!] "[![Title]!]")'},
+ {name:'Link', key:'L', openWith:'[', closeWith:']([![Url:!:http://]!] "[![Title]!]")', placeHolder:'Your text to link here...' },
+ {separator:'---------------'},
+ {name:'Quotes', openWith:'> '},
+ {name:'Code Block / Code', openWith:'(!(\t|!|`)!)', closeWith:'(!(`)!)'},
+ {separator:'---------------'},
+ {name:'Preview', call:'preview', className:"preview"}
+ ]
+}
+
+// mIu nameSpace to avoid conflict.
+miu = {
+ markdownTitle: function(markItUp, char) {
+ heading = '';
+ n = $.trim(markItUp.selection||markItUp.placeHolder).length;
+ // work around bug in python-markdown where header underlines must be at least 3 chars
+ if (n < 3) { n = 3; }
+ for(i = 0; i < n; i++) {
+ heading += char;
+ }
+ return '\n'+heading;
+ }
+}
54 markitup_field/static/markitup/sets/markdown/style.css
View
@@ -0,0 +1,54 @@
+/* -------------------------------------------------------------------
+// markItUp!
+// By Jay Salvat - http://markitup.jaysalvat.com/
+// ------------------------------------------------------------------*/
+.markItUp .markItUpButton1 a {
+ background-image:url(images/h1.png);
+}
+.markItUp .markItUpButton2 a {
+ background-image:url(images/h2.png);
+}
+.markItUp .markItUpButton3 a {
+ background-image:url(images/h3.png);
+}
+.markItUp .markItUpButton4 a {
+ background-image:url(images/h4.png);
+}
+.markItUp .markItUpButton5 a {
+ background-image:url(images/h5.png);
+}
+.markItUp .markItUpButton6 a {
+ background-image:url(images/h6.png);
+}
+
+.markItUp .markItUpButton7 a {
+ background-image:url(images/bold.png);
+}
+.markItUp .markItUpButton8 a {
+ background-image:url(images/italic.png);
+}
+
+.markItUp .markItUpButton9 a {
+ background-image:url(images/list-bullet.png);
+}
+.markItUp .markItUpButton10 a {
+ background-image:url(images/list-numeric.png);
+}
+
+.markItUp .markItUpButton11 a {
+ background-image:url(images/picture.png);
+}
+.markItUp .markItUpButton12 a {
+ background-image:url(images/link.png);
+}
+
+.markItUp .markItUpButton13 a {
+ background-image:url(images/quotes.png);
+}
+.markItUp .markItUpButton14 a {
+ background-image:url(images/code.png);
+}
+
+.markItUp .preview a {
+ background-image:url(images/preview.png);
+}
BIN  markitup_field/static/markitup/sets/restructuredtext/images/bold.png
View
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
BIN  markitup_field/static/markitup/sets/restructuredtext/images/close.png
View
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
BIN  markitup_field/static/markitup/sets/restructuredtext/images/code.png
View
Diff not rendered
BIN  markitup_field/static/markitup/sets/restructuredtext/images/h1.png
View
Diff not rendered
BIN  markitup_field/static/markitup/sets/restructuredtext/images/h2.png
View
Diff not rendered
BIN  markitup_field/static/markitup/sets/restructuredtext/images/h3.png
View
Diff not rendered
BIN  markitup_field/static/markitup/sets/restructuredtext/images/h4.png
View
Diff not rendered
BIN  markitup_field/static/markitup/sets/restructuredtext/images/h5.png
View
Diff not rendered
BIN  markitup_field/static/markitup/sets/restructuredtext/images/h6.png
View
Diff not rendered
BIN  markitup_field/static/markitup/sets/restructuredtext/images/italic.png
View
Diff not rendered
BIN  markitup_field/static/markitup/sets/restructuredtext/images/link.png
View
Diff not rendered
BIN  markitup_field/static/markitup/sets/restructuredtext/images/list-bullet.png
View
Diff not rendered
BIN  markitup_field/static/markitup/sets/restructuredtext/images/list-numeric.png
View
Diff not rendered
BIN  markitup_field/static/markitup/sets/restructuredtext/images/picture.png
View
Diff not rendered
BIN  markitup_field/static/markitup/sets/restructuredtext/images/preview.png
View
Diff not rendered
BIN  markitup_field/static/markitup/sets/restructuredtext/images/quotes.png
View
Diff not rendered
53 markitup_field/static/markitup/sets/restructuredtext/set.js
View
@@ -0,0 +1,53 @@
+// -------------------------------------------------------------------
+// markItUp!
+// -------------------------------------------------------------------
+// Copyright (C) 2008 Jay Salvat
+// http://markitup.jaysalvat.com/
+// -------------------------------------------------------------------
+// ReStructured Text
+// http://docutils.sourceforge.net/
+// http://docutils.sourceforge.net/rst.html
+// -------------------------------------------------------------------
+// Mark Renron <indexofire@gmail.com>
+// http://www.indexofire.com
+// -------------------------------------------------------------------
+// Jannis Leidel <jannis@leidel.info>
+// http://enn.io
+// -------------------------------------------------------------------
+mySettings = {
+ nameSpace: 'ReST',
+ onShiftEnter: {keepDefault:false, openWith:'\n\n'},
+ onTab: {keepDefault:false, replaceWith:' '},
+ markupSet: [
+ {name:'Level 1 Heading', key:'1', placeHolder:'Your title Here...', closeWith:function(markItUp) { return miu.markdownTitle(markItUp, '#'); } },
+ {name:'Level 2 Heading', key:'2', placeHolder:'Your title here...', closeWith:function(markItUp) { return miu.markdownTitle(markItUp, '*'); } },
+ {name:'Level 3 Heading', key:'3', placeHolder:'Your title here...', closeWith:function(markItUp) { return miu.markdownTitle(markItUp, '='); } },
+ {name:'Level 4 Heading', key:'4', placeHolder:'Your title here...', closeWith:function(markItUp) { return miu.markdownTitle(markItUp, '-'); } },
+ {name:'Level 5 Heading', key:'5', placeHolder:'Your title here...', closeWith:function(markItUp) { return miu.markdownTitle(markItUp, '^'); } },
+ {name:'Level 6 Heading', key:'6', placeHolder:'Your title here...', closeWith:function(markItUp) { return miu.markdownTitle(markItUp, '"'); } },
+ {separator:'---------------' },
+ {name:'Bold', key:'B', openWith:'**', closeWith:'**', placeHolder:'Input Your Bold Text Here...'},
+ {name:'Italic', key:'I', openWith:'`', closeWith:'`', placeHolder:'Input Your Italic Text Here...'},
+ {separator:'---------------' },
+ {name:'Bulleted List', openWith:'- ' },
+ {name:'Numeric List', openWith:function(markItUp) { return markItUp.line+'. '; } },
+ {separator:'---------------' },
+ {name:'Picture', key:'P', openWith:'.. image:: ', placeHolder:'Link Your Images Here...'},
+ {name:'Link', key:"L", openWith:'`', closeWith:'`_ \n\n.. _`Link Name`: [![Url:!:http://]!]', placeHolder:'Link Name' },
+ {name:'Quotes', openWith:' '},
+ {name:'Code', openWith:'\n:: \n\n '},
+ {name:'Preview', className:'preview', call:'preview'}
+ ]
+};
+
+// mIu nameSpace to avoid conflict.
+miu = {
+ markdownTitle: function(markItUp, character) {
+ heading = '';
+ n = $.trim(markItUp.selection||markItUp.placeHolder).length;
+ for(i = 0; i < n; i++) {
+ heading += character;
+ }
+ return '\n'+heading;
+ }
+};
53 markitup_field/static/markitup/sets/restructuredtext/style.css
View
@@ -0,0 +1,53 @@
+/* -------------------------------------------------------------------
+// ReST!
+// ------------------------------------------------------------------*/
+.ReST .markItUpButton1 a {
+ background-image:url(images/h1.png);
+}
+.ReST .markItUpButton2 a {
+ background-image:url(images/h2.png);
+}
+.ReST .markItUpButton3 a {
+ background-image:url(images/h3.png);
+}
+.ReST .markItUpButton4 a {
+ background-image:url(images/h4.png);
+}
+.ReST .markItUpButton5 a {
+ background-image:url(images/h5.png);
+}
+.ReST .markItUpButton6 a {
+ background-image:url(images/h6.png);
+}
+
+.ReST .markItUpButton7 a {
+ background-image:url(images/bold.png);
+}
+.ReST .markItUpButton8 a {
+ background-image:url(images/italic.png);
+}
+
+.ReST .markItUpButton9 a {
+ background-image:url(images/list-bullet.png);
+}
+.ReST .markItUpButton10 a {
+ background-image:url(images/list-numeric.png);
+}
+
+.ReST .markItUpButton11 a {
+ background-image:url(images/picture.png);
+}
+.ReST .markItUpButton12 a {
+ background-image:url(images/link.png);
+}
+
+.ReST .markItUpButton13 a {
+ background-image:url(images/quotes.png);
+}
+.ReST .markItUpButton14 a {
+ background-image:url(images/code.png);
+}
+
+.ReST .preview a {
+ background-image:url(images/preview.png);
+}
1  markitup_field/static/markitup/sets/style.css
View
@@ -0,0 +1 @@
+.default .markItUp .markItUpButton1 a{background-image:url(default/images/bold.png)}.default .markItUp .markItUpButton2 a{background-image:url(default/images/italic.png)}.default .markItUp .markItUpButton3 a{background-image:url(default/images/stroke.png)}.default .markItUp .markItUpButton4 a{background-image:url(default/images/picture.png)}.default .markItUp .markItUpButton5 a{background-image:url(default/images/link.png)}.default .markItUp .markItUpButton6 a{background-image:url(default/images/clean.png)}.default .markItUp .preview a{background-image:url(default/images/preview.png)}.markdown .markItUp .markItUpButton1 a{background-image:url(markdown/images/h1.png)}.markdown .markItUp .markItUpButton2 a{background-image:url(markdown/images/h2.png)}.markdown .markItUp .markItUpButton3 a{background-image:url(markdown/images/h3.png)}.markdown .markItUp .markItUpButton4 a{background-image:url(markdown/images/h4.png)}.markdown .markItUp .markItUpButton5 a{background-image:url(markdown/images/h5.png)}.markdown .markItUp .markItUpButton6 a{background-image:url(markdown/images/h6.png)}.markdown .markItUp .markItUpButton7 a{background-image:url(markdown/images/bold.png)}.markdown .markItUp .markItUpButton8 a{background-image:url(markdown/images/italic.png)}.markdown .markItUp .markItUpButton9 a{background-image:url(markdown/images/list-bullet.png)}.markdown .markItUp .markItUpButton10 a{background-image:url(markdown/images/list-numeric.png)}.markdown .markItUp .markItUpButton11 a{background-image:url(markdown/images/picture.png)}.markdown .markItUp .markItUpButton12 a{background-image:url(markdown/images/link.png)}.markdown .markItUp .markItUpButton13 a{background-image:url(markdown/images/quotes.png)}.markdown .markItUp .markItUpButton14 a{background-image:url(markdown/images/code.png)}.markdown .markItUp .preview a{background-image:url(markdown/images/preview.png)}.restructuredtext .ReST .markItUpButton1 a{background-image:url(restructuredtext/images/h1.png)}.restructuredtext .ReST .markItUpButton2 a{background-image:url(restructuredtext/images/h2.png)}.restructuredtext .ReST .markItUpButton3 a{background-image:url(restructuredtext/images/h3.png)}.restructuredtext .ReST .markItUpButton4 a{background-image:url(restructuredtext/images/h4.png)}.restructuredtext .ReST .markItUpButton5 a{background-image:url(restructuredtext/images/h5.png)}.restructuredtext .ReST .markItUpButton6 a{background-image:url(restructuredtext/images/h6.png)}.restructuredtext .ReST .markItUpButton7 a{background-image:url(restructuredtext/images/bold.png)}.restructuredtext .ReST .markItUpButton8 a{background-image:url(restructuredtext/images/italic.png)}.restructuredtext .ReST .markItUpButton9 a{background-image:url(restructuredtext/images/list-bullet.png)}.restructuredtext .ReST .markItUpButton10 a{background-image:url(restructuredtext/images/list-numeric.png)}.restructuredtext .ReST .markItUpButton11 a{background-image:url(restructuredtext/images/picture.png)}.restructuredtext .ReST .markItUpButton12 a{background-image:url(restructuredtext/images/link.png)}.restructuredtext .ReST .markItUpButton13 a{background-image:url(restructuredtext/images/quotes.png)}.restructuredtext .ReST .markItUpButton14 a{background-image:url(restructuredtext/images/code.png)}.restructuredtext .ReST .preview a{background-image:url(restructuredtext/images/preview.png)}.textile .markItUp .markItUpButton1 a{background-image:url(textile/images/h1.png)}.textile .markItUp .markItUpButton2 a{background-image:url(textile/images/h2.png)}.textile .markItUp .markItUpButton3 a{background-image:url(textile/images/h3.png)}.textile .markItUp .markItUpButton4 a{background-image:url(textile/images/h4.png)}.textile .markItUp .markItUpButton5 a{background-image:url(textile/images/h5.png)}.textile .markItUp .markItUpButton6 a{background-image:url(textile/images/h6.png)}.textile .markItUp .markItUpButton7 a{background-image:url(textile/images/paragraph.png)}.textile .markItUp .markItUpButton8 a{background-image:url(textile/images/bold.png)}.textile .markItUp .markItUpButton9 a{background-image:url(textile/images/italic.png)}.textile .markItUp .markItUpButton10 a{background-image:url(textile/images/stroke.png)}.textile .markItUp .markItUpButton11 a{background-image:url(textile/images/list-bullet.png)}.textile .markItUp .markItUpButton12 a{background-image:url(textile/images/list-numeric.png)}.textile .markItUp .markItUpButton13 a{background-image:url(textile/images/picture.png)}.textile .markItUp .markItUpButton14 a{background-image:url(textile/images/link.png)}.textile .markItUp .markItUpButton15 a{background-image:url(textile/images/quotes.png)}.textile .markItUp .markItUpButton16 a{background-image:url(textile/images/code.png)}.textile .markItUp .preview a{background-image:url(textile/images/preview.png)}
BIN  markitup_field/static/markitup/sets/textile/images/bold.png
View
Diff not rendered
BIN  markitup_field/static/markitup/sets/textile/images/code.png
View
Diff not rendered
BIN  markitup_field/static/markitup/sets/textile/images/h1.png
View
Diff not rendered
BIN  markitup_field/static/markitup/sets/textile/images/h2.png
View
Diff not rendered
BIN  markitup_field/static/markitup/sets/textile/images/h3.png
View
Diff not rendered
BIN  markitup_field/static/markitup/sets/textile/images/h4.png
View
Diff not rendered
BIN  markitup_field/static/markitup/sets/textile/images/h5.png
View
Diff not rendered
BIN  markitup_field/static/markitup/sets/textile/images/h6.png
View
Diff not rendered
BIN  markitup_field/static/markitup/sets/textile/images/italic.png
View
Diff not rendered
BIN  markitup_field/static/markitup/sets/textile/images/link.png
View
Diff not rendered
BIN  markitup_field/static/markitup/sets/textile/images/list-bullet.png
View
Diff not rendered
BIN  markitup_field/static/markitup/sets/textile/images/list-numeric.png
View
Diff not rendered
BIN  markitup_field/static/markitup/sets/textile/images/paragraph.png
View
Diff not rendered
BIN  markitup_field/static/markitup/sets/textile/images/picture.png
View
Diff not rendered
BIN  markitup_field/static/markitup/sets/textile/images/preview.png
View
Diff not rendered
BIN  markitup_field/static/markitup/sets/textile/images/quotes.png
View
Diff not rendered
BIN  markitup_field/static/markitup/sets/textile/images/stroke.png
View
Diff not rendered
11 markitup_field/static/markitup/sets/textile/readme.txt
View
@@ -0,0 +1,11 @@
+Markup language:
+Textile
+
+Description:
+A basic Textile markup set with Headings, Bold, Italic, Stroke through, Picture, Link, List, Quotes, Code, Preview button.
+
+Install:
+- Download the zip file
+- Unzip it in your markItUp! sets folder
+- Modify your JS link to point at this set.js
+- Modify your CSS link to point at this style.css
39 markitup_field/static/markitup/sets/textile/set.js
View
@@ -0,0 +1,39 @@
+// -------------------------------------------------------------------
+// markItUp!
+// -------------------------------------------------------------------
+// Copyright (C) 2008 Jay Salvat
+// http://markitup.jaysalvat.com/
+// -------------------------------------------------------------------
+// Textile tags example
+// http://en.wikipedia.org/wiki/Textile_(markup_language)
+// http://www.textism.com/
+// -------------------------------------------------------------------
+// Feel free to add more tags
+// -------------------------------------------------------------------
+mySettings = {
+ onShiftEnter: {keepDefault:false, replaceWith:'\n\n'},
+ markupSet: [
+ {name:'Heading 1', key:'1', openWith:'h1(!(([![Class]!]))!). ', placeHolder:'Your title here...' },
+ {name:'Heading 2', key:'2', openWith:'h2(!(([![Class]!]))!). ', placeHolder:'Your title here...' },
+ {name:'Heading 3', key:'3', openWith:'h3(!(([![Class]!]))!). ', placeHolder:'Your title here...' },
+ {name:'Heading 4', key:'4', openWith:'h4(!(([![Class]!]))!). ', placeHolder:'Your title here...' },
+ {name:'Heading 5', key:'5', openWith:'h5(!(([![Class]!]))!). ', placeHolder:'Your title here...' },
+ {name:'Heading 6', key:'6', openWith:'h6(!(([![Class]!]))!). ', placeHolder:'Your title here...' },
+ {name:'Paragraph', key:'P', openWith:'p(!(([![Class]!]))!). '},
+ {separator:'---------------' },
+ {name:'Bold', key:'B', closeWith:'*', openWith:'*'},
+ {name:'Italic', key:'I', closeWith:'_', openWith:'_'},
+ {name:'Stroke through', key:'S', closeWith:'-', openWith:'-'},
+ {separator:'---------------' },
+ {name:'Bulleted list', openWith:'(!(* |!|*)!)'},
+ {name:'Numeric list', openWith:'(!(# |!|#)!)'},
+ {separator:'---------------' },
+ {name:'Picture', replaceWith:'![![Source:!:http://]!]([![Alternative text]!])!'},
+ {name:'Link', openWith:'"', closeWith:'([![Title]!])":[![Link:!:http://]!]', placeHolder:'Your text to link here...' },
+ {separator:'---------------' },
+ {name:'Quotes', openWith:'bq(!(([![Class]!])!)). '},
+ {name:'Code', openWith:'@', closeWith:'@'},
+ {separator:'---------------' },
+ {name:'Preview', call:'preview', className:'preview'}
+ ]
+}
60 markitup_field/static/markitup/sets/textile/style.css
View
@@ -0,0 +1,60 @@
+/* -------------------------------------------------------------------
+// markItUp!
+// By Jay Salvat - http://markitup.jaysalvat.com/
+// ------------------------------------------------------------------*/
+.markItUp .markItUpButton1 a {
+ background-image:url(images/h1.png);
+}
+.markItUp .markItUpButton2 a {
+ background-image:url(images/h2.png);
+}
+.markItUp .markItUpButton3 a {
+ background-image:url(images/h3.png);
+}
+.markItUp .markItUpButton4 a {
+ background-image:url(images/h4.png);
+}
+.markItUp .markItUpButton5 a {
+ background-image:url(images/h5.png);
+}
+.markItUp .markItUpButton6 a {
+ background-image:url(images/h6.png);
+}
+.markItUp .markItUpButton7 a {
+ background-image:url(images/paragraph.png);
+}
+
+.markItUp .markItUpButton8 a {
+ background-image:url(images/bold.png);
+}
+.markItUp .markItUpButton9 a {
+ background-image:url(images/italic.png);
+}
+.markItUp .markItUpButton10 a {
+ background-image:url(images/stroke.png);
+}
+
+.markItUp .markItUpButton11 a {
+ background-image:url(images/list-bullet.png);
+}
+.markItUp .markItUpButton12 a {
+ background-image:url(images/list-numeric.png);
+}
+
+.markItUp .markItUpButton13 a {
+ background-image:url(images/picture.png);
+}
+.markItUp .markItUpButton14 a {
+ background-image:url(images/link.png);
+}
+
+.markItUp .markItUpButton15 a {
+ background-image:url(images/quotes.png);
+}
+.markItUp .markItUpButton16 a {
+ background-image:url(images/code.png);
+}
+
+.markItUp .preview a {
+ background-image:url(images/preview.png);
+}
BIN  markitup_field/static/markitup/skins/markitup/images/bg-container.png
View
Diff not rendered
BIN  markitup_field/static/markitup/skins/markitup/images/bg-editor-bbcode.png
View
Diff not rendered
BIN  markitup_field/static/markitup/skins/markitup/images/bg-editor-dotclear.png
View
Diff not rendered
BIN  markitup_field/static/markitup/skins/markitup/images/bg-editor-html.png
View
Diff not rendered
BIN  markitup_field/static/markitup/skins/markitup/images/bg-editor-json.png
View
Diff not rendered
BIN  markitup_field/static/markitup/skins/markitup/images/bg-editor-markdown.png
View
Diff not rendered
BIN  markitup_field/static/markitup/skins/markitup/images/bg-editor-textile.png
View
Diff not rendered
BIN  markitup_field/static/markitup/skins/markitup/images/bg-editor-wiki.png
View
Diff not rendered
BIN  markitup_field/static/markitup/skins/markitup/images/bg-editor-xml.png
View
Diff not rendered
BIN  markitup_field/static/markitup/skins/markitup/images/bg-editor.png
View
Diff not rendered
BIN  markitup_field/static/markitup/skins/markitup/images/handle.png
View
Diff not rendered
BIN  markitup_field/static/markitup/skins/markitup/images/menu.png
View
Diff not rendered
BIN  markitup_field/static/markitup/skins/markitup/images/submenu.png
View
Diff not rendered
148 markitup_field/static/markitup/skins/markitup/style.css
View
@@ -0,0 +1,148 @@
+/* -------------------------------------------------------------------
+// markItUp! Universal MarkUp Engine, JQuery plugin
+// By Jay Salvat - http://markitup.jaysalvat.com/
+// ------------------------------------------------------------------*/
+.markItUp * {
+ margin:0px; padding:0px;
+ outline:none;
+}
+.markItUp a:link,
+.markItUp a:visited {
+ color:#000;
+ text-decoration:none;
+}
+.markItUp {
+ width:700px;
+ margin:5px 0 5px 0;
+ border:5px solid #F5F5F5;
+}
+.markItUpContainer {
+ border:1px solid #3C769D;
+ background:#FFF url(images/bg-container.png) repeat-x top left;
+ padding:5px 5px 2px 5px;
+ font:11px Verdana, Arial, Helvetica, sans-serif;
+}
+.markItUpEditor {
+ font:12px 'Courier New', Courier, monospace;
+ padding:5px 5px 5px 35px;
+ border:3px solid #3C769D;
+ width:643px;
+ height:320px;