[CalendarServer-changes] [8080] CalendarServer/branches/users/glyph/other-html/twistedcaldav
source_changes at macosforge.org
source_changes at macosforge.org
Tue Sep 13 12:10:45 PDT 2011
Revision: 8080
http://trac.macosforge.org/projects/calendarserver/changeset/8080
Author: glyph at apple.com
Date: 2011-09-13 12:10:45 -0700 (Tue, 13 Sep 2011)
Log Message:
-----------
pixel-perfect for whole calendar principal page.
Modified Paths:
--------------
CalendarServer/branches/users/glyph/other-html/twistedcaldav/directory/directory-principal-resource.html
CalendarServer/branches/users/glyph/other-html/twistedcaldav/directory/principal.py
CalendarServer/branches/users/glyph/other-html/twistedcaldav/extensions.py
Modified: CalendarServer/branches/users/glyph/other-html/twistedcaldav/directory/directory-principal-resource.html
===================================================================
--- CalendarServer/branches/users/glyph/other-html/twistedcaldav/directory/directory-principal-resource.html 2011-09-13 19:10:36 UTC (rev 8079)
+++ CalendarServer/branches/users/glyph/other-html/twistedcaldav/directory/directory-principal-resource.html 2011-09-13 19:10:45 UTC (rev 8080)
@@ -29,14 +29,13 @@
Read-write Proxy For:
<t:slot name="readWriteProxyFor"/>
Read-only Proxy For:
-<t:slot name="readOnlyProxyFor"/>
-<t:transparent
+<t:slot name="readOnlyProxyFor"/><t:transparent
t:render="extra"><t:transparent t:render="enabledForCalendaring">
Calendar Homes:
<t:slot name="calendarHomes" />
Calendar user addresses:
<t:slot name="calendarUserAddresses" /></t:transparent><t:transparent
t:render="enabledForAddressBooks">
-Address Book homes:<t:slot name="addressBookHomes" />
-</t:transparent></t:transparent></blockquote></pre>
-</div>
+Address Book homes:
+<t:slot name="addressBookHomes"
+/></t:transparent></t:transparent></blockquote></pre></div>
Modified: CalendarServer/branches/users/glyph/other-html/twistedcaldav/directory/principal.py
===================================================================
--- CalendarServer/branches/users/glyph/other-html/twistedcaldav/directory/principal.py 2011-09-13 19:10:36 UTC (rev 8079)
+++ CalendarServer/branches/users/glyph/other-html/twistedcaldav/directory/principal.py 2011-09-13 19:10:45 UTC (rev 8080)
@@ -550,9 +550,7 @@
emailAddresses=formatList(record.emailAddresses),
principalUID=str(self.resource.principalUID()),
principalURL=formatLink(self.resource.principalURL()),
- alternateURIs=formatList(
- formatLink(u) for u in self.resource.alternateURIs()
- ),
+ alternateURIs=formatLinks(self.resource.alternateURIs()),
groupMembers=self.resource.groupMembers().addCallback(
formatPrincipals
),
@@ -571,10 +569,50 @@
@renderer
def extra(self, request, tag):
"""
+ No-op; implemented in subclass.
+ """
+ return ''
+
+
+ @renderer
+ def enabledForCalendaring(self, request, tag):
+ """
+ No-op; implemented in subclass.
+ """
+ return ''
+
+
+ @renderer
+ def enabledForAddressBooks(self, request, tag):
+ """
+ No-op; implemented in subclass.
+ """
+ return ''
+
+
+
+class DirectoryPrincipalElement(DirectoryElement):
+ """
+ L{DirectoryPrincipalElement} is a renderer for directory details.
+ """
+
+ @renderer
+ def resourceDetail(self, request, tag):
+ """
+ Render the directory principal's details.
+ """
+ return DirectoryPrincipalDetailElement(self.resource)
+
+
+class DirectoryCalendarPrincipalDetailElement(DirectoryPrincipalDetailElement):
+
+ @renderer
+ def extra(self, request, tag):
+ """
Renderer for extra directory body items for calendar/addressbook
principals.
"""
- return ''
+ return tag
@renderer
@@ -583,6 +621,15 @@
Renderer which returns its tag when the wrapped record is enabled for
calendaring.
"""
+ resource = self.resource
+ record = resource.record
+ if record.enabledForCalendaring:
+ return tag.fillSlots(
+ calendarUserAddresses=formatLinks(
+ resource.calendarUserAddresses()
+ ),
+ calendarHomes=formatLinks(resource.calendarHomeURLs())
+ )
return ''
@@ -592,24 +639,30 @@
Renderer which returnst its tag when the wrapped record is enabled for
addressbooks.
"""
+ resource = self.resource
+ record = resource.record
+ if record.enabledForAddressBooks:
+ return tag.fillSlots(
+ addressBookHomes=formatLinks(resource.addressBookHomeURLs())
+ )
return ''
-class DirectoryPrincipalElement(DirectoryElement):
+class DirectoryCalendarPrincipalElement(DirectoryPrincipalElement):
"""
- L{DirectoryPrincipalElement} is a renderer for directory details.
+ L{DirectoryPrincipalElement} is a renderer for directory details, with
+ calendaring additions.
"""
@renderer
def resourceDetail(self, request, tag):
"""
- Render the directory principal's details.
+ Render the directory calendar principal's details.
"""
- return DirectoryPrincipalDetailElement(self.resource)
+ return DirectoryCalendarPrincipalDetailElement(self.resource)
-
class DirectoryPrincipalResource (
PropfindCacheMixin, PermissionsMixIn, DAVPrincipalResource):
"""
@@ -1024,6 +1077,9 @@
return addresses
+ def htmlElement(self):
+ return DirectoryCalendarPrincipalElement(self)
+
def canonicalCalendarUserAddress(self):
"""
Return a CUA for this principal, preferring in this order:
@@ -1265,7 +1321,14 @@
return tags.a(href=url)(url)
+def formatLinks(urls):
+ """
+ Format a list of URL strings as a list of twisted.web.template DOM links.
+ """
+ return formatList(formatLink(link) for link in urls)
+
+
def format_list(items, *args):
def genlist():
try:
Modified: CalendarServer/branches/users/glyph/other-html/twistedcaldav/extensions.py
===================================================================
--- CalendarServer/branches/users/glyph/other-html/twistedcaldav/extensions.py 2011-09-13 19:10:36 UTC (rev 8079)
+++ CalendarServer/branches/users/glyph/other-html/twistedcaldav/extensions.py 2011-09-13 19:10:45 UTC (rev 8080)
@@ -498,7 +498,7 @@
)
@whenChildren.addCallback
def gotChildren(children):
- for even, [child, name] in zip(cycle(["even", "odd"]), children):
+ for even, [child, name] in zip(cycle(["odd", "even"]), children):
[url, name, size, lastModified, contentType] = map(
str, self.resource.getChildDirectoryEntry(
child, name, request)
@@ -550,7 +550,7 @@
@whenAllProperties.addCallback
def gotValues(items):
- for even, [name, value] in zip(cycle(["even", "odd"]), items):
+ for even, [name, value] in zip(cycle(["odd", "even"]), items):
if value is None:
value = tags.i("(no value)")
elif value is accessDeniedValue:
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20110913/8e190cce/attachment.html>
More information about the calendarserver-changes
mailing list