Skip to content

Commit

Permalink
Get ready for release 3.0.0
Browse files Browse the repository at this point in the history
Also blacken all files and start using pre-commit
  • Loading branch information
rocky committed Jun 26, 2021
1 parent a655685 commit f5e0f88
Show file tree
Hide file tree
Showing 19 changed files with 193 additions and 107 deletions.
4 changes: 2 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ repos:
- id: debug-statements
- id: end-of-file-fixer
- repo: https://github.com/psf/black
rev: 19.3b0
rev: 20.8b1
hooks:
- id: black
language_version: python3
exclude: 'mathicsscript/version.py'
exclude: 'mathics_django/version.py'
42 changes: 41 additions & 1 deletion CHANGES.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,46 @@
CHANGES
=======

3.0.0
-----

This release contains been a major overhaul and upgrade of the code.

It can't be stressed enough, but this was made only possible due to
the tireless work of Tiago Cavalcante Trindade.

There is still a lot of work still to do. However where we are at
right now, there have been massive changes and improvements:

* three.js has been upgraded to r124 (from r52) which brings us from
up seven years from circa 2013 to late 2020!
* Plots and Graphs no longer appear inside MathML when there is no reason for them to be in MathML.
* The "About" page now shows all of the the Mathics ``Settings`` that
are in effect. You can change Boolean setting inside the About page.
* 3D Polygon rendering has been greatly improved. However we currently
do not handle even/odd space filling.
* We support TickStyle coloring in 3D Graphics.
* Tick positions in most 2D Plots and Graphs as been fixed.
* We tolerate smaller screens in SVG rendering.
* Styling of Cells has been improved. A somewhat Jupyter-style frame box is used.
* Output which are strings now have surrounding quotes. (This can be
turned off via ``Settings`$QuotedStrings``.)
* In headings, we make it more clear that the code is Django
based. This is to make clear the distinction should there be a
Flask-based front-end or the long sought for Jupyter front end.
* In the online document, sections which are empty are omitted from
the online view.
* A stray in the space between logo and Mathics at the top was removed.
* Gallery examples have been improved.
* A major rewrite of the JavaScript code according to more modern
Javascript style has been started. More work will probably continue
in future releases.
* Respecting ``PointSize`` in the rendering of 3D plots as been
fixed. The default point size now more closely matches the intended specification.
* The use of Prototype and Scriptaculous are being phased out.



2.2.0
-----

Expand Down Expand Up @@ -52,4 +92,4 @@ Small bug fixes.
1.0.0
-----

Code split off from Mathics 1.1.0. We have some support for NetworkX/pyplot graphs.
Code split off from Mathics 1.1.0. We have some support for NetworkX/pyplot graphs.
1 change: 1 addition & 0 deletions mathics_django/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
PrecisionReal,
)
from mathics import version_info

version_info["django"] = django.__version__

version_string = """Mathics {mathics}
Expand Down
9 changes: 6 additions & 3 deletions mathics_django/doc/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,12 @@ def slugify(value):
Based on the Django version, but modified to preserve '$'.
"""
value = unicodedata.normalize('NFKD', value).encode('ascii', 'ignore').decode('ascii')
value = re.sub('[^$`\w\s-]', '', value).strip().lower()
return re.sub('[-\s`]+', '-', value)
value = (
unicodedata.normalize("NFKD", value).encode("ascii", "ignore").decode("ascii")
)
value = re.sub("[^$`\w\s-]", "", value).strip().lower()
return re.sub("[-\s`]+", "-", value)


# FIXME: can we replace this with Python 3's html.escape ?
def escape_html(text, verbatim_mode=False, counters=None, single_line=False):
Expand Down
4 changes: 3 additions & 1 deletion mathics_django/docpipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -527,7 +527,9 @@ def main():
if args.pymathics: # in case the section is in a pymathics module...
documentation.load_pymathics_doc()

test_chapters(chapters, stop_on_failure=args.stop_on_failure, reload=args.reload)
test_chapters(
chapters, stop_on_failure=args.stop_on_failure, reload=args.reload
)
else:
# if we want to check also the pymathics modules
if args.pymathics:
Expand Down
4 changes: 3 additions & 1 deletion mathics_django/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,9 @@
# os.makedirs(DATA_DIR)

