Ticket #4714: trac_4714-sagenb_jsmath_init_v2.patch
File trac_4714-sagenb_jsmath_init_v2.patch, 38.6 KB (added by , 13 years ago) |
---|
-
sagenb/data/sage/html/notebook/afterpublish_window.html
# HG changeset patch # User Mitesh Patel <qed777@gmail.com> # Date 1256280905 25200 # Node ID 48bd089f0667e9162849af3b29ee31f8ab195367 # 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: 7 7 - url - a string containing the url of the published page 8 8 - time - a string representing the time of publication 9 9 - JSMATH - a boolean stating whether to include jsMath 10 - JSMATH_IMAGE_FONTS - a boolean stating whether to include jsMath iamage fonts11 10 - 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 jsMath13 11 #} 14 12 15 13 {% 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: 5 5 - worksheet_filename - a string containing a worksheet's filename 6 6 - username - a string containing a username 7 7 - JSMATH - a boolean stating whether to include jsMath 8 - JSMATH_IMAGE_FONTS - a boolean stating whether to include jsMath iamage fonts9 8 - 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 jsMath11 9 #} 12 10 13 11 {% 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: 5 5 - worksheet_filename - a string containing a worksheet's filename 6 6 - username - a string containing a username 7 7 - JSMATH - a boolean stating whether to include jsMath 8 - JSMATH_IMAGE_FONTS - a boolean stating whether to include jsMath iamage fonts9 8 - 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 jsMath11 9 #} 12 10 13 11 {% include "html/notebook/head.tmpl" %} … … INPUT: 18 16 19 17 {% block css %}main{% endblock %} 20 18 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 %} 22 22 23 23 {% block javascript %} 24 {{ common_javascript(worksheet, worksheet_filename, username, JSMATH, J SMATH_IMAGE_FONTS, JEDITABLE_TINYMCE, sage_jsmath_macros) }}24 {{ common_javascript(worksheet, worksheet_filename, username, JSMATH, JEDITABLE_TINYMCE) }} 25 25 {% endblock %} 26 26 27 27 {% 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: 11 11 - file_is_text - a boolean stating whether the file is a text file 12 12 - text_file_content - a string containing the content of a text file 13 13 - JSMATH - a boolean stating whether to include jsMath 14 - JSMATH_IMAGE_FONTS - a boolean stating whether to include jsMath iamage fonts15 14 - 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 jsMath17 15 #} 18 16 {% set title = "Data file: %s"|format(filename_) %} 19 17 -
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: 7 7 - text - a string containing the text of the worksheet 8 8 - n_lines - number of lines of the text of the worksheet 9 9 - JSMATH - a boolean stating whether to include jsMath 10 - JSMATH_IMAGE_FONTS - a boolean stating whether to include jsMath iamage fonts11 10 - 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 jsMath13 11 #} 14 12 15 13 {% set title = 'Edit plain text <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: 4 4 - worksheet_filename - a string containing a worksheet's filename 5 5 - username - a string containing a user's name 6 6 - JSMATH - a boolean stating whether to include jsMath 7 - JSMATH_IMAGE_FONTS - a boolean stating whether to include jsMath iamage fonts8 7 - 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 jsMath10 8 #} 11 9 {% macro common_title(worksheet_filename, worksheet) %} 12 10 {% if worksheet_filename %} … … INPUT: 16 14 {% endif %} 17 15 {% endmacro %} 18 16 19 20 17 {% macro common_css %} 21 18 <!-- Sage notebook stylesheet --> 22 19 <link rel=stylesheet href="/css/main.css" type="text/css" /> 23 20 {% endmacro %} 24 21 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 26 24 <!-- jQuery - general-purpose functions --> 27 25 <script type="text/javascript" src="/javascript/jquery/jquery-1.3.2.min.js"></script> 28 26 … … INPUT: 42 40 43 41 {% if JSMATH %} 44 42 <!-- 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> 86 44 {% endif %} 87 45 88 46 <!-- Sage3d - accelerated 3D graphics --> … … INPUT: 90 48 91 49 <!-- Jmol - embedded 3D graphics --> 92 50 <script type="text/javascript" src="/java/jmol/appletweb/Jmol.js"></script> 93 <!-- This must stay in <head>-->51 <!-- This must stay in head --> 94 52 <script>jmolInitialize("/java/jmol");jmolSetCallback("menuFile","/java/jmol/appletweb/SageMenu.mnu");</script> 95 53 96 54 {% if JEDITABLE_TINYMCE and not worksheet.docbrowser() and not worksheet.is_published() %} 97 55 <!-- TinyMCE and jEditable - in-place editing of text cells --> 98 99 100 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> 101 59 {% endif %} 102 60 103 61 <script type="text/javascript">user_name= "{{ username }}";</script> 104 62 {% if worksheet_filename %} 105 63 <script type="text/javascript"> 106 107 108 64 worksheet_filename="{{ worksheet_filename }}"; 65 worksheet_name="{{ worksheet.name() }}"; 66 server_ping_while_alive(); 109 67 </script> 110 68 {% endif %} 111 69 -
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: 8 8 - username - a string containing a username 9 9 - show_debug - a boolean stating whether to show debug information 10 10 - JSMATH - a boolean stating whether to include jsMath 11 - JSMATH_IMAGE_FONTS - a boolean stating whether to include jsMath iamage fonts12 11 - 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 jsMath14 12 #} 15 13 16 14 {% if not select %} … … INPUT: 30 28 {% block css %}main{% endblock %} 31 29 32 30 {% block javascript %} 33 {{ common_javascript(worksheet, worksheet_filename, username, JSMATH, J SMATH_IMAGE_FONTS, JEDITABLE_TINYMCE, sage_jsmath_macros) }}31 {{ common_javascript(worksheet, worksheet_filename, username, JSMATH, JEDITABLE_TINYMCE) }} 34 32 {% endblock %} 35 33 36 34 {# 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: 6 6 - username - a string containing a username 7 7 - plain_text - a string containing the plain text version 8 8 - JSMATH - a boolean stating whether to include jsMath 9 - JSMATH_IMAGE_FONTS - a boolean stating whether to include jsMath iamage fonts10 9 - 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 jsMath12 10 #} 13 11 14 12 {% 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: 10 10 - time_ago - a string containing the time since revision 11 11 - body_worksheet_html - the body html of the worksheet 12 12 - JSMATH - a boolean stating whether to include jsMath 13 - JSMATH_IMAGE_FONTS - a boolean stating whether to include jsMath iamage fonts14 13 - 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 jsMath16 14 #} 17 15 18 16 {% 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: 5 5 - worksheet_filename - a string containing a worksheet's filename 6 6 - username - a string containing a username 7 7 - JSMATH - a boolean stating whether to include jsMath 8 - JSMATH_IMAGE_FONTS - a boolean stating whether to include jsMath iamage fonts9 8 - 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 jsMath11 9 #} 12 10 13 11 {% 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: 15 15 <script type="text/javascript" src="/javascript/jquery/jquery-1.3.2.min.js"></script> 16 16 <script type="text/javascript" src="/javascript/sage/main.js"></script> 17 17 {% 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> 19 19 {% endif %} 20 20 {% endblock %} 21 21 -
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: 8 8 - select - a string containing the control that is selected 9 9 - backwards - a boolean 10 10 - JSMATH - a boolean stating whether to include jsMath 11 - JSMATH_IMAGE_FONTS - a boolean stating whether to include jsMath iamage fonts12 11 - 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 jsMath14 12 #} 15 13 16 14 {% if not select %} … … INPUT: 32 30 {% block css %}main{% endblock %} 33 31 34 32 {% block javascript %} 35 {{ common_javascript(worksheet, worksheet_filename, username, JSMATH, J SMATH_IMAGE_FONTS, JEDITABLE_TINYMCE, sage_jsmath_macros) }}33 {{ common_javascript(worksheet, worksheet_filename, username, JSMATH, JEDITABLE_TINYMCE) }} 36 34 {% endblock %} 37 35 38 36 {% 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: 6 6 - worksheet_filename - a string containing a worksheet's filename 7 7 - username - a string containing a username 8 8 - JSMATH - a boolean stating whether to include jsMath 9 - JSMATH_IMAGE_FONTS - a boolean stating whether to include jsMath iamage fonts10 9 - 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 jsMath12 10 #} 13 11 14 12 -
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: 5 5 - worksheet_filename - a string containing a worksheet's filename 6 6 - username - a string containing a username 7 7 - JSMATH - a boolean stating whether to include jsMath 8 - JSMATH_IMAGE_FONTS - a boolean stating whether to include jsMath iamage fonts9 8 - 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 jsMath11 9 #} 12 10 13 11 {% set title = 'Worksheet Settings <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: 7 7 - other_users - a list of strings containing other users names 8 8 - user_is_admin - a boolean stating whether the user is an admin 9 9 - JSMATH - a boolean stating whether to include jsMath 10 - JSMATH_IMAGE_FONTS - a boolean stating whether to include jsMath iamage fonts11 10 - 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 jsMath13 11 #} 14 12 15 13 {% 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 20 if (!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) 24 jsMath.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 31 jsMath.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 175 if (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 } 184 jsMath.Easy.root = jsMath.Easy.root.replace(/\/$/,""); // trim trailing "/" if any 185 186 document.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: 176 176 except ImportError: 177 177 SAGE_DOC = "stub" 178 178 179 # TODO: Get macros from server and user settings. 179 180 try: 180 181 import sage.all 181 from sage.misc.latex_macros import sage_jsmath_macros 182 from sage.misc.latex_macros import sage_jsmath_macros_easy 182 183 except ImportError: 183 184 # 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]" 202 202 ] 203 finally: 204 jsmath_macros = ',\n'.join(sage_jsmath_macros_easy) 203 205 204 206 try: 205 207 from sage.misc.session import init as session_init … … except ImportError: 208 210 def session_init(*args, **kwds): 209 211 pass 210 212 211 212 213 try: 213 214 from sage.misc.sage_eval import sage_eval 214 215 except ImportError: … … except ImportError: 218 219 return eval(value, globs) 219 220 220 221 try: 221 from sage.misc. allimport is_package_installed222 from sage.misc.package import is_package_installed 222 223 except ImportError: 223 224 def is_package_installed(name, *args, **kwds): 224 225 return False 225 226 226 227 227 try: 228 228 from sage.misc.viewer import browser 229 229 except ImportError: … … except ImportError: 242 242 s = cPickle.dumps(obj, protocol=2) 243 243 open(filename,'wb').write(s) 244 244 245 246 245 try: 247 246 from sage.misc.misc import alarm, cancel_alarm, verbose 248 247 except ImportError: … … except ImportError: 315 314 SAGE_VERSION="" 316 315 317 316 try: 318 from sage.plot. allimport Color317 from sage.plot.colors import Color 319 318 except ImportError: 320 319 class Color: 321 320 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 31 31 32 32 33 33 # Sage libraries 34 from sagenb.misc.misc import (pad_zeros, is_package_installed, 35 sage_jsmath_macros, cputime, tmp_dir, load, save) 34 from sagenb.misc.misc import (pad_zeros, cputime, tmp_dir, load, save) 36 35 37 36 # Sage Notebook 38 37 import css # style … … SYSTEM_NAMES = [v.split()[0] for v in SY 61 60 62 61 JSMATH = True 63 62 64 JSMATH_IMAGE_FONTS = is_package_installed("jsmath-image-fonts")65 66 63 JEDITABLE_TINYMCE = True 67 64 68 65 DOC_TIMEOUT = 120 … … class Notebook(object): 1336 1333 data = worksheet.snapshot_data() # pairs ('how long ago', key) 1337 1334 1338 1335 return template(os.path.join("html", "notebook", "worksheet_revision_list.html"), 1339 data = data, 1340 worksheet = worksheet, 1336 data = data, worksheet = worksheet, 1341 1337 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) 1347 1340 1348 1341 1349 1342 def html_specific_revision(self, username, ws, rev): … … class Notebook(object): 1384 1377 break 1385 1378 1386 1379 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, 1392 1383 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) 1398 1385 1399 1386 def html_share(self, worksheet, username): 1400 1387 r""" … … class Notebook(object): 1426 1413 worksheet_filename = worksheet.filename(), 1427 1414 username = username, other_users = other_users, 1428 1415 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) 1434 1417 1435 1418 def html_download_or_delete_datafile(self, ws, username, filename): 1436 1419 r""" … … class Notebook(object): 1472 1455 text_file_content = open(os.path.join(ws.data_directory(), filename)).read() 1473 1456 1474 1457 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(), 1477 1459 username = username, 1478 1460 active_worksheets = active_worksheets, 1479 filename_ = filename, 1480 path = path, 1461 filename_ = filename, path = path, 1481 1462 file_is_image = file_is_image, 1482 1463 file_is_text = file_is_text, 1483 1464 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) 1490 1466 1491 1467 1492 1468 ########################################################## … … class Notebook(object): 1616 1592 return template(os.path.join("html", "notebook", "plain_text_window.html"), 1617 1593 worksheet = worksheet, 1618 1594 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) 1624 1597 1625 1598 def html_edit_window(self, worksheet, username): 1626 1599 r""" … … class Notebook(object): 1650 1623 return template(os.path.join("html", "notebook", "edit_window.html"), 1651 1624 worksheet = worksheet, 1652 1625 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) 1658 1628 1659 1629 def html_beforepublish_window(self, worksheet, username): 1660 1630 r""" … … class Notebook(object): 1691 1661 return template(os.path.join("html", "notebook", "beforepublish_window.html"), 1692 1662 worksheet = worksheet, 1693 1663 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) 1698 1666 1699 1667 def html_afterpublish_window(self, worksheet, username, url, dtime): 1700 1668 r""" … … class Notebook(object): 1723 1691 return template(os.path.join("html", "notebook", "afterpublish_window.html"), 1724 1692 worksheet = worksheet, 1725 1693 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) 1731 1696 1732 1697 def html_upload_data_window(self, ws, username): 1733 1698 r""" … … class Notebook(object): 1751 1716 '\n<!D...orksheet_menu" value="Upload File" onClick="form.submit()...r />\n</div>\n\n\n </body>\n</html>' 1752 1717 """ 1753 1718 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) 1761 1722 1762 1723 def html(self, worksheet_filename=None, username='guest', show_debug=False, admin=False): 1763 1724 r""" … … class Notebook(object): 1799 1760 1800 1761 return template(template_page, worksheet = W, 1801 1762 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) 1810 1766 1811 1767 def html_doc(self, username): 1812 1768 r""" … … class Notebook(object): 1828 1784 '\n<!D...c Documentation</a><br /><br />\n <a href="/help/">Sage Notebook Howto... </body>\n</html>' 1829 1785 """ 1830 1786 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) 1835 1789 1836 1790 1837 1791 #################################################################### -
sagenb/notebook/twist.py
diff --git a/sagenb/notebook/twist.py b/sagenb/notebook/twist.py
a b from sagenb.notebook.template import tem 51 51 HISTORY_MAX_OUTPUT = 92*5 52 52 HISTORY_NCOLS = 90 53 53 54 from sagenb.misc.misc import SAGE_DOC, walltime, tmp_filename, tmp_dir, DATA, SAGE_VERSION 54 from sagenb.misc.misc import (SAGE_DOC, DATA, SAGE_VERSION, walltime, 55 tmp_filename, tmp_dir, is_package_installed, 56 jsmath_macros) 55 57 56 58 css_path = os.path.join(DATA, "sage", "css") 57 59 image_path = os.path.join(DATA, "sage", "images") … … javascript_path = os.path.join(DATA 59 61 sage_javascript_path = os.path.join(DATA, 'sage', 'js') 60 62 java_path = os.path.join(DATA) 61 63 64 jsmath_image_fonts = is_package_installed("jsmath-image-fonts") 65 62 66 # the list of users waiting to register 63 67 waiting = {} 64 68 … … setattr(CSS, 'child_reset.css', Reset_cs 1803 1807 # Javascript resources 1804 1808 ############################ 1805 1809 1810 class 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 1806 1820 class Main_js(resource.Resource): 1807 1821 def render(self, ctx): 1808 1822 gzip_handler(ctx) … … class SageJavascript(resource.Resource): 1835 1849 return static.File(path) 1836 1850 1837 1851 setattr(SageJavascript, 'child_main.js', Main_js()) 1852 setattr(SageJavascript, 'child_jsmath.js', JSMath_js()) 1838 1853 1839 1854 class Javascript(resource.Resource): 1840 1855 addSlash = True