sagemath / sage

Main repository of SageMath
https://www.sagemath.org
Other
1.45k stars 482 forks source link

Restructure templates to idiomatic Jinja #7786

Closed 6bf4345a-8fdd-4a0e-b9a5-03107e609570 closed 14 years ago

6bf4345a-8fdd-4a0e-b9a5-03107e609570 commented 14 years ago

By idiomatic Jinja, I mean

This will make editing the templates easier, and will allow for a more consistent interface (by specifying base templates for each section).

[1] Model-View-Controller

CC: @qed777 @williamstein

Component: notebook

Author: Tim Dumol, Mitesh Patel

Reviewer: Mitesh Patel

Merged: sagenb-0.6

Issue created by migration from https://trac.sagemath.org/ticket/7786

6bf4345a-8fdd-4a0e-b9a5-03107e609570 commented 14 years ago

Attachment: trac_7783-sage-scripts.patch.gz

Preliminary work. Worksheet pages not yet done.

6bf4345a-8fdd-4a0e-b9a5-03107e609570 commented 14 years ago

Attachment: trac_7786-template-jinja-idiomatic.patch.gz

Converts template structure to an inheritance based tree. Apply this patch alone to sagenb repo.

6bf4345a-8fdd-4a0e-b9a5-03107e609570 commented 14 years ago
comment:1

This is a big patch that makes the template structure more consistent by using inheritance. It also removes a lot of non-semantic markup (
,


, etc.). Please note that there are some visual changes (font stack, bar below banner at login.html, headers instead of bold tags at login.html, etc.). I hope they're not too major. Kindly note any changes that are too big and may require consultation at the mailing list.

6bf4345a-8fdd-4a0e-b9a5-03107e609570 commented 14 years ago
comment:2

Note: Depends on #7269, #7650, and dependencies.

e14f4152-4982-4ace-8c95-73a0599b109b commented 14 years ago

Author: Tim Dumol

e14f4152-4982-4ace-8c95-73a0599b109b commented 14 years ago
comment:3

I can only look at the patch right now, but I think these are much-needed and appreciated changes to SageNB. I think we should make merging this ticket (plus its dependencies) a priority. I'll try to start reviewing the patch soon.

As the merge nears, I'll rebase #7666 and its descendants, as necessary.

6bf4345a-8fdd-4a0e-b9a5-03107e609570 commented 14 years ago

Attachment: trac_7786-template-jinja-idiomatic.2.patch.gz

Rebased on #7650 and its dependencies. Apply this patch alone to sagenb repo.

6bf4345a-8fdd-4a0e-b9a5-03107e609570 commented 14 years ago

Rebased on #7650 and its dependencies. Apply this patch alone to sagenb repo.

6bf4345a-8fdd-4a0e-b9a5-03107e609570 commented 14 years ago

Attachment: trac_7786-template-jinja-idiomatic.2,patch.gz

Attachment: trac_7786-template-jinja-idiomatic.3.patch.gz

Updates source_code.html and adds styling for it. Also adds a warning to the .css files.

6bf4345a-8fdd-4a0e-b9a5-03107e609570 commented 14 years ago

Attachment: trac_7786-template-jinja-idiomatic.4.patch.gz

Adds missing div_wrap argument to template call at Cell.html()

e14f4152-4982-4ace-8c95-73a0599b109b commented 14 years ago
comment:4

V4 applies cleanly to 4.3.1.alpha0 + #7650's latest. With this configuration, I see

e14f4152-4982-4ace-8c95-73a0599b109b commented 14 years ago
comment:5
e14f4152-4982-4ace-8c95-73a0599b109b commented 14 years ago
comment:6
trac_7843-cell_listdir.patch
trac_7844-notebook_address.patch
trac_7847-empty_trash_ie_ff.patch
trac_7846-no_CODE_PY_symlinks.patch
trac_7650-sagenb_doctesting_v3.patch
trac_7786-template-jinja-idiomatic.4.patch

!

e14f4152-4982-4ace-8c95-73a0599b109b commented 14 years ago
comment:7
e14f4152-4982-4ace-8c95-73a0599b109b commented 14 years ago

Simple Jinja template dependency graph worksheet. Not a patch.

e14f4152-4982-4ace-8c95-73a0599b109b commented 14 years ago
comment:8

Attachment: jinja_template_deps.html.gz

The attached worksheet (just paste it into an "Edit" window) generates a template dependency graph in Sage. I'm sure there are many improvements to make, but I hope it's a useful start. By the way, the last non-empty cell requires Graphviz's dot.

