def test_confencoder(self): self.assert_(ConfEncoder().encode(Conf())) self.assert_(ConfEncoder().encode(Conf(**{"a": "a", "b": 1}))) self.assert_(ConfEncoder().encode(ObjectConf())) self.assert_(ConfEncoder().encode( ObjectConf(**{ "id": "a", "name": "1" })))
# Copyright 2012-2014 Arndt Droullier, Nive GmbH. All rights reserved. # Released under GPL3. See license.txt """ Item ---- """ from nive_datastore.i18n import _ from nive.components.baseobjects import ObjectContainerBase from nive.definitions import ObjectConf class item(ObjectContainerBase): def Init(self): self.queryRestraints = {}, {} # Root definition ------------------------------------------------------------------ #@nive_module configuration = ObjectConf( id="item", context="nive_datastore.item.item", extensions=("nive_datastore.pydispatch.Dispatcher", ), name=_(u"Data item"), description=u"")
self.ListenEvent("commit", "TextToTitle") def TextToTitle(self): text = ConvertHTMLToText(self.data.get("textblock"), removeReST=True) self.meta["title"] = CutText(text, self.titleLen, postfix=u"") return True # text type definition ------------------------------------------------------------------ #@nive_module configuration = ObjectConf( id="text", name=_(u"Text"), dbparam="texts", context="nive.cms.text.text", template="text.pt", selectTag=StagPageElement, icon="nive.cms.cmsview:static/images/types/text.png", description= _(u"Text element for the web page. Can be used to add headers, preformatted text and paragraphs to the web page. " )) configuration.data = [ FieldConf(id="textblock", datatype="htext", size=100000, default=u"", name=_(u"Text"), fulltext=True, description=u""), ]
elif menu == u"level": p = self.GetPage().parent if not p: #root p = self.GetPage() return p.GetPages(hidden=0, **kw) return [] # text type definition ------------------------------------------------------------------ #@nive_module configuration = ObjectConf( id = "menublock", name = _(u"Navigation"), dbparam = "menublocks", context = "nive_cms.menublock.menublock", template = "menublock.pt", selectTag = StagPageElement, icon = "nive_cms.cmsview:static/images/types/menublock.png", description = _(u"Element to render navigation trees and linked table of contents. The menublock can be used as main navigation for the web page.") ) menu=[ {'id': u'sub', 'name': _(u'Sub pages')}, {'id': u'level', 'name': _(u'Same level pages')}, {'id': u'tree', 'name': _(u'Tree navigation')}, {'id': u'subtree', 'name': _(u'Tree navigation - first level as base')}, ] configuration.data = [ FieldConf(id="menutype", datatype="list", size=12, default=u"", name=_(u"Menu type"), listItems=menu, description=u"") ] fields = ["title", "menutype", "pool_groups"]
for g in groups: if g in self.groups: return True return False # user definition ------------------------------------------------------------------ from nive.definitions import StagUser, ObjectConf, FieldConf from nive_userdb.app import UsernameValidator, EmailValidator, PasswordValidator #@nive_module configuration = ObjectConf( id = "user", name = _(u"User"), dbparam = "users", context = "nive_userdb.user.user", template = "user.pt", selectTag = StagUser, container = False, description = __doc__ ) # split the fields up in system and extended data. Makes customizing easier. system = [ FieldConf(id="name", datatype="string", size= 30, default=u"", required=1, name=_(u"User ID"), description=u"", validator=UsernameValidator), FieldConf(id="email", datatype="email", size=255, default=u"", required=1, name=_(u"Email"), description=u"", validator=EmailValidator), FieldConf(id="password", datatype="password", size=100, default=u"", required=1, name=_(u"Password"), description=u"", validator=PasswordValidator), FieldConf(id="groups", datatype="checkbox", size=255, default=u"", name=_(u"Groups"), settings={"codelist":"groups"}, description=u""),
elif menu == u"level": p = self.GetPage().GetParent() if not p: #root p = self.GetPage() return p.GetPages(hidden=0) return [] # text type definition ------------------------------------------------------------------ #@nive_module configuration = ObjectConf( id = "menublock", name = _(u"Navigation"), dbparam = "menublocks", context = "nive.cms.menublock.menublock", template = "menublock.pt", selectTag = StagPageElement, icon = "nive.cms.cmsview:static/images/types/menublock.png", description = _(u"Element to render navigation trees and linked table of contents. The menublock can be used as main navigation for the web page.") ) css =[ {'id': u'cols1_2', 'name': _(u'50 % width left')}, {'id': u'cols1_3', 'name': _(u'33 % width left')}, {'id': u'cols2_3', 'name': _(u'66 % width left')}, {'id': u'colsRight1_2', 'name': _(u'50 % width right')}, {'id': u'colsRight1_3', 'name': _(u'33 % width right')}, {'id': u'colsRight2_3', 'name': _(u'66 % width right')}, ] menu=[ {'id': u'sub', 'name': _(u'Sub pages')}, {'id': u'level', 'name': _(u'Same level pages')}, {'id': u'tree', 'name': _(u'Tree navigation')},
self.ListenEvent("commit", "TextToTitle") def TextToTitle(self, **kw): text = ConvertHTMLToText(self.data.get("textblock"), removeReST=True) self.meta["title"] = CutText(text, self.titleLen, postfix=u"") return True # note type definition ------------------------------------------------------------------ #@nive_module configuration = ObjectConf( id = "note", name = _(u"Note"), dbparam = "notes", context = "nive_cms.note.note", template = "note.pt", selectTag = StagPageElement, icon = "nive_cms.cmsview:static/images/types/note.png", description = _(u"Simple text note for authors. The note is only visible to cms authors and not published.") ) configuration.data = [ FieldConf(id="textblock", datatype="htext", size=50000, default=u"", name=_(u"Note"), description=u"") ] fields = ["textblock", "pool_groups"] configuration.forms = {"create": {"fields":fields}, "edit": {"fields":fields}} jsonfields = fields + ["pool_type","pool_filename"] configuration.toJson = tuple(jsonfields)
return r["items"] # views ------------------------------------------------------------------------- def astext(context, request): return context.title + "\r\n\r\n" + ConvertHTMLToText(context.textblock) # configuration ----------------------------------------------------------------- configuration = ObjectConf( id="article_adv", name="Article", dbparam="article_adv", context=MyArticle, template="nive_tmpl_element_advanced:article.pt", selectTag=20, icon = "nive_cms.cmsview:static/images/types/element.png", description="" ) category = ( {"id": "politics", "name": "Politics"}, {"id": "music", "name": "Music"}, {"id": "tech", "name": "Technical"}, ) configuration.data = ( FieldConf(id="textblock", datatype="htext", size=10000, default="", name="Text", fulltext=1, description=""), FieldConf(id="image", datatype="file", size=0, default="", name="Image file", description=""), FieldConf(id="link", datatype="url", size=255, default="", name="Link", description=""),
class code(PageElementBase): """ """ # text type definition ------------------------------------------------------------------ #@nive_module configuration = ObjectConf( id = "code", name = _(u"Code"), dbparam = "codes", context = "nive_cms.codeblock.code", template = "code.pt", selectTag = StagPageElement, icon = "nive_cms.cmsview:static/images/types/code.png", description = _(u"Text element to add code snippets to web pages. Supports Javascript, HTML and CSS.") ) ct =[ {'id': u'raw', 'name': _(u'No format')}, {'id': u'js', 'name': _(u'Javascript')}, {'id': u'html', 'name': _(u'HTML')}, {'id': u'css', 'name': _(u'CSS')}, ] configuration.data = [ FieldConf(id="codetype", datatype="list", size=10, default="raw", name=_(u"Type"), listItems=ct, fulltext=False, description=u""), FieldConf(id="codeblock", datatype="code", size=50000, default="", name=_(u"Code"), fulltext=False, description=u""), ]
# ----------------------------------------------------------------- class text(object): pass class text1(object): pass class text2(object): pass class text3(object): pass testconf = ObjectConf( id = "text", name = "Text", dbparam = "texts", context = "nive.tests.test_helper.text", selectTag = 1, description = "" ) testconf.data = ( FieldConf(id="textblock", datatype="htext", size=10000, default="", name="Text", fulltext=True, description="") ) testconf.forms = { "create": { "fields": ["textblock"], "actions": ["create"]}, "edit": { "fields": ["textblock"], "actions": ["save"]} } configuration = testconf
from nive.definitions import ObjectConf configuration = ObjectConf( id="article", name="Article", dbparam="article", context="nive_cms.baseobjects.PageElementBase", template="nive_tmpl_element_python:article.pt", selectTag=20, icon="nive_cms.cmsview:static/images/types/element.png", description="" ) configuration.data = ( FieldConf(id="textblock", datatype="htext", size=10000, default="", name="Text", fulltext=1, description=""), FieldConf(id="image", datatype="file", size=0, default="", name="Image file", description=""), FieldConf(id="link", datatype="url", size=255, default="", name="Link", description=""), ) configuration.forms = { "create": {"fields":["title", "textblock", "image"]}, "edit": {"fields":["title", "textblock", "image"]} }
return groups in self.groups for g in groups: if g in self.groups: return True return False # user definition ------------------------------------------------------------------ from nive.definitions import StagUser, ObjectConf, FieldConf from nive_userdb.app import UsernameValidator, EmailValidator, PasswordValidator #@nive_module configuration = ObjectConf(id="user", name=_(u"User"), dbparam="users", context="nive_userdb.user.user", template="user.pt", selectTag=StagUser, container=False, description=__doc__) # split the fields up in system and extended data. Makes customizing easier. system = [ FieldConf(id="name", datatype="string", size=30, default=u"", required=1, name=_(u"User ID"), description=u"", validator=UsernameValidator), FieldConf(id="email",
storage.Register("nive_newsuser:newsuser_configuration") #@nive_module configuration = ObjectConf( id = "regform", name = "Subscriptions", dbparam = "regform", context = CmsFormObj, template = "nive_newsuser:form.pt", selectTag = StagPageElement, icon = "nive.cms.cmsview:static/images/types/element.png", description = __doc__, # system registration event to trigger userdb.newsuser installation events = (Conf(event="startup", callback=SetupNewsuser),), # the form to be displayed on the web page subscriptionForm = [ FieldConf(id="email", datatype="email", size= 200, default="", required=1, name="E-Mail", description=""), ], mailtmpl = "nive_newsuser:activationmail.pt", adminNotification = None, # Select the application for newsuser storage and the sendMail tool provider. # The value must be the application id registered in the portal (by default userdb) sendMailProvider = "userdb", storageApplication = "userdb" ) # these are the newsuser element fields configuration.data = [ FieldConf(id="mailtitle", datatype="string", size=255, default="", name="Activation mail title",description="Used as email title."),
# views ------------------------------------------------------------------------- def astext(context, request): return context.title + "\r\n\r\n" + ConvertHTMLToText(context.textblock) # configuration ----------------------------------------------------------------- configuration = ObjectConf( id="article_adv", name="Article", dbparam="article_adv", context=MyArticle, template="nive_tmpl_element_advanced:article.pt", selectTag=20, icon="nive.cms.cmsview:static/images/types/element.png", description="") category = ( { "id": "politics", "name": "Politics" }, { "id": "music", "name": "Music" }, {
from nive.definitions import ObjectConf configuration = ObjectConf( id="article", name="Article", dbparam="article", context="nive.components.objects.base.PageElementBase", template="nive_tmpl_element_python:article.pt", selectTag=20, icon="nive.cms.cmsview:static/images/types/element.png", description="" ) configuration.data = ( FieldConf(id="textblock", datatype="htext", size=10000, default="", name="Text", fulltext=1, description=""), FieldConf(id="image", datatype="file", size=0, default="", name="Image file", description=""), FieldConf(id="link", datatype="url", size=255, default="", name="Link", description=""), ) configuration.forms = { "create": {"fields":["title", "textblock", "image"]}, "edit": {"fields":["title", "textblock", "image"]} }
def GetContainer(self): # return the current element container return self.parent #@nive_module configuration = ObjectConf( id = "box", name = _(u"Box"), dbparam = "box", context = "nive_cms.box.box", template = "box.pt", selectTag = StagPageElement, subtypes = ("nive.definitions.INonContainer",), container = True, icon = "nive_cms.cmsview:static/images/types/box.png", description = _(u"A box is a container to group elements on a page. It can be used as an" u"advanced styling element for web pages. The box itself only stores a title and styling selector.") ) # data definition ------------------------------------------------------------------ configuration.data = [ FieldConf(id="span", datatype="list", size=20, default=u"", listItems=(), name=_(u"Block size"), description=u""), FieldConf(id="spanoffset", datatype="list", size=20, default=u"", listItems=(), name=_(u"Block empty offset left"), description=_(u"Please note: The blocksize and offset values added together can not be larger than 12. Adjust both fields accordingly.")), FieldConf(id="highlight", datatype="bool", size=2, default=False,
def Init(self): self.ListenEvent("commit", "FilenameToTitle") def FilenameToTitle(self): if self.files.get("file") and not self.meta["title"]: self.meta["title"] = self.files.get("file")["filename"] # file type definition ------------------------------------------------------------------ #@nive_module configuration = ObjectConf( id="file", name=_(u"File"), dbparam="files", context="nive.cms.file.file", template="file.pt", selectTag=StagPageElement, icon="nive.cms.cmsview:static/images/types/file.png", description= _(u"The file element provides a simple file download with title and optional description." )) configuration.data = [ FieldConf(id="file", datatype="file", size=0, default=u"", fulltext=1, name=_(u"File"), description=u""), FieldConf(id="textblock",
class media(PageElementFileBase): def IsVideo(self): return self.data.get("player") == u"video" def IsAudio(self): return self.data.get("player") == u"audio" # media type definition ------------------------------------------------------------------ #@nive_module configuration = ObjectConf( id="media", name=_(u"Media"), dbparam="mediafile", context="nive_cms.media.media", template="media.pt", selectTag=StagPageElement, icon="nive_cms.cmsview:static/images/types/media.png", description=_( u"Element to insert audio or video files into the web page. Uses HTML 5 media" u"and audio tags and the browser's default player.")) player = [{ "id": u"video", "name": _(u"Video player") }, { "id": u"audio", "name": _(u"Audio player") }] configuration.data = [
from nive.definitions import StagPageElement, ObjectConf, FieldConf from nive_cms.baseobjects import PageElementBase class spacer(PageElementBase): pass # type definition ------------------------------------------------------------------ #@nive_module configuration = ObjectConf( id = "spacer", name = _(u"Spacer"), dbparam = "spacers", context = "nive_cms.spacer.spacer", template = "spacer.pt", selectTag = StagPageElement, icon = "nive_cms.cmsview:static/images/types/spacer.png", description = _(u"Styling element to add line breaks and vertical space between elements.") ) configuration.data = [ FieldConf(id="cssClass", datatype="list", size=5, default=u"", listItems=(), name=_(u"Styling"), description=u"") ] fields =["cssClass", "pool_groups"] configuration.forms = {"create": {"fields":fields}, "edit": {"fields":fields}} jsonfields = fields + ["pool_type","pool_filename"] configuration.toJson = tuple(jsonfields)
def IsVideo(self): return self.data.get("player")==u"video" def IsAudio(self): return self.data.get("player")==u"audio" # media type definition ------------------------------------------------------------------ #@nive_module configuration = ObjectConf( id = "media", name = _(u"Media"), dbparam = "mediafile", context = "nive.cms.media.media", template = "media.pt", selectTag = StagPageElement, icon = "nive.cms.cmsview:static/images/types/media.png", description = _(u"Element to insert audio or video files into the web page. Uses HTML 5 media" u"and audio tags and the browser's default player.") ) player = [{"id": u"video", "name": _(u"Video player")}, {"id": u"audio", "name": _(u"Audio player")}] configuration.data = [ FieldConf(id="media", datatype="file", size=0, default=u"", name=_(u"Mediafile"), description=u""), FieldConf(id="mediaalt", datatype="file", size=0, default=u"", name=_(u"Alternative format"), description=_(u"To support all browsers you need to provide two different file formats.")), FieldConf(id="player", datatype="list", size=10, listItems=player, default=u"", name=_(u"Player"), description=u""), FieldConf(id="textblock", datatype="htext", size=10000, default=u"", fulltext=1, name=_(u"Text"), description=u"")
#@nive_module configuration = ObjectConf( id="regform", name="Subscriptions", dbparam="regform", context=CmsFormObj, template="nive_newsuser:form.pt", selectTag=StagPageElement, icon="nive.cms.cmsview:static/images/types/element.png", description=__doc__, # system registration event to trigger userdb.newsuser installation events=(Conf(event="startup", callback=SetupNewsuser), ), # the form to be displayed on the web page subscriptionForm=[ FieldConf(id="email", datatype="email", size=200, default="", required=1, name="E-Mail", description=""), ], mailtmpl="nive_newsuser:activationmail.pt", adminNotification=None, # Select the application for newsuser storage and the sendMail tool provider. # The value must be the application id registered in the portal (by default userdb) sendMailProvider="userdb", storageApplication="userdb") # these are the newsuser element fields
returns True if the page is redirected in public mode. """ return self.data["pagelink"] def IsPage(self): return True # type definition ------------------------------------------------------------------ #@nive_module configuration = ObjectConf( id="page", name=_(u"Page"), dbparam="pages", context="nive.cms.page.page", template="page.pt", selectTag=StagPage, container=True, workflowEnabled=True, description=_( u"Pages are rendered as html files and make up the website.")) configuration.data = [ FieldConf(id="header", datatype="string", size=255, default=u"", fulltext=1, name=_(u"Page header"), description=_(u"Text shown at top of the page")), FieldConf(id="titleImage",
from nive_cms.i18n import _ from nive.definitions import StagPageElement, ObjectConf, FieldConf from nive_cms.baseobjects import PageElementBase class news(PageElementBase): pass # news type definition ------------------------------------------------------------------ # @nive_module configuration = ObjectConf( id="news", name=_(u"News"), dbparam="news", context="nive_cms.news.news", template="news.pt", selectTag=StagPageElement, icon="nive_cms.cmsview:static/images/types/news.png", description=_(u"Simple news item with title, text, image, publish date and link."), ) configuration.data = [ FieldConf(id="image", datatype="file", size=0, default=u"", name=_(u"Imagefile"), description=u""), FieldConf(id="textblock", datatype="htext", size=100000, default=u"", fulltext=1, name=_(u"Text"), description=u""), FieldConf( id="publish", datatype="date", size=0, default=u"", required=0, name=_(u"Date"),
# css class span for the css selection if self.data.cssClass=="teaserl": return u"span4" elif self.data.cssClass=="teasers": return u"span2" return u"span3" # image type definition ------------------------------------------------------------------ #@nive_module configuration = ObjectConf( id = "image", name = _(u"Image"), dbparam = "images", context = "nive_cms.image.image", template = "image.pt", selectTag = StagPageElement, extensions = [], icon = "nive_cms.cmsview:static/images/types/image.png", description = _(u"The image element inserts images into the web page.") ) configuration.data = [ FieldConf(id="image", datatype="file", size=0, default=u"", name=_(u"Imagefile")), FieldConf(id="imagefull", datatype="file", size=0, default=u"", name=_(u"Imagefile fullsize")), FieldConf(id="textblock", datatype="htext",size=100000,default=u"", name=_(u"Text"), fulltext=1, required=0), FieldConf(id="cssClass", datatype="list", size=10, default=u"", name=_(u"Styling"), listItems=()), FieldConf(id="link", datatype="url", size=1000, default=u"", name=_(u"Link")) ] if PILloaded and "nive_cms.extensions.images.ImageProcessor" in configuration.extensions:
return True def HTML(self): return markdown2.markdown(self.data.get("textblock")) # contact definition ------------------------------------------------------------------ #@nive_module configuration = ObjectConf( id = "mtext", name = "Markdown Text", dbparam = "mtext", context = mtext, template = "nive_markdowntext:mtext.pt", selectTag = StagPageElement, icon = "nive_cms.cmsview:static/images/types/element.png", description = __doc__, ) desc = _(u"""Markdown text format.<br/>Header: # Text<br>Subheader: ## Text<br>Lists: * or Numbers<br>Emphasis: *text* or **text**<br>Links: [link text](link address) <br><br/>See <a href="http://en.wikipedia.org/wiki/Markdown" target="_blank">Wikipedia</a> for a full description.""") # these are the contact element fields configuration.data = [ FieldConf(id="textblock", datatype="text", size=100000, default=u"", name=_(u"Text"), fulltext=True, description=desc), FieldConf(id="tcache", datatype="htext", size=100000, default=u"", name=_(u"Cached text"), fulltext=False), ] fields = ["textblock", "pool_groups"] configuration.forms = {"create": {"fields":fields}, "edit": {"fields":fields}}
self.ListenEvent("commit", "TextToTitle") def TextToTitle(self): text = ConvertHTMLToText(self.data.get("textblock"), removeReST=True) self.meta["title"] = CutText(text, self.titleLen, postfix=u"") return True # note type definition ------------------------------------------------------------------ #@nive_module configuration = ObjectConf( id="note", name=_(u"Note"), dbparam="notes", context="nive.cms.note.note", template="note.pt", selectTag=StagPageElement, icon="nive.cms.cmsview:static/images/types/note.png", description= _(u"Simple text note for authors. The note is only visible to cms authors and not published." )) configuration.data = [ FieldConf(id="textblock", datatype="htext", size=50000, default=u"", name=_(u"Note"), description=u"") ]
def Span(self): # css class span for the css selection if self.data.cssClass == "teaserl": return u"span4" elif self.data.cssClass == "teasers": return u"span2" return u"span3" # image type definition ------------------------------------------------------------------ #@nive_module configuration = ObjectConf( id="image", name=_(u"Image"), dbparam="images", context="nive_cms.image.image", template="image.pt", selectTag=StagPageElement, extensions=[], icon="nive_cms.cmsview:static/images/types/image.png", description=_(u"The image element inserts images into the web page.")) configuration.data = [ FieldConf(id="image", datatype="file", size=0, default=u"", name=_(u"Imagefile")), FieldConf(id="imagefull", datatype="file", size=0, default=u"",
def GetColumn(self, name): # if name == self.meta["title"]: return self return self.GetPage().GetColumn(name) # type definition ------------------------------------------------------------------ #@nive_module configuration = ObjectConf( id = "column", name = _(u"Column"), dbparam = "columnbox", context = "nive.cms.column.column", template = "column.pt", hidden = True, selectTag = StagPageElement, container = True, icon = "nive.cms.cmsview:static/images/types/column.png", description = _(u"A column is a container to group elements on a page. Columns are not added like" u"normal page elements but have to be defined manually in the main template. A column can" u"be inherited through a hierarchy of pages.") ) configuration.data = [ FieldConf(id="showsub", datatype="bool", size=2, default=1, name=_(u"Show on subpages"), description=_(u"If checked the column will be displayed on sub pages until overwritten.")) ] configuration.forms = { "create": {"fields": [FieldConf(id="title", datatype="string", size=10, default=u"", hidden=1, required=1, name=_(u"Column type")), "showsub", "pool_groups"]}, "edit": {"fields": ["showsub", "pool_groups"]} }
if self.data.cssClass=="teaserl": return u"span4" elif self.data.cssClass=="teasers": return u"span2" return u"span3" # image type definition ------------------------------------------------------------------ #@nive_module configuration = ObjectConf( id = "image", name = _(u"Image"), dbparam = "images", context = "nive.cms.image.image", template = "image.pt", selectTag = StagPageElement, extensions = [], icon = "nive.cms.cmsview:static/images/types/image.png", description = _(u"The image element inserts images into the web page.") ) css = [{"id": u"default", "name": _(u"Simple")}, {"id": u"left", "name": _(u"Float right")}, {"id": u"teaser", "name": _(u"Teaser")}, {"id": u"teaserl", "name": _(u"Teaser large")}, {"id": u"teasers", "name": _(u"Teaser small")}, ] configuration.data = [ FieldConf(id="image", datatype="file", size=0, default=u"", name=_(u"Imagefile")),
class text1(object): pass class text2(object): pass class text3(object): pass testconf = ObjectConf(id="text", name="Text", dbparam="texts", context="nive.tests.test_helper.text", selectTag=1, description="") testconf.data = (FieldConf(id="textblock", datatype="htext", size=10000, default="", name="Text", fulltext=True, description="")) testconf.forms = { "create": { "fields": ["textblock"], "actions": ["create"]
returns True if the page is redirected in public mode. """ return self.data["pagelink"] def IsPage(self): return True # type definition ------------------------------------------------------------------ #@nive_module configuration = ObjectConf( id = "page", name = _(u"Page"), dbparam = "pages", context = "nive.cms.page.page", template = "page.pt", selectTag = StagPage, container = True, workflowEnabled = True, description = _(u"Pages are rendered as html files and make up the website.") ) configuration.data = [ FieldConf(id="header", datatype="string", size=255, default=u"", fulltext=1, name=_(u"Page header"), description=_(u"Text shown at top of the page")), FieldConf(id="titleImage", datatype="file", size=0, default=u"", name=_(u"Title image"), description=""), FieldConf(id="description",datatype="text", size=500, default=u"", fulltext=1, name=_(u"Description"), description=_(u"Description used in meta tag for search engines etc.")), FieldConf(id="keywords", datatype="text", size=500, default=u"", fulltext=1, name=_(u"Keywords"), description=_(u"Keywords used in meta tag (not really used by search engines).")),
pass # contact definition ------------------------------------------------------------------ #@nive_module configuration = ObjectConf( id = "contact", name = "Contact form", dbparam = "contact", context = ContactObj, template = "nive_contact:contact.pt", selectTag = StagPageElement, icon = "nive.cms.cmsview:static/images/types/element.png", description = __doc__, # contact specific configuration # the form to be displayed on the web page contactForm = [ FieldConf(id="name", datatype="string", size= 50, default="", required=1, name="Name", description=""), FieldConf(id="email", datatype="email", size= 200, default="", required=1, name="E-Mail", description=""), FieldConf(id="company", datatype="string", size= 200, default="", required=0, name="Company", description=""), FieldConf(id="message", datatype="text", size= 2000, default="", required=1, name="Message", description=""), ], mailtmpl = "nive_contact:contactmail.pt" ) # these are the contact element fields configuration.data = [ FieldConf(id="topics", datatype="text", size=200, default="", name="Topics by line",description=""), FieldConf(id="receiver", datatype="email", size=100, default="", name="Receiver", description=""), FieldConf(id="receiverName", datatype="string", size=100, default="", name="Receiver name", description=""),
from nive.definitions import StagPageElement, ObjectConf, FieldConf from nive.components.objects.base import PageElementBase class link(PageElementBase): pass # text type definition ------------------------------------------------------------------ #@nive_module configuration = ObjectConf( id="link", name=_(u"Link"), dbparam="links", context="nive.cms.link.link", template="link.pt", selectTag=StagPageElement, icon="nive.cms.cmsview:static/images/types/link.png", description= _(u"With the link element you can add internal or external links into the web page." )) targets = [{ "id": u"", "name": _(u"Same window") }, { "id": u"blank_", "name": _(u"New window") }] styles = [ {
from nive_cms.i18n import _ from nive.definitions import StagPageElement, ObjectConf, FieldConf from nive_cms.baseobjects import PageElementBase class news(PageElementBase): pass # news type definition ------------------------------------------------------------------ #@nive_module configuration = ObjectConf( id = "news", name = _(u"News"), dbparam = "news", context = "nive_cms.news.news", template = "news.pt", selectTag = StagPageElement, icon = "nive_cms.cmsview:static/images/types/news.png", description = _(u"Simple news item with title, text, image, publish date and link.") ) configuration.data = [ FieldConf(id="image", datatype="file", size=0, default=u"", name=_(u"Imagefile"), description=u""), FieldConf(id="textblock", datatype="htext", size=100000, default=u"", fulltext=1, name=_(u"Text"), description=u""), FieldConf(id="publish", datatype="date", size=0, default=u"", required=0, name=_(u"Date"), description=_(u"Used as publish date on the website.")), FieldConf(id="cssClass", datatype="list", size=10, default=u"", listItems=(), name=_(u"Styling"), description=u""), FieldConf(id="link", datatype="url", size=1000, default=u"", name=_(u"Link"), description=u"") ] fields = ["title", "textblock", "image", "publish", "link", "cssClass", "pool_groups"] configuration.forms = {"create": {"fields":fields}, "edit": {"fields":fields}}
def GetColumn(self, name): if name == self.meta["title"]: return self return self.GetPage().GetColumn(name) # type definition ------------------------------------------------------------------ #@nive_module configuration = ObjectConf( id="column", name=_(u"Column"), dbparam="columnbox", context="nive_cms.column.column", template="column.pt", hidden=True, selectTag=StagPageElement, container=True, icon="nive_cms.cmsview:static/images/types/column.png", description= _(u"A column is a container to group elements on a page. Columns are not added like" u"normal page elements but have to be defined manually in the main template. A column can" u"be inherited through a hierarchy of pages.")) configuration.data = [ FieldConf( id="showsub", datatype="bool", size=2, default=1, name=_(u"Show on subpages"), description= _(u"If checked the column will be displayed on sub pages until overwritten."
text = ConvertHTMLToText(temp, removeReST=True) self.meta["title"] = CutText(text, self.titleLen, postfix=u"") return True def HTML(self): return markdown2.markdown(self.data.get("textblock")) # contact definition ------------------------------------------------------------------ #@nive_module configuration = ObjectConf( id="mtext", name="Markdown Text", dbparam="mtext", context=mtext, template="nive_markdowntext:mtext.pt", selectTag=StagPageElement, icon="nive.cms.cmsview:static/images/types/element.png", description=__doc__, ) desc = _( u"""Markdown text format.<br/>Header: # Text<br>Subheader: ## Text<br>Lists: * or Numbers<br>Emphasis: *text* or **text**<br>Links: [link text](link address) <br><br/>See <a href="http://en.wikipedia.org/wiki/Markdown" target="_blank">Wikipedia</a> for a full description.""" ) # these are the contact element fields configuration.data = [ FieldConf(id="textblock", datatype="text", size=100000, default=u"", name=_(u"Text"),
from nive.i18n import _ from nive.definitions import StagPageElement, ObjectConf, FieldConf from nive.components.objects.base import PageElementBase class link(PageElementBase): pass # text type definition ------------------------------------------------------------------ #@nive_module configuration = ObjectConf( id = "link", name = _(u"Link"), dbparam = "links", context = "nive.cms.link.link", template = "link.pt", selectTag = StagPageElement, icon = "nive.cms.cmsview:static/images/types/link.png", description = _(u"With the link element you can add internal or external links into the web page.") ) targets = [{"id": u"", "name": _(u"Same window")}, {"id": u"blank_", "name": _(u"New window")} ] styles = [ {"id": u"", "name": _(u"none")}, {"id": u"btn", "name": _(u"Simple button")}, {"id": u"btn btn-large", "name": _(u"Large button")}, {"id": u"btn btn-small", "name": _(u"Small button")}, ] colors = [ {"id": u"", "name": _(u"none")}, {"id": u"btn-primary", "name": _(u"Primary")},
configuration = ObjectConf( id="contact", name="Contact form", dbparam="contact", context=ContactObj, template="nive_contact:contact.pt", selectTag=StagPageElement, icon="nive.cms.cmsview:static/images/types/element.png", description=__doc__, # contact specific configuration # the form to be displayed on the web page contactForm=[ FieldConf(id="name", datatype="string", size=50, default="", required=1, name="Name", description=""), FieldConf(id="email", datatype="email", size=200, default="", required=1, name="E-Mail", description=""), FieldConf(id="company", datatype="string", size=200, default="", required=0, name="Company", description=""), FieldConf(id="message", datatype="text", size=2000, default="", required=1, name="Message", description=""), ], mailtmpl="nive_contact:contactmail.pt")
return groups in self.groups for g in groups: if g in self.groups: return True return False # user definition ------------------------------------------------------------------ from nive.definitions import StagUser, ObjectConf, FieldConf #@nive_module configuration = ObjectConf( id = "user", name = _(u"User"), dbparam = "users", context = "nive.userdb.user.user", template = "user.pt", selectTag = StagUser, container = False, description = __doc__ ) configuration.data = ( FieldConf(id="name", datatype="string", size= 30, default=u"", required=1, name=_(u"User ID"), description=u""), FieldConf(id="password", datatype="password", size=100, default=u"", required=1, name=_(u"Password"), description=u""), FieldConf(id="email", datatype="email", size=255, default=u"", required=1, name=_(u"Email"), description=u""), FieldConf(id="groups", datatype="mcheckboxes", size=255, default=u"", name=_(u"Groups"), settings={"codelist":"groups"}, description=u""), FieldConf(id="notify", datatype="bool", size= 4, default=True, name=_(u"Activate email notifications"), description=u""), FieldConf(id="surname", datatype="string", size=100, default=u"", name=_(u"Surname"), description=u""), FieldConf(id="lastname", datatype="string", size=100, default=u"", name=_(u"Lastname"), description=u""),
return groups in self.groups for g in groups: if g in self.groups: return True return False # user definition ------------------------------------------------------------------ from nive.definitions import StagUser, ObjectConf, FieldConf # @nive_module configuration = ObjectConf( id="user", name=_(u"User"), dbparam="users", context="nive.userdb.user.user", template="user.pt", selectTag=StagUser, container=False, description=__doc__, ) configuration.data = ( FieldConf(id="name", datatype="string", size=30, default=u"", required=1, name=_(u"User ID"), description=u""), FieldConf( id="password", datatype="password", size=100, default=u"", required=1, name=_(u"Password"), description=u"" ), FieldConf(id="email", datatype="email", size=255, default=u"", required=1, name=_(u"Email"), description=u""), FieldConf( id="groups", datatype="mcheckboxes", size=255,
from nive_cms.baseobjects import PageElementBase class code(PageElementBase): """ """ # text type definition ------------------------------------------------------------------ #@nive_module configuration = ObjectConf( id="code", name=_(u"Code"), dbparam="codes", context="nive_cms.codeblock.code", template="code.pt", selectTag=StagPageElement, icon="nive_cms.cmsview:static/images/types/code.png", description= _(u"Text element to add code snippets to web pages. Supports Javascript, HTML and CSS." )) ct = [ { 'id': u'raw', 'name': _(u'No format') }, { 'id': u'js', 'name': _(u'Javascript') },
def Init(self): self.ListenEvent("commit", "FilenameToTitle") def FilenameToTitle(self): if self.files.get("file") and not self.meta["title"]: self.meta["title"] = self.files.get("file")["filename"] # file type definition ------------------------------------------------------------------ #@nive_module configuration = ObjectConf( id = "file", name = _(u"File"), dbparam = "files", context = "nive.cms.file.file", template = "file.pt", selectTag = StagPageElement, icon = "nive.cms.cmsview:static/images/types/file.png", description = _(u"The file element provides a simple file download with title and optional description.") ) configuration.data = [ FieldConf(id="file", datatype="file", size=0, default=u"", fulltext=1, name=_(u"File"), description=u""), FieldConf(id="textblock", datatype="htext", size=10000, default=u"", name=_(u"Description"), fulltext=1, description=u"") ] fields = ["title", "file", "textblock", "pool_groups"] configuration.forms = {"create": {"fields":fields}, "edit": {"fields":fields}} configuration.views = []