Code

various cosmetic fixes
authorrichard <richard@57a73879-2fb5-44c3-a270-3262357dd7e2>
Thu, 28 Aug 2003 05:53:40 +0000 (05:53 +0000)
committerrichard <richard@57a73879-2fb5-44c3-a270-3262357dd7e2>
Thu, 28 Aug 2003 05:53:40 +0000 (05:53 +0000)
git-svn-id: http://svn.roundup-tracker.org/svnroot/roundup/trunk@1840 57a73879-2fb5-44c3-a270-3262357dd7e2

CHANGES.txt
doc/customizing.txt
roundup/cgi/templating.py
templates/classic/html/issue.item.html
templates/classic/html/page.html

index d5a0b9b43d7893e39b98047b285b5d344cd0825b..60a72b570e43cf253e60e7fb24a8c5bfff856b79 100644 (file)
@@ -14,6 +14,7 @@ Fixed:
 - fixed form padding in LHS menu (sf bug 790502)
 - fixed upgrading docs for timezones (sf bug 790498)
 - set the content type on page templates (can have XML templates now)
+- various cosmetic fixes (thanks James Kew for being persistent :)
 
 
 2003-08-08 0.6.0
index 9cdf143c0aa69f82dfe9692b665fb901f889b0b3..ca5ffec06665b88dcf64096abb470d2ee91a0e38 100644 (file)
@@ -2,7 +2,7 @@
 Customising Roundup
 ===================
 
-:Version: $Revision: 1.93 $
+:Version: $Revision: 1.94 $
 
 .. This document borrows from the ZopeBook section on ZPT. The original is at:
    http://www.zope.org/Documentation/Books/ZopeBook/current/ZPT.stx
@@ -1473,65 +1473,68 @@ _value          the value of the property if any - this is the actual
 
 There are several methods available on these wrapper objects:
 
-========= ================================================================
+=========== ================================================================
 Method    Description
-========= ================================================================
-plain     render a "plain" representation of the property. This method
-          may take two arguments:
-
-          escape
-           If true, escape the text so it is HTML safe (default: no). The
-           reason this defaults to off is that text is usually escaped
-           at a later stage by the TAL commands, unless the "structure"
-           option is used in the template. The following ``tal:content``
-           expressions are all equivalent::
-
-            "structure python:msg.content.plain(escape=1)"
-            "python:msg.content.plain()"
-            "msg/content/plain"
-            "msg/content"
-
-           Usually you'll only want to use the escape option in a
-           complex expression.
-
-          hyperlink
-           If true, turn URLs, email addresses and hyperdb item
-           designators in the text into hyperlinks (default: no). Note
-           that you'll need to use the "structure" TAL option if you
-           want to use this ``tal:content`` expression::
-
-            "structure python:msg.content.plain(hyperlink=1)"
-
-           Note also that the text is automatically HTML-escaped before
-           the hyperlinking transformation.
-
-field     render an appropriate form edit field for the property - for
-          most types this is a text entry box, but for Booleans it's a
-          tri-state yes/no/neither selection.
-stext     only on String properties - render the value of the property
-          as StructuredText (requires the StructureText module to be
-          installed separately)
-multiline only on String properties - render a multiline form edit
-          field for the property
-email     only on String properties - render the value of the property
-          as an obscured email address
-confirm   only on Password properties - render a second form edit field
-          for the property, used for confirmation that the user typed
-          the password correctly. Generates a field with name
-          "name:confirm".
-now       only on Date properties - return the current date as a new
-          property
-reldate   only on Date properties - render the interval between the date
-          and now
-local     only on Date properties - return this date as a new property
-          with some timezone offset
-pretty    only on Interval properties - render the interval in a pretty
-          format (eg. "yesterday")
-menu      only on Link and Multilink properties - render a form select
-          list for this property
-reverse   only on Multilink properties - produce a list of the linked
-          items in reverse order
-========= ================================================================
+=========== ================================================================
+plain       render a "plain" representation of the property. This method
+            may take two arguments:
+
+            escape
+             If true, escape the text so it is HTML safe (default: no). The
+             reason this defaults to off is that text is usually escaped
+             at a later stage by the TAL commands, unless the "structure"
+             option is used in the template. The following ``tal:content``
+             expressions are all equivalent::
+              "structure python:msg.content.plain(escape=1)"
+              "python:msg.content.plain()"
+              "msg/content/plain"
+              "msg/content"
+
+             Usually you'll only want to use the escape option in a
+             complex expression.
+
+            hyperlink
+             If true, turn URLs, email addresses and hyperdb item
+             designators in the text into hyperlinks (default: no). Note
+             that you'll need to use the "structure" TAL option if you
+             want to use this ``tal:content`` expression::
+  
+              "structure python:msg.content.plain(hyperlink=1)"
+
+             Note also that the text is automatically HTML-escaped before
+             the hyperlinking transformation.
+hyperlinked The same as msg.content.plain(hyperlink=1), but nicer::
+
+              "structure msg/content/hyperlinked"
+
+field       render an appropriate form edit field for the property - for
+            most types this is a text entry box, but for Booleans it's a
+            tri-state yes/no/neither selection.
+stext       only on String properties - render the value of the property
+            as StructuredText (requires the StructureText module to be
+            installed separately)
+multiline   only on String properties - render a multiline form edit
+            field for the property
+email       only on String properties - render the value of the property
+            as an obscured email address
+confirm     only on Password properties - render a second form edit field
+            for the property, used for confirmation that the user typed
+            the password correctly. Generates a field with name
+            "name:confirm".
+now         only on Date properties - return the current date as a new
+            property
+reldate     only on Date properties - render the interval between the date
+            and now
+local       only on Date properties - return this date as a new property
+            with some timezone offset
+pretty      only on Interval properties - render the interval in a pretty
+            format (eg. "yesterday")
+menu        only on Link and Multilink properties - render a form select
+            list for this property
+reverse     only on Multilink properties - produce a list of the linked
+            items in reverse order
+=========== ================================================================
 
 
 The request variable
