Ticket #6568: sage-trac-6568.3.patch

File sage-trac-6568.3.patch, 17.4 KB (added by timdumol, 12 years ago)

Fixed several bugs. Incremental patch from sage-trac-6568.2.patch

  • sage/server/notebook/notebook.py

    # HG changeset patch
    # User Tim Dumol <tim@timdumol.com>
    # Date 1250167523 -28800
    # Node ID 70c794ffda2dad20d3130911cea8c7a7a4bd1e37
    # Parent  5c624a40c5ebb4a5c4c5b28f41dcbd61f0697c2a
    * Fixed various bugs in the templates.
    ** Fixed bug in `published_worksheet.html` and `worksheet_body.html`
       that allowed editing of published worksheets.
    ** Fixed bug in `afterpublish_window.html` that caused the
       "re-publish" and "stop publishing" buttons not to work.
    ** Fixed bug in various templates that caused ``main.css`` not to load.
    ** Fixed bug in print representation of a worksheet that caused
       ``main.css`` not to load.
    ** Fixed typo: 'reviisions' to 'revisions'
    
    diff -r 5c624a40c5eb -r 70c794ffda2d sage/server/notebook/notebook.py
    a b  
    13231323       
    13241324            sage: nb = sage.server.notebook.notebook.Notebook(tmp_dir())
    13251325            sage: W = nb.create_new_worksheet('Test', 'admin')
    1326             sage: nb.worksheet_html('admin', W)
     1326            sage: nb.worksheet_html(W.filename())
    13271327            '\n<!D...ript type="text/javascript">cell_id_list=[0];</script>\n\n\n\n\n\n    </body>\n</html>'
    13281328        """
    13291329        worksheet = self.get_worksheet_with_filename(filename)
     
    13731373            sage: nb = sage.server.notebook.notebook.Notebook(tmp_dir())
    13741374            sage: W = nb.create_new_worksheet('Test', 'admin')
    13751375            sage: nb.html_worksheet_revision_list('admin', W)
    1376             '\n<!D...ss="revs">1 minute ago</span></td>\n    </tr>\n\n</table>\n\n\n    </body>\n</html>'
     1376            '\n<!D...seconds ago</span></td>\n    </tr>\n\n</table>\n\n\n    </body>\n</html>'
    13771377        """
    13781378        data = worksheet.snapshot_data()  # pairs ('how long ago', key)
    13791379
     
    14471447       
    14481448            sage: nb = sage.server.notebook.notebook.Notebook(tmp_dir())
    14491449            sage: W = nb.create_new_worksheet('Test', 'admin')
    1450             sage: nb.html_worksheet_revision_list('admin', W)
     1450            sage: nb.html_share(W, 'admin')
    14511451            '\n<!D...span class="username">Sage Users:</span>\n<span class="users">\n    \n</span>\n\n\n\n    </body>\n</html>'
    14521452        """
    14531453        U = self.users()
     
    16481648       
    16491649            sage: nb = sage.server.notebook.notebook.Notebook(tmp_dir())
    16501650            sage: W = nb.create_new_worksheet('Test', 'admin')
    1651             sage: nb.html_plain_text_window('admin', W)
     1651            sage: nb.html_plain_text_window(W, 'admin')
    16521652            '\n<!D...>\n\n<pre class="plaintext" id="cell_intext" name="textfield"></pre>\n\n\n    </body>\n</html>'
    16531653        """
    16541654        plain_text = worksheet.plain_text(prompts=True, banner=False)
     
    16771677       
    16781678            sage: nb = sage.server.notebook.notebook.Notebook(tmp_dir())
    16791679            sage: W = nb.create_new_worksheet('Test', 'admin')
    1680             sage: nb.html_edit_window('admin', W)
    1681             '\n<!D...ws="7">Test\nsystem:sage\n\n{{{id=0|\n\n///\n}}}</textarea>\n</form>\n\n\n    </body>\n</html>''
     1680            sage: nb.html_edit_window(W, 'admin')
     1681            '\n<!D...Test\nsystem:sage\n\n{{{id=0|\n\n///\n}}}</textarea>\n</form>\n\n\n    </body>\n</html>'
    16821682        """
    16831683        text = worksheet.edit_text()
    16841684        text = escape(text)
     
    17051705       
    17061706            sage: nb = sage.server.notebook.notebook.Notebook(tmp_dir())
    17071707            sage: W = nb.create_new_worksheet('Test', 'admin')
    1708             sage: nb.html_before_publish_window('admin', W)
     1708            sage: nb.html_beforepublish_window(W, 'admin')
    17091709            '\n<!D...publish when changes are made</form></span>\n<br /><br /><br />\n\n\n    </body>\n</html>'
    17101710        """
    17111711        msg = """You can publish your worksheet to the Internet, where anyone will be able to access and view it online.
     
    17591759       
    17601760            sage: nb = sage.server.notebook.notebook.Notebook(tmp_dir())
    17611761            sage: W = nb.create_new_worksheet('Test', 'admin')
    1762             sage: nb.html_upload_data_window('admin', W)
     1762            sage: nb.html_upload_data_window(W, 'admin')
    17631763            '\n<!D...orksheet_menu" value="Upload File" onClick="form.submit()...r />\n</div>\n\n\n    </body>\n</html>'
    17641764        """
    17651765        return template("notebook/upload_data_window.html", worksheet = worksheet,
     
    17841784       
    17851785            sage: nb = sage.server.notebook.notebook.Notebook(tmp_dir())
    17861786            sage: W = nb.create_new_worksheet('Test', 'admin')
    1787             sage: nb.html('admin', W)
    1788             '\n<!D...pe="text/javascript">worksheet_locked=false;</script>\n\n    \n\n\n    </body>\n</html>'
     1787            sage: nb.html(W.filename(), 'admin')
     1788            '\n<!D...ipt type="text/javascript">worksheet_locked=false;</script>\n\n\n\n    </body>\n</html>'
    17891789        """
    17901790        if worksheet_filename is None or worksheet_filename == '':
    17911791            worksheet_filename = None
     
    18251825       
    18261826            sage: nb = sage.server.notebook.notebook.Notebook(tmp_dir())
    18271827            sage: W = nb.create_new_worksheet('Test', 'admin')
    1828             sage: nb.html('admin', W)
     1828            sage: nb.html_worksheet_settings(W, 'admin')
    18291829            '\n<!D...lue="Cancel" name="button_cancel"/></span>\n<br /><br /><br />\n\n</form>\n\n\n    </body>\n</html>'
    18301830        """
    18311831        return template("notebook/worksheet_settings.html", worksheet = ws,
     
    18631863       
    18641864            sage: nb = sage.server.notebook.notebook.Notebook(tmp_dir())
    18651865            sage: W = nb.create_new_worksheet('Test', 'admin')
    1866             sage: nb.html('admin', W)
     1866            sage: nb.html_doc('admin')
    18671867            '\n<!D...c Documentation</a><br /><br />\n        <a href="/help/">Sage Notebook Howto...   </body>\n</html>'
    18681868        """
    18691869        return template("notebook/doc.html", username = username,
  • sage/server/notebook/templates/afterpublish_window.html

    diff -r 5c624a40c5eb -r 70c794ffda2d sage/server/notebook/templates/afterpublish_window.html
    a b  
    1414
    1515{% set checked = 'checked="true"' if worksheet.is_auto_publis() else '' %}
    1616
    17 {% set title = 'Worksheet is publicly viewable at <a href="%s" style="color:#FFF" target="_blank">%s</a><br />Published on %s<br/><br /><input type="button" value="Re-publish worksheet" onClick="parent.location=\\\'?re\'"><input type="button" value="Stop publishing" style="margin-left:5px" onClick="parent.location=\\\'?stop\'"><br /><br /><input type="checkbox" name="auto"%s onchange="parent.location=\\\'?auto\'"/> Automatically re-publish when changes are made'|format(url, url, time, checked) %}
     17{% set title = 'Worksheet is publicly viewable at <a href="%s" style="color:#FFF" target="_blank">%s</a><br />Published on %s<br/><br /><input type="button" value="Re-publish worksheet" onClick="parent.location=\'?re\'"><input type="button" value="Stop publishing" style="margin-left:5px" onClick="parent.location=\'?stop\'"><br /><br /><input type="checkbox" name="auto"%s onchange="parent.location=\'?auto\'"/> Automatically re-publish when changes are made'|format(url, url, time, checked) %}
    1818{% set select = "publish" %}
    1919{% set backwards = true %}
     20 No newline at end of file
  • sage/server/notebook/templates/doc.html

    diff -r 5c624a40c5eb -r 70c794ffda2d sage/server/notebook/templates/doc.html
    a b  
    1616{{ common_title(worksheet_filename, worksheet) }}
    1717{% endblock %}
    1818   
    19 {% block css %}
    20 main
    21 {% endblock %}
     19{% block css %}main{% endblock %}
    2220
    2321{% block javascript %}
    2422{{ common_javascript(worksheet, worksheet_filename, username, JSMATH, JSMATH_IMAGE_FONTS, JEDITABLE_TINYMCE, sage_jsmath_macros) }}
  • sage/server/notebook/templates/index.html

    diff -r 5c624a40c5eb -r 70c794ffda2d sage/server/notebook/templates/index.html
    a b  
    2727{{ common_title(worksheet_filename, worksheet) }}
    2828{% endblock %}
    2929   
    30 {% block css %}
    31 main
    32 {% endblock %}
     30{% block css %}main{% endblock %}
    3331
    3432{% block javascript %}
    3533{{ common_javascript(worksheet, worksheet_filename, username, JSMATH, JSMATH_IMAGE_FONTS, JEDITABLE_TINYMCE, sage_jsmath_macros) }}
  • sage/server/notebook/templates/notebook/afterpublish_window.html

    diff -r 5c624a40c5eb -r 70c794ffda2d sage/server/notebook/templates/notebook/afterpublish_window.html
    a b  
    1313- sage_jsmath_macros - an array containing strings of Javascript of Sage macros for jsMath
    1414#}
    1515
    16 {% set checked = 'checked="true"' if worksheet.is_auto_publis() else '' %}
     16{% set checked = 'checked="true"' if worksheet.is_auto_publish() else '' %}
    1717
    18 {% set title = 'Worksheet is publicly viewable at <a href="%s" style="color:#FFF" target="_blank">%s</a><br />Published on %s<br/><br /><input type="button" value="Re-publish worksheet" onClick="parent.location=\\\'?re\'"><input type="button" value="Stop publishing" style="margin-left:5px" onClick="parent.location=\\\'?stop\'"><br /><br /><input type="checkbox" name="auto"%s onchange="parent.location=\\\'?auto\'"/> Automatically re-publish when changes are made'|format(url, url, time, checked) %}
     18{% set title = 'Worksheet is publicly viewable at <a href="%s" style="color:#FFF" target="_blank">%s</a><br />Published on %s<br/><br /><input type="button" value="Re-publish worksheet" onClick="parent.location=\'?re\'"><input type="button" value="Stop publishing" style="margin-left:5px" onClick="parent.location=\'?stop\'"><br /><br /><input type="checkbox" name="auto" %s onchange="parent.location=\'?auto\'"/> Automatically re-publish when changes are made'|format(url, url, time, checked) %}
    1919{% set select = "publish" %}
    2020{% set backwards = true %}
     21 No newline at end of file
  • sage/server/notebook/templates/notebook/doc.html

    diff -r 5c624a40c5eb -r 70c794ffda2d sage/server/notebook/templates/notebook/doc.html
    a b  
    1717{{ common_title(worksheet_filename, worksheet) }}
    1818{% endblock %}
    1919   
    20 {% block css %}
    21 main
    22 {% endblock %}
     20{% block css %}main{% endblock %}
    2321
    2422{% block javascript %}
    2523{{ common_javascript(worksheet, worksheet_filename, username, JSMATH, JSMATH_IMAGE_FONTS, JEDITABLE_TINYMCE, sage_jsmath_macros) }}
  • sage/server/notebook/templates/notebook/guest_top_bar_and_worksheet.html

    diff -r 5c624a40c5eb -r 70c794ffda2d sage/server/notebook/templates/notebook/guest_top_bar_and_worksheet.html
    a b  
    2525&nbsp;&nbsp;<span class="ratingmsg">
    2626    {% if worksheet.rating() != -1 %}
    2727        <a class="usercontrol" href="rating_info">
    28             This page is rated {{ "%.1f"|format("worksheet.rating()") }}.
     28            This page is rated {{ "%.1f"|format(worksheet.rating()) }}.
    2929        </a>
    3030    {% endif %}
    3131    {% if not notebook.user_is_guest(username)
    3232        and not worksheet.is_publisher(username) %}
    3333        &nbsp;&nbsp;
    3434        <span class="usercontrol">
    35             {{ "Rerate" if worksheet.is_rater(username) else "Rate" }}
     35            {{ "Rerate" if worksheet.is_rater(username) else "Rate" }} it:
    3636        </span>
    3737        {% for i in range(5) %}
    3838            <a class="usercontrol"
  • sage/server/notebook/templates/notebook/index.html

    diff -r 5c624a40c5eb -r 70c794ffda2d sage/server/notebook/templates/notebook/index.html
    a b  
    2727{{ common_title(worksheet_filename, worksheet) }}
    2828{% endblock %}
    2929   
    30 {% block css %}
    31 main
    32 {% endblock %}
     30{% block css %}main{% endblock %}
    3331
    3432{% block javascript %}
    3533{{ common_javascript(worksheet, worksheet_filename, username, JSMATH, JSMATH_IMAGE_FONTS, JEDITABLE_TINYMCE, sage_jsmath_macros) }}
     
    5452{% else %}
    5553    <script type="text/javascript">worksheet_locked=false;</script>
    5654{% endif %}
    57    
    5855{% if worksheet.computing() %}
    5956    <!-- Set the update checking back in motion. -->
    6057    <script type="text/javascript">
  • sage/server/notebook/templates/notebook/specific_revision.html

    diff -r 5c624a40c5eb -r 70c794ffda2d sage/server/notebook/templates/notebook/specific_revision.html
    a b  
    3333{% endif %}
    3434
    3535<a class="listcontrol" href="revisions?rev={{ rev }}&action=revert">Revert to this one</a> <span class="lastedit">(note that images are not recorded)</span>&nbsp;&nbsp;
    36 <a class="listcontrol" href="reviisons?rev={{ rev }}&action=publis">Publish this one</a>&nbsp;&nbsp;
     36<a class="listcontrol" href="revisions?rev={{ rev }}&action=publish">Publish this one</a>&nbsp;&nbsp;
    3737{% endmacro %}
    3838
    3939{% block body_addition %}
  • sage/server/notebook/templates/notebook/worksheet.html

    diff -r 5c624a40c5eb -r 70c794ffda2d sage/server/notebook/templates/notebook/worksheet.html
    a b  
    88
    99{% block title %}Sage Worksheet: {{ worksheet_name }}{% endblock %}
    1010
     11{% block css %}main{% endblock %}
     12
    1113{% block javascript %}
    1214<script type="text/javascript" src="/javascript_local/jquery/jquery.js"></script>
    1315<script type="text/javascript" src="/javascript/main.js"></script>
  • sage/server/notebook/templates/notebook/worksheet_page_template.html

    diff -r 5c624a40c5eb -r 70c794ffda2d sage/server/notebook/templates/notebook/worksheet_page_template.html
    a b  
    2929{{ common_title(worksheet_filename, worksheet) }}
    3030{% endblock %}
    3131   
    32 {% block css %}
    33 main
    34 {% endblock %}
     32{% block css %}main{% endblock %}
    3533
    3634{% block javascript %}
    3735{{ common_javascript(worksheet, worksheet_filename, username, JSMATH, JSMATH_IMAGE_FONTS, JEDITABLE_TINYMCE, sage_jsmath_macros) }}
  • sage/server/notebook/templates/worksheet/published_worksheet.html

    diff -r 5c624a40c5eb -r 70c794ffda2d sage/server/notebook/templates/worksheet/published_worksheet.html
    a b  
    22INPUT:
    33- cell_id_list - a list of cell id's
    44- cells_html - string of cells HTML
     5- do_print - a boolean
    56#}
    6 {% include "worksheet/worksheet_body.html" %}
    7 
    87{% set published = true %}
    98{% set do_print = true %}
    109
     10{% include "worksheet/worksheet_body.html" %}
     11
     12
    1113<script language=javascript>jsMath.ProcessBeforeShowing();</script>
  • sage/server/notebook/templates/worksheet/worksheet_body.html

    diff -r 5c624a40c5eb -r 70c794ffda2d sage/server/notebook/templates/worksheet/worksheet_body.html
    a b  
    11{#
    22INPUT:
    3 - do_print - a boolean
    43- cells_html - string of cells HTML
    54- published - a boolean stating whether the worksheet is published
    65#}
     6
    77<div class="cell_input_active" id="cell_resizer"></div>
    88{% if not published %}
    99<div class="worksheet_cell_list" id="worksheet_cell_list">
     
    1919        $("#insert_last_cell").shiftclick(function(e) {insert_new_text_cell_after(cell_id_list[cell_id_list.length-1]);});
    2020</script>
    2121<div class="worksheet_bottom_padding"></div>
    22 {% endif %}
    23  No newline at end of file
     22{% endif %}
     23
  • sage/server/notebook/worksheet.py

    diff -r 5c624a40c5eb -r 70c794ffda2d sage/server/notebook/worksheet.py
    a b  
    22292229        """
    22302230        ncols = self.notebook().conf()['word_wrap_cols']
    22312231        cells_html = ""
    2232         for cell in self.cell_list():
    2233             cells_html += cell.html(ncols, do_print=do_print) + '\n'
    22342232        if self.is_published():
    22352233            try:
    22362234                return self.__html
    22372235            except AttributeError:
     2236                for cell in self.cell_list():
     2237                    cells_html += cell.html(ncols, do_print=True) + '\n'
    22382238                s = template("worksheet/published_worksheet.html", ncols = ncols,
    22392239                             cells_html = cells_html)
    22402240                self.__html = s
    22412241                return s
     2242        for cell in self.cell_list():
     2243            cells_html += cell.html(ncols, do_print=do_print) + '\n'
    22422244           
    22432245        return template("worksheet/worksheet.html", published = self.is_published(),
    22442246                        do_print = do_print, confirm_before_leave = confirm_before_leave,
     
    22802282            sage: nb = sage.server.notebook.notebook.Notebook(tmp_dir())
    22812283            sage: W = nb.create_new_worksheet('Test', 'admin')
    22822284            sage: W.html_save_discard_buttons()
    2283             '\n\n\n<button name="button_save" title="Save changes" onClick="save_worksheet();">Save<...'
     2285            '\n\n<button name="button_save" title="Save changes" onClick="save_worksheet();">Save<...'
    22842286        """
    22852287        return template("worksheet/save_discard_buttons.html", doc_worksheet = self.is_doc_worksheet())
    22862288