Git Product home page Git Product logo

wagtailmarkdownblock's Introduction

Wagtail Markdown Block

PLEASE NOTE: Future development on this package will be limited, since most of the features are now included in the new Draftail editor available in Wagtail. Thank you to everyone who contributed!

Markdown blocks for Wagtail Streamfields.

This Django app uses the SimpleMDE Markdown editor in the Wagtail Admin and the website.

Example Usage

from wagtailmarkdownblock.blocks import MarkdownBlock

class ContentStreamBlock(StreamBlock):
    paragraph = RichTextBlock()
    heading = TextBlock()
    code = MarkdownBlock()

Contributors

wagtailmarkdownblock's People

Contributors

flipperpa avatar mathiasp avatar miltonln avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

wagtailmarkdownblock's Issues

Discuss the idea of using SimpleMDE for Markdown

I was looking to your implementation of Markdown and i think this is quite simple and awesome but i think the SimpleMDE is more useful than Showdown because of the tools this offers, this doesn't gives a real-time preview but has a button to do it please take a look here: https://simplemde.com/
btw, SimpleMDE doesn't suffer problems previewing the tables

You mentioned this:

However, on the public facing rendering in the template, I actually override the render() method so the JavaScript dependency only exists on the editor side. This also allows front end caching mechanisms like Varnish to benefit without loading another thing on the client side for our users.

But i think i did the same on my SimpleMDE implementation. I recognize my code to achieve SimpleMDE is not simpler that your code to Showdown but we can work on this to made this simpler. Please take a look here: APSL/puput#112

What i really want is that you think about this and discuss with me this idea, i think this will give a better looking markdown editor on wagtail.

If you think is better with Showdown please give me the arguments to be convinced about it

Thank you!

TemplateDoesNotExist ... wagtailmarkdownblock/markdown_block_form.html

I installed this extension next to my project using

git clone [email protected]:FlipperPA/wagtailmarkdownblock.git
pip install -e wagtailmarkdownblock

and added the code of the example to my models. After migrating and when trying to add a new page I am seeing the error

TemplateDoesNotExist at /admin/pages/add/home/contentpage/2/
wagtailmarkdownblock/markdown_block_form.html
Request Method:	GET
Request URL:	http://localhost:8000/admin/pages/add/home/contentpage/2/
Django Version:	1.10.5
Exception Type:	TemplateDoesNotExist
Exception Value:	
wagtailmarkdownblock/markdown_block_form.html
Exception Location:	/Users/nwerner/Projekte/wspz/lib/python2.7/site-packages/django/template/loader.py in get_template, line 25
Python Executable:	/usr/local/Cellar/python/2.7.13/Frameworks/Python.framework/Versions/2.7/Resources/Python.app/Contents/MacOS/Python
Python Version:	2.7.13
Python Path:	
['/Users/nwerner/Projekte/wspz/wspz',
 '/Users/nwerner/Projekte/wspz/lib/python27.zip',
 '/Users/nwerner/Projekte/wspz/lib/python2.7',
 '/Users/nwerner/Projekte/wspz/lib/python2.7/plat-darwin',
 '/Users/nwerner/Projekte/wspz/lib/python2.7/plat-mac',
 '/Users/nwerner/Projekte/wspz/lib/python2.7/plat-mac/lib-scriptpackages',
 '/Users/nwerner/Projekte/wspz/lib/python2.7/lib-tk',
 '/Users/nwerner/Projekte/wspz/lib/python2.7/lib-old',
 '/Users/nwerner/Projekte/wspz/lib/python2.7/lib-dynload',
 '/usr/local/Cellar/python/2.7.12_2/Frameworks/Python.framework/Versions/2.7/lib/python2.7',
 '/usr/local/Cellar/python/2.7.12_2/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-darwin',
 '/usr/local/Cellar/python/2.7.12_2/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-tk',
 '/usr/local/Cellar/python/2.7.12_2/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-mac',
 '/usr/local/Cellar/python/2.7.12_2/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-mac/lib-scriptpackages',
 '/Users/nwerner/Projekte/wspz/lib/python2.7/site-packages',
 '/Users/nwerner/Projekte/wspz/wagtailmarkdownblock']
