Ticket #6069: trac_6069-missing_pub_ws.2.patch

File trac_6069-missing_pub_ws.2.patch, 4.0 KB (added by mpatel, 9 years ago)

Redirect to pub/ after delay. Apply only this patch. sagenb repo.

  • sagenb/data/sage/html/base.html

    # HG changeset patch
    # User Mitesh Patel <qed777@gmail.com>
    # Date 1263956966 28800
    # Node ID 0e246136eea0d7c0afffb801d8e43424c07a93ca
    # Parent  153ae44b885b6f7253ea7554c23a237eaed4a01a
    #6069 Make error message for nonexistent published page more informative
    
    diff --git a/sagenb/data/sage/html/base.html b/sagenb/data/sage/html/base.html
    a b  
    44    <head>
    55        <title>{{ render_title() }} -- Sage</title>
    66        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
     7        {% block more_meta %}{% endblock %}
    78        {% block pre_main_css %}{% endblock %}
    89        <link type="text/css" rel="stylesheet" href="/css/{% block css %}main{% endblock %}.css" />
    910        {% block more_css %}{% endblock %}
     
    4344        </div>
    4445        {% endblock %}
    4546    </body>
    46 </html>
    47  No newline at end of file
     47</html>
  • sagenb/data/sage/html/error_message.html

    diff --git a/sagenb/data/sage/html/error_message.html b/sagenb/data/sage/html/error_message.html
    a b  
    22
    33{% block title %}Error{% endblock %}
    44
     5{% if redirect_url %}
     6{% block more_meta %}
     7<meta http-equiv="refresh" content="{{ redirect_delay }};url={{ redirect_url}}" />
     8{% endblock %}
     9{% endif %}
     10
    511{% block main %}
    612<div>
    713    {{ msg }}
    814</div>
    915{% if cont %}
    10 <div>
     16<div style="text-align: center;">
    1117    <a class="boldusercontrol" href="{{ cont }}">Continue</a>
    1218</div>
    1319{% endif %}
  • sagenb/notebook/twist.py

    diff --git a/sagenb/notebook/twist.py b/sagenb/notebook/twist.py
    a b def gzip_handler(request): 
    135135############################
    136136# An error message
    137137############################
    138 def message(msg, cont='/'):
    139     template_dict = {'msg': msg, 'cont': cont}
     138def message(msg, cont='/', username=None, **kwargs):
     139    template_dict = {'msg': msg, 'cont': cont, 'username': username}
     140    template_dict.update(kwargs)
    140141    return template(os.path.join('html', 'error_message.html'),
    141142                    **template_dict)
    142143
    class WorksheetsByUser(resource.Resource 
    16091610        try:
    16101611            return Worksheet(filename, self.username)
    16111612        except KeyError:
    1612             s = "The user '%s' has no worksheet '%s'."%(self.user, name)
    1613             return InvalidPage(msg = s, username = self.user)
     1613            if self.user != 'pub':
     1614                s = "The user '%s' has no worksheet '%s'."%(self.user, name)
     1615                return InvalidPage(msg = s, username = self.user)
     1616            else:
     1617                s = 'There is no published worksheet with name "%s".  Redirecting to the index of published worksheets in 10 seconds...<br><br>' % name
     1618                return InvalidPage(msg = s, username = self.username,
     1619                                   cont = '/pub', redirect_url = '/pub',
     1620                                   redirect_delay = 10)
    16141621        except RuntimeError:
    16151622            s = "You are not logged in or do not have access to the worksheet '%s'."%name
    16161623            return InvalidPage(msg = s, username = self.user)
    class AdminAddUser(resource.PostableReso 
    23642371class InvalidPage(resource.Resource):
    23652372    addSlash = True
    23662373
    2367     def __init__(self, msg, username):
     2374    def __init__(self, msg, username, cont='/', **kwargs):
    23682375        self.msg = msg
    23692376        self.username = username
     2377        self.cont = cont
     2378        self.kwargs = kwargs
    23702379
    23712380    def render(self, ctx):
    23722381        if self.msg:
    class InvalidPage(resource.Resource): 
    23752384            s = "This is an invalid page."
    23762385            if self.username == 'guest':
    23772386                s += ' You might have to login to view this page.'
    2378         return HTMLResponse(stream = message(s, '/'))
     2387        return HTMLResponse(stream = message(s, self.cont, self.username,
     2388                                             **self.kwargs))
    23792389
    23802390    def childFactory(self, request, name):
    23812391        return InvalidPage(msg = self.msg, username = self.username)