Skip to content

Commit

Permalink
Merge c6200ed into 5782b74
Browse files Browse the repository at this point in the history
  • Loading branch information
sarn0ld committed May 29, 2019
2 parents 5782b74 + c6200ed commit 980f692
Show file tree
Hide file tree
Showing 5 changed files with 60 additions and 40 deletions.
5 changes: 4 additions & 1 deletion src/collective/frontpage/browser/static/frontpage.css
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@
background-size: cover;
}

.full-height {
min-height: 100vh;
}

.section-content {
background-origin: padding-box, padding-box;
padding-bottom: 88px;
Expand All @@ -20,7 +24,6 @@
margin-bottom: 8px;
margin-top: 0;
text-align: center;
text-align: center;
text-transform: uppercase;
}

Expand Down
3 changes: 2 additions & 1 deletion src/collective/frontpage/browser/templates/frontpage.pt
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@
<body>
<metal:block fill-slot="main">
<tal:repeat tal:repeat="section context/listFolderContents">
<div metal:use-macro="context/@@frontpage_macros/frontpage_section_static"/>
<div metal:use-macro="context/@@frontpage_macros/frontpage_section_teaser" tal:condition="python: section.section_type==u'teaser'"/>
<div metal:use-macro="context/@@frontpage_macros/frontpage_section_static" tal:condition="python: section.section_type==u'static'"/>
</tal:repeat>
</metal:block>
</body>
Expand Down
27 changes: 25 additions & 2 deletions src/collective/frontpage/browser/templates/frontpage_macros.pt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<div class="frontpage-section"
<div class="frontpage-section" metal:define-macro="frontpage_section_static"
tal:define="image python:section.get('background_image', None)"
tal:attributes="style python:'background-image: url(' + section.absolute_url() +'@@images/background_image)' if image else ''"
metal:define-macro="frontpage_section_static">
>

<div class="section-content" style="background-color: ${section/background_color}">
<h2 class="section-title" style="color: ${python: view.text_color(section)};">${section/title}</h2>
Expand All @@ -18,3 +18,26 @@
</div>

</div>



<div class="frontpage-section full-height" metal:define-macro="frontpage_section_teaser"
tal:define="image python:section.get('background_image', None)"
tal:attributes="style python:'background-image: url(' + section.absolute_url() +'@@images/background_image)' if image else ''"
>

<div class="section-content full-height" style="background-color: ${section/background_color}">
<h2 class="section-title" style="color: ${python: view.text_color(section)};">${section/title}</h2>
<p tal:condition="section/description"
class="section-description"
style="color: ${python: view.text_color(section)}; opacity: 0.6;">${section/description}
</p>
<a tal:condition="section/link_title"
href="${section/link_url}"
class="section-link"
style="background-color: ${section/primary_color}; color: ${python: view.button_text_color(section)}">
${section/link_title}
</a>
</div>

</div>
6 changes: 4 additions & 2 deletions src/collective/frontpage/browser/templates/section.pt
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,10 @@

<body>
<metal:main fill-slot="main">
<div tal:define="section python:view.context"
metal:use-macro="context/@@frontpage_macros/frontpage_section_static" />
<tal:block tal:define="section python:view.context">
<div metal:use-macro="context/@@frontpage_macros/frontpage_section_teaser" tal:condition="python: section.section_type==u'teaser'"/>
<div metal:use-macro="context/@@frontpage_macros/frontpage_section_static" tal:condition="python: section.section_type==u'static'"/>
</tal:block>
</metal:main>
</body>

Expand Down
59 changes: 25 additions & 34 deletions src/collective/frontpage/setuphandlers.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
# -*- coding: utf-8 -*-
from collective.frontpage import config
from plone import api
from Products.CMFPlone.interfaces import INonInstallable
from random import choice
from zope.component import getUtility
from zope.interface import implementer
from zope.schema.interfaces import IVocabularyFactory


@implementer(INonInstallable)
Expand All @@ -28,9 +24,10 @@ def uninstall(context):
def demo(context):
"""Demo handler for the collective.frontpage:demo profile"""
portal = api.portal.get()
_create_frontpage(portal)
frontpage = _create_frontpage(portal)
_create_static_section(frontpage)
_create_teaser_section(frontpage)
_remove_default_pages(portal)
_create_sections(portal)
_create_dummy_user()


Expand All @@ -39,10 +36,15 @@ def _create_frontpage(portal):
type="Frontpage", container=portal, id="frontpage", title=u"Frontpage"
)
api.content.transition(obj=frontpage, transition="publish")
portal.setDefaultPage("frontpage")
return frontpage


def _create_static_section(frontpage):
section = api.content.create(
type="Section",
container=frontpage,
id="section",
id="section-static",
title=u"Example Section",
description="This is an example Section in your new Frontpage",
section_type=u"static",
Expand All @@ -52,7 +54,22 @@ def _create_frontpage(portal):
link_title="Click me!",
)
api.content.transition(obj=section, transition="publish")
portal.setDefaultPage("frontpage")


def _create_teaser_section(frontpage):
section = api.content.create(
type="Section",
container=frontpage,
id="section-teaser",
title=u"Teaser",
description="This is an example Teaser Section. It is fullscreen.",
section_type=u"teaser",
background_color="#0083BE",
primary_color="#F5F5F5",
link_url="",
link_title="",
)
api.content.transition(obj=section, transition="publish")


def _remove_default_pages(portal):
Expand All @@ -77,29 +94,3 @@ def _create_dummy_user():
password="testing@collective.frontpage",
properties={"fullname": u"Max Mustermann"},
)


def _create_sections(portal):
frontpage = portal.get("frontpage", None)
section_colors = getUtility(
IVocabularyFactory, "collective.frontpage.SectionColors"
)
voc_colors = section_colors(portal)
section_types = getUtility(IVocabularyFactory, "collective.frontpage.SectionTypes")
voc_types = section_types(portal)
if frontpage:
for i in range(1, 5):
num = "{0:0=2d}".format(i)
section = api.content.create(
type="Section",
container=frontpage,
id="section-{0}".format(num),
title=u"Section {0}".format(num),
description=choice(config.DUMMY_DESCRIPTIONS),
section_type=choice(voc_types._terms).token,
background_color=choice(voc_colors._terms).token,
primary_color=choice(voc_colors._terms).token,
link_url="https://www.operun.de",
link_title="Click me!",
)
api.content.transition(obj=section, transition="publish")

0 comments on commit 980f692

Please sign in to comment.