Feature #24736
This commit is contained in:
parent
2fed7bccf5
commit
4eda3604bc
|
@ -3,7 +3,9 @@ org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
|
|||
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
|
||||
org.eclipse.jdt.core.compiler.compliance=1.8
|
||||
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
|
||||
org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled
|
||||
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
|
||||
org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
|
||||
org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=ignore
|
||||
org.eclipse.jdt.core.compiler.release=disabled
|
||||
org.eclipse.jdt.core.compiler.source=1.8
|
||||
|
|
|
@ -1,10 +1,19 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?><project-modules id="moduleCoreId" project-version="1.5.0">
|
||||
|
||||
<wb-module deploy-name="catalogue-badge-portlet">
|
||||
|
||||
<wb-resource deploy-path="/" source-path="/target/m2e-wtp/web-resources"/>
|
||||
|
||||
<wb-resource deploy-path="/" source-path="/src/main/webapp" tag="defaultRootSource"/>
|
||||
|
||||
<wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/java"/>
|
||||
|
||||
<wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/resources"/>
|
||||
|
||||
<property name="java-output-path" value="/Catalogue-badge-portlet/target/classes"/>
|
||||
|
||||
<property name="context-root" value="catalogue-badge-portlet"/>
|
||||
|
||||
</wb-module>
|
||||
|
||||
</project-modules>
|
||||
|
|
|
@ -4,6 +4,10 @@
|
|||
All notable changes to this project will be documented in this file.
|
||||
This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
||||
|
||||
## [v1.1.2-SNAPSHOT] - 2023-02-13
|
||||
|
||||
- bug fix
|
||||
|
||||
## [v1.1.1] - 2021-10-13
|
||||
|
||||
- Feature #22177, Modify Catalogue widget portlet to display the types and the number when in root VO
|
||||
|
|
13
pom.xml
13
pom.xml
|
@ -12,7 +12,7 @@
|
|||
<artifactId>catalogue-badge-portlet</artifactId>
|
||||
<packaging>war</packaging>
|
||||
<name>Catalogue-badge-portlet Portlet</name>
|
||||
<version>1.1.1</version>
|
||||
<version>1.1.2-SNAPSHOT</version>
|
||||
<description>
|
||||
Catalogue badge portlet displays a synoptic view of the catalogue content
|
||||
</description>
|
||||
|
@ -38,7 +38,7 @@
|
|||
<dependency>
|
||||
<groupId>org.gcube.distribution</groupId>
|
||||
<artifactId>maven-portal-bom</artifactId>
|
||||
<version>3.6.3</version>
|
||||
<version>3.6.4-SNAPSHOT</version>
|
||||
<type>pom</type>
|
||||
<scope>import</scope>
|
||||
</dependency>
|
||||
|
@ -51,14 +51,13 @@
|
|||
<version>[2.4.1-SNAPSHOT, 3.0.0-SNAPSHOT)</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.gcube.dvos</groupId>
|
||||
<artifactId>usermanagement-core</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.gcube.common.portal</groupId>
|
||||
<artifactId>portal-manager</artifactId>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.gcube.dvos</groupId>
|
||||
<artifactId>usermanagement-core</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.jsoup</groupId>
|
||||
|
|
|
@ -22,7 +22,7 @@ public class CatalogueBadgeConfigurationAction extends DefaultConfigurationActio
|
|||
|
||||
PortletPreferences prefs = actionRequest.getPreferences();
|
||||
String catalogueURL = prefs.getValue("catalogueURL", "true");
|
||||
|
||||
|
||||
|
||||
_log.debug("catalogueURL = " + catalogueURL + " in CatalogueBadgeConfigurationAction.processAction().");
|
||||
}
|
||||
|
|
|
@ -1,16 +1,3 @@
|
|||
/**
|
||||
* 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 org.gcube.portlets.user.cataloguebadge;
|
||||
|
||||
|
@ -56,7 +43,7 @@ import com.liferay.portal.util.PortalUtil;
|
|||
@RequestMapping("VIEW")
|
||||
public class PortletViewController {
|
||||
private static Log _log = LogFactoryUtil.getLog(PortletViewController.class);
|
||||
private static final String IMAGES_BASE_URL = "https://catalogue.d4science.org/";
|
||||
// private static final String IMAGES_BASE_URL = "https://catalogue.d4science.org/";
|
||||
private static final long K = 1000;
|
||||
private static final long M = K * K;
|
||||
private static final long G = M * K;
|
||||
|
@ -68,7 +55,18 @@ public class PortletViewController {
|
|||
model.addAttribute("releaseInfo", ReleaseInfo.getReleaseInfo());
|
||||
PortletPreferences prefs = request.getPreferences();
|
||||
String catalogueBaseURL = GetterUtil.getString(prefs.getValue("catalogueURL", StringPool.BLANK));
|
||||
String catalogueTypes2Show = GetterUtil.getString(prefs.getValue("catalogueTypes2ShowNo", StringPool.BLANK));
|
||||
int typesNo = 5;
|
||||
if (catalogueTypes2Show != null && !catalogueTypes2Show.equals(StringPool.BLANK)) {
|
||||
try{
|
||||
typesNo = Integer.parseInt(catalogueTypes2Show);
|
||||
} catch (Exception e) {
|
||||
System.out.println(e.getMessage());
|
||||
typesNo = 5;
|
||||
}
|
||||
}
|
||||
model.addAttribute("catalogueActualURL", catalogueBaseURL);
|
||||
|
||||
HttpServletRequest httpServletRequest = PortalUtil.getHttpServletRequest(request);
|
||||
long groupId = -1;
|
||||
boolean isRootVO = false;
|
||||
|
@ -83,10 +81,13 @@ public class PortletViewController {
|
|||
model.addAttribute("isRootVO", isRootVO);
|
||||
if (catalogueBaseURL != null && catalogueBaseURL.compareTo("") != 0) { //if the config textbox with catalogueURL is filled in we show the types
|
||||
try {
|
||||
List<CatalogueType> theTypes = parseTypes(catalogueBaseURL+"/type", catalogueURL);
|
||||
List<CatalogueType> theTypes = parseTypes(catalogueBaseURL+"/type", catalogueURL, catalogueBaseURL);
|
||||
Collections.sort(theTypes, Collections.reverseOrder());
|
||||
List<CatalogueType> theFiveTypes = new ArrayList<>();
|
||||
for (int i = 0; i < 6; i++) {
|
||||
int limit = typesNo-1;
|
||||
if (theTypes.size() <= limit)
|
||||
limit = theTypes.size()-1;
|
||||
for (int i = 0; i <= limit; i++) {
|
||||
theFiveTypes.add(theTypes.get(i));
|
||||
}
|
||||
model.addAttribute("catalogueTypes", theFiveTypes);
|
||||
|
@ -135,7 +136,7 @@ public class PortletViewController {
|
|||
return "Catalogue-badge-portlet/view";
|
||||
}
|
||||
|
||||
private List<CatalogueType> parseTypes(String url, String catalogueURL) throws Exception {
|
||||
private List<CatalogueType> parseTypes(String url, String catalogueURL, String catalogueBaseURL) throws Exception {
|
||||
List<CatalogueType> toReturn = new ArrayList<>();
|
||||
Document doc = Jsoup.connect(url)
|
||||
.userAgent("Mozilla")
|
||||
|
@ -165,7 +166,7 @@ public class PortletViewController {
|
|||
} catch (Exception e) {
|
||||
_log.error("Could not find occurrence in string "+ nameAndOccurrence);
|
||||
}
|
||||
toReturn.add(new CatalogueType(name, IMAGES_BASE_URL+imgUrl, hrefPortlet, occurrence));
|
||||
toReturn.add(new CatalogueType(name, catalogueBaseURL+imgUrl, hrefPortlet, occurrence));
|
||||
}
|
||||
return toReturn;
|
||||
}
|
||||
|
|
|
@ -18,6 +18,8 @@
|
|||
|
||||
<%
|
||||
String appURL_cfg = GetterUtil.getString(portletPreferences.getValue("catalogueURL", StringPool.BLANK));
|
||||
|
||||
String types2Show_cfg = GetterUtil.getString(portletPreferences.getValue("catalogueTypes2ShowNo", StringPool.BLANK));
|
||||
%>
|
||||
|
||||
<aui:form action="<%=configurationURL%>" method="post" name="fm">
|
||||
|
@ -32,6 +34,14 @@ String appURL_cfg = GetterUtil.getString(portletPreferences.getValue("catalogueU
|
|||
placeholder="Enter Catalogue URL (e.g. https://ckan-sobigdata.d4science.org)"
|
||||
helpMessage="Actual endpoint of the ckan instance (e.g. https://ckan-sobigdata.d4science.org)"
|
||||
value="<%=appURL_cfg%>" required="false" />
|
||||
|
||||
|
||||
<aui:input style="width: 30%;" name="preferences--catalogueTypes2ShowNo--"
|
||||
type="text" cssClass="text long-field" showRequiredLabel="false"
|
||||
label="Number of types to show" inlineField="true" inlineLabel="left"
|
||||
placeholder="Enter the number of items to show"
|
||||
helpMessage="Enter the number of items to show (default is 5)"
|
||||
value="<%=types2Show_cfg%>" required="false" />
|
||||
</aui:field-wrapper>
|
||||
|
||||
<aui:button-row>
|
||||
|
|
|
@ -1,24 +1,24 @@
|
|||
<%@ page contentType="text/html" pageEncoding="UTF-8"%>
|
||||
|
||||
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
|
||||
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
|
||||
|
||||
<%@ taglib uri="http://liferay.com/tld/aui" prefix="aui" %>
|
||||
<%@ taglib uri="http://liferay.com/tld/portlet" prefix="liferay-portlet" %>
|
||||
<%@ taglib uri="http://liferay.com/tld/theme" prefix="liferay-theme" %>
|
||||
<%@ page import="com.liferay.portal.kernel.util.Constants" %>
|
||||
<%@ page import="com.liferay.portal.kernel.util.GetterUtil" %>
|
||||
<%@ page import="com.liferay.portal.kernel.util.StringPool" %>
|
||||
<%@ page import="com.liferay.portal.util.PortalUtil" %>
|
||||
<%@ taglib uri="http://liferay.com/tld/aui" prefix="aui"%>
|
||||
<%@ taglib uri="http://liferay.com/tld/portlet" prefix="liferay-portlet"%>
|
||||
<%@ taglib uri="http://liferay.com/tld/theme" prefix="liferay-theme"%>
|
||||
<%@ page import="com.liferay.portal.kernel.util.Constants"%>
|
||||
<%@ page import="com.liferay.portal.kernel.util.GetterUtil"%>
|
||||
<%@ page import="com.liferay.portal.kernel.util.StringPool"%>
|
||||
<%@ page import="com.liferay.portal.util.PortalUtil"%>
|
||||
|
||||
|
||||
<!-- show the types only when the ckan instance is specified in the config portlet part -->
|
||||
<!-- show the types only when the ckan instance is specified in the config portlet part -->
|
||||
<c:choose>
|
||||
<c:when test="${not empty catalogueActualURL}">
|
||||
<input type="hidden" value="${catalogueURL}" id="catalogueURL">
|
||||
<table class="catalogue-container">
|
||||
<tr class="catalogue-table-row">
|
||||
<td class="catalogue-table-cell">
|
||||
<div class="input-append input-catalogue">
|
||||
<div class="container-fluid">
|
||||
<div class="row-fluid">
|
||||
<div class="span6">
|
||||
<div class="input-append input-catalogue .hidden-phone">
|
||||
<input type="text" class="input-large" name="q" value=""
|
||||
autocomplete="off" placeholder="Insert keywords here"
|
||||
id="inputQueryCatalogue">
|
||||
|
@ -32,26 +32,23 @@
|
|||
href="${catalogueURL}?path=/types" style="float: right;">See
|
||||
All Types</a>
|
||||
</div>
|
||||
</td>
|
||||
<td class="catalogue-table-cell-max">
|
||||
<table>
|
||||
<tr>
|
||||
<c:forEach var="type" items="${catalogueTypes}">
|
||||
<td class="media-item-homepage"><a href="${type.link}"
|
||||
title="View ${type.name}"> <img class="logo-homepage"
|
||||
src="${type.img}" alt="${type.name}"
|
||||
title="${type.name} group">
|
||||
</a>
|
||||
<p class="media-heading-homepage">
|
||||
<a href="${type.link}" title="View ${type.name}">
|
||||
${type.name} (${type.occurrence}) </a>
|
||||
</p></td>
|
||||
</c:forEach>
|
||||
</tr>
|
||||
</table>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
<div class="span6">
|
||||
<c:forEach var="type" items="${catalogueTypes}">
|
||||
<div class="media-item-homepage">
|
||||
<a href="${type.link}" title="View ${type.name}"> <img
|
||||
class="logo-homepage" src="${type.img}" alt="${type.name}"
|
||||
title="${type.name} group">
|
||||
</a>
|
||||
<p class="media-heading-homepage">
|
||||
<a href="${type.link}" title="View ${type.name}">
|
||||
${type.name} (${type.occurrence}) </a>
|
||||
</p>
|
||||
</div>
|
||||
</c:forEach>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</c:when>
|
||||
<c:otherwise>
|
||||
<div id="catalogueDiv">
|
||||
|
|
Loading…
Reference in New Issue