Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactoring to make it work with latest version of django. #95

Open
wants to merge 6 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .bumpversion.cfg
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[bumpversion]
commit = True
current_version = 0.8.4
current_version = 2.0.0
files = django_markdown/__init__.py
tag = True
tag_name = {new_version}
Expand Down
16 changes: 9 additions & 7 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,25 +1,27 @@
language: python

python:
- "2.7"
- "3.6"


env:
- TOXENV=py27-d16
- TOXENV=py27-d17
- TOXENV=py34-d17
- TOXENV=cov
- DJANGO_VERSION=1.8.0
- DJANGO_VERSION=2.2.6
- DJANGO_VERSION=3.0.0

branches:
only:
- master
- develop

install: pip install --quiet --use-mirrors tox
install:
- pip install --quiet tox
- pip install -q Django==$DJANGO_VERSION

script: tox

after_script:
- if [ $TOXENV == "cov" ]; then
pip install --quiet --use-mirrors coveralls;
pip install --quiet coveralls;
coveralls;
fi
18 changes: 1 addition & 17 deletions CONTRIBUTORS
Original file line number Diff line number Diff line change
@@ -1,19 +1,3 @@
Contributors:

* Kirill Klenov (https://github.com/klen)

* Alexey Kalinin (https://github.com/Alkalit)
* Alexey Sveshnikov (https://github.com/alexey-sveshnikov)
* Aliaksei Harabchuk (https://github.com/harabchuk)
* Andrew Grigorev (https://github.com/ei-grad)
* Ashley Wilson (https://github.com/CptLemming)
* Caroline Nadel (https://github.com/cazgp)
* Chris Davis (https://github.com/defbyte)
* F. Gabriel Gosselin (https://github.com/evidens)
* Flávio Caetano (https://github.com/fjcaetano)
* Pavel Puchkin (https://github.com/neoascetic)
* Rolf Håvard Blindheim (https://github.com/rhblind)
* Sergii Iavorskyi (https://github.com/yavorskiy)
* Tom O'onnor' (https://github.com/tomoconnor)
* Wellington Cordeiro (https://github.com/wldcordeiro)
* dfeinzeig (https://github.com/dfeinzeig)
* Deesh Reddy (https://github.com/been-there-done-that)
73 changes: 4 additions & 69 deletions Changelog
Original file line number Diff line number Diff line change
@@ -1,69 +1,4 @@
2014-12-08 wldcordeiro
* Fixing the static loading issue properly.
* version 0.8.2

2014-12-04 wldcordeiro

* Removed static_url setting from package settings due to collision with user setting.
* Modified the ModelAdmins to only override MarkdownFields since some users want normal Textfields to display normall.
* Version 0.8.1

2014-09-25 horneds

* Remove python2.6, Django 1.4 support
* Add Django 1.7 support
* Version 0.7.0

2014-06-04 horneds

* Fix markdown_css template tag (c) Ashley Wilson

2014-05-18 horneds

* Add MARKDOWN_PROTECT_PREVIEW option

2014-02-27 horneds

* Support extension configurations
* Fix markdown extra set
* Added 'MARKDOWN_PREVIEW_TEMPALTE' option
* Use jQuery selectors except element ID

2014-02-26 horneds

* Support custom extensions set in filters
* Add template tags: 'markdown_editor', 'markdown_media', 'markdown_media_js', 'markdown_media_css'

2014-02-25 horneds dfeinzeig

* WARNING: `DJANGO_MARKDOWN_STYLE` settings renamed to `MARKDOWN_STYLE`
* Fix compress with yui compressor

2014-02-22 dfeinzeig

* Support markdown extensions

2014-02-21 F. Gabriel Gosselin

* Patching use of deprecated django.utils.simplejson

2014-02-15 horneds

* Added example project

2014-02-15 Aliaksei Harabchuk

* Added MarkdownInlineAdmin

2014-02-09 alexey-sveshnikov

* Django 1.6 support (c) alexey-sveshnikov

2012-12-14 horneds

* Side-by-side widget, custom CSS for preview (fjcaetano)
* Update to support Django 1.5 (SortwareMaven)
* Client-side improvements (Sergii Iavorskyi)
* MARKDOWN_EDITOR_SETTINGS holds the extra parameters (Sergii Iavorskyi)
* Add docs to pypi
* Add MARKDOWN_SKIN option (Sergii Iavorskyi)
2020-12-02 Deesh_Reddy
* Migrated all the code base to work with the latest version of django.
* As well checking to work with latest version of python
* Version - 2.0.0
48 changes: 23 additions & 25 deletions README.rst
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Django-Markdown v. 0.8.4
Django-Markdown v. 2.0.0
########################

.. _description:
Expand All @@ -9,23 +9,23 @@ Documentaton available at pypi_ or github_.
.. _badges:

.. image:: http://img.shields.io/travis/klen/django_markdown.svg?style=flat-square
:target: http://travis-ci.org/klen/django_markdown
:target: https://travis-ci.org/github/been-there-done-that
:alt: Build Status

.. image:: http://img.shields.io/coveralls/klen/django_markdown.svg?style=flat-square
:target: https://coveralls.io/r/klen/django_markdown
:alt: Coverals

.. image:: http://img.shields.io/pypi/v/django_markdown.svg?style=flat-square
:target: https://pypi.python.org/pypi/django_markdown
:target: https://pypi.python.org/pypi/django_markdown-2
:alt: Version

.. image:: http://img.shields.io/pypi/dm/django_markdown.svg?style=flat-square
:target: https://pypi.python.org/pypi/django_markdown
:target: https://pypi.python.org/pypi/django_markdown-2
:alt: Downloads

.. image:: http://img.shields.io/pypi/l/django_markdown.svg?style=flat-square
:target: https://pypi.python.org/pypi/django_markdown
:target: https://pypi.python.org/pypi/django_markdown-2
:alt: License

.. image:: http://img.shields.io/gratipay/klen.svg?style=flat-square
Expand All @@ -39,8 +39,8 @@ Documentaton available at pypi_ or github_.
Requirements
============

- python >= 2.7
- django >= 1.6
- python >= 3.6
- django >= 1.8
- markdown


Expand All @@ -61,12 +61,12 @@ Setup

- Add 'django_markdown' to INSTALLED_APPS ::

INSTALLED_APPS += ( 'django_markdown', )
'django_markdown',


- Add django_markdown urls to base urls ::

url('^markdown/', include( 'django_markdown.urls')),
re_path('^markdown/', include( 'django_markdown.urls')),


Use django_markdown
Expand Down Expand Up @@ -103,10 +103,12 @@ Use django_markdown
# in your project main urls
from django_markdown import flatpages
...

# Django admin
admin.autodiscover()
flatpages.register()
urlpatterns += [ url(r'^admin/', include(admin.site.urls)), ]

urlpatterns += [ re_path(r'^admin/', include(admin.site.urls)), ]

#) Template tags: ::

Expand Down Expand Up @@ -157,30 +159,27 @@ Changes

Make sure you`ve read the following document if you are upgrading from previous versions:

http://packages.python.org/django-markdown/changes.html
http://packages.python.org/django-markdown-2/changes.html


Bug tracker
===========

If you have any suggestions, bug reports or
annoyances please report them to the issue tracker
at https://github.com/klen/django_markdown/issues
at https://github.com/been-there-done-that/django_markdown-2/issues


Contributing
============

Development of django-markdown happens at github: https://github.com/klen/django_markdown
Development of django-markdown happens at github: https://github.com/been-there-done-that/django_markdown-2


Contributors
=============

* klen_ (Kirill Klenov)

* yavorskiy_ (Sergii Iavorskyi)

* Deesh_ (Jagadeeswara_Reddy_p)

License
=======
Expand All @@ -191,16 +190,15 @@ Licensed under a `GNU lesser general public license`_.
Copyright
=========

Copyright (c) 2011 Kirill Klenov (horneds@gmail.com)
Copyright (c) 2021 Deesh Reddy (internetwasmyidea@gmail.com)

Markitup_:
(c) 2008 Jay Salvat
http://markitup.jaysalvat.com/
http://markitup.jaysalvat.com/


.. _GNU lesser general public license: http://www.gnu.org/copyleft/lesser.html
.. _pypi: http://packages.python.org/django-markdown/
.. _Markitup: http://markitup.jaysalvat.com/
.. _github: https://github.com/klen/django_markdown
.. _klen: https://github.com/klen
.. _yavorskiy: https://github.com/yavorskiy
.. _pypi: http://packages.python.org/django-markdown-2/
.. _Markitup: http://markitup.jaysalvat.com/
.. _github: https://github.com/been-there-done-that/django_markdown
.. _Deesh: https://github.com/been-there-done-that
6 changes: 3 additions & 3 deletions django_markdown/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
""" Django-Markdown supports markdown in Django. """

__version__ = "0.8.4"
__project__ = "django-markdown"
__author__ = "Kirill Klenov <[email protected]>"
__version__ = "2.0.0"
__project__ = "django-markdown-2"
__author__ = "Deesh Reddy"
__license__ = "GNU LGPL"
25 changes: 17 additions & 8 deletions django_markdown/admin.py
Original file line number Diff line number Diff line change
@@ -1,21 +1,30 @@
""" Support Django admin. """

from django.contrib import admin
from django.db import models
from django.contrib.admin import (
ModelAdmin, StackedInline
)

from django_markdown.widgets import AdminMarkdownWidget
from django_markdown.models import MarkdownField
from .widgets import AdminMarkdownWidget
from .models import MarkdownField


class MarkdownModelAdmin(admin.ModelAdmin):
class MarkdownModelAdmin(ModelAdmin):

""" Support markdown as ModelAdmin. """

formfield_overrides = {MarkdownField: {'widget': AdminMarkdownWidget}}
formfield_overrides = {
MarkdownField: {
'widget': AdminMarkdownWidget
}
}


class MarkdownInlineAdmin(admin.StackedInline):
class MarkdownInlineAdmin(StackedInline):

""" Support markdown as StackedInline. """

formfield_overrides = {MarkdownField: {'widget': AdminMarkdownWidget}}
formfield_overrides = {
MarkdownField: {
'widget': AdminMarkdownWidget
}
}
2 changes: 1 addition & 1 deletion django_markdown/fields.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@ class MarkdownFormField(forms.CharField):
def __init__(self, *args, **kwargs):
# Django admin overrides the 'widget' value so this seems the only way
# to scupper it!
super(MarkdownFormField, self).__init__(*args, **kwargs)
super().__init__(*args, **kwargs)
self.widget = MarkdownWidget()
4 changes: 3 additions & 1 deletion django_markdown/flatpages.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@

from django import forms
from django.contrib import admin
from django.contrib.flatpages.admin import FlatpageForm, FlatPageAdmin
from django.contrib.flatpages.admin import (
FlatpageForm, FlatPageAdmin
)
from django.contrib.flatpages.models import FlatPage

from django_markdown.widgets import AdminMarkdownWidget
Expand Down
2 changes: 1 addition & 1 deletion django_markdown/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ class MarkdownField(models.TextField):
def formfield(self, **kwargs):
defaults = {'form_class': MarkdownFormField}
defaults.update(kwargs)
return super(MarkdownField, self).formfield(**defaults)
return super().formfield(**defaults)
4 changes: 3 additions & 1 deletion django_markdown/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,11 @@
MARKDOWN_EXTENSIONS = getattr(settings, 'MARKDOWN_EXTENSIONS', [])
MARKDOWN_EXTENSION_CONFIGS = getattr(settings, 'MARKDOWN_EXTENSION_CONFIGS', {})
MARKDOWN_SET_PATH = getattr(settings, 'MARKDOWN_SET_PATH', 'django_markdown/sets')

MARKDOWN_SET_NAME = getattr(
settings, 'MARKDOWN_SET_NAME',
'markdownextra' if 'extra' in MARKDOWN_EXTENSIONS else 'markdown')
'markdownextra' if 'extra' in MARKDOWN_EXTENSIONS else 'markdown'
)

MARKDOWN_PREVIEW_TEMPLATE = getattr(settings, 'MARKDOWN_PREVIEW_TEMPLATE', 'django_markdown/preview.html')
MARKDOWN_STYLE = getattr(settings, 'MARKDOWN_STYLE', 'django_markdown/preview.css')
Expand Down
17 changes: 12 additions & 5 deletions django_markdown/templatetags/django_markdown.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@
import posixpath

from django import template
from django.core.urlresolvers import reverse
from django.urls import reverse

from ..utils import markdown as _markdown, settings, simplejson, mark_safe
from django_markdown.utils import (
markdown as _markdown, settings, simplejson, mark_safe
)


register = template.Library()
Expand Down Expand Up @@ -53,9 +55,14 @@ def markdown_editor(selector):

"""
return dict(
selector=selector,
extra_settings=mark_safe(simplejson.dumps(
dict(previewParserPath=reverse('django_markdown_preview')))))
selector=selector, extra_settings=mark_safe(
simplejson.dumps(
dict(
previewParserPath=reverse('django_markdown_preview')
)
)
)
)


@register.inclusion_tag('django_markdown/media_all.html')
Expand Down
Loading