Skip to content

Commit

Permalink
LPS-94408 Uses vertical card on configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
ealonso committed Apr 22, 2019
1 parent f0f3161 commit 0649f1d
Show file tree
Hide file tree
Showing 3 changed files with 85 additions and 21 deletions.
@@ -0,0 +1,81 @@
/**
* Copyright (c) 2000-present Liferay, Inc. All rights reserved.
*
* This library is free software; you can redistribute it and/or modify it under
* the terms of the GNU Lesser General Public License as published by the Free
* Software Foundation; either version 2.1 of the License, or (at your option)
* any later version.
*
* This library is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*/

package com.liferay.journal.content.web.internal.servlet.taglib.clay;

import com.liferay.dynamic.data.mapping.model.DDMTemplate;
import com.liferay.frontend.taglib.clay.servlet.taglib.soy.VerticalCard;
import com.liferay.portal.kernel.language.LanguageUtil;
import com.liferay.portal.kernel.theme.ThemeDisplay;
import com.liferay.portal.kernel.util.HtmlUtil;
import com.liferay.portal.kernel.util.WebKeys;

import java.util.Date;

import javax.servlet.http.HttpServletRequest;

/**
* @author Eudaldo Alonso
*/
public class JournalDDMTemplateVerticalCard implements VerticalCard {

public JournalDDMTemplateVerticalCard(
DDMTemplate ddmTemplate, HttpServletRequest request) {

_ddmTemplate = ddmTemplate;
_request = request;
}

@Override
public String getIcon() {
return "page-template";
}

@Override
public String getImageSrc() {
ThemeDisplay themeDisplay = (ThemeDisplay)_request.getAttribute(
WebKeys.THEME_DISPLAY);

return HtmlUtil.escapeAttribute(
_ddmTemplate.getTemplateImageURL(themeDisplay));
}

@Override
public String getSubtitle() {
Date createDate = _ddmTemplate.getModifiedDate();

String modifiedDateDescription = LanguageUtil.getTimeDescription(
_request, System.currentTimeMillis() - createDate.getTime(), true);

return LanguageUtil.format(
_request, "modified-x-ago", modifiedDateDescription);
}

@Override
public String getTitle() {
ThemeDisplay themeDisplay = (ThemeDisplay)_request.getAttribute(
WebKeys.THEME_DISPLAY);

return HtmlUtil.escape(_ddmTemplate.getName(themeDisplay.getLocale()));
}

@Override
public boolean isSelectable() {
return false;
}

private final DDMTemplate _ddmTemplate;
private final HttpServletRequest _request;

}
Expand Up @@ -37,6 +37,7 @@ page import="com.liferay.journal.constants.JournalContentPortletKeys" %><%@
page import="com.liferay.journal.content.web.internal.constants.JournalContentWebKeys" %><%@
page import="com.liferay.journal.content.web.internal.display.context.JournalContentDisplayContext" %><%@
page import="com.liferay.journal.content.web.internal.servlet.taglib.clay.JournalArticleVerticalCard" %><%@
page import="com.liferay.journal.content.web.internal.servlet.taglib.clay.JournalDDMTemplateVerticalCard" %><%@
page import="com.liferay.journal.exception.NoSuchArticleException" %><%@
page import="com.liferay.journal.model.JournalArticle" %><%@
page import="com.liferay.journal.model.JournalArticleDisplay" %><%@
Expand Down
Expand Up @@ -16,28 +16,10 @@

<%@ include file="/init.jsp" %>

<%
DDMTemplate ddmTemplate = journalContentDisplayContext.getDDMTemplate();
String ddmTemplateImageURL = ddmTemplate.getTemplateImageURL(themeDisplay);
%>

<div class="row">
<div class="col-md-4">
<liferay-frontend:horizontal-card
text="<%= ddmTemplate.getName(locale) %>"
>
<liferay-frontend:horizontal-card-col>
<c:choose>
<c:when test="<%= Validator.isNotNull(ddmTemplateImageURL) %>">
<img alt="" class="<%= Validator.isNotNull(ddmTemplateImageURL) ? "icon-monospaced" : StringPool.BLANK %>" src="<%= ddmTemplateImageURL %>" />
</c:when>
<c:otherwise>
<liferay-frontend:horizontal-card-icon
icon="edit-layout"
/>
</c:otherwise>
</c:choose>
</liferay-frontend:horizontal-card-col>
</liferay-frontend:horizontal-card>
<clay:vertical-card
verticalCard="<%= new JournalDDMTemplateVerticalCard(journalContentDisplayContext.getDDMTemplate(), request) %>"
/>
</div>
</div>

0 comments on commit 0649f1d

Please sign in to comment.