From 41f022cdd8e5ea9b881fce6ad017f1f9df7b4b10 Mon Sep 17 00:00:00 2001 From: deesh Date: Mon, 30 Nov 2020 23:23:49 +0530 Subject: [PATCH 1/6] :heavy_plus_sign: refactored to work with the latest version of django :heavy_plus_sign: :/ --- django_markdown/templatetags/django_markdown.py | 2 +- django_markdown/templatetags/django_markdown_static.py | 4 ++-- django_markdown/urls.py | 7 ++++--- django_markdown/utils.py | 10 ++++++---- django_markdown/widgets.py | 2 +- 5 files changed, 14 insertions(+), 11 deletions(-) diff --git a/django_markdown/templatetags/django_markdown.py b/django_markdown/templatetags/django_markdown.py index 4199a13..2074e30 100644 --- a/django_markdown/templatetags/django_markdown.py +++ b/django_markdown/templatetags/django_markdown.py @@ -2,7 +2,7 @@ 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 diff --git a/django_markdown/templatetags/django_markdown_static.py b/django_markdown/templatetags/django_markdown_static.py index 8ef6876..818667b 100644 --- a/django_markdown/templatetags/django_markdown_static.py +++ b/django_markdown/templatetags/django_markdown_static.py @@ -3,9 +3,9 @@ register = Library() -if 'django.contrib.staticfiles' in settings.INSTALLED_APPS: +try: from django.contrib.staticfiles.templatetags.staticfiles import static as _static -else: +except: from django.templatetags.static import static as _static diff --git a/django_markdown/urls.py b/django_markdown/urls.py index ca80d4b..17522f4 100644 --- a/django_markdown/urls.py +++ b/django_markdown/urls.py @@ -1,8 +1,9 @@ """ Define preview URL. """ -from django.conf.urls import patterns, url +from django.urls import re_path from .views import preview -urlpatterns = patterns( - '', url('preview/$', preview, name='django_markdown_preview')) +urlpatterns = [ + re_path('preview/$', preview, name='django_markdown_preview') + ] diff --git a/django_markdown/utils.py b/django_markdown/utils.py index c7777e5..8890ef1 100644 --- a/django_markdown/utils.py +++ b/django_markdown/utils.py @@ -1,5 +1,5 @@ """ Markdown utils. """ -from django.core.urlresolvers import reverse +from django.urls import reverse import markdown as markdown_module from django.utils.encoding import force_text from django.utils.safestring import mark_safe @@ -41,7 +41,9 @@ def editor_js_initialization(selector, **extra_settings): previewParserPath=reverse('django_markdown_preview'), **settings.MARKDOWN_EDITOR_SETTINGS) options.update(extra_settings) - ctx = Context(dict( - selector=selector, extra_settings=simplejson.dumps(options)), - autoescape=False) + ctx = dict( + selector=selector, extra_settings=simplejson.dumps(options) + ) + + return INIT_TEMPLATE.render(ctx) diff --git a/django_markdown/widgets.py b/django_markdown/widgets.py index 43174f5..eb4e169 100644 --- a/django_markdown/widgets.py +++ b/django_markdown/widgets.py @@ -27,7 +27,7 @@ class MarkdownWidget(forms.Textarea): def __init__(self, attrs=None): super(MarkdownWidget, self).__init__(attrs) - def render(self, name, value, attrs=None): + def render(self, name, value, attrs=None, renderer=None): """ Render widget. :returns: A rendered HTML From c8260b1da5486a86dc8832a3ddc58ade8a38dcfb Mon Sep 17 00:00:00 2001 From: jagadeeswara_reddy Date: Mon, 30 Nov 2020 23:57:37 +0530 Subject: [PATCH 2/6] :heavy_plus_sign: some more refctoring to work with the latest versions of django :heavy_plus_sign: :/ --- .travis.yml | 4 +++- README.rst | 10 ++++++---- docs/index.rst | 9 +++++---- example/project/md/urls.py | 8 ++++---- example/project/md/views.py | 3 +-- example/project/settings.py | 18 +++++++++++------- example/project/urls.py | 14 +++++++------- tests/urls.py | 9 ++++----- 8 files changed, 41 insertions(+), 34 deletions(-) diff --git a/.travis.yml b/.travis.yml index 53b1684..e2fec51 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,12 +1,14 @@ language: python python: -- "2.7" +- "3.6" env: - TOXENV=py27-d16 - TOXENV=py27-d17 - TOXENV=py34-d17 +- TOXENV=py36-d17 +- TOXENV=py38-d17 - TOXENV=cov branches: diff --git a/README.rst b/README.rst index 396a151..b8c8f26 100644 --- a/README.rst +++ b/README.rst @@ -39,8 +39,8 @@ Documentaton available at pypi_ or github_. Requirements ============ -- python >= 2.7 -- django >= 1.6 +- python >= 3.6 +- django >= 1.8 - markdown @@ -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 @@ -181,6 +181,8 @@ Contributors * yavorskiy_ (Sergii Iavorskyi) +* Deesh_ (Jagadeeswara_Reddy_p) + License ======= diff --git a/docs/index.rst b/docs/index.rst index b7fb927..ed17f61 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -9,8 +9,8 @@ Documentaton available at pypi_ or github_. Requirements ============ -- python >= 2.5 -- django >= 1.2 +- python >= 3.6 +- django >= 1.8 - markdown @@ -27,12 +27,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 @@ -129,6 +129,7 @@ Contributors * yavorskiy_ (Sergii Iavorskyi) +* Deesh_ (Jagadeeswara_Reddy_p) License ======= diff --git a/example/project/md/urls.py b/example/project/md/urls.py index 18de070..9efbe7b 100644 --- a/example/project/md/urls.py +++ b/example/project/md/urls.py @@ -1,5 +1,5 @@ -from django.conf.urls import patterns, include, url +from django.urls import re_path -urlpatterns = patterns('', - url(r'^$', 'project.md.views.home'), -) +urlpatterns = [ + re_path(r'^$', 'project.md.views.home'), +] diff --git a/example/project/md/views.py b/example/project/md/views.py index 9564ffa..707526b 100644 --- a/example/project/md/views.py +++ b/example/project/md/views.py @@ -1,6 +1,5 @@ from django.shortcuts import render from django.views.decorators.csrf import csrf_protect -from django.template import RequestContext @csrf_protect @@ -8,4 +7,4 @@ def home(request): from .forms import CustomForm form = CustomForm(request.POST) - return render(request, 'md/home.html', dict(form=form)) + return render(request, 'md/home.html', {form: form}) diff --git a/example/project/settings.py b/example/project/settings.py index ce0496e..7afd38e 100644 --- a/example/project/settings.py +++ b/example/project/settings.py @@ -2,10 +2,10 @@ Django settings for project. For more information on this file, see -https://docs.djangoproject.com/en/1.6/topics/settings/ +https://docs.djangoproject.com/en/2.2/topics/settings/ For the full list of settings and their values, see -https://docs.djangoproject.com/en/1.6/ref/settings/ +https://docs.djangoproject.com/en/2.2/ref/settings/ """ # Build paths inside the project like this: os.path.join(BASE_DIR, ...) @@ -14,7 +14,7 @@ # Quick-start development settings - unsuitable for production -# See https://docs.djangoproject.com/en/1.6/howto/deployment/checklist/ +# See https://docs.djangoproject.com/en/2.2/howto/deployment/checklist/ # SECURITY WARNING: keep the secret key used in production secret! SECRET_KEY = 'qpd-psx8c+xna6!sg^@k)b3h@=hog+gwpu#z%*^(vat3=d&i1z' @@ -56,7 +56,7 @@ # Database -# https://docs.djangoproject.com/en/1.6/ref/settings/#databases +# https://docs.djangoproject.com/en/2.2/ref/settings/#databases DATABASES = { 'default': { @@ -66,7 +66,7 @@ } # Internationalization -# https://docs.djangoproject.com/en/1.6/topics/i18n/ +# https://docs.djangoproject.com/en/2.2/topics/i18n/ LANGUAGE_CODE = 'en-us' @@ -80,13 +80,17 @@ # Static files (CSS, JavaScript, Images) -# https://docs.djangoproject.com/en/1.6/howto/static-files/ +# https://docs.djangoproject.com/en/2.2/howto/static-files/ STATIC_URL = '/static/' # Custom settings -INSTALLED_APPS += 'django_markdown', 'django.contrib.flatpages', 'project.md' +INSTALLED_APPS += [ + 'django_markdown', + 'django.contrib.flatpages', + 'project.md' +] MARKDOWN_EXTENSIONS = 'extra', 'codehilite' MARKDOWN_EXTENSION_CONFIGS = { diff --git a/example/project/urls.py b/example/project/urls.py index a9edafe..a7b7c64 100644 --- a/example/project/urls.py +++ b/example/project/urls.py @@ -1,4 +1,4 @@ -from django.conf.urls import patterns, include, url +from django.urls import (include, path, re_path) from django.contrib import admin admin.autodiscover() @@ -6,9 +6,9 @@ from django_markdown import flatpages flatpages.register() -urlpatterns = patterns('', - url(r'^markdown/', include('django_markdown.urls')), - url(r'^admin/', include(admin.site.urls)), - url(r'^pages/', include('django.contrib.flatpages.urls')), - url(r'', include('project.md.urls')), -) +urlpatterns = [ + re_path(r'^markdown/', include('django_markdown.urls')), + re_path(r'^admin/', include(admin.site.urls)), + re_path(r'^pages/', include('django.contrib.flatpages.urls')), + path(r'', include('project.md.urls')), + ] diff --git a/tests/urls.py b/tests/urls.py index 43da70a..cb75d4e 100644 --- a/tests/urls.py +++ b/tests/urls.py @@ -1,6 +1,5 @@ -from django.conf.urls import include, patterns +from django.urls import (include, re_path) -urlpatterns = patterns( - '', - (r'^markdown/', include('django_markdown.urls')), -) +urlpatterns = [ + re_path(r'^markdown/', include('django_markdown.urls')), +] From 635372a47dca608e7112bb0f0f17e63fc5204b6d Mon Sep 17 00:00:00 2001 From: jagadeeswara_reddy Date: Wed, 2 Dec 2020 01:49:24 +0530 Subject: [PATCH 3/6] :rocket: much more progress then earlier :rocket: :/ --- django_markdown/__init__.py | 6 +-- django_markdown/admin.py | 25 +++++++---- django_markdown/fields.py | 2 +- django_markdown/flatpages.py | 4 +- django_markdown/models.py | 2 +- django_markdown/settings.py | 4 +- .../templatetags/django_markdown.py | 15 +++++-- .../templatetags/django_markdown_static.py | 11 ++--- django_markdown/tests.py | 7 +-- django_markdown/utils.py | 45 +++++++++++-------- django_markdown/views.py | 10 +++-- django_markdown/widgets.py | 25 +++++++---- 12 files changed, 97 insertions(+), 59 deletions(-) diff --git a/django_markdown/__init__.py b/django_markdown/__init__.py index 1e21c48..ea681b4 100644 --- a/django_markdown/__init__.py +++ b/django_markdown/__init__.py @@ -1,6 +1,6 @@ """ Django-Markdown supports markdown in Django. """ -__version__ = "0.8.4" -__project__ = "django-markdown" -__author__ = "Kirill Klenov " +__version__ = "2.0.0" +__project__ = "django-markdown-2" +__author__ = "Deesh Reddy" __license__ = "GNU LGPL" diff --git a/django_markdown/admin.py b/django_markdown/admin.py index bdbe952..6838a5e 100644 --- a/django_markdown/admin.py +++ b/django_markdown/admin.py @@ -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 + } + } diff --git a/django_markdown/fields.py b/django_markdown/fields.py index 05f8d94..5cf13f5 100644 --- a/django_markdown/fields.py +++ b/django_markdown/fields.py @@ -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() diff --git a/django_markdown/flatpages.py b/django_markdown/flatpages.py index 8ab3950..908180a 100644 --- a/django_markdown/flatpages.py +++ b/django_markdown/flatpages.py @@ -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 diff --git a/django_markdown/models.py b/django_markdown/models.py index 1f40f94..5583c11 100644 --- a/django_markdown/models.py +++ b/django_markdown/models.py @@ -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) diff --git a/django_markdown/settings.py b/django_markdown/settings.py index 2bc2e9a..10e686c 100644 --- a/django_markdown/settings.py +++ b/django_markdown/settings.py @@ -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') diff --git a/django_markdown/templatetags/django_markdown.py b/django_markdown/templatetags/django_markdown.py index 2074e30..d8b835d 100644 --- a/django_markdown/templatetags/django_markdown.py +++ b/django_markdown/templatetags/django_markdown.py @@ -4,7 +4,9 @@ from django import template 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() @@ -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') diff --git a/django_markdown/templatetags/django_markdown_static.py b/django_markdown/templatetags/django_markdown_static.py index 818667b..ae791d6 100644 --- a/django_markdown/templatetags/django_markdown_static.py +++ b/django_markdown/templatetags/django_markdown_static.py @@ -1,12 +1,7 @@ -from django.conf import settings -from django.template import Library +from django import template +from django.templatetags.static import static as _static -register = Library() - -try: - from django.contrib.staticfiles.templatetags.staticfiles import static as _static -except: - from django.templatetags.static import static as _static +register = template.Library() @register.simple_tag diff --git a/django_markdown/tests.py b/django_markdown/tests.py index fc597f1..dbe7f2c 100644 --- a/django_markdown/tests.py +++ b/django_markdown/tests.py @@ -1,7 +1,8 @@ from django.test import TestCase -from django_markdown.utils import markdown as markdown_util - -from django_markdown.templatetags.django_markdown import ( +from .utils import ( + markdown as markdown_util +) +from .templatetags.django_markdown import ( markdown as markdown_tag ) diff --git a/django_markdown/utils.py b/django_markdown/utils.py index 8890ef1..c80c479 100644 --- a/django_markdown/utils.py +++ b/django_markdown/utils.py @@ -1,17 +1,15 @@ """ Markdown utils. """ from django.urls import reverse import markdown as markdown_module -from django.utils.encoding import force_text +from django.utils.encoding import force_str from django.utils.safestring import mark_safe -from django.template import loader, Context +from django.template.loader import render_to_string + try: - import json as simplejson + import ujson as simplejson except ImportError: - try: - import simplejson - except ImportError: - from django.utils import simplejson + import json as simplejson from . import settings @@ -26,24 +24,35 @@ def markdown(value, extensions=settings.MARKDOWN_EXTENSIONS, :returns: A rendered markdown """ - return mark_safe(markdown_module.markdown( - force_text(value), extensions=extensions, - extension_configs=extension_configs, safe_mode=safe)) + return mark_safe( + markdown_module.markdown( + force_str(value), extensions=extensions, + extension_configs=extension_configs, safe_mode=safe + ) + ) -def editor_js_initialization(selector, **extra_settings): - """ Return script tag with initialization code. """ - INIT_TEMPLATE = loader.get_template( - settings.MARKDOWN_EDITOR_INIT_TEMPLATE) +def editor_js_initialization(selector, **extra_settings): + """ + Return script tag with initialization code. + extra_settings: + context data that needs to be passed to the template + """ options = dict( previewParserPath=reverse('django_markdown_preview'), - **settings.MARKDOWN_EDITOR_SETTINGS) + **settings.MARKDOWN_EDITOR_SETTINGS + ) options.update(extra_settings) + ctx = dict( - selector=selector, extra_settings=simplejson.dumps(options) + selector=selector, + extra_settings=simplejson.dumps(options) ) - - return INIT_TEMPLATE.render(ctx) + # https://docs.djangoproject.com/en/3.1/topics/templates/#django.template.loader.render_to_string + return render_to_string( + settings.MARKDOWN_EDITOR_INIT_TEMPLATE, + context=ctx + ) diff --git a/django_markdown/views.py b/django_markdown/views.py index dbf352f..d341376 100644 --- a/django_markdown/views.py +++ b/django_markdown/views.py @@ -17,8 +17,12 @@ def preview(request): from django.contrib.auth.views import redirect_to_login return redirect_to_login(request.get_full_path()) + content = request.GET.get('data') or request.POST.get('data') or 'No content posted' + return render( - request, settings.MARKDOWN_PREVIEW_TEMPLATE, dict( - content=request.REQUEST.get('data', 'No content posted'), + request, settings.MARKDOWN_PREVIEW_TEMPLATE, + dict( + content=content, css=settings.MARKDOWN_STYLE - )) + ) + ) diff --git a/django_markdown/widgets.py b/django_markdown/widgets.py index eb4e169..8072be0 100644 --- a/django_markdown/widgets.py +++ b/django_markdown/widgets.py @@ -3,7 +3,6 @@ from django import forms from django.contrib.admin.widgets import AdminTextareaWidget -from django.core.files.storage import default_storage from django.utils.safestring import mark_safe from . import settings @@ -25,7 +24,7 @@ class MarkdownWidget(forms.Textarea): """ def __init__(self, attrs=None): - super(MarkdownWidget, self).__init__(attrs) + super().__init__(attrs) def render(self, name, value, attrs=None, renderer=None): """ Render widget. @@ -33,7 +32,7 @@ def render(self, name, value, attrs=None, renderer=None): :returns: A rendered HTML """ - html = super(MarkdownWidget, self).render(name, value, attrs) + html = super().render(name, value, attrs) attrs = self.build_attrs(attrs) html += editor_js_initialization("#%s" % attrs['id']) return mark_safe(html) @@ -41,15 +40,25 @@ def render(self, name, value, attrs=None, renderer=None): class Media: css = { 'screen': ( - os.path.join('django_markdown', 'skins', settings.MARKDOWN_EDITOR_SKIN, 'style.css'), - os.path.join(settings.MARKDOWN_SET_PATH, settings.MARKDOWN_SET_NAME, 'style.css') + os.path.join( + 'django_markdown', 'skins', settings.MARKDOWN_EDITOR_SKIN, 'style.css' + ), + os.path.join( + settings.MARKDOWN_SET_PATH, settings.MARKDOWN_SET_NAME, 'style.css' + ) ) } js = ( - os.path.join('django_markdown', 'jquery.init.js'), - os.path.join('django_markdown', 'jquery.markitup.js'), - os.path.join(settings.MARKDOWN_SET_PATH, settings.MARKDOWN_SET_NAME, 'set.js') + os.path.join( + 'django_markdown', 'jquery.init.js' + ), + os.path.join( + 'django_markdown', 'jquery.markitup.js' + ), + os.path.join( + settings.MARKDOWN_SET_PATH, settings.MARKDOWN_SET_NAME, 'set.js' + ) ) From 2dac0b2c52e2232b31db688fe5ff7599aa6f228c Mon Sep 17 00:00:00 2001 From: jagadeeswara_reddy Date: Wed, 2 Dec 2020 02:37:04 +0530 Subject: [PATCH 4/6] :heavy_plus-sign: still need a lot to be figured on this config :heavy_plus_sign: :/ --- .bumpversion.cfg | 2 +- .travis.yml | 11 ++---- CONTRIBUTORS | 18 +--------- Changelog | 73 +++------------------------------------ README.rst | 40 ++++++++++------------ docs/conf.py | 89 ++++++++++++++++++++++++------------------------ docs/index.rst | 29 ++++++++-------- example.py | 23 ++++++++----- setup.py | 8 ++--- tox.ini | 28 +++++++++------ 10 files changed, 121 insertions(+), 200 deletions(-) diff --git a/.bumpversion.cfg b/.bumpversion.cfg index 69b95ed..ee38d2c 100644 --- a/.bumpversion.cfg +++ b/.bumpversion.cfg @@ -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} diff --git a/.travis.yml b/.travis.yml index e2fec51..f1d23ca 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,14 +2,9 @@ language: python python: - "3.6" - -env: -- TOXENV=py27-d16 -- TOXENV=py27-d17 -- TOXENV=py34-d17 -- TOXENV=py36-d17 -- TOXENV=py38-d17 -- TOXENV=cov +- "3.7" +- "3.8" +- "3.9" branches: only: diff --git a/CONTRIBUTORS b/CONTRIBUTORS index fc9bf12..f65c3ca 100644 --- a/CONTRIBUTORS +++ b/CONTRIBUTORS @@ -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) diff --git a/Changelog b/Changelog index b5e2c9a..69f3d7a 100644 --- a/Changelog +++ b/Changelog @@ -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 \ No newline at end of file diff --git a/README.rst b/README.rst index b8c8f26..f35fff4 100644 --- a/README.rst +++ b/README.rst @@ -1,4 +1,4 @@ -Django-Markdown v. 0.8.4 +Django-Markdown v. 2.0.0 ######################## .. _description: @@ -9,7 +9,7 @@ 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 @@ -17,15 +17,15 @@ Documentaton available at pypi_ or github_. :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 @@ -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: :: @@ -157,7 +159,7 @@ 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 @@ -165,25 +167,20 @@ 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 ======= @@ -193,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 diff --git a/docs/conf.py b/docs/conf.py index 91a92fb..227908a 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -15,17 +15,19 @@ sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) -from django_markdown import __version__, __author__ +from django_markdown import ( + __version__, __author__, __project__ +) # If extensions (or modules to document with autodoc) are in another directory, # add these directories to sys.path here. If the directory is relative to the # documentation root, use os.path.abspath to make it absolute, like shown here. -#sys.path.insert(0, os.path.abspath('.')) +# sys.path.insert(0, os.path.abspath('.')) # -- General configuration ----------------------------------------------------- # If your documentation needs a minimal Sphinx version, state it here. -#needs_sphinx = '1.0' +# needs_sphinx = '1.0' # Add any Sphinx extension module names here, as strings. They can be extensions # coming with Sphinx (named 'sphinx.ext.*') or your custom ones. @@ -38,13 +40,13 @@ source_suffix = '.rst' # The encoding of source files. -#source_encoding = 'utf-8-sig' +# source_encoding = 'utf-8-sig' # The master toctree document. master_doc = 'index' # General information about the project. -project = u'django-markdown' +project = __project__ copyright = __author__ # The version info for the project you're documenting, acts as replacement for @@ -58,37 +60,37 @@ # The language for content autogenerated by Sphinx. Refer to documentation # for a list of supported languages. -#language = None +# language = None # There are two options for replacing |today|: either, you set today to some # non-false value, then it is used: -#today = '' +# today = '' # Else, today_fmt is used as the format for a strftime call. -#today_fmt = '%B %d, %Y' +# today_fmt = '%B %d, %Y' # List of patterns, relative to source directory, that match files and # directories to ignore when looking for source files. exclude_patterns = ['_build'] # The reST default role (used for this markup: `text`) to use for all documents. -#default_role = None +# default_role = None # If true, '()' will be appended to :func: etc. cross-reference text. -#add_function_parentheses = True +# add_function_parentheses = True # If true, the current module name will be prepended to all description # unit titles (such as .. function::). -#add_module_names = True +# add_module_names = True # If true, sectionauthor and moduleauthor directives will be shown in the # output. They are ignored by default. -#show_authors = False +# show_authors = False # The name of the Pygments (syntax highlighting) style to use. pygments_style = 'sphinx' # A list of ignored prefixes for module index sorting. -#modindex_common_prefix = [] +# modindex_common_prefix = [] # -- Options for HTML output --------------------------------------------------- @@ -100,26 +102,26 @@ # Theme options are theme-specific and customize the look and feel of a theme # further. For a list of options available for each theme, see the # documentation. -#html_theme_options = {} +# html_theme_options = {} # Add any paths that contain custom themes here, relative to this directory. -#html_theme_path = [] +# html_theme_path = [] # The name for this set of Sphinx documents. If None, it defaults to # " v documentation". -#html_title = None +# html_title = None # A shorter title for the navigation bar. Default is the same as html_title. -#html_short_title = None +# html_short_title = None # The name of an image file (relative to this directory) to place at the top # of the sidebar. -#html_logo = None +# html_logo = None # The name of an image file (within the static path) to use as favicon of the # docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32 # pixels large. -#html_favicon = None +# html_favicon = None # Add any paths that contain custom static files (such as style sheets) here, # relative to this directory. They are copied after the builtin static files, @@ -128,86 +130,85 @@ # If not '', a 'Last updated on:' timestamp is inserted at every page bottom, # using the given strftime format. -#html_last_updated_fmt = '%b %d, %Y' +# html_last_updated_fmt = '%b %d, %Y' # If true, SmartyPants will be used to convert quotes and dashes to # typographically correct entities. -#html_use_smartypants = True +# html_use_smartypants = True # Custom sidebar templates, maps document names to template names. -#html_sidebars = {} +# html_sidebars = {} # Additional templates that should be rendered to pages, maps page names to # template names. -#html_additional_pages = {} +# html_additional_pages = {} # If false, no module index is generated. -#html_domain_indices = True +# html_domain_indices = True # If false, no index is generated. -#html_use_index = True +# html_use_index = True # If true, the index is split into individual pages for each letter. -#html_split_index = False +# html_split_index = False # If true, links to the reST sources are added to the pages. -#html_show_sourcelink = True +# html_show_sourcelink = True # If true, "Created using Sphinx" is shown in the HTML footer. Default is True. -#html_show_sphinx = True +# html_show_sphinx = True # If true, "(C) Copyright ..." is shown in the HTML footer. Default is True. -#html_show_copyright = True +# html_show_copyright = True # If true, an OpenSearch description file will be output, and all pages will # contain a tag referring to it. The value of this option must be the # base URL from which the finished HTML is served. -#html_use_opensearch = '' +# html_use_opensearch = '' # This is the file name suffix for HTML files (e.g. ".xhtml"). -#html_file_suffix = None +# html_file_suffix = None # Output file base name for HTML help builder. htmlhelp_basename = 'python-scssdoc' - # -- Options for LaTeX output -------------------------------------------------- # The paper size ('letter' or 'a4'). -#latex_paper_size = 'letter' +# latex_paper_size = 'letter' # The font size ('10pt', '11pt' or '12pt'). -#latex_font_size = '10pt' +# latex_font_size = '10pt' # Grouping the document tree into LaTeX files. List of tuples # (source start file, target name, title, author, documentclass [howto/manual]). latex_documents = [ - ('index', 'python-scss.tex', u'python-scss Documentation', - u'Kirill Klenov', 'manual'), + ('index', 'python-scss.tex', u'python-scss Documentation', + __author__, 'manual'), ] # The name of an image file (relative to this directory) to place at the top of # the title page. -#latex_logo = None +# latex_logo = None # For "manual" documents, if this is true, then toplevel headings are parts, # not chapters. -#latex_use_parts = False +# latex_use_parts = False # If true, show page references after internal links. -#latex_show_pagerefs = False +# latex_show_pagerefs = False # If true, show URL addresses after external links. -#latex_show_urls = False +# latex_show_urls = False # Additional stuff for the LaTeX preamble. -#latex_preamble = '' +# latex_preamble = '' # Documents to append as an appendix to all manuals. -#latex_appendices = [] +# latex_appendices = [] # If false, no module index is generated. -#latex_domain_indices = True +# latex_domain_indices = True # -- Options for manual page output -------------------------------------------- @@ -216,5 +217,5 @@ # (source start file, name, description, authors, manual section). man_pages = [ ('index', 'python-scss', u'python-scss Documentation', - [u'Kirill Klenov'], 1) + [__author__], 1) ] diff --git a/docs/index.rst b/docs/index.rst index ed17f61..9f03960 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -9,7 +9,7 @@ Documentaton available at pypi_ or github_. Requirements ============ -- python >= 3.6 +- python >= 3.5 - django >= 1.8 - markdown @@ -19,7 +19,7 @@ Installation **Django markdown** should be installed using pip: :: - pip install django-markdown + pip install django-markdown-2 Setup @@ -41,12 +41,14 @@ Use django_markdown #) Custom forms: :: from django_markdown.widgets import MarkdownWidget + class MyCustomForm(forms.Form): content = forms.CharField( widget=MarkdownWidget() ) #) Custom admins: :: from django_markdown.admin import MarkdownModelAdmin + adimin.site.register(MyModel, MarkdownModelAdmin) #) Flatpages: :: @@ -54,10 +56,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)), ] #) JavaScript API: :: @@ -105,7 +109,7 @@ 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 @@ -113,22 +117,18 @@ 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/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 Contributors ============= -* klen_ (Kirill Klenov) - -* yavorskiy_ (Sergii Iavorskyi) - * Deesh_ (Jagadeeswara_Reddy_p) License @@ -140,7 +140,7 @@ 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 @@ -148,8 +148,7 @@ Markitup_: .. _GNU lesser general public license: http://www.gnu.org/copyleft/lesser.html -.. _pypi: http://packages.python.org/django-markdown/ +.. _pypi: http://packages.python.org/django-markdown-2/ .. _Markitup: http://markitup.jaysalvat.com/ -.. _github: https://github.com/klen/django_markdown -.. _klen: https://github.com/klen -.. _yavorskiy: https://github.com/yavorskiy +.. _github: https://github.com/been-there-done-that/django_markdown +.. _Deesh: https://github.com/been-there-done-that diff --git a/example.py b/example.py index f5118a4..b764192 100755 --- a/example.py +++ b/example.py @@ -1,9 +1,9 @@ -#!/usr/bin/env python -# coding: utf-8 import os from django.core.management import call_command -from django.conf.urls import patterns, include +from django.urls import ( + include, path, re_path +) from django.conf import settings from django.http import HttpResponse @@ -14,9 +14,9 @@ # Settings # -------- -DEBUG=True, -ROOT_URLCONF=MODULE -SECRET_KEY='secret' +DEBUG = True, +ROOT_URLCONF = MODULE +SECRET_KEY = 'secret' INSTALLED_APPS = ( 'django.contrib.contenttypes', 'django.contrib.messages', @@ -38,6 +38,7 @@ from django_markdown.models import MarkdownField + class Test(models.Model): content = MarkdownField() @@ -47,19 +48,23 @@ class Meta: # Views # ----- + def home(request): return HttpResponse('OK') # Urls # ---- + from django.contrib import admin +from .views import home + admin.autodiscover() -urlpatterns = patterns( - '', + +urlpatterns = [ ('^$', home), ('^admin/', include(admin.site.urls)), -) +] if __name__ == '__main__': diff --git a/setup.py b/setup.py index 686f1b4..c67b765 100644 --- a/setup.py +++ b/setup.py @@ -22,6 +22,7 @@ def _read(fname): except IOError: return '' + _meta = _read('django_markdown/__init__.py') _license = re.search(r'^__license__\s*=\s*"(.*)"', _meta, re.M).group(1) _project = re.search(r'^__project__\s*=\s*"(.*)"', _meta, re.M).group(1) @@ -37,15 +38,14 @@ def _read(fname): long_description=_read('README.rst'), license=_license, - author="Kirill Klenov", - author_email="horneds@gmail.com", - url="https://github.com/klen/django_markdown", + author="Deesh Reddy", + author_email="internetwasmyidea@gmail.com", + url="https://github.com/been-there-done-that/django_markdown", keywords='html markdown django', classifiers=[ 'Development Status :: 5 - Production/Stable', 'Intended Audience :: Developers', - 'Natural Language :: Russian', 'Natural Language :: English', 'License :: OSI Approved :: GNU Library or Lesser General Public License (LGPL)', # noqa 'Programming Language :: Python', diff --git a/tox.ini b/tox.ini index b0df3bd..373d9f3 100644 --- a/tox.ini +++ b/tox.ini @@ -1,5 +1,5 @@ [tox] -envlist=py27-d16,py27-d17,py34-d17,cov +envlist=py36.*,py37.*,py38.*,py39.* [pylama] skip=example/* @@ -26,28 +26,34 @@ commands=py.test deps = pytest -[testenv:py27-d16] -basepython = python2.7 +[testenv:py36.*] +basepython = python3.6 deps = - django==1.6.7 + django==1.8.0 {[testenv]deps} -[testenv:py27-d17] -basepython = python2.7 +[testenv:py37.*] +basepython = python3.7 deps = - django==1.7 + django>=1.8 {[testenv]deps} -[testenv:py34-d17] -basepython = python3.4 +[testenv:py38.*] +basepython = python3.8 deps = - django==1.7 + django>=1.8 + {[testenv]deps} + +[testenv:py39.*] +basepython = python3.9 +deps = + django>=1.8 {[testenv]deps} [testenv:cov] deps = coverage - django==1.7 + django>=1.8 {[testenv]deps} commands = From cf98b5c73b59d5f6fa107a6afc2fc1078183723c Mon Sep 17 00:00:00 2001 From: jagadeeswara_reddy Date: Wed, 2 Dec 2020 10:11:24 +0530 Subject: [PATCH 5/6] :bug: that flag won't work anymore :bug: :/ --- .travis.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index f1d23ca..49c654c 100644 --- a/.travis.yml +++ b/.travis.yml @@ -11,12 +11,12 @@ branches: - master - develop -install: pip install --quiet --use-mirrors tox +install: pip install --quiet tox script: tox after_script: - if [ $TOXENV == "cov" ]; then - pip install --quiet --use-mirrors coveralls; + pip install --quiet coveralls; coveralls; fi From 1e4e3fc74c90a2c1e3b656704a920062a77b1114 Mon Sep 17 00:00:00 2001 From: jagadeeswara_reddy Date: Wed, 2 Dec 2020 13:38:32 +0530 Subject: [PATCH 6/6] one more time yaml change :/ --- .travis.yml | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/.travis.yml b/.travis.yml index 49c654c..aa3b507 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,16 +2,21 @@ language: python python: - "3.6" -- "3.7" -- "3.8" -- "3.9" + + +env: + - DJANGO_VERSION=1.8.0 + - DJANGO_VERSION=2.2.6 + - DJANGO_VERSION=3.0.0 branches: only: - master - develop -install: pip install --quiet tox +install: + - pip install --quiet tox + - pip install -q Django==$DJANGO_VERSION script: tox