e14f4152-4982-4ace-8c95-73a0599b109b commented 14 years ago
comment:9
e14f4152-4982-4ace-8c95-73a0599b109b commented 14 years ago
comment:10

Actually, Graph.plot's partition option may be a better choice for coloring vertices. Anyway, have fun!

e14f4152-4982-4ace-8c95-73a0599b109b commented 14 years ago
comment:11

Hi Tim -- Do you mind if I make a separate, commuting patch here of just changes under sagenb/testing? If it's OK, I'd like to incorporate some changes I made at #7666, including running a test(s) by name (e.g., rt.run_any(['4088', 'test_3711'], verbosity=1)) and making it easier to test other browsers (e.g., first steps toward enabling Selenium Grid). Actually getting the tests to pass in the other browsers --- I found this very tedious / time-consuming --- we can leave for another ticket.

6bf4345a-8fdd-4a0e-b9a5-03107e609570 commented 14 years ago
comment:12

Sure, no problem.

6bf4345a-8fdd-4a0e-b9a5-03107e609570 commented 14 years ago
comment:13

By the way, the dependency graph is awesome. You may want to put it in the wiki somewhere, for Sage Notebook development tools.

6bf4345a-8fdd-4a0e-b9a5-03107e609570 commented 14 years ago

Attachment: trac_7786-template-jinja-idiomatic.5.patch.gz

Fixes the issues pointed out (Se failures, etc.)

6bf4345a-8fdd-4a0e-b9a5-03107e609570 commented 14 years ago
comment:14

The doctest failures are not yet fixed. I am having trouble with the Se tests: after a recent kernel upgrade, it seems that shutil.rmdir() fails silently, and os.path.exists reports the directory as gone, but is actually still there. I can only think of a kludgy fix of sleeping a while and looping until it can be deleted. Any ideas?

e14f4152-4982-4ace-8c95-73a0599b109b commented 14 years ago

Attachment: trac_7786-template-jinja-idiomatic.6.patch.gz

New test options. Should fix Se + doc tests. Replaces previous.

e14f4152-4982-4ace-8c95-73a0599b109b commented 14 years ago
comment:15

V6 might help. I've tested just FF 3.5.6 on Linux, so far. Examples:

import sagenb.testing.run_tests as rt

# Selenium.
rt.setup_tests(environment='*firefox3 /usr/lib64/firefox-3.5.6/firefox')
rt.run_any()

# Selenium Grid.
envs = [
    '*firefox',
#    '*googlechrome',
    '*iexplore',
    '*opera',
#    '*safari'
    ]

for e in envs:
    rt.setup_tests('192.168.50.99', False, e)
    name = 'report_' + e.split()[0][1:] + '.html'
    rt.run_any(make_report=True, report_filename=name)

For other tickets:

e14f4152-4982-4ace-8c95-73a0599b109b commented 14 years ago
comment:16

Of course, please feel free to make changes!

On the dependency graph: Thanks! Maybe we should include parts of the code (wrapped in a try-except block) in template.py?

e14f4152-4982-4ace-8c95-73a0599b109b commented 14 years ago

Attachment: trac_7786-template-jinja-idiomatic.7.patch.gz

Conditional main.js compression. See js.py. Replaces previous.

e14f4152-4982-4ace-8c95-73a0599b109b commented 14 years ago
comment:17
e14f4152-4982-4ace-8c95-73a0599b109b commented 14 years ago
comment:18

Reminder: Use self-closing <input /> tags in HTML files. WebKit browsers will complain about extra </input>s.

e14f4152-4982-4ace-8c95-73a0599b109b commented 14 years ago
comment:19

Can we delete twist.Reset_css?

6bf4345a-8fdd-4a0e-b9a5-03107e609570 commented 14 years ago
comment:20

Replying to @qed777:

Of course, please feel free to make changes!

On the dependency graph: Thanks! Maybe we should include parts of the code (wrapped in a try-except block) in template.py?

It doesn't sound like it can be used by a non-developer, so I don't think it's worth including into the package. That's just my opinion though.

e14f4152-4982-4ace-8c95-73a0599b109b commented 14 years ago
comment:21

Should NotebookSettingsPage.render return a HTMLResponse, instead of a Response?

6bf4345a-8fdd-4a0e-b9a5-03107e609570 commented 14 years ago
comment:22

Replying to @qed777:

Can we delete twist.Reset_css?

Yes, we can.

