Ticket #4714: trac_4714-sagenb_jsmath_init.patch

File trac_4714-sagenb_jsmath_init.patch, 38.1 KB (added by mpatel, 11 years ago)

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

  • sagenb/data/sage/html/notebook/afterpublish_window.html

    # HG changeset patch
    # User Mitesh Patel <qed777@gmail.com>
    # Date 1256280905 25200
    # Node ID 0e4384bed657402af4f3ef530b261903a5311b71
    # Parent  26723c6583858134ddeb44512d6b5cf885c0e692
    #4714/sagenb: Put jsMath init and customizations (macros, etc.) in jsmath.js
    
    diff --git a/sagenb/data/sage/html/notebook/afterpublish_window.html b/sagenb/data/sage/html/notebook/afterpublish_window.html
    a b INPUT: 
    77- url - a string containing the url of the published page
    88- time - a string representing the time of publication
    99- JSMATH - a boolean stating whether to include jsMath
    10 - JSMATH_IMAGE_FONTS - a boolean stating whether to include jsMath iamage fonts
    1110- JEDITABLE_TINYMCE - a boolean stating whether to include jEditable and TinyMCE
    12 - sage_jsmath_macros - an array containing strings of Javascript of Sage macros for jsMath
    1311#}
    1412
    1513{% set checked = 'checked="true"' if worksheet.is_auto_publish() else '' %}
  • sagenb/data/sage/html/notebook/beforepublish_window.html

    diff --git a/sagenb/data/sage/html/notebook/beforepublish_window.html b/sagenb/data/sage/html/notebook/beforepublish_window.html
    a b INPUT: 
    55- worksheet_filename - a string containing a worksheet's filename
    66- username - a string containing a username
    77- JSMATH - a boolean stating whether to include jsMath
    8 - JSMATH_IMAGE_FONTS - a boolean stating whether to include jsMath iamage fonts
    98- JEDITABLE_TINYMCE - a boolean stating whether to include jEditable and TinyMCE
    10 - sage_jsmath_macros - an array containing strings of Javascript of Sage macros for jsMath
    119#}
    1210
    1311{% set title = '<p>You can publish your worksheet to the Internet, where anyone will be able to access and view it online.</p><p>Your worksheet will be assigned a unique address (URL) that you can send to your friends and colleagues.</p><p>Do you want to publish this worksheet?</p><form method="get" action="."><input type="hidden" name="yes" value="" /><input type="submit" value="Yes" style="margin-left:10px" /><input type="button" value="No" style="margin-left:5px" onClick="parent.location=\'../\'"><br/><br/><input type="checkbox" name="auto" style="margin-left:13px" /> Automatically re-publish when changes are made</form>' %}
  • sagenb/data/sage/html/notebook/doc.html

    diff --git a/sagenb/data/sage/html/notebook/doc.html b/sagenb/data/sage/html/notebook/doc.html
    a b INPUT: 
    55- worksheet_filename - a string containing a worksheet's filename
    66- username - a string containing a username
    77- JSMATH - a boolean stating whether to include jsMath
    8 - JSMATH_IMAGE_FONTS - a boolean stating whether to include jsMath iamage fonts
    98- JEDITABLE_TINYMCE - a boolean stating whether to include jEditable and TinyMCE
    10 - sage_jsmath_macros - an array containing strings of Javascript of Sage macros for jsMath
    119#}
    1210
    1311{% include "html/notebook/head.tmpl" %}
    INPUT: 
    1816   
    1917{% block css %}main{% endblock %}
    2018
    21 {% block morecss %}<style type="text/css" rel="stylesheet" href="_static/default.css" media="screen" />{% endblock %}
     19{% block morecss %}
     20<style type="text/css" rel="stylesheet" href="_static/default.css" media="screen" />
     21{% endblock %}
    2222
    2323{% block javascript %}
    24 {{ common_javascript(worksheet, worksheet_filename, username, JSMATH, JSMATH_IMAGE_FONTS, JEDITABLE_TINYMCE, sage_jsmath_macros) }}
     24{{ common_javascript(worksheet, worksheet_filename, username, JSMATH, JEDITABLE_TINYMCE) }}
    2525{% endblock %}
    2626
    2727{% block body %}
  • sagenb/data/sage/html/notebook/download_or_delete_datafile.html

    diff --git a/sagenb/data/sage/html/notebook/download_or_delete_datafile.html b/sagenb/data/sage/html/notebook/download_or_delete_datafile.html
    a b INPUT: 
    1111- file_is_text - a boolean stating whether the file is a text file
    1212- text_file_content - a string containing the content of a text file
    1313- JSMATH - a boolean stating whether to include jsMath
    14 - JSMATH_IMAGE_FONTS - a boolean stating whether to include jsMath iamage fonts
    1514- JEDITABLE_TINYMCE - a boolean stating whether to include jEditable and TinyMCE
    16 - sage_jsmath_macros - an array containing strings of Javascript of Sage macros for jsMath
    1715#}
    1816{% set title = "Data file: %s"|format(filename_) %}
    1917
  • sagenb/data/sage/html/notebook/edit_window.html

    diff --git a/sagenb/data/sage/html/notebook/edit_window.html b/sagenb/data/sage/html/notebook/edit_window.html
    a b INPUT: 
    77- text - a string containing the text of the worksheet
    88- n_lines - number of lines of the text of the worksheet
    99- JSMATH - a boolean stating whether to include jsMath
    10 - JSMATH_IMAGE_FONTS - a boolean stating whether to include jsMath iamage fonts
    1110- JEDITABLE_TINYMCE - a boolean stating whether to include jEditable and TinyMCE
    12 - sage_jsmath_macros - an array containing strings of Javascript of Sage macros for jsMath
    1311#}
    1412
    1513{% set title = 'Edit plain text &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type="submit" value="Save Changes" name="button_save" id="button_save"> <input type="submit" value="Cancel" name="button_cancel">' %}
  • sagenb/data/sage/html/notebook/head.tmpl

    diff --git a/sagenb/data/sage/html/notebook/head.tmpl b/sagenb/data/sage/html/notebook/head.tmpl
    a b INPUT: 
    44- worksheet_filename - a string containing a worksheet's filename
    55- username - a string containing a user's name
    66- JSMATH - a boolean stating whether to include jsMath
    7 - JSMATH_IMAGE_FONTS - a boolean stating whether to include jsMath iamage fonts
    87- JEDITABLE_TINYMCE - a boolean stating whether to include jEditable and TinyMCE
    9 - sage_jsmath_macros - an array containing strings of Javascript of Sage macros for jsMath
    108  #}
    119{% macro common_title(worksheet_filename, worksheet) %}
    1210    {% if worksheet_filename %}
    INPUT: 
    1614    {% endif %}
    1715{% endmacro %}
    1816
    19 
    2017{% macro common_css %}
    2118<!-- Sage notebook stylesheet -->
    2219<link rel=stylesheet href="/css/main.css" type="text/css" />
    2320{% endmacro %}
    2421
    25 {% macro common_javascript(worksheet, worksheet_filename, username, JSMATH, JSMATH_IMAGE_FONTS, JEDITABLE_TINYMCE, sage_jsmath_macros) %}
     22{% macro common_javascript(worksheet, worksheet_filename, username, JSMATH, JEDITABLE_TINYMCE) %}
     23
    2624<!-- jQuery - general-purpose functions -->
    2725<script type="text/javascript" src="/javascript/jquery/jquery-1.3.2.min.js"></script>
    2826<!-- Sage Notebook library -->
    INPUT: 
    3028 
    3129{% if JSMATH %}
    3230<!-- jsMath - typeset mathematics -->
    33     <!-- Turn off font warning. -->
    34     <style>
    35         #jsMath_Warning {display: none}
    36     </style>
    37     <script type="text/javascript">
    38         jsMath = {Controls: {cookie: {scale: 115}}}
    39     </script>
    40     {% if not JSMATH_IMAGE_FONTS %}
    41         <script type="text/javascript" src="/javascript/jsmath/plugins/noImageFonts.js"></script>
    42     {% endif %}
    43     <!-- Move the jsMath button 20 pixels from the right edge
    44          (apparently in some browsers, it covers up the scroll
    45          bar) -->
    46     <script type="text/javascript">
    47         jsMath.styles = {
    48             '#jsMath_button':
    49                 'position:fixed; bottom:1px; right:20px; background-color:white;'
    50                     + 'border: solid 1px #959595; margin:0px; padding: 0px 3px 1px 3px; '
    51                     + 'z-index:102; color:black; text-decoration:none; font-size:x-small; '
    52                     + 'width:auto; cursor:hand;',
    53         };
    54     </script>
    55     <script type="text/javascript" src="/javascript/jsmath/jsMath.js"></script>
    56     <script type="text/javascript">
    57         /* The extensions here do the following:
    58             - verb implements the \verb command:
    59               see http://www.math.union.edu/~dpvc/jsMath/authors/verb.html
    60             - moreArrows implements \xrightarrow, among other things:
    61               see http://www.math.union.edu/~dpvc/jsMath/authors//moreArrows.html
    62             - AMSmath implements a number of AMS math commands:
    63               see http://www.math.union.edu/~dpvc/jsMath/authors/AMSmath.html
    64         */
    65         jsMath.Extension.Require("verb");
    66         jsMath.Extension.Require("moreArrows");
    67         jsMath.Extension.Require("AMSmath");
    68         jsMath.Extension.Require("AMSsymbols");
    69     </script>
    70 
    71     {% for m in sage_jsmath_macros %}
    72     <script> {{ m }} </script>
    73     {% endfor %}
     31<script type="text/javascript" src="/javascript/jsmath.js"></script>
    7432{% endif %}
    7533
    7634<!-- jQuery UI - interacts, widgets, drag-drop, etc. -->
    INPUT: 
    8745
    8846<!-- Jmol - embedded 3D graphics -->
    8947<script type="text/javascript" src="/java/jmol/appletweb/Jmol.js"></script>
    90 <!-- This must stay in <head> -->
     48<!-- This must stay in head -->
    9149<script>jmolInitialize("/java/jmol");jmolSetCallback("menuFile","/java/jmol/appletweb/SageMenu.mnu");</script>
    9250
    9351{% if JEDITABLE_TINYMCE and not worksheet.docbrowser() and not worksheet.is_published() %}
    9452<!-- TinyMCE and jEditable - in-place editing of text cells -->
    95     <script type="text/javascript" src="/javascript/tiny_mce/tiny_mce.js"></script>
    96     <script type="text/javascript" src="/javascript/jquery/plugins/jeditable/jquery.jeditable.mini.js" charset="utf-8"></script>
    97     <script type="text/javascript" src="/javascript/sage/js/tinymce.js"></script>
     53<script type="text/javascript" src="/javascript/tiny_mce/tiny_mce.js"></script>
     54<script type="text/javascript" src="/javascript/jquery/plugins/jeditable/jquery.jeditable.mini.js" charset="utf-8"></script>
     55<script type="text/javascript" src="/javascript/sage/js/tinymce.js"></script>
    9856{% endif %}
    9957
    10058<script type="text/javascript">user_name= "{{ username }}";</script>
    10159{% if worksheet_filename %}
    10260<script  type="text/javascript">
    103     worksheet_filename="{{ worksheet_filename }}";
    104     worksheet_name="{{ worksheet.name() }}";
    105     server_ping_while_alive();
     61  worksheet_filename="{{ worksheet_filename }}";
     62  worksheet_name="{{ worksheet.name() }}";
     63  server_ping_while_alive();
    10664</script>
    10765{% endif %}
    10866
  • sagenb/data/sage/html/notebook/index.html

    diff --git a/sagenb/data/sage/html/notebook/index.html b/sagenb/data/sage/html/notebook/index.html
    a b INPUT: 
    88- username - a string containing a username
    99- show_debug - a boolean stating whether to show debug information
    1010- JSMATH - a boolean stating whether to include jsMath
    11 - JSMATH_IMAGE_FONTS - a boolean stating whether to include jsMath iamage fonts
    1211- JEDITABLE_TINYMCE - a boolean stating whether to include jEditable and TinyMCE
    13 - sage_jsmath_macros - an array containing strings of Javascript of Sage macros for jsMath
    1412#}
    1513
    1614{% if not select %}
    INPUT: 
    3028{% block css %}main{% endblock %}
    3129
    3230{% block javascript %}
    33 {{ common_javascript(worksheet, worksheet_filename, username, JSMATH, JSMATH_IMAGE_FONTS, JEDITABLE_TINYMCE, sage_jsmath_macros) }}
     31{{ common_javascript(worksheet, worksheet_filename, username, JSMATH, JEDITABLE_TINYMCE) }}
    3432{% endblock %}
    3533
    3634{% block body_attrs %}
  • sagenb/data/sage/html/notebook/plain_text_window.html

    diff --git a/sagenb/data/sage/html/notebook/plain_text_window.html b/sagenb/data/sage/html/notebook/plain_text_window.html
    a b INPUT: 
    66- username - a string containing a username
    77- plain_text - a string containing the plain text version
    88- JSMATH - a boolean stating whether to include jsMath
    9 - JSMATH_IMAGE_FONTS - a boolean stating whether to include jsMath iamage fonts
    109- JEDITABLE_TINYMCE - a boolean stating whether to include jEditable and TinyMCE
    11 - sage_jsmath_macros - an array containing strings of Javascript of Sage macros for jsMath
    1210#}
    1311
    1412{% set title = "View plain text" %}
  • sagenb/data/sage/html/notebook/specific_revision.html

    diff --git a/sagenb/data/sage/html/notebook/specific_revision.html b/sagenb/data/sage/html/notebook/specific_revision.html
    a b INPUT: 
    1010- time_ago - a string containing the time since revision
    1111- body_worksheet_html - the body html of the worksheet
    1212- JSMATH - a boolean stating whether to include jsMath
    13 - JSMATH_IMAGE_FONTS - a boolean stating whether to include jsMath iamage fonts
    1413- JEDITABLE_TINYMCE - a boolean stating whether to include jEditable and TinyMCE
    15 - sage_jsmath_macros - an array containing strings of Javascript of Sage macros for jsMath
    1614#}
    1715
    1816{% set select = "revisions" %}
  • sagenb/data/sage/html/notebook/upload_data_window.html

    diff --git a/sagenb/data/sage/html/notebook/upload_data_window.html b/sagenb/data/sage/html/notebook/upload_data_window.html
    a b INPUT: 
    55- worksheet_filename - a string containing a worksheet's filename
    66- username - a string containing a username
    77- JSMATH - a boolean stating whether to include jsMath
    8 - JSMATH_IMAGE_FONTS - a boolean stating whether to include jsMath iamage fonts
    98- JEDITABLE_TINYMCE - a boolean stating whether to include jEditable and TinyMCE
    10 - sage_jsmath_macros - an array containing strings of Javascript of Sage macros for jsMath
    119#}
    1210
    1311{% set title = 'Upload or Create Data File' %}
  • sagenb/data/sage/html/notebook/worksheet.html

    diff --git a/sagenb/data/sage/html/notebook/worksheet.html b/sagenb/data/sage/html/notebook/worksheet.html
    a b INPUT: 
    1515<script type="text/javascript" src="/javascript/jquery/jquery-1.3.2.min.js"></script>
    1616<script type="text/javascript" src="/javascript/main.js"></script>
    1717{% if do_print %}
    18     <script type="text/javascript" src="/javascript/jsmath/jsMath.js"></script>
     18    <script type="text/javascript" src="/javascript/jsmath.js"></script>
    1919{% endif %}   
    2020{% endblock %}
    2121
  • sagenb/data/sage/html/notebook/worksheet_page_template.html

    diff --git a/sagenb/data/sage/html/notebook/worksheet_page_template.html b/sagenb/data/sage/html/notebook/worksheet_page_template.html
    a b INPUT: 
    88- select    - a string containing the control that is selected
    99- backwards - a boolean
    1010- JSMATH - a boolean stating whether to include jsMath
    11 - JSMATH_IMAGE_FONTS - a boolean stating whether to include jsMath iamage fonts
    1211- JEDITABLE_TINYMCE - a boolean stating whether to include jEditable and TinyMCE
    13 - sage_jsmath_macros - an array containing strings of Javascript of Sage macros for jsMath
    1412#}
    1513
    1614{% if not select %}
    INPUT: 
    3230{% block css %}main{% endblock %}
    3331
    3432{% block javascript %}
    35 {{ common_javascript(worksheet, worksheet_filename, username, JSMATH, JSMATH_IMAGE_FONTS, JEDITABLE_TINYMCE, sage_jsmath_macros) }}
     33{{ common_javascript(worksheet, worksheet_filename, username, JSMATH, JEDITABLE_TINYMCE) }}
    3634{% endblock %}
    3735
    3836{% block body %}
  • sagenb/data/sage/html/notebook/worksheet_revision_list.html

    diff --git a/sagenb/data/sage/html/notebook/worksheet_revision_list.html b/sagenb/data/sage/html/notebook/worksheet_revision_list.html
    a b INPUT: 
    66- worksheet_filename - a string containing a worksheet's filename
    77- username - a string containing a username
    88- JSMATH - a boolean stating whether to include jsMath
    9 - JSMATH_IMAGE_FONTS - a boolean stating whether to include jsMath iamage fonts
    109- JEDITABLE_TINYMCE - a boolean stating whether to include jEditable and TinyMCE
    11 - sage_jsmath_macros - an array containing strings of Javascript of Sage macros for jsMath
    1210  #}
    1311
    1412
  • sagenb/data/sage/html/notebook/worksheet_settings.html

    diff --git a/sagenb/data/sage/html/notebook/worksheet_settings.html b/sagenb/data/sage/html/notebook/worksheet_settings.html
    a b INPUT: 
    55- worksheet_filename - a string containing a worksheet's filename
    66- username - a string containing a username
    77- JSMATH - a boolean stating whether to include jsMath
    8 - JSMATH_IMAGE_FONTS - a boolean stating whether to include jsMath iamage fonts
    98- JEDITABLE_TINYMCE - a boolean stating whether to include jEditable and TinyMCE
    10 - sage_jsmath_macros - an array containing strings of Javascript of Sage macros for jsMath
    119#}
    1210
    1311{% set title = 'Worksheet Settings &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<button name="button_save">Save Settings</button>  <input type="submit" value="Cancel" name="button_cancel"/>' %}
  • sagenb/data/sage/html/notebook/worksheet_share.html

    diff --git a/sagenb/data/sage/html/notebook/worksheet_share.html b/sagenb/data/sage/html/notebook/worksheet_share.html
    a b INPUT: 
    77    - other_users - a list of strings containing other users names
    88    - user_is_admin - a boolean stating whether the user is an admin
    99    - JSMATH - a boolean stating whether to include jsMath
    10     - JSMATH_IMAGE_FONTS - a boolean stating whether to include jsMath iamage fonts
    1110    - JEDITABLE_TINYMCE - a boolean stating whether to include jEditable and TinyMCE
    12     - sage_jsmath_macros - an array containing strings of Javascript of Sage macros for jsMath
    1311#}
    1412
    1513{% set title = "Share this document" %}
  • new file sagenb/data/sage/js/jsmath.js

    diff --git a/sagenb/data/sage/js/jsmath.js b/sagenb/data/sage/js/jsmath.js
    new file mode 100644
    - +  
     1/**********************************************************************
     2 *
     3 *   Customize the values given below to suit your needs.
     4 *   You can make additional copies of this file with
     5 *   different customizated settings if you need to load
     6 *   jsMath with different parameters.
     7 *
     8 *   Load this page via:
     9 *
     10 *   <SCRIPT SRC="path-to-jsMath/easy/load.js"></SCRIPT>
     11 *
     12 *   (If you are including this file into your page via Server-Side
     13 *   Includes, you should remove line above.)
     14 *
     15 *   You can make copies of this file with different settings
     16 *   if you need to have several different configurations.
     17 *
     18 **********************************************************************/
     19
     20if (!window.jsMath) {window.jsMath = {}}
     21
     22//  Move the jsMath button 20 pixels from the right edge (apparently
     23//  in some browsers, it covers up the scroll bar)
     24jsMath.styles = {
     25    '#jsMath_button' : 'position:fixed; bottom:1px; right:20px; '
     26        + 'background-color:white; border: solid 1px #959595; margin:0px; '
     27        + 'padding: 0px 3px 1px 3px; z-index:102; color:black; '
     28        + 'text-decoration:none; font-size:x-small; width:auto; cursor:hand;'
     29}
     30
     31jsMath.Easy = {
     32    //
     33    //  The URL of the root jsMath directory on your server
     34    //  (it must be in the same domain as the HTML page).
     35    //  It should include "http://yoursite.com/", or should
     36    //  be relative to the root of your server.  It is possible
     37    //  to be a relative URL, but it will be relative to the
     38    //  HTML page loading this file.
     39    //
     40    //  If you leave this blank, jsMath will try to look it up from
     41    //  the URL where it loaded this file, but that may not work.
     42    //
     43    root: "/javascript/jsmath",
     44
     45    //
     46    //  The default scaling factor for mathematics compared to the
     47    //  surrounding text.
     48    //
     49    scale: 115,
     50
     51    //
     52    //  1 means use the autoload plug-in to decide if jsMath should be loaded
     53    //  0 means always load jsMath
     54    //
     55    autoload: 1,
     56
     57    //
     58    //  Setting any of these will cause the tex2math plugin to be used
     59    //  to add the <DIV> and <SPAN> tags that jsMath needs.  See the
     60    //  documentation for the tex2math plugin for more information.
     61    //
     62    processSlashParens: 0,       // process \(...\) in text?
     63    processSlashBrackets: 0,     // process \[...\] in text?
     64    processDoubleDollars: 0,     // process $$...$$ in text?
     65    processSingleDollars: 0,     // process $...$ in text?
     66    processLaTeXenvironments: 0, // process \begin{xxx}...\end{xxx} outside math mode?
     67    fixEscapedDollars: 0,        // convert \$ to $ outside of math mode?
     68    doubleDollarsAreInLine: 0,   // make $$...$$ be in-line math?
     69    allowDisableTag: 0,          // allow ID="tex2math_off" to disable tex2math?
     70    //
     71    //  If you want to use your own custom delimiters for math instead
     72    //  of the usual ones, then uncomment the following four lines and
     73    //  insert your own delimiters within the quotes.  You may want to
     74    //  turn off processing of the dollars and other delimiters above
     75    //  as well, though you can use them in combination with the
     76    //  custom delimiters if you wish.  See the tex2math documentation
     77    //  for more details.
     78    //
     79    //customDelimiters: [
     80    //  '[math]','[/math]',        // to begin and end in-line math
     81    //  '[display]','[/display]'   // to begin and end display math
     82    //],
     83
     84    //
     85    //  Disallow the use of the @(...) mechanism for including raw HTML
     86    //  in the contents of \hbox{}?  (If used in a content-management system
     87    //  where users are allowed to enter mathematics, setting this to 0
     88    //  would allow them to enter arbitrary HTML code within their
     89    //  math formulas, and that poses a security risk.)
     90    //
     91    safeHBoxes: 1,
     92
     93    //
     94    //  Show TeX source when mathematics is double-clicked?
     95    //
     96    allowDoubleClicks: 1,
     97
     98    //
     99    //  Show jsMath font warning messages?  (Disabling this prevents yours
     100    //  users from finding out that they can have a better experience on your
     101    //  site by installing some fonts, so don't disable this).
     102    //
     103    showFontWarnings: 0,
     104
     105    //
     106    //  Use "Process" or "ProcessBeforeShowing".  See the jsMath
     107    //  author's documentation for the difference between these
     108    //  two routines.
     109    //
     110    method: "Process",
     111
     112    //
     113    //  List of plug-ins and extensions that you want to be
     114    //  loaded automatically.  E.g.
     115    //      ["plugins/mimeTeX.js","extensions/AMSsymbols.js"]
     116    //
     117    // See http://www.math.union.edu/~dpvc/jsMath/authors/
     118    //
     119    loadFiles: [
     120        "extensions/verb.js",
     121        "extensions/moreArrows.js",
     122        "extensions/AMSmath.js",
     123        "extensions/AMSsymbols.js"
     124    ],
     125
     126    //
     127    //  List of fonts to load automatically.  E.g.
     128    //      ["cmmib10"]
     129    //
     130    loadFonts: [],
     131
     132    //
     133    //  List of macros to define.  These are of the form
     134    //      name: value
     135    //  where 'value' is the replacement text for the macro \name.
     136    //  The 'value' can also be [value,n] where 'value' is the replacement
     137    //  text and 'n' is the number of parameters for the macro.
     138    //  Note that backslashes must be doubled in the replacement string.
     139    //  E.g.,
     140    //      {
     141    //        RR: '{\\bf R}',
     142    //        bold: ['{\\bf #1}', 1]
     143    //      }
     144    //
     145    // Sage-specific jsMath macros.
     146    macros: {
     147        {{ jsmath_macros }}
     148    },
     149
     150    //
     151    //  Allow jsMath to enter global mode?
     152    //  (Uses frames, so may not always work with complex web sites)
     153    //
     154    allowGlobal: 1,
     155
     156    //
     157    //  Disable image fonts?  (In case you don't load them on your server.)
     158    //
     159    // If we set this to 1, we do not need to load plugins/noImageFonts.js
     160    {% if jsmath_image_fonts %}
     161    noImageFonts: 0
     162    {% else %}
     163    noImageFonts: 1
     164    {% endif %}
     165};
     166
     167/****************************************************************/
     168/****************************************************************/
     169//
     170//            DO NOT MAKE CHANGES BELOW THIS
     171//
     172/****************************************************************/
     173/****************************************************************/
     174
     175if (jsMath.Easy.root == "") {
     176  jsMath.Easy.root = document.getElementsByTagName("script");
     177  jsMath.Easy.root = jsMath.Easy.root[jsMath.Easy.root.length-1].src
     178  if (jsMath.Easy.root.match(/\/easy\/[^\/]*$/)) {
     179    jsMath.Easy.root = jsMath.Easy.root.replace(/\/easy\/[^\/]*$/,"");
     180  } else {
     181    jsMath.Easy.root = jsMath.Easy.root.replace(/\/(jsMath\/(easy\/)?)?[^\/]*$/,"/jsMath");
     182  }
     183}
     184jsMath.Easy.root = jsMath.Easy.root.replace(/\/$/,""); // trim trailing "/" if any
     185
     186document.write('<SCRIPT SRC="'+jsMath.Easy.root+'/jsMath-easy-load.js"><'+'/SCRIPT>');
  • sagenb/misc/misc.py

    diff --git a/sagenb/misc/misc.py b/sagenb/misc/misc.py
    a b try: 
    176176except ImportError:
    177177    SAGE_DOC = "stub"
    178178   
     179# TODO: Get macros from server and user settings.
    179180try:
    180     import sage.all
    181     from sage.misc.latex_macros import sage_jsmath_macros
     181    from sage.misc.latex_macros import sage_jsmath_macros_easy
    182182except ImportError:
    183     sage_jsmath_macros = []
     183    sage_jsmath_macros_easy = [
     184        "ZZ : '{\\\\Bold{Z}}'",
     185        "RR : '{\\\\Bold{R}}'",
     186        "CC : '{\\\\Bold{C}}'",
     187        "QQ : '{\\\\Bold{Q}}'",
     188        "QQbar : '{\\\\overline{\\\\QQ}}'",
     189        "GF : ['{\\\\Bold{F}_{#1}}', 1]",
     190        "Zp : ['{\\\\ZZ_{#1}}', 1]",
     191        "Qp : ['{\\\\QQ_{#1}}', 1]",
     192        "Zmod : ['{\\\\ZZ/#1\\\\ZZ}', 1]",
     193        "CIF : '{\\\\Bold{C}}'",
     194        "CLF : '{\\\\Bold{C}}'",
     195        "RDF : '{\\\\Bold{R}}'",
     196        "RIF : '{\\\\Bold{I} \\\\Bold{R}}'",
     197        "RLF : '{\\\\Bold{R}}'",
     198        "CFF : '{\\\\Bold{CFF}}'",
     199        "Bold : ['{\\\\mathbf{#1}}', 1]"
     200        ]
     201finally:
     202    jsmath_macros = ',\n'.join(sage_jsmath_macros_easy)
    184203
    185204try:
    186205    from sage.misc.session import init as session_init
    except ImportError: 
    189208    def session_init(*args, **kwds):
    190209        pass
    191210   
    192 
    193211try:
    194212    from sage.misc.sage_eval import sage_eval
    195213except ImportError:
    except ImportError: 
    199217        return eval(value, globs)
    200218
    201219try:
    202     from sage.misc.all import is_package_installed
     220    from sage.misc.package import is_package_installed
    203221except ImportError:
    204222    def is_package_installed(name, *args, **kwds):
    205223        return False
    206224
    207 
    208225try:
    209226    from sage.misc.viewer import browser
    210227except ImportError:
    except ImportError: 
    223240        s = cPickle.dumps(obj, protocol=2)
    224241        open(filename,'wb').write(s)
    225242
    226 
    227243try:
    228244    from sage.misc.misc import alarm, cancel_alarm, verbose
    229245except ImportError:
    except ImportError: 
    296312    SAGE_VERSION=""
    297313
    298314try:
    299     from sage.plot.all import Color
     315    from sage.plot.colors import Color
    300316except ImportError:
    301317    class Color:
    302318        def __init__(self, *args, **kwds):
  • sagenb/notebook/notebook.py

    diff --git a/sagenb/notebook/notebook.py b/sagenb/notebook/notebook.py
    a b from cgi import escape 
    3131
    3232
    3333# Sage libraries
    34 from   sagenb.misc.misc   import (pad_zeros, is_package_installed,
    35                              sage_jsmath_macros, cputime, tmp_dir, load, save)
     34from sagenb.misc.misc import (pad_zeros, cputime, tmp_dir, load, save)
    3635
    3736# Sage Notebook
    3837import css          # style
    SYSTEM_NAMES = [v.split()[0] for v in SY 
    6160
    6261JSMATH = True
    6362
    64 JSMATH_IMAGE_FONTS = is_package_installed("jsmath-image-fonts")
    65 
    6663JEDITABLE_TINYMCE  = True
    6764
    6865DOC_TIMEOUT = 120
    class Notebook(object): 
    13451342        data = worksheet.snapshot_data()  # pairs ('how long ago', key)
    13461343
    13471344        return template(os.path.join("html", "notebook", "worksheet_revision_list.html"),
    1348                         data = data,
    1349                         worksheet = worksheet,
     1345                        data = data, worksheet = worksheet,
    13501346                        worksheet_filename = worksheet.filename(),
    1351                         username = username,
    1352                         JSMATH = JSMATH,
    1353                         JSMATH_IMAGE_FONTS = JSMATH_IMAGE_FONTS,
    1354                         JEDITABLE_TINYMCE = JEDITABLE_TINYMCE,
    1355                         sage_jsmath_macros = sage_jsmath_macros)
     1347                        username = username, JSMATH = JSMATH,
     1348                        JEDITABLE_TINYMCE = JEDITABLE_TINYMCE)
    13561349
    13571350
    13581351    def html_specific_revision(self, username, ws, rev):
    class Notebook(object): 
    13931386                break
    13941387           
    13951388        return template(os.path.join("html", "notebook", "specific_revision.html"),
    1396                         worksheet = ws,
    1397                         worksheet_filename = ws.filename(),
    1398                         username = username, rev = rev,
    1399                         prev_rev = prev_rev, next_rev = next_rev,
    1400                         time_ago = time_ago,
     1389                        worksheet = ws, worksheet_filename = ws.filename(),
     1390                        username = username, rev = rev, prev_rev = prev_rev,
     1391                        next_rev = next_rev, time_ago = time_ago,
    14011392                        body_worksheet_html = body_worksheet_html,
    1402                         JSMATH = JSMATH,
    1403                         JSMATH_IMAGE_FONTS = JSMATH_IMAGE_FONTS,
    1404                         JEDITABLE_TINYMCE = JEDITABLE_TINYMCE,
    1405                         sage_jsmath_macros = sage_jsmath_macros)
    1406        
     1393                        JSMATH = JSMATH, JEDITABLE_TINYMCE = JEDITABLE_TINYMCE)
    14071394
    14081395    def html_share(self, worksheet, username):
    14091396        r"""
    class Notebook(object): 
    14351422                        worksheet_filename = worksheet.filename(),
    14361423                        username = username, other_users = other_users,
    14371424                        user_is_admin = self.user(username).is_admin(),
    1438                         JSMATH = JSMATH,
    1439                         JSMATH_IMAGE_FONTS = JSMATH_IMAGE_FONTS,
    1440                         JEDITABLE_TINYMCE = JEDITABLE_TINYMCE,
    1441                         sage_jsmath_macros = sage_jsmath_macros)
    1442 
     1425                        JSMATH = JSMATH, JEDITABLE_TINYMCE = JEDITABLE_TINYMCE)
    14431426
    14441427    def html_download_or_delete_datafile(self, ws, username, filename):
    14451428        r"""
    class Notebook(object): 
    14811464            text_file_content = open(os.path.join(ws.data_directory(), filename)).read()
    14821465
    14831466        return template(os.path.join("html", "notebook", "download_or_delete_datafile.html"),
    1484                         worksheet = ws,
    1485                         worksheet_filename = ws.filename(),
     1467                        worksheet = ws, worksheet_filename = ws.filename(),
    14861468                        username = username,
    14871469                        active_worksheets = active_worksheets,
    1488                         filename_ = filename,
    1489                         path = path,
     1470                        filename_ = filename, path = path,
    14901471                        file_is_image = file_is_image,
    14911472                        file_is_text = file_is_text,
    14921473                        text_file_content = text_file_content,
    1493                         JSMATH = JSMATH,
    1494                         JSMATH_IMAGE_FONTS = JSMATH_IMAGE_FONTS,
    1495                         JEDITABLE_TINYMCE = JEDITABLE_TINYMCE,
    1496                         sage_jsmath_macros = sage_jsmath_macros)
    1497 
    1498 
     1474                        JSMATH = JSMATH, JEDITABLE_TINYMCE = JEDITABLE_TINYMCE)
    14991475
    15001476
    15011477    ##########################################################
    class Notebook(object): 
    16251601        return template(os.path.join("html", "notebook", "plain_text_window.html"),
    16261602                        worksheet = worksheet,
    16271603                        worksheet_filename = worksheet.filename(),
    1628                         username = username,
    1629                         plain_text = plain_text, JSMATH = JSMATH,
    1630                         JSMATH_IMAGE_FONTS = JSMATH_IMAGE_FONTS,
    1631                         JEDITABLE_TINYMCE = JEDITABLE_TINYMCE,
    1632                         sage_jsmath_macros = sage_jsmath_macros)
     1604                        username = username, plain_text = plain_text,
     1605                        JSMATH = JSMATH, JEDITABLE_TINYMCE = JEDITABLE_TINYMCE)
    16331606                       
    16341607    def html_edit_window(self, worksheet, username):
    16351608        r"""
    class Notebook(object): 
    16591632        return template(os.path.join("html", "notebook", "edit_window.html"),
    16601633                        worksheet = worksheet,
    16611634                        worksheet_filename = worksheet.filename(),
    1662                         username = username, text = text,
    1663                         n_lines = n_lines, JSMATH = JSMATH,
    1664                         JSMATH_IMAGE_FONTS = JSMATH_IMAGE_FONTS,
    1665                         JEDITABLE_TINYMCE = JEDITABLE_TINYMCE,
    1666                         sage_jsmath_macros = sage_jsmath_macros)
     1635                        username = username, text = text, n_lines = n_lines,
     1636                        JSMATH = JSMATH, JEDITABLE_TINYMCE = JEDITABLE_TINYMCE)
    16671637   
    16681638    def html_beforepublish_window(self, worksheet, username):
    16691639        r"""
    class Notebook(object): 
    17001670        return template(os.path.join("html", "notebook", "beforepublish_window.html"),
    17011671                        worksheet = worksheet,
    17021672                        worksheet_filename = worksheet.filename(),
    1703                         username = username, JSMATH = JSMATH,
    1704                         JSMATH_IMAGE_FONTS = JSMATH_IMAGE_FONTS,
    1705                         JEDITABLE_TINYMCE = JEDITABLE_TINYMCE,
    1706                         sage_jsmath_macros = sage_jsmath_macros)
     1673                        username = username,
     1674                        JSMATH = JSMATH, JEDITABLE_TINYMCE = JEDITABLE_TINYMCE)
    17071675       
    17081676    def html_afterpublish_window(self, worksheet, username, url, dtime):
    17091677        r"""
    class Notebook(object): 
    17321700        return template(os.path.join("html", "notebook", "afterpublish_window.html"),
    17331701                        worksheet = worksheet,
    17341702                        worksheet_filename = worksheet.filename(),
    1735                         username = username, url = url,
    1736                         time = time, JSMATH = JSMATH,
    1737                         JSMATH_IMAGE_FONTS = JSMATH_IMAGE_FONTS,
    1738                         JEDITABLE_TINYMCE = JEDITABLE_TINYMCE,
    1739                         sage_jsmath_macros = sage_jsmath_macros)
     1703                        username = username, url = url, time = time,
     1704                        JSMATH = JSMATH, JEDITABLE_TINYMCE = JEDITABLE_TINYMCE)
    17401705
    17411706    def html_upload_data_window(self, ws, username):
    17421707        r"""
    class Notebook(object): 
    17601725            '\n<!D...orksheet_menu" value="Upload File" onClick="form.submit()...r />\n</div>\n\n\n    </body>\n</html>'
    17611726        """
    17621727        return template(os.path.join("html", "notebook", "upload_data_window.html"),
    1763                         worksheet = ws,
    1764                         worksheet_filename = ws.filename(),
    1765                         username = username, JSMATH = JSMATH,
    1766                         JSMATH_IMAGE_FONTS = JSMATH_IMAGE_FONTS,
    1767                         JEDITABLE_TINYMCE = JEDITABLE_TINYMCE,
    1768                         sage_jsmath_macros = sage_jsmath_macros)
    1769    
     1728                        worksheet = ws, worksheet_filename = ws.filename(),
     1729                        username = username,
     1730                        JSMATH = JSMATH, JEDITABLE_TINYMCE = JEDITABLE_TINYMCE)
    17701731
    17711732    def html(self, worksheet_filename=None, username='guest', show_debug=False, admin=False):
    17721733        r"""
    class Notebook(object): 
    18081769           
    18091770        return template(template_page, worksheet = W,
    18101771                        worksheet_filename = W.filename(),
    1811                         worksheet_html = W.html(),
    1812                         notebook = self, username = username,
    1813                         show_debug = show_debug,
    1814                         JSMATH = JSMATH,
    1815                         JSMATH_IMAGE_FONTS = JSMATH_IMAGE_FONTS,
    1816                         JEDITABLE_TINYMCE = JEDITABLE_TINYMCE,
    1817                         sage_jsmath_macros = sage_jsmath_macros)
    1818 
     1772                        worksheet_html = W.html(), notebook = self,
     1773                        username = username, show_debug = show_debug,
     1774                        JSMATH = JSMATH, JEDITABLE_TINYMCE = JEDITABLE_TINYMCE)
    18191775
    18201776    def html_doc(self, username):
    18211777        r"""
    class Notebook(object): 
    18371793            '\n<!D...c Documentation</a><br /><br />\n        <a href="/help/">Sage Notebook Howto...   </body>\n</html>'
    18381794        """
    18391795        return template(os.path.join("html", "notebook", "doc.html"),
    1840                         username = username, JSMATH = JSMATH,
    1841                         JSMATH_IMAGE_FONTS = JSMATH_IMAGE_FONTS,
    1842                         JEDITABLE_TINYMCE = JEDITABLE_TINYMCE,
    1843                         sage_jsmath_macros = sage_jsmath_macros)
     1796                        username = username,
     1797                        JSMATH = JSMATH, JEDITABLE_TINYMCE = JEDITABLE_TINYMCE)
    18441798       
    18451799
    18461800####################################################################
  • sagenb/notebook/twist.py

    diff --git a/sagenb/notebook/twist.py b/sagenb/notebook/twist.py
    a b from sagenb.notebook.template import tem 
    5151HISTORY_MAX_OUTPUT = 92*5
    5252HISTORY_NCOLS = 90
    5353
    54 from sagenb.misc.misc import SAGE_DOC, walltime, tmp_filename, tmp_dir, DATA, SAGE_VERSION
     54from sagenb.misc.misc import (SAGE_DOC, DATA, SAGE_VERSION, walltime,
     55                              tmp_filename, tmp_dir, is_package_installed,
     56                              jsmath_macros)
    5557
    5658css_path        = os.path.join(DATA, "sage", "css")
    5759image_path      = os.path.join(DATA, "sage", "images")
    5860javascript_path = os.path.join(DATA)
    5961java_path       = os.path.join(DATA)
    6062
     63jsmath_image_fonts = is_package_installed("jsmath-image-fonts")
     64
    6165# the list of users waiting to register
    6266waiting = {}
    6367
    setattr(CSS, 'child_reset.css', Reset_cs 
    17651769# Javascript resources
    17661770############################
    17671771
     1772class JSMath_js(resource.Resource):
     1773    def render(self, ctx):
     1774        gzip_handler(ctx)
     1775
     1776        s = template(os.path.join('js', 'jsmath.js'),
     1777                     jsmath_macros = jsmath_macros,
     1778                     jsmath_image_fonts = jsmath_image_fonts)
     1779
     1780        return http.Response(stream=s)
     1781
    17681782class Main_js(resource.Resource):
    17691783    def render(self, ctx):
    17701784        gzip_handler(ctx)
    17711785        s = js.javascript()
    17721786        return http.Response(stream=s)
    17731787
    1774 
    17751788class Keyboard_js_specific(resource.Resource):
    17761789    def __init__(self, browser_os):
    17771790        self.s = keyboards.get_keyboard(browser_os)
    class Keyboard_js_specific(resource.Reso 
    17801793        gzip_handler(ctx)
    17811794        return http.Response(stream = self.s)
    17821795
    1783 
    17841796class Keyboard_js(resource.Resource):
    17851797    def childFactory(self, request, browser_os):
    17861798        gzip_handler(request)
    class Javascript(resource.Resource): 
    17991811        return static.File(path)
    18001812
    18011813setattr(Javascript, 'child_main.js', Main_js())
    1802 
     1814setattr(Javascript, 'child_jsmath.js', JSMath_js())
    18031815
    18041816
    18051817############################