Skip to content

Commit

Permalink
Merge branch 'release-1.12.3'
Browse files Browse the repository at this point in the history
  • Loading branch information
abidibo committed Nov 30, 2020
2 parents 6c6fa64 + 7484f6c commit 748c7e2
Show file tree
Hide file tree
Showing 18 changed files with 50 additions and 22 deletions.
11 changes: 9 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,14 @@ You must specify the _type_, _name_ and _app_ keys. Optionally, an icon key.

#### Free

You can specify free voices. You must define a _url_ and if you want some visibility permissions (OR clause). Free voices can have children and so you can specify the _default_open_ key.
You can specify free voices. You must define a _url_ and if you want some visibility permissions (OR clause). Free voices can have children and so you can specify the _default_open_ key. Free voices also accept a _re_ property, which specifies a regular expression used to decide whether to highlight the voice or not (the regular expression is evaluated against the document location pathname).

{
'type': 'free',
'label': 'Categories',
'url': '/admin/news/category/',
're': '^/admin/news/category/(\d*)?'
}

### <a name="configuration-analytics"></a>ANALYTICS

Expand Down Expand Up @@ -272,7 +279,7 @@ To use these, just override the baton `admin/base_site.html` template and regist
{% baton_config 'MENU_TITLE' as menu_title %}
{% baton_config 'GRAVATAR_DEFAULT_IMG' as gravatar_default_img %}
(function ($, undefined) {
$(window).on('load', function () {
$(document).ready(function () {
// init listeners
Baton.Dispatcher.register('onReady', function () { console.log('BATON IS READY') })
Baton.Dispatcher.register('onMenuReady', function () { console.log('BATON MENU IS READY') })
Expand Down
2 changes: 1 addition & 1 deletion baton/static/baton/app/dist/baton.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion baton/static/baton/app/dist/baton.min.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion baton/static/baton/app/package-lock.json

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

2 changes: 1 addition & 1 deletion baton/static/baton/app/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "baton",
"version": "1.12.2",
"version": "1.12.3",
"description": "Django Baton App",
"main": "index.js",
"scripts": {
Expand Down
9 changes: 8 additions & 1 deletion baton/static/baton/app/src/core/Menu.js
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,14 @@ let Menu = {

voice.children.forEach((model, i) => {
let active = false
if (model.url) {
if (model.type === 'free') {
if (model.re) {
let re = new RegExp(model.re)
active = re.test(location.pathname)
} else {
active = location.pathname === model.url
}
} else if (model.url) {
let pathRexp = new RegExp(model.url)
active = pathRexp.test(location.pathname)
}
Expand Down
2 changes: 1 addition & 1 deletion baton/static/baton/app/src/core/Tabs.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ let Tabs = {
})

$('a[data-toggle="tab"]').on('shown.bs.tab', function (e) {
$('[title]').tooltip()
$('[title]:not(iframe)').tooltip()
})
},
createInlineEl: function (el, setDataTab = false) {
Expand Down
4 changes: 2 additions & 2 deletions baton/static/baton/app/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ window.Baton = {
}

// tooltips
this.loadTooltips()
setTimeout(this.loadTooltips, 1000) // wait a bit for tinymce

console.info('Baton:', 'ready')
document.body.className += ' baton-ready'
Expand All @@ -62,7 +62,7 @@ window.Baton = {
Dispatcher.emit('onReady')
},
loadTooltips: function () {
$('[title]').tooltip()
$('[title]:not(iframe)').tooltip()
},
page: function () {
if (/^(\/[a-z]{2})?\/admin\/$/.test(location.pathname)) {
Expand Down
4 changes: 2 additions & 2 deletions baton/templates/admin/base_site.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
{% block extrahead %}
<meta content="width=device-width, initial-scale=1.0" name="viewport" />
<script src="{% static 'baton/app/dist/baton.min.js' %}"></script>
<!-- <script src="http://localhost:8080/dist/baton.min.js"></script> -->
<!-- <script src="http://localhost:8081/dist/baton.min.js"></script> -->
<script>
{% baton_config 'CONFIRM_UNSAVED_CHANGES' as confirm_unsaved_changes %}
{% baton_config 'SHOW_MULTIPART_UPLOADING' as show_multipart_uploading %}
Expand All @@ -18,7 +18,7 @@
{% baton_config 'MENU_TITLE' as menu_title %}
{% baton_config 'GRAVATAR_DEFAULT_IMG' as gravatar_default_img %}
(function ($, undefined) {
$(window).on('load', function () {
$(document).ready(function () {
Baton.init({
api: {
app_list: '{% url 'baton-app-list-json' %}',
Expand Down
1 change: 1 addition & 0 deletions baton/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ def get_free_voice(self, item):
'label': item.get('label', ''),
'icon': item.get('icon', None),
'url': item.get('url', None),
're': item.get('re', None),
'defaultOpen': item.get('default_open', False),
'children': children,
}
Expand Down
4 changes: 2 additions & 2 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,9 @@
# built documents.
#
# The short X.Y version.
version = u'1.12.2'
version = u'1.12.3'
# The full version, including alpha/beta/rc tags.
release = u'1.12.2'
release = u'1.12.3'

# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
Expand Down
14 changes: 12 additions & 2 deletions docs/configuration.rst
Original file line number Diff line number Diff line change
Expand Up @@ -254,8 +254,8 @@ In such case you must define an ``url`` and if you want some visibility permissi

{ 'type': 'free', 'label': 'Docs', 'url': 'http://www.mydocssite.com' },

or ::
or ::

{ 'type': 'free', 'label': 'Add page', 'url': '/admin/flatpages/flatpage/add/', 'perms': ('flatpages.add_flatpage', ) },

It accepts children voices ::
Expand All @@ -267,6 +267,16 @@ It accepts children voices ::

Since free voices can have children you can specify the ``default_open`` key.

Free voices also accept a _re_ property, which specifies a regular expression used to decide whether to highlight the voice or not (the regular expression is evaluated against the document location pathname): ::

{
'type': 'free',
'label': 'Categories',
'url': '/admin/news/category/',
're': '^/admin/news/category/(\d*)?'
}


Analytics
---------

Expand Down
2 changes: 1 addition & 1 deletion docs/customization.rst
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ You can also perform live development, in this case:
{% baton_config 'MENU_TITLE' as menu_title %}
{% baton_config 'GRAVATAR_DEFAULT_IMG' as gravatar_default_img %}
(function ($, undefined) {
$(window).on('load', function () {
$(document).ready(function () {
Baton.init({
api: {
app_list: '{% url 'baton-app-list-json' %}',
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

setup(
name='django-baton',
version='1.12.2',
version='1.12.3',
packages=['baton', 'baton.autodiscover', 'baton.templatetags'],
include_package_data=True,
license='MIT License',
Expand Down
7 changes: 4 additions & 3 deletions testapp/app/app/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
'django.contrib.staticfiles',
'easy_thumbnails',
'filer',
'tinymce',
'mptt',
'news',
'baton.autodiscover',
Expand Down Expand Up @@ -160,10 +161,10 @@
'default_open': True,
'children': [
{
'type': 'model',
'type': 'free',
'label': 'Categories',
'name': 'category',
'app': 'news'
'url': '/admin/news/category/',
're': '^/admin/news/category/(\d*)?'
},
{
'type': 'model',
Expand Down
1 change: 1 addition & 0 deletions testapp/app/app/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
urlpatterns = [
path('admin/', admin.site.urls),
path('baton/', include('baton.urls')),
path('tinymce/', include('tinymce.urls')),
]

if settings.DEBUG:
Expand Down
Binary file modified testapp/app/db.sqlite3
Binary file not shown.
3 changes: 2 additions & 1 deletion testapp/app/news/models.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from django.db import models
from tinymce.models import HTMLField
from filer.fields.image import FilerImageField


Expand All @@ -25,7 +26,7 @@ class News(models.Model):
title = models.CharField('title', max_length=50, help_text='please insert a cool title')
link = models.URLField('link', blank=True, null=True)
image = FilerImageField(null=True, blank=True, on_delete=models.SET_NULL, related_name="news_image")
content = models.TextField('content', help_text='html is supported')
content = HTMLField(verbose_name='content', help_text='html is supported')
share = models.BooleanField(default=False)
published = models.BooleanField(default=False)
attachments_summary = models.TextField('attachments summary', blank=True)
Expand Down

0 comments on commit 748c7e2

Please sign in to comment.