Server time:	Mi, 3 Mai 2017 09:18:42 +0200

ValueError: invalid literal for int() with base 10: '' on save.

Got the same error in 3.5.2 and 3.6.4

From the Streamfield panel in the admin interface, 'markdown' can be selected and the MDE will start, attempting to save invokes the error.

Wagtailcodeblock is working flawlessly. Perhaps I've missed something obvious?

beautifulsoup4==4.6.0
bleach==2.1.2
certifi==2018.1.18
chardet==3.0.4
Django==1.11.9
django-el-pagination==3.2.3
django-modelcluster==3.1
django-taggit==0.22.2
django-treebeard==4.2.0
djangorestframework==3.6.4
html5lib==0.999999999
idna==2.6
Markdown==2.6.11
Pillow==5.0.0
pkg-resources==0.0.0
pytz==2017.3
requests==2.18.4
six==1.11.0
Unidecode==1.0.22
urllib3==1.22
wagtail==1.13.1
wagtail-markdown==0.5a1
wagtailcodeblock==0.4.2
wagtailmarkdownblock==0.3.1
webencodings==0.5.1
Willow==1.0
Traceback (most recent call last):
  File "/usr/local/lib/python3.6/site-packages/django/core/handlers/exception.py", line 41, in inner
    response = get_response(request)
  File "/usr/local/lib/python3.6/site-packages/django/core/handlers/base.py", line 187, in _get_response
    response = self.process_exception_by_middleware(e, request)
  File "/usr/local/lib/python3.6/site-packages/django/core/handlers/base.py", line 185, in _get_response
    response = wrapped_callback(request, *callback_args, **callback_kwargs)
  File "/usr/local/lib/python3.6/site-packages/django/views/decorators/cache.py", line 43, in _cache_controlled
    response = viewfunc(request, *args, **kw)
  File "/usr/local/lib/python3.6/site-packages/wagtail/wagtailadmin/urls/__init__.py", line 96, in wrapper
    return view_func(request, *args, **kwargs)
  File "/usr/local/lib/python3.6/site-packages/wagtail/wagtailadmin/decorators.py", line 31, in decorated_view
    return view_func(request, *args, **kwargs)
  File "/usr/local/lib/python3.6/site-packages/wagtail/wagtailadmin/views/pages.py", line 321, in edit
    if form.is_valid() and not page.locked:
  File "/usr/local/lib/python3.6/site-packages/modelcluster/forms.py", line 259, in is_valid
    form_is_valid = super(ClusterForm, self).is_valid()
  File "/usr/local/lib/python3.6/site-packages/django/forms/forms.py", line 183, in is_valid
    return self.is_bound and not self.errors
  File "/usr/local/lib/python3.6/site-packages/django/forms/forms.py", line 175, in errors
    self.full_clean()
  File "/usr/local/lib/python3.6/site-packages/django/forms/forms.py", line 384, in full_clean
    self._clean_fields()
  File "/usr/local/lib/python3.6/site-packages/django/forms/forms.py", line 396, in _clean_fields
    value = field.widget.value_from_datadict(self.data, self.files, self.add_prefix(name))
  File "/usr/local/lib/python3.6/site-packages/wagtail/wagtailcore/blocks/base.py", line 523, in value_from_datadict
    return self.block_def.value_from_datadict(data, files, name)
  File "/usr/local/lib/python3.6/site-packages/wagtail/wagtailcore/blocks/stream_block.py", line 165, in value_from_datadict
    int(data['%s-%d-order' % (prefix, i)]),
ValueError: invalid literal for int() with base 10: 

models.py

 33     body = StreamField([                                                                                                                               
 34         ('heading', blocks.CharBlock(classname="full title")),                                                                                         
 35         ('paragraph', blocks.RichTextBlock()),                                                                                                         
 36         ('image', ImageChooserBlock()),                                                                                                                
 37         ('code', CodeBlock(label='Code')),                                                                                                             
 38         ('markdown', MarkdownBlock()),                                                                                                                 
 39     ])

Could you please explain how to use this?

I used wagtail2.3 version.
Everything was fine when editing the article in admin area, but after the article was published, the markdown displayed was abnormal. Could you please explain how to use this?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.