Ticket #4714: trac_4714-sagenb_jsmath_init_v3.patch

File trac_4714-sagenb_jsmath_init_v3.patch, 38.6 KB (added by mpatel, 11 years ago)

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

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

    # HG changeset patch
    # User Mitesh Patel <qed777@gmail.com>
    # Date 1256280905 25200
    # Node ID 942a10372859042eeb0361e49fc2f689ab73fa17
    # Parent  5196c5888599dca1145c2f5737591941f633c24a
    #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
    INPUT: 
    4240 
    4341{% if JSMATH %}
    4442<!-- jsMath - typeset mathematics -->
    45     <!-- Turn off font warning. -->
    46     <style>
    47         #jsMath_Warning {display: none}
    48     </style>
    49     <script type="text/javascript">
    50         jsMath = {Controls: {cookie: {scale: 115}}}
    51     </script>
    52     {% if not JSMATH_IMAGE_FONTS %}
    53         <script type="text/javascript" src="/javascript/jsmath/plugins/noImageFonts.js"></script>
    54     {% endif %}
    55     <!-- Move the jsMath button 20 pixels from the right edge
    56          (apparently in some browsers, it covers up the scroll
    57          bar) -->
    58     <script type="text/javascript">
    59         jsMath.styles = {
    60             '#jsMath_button':
    61                 'position:fixed; bottom:1px; right:20px; background-color:white;'
    62                     + 'border: solid 1px #959595; margin:0px; padding: 0px 3px 1px 3px; '
    63                     + 'z-index:102; color:black; text-decoration:none; font-size:x-small; '
    64                     + 'width:auto; cursor:hand;',
    65         };
    66     </script>
    67     <script type="text/javascript" src="/javascript/jsmath/jsMath.js"></script>
    68     <script type="text/javascript">
    69         /* The extensions here do the following:
    70             - verb implements the \verb command:
    71               see http://www.math.union.edu/~dpvc/jsMath/authors/verb.html
    72             - moreArrows implements \xrightarrow, among other things:
    73               see http://www.math.union.edu/~dpvc/jsMath/authors//moreArrows.html
    74             - AMSmath implements a number of AMS math commands:
    75               see http://www.math.union.edu/~dpvc/jsMath/authors/AMSmath.html
    76         */
    77         jsMath.Extension.Require("verb");
    78         jsMath.Extension.Require("moreArrows");
    79         jsMath.Extension.Require("AMSmath");
    80         jsMath.Extension.Require("AMSsymbols");
    81     </script>
    82 
    83     {% for m in sage_jsmath_macros %}
    84     <script> {{ m }} </script>
    85     {% endfor %}
     43<script type="text/javascript" src="/javascript/sage/jsmath.js"></script>
    8644{% endif %}
    8745
    8846<!-- Sage3d - accelerated 3D graphics -->
    INPUT: 
    9048
    9149<!-- Jmol - embedded 3D graphics -->
    9250<script type="text/javascript" src="/java/jmol/appletweb/Jmol.js"></script>
    93 <!-- This must stay in <head> -->
     51<!-- This must stay in head -->
    9452<script>jmolInitialize("/java/jmol");jmolSetCallback("menuFile","/java/jmol/appletweb/SageMenu.mnu");</script>
    9553
    9654{% if JEDITABLE_TINYMCE and not worksheet.docbrowser() and not worksheet.is_published() %}
    9755<!-- TinyMCE and jEditable - in-place editing of text cells -->
    98     <script type="text/javascript" src="/javascript/tiny_mce/tiny_mce.js"></script>
    99     <script type="text/javascript" src="/javascript/jquery/plugins/jeditable/jquery.jeditable.mini.js" charset="utf-8"></script>
    100     <script type="text/javascript" src="/javascript/sage/tinymce.js"></script>
     56<script type="text/javascript" src="/javascript/tiny_mce/tiny_mce.js"></script>
     57<script type="text/javascript" src="/javascript/jquery/plugins/jeditable/jquery.jeditable.mini.js" charset="utf-8"></script>
     58<script type="text/javascript" src="/javascript/sage/tinymce.js"></script>
    10159{% endif %}
    10260
    10361<script type="text/javascript">user_name= "{{ username }}";</script>
    10462{% if worksheet_filename %}
    10563<script  type="text/javascript">
    106     worksheet_filename="{{ worksheet_filename }}";
    107     worksheet_name="{{ worksheet.name() }}";
    108     server_ping_while_alive();
     64  worksheet_filename="{{ worksheet_filename }}";
     65  worksheet_name="{{ worksheet.name() }}";
     66  server_ping_while_alive();
    10967</script>
    11068{% endif %}
    11169
  • 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{# TODO: Hack until the template restructuring #}
  • 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/sage/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/sage/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: 0,
     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:
    180181    import sage.all
    181     from sage.misc.latex_macros import sage_jsmath_macros
     182    from sage.misc.latex_macros import sage_jsmath_macros_easy
    182183except ImportError:
    183184#    sage_jsmath_macros = []
    184     sage_jsmath_macros = [
    185         "jsMath.Macro('ZZ','\\\\Bold{Z}');",
    186         "jsMath.Macro('RR','\\\\Bold{R}');",
    187         "jsMath.Macro('CC','\\\\Bold{C}');",
    188         "jsMath.Macro('QQ','\\\\Bold{Q}');",
    189         "jsMath.Macro('QQbar','\\\\overline{\\\\QQ}');",
    190         "jsMath.Macro('GF','\\\\Bold{F}_{#1}',1);",
    191         "jsMath.Macro('Zp','\\\\ZZ_{#1}',1);",
    192         "jsMath.Macro('Qp','\\\\QQ_{#1}',1);",
    193         "jsMath.Macro('Zmod','\\\\ZZ/#1\\\\ZZ',1);",
    194         "jsMath.Macro('CDF','\\\\texttt{Complex Double Field}');",
    195         "jsMath.Macro('CIF','\\\\Bold{C}');",
    196         "jsMath.Macro('CLF','\\\\Bold{C}');",
    197         "jsMath.Macro('RDF','\\\\Bold{R}');",
    198         "jsMath.Macro('RIF','\\\\Bold{I} \\\\Bold{R}');",
    199         "jsMath.Macro('RLF','\\\\Bold{R}');",
    200         "jsMath.Macro('CFF','\\\\Bold{CFF}');",
    201         "jsMath.Macro('Bold','\\\\mathbf{#1}',1);"
     185    sage_jsmath_macros_easy = [
     186        "ZZ : '{\\\\Bold{Z}}'",
     187        "RR : '{\\\\Bold{R}}'",
     188        "CC : '{\\\\Bold{C}}'",
     189        "QQ : '{\\\\Bold{Q}}'",
     190        "QQbar : '{\\\\overline{\\\\QQ}}'",
     191        "GF : ['{\\\\Bold{F}_{#1}}', 1]",
     192        "Zp : ['{\\\\ZZ_{#1}}', 1]",
     193        "Qp : ['{\\\\QQ_{#1}}', 1]",
     194        "Zmod : ['{\\\\ZZ/#1\\\\ZZ}', 1]",
     195        "CIF : '{\\\\Bold{C}}'",
     196        "CLF : '{\\\\Bold{C}}'",
     197        "RDF : '{\\\\Bold{R}}'",
     198        "RIF : '{\\\\Bold{I} \\\\Bold{R}}'",
     199        "RLF : '{\\\\Bold{R}}'",
     200        "CFF : '{\\\\Bold{CFF}}'",
     201        "Bold : ['{\\\\mathbf{#1}}', 1]"
    202202        ]
     203finally:
     204    jsmath_macros = ',\n'.join(sage_jsmath_macros_easy)
    203205
    204206try:
    205207    from sage.misc.session import init as session_init
    except ImportError: 
    208210    def session_init(*args, **kwds):
    209211        pass
    210212   
    211 
    212213try:
    213214    from sage.misc.sage_eval import sage_eval
    214215except ImportError:
    except ImportError: 
    218219        return eval(value, globs)
    219220
    220221try:
    221     from sage.misc.all import is_package_installed
     222    from sage.misc.package import is_package_installed
    222223except ImportError:
    223224    def is_package_installed(name, *args, **kwds):
    224225        return False
    225226
    226 
    227227try:
    228228    from sage.misc.viewer import browser
    229229except ImportError:
    except ImportError: 
    242242        s = cPickle.dumps(obj, protocol=2)
    243243        open(filename,'wb').write(s)
    244244
    245 
    246245try:
    247246    from sage.misc.misc import alarm, cancel_alarm, verbose
    248247except ImportError:
    except ImportError: 
    315314    SAGE_VERSION=""
    316315
    317316try:
    318     from sage.plot.all import Color
     317    from sage.plot.colors import Color
    319318except ImportError:
    320319    class Color:
    321320        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): 
    13361333        data = worksheet.snapshot_data()  # pairs ('how long ago', key)
    13371334
    13381335        return template(os.path.join("html", "notebook", "worksheet_revision_list.html"),
    1339                         data = data,
    1340                         worksheet = worksheet,
     1336                        data = data, worksheet = worksheet,
    13411337                        worksheet_filename = worksheet.filename(),
    1342                         username = username,
    1343                         JSMATH = JSMATH,
    1344                         JSMATH_IMAGE_FONTS = JSMATH_IMAGE_FONTS,
    1345                         JEDITABLE_TINYMCE = JEDITABLE_TINYMCE,
    1346                         sage_jsmath_macros = sage_jsmath_macros)
     1338                        username = username, JSMATH = JSMATH,
     1339                        JEDITABLE_TINYMCE = JEDITABLE_TINYMCE)
    13471340
    13481341
    13491342    def html_specific_revision(self, username, ws, rev):
    class Notebook(object): 
    13841377                break
    13851378           
    13861379        return template(os.path.join("html", "notebook", "specific_revision.html"),
    1387                         worksheet = ws,
    1388                         worksheet_filename = ws.filename(),
    1389                         username = username, rev = rev,
    1390                         prev_rev = prev_rev, next_rev = next_rev,
    1391                         time_ago = time_ago,
     1380                        worksheet = ws, worksheet_filename = ws.filename(),
     1381                        username = username, rev = rev, prev_rev = prev_rev,
     1382                        next_rev = next_rev, time_ago = time_ago,
    13921383                        body_worksheet_html = body_worksheet_html,
    1393                         JSMATH = JSMATH,
    1394                         JSMATH_IMAGE_FONTS = JSMATH_IMAGE_FONTS,
    1395                         JEDITABLE_TINYMCE = JEDITABLE_TINYMCE,
    1396                         sage_jsmath_macros = sage_jsmath_macros)
    1397        
     1384                        JSMATH = JSMATH, JEDITABLE_TINYMCE = JEDITABLE_TINYMCE)
    13981385
    13991386    def html_share(self, worksheet, username):
    14001387        r"""
    class Notebook(object): 
    14261413                        worksheet_filename = worksheet.filename(),
    14271414                        username = username, other_users = other_users,
    14281415                        user_is_admin = self.user(username).is_admin(),
    1429                         JSMATH = JSMATH,
    1430                         JSMATH_IMAGE_FONTS = JSMATH_IMAGE_FONTS,
    1431                         JEDITABLE_TINYMCE = JEDITABLE_TINYMCE,
    1432                         sage_jsmath_macros = sage_jsmath_macros)
    1433 
     1416                        JSMATH = JSMATH, JEDITABLE_TINYMCE = JEDITABLE_TINYMCE)
    14341417
    14351418    def html_download_or_delete_datafile(self, ws, username, filename):
    14361419        r"""
    class Notebook(object): 
    14721455            text_file_content = open(os.path.join(ws.data_directory(), filename)).read()
    14731456
    14741457        return template(os.path.join("html", "notebook", "download_or_delete_datafile.html"),
    1475                         worksheet = ws,
    1476                         worksheet_filename = ws.filename(),
     1458                        worksheet = ws, worksheet_filename = ws.filename(),
    14771459                        username = username,
    14781460                        active_worksheets = active_worksheets,
    1479                         filename_ = filename,
    1480                         path = path,
     1461                        filename_ = filename, path = path,
    14811462                        file_is_image = file_is_image,
    14821463                        file_is_text = file_is_text,
    14831464                        text_file_content = text_file_content,
    1484                         JSMATH = JSMATH,
    1485                         JSMATH_IMAGE_FONTS = JSMATH_IMAGE_FONTS,
    1486                         JEDITABLE_TINYMCE = JEDITABLE_TINYMCE,
    1487                         sage_jsmath_macros = sage_jsmath_macros)
    1488 
    1489 
     1465                        JSMATH = JSMATH, JEDITABLE_TINYMCE = JEDITABLE_TINYMCE)
    14901466
    14911467
    14921468    ##########################################################
    class Notebook(object): 
    16161592        return template(os.path.join("html", "notebook", "plain_text_window.html"),
    16171593                        worksheet = worksheet,
    16181594                        worksheet_filename = worksheet.filename(),
    1619                         username = username,
    1620                         plain_text = plain_text, JSMATH = JSMATH,
    1621                         JSMATH_IMAGE_FONTS = JSMATH_IMAGE_FONTS,
    1622                         JEDITABLE_TINYMCE = JEDITABLE_TINYMCE,
    1623                         sage_jsmath_macros = sage_jsmath_macros)
     1595                        username = username, plain_text = plain_text,
     1596                        JSMATH = JSMATH, JEDITABLE_TINYMCE = JEDITABLE_TINYMCE)
    16241597                       
    16251598    def html_edit_window(self, worksheet, username):
    16261599        r"""
    class Notebook(object): 
    16501623        return template(os.path.join("html", "notebook", "edit_window.html"),
    16511624                        worksheet = worksheet,
    16521625                        worksheet_filename = worksheet.filename(),
    1653                         username = username, text = text,
    1654                         n_lines = n_lines, JSMATH = JSMATH,
    1655                         JSMATH_IMAGE_FONTS = JSMATH_IMAGE_FONTS,
    1656                         JEDITABLE_TINYMCE = JEDITABLE_TINYMCE,
    1657                         sage_jsmath_macros = sage_jsmath_macros)
     1626                        username = username, text = text, n_lines = n_lines,
     1627                        JSMATH = JSMATH, JEDITABLE_TINYMCE = JEDITABLE_TINYMCE)
    16581628   
    16591629    def html_beforepublish_window(self, worksheet, username):
    16601630        r"""
    class Notebook(object): 
    16911661        return template(os.path.join("html", "notebook", "beforepublish_window.html"),
    16921662                        worksheet = worksheet,
    16931663                        worksheet_filename = worksheet.filename(),
    1694                         username = username, JSMATH = JSMATH,
    1695                         JSMATH_IMAGE_FONTS = JSMATH_IMAGE_FONTS,
    1696                         JEDITABLE_TINYMCE = JEDITABLE_TINYMCE,
    1697                         sage_jsmath_macros = sage_jsmath_macros)
     1664                        username = username,
     1665                        JSMATH = JSMATH, JEDITABLE_TINYMCE = JEDITABLE_TINYMCE)
    16981666       
    16991667    def html_afterpublish_window(self, worksheet, username, url, dtime):
    17001668        r"""
    class Notebook(object): 
    17231691        return template(os.path.join("html", "notebook", "afterpublish_window.html"),
    17241692                        worksheet = worksheet,
    17251693                        worksheet_filename = worksheet.filename(),
    1726                         username = username, url = url,
    1727                         time = time, JSMATH = JSMATH,
    1728                         JSMATH_IMAGE_FONTS = JSMATH_IMAGE_FONTS,
    1729                         JEDITABLE_TINYMCE = JEDITABLE_TINYMCE,
    1730                         sage_jsmath_macros = sage_jsmath_macros)
     1694                        username = username, url = url, time = time,
     1695                        JSMATH = JSMATH, JEDITABLE_TINYMCE = JEDITABLE_TINYMCE)
    17311696
    17321697    def html_upload_data_window(self, ws, username):
    17331698        r"""
    class Notebook(object): 
    17511716            '\n<!D...orksheet_menu" value="Upload File" onClick="form.submit()...r />\n</div>\n\n\n    </body>\n</html>'
    17521717        """
    17531718        return template(os.path.join("html", "notebook", "upload_data_window.html"),
    1754                         worksheet = ws,
    1755                         worksheet_filename = ws.filename(),
    1756                         username = username, JSMATH = JSMATH,
    1757                         JSMATH_IMAGE_FONTS = JSMATH_IMAGE_FONTS,
    1758                         JEDITABLE_TINYMCE = JEDITABLE_TINYMCE,
    1759                         sage_jsmath_macros = sage_jsmath_macros)
    1760    
     1719                        worksheet = ws, worksheet_filename = ws.filename(),
     1720                        username = username,
     1721                        JSMATH = JSMATH, JEDITABLE_TINYMCE = JEDITABLE_TINYMCE)
    17611722
    17621723    def html(self, worksheet_filename=None, username='guest', show_debug=False, admin=False):
    17631724        r"""
    class Notebook(object): 
    17991760           
    18001761        return template(template_page, worksheet = W,
    18011762                        worksheet_filename = W.filename(),
    1802                         worksheet_html = W.html(),
    1803                         notebook = self, username = username,
    1804                         show_debug = show_debug,
    1805                         JSMATH = JSMATH,
    1806                         JSMATH_IMAGE_FONTS = JSMATH_IMAGE_FONTS,
    1807                         JEDITABLE_TINYMCE = JEDITABLE_TINYMCE,
    1808                         sage_jsmath_macros = sage_jsmath_macros)
    1809 
     1763                        worksheet_html = W.html(), notebook = self,
     1764                        username = username, show_debug = show_debug,
     1765                        JSMATH = JSMATH, JEDITABLE_TINYMCE = JEDITABLE_TINYMCE)
    18101766
    18111767    def html_doc(self, username):
    18121768        r"""
    class Notebook(object): 
    18281784            '\n<!D...c Documentation</a><br /><br />\n        <a href="/help/">Sage Notebook Howto...   </body>\n</html>'
    18291785        """
    18301786        return template(os.path.join("html", "notebook", "doc.html"),
    1831                         username = username, JSMATH = JSMATH,
    1832                         JSMATH_IMAGE_FONTS = JSMATH_IMAGE_FONTS,
    1833                         JEDITABLE_TINYMCE = JEDITABLE_TINYMCE,
    1834                         sage_jsmath_macros = sage_jsmath_macros)
     1787                        username = username,
     1788                        JSMATH = JSMATH, JEDITABLE_TINYMCE = JEDITABLE_TINYMCE)
    18351789       
    18361790
    18371791####################################################################
  • 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")
    javascript_path = os.path.join(DATA 
    5961sage_javascript_path = os.path.join(DATA, 'sage', 'js')
    6062java_path            = os.path.join(DATA)
    6163
     64jsmath_image_fonts = is_package_installed("jsmath-image-fonts")
     65
    6266# the list of users waiting to register
    6367waiting = {}
    6468
    setattr(CSS, 'child_reset.css', Reset_cs 
    18031807# Javascript resources
    18041808############################
    18051809
     1810class JSMath_js(resource.Resource):
     1811    def render(self, ctx):
     1812        gzip_handler(ctx)
     1813
     1814        s = template(os.path.join('js', 'jsmath.js'),
     1815                     jsmath_macros = jsmath_macros,
     1816                     jsmath_image_fonts = jsmath_image_fonts)
     1817       
     1818        return http.Response(stream=s)
     1819
    18061820class Main_js(resource.Resource):
    18071821    def render(self, ctx):
    18081822        gzip_handler(ctx)
    class SageJavascript(resource.Resource): 
    18351849        return static.File(path)
    18361850
    18371851setattr(SageJavascript, 'child_main.js', Main_js())
     1852setattr(SageJavascript, 'child_jsmath.js', JSMath_js())
    18381853
    18391854class Javascript(resource.Resource):
    18401855    addSlash = True