new concept type SimpleBlogItem, stores text in concept, not in resource
This commit is contained in:
parent
58fda446ff
commit
380aba02ed
4 changed files with 59 additions and 10 deletions
|
@ -5,6 +5,19 @@
|
||||||
xmlns:browser="http://namespaces.zope.org/browser"
|
xmlns:browser="http://namespaces.zope.org/browser"
|
||||||
i18n_domain="zope">
|
i18n_domain="zope">
|
||||||
|
|
||||||
|
<zope:adapter
|
||||||
|
factory="loops.compound.blog.post.SimpleBlogPost"
|
||||||
|
provides="loops.compound.blog.interfaces.ISimpleBlogPost"
|
||||||
|
trusted="True" />
|
||||||
|
<zope:class class="loops.compound.blog.post.SimpleBlogPost">
|
||||||
|
<require permission="zope.View"
|
||||||
|
interface="loops.compound.blog.interfaces.ISimpleBlogPost" />
|
||||||
|
<require permission="zope.View"
|
||||||
|
attributes="context" />
|
||||||
|
<require permission="zope.ManageContent"
|
||||||
|
set_schema="loops.compound.blog.interfaces.ISimpleBlogPost" />
|
||||||
|
</zope:class>
|
||||||
|
|
||||||
<zope:adapter
|
<zope:adapter
|
||||||
factory="loops.compound.blog.post.BlogPost"
|
factory="loops.compound.blog.post.BlogPost"
|
||||||
provides="loops.compound.blog.interfaces.IBlogPost"
|
provides="loops.compound.blog.interfaces.IBlogPost"
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
#
|
#
|
||||||
# Copyright (c) 2008 Helmut Merz helmutm@cy55.de
|
# Copyright (c) 2013 Helmut Merz helmutm@cy55.de
|
||||||
#
|
#
|
||||||
# This program is free software; you can redistribute it and/or modify
|
# This program is free software; you can redistribute it and/or modify
|
||||||
# it under the terms of the GNU General Public License as published by
|
# it under the terms of the GNU General Public License as published by
|
||||||
|
@ -18,8 +18,6 @@
|
||||||
|
|
||||||
"""
|
"""
|
||||||
Blogs (weblogs) and blog posts.
|
Blogs (weblogs) and blog posts.
|
||||||
|
|
||||||
$Id$
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
|
@ -27,9 +25,32 @@ from zope.interface import Interface, Attribute
|
||||||
from zope import interface, component, schema
|
from zope import interface, component, schema
|
||||||
|
|
||||||
from loops.compound.interfaces import ICompound
|
from loops.compound.interfaces import ICompound
|
||||||
|
from loops.interfaces import HtmlText
|
||||||
from loops.util import _
|
from loops.util import _
|
||||||
|
|
||||||
|
|
||||||
|
class ISimpleBlogPost(ICompound):
|
||||||
|
""" An item on a blog, sort of a diary item, minimal version.
|
||||||
|
"""
|
||||||
|
|
||||||
|
date = schema.Datetime(
|
||||||
|
title=_(u'Date/Time'),
|
||||||
|
description=_(u'The date and time the information '
|
||||||
|
'was posted.'),
|
||||||
|
required=True,)
|
||||||
|
date.default_method = datetime.now
|
||||||
|
creator = schema.ASCIILine(
|
||||||
|
title=_(u'Creator'),
|
||||||
|
description=_(u'The principal id of the user that created '
|
||||||
|
'the blog post.'),
|
||||||
|
readonly=True,
|
||||||
|
required=False,)
|
||||||
|
text = HtmlText(
|
||||||
|
title=_(u'Text'),
|
||||||
|
description=_(u'The text of your blog entry'),
|
||||||
|
required=False)
|
||||||
|
|
||||||
|
|
||||||
class IBlogPost(ICompound):
|
class IBlogPost(ICompound):
|
||||||
""" An item on a blog, sort of a diary item.
|
""" An item on a blog, sort of a diary item.
|
||||||
"""
|
"""
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
#
|
#
|
||||||
# Copyright (c) 2008 Helmut Merz helmutm@cy55.de
|
# Copyright (c) 2013 Helmut Merz helmutm@cy55.de
|
||||||
#
|
#
|
||||||
# This program is free software; you can redistribute it and/or modify
|
# This program is free software; you can redistribute it and/or modify
|
||||||
# it under the terms of the GNU General Public License as published by
|
# it under the terms of the GNU General Public License as published by
|
||||||
|
@ -18,8 +18,6 @@
|
||||||
|
|
||||||
"""
|
"""
|
||||||
Blogs and blog posts.
|
Blogs and blog posts.
|
||||||
|
|
||||||
$Id$
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
from zope.cachedescriptors.property import Lazy
|
from zope.cachedescriptors.property import Lazy
|
||||||
|
@ -32,14 +30,31 @@ from zope.traversing.api import getName
|
||||||
|
|
||||||
from loops.common import adapted
|
from loops.common import adapted
|
||||||
from loops.compound.base import Compound
|
from loops.compound.base import Compound
|
||||||
from loops.compound.blog.interfaces import IBlogPost
|
from loops.compound.blog.interfaces import ISimpleBlogPost, IBlogPost
|
||||||
from loops.resource import Resource
|
from loops.resource import Resource
|
||||||
from loops.security.common import restrictView
|
from loops.security.common import restrictView
|
||||||
from loops.setup import addAndConfigureObject
|
from loops.setup import addAndConfigureObject
|
||||||
from loops.type import TypeInterfaceSourceList
|
from loops.type import TypeInterfaceSourceList
|
||||||
|
|
||||||
|
|
||||||
TypeInterfaceSourceList.typeInterfaces += (IBlogPost,)
|
TypeInterfaceSourceList.typeInterfaces += (ISimpleBlogPost, IBlogPost,)
|
||||||
|
|
||||||
|
|
||||||
|
class SimpleBlogPost(Compound):
|
||||||
|
|
||||||
|
implements(IBlogPost)
|
||||||
|
|
||||||
|
textContentType = 'text/html'
|
||||||
|
|
||||||
|
_adapterAttributes = Compound._adapterAttributes + ('creator',)
|
||||||
|
_contextAttributes = list(ISimpleBlogPost)
|
||||||
|
_noexportAttributes = _adapterAttributes
|
||||||
|
_textIndexAttributes = ('text',)
|
||||||
|
|
||||||
|
@property
|
||||||
|
def creator(self):
|
||||||
|
cr = IZopeDublinCore(self.context).creators
|
||||||
|
return cr and cr[0] or None
|
||||||
|
|
||||||
|
|
||||||
class BlogPost(Compound):
|
class BlogPost(Compound):
|
||||||
|
|
|
@ -53,7 +53,7 @@
|
||||||
<a tal:omit-tag="not:url"
|
<a tal:omit-tag="not:url"
|
||||||
tal:content="data/creator"
|
tal:content="data/creator"
|
||||||
tal:attributes="href url">Will Smith</a>
|
tal:attributes="href url">Will Smith</a>
|
||||||
<span tal:condition="item/adapted/private">
|
<span tal:condition="item/adapted/private|nothing">
|
||||||
(<span i18n:translate="">Private</span>)
|
(<span i18n:translate="">Private</span>)
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
|
@ -65,7 +65,7 @@
|
||||||
<div class="text"
|
<div class="text"
|
||||||
tal:content="structure item/render">Here comes the text...</div>
|
tal:content="structure item/render">Here comes the text...</div>
|
||||||
<div class="comment"
|
<div class="comment"
|
||||||
tal:define="comment data/privateComment"
|
tal:define="comment data/privateComment|nothing"
|
||||||
tal:condition="comment">
|
tal:condition="comment">
|
||||||
<h4 i18n:translate="" class="headline">Private Comment</h4>
|
<h4 i18n:translate="" class="headline">Private Comment</h4>
|
||||||
<div tal:content="structure python:
|
<div tal:content="structure python:
|
||||||
|
|
Loading…
Add table
Reference in a new issue