Should NotebookSettingsPage.render return a HTMLResponse, instead of a Response?

Yes.

But I think this patch has way too many changes in it as is. The clean up on twist.py should probably be spun off to another ticket.

e14f4152-4982-4ace-8c95-73a0599b109b commented 14 years ago
comment:23

Replying to @TimDumol:

But I think this patch has way too many changes in it as is. The clean up on twist.py should probably be spun off to another ticket.

Sounds good. I need to do this anyway for public / remote interacts.

e14f4152-4982-4ace-8c95-73a0599b109b commented 14 years ago

Attachment: trac_7786-template-jinja-idiomatic.8.patch.gz

Further small fixes. Replaces previous.

e14f4152-4982-4ace-8c95-73a0599b109b commented 14 years ago
comment:24

V8 should cover the problems above, except for deleting docbrowser cells, which is a known "problem" --- we don't save changes to these worksheets. Anyway, to the extent it counts, my review is positive, except:

Sass::SyntaxError on line 29 of /.../sass/src/main.sass: File to import not found or unreadable: topbar.sass.

If I comment out the @import, the generated main.css seems to be missing topbar directives.

By the way, I removed template_error.html and base_popup.html, since they don't appear to be used. I also put set div_wrap = true in cell.html (when printing). I apologize for going too far, in case I have.

e14f4152-4982-4ace-8c95-73a0599b109b commented 14 years ago

Reviewer: Mitesh Patel

e14f4152-4982-4ace-8c95-73a0599b109b commented 14 years ago

Changed author from Tim Dumol to Tim Dumol, Mitesh Patel

6bf4345a-8fdd-4a0e-b9a5-03107e609570 commented 14 years ago

Adds missing file _topbar.sass

6bf4345a-8fdd-4a0e-b9a5-03107e609570 commented 14 years ago
comment:26

Attachment: trac_7786-template-jinja-idiomatic.9.patch.gz

Yes, it was missing. This patch fixes that problem.

e14f4152-4982-4ace-8c95-73a0599b109b commented 14 years ago
comment:27

Positive review from me. If you agree, please update the status.

e14f4152-4982-4ace-8c95-73a0599b109b commented 14 years ago
comment:28

Actually, I just noticed some problems with $(document).ready(). I'm working on V10.

e14f4152-4982-4ace-8c95-73a0599b109b commented 14 years ago

Attachment: trac_7786-template-jinja-idiomatic.10.patch.gz

DOM ready / load event timing fixes. Replaces previous.

e14f4152-4982-4ace-8c95-73a0599b109b commented 14 years ago
comment:29

In V10, I replaced $(document).ready() in a few places with either synchronous evaluation or $(window).load() (in particular, $(document).load() does not always work). The main reason is timing --- the "DOM ready" event can fire too early for certain notebook initializations. For example, evaluate

import time
time.sleep(20)
print 'foo'

and reload the worksheet. Published interacts are another, forthcoming example...

I noticed that Worksheet.html_cell_list in V9

I've replaced the call with an empty string. However, the main problem is that HTML for published worksheets is now no longer cached by the server. Or am I mistaken?

I'll try to fix this in V11...

e14f4152-4982-4ace-8c95-73a0599b109b commented 14 years ago

Attachment: trac_7786-template-jinja-idiomatic.11.patch.gz

Cache HTML for published worksheets. Replaces previous.

e14f4152-4982-4ace-8c95-73a0599b109b commented 14 years ago
comment:30

V11 is attached.

e14f4152-4982-4ace-8c95-73a0599b109b commented 14 years ago
comment:31

If I save $\alpha$ in a text cell, then edit the cell again, I see Ë in the editor. Moreover, the HTML source now contains <span> tags, etc.

e14f4152-4982-4ace-8c95-73a0599b109b commented 14 years ago

Fix text cell typesetting. Replaces previous.

e14f4152-4982-4ace-8c95-73a0599b109b commented 14 years ago
comment:32

Attachment: trac_7786-template-jinja-idiomatic.12.patch.gz

Replying to @qed777:

If I save $\alpha$ in a text cell, then edit the cell again, I see Ë in the editor. Moreover, the HTML source now contains <span> tags, etc.

V12 should fix this.

e14f4152-4982-4ace-8c95-73a0599b109b commented 14 years ago
comment:33

I just noticed that Sphinx fails to build the reference manual. The "problem" may be in template.py:

Sphinx error:
'utf8' codec can't decode bytes in position 746-749: invalid data