Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: move /contributor #1897

Merged
merged 4 commits into from
Sep 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions TEST.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,12 @@ First, launch the webapp on localhost:

Then, in another terminal window run all the regression tests against the REST API:

mvn verify -P regression-testing-rest
mvn verify -P regression-test-rest

> [!TIP]
> If you want to run the tests against another URL, set the `base.url` system property:
>
> mvn verify -P regression-testing-rest -D base.url=https://eng.elimu.ai
> mvn verify -P regression-test-rest -D base.url=https://eng.elimu.ai

#### UI

Expand All @@ -44,18 +44,18 @@ First, launch the webapp on localhost:

Then, in another terminal window run all the regression tests against the UI:

mvn verify -P regression-testing-ui
mvn verify -P regression-test-ui

> [!TIP]
> If you want to run the tests against another URL, set the `base.url` system property:
>
> mvn verify -P regression-testing-ui -D base.url=https://eng.elimu.ai
> mvn verify -P regression-test-ui -D base.url=https://eng.elimu.ai

##### Headless 😶‍🌫️

If you don't want the automated test software to open browser windows, you can disable that by setting the `headless` system property:

mvn verify -P regression-testing-ui -D headless=true
mvn verify -P regression-test-ui -D headless=true

![](https://private-user-images.githubusercontent.com/1451036/361187317-35e99a19-f42d-4934-a0ba-f3d1e06ed6f6.png)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public String handleSubmit(
// The Contributor completed the on-boarding wizard for the first time

if (!EnvironmentContextLoaderListener.PROPERTIES.isEmpty()) {
String contentUrl = "https://" + EnvironmentContextLoaderListener.PROPERTIES.getProperty("content.language").toLowerCase() + ".elimu.ai/content/contributor/" + contributor.getId();
String contentUrl = "https://" + EnvironmentContextLoaderListener.PROPERTIES.getProperty("content.language").toLowerCase() + ".elimu.ai/contributor/" + contributor.getId();
String embedThumbnailUrl = null;
if (StringUtils.isNotBlank(contributor.getImageUrl())) {
embedThumbnailUrl = contributor.getImageUrl();
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package ai.elimu.web.content.contributor;
package ai.elimu.web.contributor;

import ai.elimu.dao.AudioContributionEventDao;
import ai.elimu.dao.AudioPeerReviewEventDao;
Expand Down Expand Up @@ -29,7 +29,7 @@
import org.springframework.web.bind.annotation.RequestMethod;

@Controller
@RequestMapping("/content/contributor/{contributorId}")
@RequestMapping("/contributor/{contributorId}")
public class ContributorController {

private final Logger logger = LogManager.getLogger();
Expand Down Expand Up @@ -111,6 +111,6 @@ public String handleRequest(
}
model.addAttribute("numberPeerReviewEventsByContributionMap", numberPeerReviewEventsByContributionMap);

return "content/contributor/contributor";
return "contributor/contributor";
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package ai.elimu.web.content.contributor;
package ai.elimu.web.contributor;

import ai.elimu.dao.ContributorDao;
import ai.elimu.dao.LetterContributionEventDao;
Expand Down Expand Up @@ -28,7 +28,7 @@
import org.springframework.web.bind.annotation.RequestMethod;

@Controller
@RequestMapping("/content/contributor/list")
@RequestMapping("/contributor/list")
public class ContributorCsvExportController {
jo-elimu marked this conversation as resolved.
Show resolved Hide resolved

private final Logger logger = LogManager.getLogger();
Expand Down Expand Up @@ -60,9 +60,9 @@ public void handleRequest(

CSVFormat csvFormat = CSVFormat.DEFAULT
.withHeader(
"contributor_id",
"ethereum_address",
"impact_percentage",
"contributor_id"
"impact_percentage"
);
StringWriter stringWriter = new StringWriter();
CSVPrinter csvPrinter = new CSVPrinter(stringWriter, csvFormat);
Expand Down Expand Up @@ -108,9 +108,9 @@ public void handleRequest(
logger.debug("impactPercentage: " + impactPercentage);

csvPrinter.printRecord(
contributor.getId(),
ethereumAddress,
impactPercentage,
contributor.getId()
impactPercentage
);

csvPrinter.flush();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package ai.elimu.web.content.contributor;
package ai.elimu.web.contributor;

import ai.elimu.dao.ContributorDao;
import org.apache.logging.log4j.Logger;
Expand All @@ -10,7 +10,7 @@
import org.springframework.web.bind.annotation.RequestMethod;

@Controller
@RequestMapping("/content/contributor/list")
@RequestMapping("/contributor/list")
public class ContributorListController {

private final Logger logger = LogManager.getLogger();
Expand All @@ -24,6 +24,6 @@ public String handleRequest(Model model) {

model.addAttribute("contributors", contributorDao.readAllOrderedDesc());

return "content/contributor/list";
return "contributor/list";
}
}
4 changes: 2 additions & 2 deletions src/main/webapp/WEB-INF/jsp/admin/layout.jsp
Original file line number Diff line number Diff line change
Expand Up @@ -98,9 +98,9 @@
</div>
</a>
<ul id='contributorDropdown' class='dropdown-content'>
<li><a href="<spring:url value='/content/contributor/${contributor.id}' />"><i class="material-icons left">art_track</i><fmt:message key="my.contributions" /></a></li>
<li><a href="<spring:url value='/contributor/${contributor.id}' />"><i class="material-icons left">art_track</i><fmt:message key="my.contributions" /></a></li>
<li class="divider"></li>
<li><a href="<spring:url value='/content/contributor/edit-name' />"><i class="material-icons left">mode_edit</i><fmt:message key="edit.name" /></a></li>
<li><a href="<spring:url value='/contributor/edit-name' />"><i class="material-icons left">mode_edit</i><fmt:message key="edit.name" /></a></li>
Comment on lines +101 to +103
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codebase verification

Remaining instances of '/content/contributor' found in JSP files.

The following files still contain /content/contributor URLs which need to be updated to align with the new URL structure:

  • src/main/webapp/WEB-INF/jsp/content/layout.jsp
  • src/main/webapp/WEB-INF/jsp/admin/layout.jsp

Please update these instances to ensure consistency across the codebase.

🔗 Analysis chain

Summary: URL paths updated successfully for contributor-related actions.

The changes in this file successfully update the URL paths for contributor-related actions by removing the /content prefix. This aligns with the PR objectives of relocating the contributor list and simplifies the overall URL structure. The changes are consistent and improve the RESTful nature of the endpoints.

To ensure completeness:

Run the following script to check if there are any remaining instances of /content/contributor that might need updating:

If the script returns any results, those locations may need to be updated as well.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Search for any remaining instances of '/content/contributor' in JSP files
# Expected result: No output, indicating all instances have been updated

rg --type jsp '/content/contributor' src/main/webapp/WEB-INF/jsp

Length of output: 92


Script:

#!/bin/bash
# Description: Search for any remaining instances of '/content/contributor' in JSP files
# Expected result: No output, indicating all instances have been updated

rg '/content/contributor' src/main/webapp/WEB-INF/jsp --glob '*.jsp'

Length of output: 1326

<%--<li class="divider"></li>
<li><a href="<spring:url value='/content/contributor/edit-email' />"><i class="material-icons left">mail</i><fmt:message key="edit.email" /></a></li>--%>
<sec:authorize access="hasRole('ROLE_ADMIN')">
Expand Down
6 changes: 3 additions & 3 deletions src/main/webapp/WEB-INF/jsp/content/layout.jsp
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@
</c:choose>

<li class="grey-text"><b><fmt:message key="community" /></b></li>
<li><a href="<spring:url value='/content/contributor/list' />"><i class="material-icons left">group</i><fmt:message key="contributors" /></a></li>
<li><a href="<spring:url value='/contributor/list' />"><i class="material-icons left">group</i><fmt:message key="contributors" /></a></li>
<li><a href="https://discord.gg/9rz4XYJJDE" target="_blank"><i class="material-icons left">forum</i>Discord</a></li>

<li class="divider"></li>
Expand All @@ -130,7 +130,7 @@
<c:choose>
<c:when test="${fn:contains(pageContext.request.requestURI, '/content/contributor/')
&& !fn:endsWith(pageContext.request.requestURI, '/list.jsp')}">
<a class="breadcrumb" href="<spring:url value='/content/contributor/list' />"><fmt:message key="contributors" /></a>
<a class="breadcrumb" href="<spring:url value='/contributor/list' />"><fmt:message key="contributors" /></a>
</c:when>
<c:when test="${fn:contains(pageContext.request.requestURI, '/content/sound/')
&& !fn:endsWith(pageContext.request.requestURI, '/list.jsp')}">
Expand Down Expand Up @@ -205,7 +205,7 @@
</div>
</a>
<ul id='contributorDropdown' class='dropdown-content'>
<li><a href="<spring:url value='/content/contributor/${contributor.id}' />"><i class="material-icons left">art_track</i><fmt:message key="my.contributions" /></a></li>
<li><a href="<spring:url value='/contributor/${contributor.id}' />"><i class="material-icons left">art_track</i><fmt:message key="my.contributions" /></a></li>
jo-elimu marked this conversation as resolved.
Show resolved Hide resolved
<li class="divider"></li>
<li><a href="<spring:url value='/content/contributor/edit-name' />"><i class="material-icons left">mode_edit</i><fmt:message key="edit.name" /></a></li>
<%--<li class="divider"></li>
Expand Down
4 changes: 2 additions & 2 deletions src/main/webapp/WEB-INF/jsp/content/letter-sound/edit.jsp
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@
(<fmt:formatNumber maxFractionDigits="0" value="${letterSoundContributionEvent.timeSpentMs / 1000 / 60}" /> min).
<fmt:formatDate value="${letterSoundContributionEvent.timestamp.time}" pattern="yyyy-MM-dd HH:mm" />
</span>
<a href="<spring:url value='/content/contributor/${letterSoundContributionEvent.contributor.id}' />">
<a href="<spring:url value='/contributor/${letterSoundContributionEvent.contributor.id}' />">
jo-elimu marked this conversation as resolved.
Show resolved Hide resolved
<div class="chip">
<c:choose>
<c:when test="${not empty letterSoundContributionEvent.contributor.imageUrl}">
Expand Down Expand Up @@ -244,7 +244,7 @@
<c:if test="${letterSoundPeerReviewEvent.letterSoundContributionEvent.id == letterSoundContributionEvent.id}">
<div class="row peerReviewEvent indent" data-approved="${letterSoundPeerReviewEvent.isApproved()}">
<div class="col s4">
<a href="<spring:url value='/content/contributor/${letterSoundPeerReviewEvent.contributor.id}' />">
<a href="<spring:url value='/contributor/${letterSoundPeerReviewEvent.contributor.id}' />">
<div class="chip">
<c:choose>
<c:when test="${not empty letterSoundPeerReviewEvent.contributor.imageUrl}">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
/ <c:forEach var="sound" items="${letterSound.sounds}"><a href="<spring:url value='/content/sound/edit/${sound.id}' />">${sound.valueIpa}</a> </c:forEach> /
</td>
<td>
<a href="<spring:url value='/content/contributor/${letterSoundContributionEvent.contributor.id}' />">
<a href="<spring:url value='/contributor/${letterSoundContributionEvent.contributor.id}' />">
jo-elimu marked this conversation as resolved.
Show resolved Hide resolved
<div class="chip">
<c:choose>
<c:when test="${not empty letterSoundContributionEvent.contributor.imageUrl}">
Expand Down
4 changes: 2 additions & 2 deletions src/main/webapp/WEB-INF/jsp/content/letter/edit.jsp
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@
(<fmt:formatNumber maxFractionDigits="0" value="${letterContributionEvent.timeSpentMs / 1000 / 60}" /> min).
<fmt:formatDate value="${letterContributionEvent.timestamp.time}" pattern="yyyy-MM-dd HH:mm" />
</span>
<a href="<spring:url value='/content/contributor/${letterContributionEvent.contributor.id}' />">
<a href="<spring:url value='/contributor/${letterContributionEvent.contributor.id}' />">
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codebase verification

Action Required: Update Remaining Instances of Old URL Structure

The old URL structure /content/contributor/ is still present in several files, which may lead to inconsistencies and potential issues within the application. Please update the following instances to maintain consistency:

  • JSP Files:

    • src/main/webapp/WEB-INF/jsp/admin/layout.jsp
    • src/main/webapp/WEB-INF/jsp/content/layout.jsp
  • Java Files:

    • src/main/java/ai/elimu/web/content/MainContentController.java
    • src/main/java/ai/elimu/web/SignOnControllerGitHub.java
    • src/main/java/ai/elimu/web/content/contributor/EditMotivationController.java
    • src/main/java/ai/elimu/web/content/contributor/EditNameController.java
    • src/main/java/ai/elimu/web/content/contributor/AddEmailController.java
    • src/main/java/ai/elimu/web/SignOnControllerDiscord.java

Please ensure all instances are updated to the new URL structure to maintain application integrity.

🔗 Analysis chain

LGTM! Verify URL consistency across the application.

The URL change from /content/contributor/${letterContributionEvent.contributor.id} to /contributor/${letterContributionEvent.contributor.id} aligns with the PR objective of relocating the contributor list. This simplification of the URL structure is a good improvement.

To ensure consistency, please run the following script to check if there are any remaining occurrences of the old URL structure:

If any occurrences are found, please update them to maintain consistency across the application.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check for any remaining occurrences of the old URL structure

# Test: Search for '/content/contributor/' in JSP files
echo "Searching for '/content/contributor/' in JSP files:"
rg --type jsp '/content/contributor/' src/main/webapp/WEB-INF/jsp/

# Test: Search for '/content/contributor/' in Java files
echo "Searching for '/content/contributor/' in Java files:"
rg --type java '/content/contributor/' src/main/java/

Length of output: 1670


Script:

#!/bin/bash
# Description: Check for any remaining occurrences of the old URL structure in JSP files

# Test: Search for '/content/contributor/' in JSP files without using --type
echo "Searching for '/content/contributor/' in JSP files:"
rg '/content/contributor/' --glob '*.jsp' src/main/webapp/WEB-INF/jsp/

Length of output: 1447

<div class="chip">
<c:choose>
<c:when test="${not empty letterContributionEvent.contributor.imageUrl}">
Expand Down Expand Up @@ -105,7 +105,7 @@
<c:if test="${letterPeerReviewEvent.letterContributionEvent.id == letterContributionEvent.id}">
<div class="row peerReviewEvent indent" data-approved="${letterPeerReviewEvent.isApproved()}">
<div class="col s4">
<a href="<spring:url value='/content/contributor/${letterPeerReviewEvent.contributor.id}' />">
<a href="<spring:url value='/contributor/${letterPeerReviewEvent.contributor.id}' />">
<div class="chip">
<c:choose>
<c:when test="${not empty letterPeerReviewEvent.contributor.imageUrl}">
Expand Down
8 changes: 4 additions & 4 deletions src/main/webapp/WEB-INF/jsp/content/main.jsp
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@
<ol style="list-style-type: inherit;">
<c:forEach var="contributor" items="${contributorsWithStoryBookContributions}">
<li>
<a href="<spring:url value='/content/contributor/${contributor.id}' />">
<a href="<spring:url value='/contributor/${contributor.id}' />">
<div class="chip">
<c:choose>
<c:when test="${not empty contributor.imageUrl}">
Expand Down Expand Up @@ -179,7 +179,7 @@
<ol style="list-style-type: inherit;">
<c:forEach var="contributor" items="${contributorsWithAudioContributions}">
<li>
<a href="<spring:url value='/content/contributor/${contributor.id}' />">
<a href="<spring:url value='/contributor/${contributor.id}' />">
<div class="chip">
<c:choose>
<c:when test="${not empty contributor.imageUrl}">
Expand Down Expand Up @@ -212,7 +212,7 @@
<ol style="list-style-type: inherit;">
<c:forEach var="contributor" items="${contributorsWithWordContributions}">
<li>
<a href="<spring:url value='/content/contributor/${contributor.id}' />">
<a href="<spring:url value='/contributor/${contributor.id}' />">
<div class="chip">
<c:choose>
<c:when test="${not empty contributor.imageUrl}">
Expand Down Expand Up @@ -245,7 +245,7 @@
<ol style="list-style-type: inherit;">
<c:forEach var="contributor" items="${contributorsWithNumberContributions}">
<li>
<a href="<spring:url value='/content/contributor/${contributor.id}' />">
<a href="<spring:url value='/contributor/${contributor.id}' />">
<div class="chip">
<c:choose>
<c:when test="${not empty contributor.imageUrl}">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@
(<fmt:formatNumber maxFractionDigits="0" value="${audioContributionEvent.timeSpentMs / 1000 / 60}" /> min).
<fmt:formatDate value="${audioContributionEvent.timestamp.time}" pattern="yyyy-MM-dd HH:mm" />
</span>
<a href="<spring:url value='/content/contributor/${audioContributionEvent.contributor.id}' />">
<a href="<spring:url value='/contributor/${audioContributionEvent.contributor.id}' />">
<div class="chip">
<c:choose>
<c:when test="${not empty audioContributionEvent.contributor.imageUrl}">
Expand Down Expand Up @@ -224,7 +224,7 @@
<c:if test="${audioPeerReviewEvent.audioContributionEvent.id == audioContributionEvent.id}">
<div class="row peerReviewEvent indent" data-approved="${audioPeerReviewEvent.isApproved()}">
<div class="col s4">
<a href="<spring:url value='/content/contributor/${audioPeerReviewEvent.contributor.id}' />">
<a href="<spring:url value='/contributor/${audioPeerReviewEvent.contributor.id}' />">
<div class="chip">
<c:choose>
<c:when test="${not empty audioPeerReviewEvent.contributor.imageUrl}">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@
(<fmt:formatNumber maxFractionDigits="0" value="${imageContributionEvent.timeSpentMs / 1000 / 60}" /> min).
<fmt:formatDate value="${imageContributionEvent.timestamp.time}" pattern="yyyy-MM-dd HH:mm" />
</span>
<a href="<spring:url value='/content/contributor/${imageContributionEvent.contributor.id}' />">
<a href="<spring:url value='/contributor/${imageContributionEvent.contributor.id}' />">
jo-elimu marked this conversation as resolved.
Show resolved Hide resolved
<div class="chip">
<c:choose>
<c:when test="${not empty imageContributionEvent.contributor.imageUrl}">
Expand Down
4 changes: 2 additions & 2 deletions src/main/webapp/WEB-INF/jsp/content/number/edit.jsp
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@
(<fmt:formatNumber maxFractionDigits="0" value="${numberContributionEvent.timeSpentMs / 1000 / 60}" /> min).
<fmt:formatDate value="${numberContributionEvent.timestamp.time}" pattern="yyyy-MM-dd HH:mm" />
</span>
<a href="<spring:url value='/content/contributor/${numberContributionEvent.contributor.id}' />">
<a href="<spring:url value='/contributor/${numberContributionEvent.contributor.id}' />">
<div class="chip">
<c:choose>
<c:when test="${not empty numberContributionEvent.contributor.imageUrl}">
Expand Down Expand Up @@ -213,7 +213,7 @@
<c:if test="${numberPeerReviewEvent.numberContributionEvent.id == numberContributionEvent.id}">
<div class="row peerReviewEvent indent" data-approved="${numberPeerReviewEvent.isApproved()}">
<div class="col s4">
<a href="<spring:url value='/content/contributor/${numberPeerReviewEvent.contributor.id}' />">
<a href="<spring:url value='/contributor/${numberPeerReviewEvent.contributor.id}' />">
<div class="chip">
<c:choose>
<c:when test="${not empty numberPeerReviewEvent.contributor.imageUrl}">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
</c:forEach>
</td>
<td>
<a href="<spring:url value='/content/contributor/${numberContributionEvent.contributor.id}' />">
<a href="<spring:url value='/contributor/${numberContributionEvent.contributor.id}' />">
jo-elimu marked this conversation as resolved.
Show resolved Hide resolved
<div class="chip">
<c:choose>
<c:when test="${not empty numberContributionEvent.contributor.imageUrl}">
Expand Down
4 changes: 2 additions & 2 deletions src/main/webapp/WEB-INF/jsp/content/sound/edit.jsp
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@
(<fmt:formatNumber maxFractionDigits="0" value="${soundContributionEvent.timeSpentMs / 1000 / 60}" /> min).
<fmt:formatDate value="${soundContributionEvent.timestamp.time}" pattern="yyyy-MM-dd HH:mm" />
</span>
<a href="<spring:url value='/content/contributor/${soundContributionEvent.contributor.id}' />">
<a href="<spring:url value='/contributor/${soundContributionEvent.contributor.id}' />">
<div class="chip">
<c:choose>
<c:when test="${not empty soundContributionEvent.contributor.imageUrl}">
Expand Down Expand Up @@ -109,7 +109,7 @@
<c:if test="${soundPeerReviewEvent.soundContributionEvent.id == soundContributionEvent.id}">
<div class="row peerReviewEvent indent" data-approved="${soundPeerReviewEvent.isApproved()}">
<div class="col s4">
<a href="<spring:url value='/content/contributor/${soundPeerReviewEvent.contributor.id}' />">
<a href="<spring:url value='/contributor/${soundPeerReviewEvent.contributor.id}' />">
<div class="chip">
<c:choose>
<c:when test="${not empty soundPeerReviewEvent.contributor.imageUrl}">
Expand Down
Loading
Loading