From 06dc0e53c532e972bcb94cd80cad31846771753a Mon Sep 17 00:00:00 2001 From: Carl Meyer Date: Wed, 18 Mar 2009 12:40:42 -0400 Subject: [PATCH] docs, customizability of preview filter --- AUTHORS.txt | 1 + CHANGELOG.txt | 4 + INSTALL.txt | 12 ++ LICENSE.txt | 28 ++++ README.txt | 16 ++ docs/overview.txt | 143 ++++++++++++++++++ markitup/markup.py | 40 +++++ markitup/media/sets/markdown/set.js | 4 +- markitup/media/sets/textile/images/bold.png | Bin 0 -> 304 bytes markitup/media/sets/textile/images/code.png | Bin 0 -> 859 bytes markitup/media/sets/textile/images/h1.png | Bin 0 -> 276 bytes markitup/media/sets/textile/images/h2.png | Bin 0 -> 304 bytes markitup/media/sets/textile/images/h3.png | Bin 0 -> 306 bytes markitup/media/sets/textile/images/h4.png | Bin 0 -> 293 bytes markitup/media/sets/textile/images/h5.png | Bin 0 -> 304 bytes markitup/media/sets/textile/images/h6.png | Bin 0 -> 310 bytes markitup/media/sets/textile/images/italic.png | Bin 0 -> 223 bytes markitup/media/sets/textile/images/link.png | Bin 0 -> 343 bytes .../media/sets/textile/images/list-bullet.png | Bin 0 -> 344 bytes .../sets/textile/images/list-numeric.png | Bin 0 -> 357 bytes .../media/sets/textile/images/paragraph.png | Bin 0 -> 361 bytes .../media/sets/textile/images/picture.png | Bin 0 -> 606 bytes .../media/sets/textile/images/preview.png | Bin 0 -> 537 bytes markitup/media/sets/textile/images/quotes.png | Bin 0 -> 743 bytes markitup/media/sets/textile/images/stroke.png | Bin 0 -> 269 bytes markitup/media/sets/textile/readme.txt | 11 ++ markitup/media/sets/textile/set.js | 40 +++++ markitup/media/sets/textile/style.css | 60 ++++++++ markitup/settings.py | 14 ++ markitup/urls.py | 4 +- markitup/views.py | 9 +- markitup/widgets.py | 22 +-- setup.py | 2 +- 33 files changed, 391 insertions(+), 19 deletions(-) create mode 100644 AUTHORS.txt create mode 100644 CHANGELOG.txt create mode 100644 INSTALL.txt create mode 100644 LICENSE.txt create mode 100644 README.txt create mode 100644 docs/overview.txt create mode 100644 markitup/markup.py create mode 100644 markitup/media/sets/textile/images/bold.png create mode 100644 markitup/media/sets/textile/images/code.png create mode 100644 markitup/media/sets/textile/images/h1.png create mode 100644 markitup/media/sets/textile/images/h2.png create mode 100644 markitup/media/sets/textile/images/h3.png create mode 100644 markitup/media/sets/textile/images/h4.png create mode 100644 markitup/media/sets/textile/images/h5.png create mode 100644 markitup/media/sets/textile/images/h6.png create mode 100644 markitup/media/sets/textile/images/italic.png create mode 100644 markitup/media/sets/textile/images/link.png create mode 100644 markitup/media/sets/textile/images/list-bullet.png create mode 100644 markitup/media/sets/textile/images/list-numeric.png create mode 100644 markitup/media/sets/textile/images/paragraph.png create mode 100644 markitup/media/sets/textile/images/picture.png create mode 100644 markitup/media/sets/textile/images/preview.png create mode 100644 markitup/media/sets/textile/images/quotes.png create mode 100644 markitup/media/sets/textile/images/stroke.png create mode 100644 markitup/media/sets/textile/readme.txt create mode 100644 markitup/media/sets/textile/set.js create mode 100644 markitup/media/sets/textile/style.css create mode 100644 markitup/settings.py diff --git a/AUTHORS.txt b/AUTHORS.txt new file mode 100644 index 0000000..6219fa3 --- /dev/null +++ b/AUTHORS.txt @@ -0,0 +1 @@ +Carl Meyer diff --git a/CHANGELOG.txt b/CHANGELOG.txt new file mode 100644 index 0000000..0781ae0 --- /dev/null +++ b/CHANGELOG.txt @@ -0,0 +1,4 @@ +========================= +django-markitup changelog +========================= + diff --git a/INSTALL.txt b/INSTALL.txt new file mode 100644 index 0000000..edbed6e --- /dev/null +++ b/INSTALL.txt @@ -0,0 +1,12 @@ +To install django-markitup, run the following command inside this +directory: + + python setup.py install + +You can also just copy the included ``markitup`` directory somewhere +on your Python path, or symlink to it from somewhere on your Python path; +this is useful if you're working from a Subversion checkout. + +This application requires Python 2.3 or later, and Django 1.0 or later. +You can obtain Python from http://www.python.org/ and Django from +http://www.djangoproject.com/. diff --git a/LICENSE.txt b/LICENSE.txt new file mode 100644 index 0000000..f9135c0 --- /dev/null +++ b/LICENSE.txt @@ -0,0 +1,28 @@ +Copyright (c) 2009, 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. diff --git a/README.txt b/README.txt new file mode 100644 index 0000000..b8a3fee --- /dev/null +++ b/README.txt @@ -0,0 +1,16 @@ +=============== +django-markitup +=============== + +This application provides convenient integration of the MarkItUp_ +markup editor widget (by Jay Salvat) in Django projects, via a custom +form widget. It also provides server-side support for MarkItUp!'s +AJAX preview. + +For installation instructions, see the file "INSTALL.txt" in this +directory; for instructions on how to use this application, and on +what it provides, see the file "overview.txt" in the "docs/" +directory. + +.. _MarkItUp: http://markitup.jaysalvat.com/ + diff --git a/docs/overview.txt b/docs/overview.txt new file mode 100644 index 0000000..87a6708 --- /dev/null +++ b/docs/overview.txt @@ -0,0 +1,143 @@ +=============== +django-markitup +=============== + +Easy integration of the MarkItUp_ markup editor widget in Django projects. + + +.. _MarkItUp: http://markitup.jaysalvat.com/ + +Installation +============ + +Get the Bazaar trunk version of the application:: + + bzr checkout lp:django-markitup django-markitup + +To install django-markitup: + + 1. Put the ``markitup`` folder somewhere on your Python path. + + 2. Put ``'markitup'`` in your ``INSTALLED_APPS`` setting. + + 3. Make the contents of the "markitup/media" directory available + at ``MEDIA_URL/markitup``. This can be done by copying the + files, making a symlink, or through your webserver + configuration. + + 4. If you want to use AJAX-based preview: + + - Add ``url(r'^markitup/', include('markitup.urls')`` in your + root URLconf. + - Set the MARKITUP_PREVIEW_FILTER setting (see `Using AJAX preview`_ + below). + + +Using the MarkItUp! widget +========================== + +The MarkItUp! widget lives at ``markitup.widgets.MarkItUpWidget``, and +can be used like any other Django custom widget. + +To assign it to a form field:: + + from markitup.widgets import MarkItUpWidget + ... + content = forms.TextField(widget=MarkItUpWidget()) + +When this form is displayed on your site, you must include the form +media somewhere on the page using ``{{ form.media }}``, or the +MarkItUpWidget will have no effect. + +To use MarkItUpWidget in the Django admin: + + from markitup.widgets import MarkItUpWidget + + class MyModelAdmin(admin.ModelAdmin): + ... + def formfield_for_dbfield(self, db_field, **kwargs): + if db_field.name == 'content': + kwargs['widget'] = MarkItUpWidget(attrs={'class': 'vLargeTextField'}) + return super(MyModelAdmin, self).formfield_for_dbfield(db_field, **kwargs) + +Choosing a MarkItUp! button set and skin +======================================== + +MarkItUp! allows the toolbar button-set to be customized in a +Javascript settings file. By default, django-markitup uses the +"default" set (meant for HTML editing). Django-markitup also includes +basic "markdown" and "textile" sets (these are the sets available from +`the MarkItUp site `_, modified only to +add previewParserPath). + +To use an alternate set, assign the ``MARKITUP_SET`` setting a URL +path (absolute or relative to MEDIA_URL) to the set directory. For +instance, to use the "markdown" set included with django-markitup:: + + MARKITUP_SET = 'markitup/sets/markdown' + +MarkItUp! skins can be specified in a similar manner. Both "simple" +and "markitup" skins are included, by default "simple" is used. To +use the "markitup" skin instead:: + + MARKITUP_SKIN = 'markitup/skins/markitup' + +Neither of these settings has to refer to a location inside +django-markitup's media. You can define your own sets and skins and +store them anywhere, as long as you set the MARKITUP_SET and +MARKITUP_SKIN settings to the appropriate URLs. + +Set and skin may also be chosen on a per-widget basis by passing the +``markitup_set`` and ``markitup_skin`` keyword arguments to +MarkItUpWidget. + + +Using AJAX preview +================== + +If you've included ``markitup.urls`` in your root URLconf (as +demonstrated above under `Installation`_), all you need to enable +server-side AJAX preview is the ``MARKITUP_PREVIEW_FILTER`` setting. + +``MARKITUP_PREVIEW_FILTER`` must be a two-tuple. + +The first element must be a string, the Python dotted path to a markup +filter function. This function should accept markup as its first +argument and return HTML. It may accept other keyword arguments as +well. You may parse your markup for preview using any method you +choose, as long as you can wrap it in a function that meets these +criteria. + +The second element must be a dictionary of keyword arguments to pass +to the filter function. The dictionary may be empty. + +For example, if you have python-markdown installed, you could use it +like this:: + + MARKITUP_PREVIEW_FILTER = ('markdown.markdown', {'safe_mode': True}) + +Alternatively, you could use the "textile" filter provided by Django +like this:: + + MARKITUP_PREVIEW_FILTER = ('django.contrib.markup.templatetags.markup.textile', {}) + +(The textile filter function doesn't accept keyword arguments, so the +kwargs dictionary must be empty in this case.) + +**Note:** If you use your own custom MarkItUp! set, be sure to set the + ``previewParserPath`` option to ``'/markitup/preview/'``. + + +Other settings +============== + +MarkItUp! requires the jQuery Javascript library. By default, +django-markitup links to the most recent minor version of jQuery 1.3 +available at ajax.googleapis.com (via the URL +``http://ajax.googleapis.com/ajax/libs/jquery/1.3/jquery.min.js``). +If you wish to use a different version of jQuery, or host it yourself, +set the JQUERY_URL setting. For example:: + + JQUERY_URL = 'jquery.min.js' + +This will use the jQuery available at MEDIA_URL/jquery.min.js. diff --git a/markitup/markup.py b/markitup/markup.py new file mode 100644 index 0000000..64a8f51 --- /dev/null +++ b/markitup/markup.py @@ -0,0 +1,40 @@ +""" +markup filters for django-markitup + +Time-stamp: <2009-03-18 11:44:57 carljm markup.py> + +This module provides a ``filter_func`` module-level markup filter +function based on the MARKITUP_PREVIEW_FILTER setting. + +MARKITUP_PREVIEW_FILTER should be a two-tuple, where the first element +is a dotted-path string to a markup filter function, and the second +element is a dictionary of kwargs to be passed to the filter function +along with the markup to parse. + +For instance, if MARKITUP_PREVIEW_FILTER is set to:: + + ('markdown.markdown', {'safe_mode': True}) + +then calling ``filter_func(text)`` is equivalent to:: + + from markdown import markdown + markdown(text, safe_mode=True) + +Though the implementation differs, the format of the +MARKITUP_PREVIEW_FILTER setting is inspired by James Bennett's +django-template-utils_. + +.. _django-template-utils: http://code.google.com/p/django-template-utils/ + +""" +from django.utils.functional import curry, wraps + +from markitup.settings import MARKITUP_PREVIEW_FILTER + +if MARKITUP_PREVIEW_FILTER is None: + filter_func = lambda text: text +else: + filter_path, filter_kwargs = MARKITUP_PREVIEW_FILTER + module, funcname = filter_path.rsplit('.', 1) + func = getattr(__import__(module, {}, {}, [funcname]), funcname) + filter_func = wraps(func)(curry(func, **filter_kwargs)) diff --git a/markitup/media/sets/markdown/set.js b/markitup/media/sets/markdown/set.js index 96970a4..21649dd 100644 --- a/markitup/media/sets/markdown/set.js +++ b/markitup/media/sets/markdown/set.js @@ -11,7 +11,7 @@ // Feel free to add more tags // ------------------------------------------------------------------- mySettings = { - previewParserPath: '', + previewParserPath: '/markitup/preview/', onShiftEnter: {keepDefault:false, openWith:'\n\n'}, markupSet: [ {name:'First Level Heading', key:'1', placeHolder:'Your title here...', closeWith:function(markItUp) { return miu.markdownTitle(markItUp, '=') } }, @@ -49,4 +49,4 @@ miu = { } return '\n'+heading; } -} \ No newline at end of file +} diff --git a/markitup/media/sets/textile/images/bold.png b/markitup/media/sets/textile/images/bold.png new file mode 100644 index 0000000000000000000000000000000000000000..889ae80e37b6167cc15f2a89e05a183815ec18b2 GIT binary patch literal 304 zcmV-00nh%4P)b^}|6b=Y6y(;Y{!a!g z@UQp#@Aw}>L3(}s|7f5BUjeuKZvQRjV<2U7yvu*H{aAbvQ6K!@3oKzW z-{Qa8d3gae1^)HE{~f^!v<1}u>;4xnKvUpW540I-w9J3a{{r=B3T*2g{_BH1CtaZO zpZ`6V0*V5g1e5i;`_=Z#_e=H*@8|93RG@lX;D!K7TKswwko8{x00005>jf6w4x#gTU%_MMNlkNp$oSbvBp&uHw9M;u0-4@=t5BI zP6Hx#-C_{5RMJ z0_P+Xkumexn8%)S+Y)#l(gR;YJP<6#1-=jjK0LONWPdJQIR8uK1HpvVIxBIQ2ztt+ zqoEx_X9S%QGMe=~(k#sebCL-an)%CR%a7YtUOQUgv+G>~?N~XSWhx=? z@$fx}0MB;$`JWcQ-Re{XV~5|{DvU(#*+NF*g)j^qk#b~G9_O!i*y&mZVZ=a3;Go(K z`DkskYn56Nhu+k@1Ke*uY|x zI&k6j$JfNe_a{GH%=n2rZOz$Z8R9V?Pe36hIk}jo+A-`;dt9vyvBu#Xm@veu&@v`| zzt%mwc_$nd0-sMVx2d)b0!MqGxmfCumx7yB#nIUWvA{!HOMfslMyW1iV&nY>zxwyj z8^JfLN|kT z4m^Q1mhO(_r4w@`V?H=YNkOf(i&bHT3Auc3bryK1_{hDSetLoLN{VLB^78ULiNFy^ zkUqqG$fjVkJj5tfWkOn|P5`HVEp5@-mGnc0wvJGHC=+39MC2TWT#i?t*~fNch*he_ zgtS^8dH$(KlW)EF1b4Fzv~?&0IQaNdg;W5&{t&Bmg9&N1-rBBr_;Rg8ekw^mn;@T# zlS{|Rq+-Nlg18i%UY;i|q1NnSwf>I@85#4U4002ovPDHLkV1mEDi4_0< literal 0 HcmV?d00001 diff --git a/markitup/media/sets/textile/images/h1.png b/markitup/media/sets/textile/images/h1.png new file mode 100644 index 0000000000000000000000000000000000000000..9c122e91e358860733eaf08fd543e5fc585d4cfd GIT binary patch literal 276 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!60wlNoGJgf6SkfJR9T^zbpD<_bdI{u9mbgZg z1m~xflqVLYGB~E>C#5QQ<|d}62BjvZR2H60wE-$x=IP=XqH%ujg^j!|20W|*-XbO@ zAtBSd^khRzd{=pNv@vN)9uZDqGTXuVPf6#I=?;x2B`Y;1YQMI>>GxvE??vtn{c>{A z7MYxUVrui2JTF|YR&ldntL8M3{q7no52$4`vIX;r@S8@YTFOM5*~nV4Gk-UYI5L$} zDw(h9UDksmVjphbEsSQ?UdGUxU4Htk{EZoY&3@-Y5*_;Wwk`ZAkg@!FaC~ii{N>;; VD%(>GD}XL$@O1TaS?83{1OVXtVO9VD literal 0 HcmV?d00001 diff --git a/markitup/media/sets/textile/images/h2.png b/markitup/media/sets/textile/images/h2.png new file mode 100644 index 0000000000000000000000000000000000000000..fbd87657fbe001c0a78fb095284fffc32e739497 GIT binary patch literal 304 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!60wlNoGJgf6SkfJR9T^zbpD<_bdI{u9mbgZg z1m~xflqVLYGB~E>C#5QQ<|d}62BjvZR2H60wE-$ROXGNhtQ`{C(%$wdeB3 zGTnLdz~IMJtNg?T>Z(s;oVU0)KW5x*9xvq)rPF;` zY|Fc4&#rLa>Txf#@y+aKf+ac0%`STzAI(*qdYo^XFH557y+_x*JpKO5^1S9?c^6}{ zP=+&OVHtDUrGNmdKI;Vst0KHFj AM*si- literal 0 HcmV?d00001 diff --git a/markitup/media/sets/textile/images/h3.png b/markitup/media/sets/textile/images/h3.png new file mode 100644 index 0000000000000000000000000000000000000000..c7836cf09e4565cc76c13bd14c13971c9e093c40 GIT binary patch literal 306 zcmV-20nPr2P)wEzGB literal 0 HcmV?d00001 diff --git a/markitup/media/sets/textile/images/h4.png b/markitup/media/sets/textile/images/h4.png new file mode 100644 index 0000000000000000000000000000000000000000..4e929eaf583f10cf50eb1666ff6530b9d4cc7915 GIT binary patch literal 293 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!60wlNoGJgf6SkfJR9T^zbpD<_bdI{u9mbgZg z1m~xflqVLYGB~E>C#5QQ<|d}62BjvZR2H60wE-&H?&;zfqH%ujg^j$;1_G=B-XbO( zon2btF4r#xDw?mmvtwaL3R_~+Yz66*rrQmiHySwec#9a-mn?F*9`VcnzTNDrbNY9( zxOA;CUb9S|sk-b7=Pc<<>lMA8+|AaBj(NoLhh2`-;+F zenR#-z6;(Syt?;Ub#DVE_OC literal 0 HcmV?d00001 diff --git a/markitup/media/sets/textile/images/h5.png b/markitup/media/sets/textile/images/h5.png new file mode 100644 index 0000000000000000000000000000000000000000..30cabebf7445e168a0f31b0ed68c43d54eaf017d GIT binary patch literal 304 zcmV-00nh%4P)ZVg9Hj*!Zw zxkAM~zCH&l><=6QeDdgV4l9hop+%GWq_IPV?Z641X8iiHrWJUN^2}hSiGjhsfbOLp z?d`9_MC0P3jVAVsEwEMMb0n zB0~XIzS#Ls)C#5QQ<|d}62BjvZR2H60wE-$B^mK6y(Kw&{<9vg>Q9!g~ne(gm zmj4swoA@7?D86%i^8WzK9JM17E&sp&Z#dpHfz$E-U9ks&4?Z9Gyg!%0k2Q{M-Tz#> z2OnD>vrPZ*#{EHKLq)>Jcx{H|Ovdb&|4aQZWSipI{El%e^Cxx{^9vSw28s;a3IDB= TS1%U=TF&6<>gTe~DWM4fm>N^1 literal 0 HcmV?d00001 diff --git a/markitup/media/sets/textile/images/link.png b/markitup/media/sets/textile/images/link.png new file mode 100644 index 0000000000000000000000000000000000000000..25eacb7c2524142262d68bf729c5e2b61adfd6d4 GIT binary patch literal 343 zcmV-d0jU0oP)$`dXYaZs9=SbAto%g@>T~?_bH&lTUn@`uo|1bXE{eSR(AO)ESb=V4`uk}mK|39Px&03WLbv~pzk+s7D@lK^ zn+aB+sp)&Y_x-B3>;6ywU--WQNUr<8>TU0P-|L#1U&;A)67w(+> pDf@fM7q9#F25QXo3rUI;002ro52U44e~JJA002ovPDHLkV1l;_q@Mr) literal 0 HcmV?d00001 diff --git a/markitup/media/sets/textile/images/list-bullet.png b/markitup/media/sets/textile/images/list-bullet.png new file mode 100644 index 0000000000000000000000000000000000000000..4a8672bde48f806d3d4d37db192588a9aa3eac10 GIT binary patch literal 344 zcmV-e0jK_nP)PbXFR5;6H z`2YVu10|S&DhA}te_Swi*Xsu$nk)lAnzx?+_#Z@r_~qs0*+Bfiq@?73K|#U)?Ck9S zsi~>|6A}{sM@B~e4-O9gPhA%bd?2RGd{of6>E(lvp1b6Ep>6&12TPB<{a?EDDL4@0 z;^ML+A|n0=1_u83^78uc?CkvC#>VEqiHXU7U0vP(YHDhzff&$ntDt1@;|H#l*M@2! z+U8#>h@W=vfpy*`^1J}j+`sMRe-I7g8yOj8Yin!&S5Z;VicFNp}SURRVGD{CSNFe~ni^^#wyl5uzj4je z|23%2?k#{x(*%mqe9M%mih+W%ElRQ}7!$^91> z7ymCLB=nz$hvz>#JNtiTW@gkt1Zf0eyP_){bPq%T_kY#2Z7&xs00000NkvXXu0mjf DNYA0= literal 0 HcmV?d00001 diff --git a/markitup/media/sets/textile/images/paragraph.png b/markitup/media/sets/textile/images/paragraph.png new file mode 100644 index 0000000000000000000000000000000000000000..95704fbab31bf9d71315c52f73f106e9b555255c GIT binary patch literal 361 zcmV-v0ha!WP)W2UMkn=!+`e+&#r4!m&t*Pi{kVy<{yV5rBn%1W8t zSc#vBL6V!9;o`ktd-^>D7(tpD{uAK>89pW@UKU2M&7k1<{}&?u{~w6_M>q^XHopD# zj{zRGFdFC`m|=JgcyRw`*p4$_S3h|7hvD1L|3FO;TfwpQ_dj7T-0PBk52V5r3LXh+ zs&njyMf3kZ3=9ldq8w*5KA0f){@b^|?-~BUyz(C!4g_3)48VSdx!^BW2jDjVQ2rnAt>LM%-F zK|rtwgcU)}7x~z1Hrcs5bH*ZO$!>xO8K#?==bZPQ_ecnV>#P`H`QzGaRhd62G_&rC zTLU$c7_x*nFP_dW#Q+*);mMHE?j)HexK784D4x9l_tfpz2$@1y}9rkF+ zI+J5NMWeZyObc!d+rUc=>D+uOdAOg#%+Ej6h+wn5^xPmVVH*Eu446Y0A_@ zo$rlds-+sL10DbHs{AQG2a)rMyf zFQK~pm1x3+7!nu%-M`k}``c>^00{o_1pjWJUTfl8mg=3qGEl8H@}^@w`VUx0_$uy4 z2FhRqKX}xI*?Tv1DJd8z#F#0c%*~rM30HE1@2o5m~}ZyoWhqv>ql{V z1ZGE0lgcoK^lx+eqc*rAX1Ky;Xx3U%u#zG!m-;eD1Qsn@kf3|F9qz~|95=&g3(7!X zB}JAT>RU;a%vaNOGnJ%e1=K6eAh43c(QN8RQ6~GP%O}Jju$~Ld*%`mO1p?P)vCi#|P&Xm-dkucwL z3)87{8iWe96huvPHfK`KOdC2Z({T6vJ9pwDx$D4>d(Pqff6w7Lmj{5i6;ZyPPpPN; zroaW=6d#@oL2Fa53F~$Su10(RG%K0p3VTuP3?Z=nBA8z$uq+XLUL^QrC74`bU|!e| zr>hK{)%Q!vdmIO5Z3JIvaOyjOX`X@c8-ua03`Q&)f&%p*{(A$q`ZTTjk%q_T7>v^J zu!R-a9fFLScYlKkNBP_Cob=9m9JLVoC-?c{)eOtMnh7qNN{ejy2sM{pS^mgFHJm@(buuM4>=<5Vr$&Kzw{B?uPr; z(1Yf=#g)zADkWnx=MR%ykl| z3Ui42k+O2{bCn)01-s5Sxp|z{G2di&KT(_M6;$EI zDL57JFf}cw4bP1P$pgTRKH$0@h|~aA>j`qZ2*kU5t2EVD5#~@VNhqx{vz8ethDD-=+1vnemftUBA zF;N!Q%PBB5B=KLB#QO(CHe?;R+-C8M?ppDW>R$5`cCPq@YpusFRTaH1i9Kv;l<>I( Ze*oTy+;kdDB`N>_002ovPDHLkV1l3CM+g7_ literal 0 HcmV?d00001 diff --git a/markitup/media/sets/textile/images/stroke.png b/markitup/media/sets/textile/images/stroke.png new file mode 100644 index 0000000000000000000000000000000000000000..612058a78eba4e3ca259aa13417fd60cd6cf2fbd GIT binary patch literal 269 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!60wlNoGJgf6SkfJR9T^zbpD<_bdI{u9mbgZg z1m~xflqVLYGB~E>C#5QQ<|d}62BjvZR2H60wE-%c@9E+gqH#X?$N2_%qkv$?&V++! z-fX$@sb%KG-5a$|R8J4(Tcmu7`G0cYgxS-++3#dN^zA^J(=P8r|6lx9G_LLaZ+v5S z!d9iC@)!RP{FnQmdw#}3Ee(C$|NPA#|L6YmR@fBO9w|C7oMMQ$vc`Tu(RETvC<`(>OPJ!ieM-fH~m>7>j + +""" +from django.conf import settings + +MARKITUP_PREVIEW_FILTER = getattr(settings, 'MARKITUP_PREVIEW_FILTER', None) +MARKITUP_SET = getattr(settings, 'MARKITUP_SET', 'markitup/sets/default') +MARKITUP_SKIN = getattr(settings, 'MARKITUP_SKIN', 'markitup/skins/simple') +JQUERY_URL = getattr( + settings, 'JQUERY_URL', + 'http://ajax.googleapis.com/ajax/libs/jquery/1.3/jquery.min.js') diff --git a/markitup/urls.py b/markitup/urls.py index e0f63c7..f012340 100644 --- a/markitup/urls.py +++ b/markitup/urls.py @@ -1,8 +1,8 @@ from django.conf.urls.defaults import * -from markitup.views import apply_markdown +from markitup.views import apply_filter urlpatterns = patterns( '', - url(r'markdown/$', apply_markdown, name='markitup_markdown') + url(r'preview/$', apply_filter, name='markitup_preview') ) diff --git a/markitup/views.py b/markitup/views.py index 42b0970..7e00fa1 100644 --- a/markitup/views.py +++ b/markitup/views.py @@ -1,15 +1,16 @@ """ views for django-markitup -Time-stamp: <2009-03-09 13:42:35 carljm views.py> +Time-stamp: <2009-03-18 11:24:32 carljm views.py> """ -from markdown import markdown from django.template.context import RequestContext from django.shortcuts import render_to_response -def apply_markdown(request): - markup = markdown(request.POST.get('data', '')) +from markitup.markup import filter_func + +def apply_filter(request): + markup = filter_func(request.POST.get('data', '')) return render_to_response( 'markitup/preview.html', {'preview':markup}, context_instance=RequestContext(request)) diff --git a/markitup/widgets.py b/markitup/widgets.py index 8344223..f67b693 100644 --- a/markitup/widgets.py +++ b/markitup/widgets.py @@ -1,38 +1,40 @@ """ widgets for django-markitup -Time-stamp: <2009-03-09 13:23:33 carljm widgets.py> +Time-stamp: <2009-03-18 11:50:47 carljm widgets.py> """ from django import forms from django.utils.safestring import mark_safe +from markitup.settings import MARKITUP_SET, MARKITUP_SKIN, JQUERY_URL + class MarkItUpWidget(forms.Textarea): """ Widget for a MarkItUp editor textarea. Takes two additional optional keyword arguments: - ``miu_set`` + ``markitup_set`` URL path (absolute or relative to MEDIA_URL) to MarkItUp - button set directory. Default: ``markitup/sets/default``. + button set directory. Default: value of MARKITUP_SET setting. - ``miu_skin`` + ``markitup_skin`` URL path (absolute or relative to MEDIA_URL) to MarkItUp skin - directory. Default: ``markitup/skins/simple``. + directory. Default: value of MARKITUP_SKIN setting. """ def __init__(self, attrs=None, - miu_set='markitup/sets/default', - miu_skin='markitup/skins/simple'): - self.miu_set = miu_set - self.miu_skin = miu_skin + markitup_set=None, + markitup_skin=None): + self.miu_set = markitup_set or MARKITUP_SET + self.miu_skin = markitup_skin or MARKITUP_SKIN super(MarkItUpWidget, self).__init__(attrs) def _media(self): return forms.Media(css={'screen': ('%s/style.css' % self.miu_skin, '%s/style.css' % self.miu_set)}, - js=('http://ajax.googleapis.com/ajax/libs/jquery/1.2.6/jquery.min.js', + js=(JQUERY_URL, 'markitup/jquery.markitup.js', '%s/set.js' % self.miu_set)) media = property(_media) diff --git a/setup.py b/setup.py index 54eb98a..6f67dbe 100644 --- a/setup.py +++ b/setup.py @@ -2,7 +2,7 @@ from setuptools import setup, find_packages setup( name='django-markitup', - version='0.1.0', + version='0.2.0', description='Django integration with the MarkItUp universal markup editor', author='Carl Meyer', author_email='carl@dirtcircle.com',