Skip to content

Commit

Permalink
Upgrade bootstrap 5 #177, Django 4.0.2, implement black.
Browse files Browse the repository at this point in the history
  • Loading branch information
Agus Makmun committed Mar 1, 2022
1 parent 22f6c59 commit e51c4ea
Show file tree
Hide file tree
Showing 29 changed files with 117 additions and 104 deletions.
2 changes: 1 addition & 1 deletion martor/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# -*- coding: utf-8 -*-

__VERSION__ = "1.6.11"
__VERSION__ = "1.6.12"
__AUTHOR__ = "Agus Makmun (Summon Agus)"
__AUTHOR_EMAIL__ = "summon.agus@gmail.com"
13 changes: 10 additions & 3 deletions martor/extensions/mdx_video.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,14 @@ def extendMarkdown(self, md, md_globals):
r"([^(]|^)http://www\.veoh\.com/\S*(#watch%3D|watch/)(?P<veohid>\w+)", # noqa: E501
)
self.add_inline(
md, "vimeo", Vimeo, r"([^(]|^)http://(www.|)vimeo\.com/(?P<vimeoid>\d+)\S*" # noqa: E501
md,
"vimeo",
Vimeo,
r"([^(]|^)http://(www.|)vimeo\.com/(?P<vimeoid>\d+)\S*", # noqa: E501
)
self.add_inline(md, "yahoo", Yahoo, r"([^(]|^)http://screen\.yahoo\.com/.+/?") # noqa: E501
self.add_inline(
md, "yahoo", Yahoo, r"([^(]|^)http://screen\.yahoo\.com/.+/?"
) # noqa: E501
self.add_inline(
md,
"youtube",
Expand Down Expand Up @@ -90,7 +95,9 @@ def handleMatch(self, m):

class Veoh(markdown.inlinepatterns.Pattern):
def handleMatch(self, m):
url = "//www.veoh.com/videodetails2.swf?permalinkId=%s" % m.group("veohid") # noqa: E501
url = "//www.veoh.com/videodetails2.swf?permalinkId=%s" % m.group(
"veohid"
) # noqa: E501
width = self.ext.config["veoh_width"][0]
height = self.ext.config["veoh_height"][0]
return flash_object(url, width, height)
Expand Down
8 changes: 6 additions & 2 deletions martor/extensions/mention.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,16 @@
class MentionPattern(markdown.inlinepatterns.Pattern):
def handleMatch(self, m):
username = self.unescape(m.group(2))
users = get_user_model().objects.filter(username=username, is_active=True) # noqa: E501
users = get_user_model().objects.filter(
username=username, is_active=True
) # noqa: E501

"""Makesure `username` is registered and actived."""
if MARTOR_ENABLE_CONFIGS["mention"] == "true":
if users.exists():
url = "{0}{1}/".format(MARTOR_MARKDOWN_BASE_MENTION_URL, username) # noqa: E501
url = "{0}{1}/".format(
MARTOR_MARKDOWN_BASE_MENTION_URL, username
) # noqa: E501
el = markdown.util.etree.Element("a")
el.set("href", url)
el.set("class", "direct-mention-link")
Expand Down
4 changes: 2 additions & 2 deletions martor/static/martor/css/martor-admin.min.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion martor/static/martor/css/martor.bootstrap.css
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,8 @@ body.overflow {
font-size: 12px;
}
.insert-emoji {
cursor: pointer
cursor: pointer;
text-decoration: none;
}

.table.markdown-reference {
Expand Down
6 changes: 3 additions & 3 deletions martor/static/martor/css/martor.bootstrap.min.css

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions martor/static/martor/css/martor.semantic.min.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions martor/static/martor/js/martor.bootstrap.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* Name : Martor v1.6.11
* Name : Martor v1.6.12
* Created by : Agus Makmun (Summon Agus)
* Release date : 21-Feb-2022
* Release date : 01-Mar-2022
* License : GNU GENERAL PUBLIC LICENSE Version 3, 29 June 2007
* Repository : https://github.com/agusmakmun/django-markdown-editor
**/
Expand Down
4 changes: 2 additions & 2 deletions martor/static/martor/js/martor.bootstrap.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions martor/static/martor/js/martor.semantic.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* Name : Martor v1.6.11
* Name : Martor v1.6.12
* Created by : Agus Makmun (Summon Agus)
* Release date : 21-Feb-2022
* Release date : 01-Mar-2022
* License : GNU GENERAL PUBLIC LICENSE Version 3, 29 June 2007
* Repository : https://github.com/agusmakmun/django-markdown-editor
**/
Expand Down
4 changes: 2 additions & 2 deletions martor/static/martor/js/martor.semantic.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 5 additions & 5 deletions martor/static/plugins/css/bootstrap.min.css

Large diffs are not rendered by default.

12 changes: 3 additions & 9 deletions martor/static/plugins/js/bootstrap.min.js

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions martor/templates/martor/bootstrap/editor.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@
<div class="section-martor">
<nav class="tab-martor-menu" style="position:relative">
<div class="nav nav-tabs" id="nav-tab" role="tablist">
<a class="nav-link active" data-tab="editor-tab-{{ field_name }}" id="nav-editor-tab-{{ field_name }}" data-toggle="tab" href="#nav-editor-{{ field_name }}" role="tab" aria-controls="nav-editor-{{ field_name }}" aria-selected="true">
<a class="nav-link active" data-tab="editor-tab-{{ field_name }}" id="nav-editor-tab-{{ field_name }}" data-bs-toggle="tab" data-bs-target="#nav-editor-{{ field_name }}" type="button" role="tab" aria-controls="nav-editor-{{ field_name }}" aria-selected="true">
<svg width="1em" height="1em" viewBox="0 0 16 16" class="bi bi-pencil-square" fill="currentColor" xmlns="http://www.w3.org/2000/svg">
<path d="M15.502 1.94a.5.5 0 0 1 0 .706L14.459 3.69l-2-2L13.502.646a.5.5 0 0 1 .707 0l1.293 1.293zm-1.75 2.456l-2-2L4.939 9.21a.5.5 0 0 0-.121.196l-.805 2.414a.25.25 0 0 0 .316.316l2.414-.805a.5.5 0 0 0 .196-.12l6.813-6.814z"/>
<path fill-rule="evenodd" d="M1 13.5A1.5 1.5 0 0 0 2.5 15h11a1.5 1.5 0 0 0 1.5-1.5v-6a.5.5 0 0 0-1 0v6a.5.5 0 0 1-.5.5h-11a.5.5 0 0 1-.5-.5v-11a.5.5 0 0 1 .5-.5H9a.5.5 0 0 0 0-1H2.5A1.5 1.5 0 0 0 1 2.5v11z"/>
</svg>
<span>{% trans "Editor" %}</span>
</a>
<a class="nav-link" data-tab="preview-tab-{{ field_name }}" id="nav-preview-tab-{{ field_name }}" data-toggle="tab" href="#nav-preview-{{ field_name }}" role="tab" aria-controls="nav-preview-{{ field_name }}" aria-selected="false">
<a class="nav-link" data-tab="preview-tab-{{ field_name }}" id="nav-preview-tab-{{ field_name }}" data-bs-toggle="tab" data-bs-target="#nav-preview-{{ field_name }}" type="button" role="tab" aria-controls="nav-preview-{{ field_name }}" aria-selected="false">
<svg width="1em" height="1em" viewBox="0 0 16 16" class="bi bi-eye-fill" fill="currentColor" xmlns="http://www.w3.org/2000/svg">
<path d="M10.5 8a2.5 2.5 0 1 1-5 0 2.5 2.5 0 0 1 5 0z"/>
<path fill-rule="evenodd" d="M0 8s3-5.5 8-5.5S16 8 16 8s-3 5.5-8 5.5S0 8 0 8zm8 3.5a3.5 3.5 0 1 0 0-7 3.5 3.5 0 0 0 0 7z"/>
Expand All @@ -26,7 +26,7 @@
<div class="tab-pane fade show active" id="nav-editor-{{ field_name }}" role="tabpanel" aria-labelledby="nav-editor-tab-{{ field_name }}">
<div class="text-center upload-progress" data-field-name="{{ field_name }}" style="display:none">
<div class="spinner-border" role="status">
<span class="sr-only">Loading...</span>
<span class="visually-hidden">Loading...</span>
</div>
<div>{% trans "Uploading... please wait..." %}</div>
</div>
Expand Down
10 changes: 4 additions & 6 deletions martor/templates/martor/bootstrap/emoji.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,21 @@
<div class="modal fade modal-emoji" tabindex="-1" aria-labelledby="modalInsertEmojiTitle" aria-hidden="true">
<div class="modal-dialog modal-lg modal-dialog-scrollable">
<div class="modal-content emoji-content-base">
<div class="modal-header">
<div class="modal-header bg-light">
<h5 class="modal-title" id="modalInsertEmojiTitle">
<svg width="1em" height="1em" viewBox="0 0 16 16" class="bi bi-info-circle" fill="currentColor" xmlns="http://www.w3.org/2000/svg">
<path fill-rule="evenodd" d="M8 15A7 7 0 1 0 8 1a7 7 0 0 0 0 14zm0 1A8 8 0 1 0 8 0a8 8 0 0 0 0 16z"/>
<path d="M8.93 6.588l-2.29.287-.082.38.45.083c.294.07.352.176.288.469l-.738 3.468c-.194.897.105 1.319.808 1.319.545 0 1.178-.252 1.465-.598l.088-.416c-.2.176-.492.246-.686.246-.275 0-.375-.193-.304-.533L8.93 6.588z"/>
<circle cx="8" cy="4.5" r="1"/>
</svg>
<span>{% trans "Select Emoji to Insert" %}</span>
<span class="ms-1">{% trans "Select Emoji to Insert" %}</span>
</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
</div>
<div class="modal-body emoji-content-base">
<div class="text-center emoji-loader-init" style="display:none">
<div class="spinner-border" role="status">
<span class="sr-only">Loading...</span>
<span class="visually-hidden">Loading...</span>
</div>
<div>{% trans "Preparing emojis..." %}</div>
</div>
Expand Down
16 changes: 7 additions & 9 deletions martor/templates/martor/bootstrap/guide.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,28 +3,26 @@
<div class="modal fade modal-help-guide" tabindex="-1" aria-labelledby="modalMarkdownGuideTitle" aria-hidden="true">
<div class="modal-dialog modal-lg modal-dialog-scrollable">
<div class="modal-content">
<div class="modal-header">
<div class="modal-header bg-light">
<h5 class="modal-title" id="modalMarkdownGuideTitle">
<svg width="1em" height="1em" viewBox="0 0 16 16" class="bi bi-question-circle" fill="currentColor" xmlns="http://www.w3.org/2000/svg">
<path fill-rule="evenodd" d="M8 15A7 7 0 1 0 8 1a7 7 0 0 0 0 14zm0 1A8 8 0 1 0 8 0a8 8 0 0 0 0 16z"/>
<path d="M5.255 5.786a.237.237 0 0 0 .241.247h.825c.138 0 .248-.113.266-.25.09-.656.54-1.134 1.342-1.134.686 0 1.314.343 1.314 1.168 0 .635-.374.927-.965 1.371-.673.489-1.206 1.06-1.168 1.987l.003.217a.25.25 0 0 0 .25.246h.811a.25.25 0 0 0 .25-.25v-.105c0-.718.273-.927 1.01-1.486.609-.463 1.244-.977 1.244-2.056 0-1.511-1.276-2.241-2.673-2.241-1.267 0-2.655.59-2.75 2.286zm1.557 5.763c0 .533.425.927 1.01.927.609 0 1.028-.394 1.028-.927 0-.552-.42-.94-1.029-.94-.584 0-1.009.388-1.009.94z"/>
</svg>
<span>{% trans "Markdown Guide" %}</span>
<span class="ms-1">{% trans "Markdown Guide" %}</span>
</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
</div>
<div class="modal-body">
<div class="text-center small credit">
<span>{% blocktrans with repo_url='https://github.com/agusmakmun/django-markdown-editor' %}Copyright &copy; <a href="{{ repo_url }}">Martor</a>{% endblocktrans %}</span>
</div>
<div class="text-center">
<div class="text-center small">
<p>{% blocktrans with doc_url='http://commonmark.org/help/' %}This editor is powered by Markdown. For full documentation, <a href="{{ doc_url }}" target="_blank">click here</a>.{% endblocktrans %}</p>
</div>
<table class="table markdown-reference">
<thead class="thead-light">
<tr>
<table class="table lh-lg markdown-reference">
<thead>
<tr class="table-light">
<th>{% trans "Code" %}</th>
<th>{% trans "Or" %}</th>
<th>Linux/Windows</th>
Expand Down
6 changes: 3 additions & 3 deletions martor/templates/martor/bootstrap/toolbar.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{% load i18n %}

<div class="btn-toolbar float-right martor-toolbar" role="toolbar" aria-label="{% trans 'Martor Toolbar Buttons' %}">
<div class="btn-toolbar float-end martor-toolbar" role="toolbar" aria-label="{% trans 'Martor Toolbar Buttons' %}">
<div class="btn-group btn-group-sm" role="group" aria-label="First group">

{% if 'bold' in toolbar_buttons %}
Expand Down Expand Up @@ -29,7 +29,7 @@

{% if 'heading' in toolbar_buttons %}
<div class="btn-group" role="group">
<span id="btnGroupVerticalDropHeading" class="btn btn-light dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false" title="{% trans 'Heading' %}">
<span id="btnGroupVerticalDropHeading" class="btn btn-light dropdown-toggle" data-bs-toggle="dropdown" aria-haspopup="true" aria-expanded="false" title="{% trans 'Heading' %}">
<svg width="1em" height="1em" viewBox="0 0 16 16" class="bi bi-type-h1" fill="currentColor" xmlns="http://www.w3.org/2000/svg">
<path d="M8.637 13V3.669H7.379V7.62H2.758V3.67H1.5V13h1.258V8.728h4.62V13h1.259zm5.329 0V3.669h-1.244L10.5 5.316v1.265l2.16-1.565h.062V13h1.244z"/>
</svg>
Expand All @@ -44,7 +44,7 @@

{% if 'pre-code' in toolbar_buttons %}
<div class="btn-group" role="group">
<span id="btnGroupVerticalDropPreCode" class="btn btn-light dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false" title="{% trans 'Pre or Code' %}">
<span id="btnGroupVerticalDropPreCode" class="btn btn-light dropdown-toggle" data-bs-toggle="dropdown" aria-haspopup="true" aria-expanded="false" title="{% trans 'Pre or Code' %}">
<svg width="1em" height="1em" viewBox="0 0 16 16" class="bi bi-code-slash" fill="currentColor" xmlns="http://www.w3.org/2000/svg">
<path fill-rule="evenodd" d="M4.854 4.146a.5.5 0 0 1 0 .708L1.707 8l3.147 3.146a.5.5 0 0 1-.708.708l-3.5-3.5a.5.5 0 0 1 0-.708l3.5-3.5a.5.5 0 0 1 .708 0zm6.292 0a.5.5 0 0 0 0 .708L14.293 8l-3.147 3.146a.5.5 0 0 0 .708.708l3.5-3.5a.5.5 0 0 0 0-.708l-3.5-3.5a.5.5 0 0 0-.708 0zm-.999-3.124a.5.5 0 0 1 .33.625l-4 13a.5.5 0 0 1-.955-.294l4-13a.5.5 0 0 1 .625-.33z"/>
</svg>
Expand Down
6 changes: 5 additions & 1 deletion martor/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,11 @@ def markdown_imgur_uploader(request):
Makdown image upload for uploading to imgur.com
and represent as json to markdown editor.
"""
if request.method == "POST" and request.is_ajax():

def is_ajax(request):
return request.META.get("HTTP_X_REQUESTED_WITH") == "XMLHttpRequest"

if request.method == "POST" and is_ajax(request):
if "markdown-image-upload" in request.FILES:
image = request.FILES["markdown-image-upload"]
response_data = imgur_uploader(image=image)
Expand Down
8 changes: 4 additions & 4 deletions martor_demo/app/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@ class PostMetaAdminInline(admin.TabularInline):


class PostAdmin(admin.ModelAdmin):
inlines = [PostMetaAdminInline, ]
list_display = ['title', 'id']
inlines = [PostMetaAdminInline]
list_display = ["title", "id"]
formfield_overrides = {
MartorField: {'widget': AdminMartorWidget},
models.TextField: {'widget': AdminMartorWidget},
MartorField: {"widget": AdminMartorWidget},
models.TextField: {"widget": AdminMartorWidget},
}


Expand Down
2 changes: 1 addition & 1 deletion martor_demo/app/apps.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@


class AppConfig(AppConfig):
name = 'app'
name = "app"
3 changes: 1 addition & 2 deletions martor_demo/app/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ class SimpleForm(forms.Form):


class PostForm(forms.ModelForm):

class Meta:
model = Post
fields = '__all__'
fields = "__all__"
8 changes: 6 additions & 2 deletions martor_demo/app/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,12 @@


class Post(models.Model):
author = models.ForeignKey(User, on_delete=models.CASCADE,
blank=True, null=True)
author = models.ForeignKey(
User,
on_delete=models.CASCADE,
blank=True,
null=True,
)
title = models.CharField(max_length=200)
description = MartorField()
wiki = MartorField(blank=True)
Expand Down
4 changes: 2 additions & 2 deletions martor_demo/app/templates/bootstrap/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@
<nav class="navbar navbar-expand-lg navbar-dark bg-dark">
<div class="container">
<a class="navbar-brand" href="/">Martor</a>
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>

<div class="collapse navbar-collapse" id="navbarSupportedContent">
<ul class="navbar-nav mr-auto">
<li class="nav-item dropdown">
<a class="nav-link dropdown-toggle" href="#" id="navbarDropdown" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
<a class="nav-link dropdown-toggle" href="#" id="navbarDropdown" role="button" data-bs-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
Choose Demo
</a>
<div class="dropdown-menu" aria-labelledby="navbarDropdown">
Expand Down
16 changes: 10 additions & 6 deletions martor_demo/app/urls.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
from django.urls import path

from app.views import (home_redirect_view, simple_form_view,
post_form_view, test_markdownify)
from app.views import (
home_redirect_view,
simple_form_view,
post_form_view,
test_markdownify,
)

urlpatterns = [
path('', home_redirect_view, name='home_redirect'),
path('simple-form/', simple_form_view, name='simple_form'),
path('post-form/', post_form_view, name='post_form'),
path('test-markdownify/', test_markdownify, name='test_markdownify'),
path("", home_redirect_view, name="home_redirect"),
path("simple-form/", simple_form_view, name="simple_form"),
path("post-form/", post_form_view, name="post_form"),
path("test-markdownify/", test_markdownify, name="test_markdownify"),
]
Loading

0 comments on commit e51c4ea

Please sign in to comment.