Ticket #6568: sage-trac-6568.2.patch

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

Migrated worksheet.py to Jinja. Added doctests. Removed html_slide_controls. Incremental patch from the first patch.

  • sage/server/notebook/notebook.py

    # HG changeset patch
    # User Tim Dumol <tim@timdumol.com>
    # Date 1248788034 -28800
    # Node ID 5c624a40c5ebb4a5c4c5b28f41dcbd61f0697c2a
    # Parent  95f3679a5a9d3572700acc8e74421707433bec73
    * Completed migration of worksheet.py to Jinja and added doctests
    ** worksheet.html
    ** worksheet.html_title
    ** worksheet.html_share_publish_buttons
    ** worksheet.html_menu
    ** worksheet.html_worksheet_body
    ** worksheet.time_since_last_edited
    ** worksheet.attached_html
    ** worksheet.format_completions_as_html
    * Changed template directory scheme from a flat to nested tree
    * Removed unused functions:
    ** notebook.html_system_select_form_element
    ** notebook.html_pretty_print_check_form_element
    ** notebook.html_slide_controls
    ** notebook.html_worksheet_page_template
    ** notebook._html_head
    ** notebook.html_worksheet_topbar
    ** notebook._html_body
    
    diff -r 95f3679a5a9d -r 5c624a40c5eb sage/server/notebook/notebook.py
    a b  
    169169        # quickly, etc.
    170170        shutil.rmtree(dir, ignore_errors=True)
    171171
     172    def systems(self):
     173        return SYSTEMS
     174
     175    def system_names(self):
     176        return SYSTEM_NAMES
    172177    ##########################################################
    173178    # Users
    174179    ##########################################################
     
    910915            return MAX_HISTORY_LENGTH
    911916       
    912917    def history_html(self):
    913         return template("command_history.html", history_text = escape(self.history_text()))
     918        return template("notebook/command_history.html", history_text = escape(self.history_text()))
    914919
    915920       
    916921    def history_with_start(self, start):
     
    11731178        """
    11741179        worksheet = self.get_worksheet_with_filename(filename)
    11751180        text = worksheet.plain_text(prompts = prompts)
    1176         return template("plain_text_worksheet.html",
     1181        return template("notebook/plain_text_worksheet.html",
    11771182                        worksheet_name = worksheet.name(),
    11781183                        worksheet_plain_text = escape(worksheet.plain_text(prompts = prompts)))
    11791184
     
    13041309        return s
    13051310
    13061311    def worksheet_html(self, filename, do_print=False):
     1312        """
     1313        Returns the HTML for the worksheet.
     1314
     1315        INPUT:
     1316        - ``username`` - a string
     1317        - ``worksheet`` - an instance of Worksheet
     1318
     1319        OUTPUT:
     1320        - a string containing the HTML
     1321
     1322        EXAMPLES::
     1323       
     1324            sage: nb = sage.server.notebook.notebook.Notebook(tmp_dir())
     1325            sage: W = nb.create_new_worksheet('Test', 'admin')
     1326            sage: nb.worksheet_html('admin', W)
     1327            '\n<!D...ript type="text/javascript">cell_id_list=[0];</script>\n\n\n\n\n\n    </body>\n</html>'
     1328        """
    13071329        worksheet = self.get_worksheet_with_filename(filename)
    1308         return template("worksheet.html", worksheet_name = worksheet.name(),
     1330        return template("notebook/worksheet.html", worksheet_name = worksheet.name(),
    13091331                 worksheet_html = worksheet.html(include_title=False, do_print=do_print))
    13101332
    13111333   
     
    13321354        sort_worksheet_list(W, sort, reverse)  # changed W in place
    13331355        return W
    13341356
    1335     def html_topbar(self, user, pub=False):
    1336         return template("top_bar.html", user = user, pub = pub,
    1337                         notebook = self)
    1338    
    1339 
    13401357    ##########################################################
    13411358    # Revision history for a worksheet
    13421359    ##########################################################
     
    13501367
    13511368        OUTPUT:
    13521369        - a string containing the HTML
     1370
     1371        EXAMPLES::
     1372       
     1373            sage: nb = sage.server.notebook.notebook.Notebook(tmp_dir())
     1374            sage: W = nb.create_new_worksheet('Test', 'admin')
     1375            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>'
    13531377        """
    13541378        data = worksheet.snapshot_data()  # pairs ('how long ago', key)
    13551379
    1356         return template("worksheet_revision_list.html", data = data,
     1380        return template("notebook/worksheet_revision_list.html", data = data,
    13571381                        worksheet = worksheet,
    13581382                        worksheet_filename = worksheet.filename(),
    13591383                        username = username,
     
    13961420                    next_rev = data[i+1][1]
    13971421                break
    13981422           
    1399         return template("specific_revision.html", worksheet = ws,
     1423        return template("notebook/specific_revision.html", worksheet = ws,
    14001424                        worksheet_filename = ws.filename(),
    14011425                        username = username, rev = rev,
    14021426                        prev_rev = prev_rev, next_rev = next_rev,
     
    14061430                        JSMATH_IMAGE_FONTS = JSMATH_IMAGE_FONTS,
    14071431                        JEDITABLE_TINYMCE = JEDITABLE_TINYMCE,
    14081432                        sage_jsmath_macros = sage_jsmath_macros)
    1409 
    1410     # TODO: Make obsolete
    1411     def html_worksheet_page_template(self, worksheet, username, title, select=None, backwards=False):
    1412         head = self._html_head(worksheet_filename=worksheet.filename(), username=username)
    1413         body = self._html_body(worksheet.filename(), top_only=True, username=username)
    1414         body += self.html_worksheet_topbar(worksheet, select=select, username=username, backwards=backwards)
    1415         body += '<hr class="usercontrol">'
    1416         body += '<span class="sharebar">%s</span>'%title
    1417         body += '<br>'*3
    1418         return head, body
    14191433       
    14201434
    14211435    def html_share(self, worksheet, username):
     
    14281442
    14291443        OUTPUT:
    14301444        - a string containing the HTML
     1445       
     1446        EXAMPLES::
     1447       
     1448            sage: nb = sage.server.notebook.notebook.Notebook(tmp_dir())
     1449            sage: W = nb.create_new_worksheet('Test', 'admin')
     1450            sage: nb.html_worksheet_revision_list('admin', W)
     1451            '\n<!D...span class="username">Sage Users:</span>\n<span class="users">\n    \n</span>\n\n\n\n    </body>\n</html>'
    14311452        """
    1432         head, body = self.html_worksheet_page_template(worksheet, username, "Share this document", select="share")
    14331453        U = self.users()
    14341454        other_users = [x for x, u in U.iteritems() if not u.is_guest() and not u.username() in [username, 'pub', '_sage_']]
    14351455        other_users.sort(lambda x,y: cmp(x.lower(), y.lower()))
    14361456
    1437         return template("worksheet_share.html", worksheet = worksheet,
     1457        return template("notebook/worksheet_share.html", worksheet = worksheet,
    14381458                        worksheet_filename = worksheet.filename(),
    14391459                        username = username, other_users = other_users,
    14401460                        user_is_admin = self.user(username).is_admin(),
     
    14551475
    14561476        OUTPUT:
    14571477        - a string containing the HTML
     1478
     1479        EXAMPLES::
     1480       
     1481            sage: nb = sage.server.notebook.notebook.Notebook(tmp_dir())
     1482            sage: W = nb.create_new_worksheet('Test', 'admin')
     1483            sage: nb.html_download_or_delete_datafile(W, 'admin', 'bar')
     1484            '\n<!D...ploaded to this worksheet.</p>\n\n<hr class="usercontrol" />\n\n\n\n\n    </body>\n</html>'
    14581485        """
    14591486        path = "/home/%s/data/%s"%(ws.filename(), filename)
    14601487
    14611488        worksheets = self.get_worksheets_with_viewer(username)
    1462         active_worksheets = [x for x in X if x.is_active(username)]
     1489        active_worksheets = [worksheet for worksheet in worksheets if worksheet.is_active(username)]
    14631490        sort_worksheet_list(active_worksheets, 'name', False)
    14641491       
    14651492        ext = os.path.splitext(filename)[1].lower()
     1493        file_is_image, file_is_text = False, False
     1494        text_file_content = ""
     1495       
    14661496        if ext in ['.png', '.jpg', '.gif']:
    14671497            file_is_image = True
    14681498        if ext in ['.txt', '.tex', '.sage', '.spyx', '.py', '.f', '.f90', '.c']:
    14691499            file_is_text = True
    14701500            text_file_content = open('%s/%s'%(ws.data_directory(), filename)).read()
    14711501
    1472         return template("download_or_delete_datafile.html",
     1502        return template("notebook/download_or_delete_datafile.html",
    14731503                        worksheet = ws,
    14741504                        worksheet_filename = ws.filename(),
    14751505                        username = username,
    14761506                        active_worksheets = active_worksheets,
    1477                         filename = filename,
     1507                        filename_ = filename,
    14781508                        path = path,
    14791509                        file_is_image = file_is_image,
    14801510                        file_is_text = file_is_text,
     
    15811611    ###########################################################
    15821612    # HTML -- generate most html related to the whole notebook page
    15831613    ###########################################################
    1584     def html_slide_controls(self):
    1585         return template("slide_controls.html")
    1586 
    15871614    def html_debug_window(self):
    15881615        """
    15891616Returns the HTML for the debug window 
    1590 DEPRECATED
    15911617
    15921618OUTPUT:
    15931619- the HTML for the debug window
     
    16021628                  onFocus='debug_focus();' onBlur='debug_blur();'></textarea>
    16031629    </div>
    16041630        """
    1605         return template("debug_window.html")
     1631        return template("notebook/debug_window.html")
    16061632
    16071633   
    1608     def _html_head(self, worksheet_filename, username):
    1609         worksheet = self.get_worksheet_with_filename(worksheet_filename)
    1610         return template("head.html", worksheet = worksheet,
    1611                         worksheet_filename = worksheet_filename,
    1612                         username = username, JSMATH = JSMATH,
    1613                         JSMATH_IMAGE_FONTS = JSMATH_IMAGE_FONTS,
    1614                         JEDITABLE_TINYMCE = JEDITABLE_TINYMCE,
    1615                         sage_jsmath_macros = sage_jsmath_macros)
    1616 
    1617     def html_worksheet_topbar(self, worksheet, select=None, username='guest', backwards=False):
    1618         """
    1619 Returns the HTML for the topbar of a worksheet
    1620 
    1621 DEPRECATED
    1622 
    1623 INPUT:
    1624 -   worksheet - a Worksheet instance
    1625 -   select    - a string
    1626 -   username  - a string of a username
    1627 -   backwards - a boolean
    1628 
    1629 OUTPUT:
    1630 -   html - the HTML for the topbar of a worksheet
    1631         """
    1632         body = ''
    1633         body += """
    1634 <table width="100%%" id="topbar">
    1635 <tr>
    1636   <td align=left> %s </td>   <td align=right> %s </td>
    1637 </tr>
    1638 <tr>
    1639   <td align=left> %s </td>   <td align=right> %s </td>
    1640 </tr>
    1641 </table>
    1642 """%(worksheet.html_title(username), worksheet.html_save_discard_buttons(),
    1643      worksheet.html_menu(), worksheet.html_share_publish_buttons(select=select, backwards=backwards))
    1644        
    1645         body += self.html_slide_controls()
    1646         return body
    1647 
    1648 
    1649     def _html_body(self, worksheet_filename, show_debug=False, username='', top_only=False):
    1650         worksheet = self.get_worksheet_with_filename(worksheet_filename)
    1651         worksheet_html = worksheet.html()
    1652 
    1653         return template("worksheet_body.html", username = username,
    1654                             worksheet = worksheet, top_only = top_only,
    1655                             worksheet_filename = worksheet_filename,
    1656                             worksheet_html = worksheet_html,
    1657                             notebook = self, show_debug = self.__show_debug or show_debug)
    1658 
    16591634    def html_plain_text_window(self, worksheet, username):
    16601635        """
    1661         Return a window that displays a plain text version of the
     1636        Returns a window that displays a plain text version of the
    16621637        worksheet
    16631638       
    16641639        INPUT:
     1640        -  ``worksheet`` - a worksheet
     1641        -  ``username`` - name of the user
     1642
     1643        OUTPUT:
     1644        - a window that displays a plain text version of the
     1645        worksheet
    16651646       
     1647        EXAMPLES::
    16661648       
    1667         -  ``worksheet`` - a worksheet
    1668        
    1669         -  ``username`` - name of the user
     1649            sage: nb = sage.server.notebook.notebook.Notebook(tmp_dir())
     1650            sage: W = nb.create_new_worksheet('Test', 'admin')
     1651            sage: nb.html_plain_text_window('admin', W)
     1652            '\n<!D...>\n\n<pre class="plaintext" id="cell_intext" name="textfield"></pre>\n\n\n    </body>\n</html>'
    16701653        """
    16711654        plain_text = worksheet.plain_text(prompts=True, banner=False)
    16721655        plain_text = escape(plain_text).strip()
    16731656         
    1674         return template("plain_text_window.html", worksheet = worksheet,
     1657        return template("notebook/plain_text_window.html", worksheet = worksheet,
    16751658                        worksheet_filename = worksheet.filename(),
    16761659                        username = username,
    16771660                        plain_text = plain_text, JSMATH = JSMATH,
     
    16861669        INPUT:
    16871670        - ``username`` - a string containing the username
    16881671        - ``worksheet`` - a Worksheet instance
     1672
     1673        OUTPUT:
     1674        - html for a window for editing ``worksheet``.
     1675
     1676        EXAMPLES::
     1677       
     1678            sage: nb = sage.server.notebook.notebook.Notebook(tmp_dir())
     1679            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>''
    16891682        """
    16901683        text = worksheet.edit_text()
    16911684        text = escape(text)
    16921685        n_lines = text.count("\n")+1
    16931686         
    1694         return template("edit_window.html", worksheet = worksheet,
     1687        return template("notebook/edit_window.html", worksheet = worksheet,
    16951688                        worksheet_filename = worksheet.filename(),
    16961689                        username = username, text = text,
    16971690                        n_lines = n_lines, JSMATH = JSMATH,
     
    17071700        INPUT:
    17081701        - ``worksheet`` - instance of Worksheet
    17091702        - ``username`` - string
     1703
     1704        EXAMPLES::
     1705       
     1706            sage: nb = sage.server.notebook.notebook.Notebook(tmp_dir())
     1707            sage: W = nb.create_new_worksheet('Test', 'admin')
     1708            sage: nb.html_before_publish_window('admin', W)
     1709            '\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.
    17121712        Your worksheet will be assigned a unique address (URL) that you can send to your friends and colleagues.<br/><br/>
     
    17181718        <input type="checkbox" name="auto" style="margin-left:13px" /> Automatically re-publish when changes are made
    17191719        </form>
    17201720        """
    1721         head, body = self.html_worksheet_page_template(worksheet, username, msg, select="publish", backwards=True)
    1722        
    1723         return template("beforepublish_window.html", worksheet = worksheet,
     1721        return template("notebook/beforepublish_window.html", worksheet = worksheet,
    17241722                        worksheet_filename = worksheet.filename(),
    17251723                        username = username, JSMATH = JSMATH,
    17261724                        JSMATH_IMAGE_FONTS = JSMATH_IMAGE_FONTS,
     
    17411739        from time import strftime
    17421740        time = strftime("%B %d, %Y %I:%M %p", dtime)
    17431741       
    1744         return template("afterpublish_window.html", worksheet = worksheet,
     1742        return template("notebook/afterpublish_window.html", worksheet = worksheet,
    17451743                        worksheet_filename = worksheet.filename(),
    17461744                        username = username, url = url,
    17471745                        time = time, JSMATH = JSMATH,
     
    17561754        INPUT:
    17571755        - ``worksheet`` - instance of Worksheet
    17581756        - ``username`` - string
     1757
     1758        EXAMPLES::
     1759       
     1760            sage: nb = sage.server.notebook.notebook.Notebook(tmp_dir())
     1761            sage: W = nb.create_new_worksheet('Test', 'admin')
     1762            sage: nb.html_upload_data_window('admin', W)
     1763            '\n<!D...orksheet_menu" value="Upload File" onClick="form.submit()...r />\n</div>\n\n\n    </body>\n</html>'
    17591764        """
    1760         return template("upload_data_window.html", worksheet = worksheet,
    1761                         worksheet_filename = worksheet.filename(),
     1765        return template("notebook/upload_data_window.html", worksheet = worksheet,
     1766                        worksheet_filename = ws.filename(),
    17621767                        username = username, JSMATH = JSMATH,
    17631768                        JSMATH_IMAGE_FONTS = JSMATH_IMAGE_FONTS,
    17641769                        JEDITABLE_TINYMCE = JEDITABLE_TINYMCE,
     
    17741779        - ``username`` - a string
    17751780        - ``show_debug`` - a boolean
    17761781        - ``admin`` - a boolean
     1782
     1783        EXAMPLES::
     1784       
     1785            sage: nb = sage.server.notebook.notebook.Notebook(tmp_dir())
     1786            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>'
    17771789        """
    17781790        if worksheet_filename is None or worksheet_filename == '':
    17791791            worksheet_filename = None
     
    17841796            except KeyError:
    17851797                W = None
    17861798
    1787         return template("index.html", worksheet = W,
     1799        return template("notebook/index.html", worksheet = W,
    17881800                        worksheet_filename = W.filename(),
    17891801                        worksheet_html = W.html(),
    17901802                        notebook = self, username = username,
     
    17991811    # In each case the settings html is a form that when submitted
    18001812    # pulls up another web page and sets the corresponding options.
    18011813    ####################################################################
    1802     def html_system_select_form_element(self, ws):
    1803         system = ws.system()
    1804         options = ''
    1805         i = SYSTEM_NAMES.index(system)
    1806         for j, S in enumerate(SYSTEMS):
    1807             if i == j:
    1808                 selected = "selected"
    1809             else:
    1810                 selected = ''
    1811             T = SYSTEM_NAMES[j]
    1812             options += '<option title="Evaluate all input cells using %s" %s value="%s">%s</option>\n'%(T, selected, T,S)
    1813         s = """<select  onchange="go_system_select(this, %s);" class="worksheet">
    1814             %s
    1815             </select>"""%(i, options)
    1816         return s
    1817    
    1818     def html_pretty_print_check_form_element(self, ws):
    1819         pretty_print = ws.pretty_print()
    1820         if pretty_print:
    1821             check='checked="checked"'
    1822         else:
    1823             check=''
    1824         s = """<input type="checkbox" title="Enable/disable pretty_printing"
    1825         onchange="pretty_print_check(this.checked);"
    1826         class="worksheet" value="pretty_print" %s>&nbsp;Typeset"""%(check)
    1827         return s
    18281814
    18291815
    18301816    def html_worksheet_settings(self, ws, username):
    1831         head, body = self.html_worksheet_page_template(ws, username, 'Worksheet Settings &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<button name="button_save">Save Settings</button>  <input type="submit" value="Cancel" name="button_cancel"/>')
     1817        """
     1818        Returns the html for the setings page of the worksheet.
     1819       
     1820        INPUT:
     1821        - ``ws`` - instance of Worksheet
     1822        - ``username`` - string
    18321823
    1833         body = '<form width=70%% method="post" action="input_settings"  enctype="multipart/form-data">' + body
    1834         body += '</form>'
    1835            
    1836         return template("worksheet_settings.html", worksheet = ws,
     1824        EXAMPLES::
     1825       
     1826            sage: nb = sage.server.notebook.notebook.Notebook(tmp_dir())
     1827            sage: W = nb.create_new_worksheet('Test', 'admin')
     1828            sage: nb.html('admin', W)
     1829            '\n<!D...lue="Cancel" name="button_cancel"/></span>\n<br /><br /><br />\n\n</form>\n\n\n    </body>\n</html>'
     1830        """
     1831        return template("notebook/worksheet_settings.html", worksheet = ws,
    18371832                        worksheet_filename = ws.filename(),
    18381833                        username = username, JSMATH = JSMATH,
    18391834                        JSMATH_IMAGE_FONTS = JSMATH_IMAGE_FONTS,
     
    18551850        return s
    18561851
    18571852    def html_doc(self, username):
    1858         top = self._html_head(None, username) + self.html_topbar(username)
     1853        """
     1854        Returns the html for the documentation pages.
    18591855       
    1860         return template("doc.html", username = username,
     1856        INPUT:
     1857        - ``worksheet_filename`` - a string
     1858        - ``username`` - a string
     1859        - ``show_debug`` - a boolean
     1860        - ``admin`` - a boolean
     1861
     1862        EXAMPLES::
     1863       
     1864            sage: nb = sage.server.notebook.notebook.Notebook(tmp_dir())
     1865            sage: W = nb.create_new_worksheet('Test', 'admin')
     1866            sage: nb.html('admin', W)
     1867            '\n<!D...c Documentation</a><br /><br />\n        <a href="/help/">Sage Notebook Howto...   </body>\n</html>'
     1868        """
     1869        return template("notebook/doc.html", username = username,
    18611870                        JSMATH = JSMATH,
    18621871                        JSMATH_IMAGE_FONTS = JSMATH_IMAGE_FONTS,
    18631872                        JEDITABLE_TINYMCE = JEDITABLE_TINYMCE,
  • sage/server/notebook/templates/account_recovery.html

    diff -r 95f3679a5a9d -r 5c624a40c5eb sage/server/notebook/templates/account_recovery.html
    a b  
     1
    12{% extends "base.html" %}
    23
    34{% block title %}Account Recovery{% endblock %}
  • sage/server/notebook/templates/account_settings.html

    diff -r 95f3679a5a9d -r 5c624a40c5eb sage/server/notebook/templates/account_settings.html
    a b  
     1
    12{% extends "base.html" %}
    23
    34{% block title %}Account Settings{% endblock %}
  • sage/server/notebook/templates/banner.html

    diff -r 95f3679a5a9d -r 5c624a40c5eb sage/server/notebook/templates/banner.html
    a b  
     1
    12<div class="banner">
    23  <table width="100%">
    34    <tr>
  • sage/server/notebook/templates/base.html

    diff -r 95f3679a5a9d -r 5c624a40c5eb sage/server/notebook/templates/base.html
    a b  
     1
    12<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN">
    23<html lang="en">
    34    <head>
  • sage/server/notebook/templates/base_authenticated.html

    diff -r 95f3679a5a9d -r 5c624a40c5eb sage/server/notebook/templates/base_authenticated.html
    a b  
     1
    12{% extends "base.html" %}
    23
    34{% block css %}main{% endblock %}
  • sage/server/notebook/templates/command_history.html

    diff -r 95f3679a5a9d -r 5c624a40c5eb sage/server/notebook/templates/command_history.html
    a b  
    1 <!--
    2     INPUT:
     1
     2{#
     3INPUT:
    34    - history_text - a string containing the history text of the notebook
    4 -->
     5#}
    56<html>
    67    <head>
    78        <title>Command History</title>
  • sage/server/notebook/templates/error_message.html

    diff -r 95f3679a5a9d -r 5c624a40c5eb sage/server/notebook/templates/error_message.html
    a b  
     1
    12{% extends "base.html" %}
    23
    34{% block title %}Error{% endblock %}
    45
    5 {% block content %}
     6{% block body %}
    67<br><a class="usercontrol" href="/">Home</a>
    78<hr class="usercontrol">
    89<br/><br/>
  • sage/server/notebook/templates/history.html

    diff -r 95f3679a5a9d -r 5c624a40c5eb sage/server/notebook/templates/history.html
    a b  
     1
    12{% extends "base.html" %}
    23
    34{% block title %}Sage: History for {{username}} {% endblock %}
  • sage/server/notebook/templates/list_top.html

    diff -r 95f3679a5a9d -r 5c624a40c5eb sage/server/notebook/templates/list_top.html
    a b  
     1
    12{% include 'top_bar.html' %}
    23
    34
  • sage/server/notebook/templates/login.html

    diff -r 95f3679a5a9d -r 5c624a40c5eb sage/server/notebook/templates/login.html
    a b  
     1
    12{% extends "base.html" %}
    23
    34{% block title %}Sign in{% endblock %}
  • new file sage/server/notebook/templates/notebook/afterpublish_window.html

    diff -r 95f3679a5a9d -r 5c624a40c5eb sage/server/notebook/templates/notebook/afterpublish_window.html
    - +  
     1
     2{% extends "notebook/worksheet_page_template.html" %}
     3{#
     4INPUT:
     5- worksheet - an instance of Worksheet
     6- worksheet_filename - a string containing a worksheet's filename
     7- username - a string containing a username
     8- url - a string containing the url of the published page
     9- time - a string representing the time of publication
     10- JSMATH - a boolean stating whether to include jsMath
     11- JSMATH_IMAGE_FONTS - a boolean stating whether to include jsMath iamage fonts
     12- 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
     14#}
     15
     16{% set checked = 'checked="true"' if worksheet.is_auto_publis() else '' %}
     17
     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) %}
     19{% set select = "publish" %}
     20{% set backwards = true %}
     21 No newline at end of file
  • new file sage/server/notebook/templates/notebook/beforepublish_window.html

    diff -r 95f3679a5a9d -r 5c624a40c5eb sage/server/notebook/templates/notebook/beforepublish_window.html
    - +  
     1
     2{% extends "notebook/worksheet_page_template.html" %}
     3{#
     4INPUT:
     5- worksheet - an instance of Worksheet
     6- worksheet_filename - a string containing a worksheet's filename
     7- username - a string containing a username
     8- JSMATH - a boolean stating whether to include jsMath
     9- JSMATH_IMAGE_FONTS - a boolean stating whether to include jsMath iamage fonts
     10- 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
     12#}
     13
     14{% 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>' %}
     15{% set select = "publish" %}
     16{% set backwards = true %}
     17 No newline at end of file
  • new file sage/server/notebook/templates/notebook/debug_window.html

    diff -r 95f3679a5a9d -r 5c624a40c5eb sage/server/notebook/templates/notebook/debug_window.html
    - +  
     1
     2<div class='debug_window'>
     3    <div class='debug_output'><pre id='debug_output'></pre></div>
     4    <textarea rows=5 id='debug_input' class='debug_input'
     5              onKeyPress='return debug_keypress(event);'
     6              onFocus='debug_focus();' onBlur='debug_blur();'></textarea>
     7</div>
     8 No newline at end of file
  • new file sage/server/notebook/templates/notebook/doc.html

    diff -r 95f3679a5a9d -r 5c624a40c5eb sage/server/notebook/templates/notebook/doc.html
    - +  
     1
     2{% extends "base.html" %}
     3{#
     4INPUT:
     5- worksheet - an instance of Worksheet
     6- worksheet_filename - a string containing a worksheet's filename
     7- username - a string containing a username
     8- JSMATH - a boolean stating whether to include jsMath
     9- JSMATH_IMAGE_FONTS - a boolean stating whether to include jsMath iamage fonts
     10- 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
     12#}
     13
     14{% include "notebook/head.tmpl" %}
     15
     16{% block title %}
     17{{ common_title(worksheet_filename, worksheet) }}
     18{% endblock %}
     19   
     20{% block css %}
     21main
     22{% endblock %}
     23
     24{% block javascript %}
     25{{ common_javascript(worksheet, worksheet_filename, username, JSMATH, JSMATH_IMAGE_FONTS, JEDITABLE_TINYMCE, sage_jsmath_macros) }}
     26{% endblock %}
     27
     28{% block body %}
     29<br />
     30<div class="docidx">
     31    <h1>Sage Documentation</h1>
     32    <br />
     33    <hr class="usercontrol" />
     34    <br /><br />
     35    <font size=+2>
     36        <a href="/doc/live/">Live Documentation</a><br /><br />
     37        <a href="/doc/static/">Static Documentation</a><br /><br />
     38        <a href="/help/">Sage Notebook Howto</a><br /><br />
     39        <br /><br />
     40        <br />
     41        <hr class="usercontrol" />
     42    </font>
     43</div>
     44{% endblock %}
     45 No newline at end of file
  • new file sage/server/notebook/templates/notebook/download_or_delete_datafile.html

    diff -r 95f3679a5a9d -r 5c624a40c5eb sage/server/notebook/templates/notebook/download_or_delete_datafile.html
    - +  
     1
     2{% extends "notebook/worksheet_page_template.html" %}
     3{#
     4INPUT:
     5- worksheet - an instance of Worksheet
     6- worksheet_filename - a string containing a worksheet's filename
     7- username - a string containing a username
     8- active_worksheets - a list of the Worksheet instances that are active for username
     9- filename_ - the name of the file
     10- path - the path to the file
     11- file_is_image - a boolean stating whether the file is an image
     12- file_is_text - a boolean stating whether the file is a text file
     13- text_file_content - a string containing the content of a text file
     14- JSMATH - a boolean stating whether to include jsMath
     15- JSMATH_IMAGE_FONTS - a boolean stating whether to include jsMath iamage fonts
     16- JEDITABLE_TINYMCE - a boolean stating whether to include jEditable and TinyMCE
     17- sage_jsmath_macros - an array containing strings of Javascript of Sage macros for jsMath
     18#}
     19{% set title = "Data file: %s"|format(filename_) %}
     20
     21{% block body_addition %}
     22<p>You may download <a href="{{ path }}">{{ filename_ }}</a> or create a linked copy to the worksheet <select onchange="go_option(this);" class="worksheet">
     23<option selected>select worksheet</option>
     24{% for worksheet in active_worksheets %}
     25    <option value='link_datafile("{{ worksheet.filename() }}","{{ filename_ }}")'>{{ worksheet.name() }}</option>
     26{% endfor %}
     27</select> or <a href="/home/{{ worksheet.filename() }}/datafile?name={{ filename_ }}&action=delete">delete {{ filename_ }}.</a></p>
     28
     29<p>Access {{ filename_ }} in this worksheet by typing <tt>DATA+'{{ filename_ }}'</tt>.  Here DATA is a special variable that gives the exact path to all data files uploaded to this worksheet.</p>
     30
     31<hr class="usercontrol" />
     32
     33{% if file_is_image %}
     34<div align=center><img src="{{ path }}"></div>
     35{% elif file_is_text %}
     36<form method="post" action="savedatafile" enctype="multipart/form-data">
     37    <input type="submit" value="Save Changes" name="button_save" /> <input type="submit" value="Cancel" name="button_cancel" style="display:block" />
     38    <textarea class="edit" name="textfield" rows=17 cols=70 id="textfield">{{ text_file_content }}</textarea>
     39    <input type="hidden" name="filename" value="{{ filename_ }}" id="filename" />
     40</form>
     41{% endif %}
     42{% endblock %}
     43
     44
     45
     46
  • new file sage/server/notebook/templates/notebook/edit_window.html

    diff -r 95f3679a5a9d -r 5c624a40c5eb sage/server/notebook/templates/notebook/edit_window.html
    - +  
     1{% extends "notebook/worksheet_page_template.html" %}
     2{#
     3INPUT:
     4- worksheet - an instance of Worksheet
     5- worksheet_filename - a string containing a worksheet's filename
     6- username - a string containing a username
     7- text - a string containing the text of the worksheet
     8- n_lines - number of lines of the text of the worksheet
     9- JSMATH - a boolean stating whether to include jsMath
     10- JSMATH_IMAGE_FONTS - a boolean stating whether to include jsMath iamage fonts
     11- 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
     13#}
     14
     15{% 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">' %}
     16{% set select = "edit" %}
     17
     18{% block before_sharebar %}
     19<form method="post" action="save" enctype="multipart/form-data">
     20{% endblock %}
     21{% block body_addition %}
     22<script type="text/javascript">
     23    function save_worksheet() {
     24    }
     25    function save_worksheet_and_close() {
     26    }
     27</script>
     28    <textarea class="plaintextedit" id="cell_intext" name="textfield" rows="{{ n_lines }}">{{ text }}</textarea>
     29</form>
     30{% endblock %}
  • new file sage/server/notebook/templates/notebook/guest_top_bar_and_worksheet.html

    diff -r 95f3679a5a9d -r 5c624a40c5eb sage/server/notebook/templates/notebook/guest_top_bar_and_worksheet.html
    - +  
     1
     2{#
     3INPUT:
     4- original_worksheet - an instance of Worksheet
     5- worksheet - an instance of Worksheet
     6- notebook - an instance of Notebook which contains worksheet
     7- worksheet_html - a string containing the html for the worksheet
     8- username - a string containing a username
     9#}
     10{% if original_worksheet.is_collaborator(username) or original_worksheet.is_owner(username) %}
     11    {% set edit_text = "Edit this." %}
     12    {% set url       = "edit_published_page" %}
     13{% elif notebook.user_is_guest(username) %}
     14    {% set edit_text = "Log in to edit a copy." %}
     15    {% set url       = "/" %}
     16{% else %}
     17    {% set edit_text = "Edit a copy." %}
     18    {% set url       = "edit_published_page" %}
     19{% endif %}
     20
     21{% set download_name = os.path.split(worksheet.name())[-1] %}
     22
     23<a class="usercontrol" href="{{ url }}">{{ edit_text }}</a>
     24&nbsp;&nbsp;<a class="usercontrol" href="download/{{ download_name }}.sws">Download.</a>
     25&nbsp;&nbsp;<span class="ratingmsg">
     26    {% if worksheet.rating() != -1 %}
     27        <a class="usercontrol" href="rating_info">
     28            This page is rated {{ "%.1f"|format("worksheet.rating()") }}.
     29        </a>
     30    {% endif %}
     31    {% if not notebook.user_is_guest(username)
     32        and not worksheet.is_publisher(username) %}
     33        &nbsp;&nbsp;
     34        <span class="usercontrol">
     35            {{ "Rerate" if worksheet.is_rater(username) else "Rate" }}
     36        </span>
     37        {% for i in range(5) %}
     38            <a class="usercontrol"
     39               onClick="rate_worksheet({{ i }})">
     40                &nbsp;{{ i }}&nbsp;
     41            </a>
     42        {% endfor %}
     43            &nbsp;&nbsp; <input name="rating_comment" id="rating_comment"></input>
     44    {% endif %}
     45</span>
     46<span class="pubmsg">
     47    <a href="/pub/">Other published documents...</a>
     48</span>
     49<hr class="usercontrol" />
     50<h1 align="center">{{ original_worksheet.name() }}</h1>
     51<h2 align="center">{{ worksheet.html_time_since_last_edited() }}</h2>
     52{{ worksheet_html }}
     53<hr class="usercontrol" />
     54{% for i in range(10) %}
     55&nbsp;
     56{% endfor %}
     57
  • new file sage/server/notebook/templates/notebook/head.tmpl

    diff -r 95f3679a5a9d -r 5c624a40c5eb sage/server/notebook/templates/notebook/head.tmpl
    - +  
     1
     2{#
     3INPUT:
     4- worksheet - an instance of Worksheet
     5- worksheet_filename - a string containing a worksheet's filename
     6- username - a string containing a user's name
     7- JSMATH - a boolean stating whether to include jsMath
     8- JSMATH_IMAGE_FONTS - a boolean stating whether to include jsMath iamage fonts
     9- 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
     11  #}
     12{% macro common_title(worksheet_filename, worksheet) %}
     13    {% if worksheet_filename %}
     14        {{ worksheet.name() }} (Sage)
     15    {% else %}
     16        Sage Notebook | Welcome
     17    {% endif %}
     18{% endmacro %}
     19
     20{% macro common_css %}
     21<link rel=stylesheet href="/css/main.css" type="text/css" />
     22{% endmacro %}
     23
     24{% macro common_javascript(worksheet, worksheet_filename, username, JSMATH, JSMATH_IMAGE_FONTS, JEDITABLE_TINYMCE, sage_jsmath_macros) %}
     25<!-- Load the Sage javascript library. -->
     26<script type="text/javascript" src="/javascript_local/jquery/jquery.js"></script>
     27<script type="text/javascript" src="/javascript/main.js"></script>
     28 
     29{% if JSMATH %}
     30    <!-- Turn off font warning. -->
     31    <style>
     32        #jsMath_Warning {display: none}
     33    </style>
     34    <script type="text/javascript">
     35        jsMath = {Controls: {cookie: {scale: 115}}}
     36    </script>
     37    {% if not JSMATH_IMAGE_FONTS %}
     38        <script type="text/javascript" src="/javascript_local/jsmath/plugins/noImageFonts.js"></script>
     39    {% endif %}
     40    <!-- Move the jsMath button 20 pixels from the right edge
     41         (apparently in some browsers, it covers up the scroll
     42         bar) -->
     43    <script type="text/javascript">
     44        jsMath.styles = {
     45            '#jsMath_button':
     46                'position:fixed; bottom:1px; right:20px; background-color:white;'
     47                    + 'border: solid 1px #959595; margin:0px; padding: 0px 3px 1px 3px; '
     48                    + 'z-index:102; color:black; text-decoration:none; font-size:x-small; '
     49                    + 'width:auto; cursor:hand;',
     50        };
     51    </script>
     52    <script type="text/javascript" src="/javascript_local/jsmath/jsMath.js"></script>
     53    <script type="text/javascript">
     54        /* The extensions here do the following:
     55            - verb implements the \verb command:
     56              see http://www.math.union.edu/~dpvc/jsMath/authors/verb.html
     57            - moreArrows implements \xrightarrow, among other things:
     58              see http://www.math.union.edu/~dpvc/jsMath/authors//moreArrows.html
     59            - AMSmath implements a number of AMS math commands:
     60              see http://www.math.union.edu/~dpvc/jsMath/authors/AMSmath.html
     61        */
     62        jsMath.Extension.Require("verb");
     63        jsMath.Extension.Require("moreArrows");
     64        jsMath.Extension.Require("AMSmath");
     65        jsMath.Extension.Require("AMSsymbols");
     66    </script>
     67{% endif %}
     68<!-- Import LaTeX macros -->
     69{% for m in sage_jsmath_macros %}
     70<script> {{ m }} </script>
     71{% endfor %}
     72
     73<!-- Load the jquery and ui-jquery javascript library.
     74     This is used for interact functionality in the notebook, and will be used
     75     to enable drag and drop, image zoom, etc. -->
     76<script type="text/javascript" src="/javascript_local/jqueryui/jquery.ui.all.min.js"></script>
     77<script type="text/javascript" src="/javascript_local/jquery/plugins/farbtastic/farbtastic.min.js"></script>
     78<script type="text/javascript" src="/javascript_local/jquery/plugins/dimensions/jquery.dimensions.min.js"></script>
     79<script type="text/javascript" src="/javascript_local/jquery/plugins/jquery.event.extendedclick.js"></script>
     80
     81<link rel="stylesheet" href="/javascript_local/jquery/plugins/farbtastic/farbtastic.css" type="text/css" /> 
     82<link rel="stylesheet" href="/javascript_local/jqueryui/themes/flora/flora.all.css" />
     83
     84<!-- TODO: get the lazy loading plugin -->
     85
     86<!-- TODO: Load individual ui plugins, not the whole package:
     87     <script type="text/javascript" src="/javascript_local/jqueryui/ui.mouse.min.js"></script>
     88     <script type="text/javascript" src="/javascript_local/jqueryui/ui.slider.min.js"></script>
     89     <script type="text/javascript" src="/javascript_local/jqueryui/ui.draggable.min.js"></script>
     90     <script type="text/javascript" src="/javascript_local/jqueryui/ui.draggable.ext.min.js"></script>
     91     <script type="text/javascript" src="/javascript_local/jqueryui/ui.resizable.min.js"></script>
     92     <script type="text/javascript" src="/javascript_local/jqueryui/ui.dialog.min.js"></script>
     93-->
     94
     95<!-- This was for syntax highlighting
     96     <script type="text/javascript" src="/javascript/highlight/prettify.js"></script>
     97     <link rel=stylesheet href="/css/highlight/prettify.css" type="text/css" />
     98-->
     99
     100<script type="text/javascript" src="/javascript/sage3d.js"></script
     101
     102<!-- Jmol - embedded 3D graphics -->
     103<script type="text/javascript" src="/java/jmol/appletweb/Jmol.js"></script>
     104<script>jmolInitialize("/java/jmol");jmolSetCallback("menuFile","/java/jmol/appletweb/SageMenu.mnu");</script> <!-- This must stay in <head> -->
     105
     106<!-- TinyMCE and jEditable - in-place editing of text cells -->
     107{% if JEDITABLE_TINYMCE %}
     108    <script type="text/javascript" src="/javascript_local/tiny_mce/tiny_mce.js"></script>
     109    <script src="/javascript_local/jquery/plugins/jquery.jeditable.mini.js" type="text/javascript" charset="utf-8"></script>
     110    <script type="text/javascript">
     111   
     112    function toggleEditor(id) {
     113            if (!tinyMCE.get(id))
     114                    tinyMCE.execCommand('mceAddControl', false, id);
     115            else
     116                    tinyMCE.execCommand('mceRemoveControl', false, id);
     117    }
     118   
     119    $.fn.tinymce = function(options){
     120       return this.each(function(){
     121          tinyMCE.execCommand("mceAddControl", true, this.id);
     122       });
     123    }
     124   
     125    function initMCE(){
     126       tinyMCE.init({mode : "none",
     127          plugins: "table,searchreplace,safari,paste,autosave",
     128          theme : "advanced",
     129          theme_advanced_toolbar_location : "top",
     130          theme_advanced_toolbar_align : "left",
     131          theme_advanced_statusbar_location : "bottom",
     132          theme_advanced_buttons1 : "\
     133    formatselect,fontselect,fontsizeselect,bold,italic,underline,strikethrough,forecolor,backcolor,|,\
     134    bullist,numlist,|,\
     135    undo,redo,search,pastetext,pasteword",
     136          theme_advanced_buttons2 : "\
     137    justifyleft,justifycenter,justifyright,justifyfull,outdent,indent,|,\
     138    charmap,|,\
     139    table,tablecontrols,|,\
     140    code,|,\
     141    link,image,unlink",
     142          theme_advanced_buttons3 : "",
     143          theme_advanced_resizing : true,
     144          setup : function(ed) {
     145          ed.onKeyDown.add(function(ed, e) {
     146              if(key_enter_shift(key_event(e))) {
     147                $(ed.formElement).submit();
     148              }
     149          })}
     150       });
     151    };
     152   
     153    initMCE();
     154   
     155   
     156    $.editable.addInputType('mce', {
     157       element : function(settings, original) {
     158          var textarea = $('<textarea id="'+$(original).attr("id")+'_mce"/>');
     159          if (settings.rows) {
     160             textarea.attr('rows', settings.rows);
     161          } else {
     162             textarea.height(settings.height);
     163          }
     164          if (settings.cols) {
     165             textarea.attr('cols', settings.cols);
     166          } else {
     167             textarea.width(settings.width);
     168          }
     169          $(this).append(textarea);
     170             return(textarea);
     171          },
     172       plugin : function(settings, original) {
     173          tinyMCE.execCommand("mceAddControl", true, $(original).attr("id")+'_mce');
     174          },
     175       submit : function(settings, original) {
     176          tinyMCE.triggerSave();
     177          tinyMCE.execCommand("mceRemoveControl", true, $(original).attr("id")+'_mce');
     178          },
     179       reset : function(settings, original) {
     180          tinyMCE.execCommand("mceRemoveControl", true, $(original).attr("id")+'_mce');
     181          original.reset();
     182       }
     183    });
     184    </script>
     185{% endif %}
     186<script type="text/javascript">user_name= "{{ username }}";</script>
     187{% if worksheet_filename %}
     188<script  type="text/javascript">
     189    worksheet_filename="{{ worksheet_filename }}";
     190    worksheet_name="{{ worksheet.name() }}";
     191    server_ping_while_alive();
     192</script>
     193{% endif %}
     194<!-- Uncomment this to force rename when the worksheet is opened (annoying!)
     195     if W and
     196        W.name() == "Untitled":
     197        <script  type="text/javascript">setTimeout("rename_worksheet()",1)</script> -->
     198{% endmacro %}
     199 No newline at end of file
  • new file sage/server/notebook/templates/notebook/index.html

    diff -r 95f3679a5a9d -r 5c624a40c5eb sage/server/notebook/templates/notebook/index.html
    - +  
     1{% extends "base.html" %}
     2{#
     3INPUT:
     4- worksheet - an instance of Worksheet
     5- worksheet_filename - a string containing a worksheet's filename
     6- worksheet_html - a string containing the html for the worksheet
     7- notebook - an instance of Notebook which contains worksheet
     8- username - a string containing a username
     9- show_debug - a boolean stating whether to show debug information
     10- JSMATH - a boolean stating whether to include jsMath
     11- JSMATH_IMAGE_FONTS - a boolean stating whether to include jsMath iamage fonts
     12- 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
     14#}
     15
     16{% if not select %}
     17    {% set select = none %}
     18{% endif %}
     19
     20{% if not backwards %}
     21    {% set backwards = false %}
     22{% endif %}
     23   
     24{% include "notebook/head.tmpl" %}
     25
     26{% block title %}
     27{{ common_title(worksheet_filename, worksheet) }}
     28{% endblock %}
     29   
     30{% block css %}
     31main
     32{% endblock %}
     33
     34{% block javascript %}
     35{{ common_javascript(worksheet, worksheet_filename, username, JSMATH, JSMATH_IMAGE_FONTS, JEDITABLE_TINYMCE, sage_jsmath_macros) }}
     36{% endblock %}
     37
     38{% block body_attrs %}
     39class="worksheet-online" onLoad="initialize_the_notebook();"
     40{% endblock %}
     41
     42{% block body %}
     43{% if worksheet.is_published() or notebook.user_is_guest(username) %}
     44    {% set original_worksheet = worksheet.worksheet_that_was_published() %}
     45    {% include "notebook/guest_top_bar_and_worksheet.html" %}
     46{% else %}
     47    {% include "notebook/top_bar_and_worksheet.html" %}
     48{% endif %}
     49{% if not worksheet %}
     50    </td></tr></table></span>
     51{% endif %}
     52{% if worksheet.user_is_only_viewer(username) %}
     53    <script type="text/javascript">worksheet_locked=true;</script>
     54{% else %}
     55    <script type="text/javascript">worksheet_locked=false;</script>
     56{% endif %}
     57   
     58{% if worksheet.computing() %}
     59    <!-- Set the update checking back in motion. -->
     60    <script type="text/javascript">
     61        active_cell_list = {{ worksheet.queue_id_list() }};
     62        for(var i = 0; i < active_cell_list.length; i++) {
     63            cell_set_running(active_cell_list[i]);
     64        }
     65        start_update_check();
     66    </script>
     67{% endif %}
     68{% endblock %}
  • new file sage/server/notebook/templates/notebook/plain_text_window.html

    diff -r 95f3679a5a9d -r 5c624a40c5eb sage/server/notebook/templates/notebook/plain_text_window.html
    - +  
     1
     2{% extends "notebook/worksheet_page_template.html" %}
     3{#
     4INPUT:
     5- worksheet - an instance of Worksheet
     6- worksheet_filename - a string containing a worksheet's filename
     7- username - a string containing a username
     8- plain_text - a string containing the plain text version
     9- JSMATH - a boolean stating whether to include jsMath
     10- JSMATH_IMAGE_FONTS - a boolean stating whether to include jsMath iamage fonts
     11- 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
     13#}
     14
     15{% set title = "View plain text" %}
     16{% set select = "text" %}
     17
     18{% block body_addition %}
     19<pre class="plaintext" id="cell_intext" name="textfield">{{ plain_text }}</pre>
     20{% endblock %}
  • new file sage/server/notebook/templates/notebook/plain_text_worksheet.html

    diff -r 95f3679a5a9d -r 5c624a40c5eb sage/server/notebook/templates/notebook/plain_text_worksheet.html
    - +  
     1
     2{#
     3INPUT:
     4     - worksheet_name - a string containing a worksheet's name
     5     - worksheet_plain_text - a string containing the plain text version of a worksheet
     6#}
     7<head>
     8    <title>Sage Worksheet: {{ worksheet_name }}</title>
     9    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
     10</head>
     11<body>
     12    <h1><a href=".">Sage Worksheet: %s</a></h1>
     13    <pre>{{ worksheet_plain_text }}</pre>
     14</body>
     15 No newline at end of file
  • new file sage/server/notebook/templates/notebook/slide_controls.html

    diff -r 95f3679a5a9d -r 5c624a40c5eb sage/server/notebook/templates/notebook/slide_controls.html
    - +  
     1
     2<div class="hidden" id="slide_controls">
     3    <div class="slideshow_control">
     4        <a class="slide_arrow" onClick="slide_next()">&gt;</a>
     5        <a class="slide_arrow" onClick="slide_last()">&gt;&gt;</a> <span class="vbar"></span>
     6        <a class="cell_mode" onClick="cell_mode()">Exit</a>
     7    </div>
     8    <div class="slideshow_progress" id="slideshow_progress" onClick="slide_next()">
     9        <div class="slideshow_progress_bar" id="slideshow_progress_bar">&nbsp;</div>
     10        <div class="slideshow_progress_text" id="slideshow_progress_text">&nbsp;</div>
     11    </div>
     12    <div class="slideshow_control">
     13        <a class="slide_arrow" onClick="slide_first()">&lt;&lt;</a>
     14        <a class="slide_arrow" onClick="slide_prev()">&lt;</a>
     15    </div>
     16</div>
     17
     18
     19
     20
     21
     22
     23
  • new file sage/server/notebook/templates/notebook/specific_revision.html

    diff -r 95f3679a5a9d -r 5c624a40c5eb sage/server/notebook/templates/notebook/specific_revision.html
    - +  
     1
     2{% extends "notebook/worksheet_page_template.html" %}
     3{#
     4INPUT:
     5- worksheet - an instance of Worksheet
     6- worksheet_filename - a string containing a worksheet's filename
     7- username - a string containing a username
     8- rev - this revision's key
     9- prev_rev - the previous revision's key
     10- next_rev - the next revision's key
     11- time_ago - a string containing the time since revision
     12- body_worksheet_html - the body html of the worksheet
     13- JSMATH - a boolean stating whether to include jsMath
     14- JSMATH_IMAGE_FONTS - a boolean stating whether to include jsMath iamage fonts
     15- 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
     17#}
     18
     19{% set select = "revisions" %}
     20{% set title = "Revision from %s ago&nbsp;&nbsp;&nbsp;&nbsp;<a href='revisions'>Revision List</a>"|format(time_ago) %}
     21   
     22{% macro actions %}
     23{% if prev_rev %}
     24    <a class="listcontrol" href="revisions?rev={{ prev_rev }}">Older</a>&nbsp;&nbsp;
     25{% else %}
     26    Oldest
     27{% endif %}
     28
     29{% if next_rev %}
     30    <a class="listcontrol" href="revisions?rev={{ next_rev }}">Newer</a>&nbsp;&nbsp;
     31{% else %}
     32    Newest
     33{% endif %}
     34
     35<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;
     37{% endmacro %}
     38
     39{% block body_addition %}
     40{{ actions() }}
     41<hr class="usercontrol" />       
     42<table width="100%%">
     43{{ body_worksheet_html }}
     44<hr class="usercontrol" />
     45{{ actions() }}
     46{% endblock %}
  • new file sage/server/notebook/templates/notebook/top_bar_and_worksheet.html

    diff -r 95f3679a5a9d -r 5c624a40c5eb sage/server/notebook/templates/notebook/top_bar_and_worksheet.html
    - +  
     1
     2{#
     3INPUT:
     4- username - a string containing a username
     5- worksheet_filename - a string containing a worksheet's filename
     6- worksheet_html - a string containing the html for a worksheet
     7- show_debug - a boolean stating whether to show debug information
     8  #}
     9{% include "notebook/user_controls.tmpl" %}
     10{% include "notebook/worksheet_topbar.tmpl" %}
     11{% set entries = [("$('#topbar').toggle()", 'Toggle', 'Toggle the top bar'),
     12                       ('/', 'Home', 'Back to your personal worksheet list'),
     13                       ('/pub', 'Published', 'Browse the published worksheets'),
     14                       ('history_window()', 'Log', 'View a log of recent computations'),
     15                       ('/settings', 'Settings', 'Account Settings'),
     16                       ('bugreport()', 'Report a Problem', 'Report a problem or submit a bug to improve Sage'),
     17                       ('help()', 'Help', 'Documentation'),
     18                       ('/logout', 'Sign out', 'Log out of the Sage notebook')] %}
     19<table width="100%">
     20    <tr>
     21        <td>{% include "banner.html" %}</td>
     22        <td align="right">{{ user_controls(username, entries) }}</td>
     23    </tr>
     24</table>
     25{% if worksheet_filename %}
     26{{ worksheet_topbar(worksheet, "use", username) }}
     27{% endif %}
     28{% if show_debug %}
     29{% include "notebook/debug_window.html" %}
     30{% endif %}
     31
     32<div class="worksheet" id="worksheet">
     33    {{ worksheet_html }}
     34</div>
  • new file sage/server/notebook/templates/notebook/upload_data_window.html

    diff -r 95f3679a5a9d -r 5c624a40c5eb sage/server/notebook/templates/notebook/upload_data_window.html
    - +  
     1
     2{% extends "notebook/worksheet_page_template.html" %}
     3{#
     4INPUT:
     5- worksheet - an instance of Worksheet
     6- worksheet_filename - a string containing a worksheet's filename
     7- username - a string containing a username
     8- JSMATH - a boolean stating whether to include jsMath
     9- JSMATH_IMAGE_FONTS - a boolean stating whether to include jsMath iamage fonts
     10- 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
     12#}
     13
     14{% set title = 'Upload or Create Data File' %}
     15
     16{% block body_addition %}
     17<div class="upload_worksheet_menu" id="upload_worksheet_menu">
     18    <h1><font size=+1>Upload or create data file attached to the worksheet '%s'</font></h1>
     19    <hr />
     20    <form method="POST" action="do_upload_data"
     21          name="upload" enctype="multipart/form-data">
     22        <table>
     23            <tr>
     24                <td>
     25                    Browse your computer to select a file to upload:<br />
     26                    <input class="upload_worksheet_menu" size="50" type="file" name="fileField" value="" id="upload_filename"></input><br /><br />
     27                    Or enter the url of a file on the web:<br />
     28                   
     29                    <input class="upload_worksheet_menu" size="50" type="text" name="urlField" value="" id="upload_url"></input><br />
     30                    <br /><br />
     31                    Or enter the name of a new file, which will be created:<br />
     32                    <input class="upload_worksheet_menu" size="50" type="text" name="newField" value="" id="upload_filename"></input><br /><br />
     33                   
     34                    What do you want to call it? (if different than the original name)<br />
     35                    <input class="upload_worksheet_menu" size="50" type="text" name="nameField" value="" id="upload_name"></input><br />
     36                </td>
     37            </tr>
     38            <tr>
     39                <td><br /><input type="button" class="upload_worksheet_menu" value="Upload File" onClick="form.submit();" /></td>
     40            </tr>
     41        </table>
     42    </form>
     43    <br />
     44</div>
     45{% endblock %}
     46       
     47 No newline at end of file
  • new file sage/server/notebook/templates/notebook/user_controls.tmpl

    diff -r 95f3679a5a9d -r 5c624a40c5eb sage/server/notebook/templates/notebook/user_controls.tmpl
    - +  
     1
     2{% macro user_controls(user, entries) %}
     3    <span class="username">{{ user }}</span>
     4    {% for href, name, title in entries %}
     5        {% if '(' in href %}
     6            {% set action = 'onClick="' ~ href ~ '"' %}
     7        {% else %}
     8            {% set action = 'href="' ~ href ~ '"' %}
     9        {% endif %}
     10        <span class="vbar"></span>
     11        <a title="{{ title }}" class="usercontrol" {{ action }}>{{ name }}</a>
     12    {% endfor %}
     13{% endmacro %}
  • new file sage/server/notebook/templates/notebook/worksheet.html

    diff -r 95f3679a5a9d -r 5c624a40c5eb sage/server/notebook/templates/notebook/worksheet.html
    - +  
     1
     2{#
     3INPUT:
     4     - worksheet_name - a string containing a worksheet's name
     5     - worksheet_html - a string containing the html for a worksheet
     6  #}
     7{% extends "base.html" %}
     8
     9{% block title %}Sage Worksheet: {{ worksheet_name }}{% endblock %}
     10
     11{% block javascript %}
     12<script type="text/javascript" src="/javascript_local/jquery/jquery.js"></script>
     13<script type="text/javascript" src="/javascript/main.js"></script>
     14{% if do_print %}
     15    <script type="text/javascript" src="/javascript_local/jsmath/jsMath.js"></script>
     16{% endif %}   
     17{% endblock %}
     18
     19{% block body_attrs %}
     20{% if not do_print %}
     21    class="worksheet-online" onLoad="initialize_the_notebook();"
     22{% endif %}
     23{% endblock %}
     24
     25{% block body %}
     26{% if do_print %}
     27    <div class="worksheet_print_title"> {{ worksheet_name }}</div>
     28{% endif %}
     29{{ worksheet_html }}
     30{% if do_print %}
     31    <script type="text/javascript">jsMath.Process();</script>
     32{% endif %}
     33{% endblock %}
     34 No newline at end of file
  • new file sage/server/notebook/templates/notebook/worksheet_page_template.html

    diff -r 95f3679a5a9d -r 5c624a40c5eb sage/server/notebook/templates/notebook/worksheet_page_template.html
    - +  
     1{% extends "base.html" %}
     2{#
     3INPUT:
     4- worksheet - an instance of Worksheet
     5- worksheet_filename - a string containing a worksheet's filename
     6- username - a string containing a username
     7- title - a string
     8- select    - a string containing the control that is selected
     9- backwards - a boolean
     10- JSMATH - a boolean stating whether to include jsMath
     11- JSMATH_IMAGE_FONTS - a boolean stating whether to include jsMath iamage fonts
     12- 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
     14#}
     15
     16{% if not select %}
     17    {% set select = none %}
     18{% endif %}
     19
     20{% if not backwards %}
     21    {% set backwards = false %}
     22{% endif %}
     23   
     24{% include "notebook/head.tmpl" %}
     25{% include "notebook/worksheet_top.tmpl" %}
     26{% include "notebook/worksheet_topbar.tmpl" %}
     27
     28{% block title %}
     29{{ common_title(worksheet_filename, worksheet) }}
     30{% endblock %}
     31   
     32{% block css %}
     33main
     34{% endblock %}
     35
     36{% block javascript %}
     37{{ common_javascript(worksheet, worksheet_filename, username, JSMATH, JSMATH_IMAGE_FONTS, JEDITABLE_TINYMCE, sage_jsmath_macros) }}
     38{% endblock %}
     39
     40{% block body %}
     41{{ worksheet_top(username) }}
     42{{ worksheet_topbar(worksheet, select, username, backwards) }}
     43<hr class="usercontrol" />
     44{% block before_sharebar %}{% endblock %}
     45<span class="sharebar">{{ title }}</span>
     46<br /><br /><br />
     47{% block body_addition %}{% endblock %}
     48{% endblock %}
     49
  • new file sage/server/notebook/templates/notebook/worksheet_revision_list.html

    diff -r 95f3679a5a9d -r 5c624a40c5eb sage/server/notebook/templates/notebook/worksheet_revision_list.html
    - +  
     1
     2{% extends "notebook/worksheet_page_template.html" %}
     3{#
     4INPUT:
     5- data - a list of pairs of the form ('how long ago', key)
     6- worksheet - an instance of Worksheet
     7- worksheet_filename - a string containing a worksheet's filename
     8- username - a string containing a username
     9- JSMATH - a boolean stating whether to include jsMath
     10- JSMATH_IMAGE_FONTS - a boolean stating whether to include jsMath iamage fonts
     11- 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
     13  #}
     14
     15
     16{% set title  = "Revision History" %}
     17{% set select = "revisions" %}
     18
     19{% block body_addition %}
     20<hr class="usercontrol">
     21<table width="100%%">
     22    <tr>
     23        <td width="1%%"></td>
     24        <td width="20%%"><b>Revision</b></td>
     25        <td width="20%%"><b>Last Edited</b></td>
     26        <td width="30%%"></td>
     27    </tr>
     28{% for desc, key in data|reverse %}
     29    <tr>
     30        <td></td>
     31        <td><a href="revisions?rev={{ key }}">Revision {{ loop.revindex0 }}</a></td>
     32        <td><span class="revs">{{ desc }}</span></td>
     33    </tr>
     34{% endfor %}
     35</table>
     36{% endblock %}
     37 No newline at end of file
  • new file sage/server/notebook/templates/notebook/worksheet_settings.html

    diff -r 95f3679a5a9d -r 5c624a40c5eb sage/server/notebook/templates/notebook/worksheet_settings.html
    - +  
     1
     2{% extends "notebook/worksheet_page_template.html" %}
     3{#
     4INPUT:
     5- worksheet - an instance of Worksheet
     6- worksheet_filename - a string containing a worksheet's filename
     7- username - a string containing a username
     8- JSMATH - a boolean stating whether to include jsMath
     9- JSMATH_IMAGE_FONTS - a boolean stating whether to include jsMath iamage fonts
     10- 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
     12#}
     13
     14{% set title = 'Worksheet Settings &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<button name="button_save">Save Settings</button>  <input type="submit" value="Cancel" name="button_cancel"/>' %}
     15
     16{% block before_sharebar %}
     17<form width=70%% method="post" action="input_settings"  enctype="multipart/form-data">
     18{% endblock %}
     19{% block body_addition %}
     20</form>
     21{% endblock %}
     22
     23
     24
  • new file sage/server/notebook/templates/notebook/worksheet_share.html

    diff -r 95f3679a5a9d -r 5c624a40c5eb sage/server/notebook/templates/notebook/worksheet_share.html
    - +  
     1
     2{% extends "notebook/worksheet_page_template.html" %}
     3{#
     4INPUT:
     5    - worksheet - an instance of Worksheet
     6    - worksheet_filename - a string containing a worksheet's filename
     7    - username - a string containing a username
     8    - other_users - a list of strings containing other users names
     9    - user_is_admin - a boolean stating whether the user is an admin
     10    - JSMATH - a boolean stating whether to include jsMath
     11    - JSMATH_IMAGE_FONTS - a boolean stating whether to include jsMath iamage fonts
     12    - 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
     14#}
     15
     16{% set title = "Share this document" %}
     17{% set select = "share" %}
     18
     19{% block body_addition %}
     20{% if not (user_is_admin or username == worksheet.owner()) %}
     21    Only the owner of a worksheet is allowed to share it. You can do whatever you want if you <a href="copy">make your own copy</a>.
     22{% else %}
     23<p>This Sage Worksheet is currently shared with the people listed in the box below.</p>
     24<p style="margin-bottom:1em">You may add or remove collaborators (separate user names by commas).</p>
     25
     26<form width=70% method="post" action="invite_collab" style="margin-bottom:1em">
     27    <textarea name="collaborators" rows=5 cols=70 class="edit" id="collaborators" style="display:block; margin-bottom:1em;">{{ worksheet.collaborators()|join(', ') }}</textarea>
     28    <input type="submit" title="Give access to your worksheet to the above collaborators" value="Invite Collaborators" />
     29</form>
     30
     31<hr class="usercontrol" />
     32<span class="username">Sage Users:</span>
     33<span class="users">
     34    {{ other_users|join(', ') }}
     35</span>
     36{% endif %}
     37{% endblock %}
  • new file sage/server/notebook/templates/notebook/worksheet_top.tmpl

    diff -r 95f3679a5a9d -r 5c624a40c5eb sage/server/notebook/templates/notebook/worksheet_top.tmpl
    - +  
     1{#
     2INPUT:
     3- username - a string containing a username
     4#}
     5
     6{% macro worksheet_top(username) %}
     7{% include "notebook/user_controls.tmpl" %}
     8{% include "notebook/worksheet_topbar.tmpl" %}
     9{% set entries = [("$('#topbar').toggle()", 'Toggle', 'Toggle the top bar'),
     10                       ('/', 'Home', 'Back to your personal worksheet list'),
     11                       ('/pub', 'Published', 'Browse the published worksheets'),
     12                       ('history_window()', 'Log', 'View a log of recent computations'),
     13                       ('/settings', 'Settings', 'Account Settings'),
     14                       ('bugreport()', 'Report a Problem', 'Report a problem or submit a bug to improve Sage'),
     15                       ('help()', 'Help', 'Documentation'),
     16                       ('/logout', 'Sign out', 'Log out of the Sage notebook')] %}
     17<table width="100%">
     18    <tr>
     19        <td>{% include "banner.html" %}</td>
     20        <td align="right">{{ user_controls(username, entries) }}</td>
     21    </tr>
     22</table>
     23{% endmacro %}
  • new file sage/server/notebook/templates/notebook/worksheet_topbar.tmpl

    diff -r 95f3679a5a9d -r 5c624a40c5eb sage/server/notebook/templates/notebook/worksheet_topbar.tmpl
    - +  
     1
     2{#
     3INPUT:
     4- worksheet - an instance of Worksheet
     5- select    - a string containing the control that is selected
     6- username  - a string containing a username
     7- backwards - a boolean
     8  #}
     9{% macro worksheet_topbar(worksheet, select=None, username='guest', backwards=false) %}
     10    <table width="100%%" id="topbar">
     11        <tr>
     12            <td align="left"> {{ worksheet.html_title(username) }} </td>
     13            <td align="right"> {{ worksheet.html_save_discard_buttons() }} </td>
     14        </tr>
     15        <tr>
     16            <td align="left"> {{ worksheet.html_menu() }} </td>
     17            <td align="right"> {{ worksheet.html_share_publish_buttons(select, backwards) }}</td>
     18        </tr>
     19    </table>
     20    <div class="hidden" id="slide_controls">
     21        <div class="slideshow_control">
     22            <a class="slide_arrow" onClick="slide_next()">&gt;</a>
     23            <a class="slide_arrow" onClick="slide_last()">&gt;&gt;</a> <span class="vbar"></span>
     24            <a class="cell_mode" onClick="cell_mode()">Exit</a>
     25        </div>
     26        <div class="slideshow_progress" id="slideshow_progress" onClick="slide_next()">
     27            <div class="slideshow_progress_bar" id="slideshow_progress_bar">&nbsp;</div>
     28            <div class="slideshow_progress_text" id="slideshow_progress_text">&nbsp;</div>
     29        </div>
     30        <div class="slideshow_control">
     31            <a class="slide_arrow" onClick="slide_first()">&lt;&lt;</a>
     32            <a class="slide_arrow" onClick="slide_prev()">&lt;</a>
     33        </div>
     34    </div>
     35{% endmacro %}
  • sage/server/notebook/templates/registration.html

    diff -r 95f3679a5a9d -r 5c624a40c5eb sage/server/notebook/templates/registration.html
    a b  
     1
    12{% extends "base.html" %}
    23
    34{% block title %}Sign up{% endblock %}
  • sage/server/notebook/templates/search.html

    diff -r 95f3679a5a9d -r 5c624a40c5eb sage/server/notebook/templates/search.html
    a b  
     1
    12<span class="flush-right">
    23<input id="search_worksheets" size=20 onkeypress="return search_worksheets_enter_pressed(event, '{{ typ }}');" value="{{ search }}"></input>
    34<button class="add_new_worksheet_menu" onClick="search_worksheets('{{ typ }}');">Search Worksheets</button>
  • sage/server/notebook/templates/source_code.html

    diff -r 95f3679a5a9d -r 5c624a40c5eb sage/server/notebook/templates/source_code.html
    a b  
     1
    12{% extends "base.html" %}
    23
    34{% block title %}{{ src_filename }} - Source Code{% endblock %}
  • sage/server/notebook/templates/template_error.html

    diff -r 95f3679a5a9d -r 5c624a40c5eb sage/server/notebook/templates/template_error.html
    a b  
     1
    12{% extends "base.html" %}
    23
    34{% block title %}Error{% endblock %}
  • sage/server/notebook/templates/top_bar.html

    diff -r 95f3679a5a9d -r 5c624a40c5eb sage/server/notebook/templates/top_bar.html
    a b  
     1
    12<table width="100%%">
    23  <tr>
    34    <td>
  • sage/server/notebook/templates/upload.html

    diff -r 95f3679a5a9d -r 5c624a40c5eb sage/server/notebook/templates/upload.html
    a b  
     1
    12{% extends "base.html" %}
    23
    34{% block title %}Upload File{% endblock %}
  • sage/server/notebook/templates/user_management.html

    diff -r 95f3679a5a9d -r 5c624a40c5eb sage/server/notebook/templates/user_management.html
    a b  
     1
    12{% extends "base.html" %}
    23
    34{% block title %}User Management{% endblock %}
  • new file sage/server/notebook/templates/worksheet/attached.html

    diff -r 95f3679a5a9d -r 5c624a40c5eb sage/server/notebook/templates/worksheet/attached.html
    - +  
     1{#
     2INPUT:
     3- attached_files - dictionary of attached files
     4#}
     5{% for file, tm in attached_files %}
     6<div class="attached_filename" onClick="inspect_attached_file('{{ file }}')">
     7    {{ file }}
     8</div>
     9{% endfor %}
     10 No newline at end of file
  • new file sage/server/notebook/templates/worksheet/completions.html

    diff -r 95f3679a5a9d -r 5c624a40c5eb sage/server/notebook/templates/worksheet/completions.html
    - +  
     1{#
     2INPUT:
     3- cell_id - id for the cell of the completions
     4- completions_enumerated - enumerated (enumerate()) 2D list of completions in
     5column-major order
     6#}
     7<ul class='completion_menu_one'
     8    {% for col_i, column in completions_enumerated %}
     9    <li class='completion_menu_one'>
     10        {% for row in column %}
     11        <ul class='completion_menu_two'>
     12            <li id='completion{{ cell_id }}_{{ loop.index0 }}_{{ col_i }}' class='completion_menu_two'>
     13                <a onClick='do_replacement({{ cell_id }}, "{{ row }}"); return false;'
     14                   onMouseOver='this.focus(); select_replacement({{ loop.index0 }},{{ col_i }});'>
     15                    {{ row }}
     16                </a>
     17            </li>
     18        </ul>
     19        {% endfor %}
     20    </li>
     21    {% endfor %}
     22</ul>
     23 No newline at end of file
  • new file sage/server/notebook/templates/worksheet/menu.html

    diff -r 95f3679a5a9d -r 5c624a40c5eb sage/server/notebook/templates/worksheet/menu.html
    - +  
     1{#
     2INPUT
     3- name - string with worksheet name
     4- filename_ - string with worksheet filename
     5- data - list of data to put in the Data menu
     6- systems_enumerated - enumerated list of systems
     7- system_names - list of system names
     8- current_system_index - the currently selected system_index
     9- pretty_print - a boolean stating whether to typeset as default
     10- doc_worksheet - a boolean stating whether the worksheet is the doc worksheet
     11#}
     12&nbsp;&nbsp;&nbsp;<select class="worksheet"  onchange="go_option(this);">
     13    <option title="Select a file related function" value=""  selected>File...</option>
     14    <option title="Load a new worksheet stored in a file" value="upload_worksheet_button();">Upload worksheet from a file</option>
     15    <option title="Create a new worksheet" value="new_worksheet();">New worksheet</option>
     16    <option title="Save this worksheet to an sws file" value="download_worksheet('{{ name }}');">Download to a file</option>
     17    <option title="Print this worksheet" value="print_worksheet();">Print</option>
     18    <option title="Rename this worksheet" value="rename_worksheet();">Rename worksheet</option>
     19    <option title="Copy this worksheet" value="copy_worksheet();">Copy worksheet</option>
     20    <option title="Move this worksheet to the trash" value="delete_worksheet('{{ filename_ }}');">Delete worksheet</option>
     21</select>
     22
     23<select class="worksheet"  onchange="go_option(this);" >
     24    <option title="Select a worksheet function" value="" selected>Action...</option>
     25    <option title="Interrupt currently running calculations, if possible" value="interrupt();">Interrupt</option>
     26    <option title="Restart the worksheet process" value="restart_sage();">Restart worksheet</option>
     27    <option title="Quit the worksheet process" value="save_worksheet_and_close();">Save and quit worksheet</option>
     28    <option value="">---------------------------</option>
     29    <option title="Evaluate all input cells in the worksheet" value="evaluate_all();">Evaluate All</option>
     30    <option title="Hide all output" value="hide_all();">Hide All Output</option>
     31    <option title="Show all output" value="show_all();">Show All Output</option>
     32    <option title="Delete all output" value="delete_all_output();">Delete All Output</option>
     33    <option value="">---------------------------</option>
     34    <option title="Switch to single-cell mode" value="slide_mode();">One Cell Mode</option>
     35    <option title="Switch to multi-cell mode" value="cell_mode();">Multi Cell Mode</option>
     36</select>
     37
     38<select class="worksheet" onchange="handle_data_menu(this);" >
     39    <option title="Select an attached file" value="" selected>Data...</option>
     40    <option title="Upload or create a data file in a wide range of formats" value="__upload_data_file__">Upload or create file...</option>
     41    <option value="">--------------------</option>
     42    {% for name in data %}
     43    <option value="datafile?name={{ option }}">{{ option }}</option>
     44    {% endfor %}
     45</select>
     46
     47{% if not doc_worksheet %}
     48<select onchange="go_system_select(this, {{ current_system_index }});" class="worksheet">
     49    {% for system_index, system_name in systems_enumerated %}
     50        <option title="Evaluate all input cells using {{ system_names[system_index] }}"
     51            {{ "selected" if current_system_index == system_index else "" }} value="{{ system_names[system_index] }}">
     52            {{ system_name }}
     53        </option>
     54    {% endfor %}
     55</select>   
     56<input type="checkbox" title="Enable/disable pretty_printing"
     57       onchange="pretty_print_check(this.checked);"
     58       class="worksheet" value="pretty_print" {{ "checked" if pretty_print else "" }} />&nbsp;Typeset
     59{% endif %}
     60 No newline at end of file
  • new file sage/server/notebook/templates/worksheet/published_worksheet.html

    diff -r 95f3679a5a9d -r 5c624a40c5eb sage/server/notebook/templates/worksheet/published_worksheet.html
    - +  
     1{#
     2INPUT:
     3- cell_id_list - a list of cell id's
     4- cells_html - string of cells HTML
     5#}
     6{% include "worksheet/worksheet_body.html" %}
     7
     8{% set published = true %}
     9{% set do_print = true %}
     10
     11<script language=javascript>jsMath.ProcessBeforeShowing();</script>
  • new file sage/server/notebook/templates/worksheet/save_discard_buttons.html

    diff -r 95f3679a5a9d -r 5c624a40c5eb sage/server/notebook/templates/worksheet/save_discard_buttons.html
    - +  
     1{#
     2INPUT:
     3doc_worksheet - boolean stating whether this worksheet is the doc worksheet
     4#}
     5{% if not doc_worksheet %}
     6<button name="button_save" title="Save changes" onClick="save_worksheet();">Save</button><button title="Save changes and close window" onClick="save_worksheet_and_close();" name="button_save">Save & quit</button><button title="Discard changes to this worksheet" onClick="worksheet_discard();">Discard & quit</button>
     7{% endif %}
  • new file sage/server/notebook/templates/worksheet/share_publish_buttons.html

    diff -r 95f3679a5a9d -r 5c624a40c5eb sage/server/notebook/templates/worksheet/share_publish_buttons.html
    - +  
     1
     2{#
     3INPUT:
     4- worksheet - Worksheet instance
     5- select - a boolean
     6- backwards - a boolean
     7#}
     8{% if not worksheet.is_doc_worksheet() %}
     9{% macro cls(x) %}
     10{{ "control-select" if x == select else "control" }}
     11{% endmacro %}
     12{% macro backwards_text %}
     13{{ "../" if backwards else "" }}
     14{% endmacro %}
     15<a title="Print this worksheet" class="usercontrol" onClick="print_worksheet()"><img border=0 src="/images/icon_print.gif" alt="Print">Print</a>
     16<a class="{{ cls('use') }}" title="Interactively use this worksheet" onClick="edit_worksheet();">Worksheet</a>       
     17<a class="{{ cls('edit') }}" title="Edit text version of this worksheet" href="{{ backwards_text() }}edit">Edit</a>
     18<a class="{{ cls('text') }}" title="View plain text version of this worksheet" href="{{ backwards_text() }}text">Text</a>
     19<a class="{{ cls('undo') }}" title="View changes to this worksheet over time" href="{{ backwards_text() }}revisions">Undo</a>
     20<a class="{{ cls('share') }}" title="Let others edit this worksheet" href="{{ backwards_text() }}share">Share</a>
     21<a class="{{ cls('publish') }}" title="Make this worksheet publicly viewable" href="{{ backwards_text() }}publish">Publish</a>
     22{% endif %}
  • new file sage/server/notebook/templates/worksheet/time_last_edited.html

    diff -r 95f3679a5a9d -r 5c624a40c5eb sage/server/notebook/templates/worksheet/time_last_edited.html
    - +  
     1{#
     2INPUT:
     3- time - string of time of  last edit
     4- last_editor - string of name of last editor
     5#}
     6<span class="lastedit">last edited on {{ time }} by {{ last_editor }}</span>
     7 No newline at end of file
  • new file sage/server/notebook/templates/worksheet/time_since_last_edited.html

    diff -r 95f3679a5a9d -r 5c624a40c5eb sage/server/notebook/templates/worksheet/time_since_last_edited.html
    - +  
     1{#
     2INPUT:
     3- time - string of time since last edit
     4- last_editor - string of name of last editor
     5#}
     6<span class="lastedit">{{ time }} ago by {{ last_editor }}</span>
  • new file sage/server/notebook/templates/worksheet/title.html

    diff -r 95f3679a5a9d -r 5c624a40c5eb sage/server/notebook/templates/worksheet/title.html
    - +  
     1{#
     2- worksheet - Worksheet instance
     3- name - escaped name of the worksheet
     4- username - string of username
     5- doc_worksheet - boolean stating whether the worksheet is the doc worksheet
     6- warn - boolean stating whether to warn that another user is viewing
     7         the worksheet
     8#}
     9<div class="worksheet_title">
     10     <a id="worksheet_title" class="worksheet_title" onClick="rename_worksheet(); return false;" title="Click to rename this worksheet">{{ name }}</a>
     11     <br> {{ worksheet.html_time_last_edited() }}
     12     {% if warn and username != 'guest' and not doc_worksheet%}
     13     &nbsp;&nbsp;<span class="pingdown">(Someone else is viewing this worksheet)</span>
     14     {% endif %}
     15 </div>
     16 No newline at end of file
  • new file sage/server/notebook/templates/worksheet/worksheet.html

    diff -r 95f3679a5a9d -r 5c624a40c5eb sage/server/notebook/templates/worksheet/worksheet.html
    - +  
     1{#
     2INPUT:
     3- do_print - a boolean
     4- cell_id_list - a list of cell id's
     5- confirm_before_leave - a boolean stating whether to popup a js confirm
     6  dialog before leaving
     7- cells_html - string of cells HTML
     8- published - a boolean stating whether the worksheet is published
     9#}
     10{% include "worksheet/worksheet_body.html" %}
     11
     12{% if do_print %}
     13<script language=javascript>jsMath.ProcessBeforeShowing();</script>
     14{% else %}
     15<script type="text/javascript">cell_id_list={{ cell_id_list }};</script>
     16{% endif %}
     17
     18{% if not do_print and confirm_before_leave %}
     19<script type="text/javascript">
     20            window.onbeforeunload = confirmBrowseAway;
     21            function confirmBrowseAway()
     22            {
     23            return "Unsubmitted cells will be lost.";
     24            }
     25</script>
     26{% endif %}
     27 No newline at end of file
  • new file sage/server/notebook/templates/worksheet/worksheet_body.html

    diff -r 95f3679a5a9d -r 5c624a40c5eb sage/server/notebook/templates/worksheet/worksheet_body.html
    - +  
     1{#
     2INPUT:
     3- do_print - a boolean
     4- cells_html - string of cells HTML
     5- published - a boolean stating whether the worksheet is published
     6#}
     7<div class="cell_input_active" id="cell_resizer"></div>
     8{% if not published %}
     9<div class="worksheet_cell_list" id="worksheet_cell_list">
     10{% endif %}
     11
     12{{ cells_html }}
     13
     14{% if not do_print and not published %}
     15</div>
     16<div class="insert_new_cell" id="insert_last_cell"></div>
     17<script type="text/javascript">
     18        $("#insert_last_cell").plainclick(function(e) {insert_new_cell_after(cell_id_list[cell_id_list.length-1]);});
     19        $("#insert_last_cell").shiftclick(function(e) {insert_new_text_cell_after(cell_id_list[cell_id_list.length-1]);});
     20</script>
     21<div class="worksheet_bottom_padding"></div>
     22{% endif %}
     23 No newline at end of file
  • sage/server/notebook/templates/worksheet_listing.html

    diff -r 95f3679a5a9d -r 5c624a40c5eb sage/server/notebook/templates/worksheet_listing.html
    a b  
     1
    12{% extends "base.html" %}
    23
    34{% if pub %}
  • sage/server/notebook/templates/yes_no.html

    diff -r 95f3679a5a9d -r 5c624a40c5eb sage/server/notebook/templates/yes_no.html
    a b  
     1
    12{% extends "base.html" %}
    23
    34{% block title %}Confirm{% endblock %}
  • sage/server/notebook/worksheet.py

    diff -r 95f3679a5a9d -r 5c624a40c5eb sage/server/notebook/worksheet.py
    a b  
    5252# Imports specifically relevant to the sage notebook
    5353import worksheet_conf
    5454from   cell import Cell, TextCell
     55from template import template
    5556
    5657# Set some constants that will be used for regular expressions below.
    5758whitespace = re.compile('\s')  # Match any whitespace character
     
    22112212    ##########################################################
    22122213    def html(self, include_title=True, do_print=False,
    22132214             confirm_before_leave=False, read_only=False):
     2215        """
     2216        INPUT:
     2217        - publish - a boolean stating whether the worksheet is published
     2218        - do_print - a boolean
     2219
     2220        OUTPUT:
     2221        - returns the html for the worksheet
     2222       
     2223        EXAMPLES::
     2224       
     2225            sage: nb = sage.server.notebook.notebook.Notebook(tmp_dir())
     2226            sage: W = nb.create_new_worksheet('Test', 'admin')
     2227            sage: W.html()
     2228            '\n\n\n<div class="cell_input_active" id="cell_resizer"></div>\n\n<div class="worksheet_cell_list" id...'
     2229        """
     2230        ncols = self.notebook().conf()['word_wrap_cols']
     2231        cells_html = ""
     2232        for cell in self.cell_list():
     2233            cells_html += cell.html(ncols, do_print=do_print) + '\n'
    22142234        if self.is_published():
    22152235            try:
    22162236                return self.__html
    22172237            except AttributeError:
    2218                 s = self.html_worksheet_body(do_print=True)
    2219                 s += self.javascript_for_jsmath_rendering()
     2238                s = template("worksheet/published_worksheet.html", ncols = ncols,
     2239                             cells_html = cells_html)
    22202240                self.__html = s
    22212241                return s
    2222                
    2223         s = ''
    2224            
    2225         s += self.html_worksheet_body(do_print=do_print)
    2226 
    2227         if do_print:
    2228             s += self.javascript_for_jsmath_rendering()
    2229         else:
    2230             s += self.javascript_for_being_active_worksheet()
    2231 
    2232         if not do_print and confirm_before_leave:
    2233             s += self.javascript_confirm_before_leave()
    2234            
    2235         return s
     2242           
     2243        return template("worksheet/worksheet.html", published = self.is_published(),
     2244                        do_print = do_print, confirm_before_leave = confirm_before_leave,
     2245                        cells_html = cells_html,
     2246                        cell_id_list = self.compute_cell_id_list())
    22362247
    22372248    def truncated_name(self, max=30):
    22382249        name = self.name()
     
    22432254    def html_title(self, username='guest'):
    22442255        import cgi
    22452256        name = self.truncated_name()
    2246 
    22472257        warn = self.warn_about_other_person_editing(username, WARN_THRESHOLD)
    22482258       
    2249         s = ''
    2250         s += '<div class="worksheet_title">'
    2251         s += '<a id="worksheet_title" class="worksheet_title" onClick="rename_worksheet(); return false;" title="Click to rename this worksheet">%s</a>'%(cgi.escape(name))
    2252         s += '<br>' + self.html_time_last_edited()
    2253         if warn and username != 'guest' and not self.is_doc_worksheet():
    2254             s += '&nbsp;&nbsp;<span class="pingdown">(Someone else is viewing this worksheet)</span>'
    2255         s += '</div>'
    2256 
    2257         return s
     2259        return template("worksheet/title.html", worksheet = self,
     2260                        name = cgi.escape(self.truncated_name()),
     2261                        warn = warn, doc_worksheet = self.is_doc_worksheet(),
     2262                        username = username)
    22582263
    22592264    def is_doc_worksheet(self):
    22602265        try:
     
    22662271        self.__is_doc_worksheet = value
    22672272
    22682273    def html_save_discard_buttons(self):
    2269         if self.is_doc_worksheet():
    2270             return ''
    2271         return """
    2272         <button name="button_save" title="Save changes" onClick="save_worksheet();">Save</button><button title="Save changes and close window" onClick="save_worksheet_and_close();" name="button_save">Save & quit</button><button title="Discard changes to this worksheet" onClick="worksheet_discard();">Discard & quit</button>
    2273         """
    2274 
     2274        r"""
     2275        OUTPUT:
     2276        - returns the html for the save, discard, etc. buttons
     2277
     2278        EXAMPLES::
     2279
     2280            sage: nb = sage.server.notebook.notebook.Notebook(tmp_dir())
     2281            sage: W = nb.create_new_worksheet('Test', 'admin')
     2282            sage: W.html_save_discard_buttons()
     2283            '\n\n\n<button name="button_save" title="Save changes" onClick="save_worksheet();">Save<...'
     2284        """
     2285        return template("worksheet/save_discard_buttons.html", doc_worksheet = self.is_doc_worksheet())
     2286       
    22752287    def html_share_publish_buttons(self, select=None, backwards=False):
    2276         if self.is_doc_worksheet():
    2277             return ''
    2278         def cls(x):
    2279             if x == select:
    2280                 return "control-select"
    2281             else:
    2282                 return "control"
    2283         backwards = '../' if backwards else ''
    2284         return """
    2285 
    2286         <a  title="Print this worksheet" class="usercontrol" onClick="print_worksheet()"><img border=0 src="/images/icon_print.gif" alt="Print">Print</a>
    2287         <a class="%s" title="Interactively use this worksheet" onClick="edit_worksheet();">Worksheet</a>       
    2288         <a class="%s" title="Edit text version of this worksheet" href="%sedit">Edit</a>
    2289         <a class="%s" title="View plain text version of this worksheet" href="%stext">Text</a>
    2290         <a class="%s" href="%srevisions" title="View changes to this worksheet over time">Undo</a>
    2291         <a class="%s" href="%sshare" title="Let others edit this worksheet">Share</a>
    2292         <a class="%s" href="%spublish" title="Make this worksheet publicly viewable">Publish</a>
    2293         """%(cls('use'),cls('edit'),backwards,cls('text'),backwards,cls('revisions'),backwards,cls('share'),backwards,cls('publish'),backwards)
    2294 
    2295     def html_data_options_list(self):
    2296         D = self.attached_data_files()
    2297         D.sort()
    2298         x = '\n'.join(['<option value="datafile?name=%s">%s</option>'%(nm,nm) for nm in D])
    2299         return x
    2300 
    2301     def html_file_menu(self):
    2302 ##  <option title="Save this worksheet as an HTML web page" onClick="save_as('html');">Save as HTML (zipped) </option>
    2303 ##  <option title="Save this worksheet to LaTeX format" onClick="save_as('latex');">Save as LaTeX (zipped) </option>
    2304 ##  <option title="Save this worksheet as a PDF file" onClick="save_as('pdf');">Save as PDF</option>
    2305 ##  <option title="Save this worksheet as a text file" onClick="save_as('text');">Save as Text</option>
    2306 
    2307         if self.is_doc_worksheet():
    2308             system_select = ''
    2309             pretty_print_check = ''
    2310         else:
    2311             system_select = self.notebook().html_system_select_form_element(self)
    2312             pretty_print_check = self.notebook().html_pretty_print_check_form_element(self)
    2313 
    2314         data = self.html_data_options_list()
    2315        
    2316         return """
    2317 <select class="worksheet"  onchange="go_option(this);">
    2318 <option title="Select a file related function" value=""  selected>File...</option>
    2319  <option title="Load a new worksheet stored in a file" value="upload_worksheet_button();">Upload worksheet from a file</option>
    2320  <option title="Create a new worksheet" value="new_worksheet();">New worksheet</option>
    2321  <option title="Save this worksheet to an sws file" value="download_worksheet('%s');">Download to a file</option>
    2322  <option title="Print this worksheet" value="print_worksheet();">Print</option>
    2323  <option title="Rename this worksheet" value="rename_worksheet();">Rename worksheet</option>
    2324  <option title="Copy this worksheet" value="copy_worksheet();">Copy worksheet</option>
    2325  <option title="Move this worksheet to the trash" value="delete_worksheet('%s');">Delete worksheet</option>
    2326 </select>
    2327 
    2328 <select class="worksheet"  onchange="go_option(this);" >
    2329  <option title="Select a worksheet function" value="" selected>Action...</option>
    2330  <option title="Interrupt currently running calculations, if possible" value="interrupt();">Interrupt</option>
    2331  <option title="Restart the worksheet process" value="restart_sage();">Restart worksheet</option>
    2332  <option title="Quit the worksheet process" value="save_worksheet_and_close();">Save and quit worksheet</option>
    2333  <option value="">---------------------------</option>
    2334  <option title="Evaluate all input cells in the worksheet" value="evaluate_all();">Evaluate All</option>
    2335  <option title="Hide all output" value="hide_all();">Hide All Output</option>
    2336  <option title="Show all output" value="show_all();">Show All Output</option>
    2337  <option title="Delete all output" value="delete_all_output();">Delete All Output</option>
    2338  <option value="">---------------------------</option>
    2339  <option title="Switch to single-cell mode" value="slide_mode();">One Cell Mode</option>
    2340  <option title="Switch to multi-cell mode" value="cell_mode();">Multi Cell Mode</option>
    2341  </select>
    2342 
    2343 <select class="worksheet" onchange="handle_data_menu(this);" >
    2344  <option title="Select an attached file" value="" selected>Data...</option>
    2345  <option title="Upload or create a data file in a wide range of formats" value="__upload_data_file__">Upload or create file...</option>
    2346  <option value="">--------------------</option>
    2347 %s
    2348 </select>
    2349 
    2350  %s
    2351  %s
    2352  """%(_notebook.clean_name(self.name()), self.filename(),
    2353       data, system_select, pretty_print_check)
     2288        r"""
     2289        INPUT:
     2290        - select - a boolean
     2291        - backwards - a boolean
     2292
     2293        OUTPUT:
     2294        - returns the html for the share, publish, etc. buttons
     2295
     2296        EXAMPLES::
     2297
     2298            sage: nb = sage.server.notebook.notebook.Notebook(tmp_dir())
     2299            sage: W = nb.create_new_worksheet('Test', 'admin')
     2300            sage: W.html_share_publish_buttons()
     2301            '\n\n\n\n\n<a title="Print this worksheet" class="usercontrol" onClick="print_worksheet()">...'
     2302        """
     2303        return template("worksheet/share_publish_buttons.html", worksheet = self, select = select, backwards = backwards)
     2304       
    23542305# <option title="Browse the data directory" value="data/">Browse data directory...</option>
    23552306# <option title="Browse the directory of output from cells" value="cells/">Browse cell output directories...</option>
    23562307
    23572308# <option title="Configure this worksheet" value="worksheet_settings();">Worksheet settings</option>
    23582309
    23592310    def html_menu(self):
    2360         name = self.filename()
    2361 
    2362         menu = '&nbsp;'*3 + self.html_file_menu()
    2363        
    2364         filename = os.path.split(self.filename())[-1]
    2365         download_name = _notebook.clean_name(self.name())
    2366        
    2367         #menu += '  </span>' #why is this here?  it isn't opened anywhere.
    2368 
    2369         return menu
     2311        """
     2312        OUTPUT:
     2313        - returns the html for the menus of the worksheet
     2314
     2315        EXAMPLES::
     2316       
     2317            sage: nb = sage.server.notebook.notebook.Notebook(tmp_dir())
     2318            sage: W = nb.create_new_worksheet('Test', 'admin')
     2319            sage: W.html_menu()
     2320            '\n&nbsp;&nbsp;&nbsp;<select class="worksheet"  onchange="go_option(this);">\n    ...'
     2321        """
     2322        return template("worksheet/menu.html", name = _notebook.clean_name(self.name()),
     2323                        filename_ = self.filename(), data = self.attached_data_files().sort(),
     2324                        systems_enumerated = enumerate(self.notebook().systems()),
     2325                        system_names = self.notebook().system_names(),
     2326                        current_system_index = self.notebook().system_names().index(self.system()),
     2327                        pretty_print = self.pretty_print(),
     2328                        doc_worksheet = self.is_doc_worksheet())
    23702329
    23712330    def html_worksheet_body(self, do_print, publish=False):
    2372         n = len(self.cell_list())
     2331        """
     2332        INPUT:
     2333        - publish - a boolean stating whether the worksheet is published
     2334        - do_print - a boolean
     2335
     2336        OUTPUT:
     2337        - returns the html for the File menu of the worksheet
     2338
     2339        EXAMPLES::
     2340       
     2341            sage: nb = sage.server.notebook.notebook.Notebook(tmp_dir())
     2342            sage: W = nb.create_new_worksheet('Test', 'admin')
     2343            sage: W.html_worksheet_body(false)
     2344            '\n\n<div class="cell_input_active" id="cell_resizer"></div>\n\n<div class="worksheet_cell_list" id...'
     2345        """
    23732346        published = self.is_published() or publish
    2374 
    2375         s = '<div class="cell_input_active" id="cell_resizer"></div>'
    2376         D = self.notebook().conf()
    2377         ncols = D['word_wrap_cols']
    2378         if not published:
    2379             s += '<div class="worksheet_cell_list" id="worksheet_cell_list">\n'
    2380            
    2381         for i in range(n):
    2382             cell = self.cell_list()[i]
    2383             s += cell.html(ncols, do_print=do_print) + '\n'
    2384 
    2385         if not do_print and not published:
    2386             s += '\n</div>\n'
    2387             s += """<div class="insert_new_cell" id="insert_last_cell">
    2388                  </div>
    2389 <script type="text/javascript">
    2390 $("#insert_last_cell").plainclick(function(e) {insert_new_cell_after(cell_id_list[cell_id_list.length-1]);});
    2391 $("#insert_last_cell").shiftclick(function(e) {insert_new_text_cell_after(cell_id_list[cell_id_list.length-1]);});
    2392 </script>"""
    2393             s += '<div class="worksheet_bottom_padding"></div>\n'
    2394         return s
    2395 
    2396     def javascript_for_being_active_worksheet(self):
    2397         s =  '<script type="text/javascript">cell_id_list=%s;</script>'%self.compute_cell_id_list()
    2398         #s += 'for(i=0;i<cell_id_list.length;i++) prettify_cell(cell_id_list[i]);</script>\n'
    2399         return s
    2400 
    2401     def javascript_for_jsmath_rendering(self):
    2402         return '<script language=javascript>jsMath.ProcessBeforeShowing();</script>\n'
    2403 
    2404     def javascript_confirm_before_leave(self):
    2405         return """<script type="text/javascript">
    2406             window.onbeforeunload = confirmBrowseAway;
    2407             function confirmBrowseAway()
    2408             {
    2409             return "Unsubmitted cells will be lost.";
    2410             }
    2411             </script>
    2412             """
    2413 
     2347        ncols = self.notebook().conf()['word_wrap_cols']
     2348        cells_html = ""
     2349        for cell in self.cell_list():
     2350            cells_html += cell.html(ncols, do_print=do_print) + '\n'
     2351       
     2352        return template("worksheet/worksheet_body.html",
     2353                        cells_html = cells_html,
     2354                        published = published,
     2355                        do_print = do_print)
    24142356
    24152357
    24162358    ##########################################################
     
    24702412            user = self.last_to_edit()
    24712413            if user != username:
    24722414                return True, user
    2473         False
     2415        return False
    24742416       
    24752417    def html_time_since_last_edited(self):
    24762418        t = self.time_since_last_edited()
    24772419        tm = convert_seconds_to_meaningful_time_span(t)
    2478         who = ' by %s'%self.last_to_edit()
    2479         return '<span class="lastedit">%s ago%s</span>'%(tm, who)
     2420        return template("worksheet/time_since_last_edited.html",
     2421                        last_editor = self.last_to_edit(),
     2422                        time = tm)
    24802423
    24812424    def html_time_last_edited(self):
    2482         tm = convert_time_to_string(self.last_edited())
    2483         who = self.last_to_edit()
    2484         t = '<span class="lastedit">last edited on %s by %s</span>'%(tm, who)
    2485         return t
     2425        return template("worksheet/time_last_edited.html",
     2426                        time = convert_time_to_string(self.last_edited()),
     2427                        last_editor = self.last_to_edit())
    24862428
    24872429       
    24882430    ##########################################################
     
    38403782    # List of attached files.
    38413783    ##########################################################
    38423784    def attached_html(self):
    3843         s = ''
    3844         div = '<div class="attached_filename" onClick="inspect_attached_file(\'%s\')">'
    3845         A = self.attached_files()
    3846         D = self.DIR()
    3847         for F, tm in A.iteritems():
    3848             # uncomment this to remove some absolute path info...
    3849             # if F[:len(D)] == D: F = F[len(D)+1:]
    3850             s += div%F + '%s</div>'%F
    3851         return s
     3785        return template("worksheet/attached.html",
     3786                        attached_files = self.attached_files())
    38523787
    38533788    ##########################################################
    38543789    # Showing and hiding all cells
     
    40814016
    40824017
    40834018def format_completions_as_html(cell_id, completions):
    4084     if len(completions) == 0:
    4085         return ''
    4086     lists = []
    4087 
    4088     # compute the width of each column
    4089     column_width = []
    4090     for i in range(len(completions[0])):
    4091         column_width.append(max([len(x[i]) for x in completions if i < len(x)]))
    4092 
    4093     for i in range(len(completions)):
    4094         row = completions[i]
    4095         for j in range(len(row)):
    4096             if len(lists) <= j:
    4097                 lists.append([])     
    4098             cell = """
    4099 <li id='completion%s_%s_%s' class='completion_menu_two'>
    4100 <a onClick='do_replacement(%s, "%s"); return false;'
    4101    onMouseOver='this.focus(); select_replacement(%s,%s);'
    4102 >%s</a>
    4103 </li>"""%(cell_id, i, j, cell_id, row[j], i,j,
    4104          row[j])
    4105          #row[j] + '&nbsp;'*(column_width[j]-len(row[j])) )
    4106 
    4107             lists[j].append(cell)
    4108 
    4109     grid = "<ul class='completion_menu_one'>"
    4110     for L in lists:
    4111         s = "\n   ".join(L)
    4112         grid += "\n <li class='completion_menu_one'>\n  <ul class='completion_menu_two'>\n%s\n  </ul>\n </li>"%s
    4113 
    4114     return grid + "\n</ul>"
     4019    """
     4020    INPUT:
     4021    - cell_id - id for the cell of the completions
     4022    - completions - list of completions in row-major order
     4023   
     4024    OUTPUT:
     4025    - html for the completions formatted in rows and columns
     4026    """
     4027    return template("worksheet/completions.html", cell_id = cell_id,
     4028                    # Transpose and enumerate completions to 8column-major
     4029                    completions_enumerated = enumerate(map(list, zip(*completions))))
    41154030
    41164031
    41174032def extract_name(text):