Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use easy/load.js when loading jsmath in the notebook #4714

Closed
jasongrout opened this issue Dec 5, 2008 · 31 comments
Closed

use easy/load.js when loading jsmath in the notebook #4714

jasongrout opened this issue Dec 5, 2008 · 31 comments

Comments

@jasongrout
Copy link
Member

The patch

consolidates jsMath setup in /javascript/jsmath.js. It depends on #6673.

CC: @jhpalmieri @TimDumol @williamstein

Component: notebook

Author: Mitesh Patel

Reviewer: William Stein

Merged: sagenb-0.4.6

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

@qed777
Copy link
Mannequin

qed777 mannequin commented May 7, 2009

comment:1

Copied from jason:

Replying to mpatel:

A related issue: It would be nice to have just one <script> element load jsMath with all of Sage's customizations (extensions, plug-ins, macros, etc.) into regular, published, printed, and docbrowser worksheets, as well as "torn out" introspection windows and offline documentation. Maybe easy/load.js is the right place (see #4714),
but I think notebook.py generates the macro list on-the-fly.

Davide (author of jsmath) sent these comments about the above paragraph:

Mpatel is right that jsMath/easy/load.js could be used for this. Rather than putting calls to jsMath.Setup.Script() or jsMath.Extention.Require() in-line in the document itself, these can be be put in the loadFiles array in easy/load.js. It is also possible to put the jsMath.Macro() calls into a file (say jsMath/local/sage.js), and add that file to the loadFiles array as well rather than put them in-line. Any sage-specific customization could go in local/sage.js as well. In the latest version of jsMath, there is even a macros array in easy/load.js for custom macros, so you would not even need an extra file for that. These features are, in fact, one of the important reasons for easy/load.js, so I hope you are able to take advantage of them.

@qed777
Copy link
Mannequin

qed777 mannequin commented Jun 18, 2009

comment:3

A few *estions:

  • Should we patch the spkg's jsmath/easy/load.js?
  • Add jsmath/local/sage.js to its loadFiles array?
  • Re-generate this sage.js from the list in sage/misc/latex_macros.py during
    1. sage -docbuild, in doc/common/conf.py?
    2. sage -b?
    3. notebook startup?

@loefflerd
Copy link
Mannequin

loefflerd mannequin commented Jul 13, 2009

comment:4

This is misfiled (should be under "documentation").

@loefflerd loefflerd mannequin unassigned boothby Jul 13, 2009
@qed777
Copy link
Mannequin

qed777 mannequin commented Jul 17, 2009

comment:5

After #5799, we have two copies of the jsmath tree, one in doc/common/static and another in javascript_local. That is, one from sage-4.1.spkg and another from jsmath-3.6b.p1.spkg. Can we avoid this? Or should we maintain separate load.js files for the notebook and documentation?

@qed777
Copy link
Mannequin

qed777 mannequin commented Aug 2, 2009

comment:6

Replying to @qed777:

After #5799, we have two copies of the jsmath tree, one in doc/common/static and another in javascript_local. That is, one from sage-4.1.spkg and another from jsmath-3.6b.p1.spkg. Can we avoid this? Or should we maintain separate load.js files for the notebook and documentation?

See #6614 for a potential resolution.

@qed777
Copy link
Mannequin

qed777 mannequin commented Aug 2, 2009

comment:7

The latest patch at #6614 tells Sphinx to copy jsMath directly from javascript_local to doc/output/html/en/*/_static. In particular, it does this before it copies the files in doc/common/static. How about putting a custom easy/load.js there?

If we're not adding new doc macros frequently, we could just paste them from latex_macros.py. Or we might add an option to sage -docbuild to regenerate load.js on demand (cf. #6187). If we overwrite the file during every build, we may need to synchronize access from multiple Sphinx processes (cf. #6255).

(Note: Sphinx 0.6.2 supports HTML themes, including static templates. It's tempting to create a template static/easy/load.js_t. However, Sphinx does not process user templates in static's subdirectories.)

On the notebook: I believe we can move nearly all jsMath directives from notebook.py to a custom javascript_local/jsmath/easy/load.js that's overwritten on notebook start-up. Perhaps in twist.py?

I'd really like to get moving on this, provided there's agreement. Of course, we can split this into two tickets, [at least] one each for the docs and notebook. Thoughts?

@qed777
Copy link
Mannequin

qed777 mannequin commented Aug 4, 2009

Minimal approach for docs. Depends on #6614.

@qed777
Copy link
Mannequin

qed777 mannequin commented Aug 4, 2009

comment:8

Attachment: trac_4714-minimal_doc.patch.gz

This p(r)oof of concept, which depends on a patch at #6614,

  • Adds doc/common/static/jsmath_sage.js.
  • Sets jsmath_path=jsmath_sage.js in doc/common/conf.py.

The new static file is jsMath's "stock" easy/load.js plus all Sage-related customizations I could find, including extensions, macros, and a few other bits from notebook.py. I've also made changes below DO NOT MAKE CHANGES BELOW THIS (gasp!) to help the loader find jsMath from its new [relative] location.