index 55e0b7db1e66732e5ce8bfd7e63c127f1093d5a9..4b1b374afdc0dc4b1feda843174a7195c69c0aec 100644 (file)
@@ -117,7 +117,8 @@ class Templates:
         # compile the template
         self.templates[src] = pt = RoundupPageTemplate()
         # use pt_edit so we can pass the content_type guess too
-        pt.pt_edit(open(src).read(), mimetypes.guess_type(filename))
+        content_type = mimetypes.guess_type(filename)[0] or 'text/html'
+        pt.pt_edit(open(src).read(), content_type)
         pt.id = filename
         pt.mtime = time.time()
         return pt
@@ -588,8 +589,10 @@ class HTMLItem(HTMLPermissions):
                             isinstance(self._props[prop_n], hyperdb.Link)):
                         classname = self._props[prop_n].classname
                         try:
-                            find_template(self._db.config.TEMPLATES,
+                            template = find_template(self._db.config.TEMPLATES,
                                 classname, 'item')
+                            if template[1].startswith('_generic'):
+                                raise NoTemplate, 'not really...'
                         except NoTemplate:
                             pass
                         else:
@@ -625,116 +628,123 @@ class HTMLItem(HTMLPermissions):
                         prop = self._props[k]
                     except KeyError:
                         prop = None
-                    if prop is not None:
-                        if args[k] and (isinstance(prop, hyperdb.Multilink) or
-                                isinstance(prop, hyperdb.Link)):
-                            # figure what the link class is
-                            classname = prop.classname
-                            try:
-                                linkcl = self._db.getclass(classname)
-                            except KeyError:
-                                labelprop = None
-                                comments[classname] = _('''The linked class
-                                    %(classname)s no longer exists''')%locals()
-                            labelprop = linkcl.labelprop(1)
-                            hrefable = os.path.exists(
-                                os.path.join(self._db.config.TEMPLATES,
-                                classname+'.item'))
-
-                        if isinstance(prop, hyperdb.Multilink) and args[k]:
-                            ml = []
-                            for linkid in args[k]:
-                                if isinstance(linkid, type(())):
-                                    sublabel = linkid[0] + ' '
-                                    linkids = linkid[1]
-                                else:
-                                    sublabel = ''
-                                    linkids = [linkid]
-                                subml = []
-                                for linkid in linkids:
-                                    label = classname + linkid
-                                    # if we have a label property, try to use it
-                                    # TODO: test for node existence even when
-                                    # there's no labelprop!
-                                    try:
-                                        if labelprop is not None and \
-                                                labelprop != 'id':
-                                            label = linkcl.get(linkid, labelprop)
-                                    except IndexError:
-                                        comments['no_link'] = _('''<strike>The
-                                            linked node no longer
-                                            exists</strike>''')
-                                        subml.append('<strike>%s</strike>'%label)
-                                    else:
-                                        if hrefable:
-                                            subml.append('<a href="%s%s">%s</a>'%(
-                                                classname, linkid, label))
-                                        else:
-                                            subml.append(label)
-                                ml.append(sublabel + ', '.join(subml))
-                            cell.append('%s:\n  %s'%(k, ', '.join(ml)))
-                        elif isinstance(prop, hyperdb.Link) and args[k]:
-                            label = classname + args[k]
-                            # if we have a label property, try to use it
-                            # TODO: test for node existence even when
-                            # there's no labelprop!
-                            if labelprop is not None and labelprop != 'id':
+                    if prop is None:
+                        # property no longer exists
+                        comments['no_exist'] = _('''<em>The indicated property
+                            no longer exists</em>''')
+                        cell.append('<em>%s: %s</em>\n'%(k, str(args[k])))
+                        continue
+
+                    if args[k] and (isinstance(prop, hyperdb.Multilink) or
+                            isinstance(prop, hyperdb.Link)):
+                        # figure what the link class is
+                        classname = prop.classname
+                        try:
+                            linkcl = self._db.getclass(classname)
+                        except KeyError:
+                            labelprop = None
+                            comments[classname] = _('''The linked class
+                                %(classname)s no longer exists''')%locals()
+                        labelprop = linkcl.labelprop(1)
+                        try:
+                            template = find_template(self._db.config.TEMPLATES,
+                                classname, 'item')
+                            if template[1].startswith('_generic'):
+                                raise NoTemplate, 'not really...'
+                            hrefable = 1
+                        except NoTemplate:
+                            hrefable = 0
+
+                    if isinstance(prop, hyperdb.Multilink) and args[k]:
+                        ml = []
+                        for linkid in args[k]:
+                            if isinstance(linkid, type(())):
+                                sublabel = linkid[0] + ' '
+                                linkids = linkid[1]
+                            else:
+                                sublabel = ''
+                                linkids = [linkid]
+                            subml = []
+                            for linkid in linkids:
+                                label = classname + linkid
+                                # if we have a label property, try to use it
+                                # TODO: test for node existence even when
+                                # there's no labelprop!
                                 try:
-                                    label = linkcl.get(args[k], labelprop)
+                                    if labelprop is not None and \
+                                            labelprop != 'id':
+                                        label = linkcl.get(linkid, labelprop)
                                 except IndexError:
                                     comments['no_link'] = _('''<strike>The
                                         linked node no longer
                                         exists</strike>''')
-                                    cell.append(' <strike>%s</strike>,\n'%label)
-                                    # "flag" this is done .... euwww
-                                    label = None
-                            if label is not None:
-                                if hrefable:
-                                    old = '<a href="%s%s">%s</a>'%(classname, args[k], label)
+                                    subml.append('<strike>%s</strike>'%label)
                                 else:
-                                    old = label;
-                                cell.append('%s: %s' % (k,old))
-                                if current.has_key(k):
-                                    cell[-1] += ' -> %s'%current[k]
-                                    current[k] = old
-
-                        elif isinstance(prop, hyperdb.Date) and args[k]:
-                            d = date.Date(args[k]).local(timezone)
-                            cell.append('%s: %s'%(k, str(d)))
-                            if current.has_key(k):
-                                cell[-1] += ' -> %s' % current[k]
-                                current[k] = str(d)
-
-                        elif isinstance(prop, hyperdb.Interval) and args[k]:
-                            d = date.Interval(args[k])
-                            cell.append('%s: %s'%(k, str(d)))
-                            if current.has_key(k):
-                                cell[-1] += ' -> %s'%current[k]
-                                current[k] = str(d)
-
-                        elif isinstance(prop, hyperdb.String) and args[k]:
-                            cell.append('%s: %s'%(k, cgi.escape(args[k])))
-                            if current.has_key(k):
-                                cell[-1] += ' -> %s'%current[k]
-                                current[k] = cgi.escape(args[k])
-
-                        elif not args[k]:
-                            if current.has_key(k):
-                                cell.append('%s: %s'%(k, current[k]))
-                                current[k] = '(no value)'
+                                    if hrefable:
+                                        subml.append('<a href="%s%s">%s</a>'%(
+                                            classname, linkid, label))
+                                    else:
+                                        subml.append(label)
+                            ml.append(sublabel + ', '.join(subml))
+                        cell.append('%s:\n  %s'%(k, ', '.join(ml)))
+                    elif isinstance(prop, hyperdb.Link) and args[k]:
+                        label = classname + args[k]
+                        # if we have a label property, try to use it
+                        # TODO: test for node existence even when
+                        # there's no labelprop!
+                        if labelprop is not None and labelprop != 'id':
+                            try:
+                                label = linkcl.get(args[k], labelprop)
+                            except IndexError:
+                                comments['no_link'] = _('''<strike>The
+                                    linked node no longer
+                                    exists</strike>''')
+                                cell.append(' <strike>%s</strike>,\n'%label)
+                                # "flag" this is done .... euwww
+                                label = None
+                        if label is not None:
+                            if hrefable:
+                                old = '<a href="%s%s">%s</a>'%(classname, args[k], label)
                             else:
-                                cell.append('%s: (no value)'%k)
-
-                        else:
-                            cell.append('%s: %s'%(k, str(args[k])))
+                                old = label;
+                            cell.append('%s: %s' % (k,old))
                             if current.has_key(k):
                                 cell[-1] += ' -> %s'%current[k]
-                                current[k] = str(args[k])
+                                current[k] = old
+
+                    elif isinstance(prop, hyperdb.Date) and args[k]:
+                        d = date.Date(args[k]).local(timezone)
+                        cell.append('%s: %s'%(k, str(d)))
+                        if current.has_key(k):
+                            cell[-1] += ' -> %s' % current[k]
+                            current[k] = str(d)
+
+                    elif isinstance(prop, hyperdb.Interval) and args[k]:
+                        d = date.Interval(args[k])
+                        cell.append('%s: %s'%(k, str(d)))
+                        if current.has_key(k):
+                            cell[-1] += ' -> %s'%current[k]
+                            current[k] = str(d)
+
+                    elif isinstance(prop, hyperdb.String) and args[k]:
+                        cell.append('%s: %s'%(k, cgi.escape(args[k])))
+                        if current.has_key(k):
+                            cell[-1] += ' -> %s'%current[k]
+                            current[k] = cgi.escape(args[k])
+
+                    elif not args[k]:
+                        if current.has_key(k):
+                            cell.append('%s: %s'%(k, current[k]))
+                            current[k] = '(no value)'
+                        else:
+                            cell.append('%s: (no value)'%k)
+
                     else:
-                        # property no longer exists
-                        comments['no_exist'] = _('''<em>The indicated property
-                            no longer exists</em>''')
-                        cell.append('<em>%s: %s</em>\n'%(k, str(args[k])))
+                        cell.append('%s: %s'%(k, str(args[k])))
+                        if current.has_key(k):
+                            cell[-1] += ' -> %s'%current[k]
+                            current[k] = str(args[k])
+
                 arg_s = '<br />'.join(cell)
             else:
                 # unkown event!!
@@ -862,6 +872,10 @@ class StringHTMLProperty(HTMLProperty):
             except KeyError:
                 return '%s%s'%(s1, s2)
 
+    def hyperlinked(self):
+        ''' Render a "hyperlinked" version of the text '''
+        return self.plain(hyperlink=1)
+
     def plain(self, escape=0, hyperlink=0):
         ''' Render a "plain" representation of the property
             
@@ -876,6 +890,7 @@ class StringHTMLProperty(HTMLProperty):
         else:
             s = str(self._value)
         if hyperlink:
+            # no, we *must* escape this text
             if not escape:
                 s = cgi.escape(s)
             s = self.hyper_re.sub(self._hyper_repl, s)
index 0700966431ba6f3bf85be779e9e1ae8bca867f18..6d861429747b2f1b4470cac1d754db75d4dd80ee 100644 (file)
@@ -146,7 +146,7 @@ python:db.user.classhelp('username,realname,address', property='nosy', width='60
    </tr>
    <tr>
     <td colspan="4" class="content">
-     <pre tal:content="msg/content">content</pre>
+     <pre tal:content="structure msg/content/hyperlinked">content</pre>
     </td>
    </tr>
   </tal:block>
index dde4f082b7a9ce11d71329de258c7a58bcc0bb18..b336dd0b33054231a7238c002ec304a162330301 100644 (file)
 
   <form method="POST" action="">
    <p class="userblock" tal:condition="python:request.user.username=='anonymous'">
+    <b>Login</b><br>
     <input size="10" name="__login_name"><br>
     <input size="10" type="password" name="__login_password"><br>
-    <input type="submit" name=":action" value="login">
+    <input type="submit" name=":action" value="Login">
     <span tal:replace="structure request/indexargs_form" />
     <a href="user?:template=register">Register</a><br>
-    <a href="user?:template=forgotten">Forgotten your password?</a><br>
+    <a href="user?:template=forgotten">Lost your password?</a><br>
    </p>
   </form>
    
   <p class="userblock" tal:condition="python:request.user.username != 'anonymous'">
-   <b>Hello,</b><br><b tal:content="request/user/username">username</b><br>
+   <b>Hello,</b> <b tal:content="request/user/username">username</b><br>
    <a tal:attributes="href string:issue?:sort=-activity&:group=priority&:filter=status,assignedto&:columns=id,activity,title,creator,status&status=-1,1,2,3,4,5,6,7&assignedto=${request/user/id}">My Issues</a><br>
    <a tal:attributes="href string:user${request/user/id}">My Details</a><br>
    <a tal:attributes="href python:request.indexargs_href('',