From: richard Date: Thu, 28 Aug 2003 05:53:40 +0000 (+0000) Subject: various cosmetic fixes X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=a2c41ca5b2f7ea16af3d49be419611db091d6d6f;p=roundup.git various cosmetic fixes git-svn-id: http://svn.roundup-tracker.org/svnroot/roundup/trunk@1840 57a73879-2fb5-44c3-a270-3262357dd7e2 --- diff --git a/CHANGES.txt b/CHANGES.txt index d5a0b9b..60a72b5 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -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 diff --git a/doc/customizing.txt b/doc/customizing.txt index 9cdf143..ca5ffec 100644 --- a/doc/customizing.txt +++ b/doc/customizing.txt @@ -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 diff --git a/roundup/cgi/templating.py b/roundup/cgi/templating.py index 55e0b7d..4b1b374 100644 --- a/roundup/cgi/templating.py +++ b/roundup/cgi/templating.py @@ -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'] = _('''The - linked node no longer - exists''') - subml.append('%s'%label) - else: - if hrefable: - subml.append('%s'%( - 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'] = _('''The indicated property + no longer exists''') + cell.append('%s: %s\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'] = _('''The linked node no longer exists''') - cell.append(' %s,\n'%label) - # "flag" this is done .... euwww - label = None - if label is not None: - if hrefable: - old = '%s'%(classname, args[k], label) + subml.append('%s'%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('%s'%( + 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'] = _('''The + linked node no longer + exists''') + cell.append(' %s,\n'%label) + # "flag" this is done .... euwww + label = None + if label is not None: + if hrefable: + old = '%s'%(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'] = _('''The indicated property - no longer exists''') - cell.append('%s: %s\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 = '
'.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) diff --git a/templates/classic/html/issue.item.html b/templates/classic/html/issue.item.html index 0700966..6d86142 100644 --- a/templates/classic/html/issue.item.html +++ b/templates/classic/html/issue.item.html @@ -146,7 +146,7 @@ python:db.user.classhelp('username,realname,address', property='nosy', width='60 -
content
+
content
diff --git a/templates/classic/html/page.html b/templates/classic/html/page.html index dde4f08..b336dd0 100644 --- a/templates/classic/html/page.html +++ b/templates/classic/html/page.html @@ -68,17 +68,18 @@

+ Login


- + Register
- Forgotten your password?
+ Lost your password?

- Hello,
username
+ Hello, username
My Issues
My Details