I think this means we don't need to patch the spkg. Later, we may be able to use Sphinx 0.6.2's static templates to insert an updated macro list at build time (cf. #6586).

Perhaps we can do something similar for the notebook, e.g., in sage/server/notebook/templates.

@qed777
Copy link
Mannequin

qed777 mannequin commented Aug 4, 2009

comment:9

With major changes in afoot in the notebook at #6568, I've put the doc patch up for review at #6673 and made this ticket specific to the notebook.

@qed777 qed777 mannequin changed the title use easy/load.js when loading jsmath use easy/load.js when loading jsmath in the notebook Aug 4, 2009
@qed777 qed777 mannequin added c: user interface and removed c: documentation labels Aug 4, 2009
@qed777 qed777 mannequin assigned boothby Aug 4, 2009
@qed777
Copy link
Mannequin

qed777 mannequin commented Oct 16, 2009

comment:10

See this comment (and the next one) at #6673 for a suggested path to "unification."

@qed777
Copy link
Mannequin

qed777 mannequin commented Oct 21, 2009

comment:11

In sagenb.notebook.twist, we can use a cached sage.misc.latex_macros.sage_jsmath_macros_easy (cf. #6673's v3) and JSMATH_IMAGE_FONTS, plus a user's own macros, to serve a dynamic javascript/jsmath.js.

@qed777
Copy link
Mannequin

qed777 mannequin commented Oct 23, 2009

Consolidate jsMath setup. Apply to sagenb repository. Apply only this patch.

@qed777
Copy link
Mannequin

qed777 mannequin commented Oct 23, 2009

comment:12

Attachment: trac_4714-sagenb_jsmath_init.patch.gz

The patch attachment: trac_4714-sagenb_jsmath_init.patch consolidates jsMath setup in /javascript/jsmath.js. It depends on #6673.

The patch still hard-codes the sage.misc.latex_macros's macros. Still to do: Generate the macros from server/user settings and latex_macros's helper functions.

@qed777
Copy link
Mannequin

qed777 mannequin commented Oct 23, 2009

Author: Mitesh Patel

@qed777 qed777 mannequin added the s: needs review label Oct 23, 2009
@qed777
Copy link
Mannequin

qed777 mannequin commented Oct 24, 2009

Hard-code jsMath macros. Apply to sagenb repository.

@qed777
Copy link
Mannequin

qed777 mannequin commented Oct 24, 2009

comment:13

Attachment: trac_4714-sagenb_hard_code_macros.patch.gz

I've reattached attachment: trac_4714-sagenb_hard_code_macros.patch, since my first try didn't work (server problems?).

@qed777
Copy link
Mannequin

qed777 mannequin commented Oct 24, 2009

comment:14

Note: With Jinja2 (cf. #7269, #7249), we can instead use, e.g.,

    macros: {
       {{ jsmath_macros|join(',\n') }}
    },

in jsmath.js (cf. #6673).

@qed777 qed777 mannequin modified the milestones: sage-4.2.1, sage-4.2 Oct 25, 2009
@sagetrac-mvngu sagetrac-mvngu mannequin modified the milestones: sage-4.2, sage-4.3 Nov 20, 2009
@qed777
Copy link
Mannequin

qed777 mannequin commented Nov 26, 2009

Work Issues: rebase

@qed777 qed777 mannequin added s: needs work and removed s: needs review labels Nov 26, 2009
@qed777
Copy link
Mannequin

qed777 mannequin commented Nov 26, 2009

Rebased. See the comment for the queue. Apply only this patch. sagenb repo.

@qed777
Copy link
Mannequin

qed777 mannequin commented Nov 26, 2009

comment:19

Attachment: trac_4714-sagenb_jsmath_init_v2.patch.gz

Rebased against this sequence:

trac_7390-sagenb_test_report_A.patch
trac_7390-sagenb_test_report_B_v2.patch
trac_7390-sagenb_test_report_referee.patch
trac_7402-pkg_resources.patch
trac_7428-publish_last_edited_v2.patch
trac_7444-search_after_publish.patch
trac_7376-search_by_username_v2.patch
trac_1321-sagenb_graphed.patch
sagenb_7483.patch
sagenb_7482.patch
sagenb-7495.patch
sagenb_3849.patch
trac_4714-sagenb_jsmath_init_v2.patch

@qed777 qed777 mannequin added s: needs review and removed s: needs work labels Nov 26, 2009
@qed777
Copy link
Mannequin

qed777 mannequin commented Nov 26, 2009

Changed work issues from rebase to none

@qed777 qed777 mannequin added p: minor / 4 and removed p: major / 3 labels Nov 26, 2009
@qed777
Copy link
Mannequin

qed777 mannequin commented Dec 2, 2009

Attachment: trac_4714-sagenb_jsmath_init_v3.patch.gz

Force jsMath to load always. This patch only. sagenb repo.

@qed777
Copy link
Mannequin

qed777 mannequin commented Dec 2, 2009

comment:22

Version 3:

  • Disables jsMath's autoload plug-in. Otherwise, jsMath does not load itself and run in worksheets that initially do not contain expressions to typeset.

@qed777

This comment has been minimized.

@williamstein
Copy link
Contributor

comment:23

Looks good to me.

@williamstein
Copy link
Contributor

comment:24

I merged this patch into sagenb-0.4.6.

@sagetrac-mvngu
Copy link
Mannequin

sagetrac-mvngu mannequin commented Dec 27, 2009

Merged: sagenb-0.4.6

@sagetrac-mvngu
Copy link
Mannequin

sagetrac-mvngu mannequin commented Dec 27, 2009

Reviewer: William Stein

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants