h2. Easy to Use Simple applications are easy to get up and running. pre(gist#240887). See Gist #240887 (http://gist.github.com/240887) on GitHub.""" ; default.save() about = Folder(name="about", title="About", owner=admin, default="default") ; about.save() ; about.attach(root) _ = Page(name="default", title="About the Site", owner=admin, content=u"""h1(primary). About the WebCore Website The WebCore website is powered by the "Contentment":http://github.com/GothAlice/Contentment content management system, the "WebCore":http://www.web-core.org/ web application development framework, and "Python":http://www.python.org/, a high-level general purpose scripting language. Portions of the code are copyright their respective authors and distributed under various licenses. For more information, please see the specific project websites and respective dependant packages. p(tc). Developed by "Alice Bevan-McGregor":http://www.gothcandy.com/ p(tc). Contentment Copyright © 2010 Alice Bevan-McGregor WebCore Copyright © 2009-2010 Alice Bevan-McGregor, Alex Grönholm, and Contributors Python Copyright © 1990-2010 Python Software Foundation""") ; _.save() ; _.attach(about) _ = Page(name="privacy", title="Privacy Policy", owner=admin, description=u"This privacy policy sets out how WebCore uses and protects any information that you voluntarily or involuntarily provide when you use this website.", content=u"""h1(primary). WebCore Privacy Policy WebCore is committed to ensuring that your privacy is protected. Should we ask you to provide certain information by which you can be identified when using this website, then you can be assured that it will only be used in accordance with this privacy statement. WebCore may change this policy from time to time by updating this page. You should check this page from time to time to ensure that you are happy with any changes. The date this policy was last modified is available in the footer. (You can hover your mouse over the relative date to view the absolute one.) bq. This privacy policy sets out how WebCore uses and protects any information that you voluntarily or involuntarily provide when you use this website. h1. What We Collect
password = PasswordCredential(identity="admin") password.password = "******" admin.credentials.append(password) admin.save() admin.attach(users) user = Identity(name="jrh", title="Example User", email="*****@*****.**") password = PasswordCredential(identity="jrh") password.password = "******" user.credentials.append(password) user.save() user.attach(users) header = Page(name="header", title="Global Site Header", content="""h1. "Contentment":/""") header.save() header.attach(templates) menu = Page( name="menu", title="Main Menu", engine="raw", content=""" <menu class="container"> <li class="nav-home"><a href="/">Home<br><label> </label></a></li ><li class="nav-start"><a href="/start">Get Started<br><label>Getting Started with Contentment</label></a></li> </menu>""", ) menu.save()
def post(self): print("Bootstrapping default site content...") from web.extras.contentment.components.asset.model import db, Asset, AdvancedACLRule, OwnerACLRule, UserACLRule, AllUsersACLRule, InheritACLRules from web.extras.contentment.components.page.model import Page from web.extras.contentment.components.folder.model import Folder from web.extras.contentment.components.identity.model import PasswordCredential, Identity from web.extras.contentment.components.authenticator.model import Authenticator from web.extras.contentment.components.search.model import Search from web.extras.contentment.components.settings.model import Settings from web.extras.contentment.themes.default.model import DefaultTheme settings = self.options scheme, parts = settings.db.split('://', 1) parts, db = parts.split('/', 1) auth, host = parts.split('@', 1) if '@' in parts else (None, parts) connection = dict() connection[b'host'], connection[b'port'] = host.split(':') if ':' in host else (host, '27017') connection[b'port'] = int(connection[b'port']) if auth: connection[b'username'], _, connection[b'password'] = auth.partition(':') mongoengine.connect(db, **connection) if Asset.objects().count() > 0: print("Existing content found, bootstrap cancelled.") # TODO: Interactively ask to overwrite data. return root = Asset(name="", path="/", title=settings['title'], default="default", immutable=True, properties={ 'org-contentment-formats-date': '%B %e, %G at %H:%M:%S', 'org-contentment-theme': 'web.extras.contentment.themes.default', 'org-contentment-option-attribution': True, 'org-contentment-option-showdates': True, 'org-contentment-lang': 'en', 'org-contentment-cache': True }) admin = Identity(name=settings['admin.name'], title=settings['admin.title'], email=settings['admin.email']) ; admin.save() root.acl.append(AdvancedACLRule(allow=False, permission="action:delete", attributes={'immutable': True})) root.acl.append(OwnerACLRule(allow=True, permission="*")) root.acl.append(UserACLRule(allow=True, permission="*", reference=admin)) root.acl.append(AllUsersACLRule(allow=False, permission="view:acl")) root.acl.append(InheritACLRules()) root.acl.append(AllUsersACLRule(allow=True, permission="view:*")) root.acl.append(AllUsersACLRule(allow=False, permission="*")) root.save() settings_ = Settings(name="settings", title="Site Settings", immutable=True, default="view:contents") settings_.acl.append(UserACLRule(allow=False, permission="*", inverse=True, reference=admin)) settings_.save() ; settings_.attach(root) extensions = Folder(name="extensions", title="Site Extensions", immutable=True) ; extensions.save() ; extensions.attach(settings_) templates = Folder(name="templates", title="Site Templates", immutable=True) ; templates.save() ; templates.attach(settings_) custom = Folder(name="custom", title="Custom Page Templates", immutable=True) ; custom.save() ; custom.attach(templates) theme = DefaultTheme(name="theme", title="Default Theme", immutable=True); theme.save() ; theme.attach(root) users = Authenticator(name="users", title="Users", immutable=True) users.acl.append(AllUsersACLRule(allow=True, permission="action:authenticate")) users.acl.append(AllUsersACLRule(allow=True, permission="action:expire")) users.save() ; users.attach(root) password = PasswordCredential(identity=settings['admin.name']) password.password = settings['admin.password'] admin.credentials.append(password) ; admin.save() ; admin.attach(users) header = Page(name="header", title="Global Site Header", content="""h1. "%s":/""" % (settings['title'], )) ; header.save() ; header.attach(templates) menu = Page(name="menu", title="Main Menu", engine="raw", content=""" <menu class="container"> <li class="nav-default"><a href="/">Home<br><label> </label></a></li ><li class="nav-start"><a href="/start">Get Started<br><label>Getting Started with Contentment</label></a></li> </menu>""") ; menu.save() ; menu.attach(templates) footer = Page(name="footer", title="Global Site Footer", engine="raw", content="""<p class="fr">© %s %s</p> <menu> <li><a href="/about">About the Site</a></li ><li><a href="/about/privacy">Privacy Policy</a></li ><li><a href="/about/colophon">Colophon</a></li> </menu>""" % (datetime.datetime.now().year, settings['admin.title'])) ; footer.save() ; footer.attach(templates) search = Search(name="search", title="Site Search") ; search.save() ; search.attach(root) default = Page(name="default", title="Welcome", owner=admin, content="""h1. Welcome to Contentment Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.""" ) ; default.save() ; default.attach(root) print("Finished bootstrapping the default site.")