MATHICS_DJANGO_DB = os.environ.get("MATHICS_DJANGO_DB", "mathics.sqlite")
MATHICS_DJANGO_DB_PATH = os.environ.get("MATHICS_DJANGO_DB_PATH", DATA_DIR + MATHICS_DJANGO_DB)
MATHICS_DJANGO_DB_PATH = os.environ.get(
"MATHICS_DJANGO_DB_PATH", DATA_DIR + MATHICS_DJANGO_DB
)

DOC_DIR = os.path.join(MATHICS_ROOT_DIR, "doc/documentation/")

Expand Down
9 changes: 3 additions & 6 deletions mathics_django/test_django.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,10 @@


class HomePageTests(SimpleTestCase):

def test_home_page_status_code(self):
response = self.client.get('/')
response = self.client.get("/")
self.assertEquals(response.status_code, 200)


def test_home_page_does_not_contain_incorrect_html(self):
response = self.client.get('/')
self.assertNotContains(
response, 'Hi there! I should not be on the page.')
response = self.client.get("/")
self.assertNotContains(response, "Hi there! I should not be on the page.")
6 changes: 3 additions & 3 deletions mathics_django/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@
from django.conf.urls.static import static
from django.conf import settings

handler404 = 'mathics_django.web.views.error_404_view'
handler500 = 'mathics_django.web.views.error_500_view'
handler404 = "mathics_django.web.views.error_404_view"
handler500 = "mathics_django.web.views.error_500_view"

urlpatterns = [
# url(''),
url(r'^', include('mathics_django.web.urls')),
url(r"^", include("mathics_django.web.urls")),
] + static(settings.STATIC_URL, document_root=settings.STATIC_ROOT)
4 changes: 2 additions & 2 deletions mathics_django/version.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# -*- coding: utf-8 -*-


# This file is suitable for sourcing inside POSIX shell as
# well as importing into Python. That's why there is no
# space around "=" below.
__version__="2.2.1.dev0" # noqa
# fmt: off
__version__="3.0.0" # noqa
7 changes: 5 additions & 2 deletions mathics_django/web/format.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
"System`OutputForm": "text",
}


