Skip to content
This repository

Warn user if MathJax can't be fetched from notebook closes #744 #868

Merged
merged 3 commits into from over 2 years ago

3 participants

Matthias Bussonnier Min RK Fernando Perez
Matthias Bussonnier
Collaborator

just put this in notebook.html

There was an issues trying to fetch MathJax.js from the internet. You might
wan't to consider using "install_mathjax()" to be able to use the Notebook
fonctionnality offline

And hide it at <body>'s onload if window.mathjax found.

IPython/frontend/html/notebook/templates/notebook.html
@@ -49,6 +56,12 @@
49 56
     <span id="kernel_status">Idle</span>
50 57
 </div>
51 58
 
  59
+<div id="MatjaxFetchingWarning">
  60
+    There was an issues trying to fetch MathJax.js from the internet. You might
1
Fernando Perez Owner
fperez added a note

typo: issue

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
IPython/frontend/html/notebook/templates/notebook.html
@@ -49,6 +56,12 @@
49 56
     <span id="kernel_status">Idle</span>
50 57
 </div>
51 58
 
  59
+<div id="MatjaxFetchingWarning">
  60
+    There was an issues trying to fetch MathJax.js from the internet. You might
  61
+    wan't to consider using "install_mathjax()" to be able to use the Notebook
1
Fernando Perez Owner
fperez added a note

s/wan't/want/

The instructions should say instead:

You may want to consider running "from IPython.external import mathjax; mathjax.install_mathjax()" in order to be able to use the Notebook. Note that this will require a working internet connection when run, and it will try to install MathJax into the directory where you installed IPython. If you installed IPython to a location that requires administrative privileges to write, you will need to make this call as an administrator. On OSX/Linux/Unix, this can be done at the command-line via 'sudo python -c "from IPython.external import mathjax; mathjax.install_mathjax"'.

This will be much clearer and directly useful.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
IPython/frontend/html/notebook/templates/notebook.html
@@ -12,6 +12,13 @@
12 12
 
13 13
     <!-- <script type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS_HTML" charset="utf-8"></script> -->
14 14
     <script type='text/javascript' src='static/mathjax/MathJax.js?config=TeX-AMS_HTML' charset='utf-8'></script>
  15
+    <script language="Javascript">
1
Fernando Perez Owner
fperez added a note

shouldn't this be merged with the next script section immediately below, which is also about mathjax anyway?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Matthias Bussonnier Matjax Warning message improvement.
	merge '<script>' balises.
	Improve message text and style.
	Remove instead of hide
5a3b5ce
Matthias Bussonnier
Collaborator

Fixed,
with some styling inlined in HTML.
I've also change from hide to removeChild

IPython/frontend/html/notebook/templates/notebook.html
@@ -12,7 +12,13 @@
12 12
 
13 13
     <!-- <script type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS_HTML" charset="utf-8"></script> -->
14 14
     <script type='text/javascript' src='static/mathjax/MathJax.js?config=TeX-AMS_HTML' charset='utf-8'></script>
15  
-    <script type="text/javascript">
  15
+    <script language="Javascript">
9
Min RK Owner
minrk added a note

As I understand it, language="javascript" is deprecated, and type="text/javascript" is officially the way to declare script type.

Matthias Bussonnier Collaborator
Carreau added a note

I've never done javascript before, so I trust you.

Min RK Owner
minrk added a note

No worries, I didn't know either, but when I saw the inconsistency I Google'd it. We are pretty much all js novices here.

Fernando Perez Owner
fperez added a note
Matthias Bussonnier Collaborator
Carreau added a note

Very true. It took me 2hours last night to get CodeMirror to toggle
line-numbers on a per cell basis :) (pull request coming soon after I
clean it up a little).

I though I was the only one :-)

Question: are we ready to merge this one, or is further cleanup needed?

Might want to test on IE6 ?
Add a message for people with JS not activated ?

Fernando Perez Owner
fperez added a note
Matthias Bussonnier Collaborator
Carreau added a note

IE was a joke of course.
I have no idea how to add a message that will be visible only to browser without JS, without having it "poping up" for a few millisecond for user having JS...

Min RK Owner
minrk added a note

Note that you can't even get to the notebook page without js, since our whole UI (including the frontpage) is jQuery.

