-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Stefan Arnold
committed
Aug 8, 2019
1 parent
f3b954d
commit 8b3b631
Showing
15 changed files
with
611 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
# -*- coding: utf-8 -*- | ||
from collective.frontpage.browser.mixins import SectionsViewMixin | ||
from collective.frontpage.utils import crop | ||
from plone import api | ||
from Products.Five import BrowserView | ||
from Products.Five.browser.pagetemplatefile import ViewPageTemplateFile | ||
|
||
|
||
class NewsBase(SectionsViewMixin, BrowserView): | ||
"""TeaserBase base class""" | ||
|
||
def get_news(self): | ||
results = [] | ||
items = api.content.find( | ||
portal_type='News Item', | ||
sort_on='Date', | ||
sort_order='descending', | ||
Language=api.portal.get_current_language(), | ||
) | ||
if items: | ||
items = [item.getObject() for item in items] | ||
for item in items: | ||
title = item.title | ||
description = crop(item.description, 200) | ||
url = item.absolute_url() | ||
scaled_image = None | ||
if item.image: | ||
images_view = api.content.get_view( | ||
'images', item, self.request) | ||
scaled_image = images_view.scale( | ||
'image', width=640, height=420, direction='down') | ||
data = { | ||
'title': title, | ||
'description': description, | ||
'url': url, | ||
'scaled_image': scaled_image, | ||
} | ||
results.append(data) | ||
return results[:3] | ||
|
||
|
||
class NewsDefaultView(NewsBase): | ||
"""TeaserDefaultView base class""" | ||
|
||
template = ViewPageTemplateFile("templates/sections/news_default.pt") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
.cards { | ||
color: inherit; | ||
display: flex; | ||
flex-wrap: wrap; | ||
justify-content: center; | ||
margin: 0 auto; | ||
float: none !important; | ||
|
||
.card { | ||
color: inherit; | ||
border: 1px solid #d0d0d0; | ||
box-shadow: 0 2px 4px rgba(3, 27, 78, 0.06); | ||
cursor: pointer; | ||
margin: 15px; | ||
padding: 0; | ||
text-align: center; | ||
|
||
&.blank { | ||
border: none !important; | ||
box-shadow: none !important; | ||
} | ||
|
||
&.fill { | ||
background-color: white; | ||
} | ||
|
||
&.inactive:hover { | ||
box-shadow: 0 2px 4px rgba(3, 27, 78, 0.06); | ||
cursor: default; | ||
} | ||
|
||
&:hover { | ||
box-shadow: 0 10px 20px rgba(3, 27, 78, 0.1); | ||
} | ||
|
||
a { | ||
color: inherit; | ||
} | ||
|
||
.vendor(transition, all 150ms ease-in-out); | ||
|
||
.card-graphic { | ||
font-size: 3em; | ||
margin-bottom: 30px; | ||
display: inline-block; | ||
width: 100%; | ||
height: auto; | ||
} | ||
|
||
.card-heading { | ||
font-weight: 500; | ||
line-height: 1.5; | ||
margin: 0 20px 20px 20px; | ||
position: relative; | ||
} | ||
|
||
.card-description { | ||
font-weight: 400; | ||
margin: 20px; | ||
} | ||
} | ||
} |
2 changes: 1 addition & 1 deletion
2
src/collective/frontpage/browser/static/frontpage-compiled-2019-06-27.css
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
47 changes: 47 additions & 0 deletions
47
src/collective/frontpage/browser/templates/sections/news_default.pt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
<html xmlns:metal="http://xml.zope.org/namespaces/metal" | ||
metal:use-macro="here/main_template/macros/master" | ||
xmlns:i18n="http://xml.zope.org/namespaces/i18n" | ||
xmlns:tal="http://xml.zope.org/namespaces/tal" | ||
xmlns="http://www.w3.org/1999/xhtml" | ||
i18n:domain="collective.frontpage" | ||
lang="en" | ||
tal:omit-tag=""> | ||
|
||
<head> | ||
<metal:block fill-slot="style_slot"> | ||
<link rel="stylesheet" type="text/css" | ||
href="++resource++collective.frontpage/frontpage-compiled-2019-06-27.css"> | ||
</metal:block> | ||
</head> | ||
|
||
<body> | ||
<metal:main fill-slot="main"> | ||
|
||
<div class="frontpage-section" metal:define-macro="static_default"> | ||
<div class="section-content container" tal:attributes="style view/get_style"> | ||
|
||
<div class="section-text col-md-6 col-md-offset-3"> | ||
<h2 class="section-title">${context/title}</h2> | ||
<p class="section-description" tal:condition="context/description">${context/description}</p> | ||
</div> | ||
|
||
<div class="cards col-md-12" tal:define="news_items view/get_news"> | ||
<tal:repeat tal:repeat="news_item news_items"> | ||
<div class="card fill col-md-3" style="background-color: ${context/primary_color}; color: ${python: view.button_text_color(context)}"> | ||
<a href="${news_item/url}"> | ||
<img tal:replace="structure python:news_item.get('scaled_image').tag(css_class='card-graphic')" tal:condition="news_item/scaled_image" /> | ||
<h4 class="card-heading">${news_item/title}</h4> | ||
<p class="card-description">${news_item/description}</p> | ||
</a> | ||
</div> | ||
|
||
</tal:repeat> | ||
</div> | ||
|
||
</div> | ||
</div> | ||
|
||
</metal:main> | ||
</body> | ||
|
||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
# -*- coding: utf-8 -*- | ||
from plone.dexterity.content import Container | ||
from plone.supermodel import model | ||
|
||
|
||
class INews(model.Schema): | ||
""" | ||
Marker interface and Dexterity Python Schema for Static. | ||
""" | ||
|
||
pass | ||
|
||
|
||
class News(Container): | ||
|
||
pass |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.