Ticket #6069: trac_6069-missing_pub_ws.3.patch

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

Better titles for non-Error pages. Apply only this patch.

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

    # HG changeset patch
    # User Mitesh Patel <qed777@gmail.com>
    # Date 1263956966 28800
    # Node ID b120813f2619c570caa001a4fb48ef873628edd9
    # Parent  6d1e1afd37f07c966839f9b454b2764663ec1dcb
    #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  
    11{% extends "html/base_authenticated.html" %}
    22
    3 {% block title %}Error{% endblock %}
     3{% block title %}
     4{% if title %}{{ title }}{% else %}Error{% endif %}
     5{% endblock %}
     6
     7{% if redirect_url %}
     8{% block more_meta %}
     9<meta http-equiv="refresh" content="{{ redirect_delay }};url={{ redirect_url}}" />
     10{% endblock %}
     11{% endif %}
    412
    513{% block main %}
    614<div>
    715    {{ msg }}
    816</div>
    917{% if cont %}
    10 <div>
     18<div style="padding: 1.0em; text-align: center;">
    1119    <a class="boldusercontrol" href="{{ cont }}">Continue</a>
    1220</div>
    1321{% endif %}
  • sagenb/notebook/twist.py

    diff --git a/sagenb/notebook/twist.py b/sagenb/notebook/twist.py
    a b def gzip_handler(request): 
    136136############################
    137137# An error message
    138138############################
    139 def message(msg, cont='/'):
    140     template_dict = {'msg': msg, 'cont': cont}
     139def message(msg, cont='/', username=None, **kwargs):
     140    template_dict = {'msg': msg, 'cont': cont, 'username': username}
     141    template_dict.update(kwargs)
    141142    return template(os.path.join('html', 'error_message.html'),
    142143                    **template_dict)
    143144
    class Worksheet_datafile(WorksheetResour 
    668669                os.unlink(path)
    669670                return HTMLResponse(stream = message("Successfully deleted '%s'"%filename,
    670671                                                      '/home/' + self.worksheet.filename(),
    671                                                      title=u'%s delete successful' % filename))
     672                                                     title=u'Data file deleted'))
    672673        s = notebook.html_download_or_delete_datafile(self.worksheet, self.username, filename)
    673674        return HTMLResponse(stream=s)
    674675
    class Worksheet_rate(WorksheetResource,  
    13861387        return HTMLResponse(stream=message("""
    13871388        Thank you for rating the worksheet <b><i>%s</i></b>!
    13881389        You can <a href="rating_info">see all ratings of this worksheet.</a>
    1389         """%self.worksheet.name(), '/pub/'))
     1390        """%self.worksheet.name(), '/pub/', title=u'Rating Accepted'))
    13901391
    13911392
    13921393########################################################
    class WorksheetsByUser(resource.Resource 
    16171618        try:
    16181619            return Worksheet(filename, self.username)
    16191620        except KeyError:
    1620             s = "The user '%s' has no worksheet '%s'."%(self.user, name)
    1621             return InvalidPage(msg = s, username = self.user)
     1621            if self.user != 'pub':
     1622                s = "The user '%s' has no worksheet '%s'."%(self.user, name)
     1623                return InvalidPage(msg = s, username = self.user)
     1624            else:
     1625                s = 'There is no published worksheet with name "%s".  Redirecting to the index of published worksheets in 10 seconds...<br><br>' % name
     1626                return InvalidPage(msg = s, username = self.username,
     1627                                   cont = '/pub', redirect_url = '/pub',
     1628                                   redirect_delay = 10)
    16221629        except RuntimeError:
    16231630            s = "You are not logged in or do not have access to the worksheet '%s'."%name
    16241631            return InvalidPage(msg = s, username = self.user)
    class Java(resource.Resource): 
    19461953############################
    19471954class Logout(resource.Resource):
    19481955    def render(self, ctx):
    1949         # TODO -- actually log out.
    1950         s = message("<br>Thank you for using Sage.<br><br><a href='/'>Please login and use Sage again soon.</a><br>")
    1951         return HTMLResponse(stream=s)
     1956        # We use this class only when require_login is False.  Since
     1957        # we haven't logged in, we just redirect to the home page.
     1958        return http.RedirectResponse('/')
    19521959
    19531960############################
    19541961# Image resource
    server. Please <a href="/register">regis 
    19861993            return HTMLResponse(stream=message(invalid_confirm_key, '/register'))
    19871994        success = """<h1>Email address confirmed for user %s</h1>""" % username
    19881995        del waiting[key]
    1989         return HTMLResponse(stream=message(success))
     1996        return HTMLResponse(stream=message(success, title='Email Confirmed'))
    19901997
    19911998############################
    19921999# Registration page
    class AdminAddUser(resource.PostableReso 
    23642371                                                    error='username_taken', username_input=username, **template_dict))
    23652372            notebook.add_user(username, password, '', force=True)
    23662373            return HTMLResponse(stream=message('The temporary password for the new user <em>%s</em> is <em>%s</em>' %
    2367                                                (username, password), '/adduser'))
     2374                                               (username, password), '/adduser',
     2375                                               title=u'New User'))
    23682376        else:
    23692377           
    23702378            return HTMLResponse(stream=template(os.path.join('html', 'settings', 'admin_add_user.html'), **template_dict))
    class AdminAddUser(resource.PostableReso 
    23722380class InvalidPage(resource.Resource):
    23732381    addSlash = True
    23742382
    2375     def __init__(self, msg, username):
     2383    def __init__(self, msg, username, cont='/', **kwargs):
    23762384        self.msg = msg
    23772385        self.username = username
     2386        self.cont = cont
     2387        self.kwargs = kwargs
    23782388
    23792389    def render(self, ctx):
    23802390        if self.msg:
    class InvalidPage(resource.Resource): 
    23832393            s = "This is an invalid page."
    23842394            if self.username == 'guest':
    23852395                s += ' You might have to login to view this page.'
    2386         return HTMLResponse(stream = message(s, '/'))
     2396        return HTMLResponse(stream = message(s, self.cont, self.username,
     2397                                             **self.kwargs))
    23872398
    23882399    def childFactory(self, request, name):
    23892400        return InvalidPage(msg = self.msg, username = self.username)