A single line of plaintext 'IPython notebook requires javascript' shouldn't be bothersome. I don't think there's any need for more information than that these days.

Min RK Owner
minrk added a note

Also a reason our pre-load warning messages may linger longer than others is that MathJax is huge, so loading up a notebook page can take a significant fraction of a second.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Min RK
Owner

This looks good, but as it is, you can see the MathJax warning briefly on every notebook load. We should only draw the warning when the MathJax test fails, so initially it should have display:none, and add to the check:

    function CheckMathJax(){
        var div=document.getElementById("MatjaxFetchingWarning");
        if(window.MathJax){
            document.body.removeChild(div);
        }else{
            div.style.display = "block";
        }
    }
Matthias Bussonnier
Collaborator

True, I was still thinking as if it would be executed after mathjax.js was loaded... and that the 'else' would then never be executed

Fernando Perez fperez merged commit 7a1207e into from
Fernando Perez fperez closed this
Fernando Perez
Owner

Thanks a lot for the work! Made some minor edits to the message before pushing.

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

Showing 3 unique commits by 1 author.

Oct 13, 2011
Matthias Bussonnier Warn user if MathJax can't be fetched from notebook
	closes #744
54ed7b2
Oct 14, 2011
Matthias Bussonnier Matjax Warning message improvement.
	merge '<script>' balises.
	Improve message text and style.
	Remove instead of hide
5a3b5ce
Matthias Bussonnier Hide warning message about matjax when page load
	also fix Matjax->MathJax
7a1207e
This page is out of date. Refresh to see the latest.
29  IPython/frontend/html/notebook/templates/notebook.html
@@ -13,6 +13,15 @@
13 13
     <!-- <script type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS_HTML" charset="utf-8"></script> -->
14 14
     <script type='text/javascript' src='static/mathjax/MathJax.js?config=TeX-AMS_HTML' charset='utf-8'></script>
15 15
     <script type="text/javascript">
  16
+    function CheckMathJax(){
  17
+        var div=document.getElementById("MathJaxFetchingWarning")
  18
+        if(window.MathJax){
  19
+            document.body.removeChild(div)
  20
+        }
  21
+        else{
  22
+           div.style.display = "block";
  23
+        }
  24
+    }
16 25
     if (typeof MathJax == 'undefined') {
17 26
         console.log("No local MathJax, loading from CDN");
18 27
         document.write(unescape("%3Cscript type='text/javascript' src='http://cdn.mathjax.org/mathjax/latest/MathJax.js%3Fconfig=TeX-AMS_HTML' charset='utf-8'%3E%3C/script%3E"));
@@ -37,7 +46,7 @@
37 46
 
38 47
 </head>
39 48
 
40  
-<body>
  49
+<body onload='CheckMathJax();'>
41 50
 
42 51
 <div id="header">
43 52
     <span id="ipython_notebook"><h1>IPython Notebook</h1></span>
@@ -49,6 +58,24 @@
49 58
     <span id="kernel_status">Idle</span>
50 59
 </div>
51 60
 
  61
+<div id="MathJaxFetchingWarning" style="width:80%;margin:auto;padding-top:20%;text-align:justify;display:none">
  62
+    <p style="font-size:26px;">There was an issues trying to fetch MathJax.js from the internet.</p>
  63
+    <p>You may want to consider running the following in order to be able to use the Notebook.
  64
+        <pre style="background-color:lightblue;border:thin silver solid">
  65
+            from IPython.external import mathjax; mathjax.install_mathjax()
  66
+        </pre>
  67
+        Note that this will require a working internet connection when run, and
  68
+        it will try to install MathJax into the directory where you installed
  69
+        IPython. If you installed IPython to a location that requires
  70
+        administrative privileges to write, you will need to make this call as
  71
+        an administrator. On OSX/Linux/Unix, this can be done at the
  72
+        command-line via:
  73
+        <pre style="background-color:lightblue;border:thin silver solid">
  74
+            sudo python -c "from IPython.external import mathjax; mathjax.install_mathjax()"
  75
+        </pre>
  76
+    </p>
  77
+</div>
  78
+
52 79
 <div id="main_app">
53 80
 
54 81
     <div id="left_panel">
Commit_comment_tip

Tip: You can add notes to lines in a file. Hover to the left of a line to make a note

Something went wrong with that request. Please try again.