def format_output(obj, expr, format=None):
"""
Handle unformatted output using the *specific* capabilities of mathics-django.
Expand Down Expand Up @@ -64,7 +65,9 @@ def eval_boxes(result, fn, obj, **options):

# This part was derived from and the same as evaluation.py format_output.

use_quotes = Expression("Settings`$QuotedStrings").evaluate(obj).get_head().to_python()
use_quotes = (
Expression("Settings`$QuotedStrings").evaluate(obj).get_head().to_python()
)

if format == "text":
result = expr.format(obj, "System`OutputForm")
Expand All @@ -89,7 +92,7 @@ def eval_boxes(result, fn, obj, **options):
result = expr.format(obj, "System`InputForm")
result = result.boxes_to_text(result)

if (not use_quotes):
if not use_quotes:
# Substring without the quotes
result = result[1:-1]

Expand Down
29 changes: 18 additions & 11 deletions mathics_django/web/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,34 +6,41 @@

class AjaxForm(forms.Form):
def as_json(self, general_errors=[]):
field_errors = dict((key, [str(error) for error in errors])
for key, errors in self.errors.items())
field_errors = dict(
(key, [str(error) for error in errors])
for key, errors in self.errors.items()
)
gen_errors = general_errors + self.non_field_errors()
result = {}
if field_errors:
result['fieldErrors'] = field_errors
result["fieldErrors"] = field_errors
if gen_errors:
result['generalErrors'] = gen_errors
if hasattr(self, 'cleaned_data'):
result['values'] = self.cleaned_data
result["generalErrors"] = gen_errors
if hasattr(self, "cleaned_data"):
result["values"] = self.cleaned_data
return result


class LoginForm(AjaxForm):
email = forms.EmailField(max_length=80)
password = forms.CharField(
required=False, max_length=40, widget=forms.PasswordInput,
required=False,
max_length=40,
widget=forms.PasswordInput,
help_text=(
'<p class="helptext">Leave this field empty '
"if you don't have an account yet,\n"
"or if you have forgotten your pass&shy;word.\n"
"A new password will be sent to your e-mail address.</p>")
"A new password will be sent to your e-mail address.</p>"
),
)


class SaveForm(AjaxForm):
name = forms.CharField(
required=True, max_length=30,
help_text=('<p class="helptext">Worksheet names '
'are not case-sensitive.</p>')
required=True,
max_length=30,
help_text=(
'<p class="helptext">Worksheet names ' "are not case-sensitive.</p>"
),
)
66 changes: 45 additions & 21 deletions mathics_django/web/migrations/0001_initial.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,34 +17,58 @@ class Migration(migrations.Migration):

operations = [
migrations.CreateModel(
name='Query',
name="Query",
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('time', models.DateTimeField(auto_now_add=True)),
('query', models.TextField()),
('result', models.TextField(null=True)),
('timeout', models.BooleanField()),
('out', models.TextField()),
('error', models.BooleanField()),
('remote_user', models.CharField(max_length=255, null=True)),
('remote_addr', models.TextField(null=True)),
('remote_host', models.TextField(null=True)),
('browser', models.TextField(null=True)),
('meta', models.TextField(null=True)),
('log', models.TextField(null=True)),
(
"id",
models.AutoField(
auto_created=True,
primary_key=True,
serialize=False,
verbose_name="ID",
),
),
("time", models.DateTimeField(auto_now_add=True)),
("query", models.TextField()),
("result", models.TextField(null=True)),
("timeout", models.BooleanField()),
("out", models.TextField()),
("error", models.BooleanField()),
("remote_user", models.CharField(max_length=255, null=True)),
("remote_addr", models.TextField(null=True)),
("remote_host", models.TextField(null=True)),
("browser", models.TextField(null=True)),
("meta", models.TextField(null=True)),
("log", models.TextField(null=True)),
],
),
migrations.CreateModel(
name='Worksheet',
name="Worksheet",
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('name', models.CharField(max_length=30)),
('content', models.TextField()),
('user', models.ForeignKey(null=True, on_delete=django.db.models.deletion.CASCADE, related_name='worksheets', to=settings.AUTH_USER_MODEL)),
(
"id",
models.AutoField(
auto_created=True,
primary_key=True,
serialize=False,
verbose_name="ID",
),
),
("name", models.CharField(max_length=30)),
("content", models.TextField()),
(
"user",
models.ForeignKey(
null=True,
on_delete=django.db.models.deletion.CASCADE,
related_name="worksheets",
to=settings.AUTH_USER_MODEL,
),
),
],
),
migrations.AlterUniqueTogether(
name='worksheet',
unique_together=set([('user', 'name')]),
name="worksheet",
unique_together=set([("user", "name")]),
),
]
13 changes: 9 additions & 4 deletions mathics_django/web/migrations/0002_auto_20200917_2354.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,18 @@
class Migration(migrations.Migration):

dependencies = [
('web', '0001_initial'),
("web", "0001_initial"),
]

operations = [
migrations.AlterField(
model_name='worksheet',
name='user',
field=models.ForeignKey(null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='worksheets', to=settings.AUTH_USER_MODEL),
model_name="worksheet",
name="user",
field=models.ForeignKey(
null=True,
on_delete=django.db.models.deletion.SET_NULL,
related_name="worksheets",
to=settings.AUTH_USER_MODEL,
),
),
]
13 changes: 9 additions & 4 deletions mathics_django/web/migrations/0003_auto_20200921_1835.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,18 @@
class Migration(migrations.Migration):

dependencies = [
('web', '0002_auto_20200917_2354'),
("web", "0002_auto_20200917_2354"),
]

operations = [
migrations.AlterField(
model_name='worksheet',
name='user',
field=models.ForeignKey(null=True, on_delete=django.db.models.deletion.CASCADE, related_name='worksheets', to=settings.AUTH_USER_MODEL),
model_name="worksheet",
name="user",
field=models.ForeignKey(
null=True,
on_delete=django.db.models.deletion.CASCADE,
related_name="worksheets",
to=settings.AUTH_USER_MODEL,
),
),
]
10 changes: 5 additions & 5 deletions mathics_django/web/migrations/0004_auto_20210425_1408.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,18 @@
class Migration(migrations.Migration):

dependencies = [
('web', '0003_auto_20200921_1835'),
("web", "0003_auto_20200921_1835"),
]

operations = [
migrations.AlterField(
model_name='query',
name='id',
model_name="query",
name="id",
field=models.AutoField(primary_key=True, serialize=False),
),
migrations.AlterField(
model_name='worksheet',
name='id',
model_name="worksheet",
name="id",
field=models.AutoField(primary_key=True, serialize=False),
),
]
Loading

0 comments on commit f5e0f88

Please sign in to comment.