1<#-- Conteúdo Web -> Templates: Site de Crise - Include de templates-->
2<#-- include "${templatesPath}/1975602" -->
3
4<#-- Conteúdo Web -> Templates: Site de Crise - Funções gerais-->
5<#include "${templatesPath}/1975398" />
6
7<#assign journalArticleService = serviceLocator.findService("com.liferay.journal.service.JournalArticleLocalService") />
8<#assign fileEntryService = staticUtil["com.liferay.document.library.kernel.service.DLFileEntryLocalServiceUtil"] />
9<#assign assetCategoryLocalService = serviceLocator.findService("com.liferay.asset.kernel.service.AssetCategoryLocalService") />
10<#assign assetVocabularyService = serviceLocator.findService("com.liferay.asset.kernel.service.AssetVocabularyService") />
11<#assign assetCategoryLocalService = serviceLocator.findService("com.liferay.asset.kernel.service.AssetCategoryLocalService") />
12<#assign assetEntryQuery = objectUtil('com.liferay.asset.kernel.service.persistence.AssetEntryQuery')>
13<#assign portalUtil = staticUtil["com.liferay.portal.kernel.util.PortalUtil"]>
14<#assign assetEntryLocalServiceUtil = objectUtil("com.liferay.asset.kernel.service.AssetEntryLocalServiceUtil").getService()>
15
16<#assign vocabularies = assetVocabularyService.getGroupVocabularies(groupId) />
17<#assign editoriaVocabulary = findVocabulary("Editorial", vocabularies) />
18<#assign mediaVocabulary = findVocabulary("Multimidia", vocabularies) />
19
20
21
22
23<#function getFirstCategoryFromVocabulary entry vocabulary>
24 <#assign categories = assetCategoryLocalService.getCategories("com.liferay.journal.model.JournalArticle", entry.getClassPK()) />
25 <#list categories as category>
26 <#assign vocabulary = assetVocabularyService.getVocabulary(category.getVocabularyId()) />
27
28 <#if vocabulary.getVocabularyId() == category.getVocabularyId()>
29 <#return category>
30 </#if>
31 </#list>
32 <#return "">
33</#function>
34
35<#function getAssetEntriesByCategory portalUtil assetEntryLocalServiceUtil newCategoryId vocabularyToExclude>
36 <#attempt >
37 <#assign groupId = themeDisplay.getScopeGroupId()>
38 <#assign companyId = themeDisplay.getCompanyId()>
39 <#assign realUserId = themeDisplay.getDefaultUserId() />
40 <#assign className = "com.liferay.journal.model.JournalArticle">
41 <#assign classNameId = portalUtil.getClassNameId(className)>
42
43 <#assign assetEntryQuery = objectUtil('com.liferay.asset.kernel.service.persistence.AssetEntryQuery') />
44 ${assetEntryQuery.setClassNameIds([classNameId]) }
45 ${assetEntryQuery.setEnd(8)}
46 <#assign notAllCategoryIds = [] />
47 <#list vocabularyToExclude.getCategories() as category>
48 <#assign notAllCategoryIds += [category.getCategoryId()] />
49 </#list>
50 ${assetEntryQuery.setNotAllCategoryIds(notAllCategoryIds)}
51 ${assetEntryQuery.setAllCategoryIds([newCategoryId])}
52
53 <#assign allAssets = assetEntryLocalServiceUtil.getEntries(assetEntryQuery)/>
54
55 <#return allAssets />
56 <#recover >
57 <#return [] />
58 </#attempt>
59</#function>
60
61<#assign rootCss = "card-news_" + randomNumber(4586) />
62<#assign cardMap = {} />
63
64<#-- Função para obter os dados de um card no Web Content (Journal Article) -->
65<#function getCardData entry journalArticleLocalService fileEntryService cardMap>
66
67 <#assign editoria = getFirstCategoryFromVocabulary(entry, editoriaVocabulary) />
68 <#assign editoriaId = -1 />
69 <#if editoria?has_content>
70 <#assign editoriaId = editoria.getCategoryId() />
71 </#if>
72 <#if editoriaId == -1>
73 <#return {} />
74 </#if>
75 <#if cardMap[ editoriaId?string]??>
76 <#if cardMap[editoriaId?string]?size gt 7 >
77 <#return {} />
78 </#if>
79 </#if>
80
81 <#assign journalArticle = journalArticleLocalService.getLatestArticle(entry.getClassPK()) />
82 <#assign ddmStructure = journalArticle.getDDMStructure() />
83 <#assign fieldList = getFieldListByStructure(ddmStructure) />
84 <#assign xmlArticle = journalArticle.getDocument().getRootElement() />
85
86 <#if getStructName(journalArticle) != "Agência de Notícias - Notícia">
87 <#return {} />
88 </#if>
89
90 <#assign imagesGroup = getNodes(getIdFromFieldName(fieldList, "Imagem de destaque da notícia"), xmlArticle) />
91 <#assign image = "" />
92 <#list imagesGroup as imageGroup >
93 <#assign image = getMediaInfo(fieldList, imageGroup, "Imagem Destaque", fileEntryService) /> />
94 </#list>
95
96 <#assign title = getFieldValue(fieldList, xmlArticle, "Título de destaque da notícia") />
97 <#if !(title?has_content && title != "")>
98 <#assign title = journalArticle.getTitle(locale) />
99 </#if>
100
101 <#assign lastPublishDate = journalArticle.getDisplayDate()>
102 <#assign createDate = journalArticle.getCreateDate()>
103
104 <#assign editoria = getFirstCategoryFromVocabulary(entry, editoriaVocabulary) />
105 <#assign editoriaId = -1 />
106 <#if editoria?has_content>
107 <#assign editoriaId = editoria.getCategoryId() />
108 </#if>
109
110 <#assign review = getFieldValue(fieldList, xmlArticle, "Subtítulo") />
111
112 <#assign urlNews = themeDisplay.getPortalURL() + themeDisplay.getPathFriendlyURLPublic() + layout.getGroup().friendlyURL + "/w/" + journalArticle.getUrlTitle()>
113
114 <#if themeDisplay.getPortalURL()?contains("webserver")>
115 <#assign urlNews = themeDisplay.getPortalURL() + themeDisplay.getPathFriendlyURLPublic() + layout.getGroup().friendlyURL + "/w/" + journalArticle.getUrlTitle()>
116 <#else>
117 <#assign urlNews = "/w/" + journalArticle.getUrlTitle()>
118 </#if>
119
120 <#assign cardInfo = {"image": image,
121 "title": title,
122 "lastPublishDate": lastPublishDate,
123 "createDate" : createDate,
124 "editoriaId": editoriaId,
125 "urlNews": urlNews,
126 "review": review} />
127
128 <#if cardMap[editoriaId?string]??>
129 <#assign cardMap = cardMap + {editoriaId : cardMap[editoriaId?string] + [cardInfo]} />
130 <#else>
131 <#assign cardMap = cardMap + {editoriaId : [cardInfo]} />
132 </#if>
133
134 <#return cardInfo />
135
136</#function>
137
138
139<#macro renderCard cardData>
140 <#if !cardData["image"]??>
141 <#return />
142 </#if>
143
144 <div class="card ${rootCss}" category-id="${cardData.editoriaId}">
145 <a class="news-card-of-interest-link" href="${cardData.urlNews}"></a>
146 <div class="news-content">
147 <div class="head">
148 <h2 class="title h4">${cardData.title}</h2>
149 <div class="bar"></div>
150 </div>
151 <div class="bottom-wrapper">
152 <div class="link-container">
153 <p class="read-more">
154 <#if locale?lower_case == "pt_br"> Continuar lendo <#else> Keep reading </#if>
155 </p>
156 </div>
157 </div>
158 </div>
159 </div>
160
161</#macro>
162
163<#assign newsJournalArticle = "">
164<#assign newsAssetEntry = getAssetEntryFromRequest(assetEntryLocalServiceUtil)>
165<#if newsAssetEntry?? && newsAssetEntry?has_content>
166 <#assign newsJournalArticle = journalArticleService.fetchLatestArticle(newsAssetEntry.classPK)/>
167</#if>
168
169<#if newsJournalArticle?? && newsJournalArticle?has_content>
170
171 <#assign newsEditoria = getFirstCategoryFromVocabulary(newsAssetEntry, editoriaVocabulary) />
172 <#assign newsEditoriaId = -1 />
173 <#if newsEditoria?has_content>
174 <#assign newsEditoriaId = newsEditoria.getCategoryId() />
175 </#if>
176
177 <#assign entries = getAssetEntriesByCategory(portalUtil, assetEntryLocalServiceUtil, newsEditoriaId, mediaVocabulary) />
178
179 <#-- Renderizar Lista de cards -->
180 <#if entries?has_content>
181 <#list entries as entry>
182 <#assign cardData = getCardData(entry journalArticleService fileEntryService cardMap) />
183 <@renderCard cardData/>
184 </#list>
185
186 <style>
187 .${rootCss} {
188 width: 306px;
189 border-radius: 16px;
190 border: 1px solid var(--color-neutral-400, #EEE);
191 background: var(--color-neutral-100, #FFF);
192 margin: 0;
193 }
194
195 .${rootCss} *:not(.news-card-of-interest-link) {
196 pointer-events: none;
197 }
198
199 .${rootCss} a.news-card-of-interest-link {
200 position: absolute;
201 width: 100%;
202 height: 100%;
203 opacity: 0;
204 top: 0;
205 }
206
207 .${rootCss}:hover {
208 box-shadow: var(--box-shadow-neutral);
209 transition: box-shadow 300ms ease-in-out;
210 }
211
212 .${rootCss} .news-content {
213 padding: var(--space-md, 24px);
214 display: flex;
215 flex-direction: column;
216 height: 100%;
217 background: var(--color-background-card);
218 border-radius: var(--border-radius-card);
219 }
220
221 .${rootCss} img {
222 background: lightgray 50% / cover no-repeat;
223 height: 170px;
224 }
225
226 .${rootCss} .head {
227 display: flex;
228 flex-direction: column;
229 gap: var(--space-xxs, 8px);
230 }
231
232 .${rootCss} .head .date {
233 color: var(--color-neutral-800, #373737);
234 font-family: var(--font-family-base, "Petrobras Sans");
235 font-size: var(--font-size-xxxs, 14px);
236 font-style: var(--font-style-normal, normal);
237 font-weight: var(--font-weight-regular, 400);
238 line-height: var(--line-height-xl, 160%); /* 19.2px */
239 }
240
241 .${rootCss} .head .title {
242 color: var(--color-neutral-800);
243 }
244
245 .${rootCss} .head .bar {
246 background-color: var(--color-secondary-solid-to-bright-200, #FDC82F);
247 height: 4px;
248 width: 20px;
249 margin: var(--space-xs, 12px) 0 var(--space-sm, 16px) 0;
250 }
251
252 .${rootCss} .bottom-wrapper {
253 height: 100%;
254 display: flex;
255 flex-direction: column;
256 justify-content: flex-end;
257 }
258
259 .${rootCss} .bottom-wrapper .review-container {
260 color: var(--color-neutral-800, #373737);
261 font-family: var(--font-family-base, "Petrobras Sans");
262 font-size: var(--font-size-xxs, 16px);
263 font-style: var(--font-style-normal, normal);
264 font-weight: var(--font-weight-regular, 400);
265 line-height: var(--line-height-xl, 160%); /* 22.4px */
266 }
267
268 .${rootCss} .bottom-wrapper .link-container {
269 flex: 0 1 auto;
270 }
271
272 .${rootCss} .bottom-wrapper .link-container .read-more {
273 color: var(--color-primary-solid-to-bright-200, var(--color-primary-medium));
274 font-family: var(--font-family-base, "Petrobras Sans");
275 font-size: var(--font-size-xxs, 16px);
276 font-style: var(--font-style-normal, normal);
277 font-weight: var(--font-weight-bold, 700);
278 line-height: var(--line-height-lg, 144%); /* 22.4px */
279 text-decoration-line: underline;
280 }
281
282
283 @media screen and (max-width: ${MAX_TABLET_WIDTH}px) {
284 .${rootCss} {
285 flex-direction: column;
286 gap: var(--space-sm, 16px);
287 padding-top: var(--space-md, 24px);
288 min-width: 296px;
289 }
290
291 .${rootCss} img {
292 height: 140px;
293 }
294
295 .${rootCss} .head .date {
296 font-size: 12px;
297 }
298
299 .${rootCss} .head .title {}
300
301 .${rootCss} .head .bar {
302 width: 18px;
303 margin: var(--space-xxs, 8px) 0 var(--space-sm, 16px) 0;
304 }
305
306 .${rootCss} .review-container {
307 font-size: var(--font-size-xxxs, 14px);
308 }
309 }
310 </style>
311 <script>
312 (function() {
313 const cards = document.querySelectorAll('.${rootCss}.card');
314
315 cards.forEach((card) => {
316 const cardLink = card.querySelector('a.news-card-of-interest-link');
317 const cardTitle = card.querySelector('.title');
318 cardLink.textContent = cardTitle.textContent;
319 });
320 })();
321 </script>
322 </#if>
323</#if>