Ticket #7309: trac_7309-javascript-sage.patch

File trac_7309-javascript-sage.patch, 7.0 KB (added by timdumol, 11 years ago)

Adds /javascript/sage/ and updates notebook_lib.js and the html templates to use it.

  • sagenb/data/sage/html/notebook/head.tmpl

    # HG changeset patch
    # User Tim Dumol <tim@timdumol.com>
    # Date 1256563466 -28800
    # Node ID d8cedf9b69745f99835417ff40faa91911c079e7
    # Parent  6486b05dd7484339a7ed4fa4ad37a50c6947d3de
    #7309 SageNB - Restructure /javascript/ to have /javascript/sage/. Tim Dumol.
    
    diff -r 6486b05dd748 -r d8cedf9b6974 sagenb/data/sage/html/notebook/head.tmpl
    a b  
    2626<!-- jQuery - general-purpose functions -->
    2727<script type="text/javascript" src="/javascript/jquery/jquery-1.3.2.min.js"></script>
    2828<!-- Sage Notebook library -->
    29 <script type="text/javascript" src="/javascript/main.js"></script>
     29<script type="text/javascript" src="/javascript/sage/main.js"></script>
    3030 
    3131{% if JSMATH %}
    3232<!-- jsMath - typeset mathematics -->
  • sagenb/data/sage/html/notebook/index.html

    diff -r 6486b05dd748 -r d8cedf9b6974 sagenb/data/sage/html/notebook/index.html
    a b  
    3333{{ common_javascript(worksheet, worksheet_filename, username, JSMATH, JSMATH_IMAGE_FONTS, JEDITABLE_TINYMCE, sage_jsmath_macros) }}
    3434{% endblock %}
    3535
     36{# TODO: Hack until the template restructuring #}
    3637{% block body_attrs %}
    37 class="worksheet-online" onLoad="initialize_the_notebook();"
     38{% if worksheet.is_published() or notebook.user_is_guest(username) %}
     39        class="worksheet-online" onLoad="initialize_the_notebook();"
     40    {% else %}
     41        class="worksheet-online" onLoad="initialize_the_notebook();" id="user-worksheet-index"
     42{% endif %}
    3843{% endblock %}
    3944
     45
    4046{% block body %}
    4147{% if worksheet.is_published() or notebook.user_is_guest(username) %}
    4248    {% set original_worksheet = worksheet.worksheet_that_was_published() %}
  • sagenb/data/sage/html/notebook/top_bar_and_worksheet.html

    diff -r 6486b05dd748 -r d8cedf9b6974 sagenb/data/sage/html/notebook/top_bar_and_worksheet.html
    a b  
    1515                       ('bugreport()', 'Report a Problem', 'Report a problem or submit a bug to improve Sage'),
    1616                       ('help()', 'Help', 'Documentation'),
    1717                       ('/logout', 'Sign out', 'Log out of the Sage notebook')] %}
     18
    1819<table width="100%">
    1920    <tr>
    2021        <td>{% include "html/banner.html" %}</td>
  • sagenb/data/sage/html/notebook/worksheet.html

    diff -r 6486b05dd748 -r d8cedf9b6974 sagenb/data/sage/html/notebook/worksheet.html
    a b  
    1313
    1414{% block javascript %}
    1515<script type="text/javascript" src="/javascript/jquery/jquery-1.3.2.min.js"></script>
    16 <script type="text/javascript" src="/javascript/main.js"></script>
     16<script type="text/javascript" src="/javascript/sage/main.js"></script>
    1717{% if do_print %}
    1818    <script type="text/javascript" src="/javascript/jsmath/jsMath.js"></script>
    1919{% endif %}   
  • sagenb/data/sage/html/worksheet_listing.html

    diff -r 6486b05dd748 -r d8cedf9b6974 sagenb/data/sage/html/worksheet_listing.html
    a b  
    2121  {% if not pub %}
    2222  <script type="text/javascript" src="/javascript/jquery/jquery-1.3.2.min.js"></script>
    2323  {% endif %}
    24   <script type="text/javascript" src="/javascript/main.js"></script>
     24  <script type="text/javascript" src="/javascript/sage/main.js"></script>
    2525  {% if not pub %}
    2626    <script type="text/javascript">
    2727    var worksheet_filenames = {{ worksheet_filenames }};
  • sagenb/data/sage/js/notebook_lib.js

    diff -r 6486b05dd748 -r d8cedf9b6974 sagenb/data/sage/js/notebook_lib.js
    a b  
    265265        alert("Your browser / OS combination is not supported.  \nPlease use Firefox or Opera under Linux, Windows, or Mac OS X, or Safari.")
    266266    }
    267267
    268     async_request('/javascript/keyboard/'+b+o, get_keyboard_callback);
     268    async_request('/javascript/sage/keyboard/'+b+o, get_keyboard_callback);
    269269}
    270270
    271271
     
    576576
    577577String.prototype.replaceAll = function(strTarget, strSubString ) {
    578578    /*
    579     Replace all instances of the given substring by another string>
     579    Replace all instances of the given substring by another string.
    580580
    581581    From http://www.bennadel.com/blog/142-Ask-Ben-Javascript-String-Replace-Method.htm
    582582
     
    673673
    674674function input_keyup(id, event) {
    675675    /*
    676     Resize the cell once and a while.  Not too often.
     676    Resize the cell once in a while.  Not too often.
    677677    INPUT:
    678678        id -- an integer
    679679        event -- a keyup event
     
    701701    if (e==null) return;
    702702    if (key_enter(e)) {
    703703        var cell = get_cell(id)
    704         //warning!  very subtle regular expression (for nonjaphs)
     704        // warning!  very subtle regular expression (for nonjaphs)
    705705        // (?:\n|^)        -- starting from the last line ending (or beginning of the cell), (don't capture contents)
    706706        // ( *)            -- as many spaces as we can find (capture this, we'll find it in RegExp.$1)
    707707        // (?:.*?)         -- everything else in the string, but save room for the following terms (don't capture contents)
  • sagenb/notebook/twist.py

    diff -r 6486b05dd748 -r d8cedf9b6974 sagenb/notebook/twist.py
    a b  
    5353
    5454from sagenb.misc.misc import SAGE_DOC, walltime, tmp_filename, tmp_dir, DATA, SAGE_VERSION
    5555
    56 css_path        = os.path.join(DATA, "sage", "css")
    57 image_path      = os.path.join(DATA, "sage", "images")
    58 javascript_path = os.path.join(DATA)
    59 java_path       = os.path.join(DATA)
     56css_path             = os.path.join(DATA, "sage", "css")
     57image_path           = os.path.join(DATA, "sage", "images")
     58javascript_path      = os.path.join(DATA)
     59sage_javascript_path = os.path.join(DATA, 'sage', 'js')
     60java_path            = os.path.join(DATA)
    6061
    6162# the list of users waiting to register
    6263waiting = {}
     
    17881789
    17891790class Javascript(resource.Resource):
    17901791    addSlash = True
    1791     child_keyboard = Keyboard_js()
    17921792
    17931793    def render(self, ctx):
    17941794        return static.File(javascript_path)
    17951795
    17961796    def childFactory(self, request, name):
    17971797        gzip_handler(request)
     1798        if name == 'sage':
     1799            return SageJavascript()
    17981800        path = os.path.join(javascript_path, name)
    17991801        return static.File(path)
    18001802
    1801 setattr(Javascript, 'child_main.js', Main_js())
     1803class SageJavascript(resource.Resource):
     1804    addSlash = True
     1805    child_keyboard = Keyboard_js()
     1806   
     1807    def render(self, ctx):
     1808        return static.File(javascript_path)
     1809
     1810    def childFactory(self, request, name):
     1811        gzip_handler(request)
     1812        path = os.path.join(sage_javascript_path, name)
     1813        return static.File(path)
     1814   
     1815setattr(SageJavascript, 'child_main.js', Main_js())
    18021816
    18031817
    18041818