From 70349fb7e32551b0afa9ba8c5ae3d85bfcc30e48 Mon Sep 17 00:00:00 2001 From: Reece Browne <74901996+reecebrowne@users.noreply.github.com> Date: Tue, 20 May 2025 12:08:20 +0100 Subject: [PATCH] remove legacy homepage (#3518) # Description of Changes Please provide a summary of the changes, including: - What was changed - Why the change was made - Any challenges encountered Closes #(issue_number) --- ## Checklist ### General - [ ] I have read the [Contribution Guidelines](https://github.com/Stirling-Tools/Stirling-PDF/blob/main/CONTRIBUTING.md) - [ ] I have read the [Stirling-PDF Developer Guide](https://github.com/Stirling-Tools/Stirling-PDF/blob/main/DeveloperGuide.md) (if applicable) - [ ] I have read the [How to add new languages to Stirling-PDF](https://github.com/Stirling-Tools/Stirling-PDF/blob/main/HowToAddNewLanguage.md) (if applicable) - [ ] I have performed a self-review of my own code - [ ] My changes generate no new warnings ### Documentation - [ ] I have updated relevant docs on [Stirling-PDF's doc repo](https://github.com/Stirling-Tools/Stirling-Tools.github.io/blob/main/docs/) (if functionality has heavily changed) - [ ] I have read the section [Add New Translation Tags](https://github.com/Stirling-Tools/Stirling-PDF/blob/main/HowToAddNewLanguage.md#add-new-translation-tags) (for new translation tags only) ### UI Changes (if applicable) - [ ] Screenshots or videos demonstrating the UI changes are attached (e.g., as comments or direct attachments in the PR) ### Testing (if applicable) - [ ] I have tested my changes locally. Refer to the [Testing Guide](https://github.com/Stirling-Tools/Stirling-PDF/blob/main/DeveloperGuide.md#6-testing) for more details. --- .../controller/web/HomeWebController.java | 5 +- src/main/resources/static/css/home-legacy.css | 229 -------- src/main/resources/static/js/favourites.js | 6 +- .../resources/static/js/homecard-legacy.js | 266 --------- src/main/resources/static/js/pages/home.js | 4 - .../fragments/featureGroupHeaderLegacy.html | 6 - src/main/resources/templates/home-legacy.html | 528 ------------------ src/main/resources/templates/home.html | 7 - 8 files changed, 3 insertions(+), 1048 deletions(-) delete mode 100644 src/main/resources/static/css/home-legacy.css delete mode 100644 src/main/resources/static/js/homecard-legacy.js delete mode 100644 src/main/resources/templates/fragments/featureGroupHeaderLegacy.html delete mode 100644 src/main/resources/templates/home-legacy.html diff --git a/src/main/java/stirling/software/SPDF/controller/web/HomeWebController.java b/src/main/java/stirling/software/SPDF/controller/web/HomeWebController.java index 9a3b2b3e2..9fc644863 100644 --- a/src/main/java/stirling/software/SPDF/controller/web/HomeWebController.java +++ b/src/main/java/stirling/software/SPDF/controller/web/HomeWebController.java @@ -77,9 +77,8 @@ public class HomeWebController { } @GetMapping("/home-legacy") - public String homeLegacy(Model model) { - model.addAttribute("currentPage", "home-legacy"); - return "home-legacy"; + public String redirectHomeLegacy() { + return "redirect:/"; } @GetMapping(value = "/robots.txt", produces = MediaType.TEXT_PLAIN_VALUE) diff --git a/src/main/resources/static/css/home-legacy.css b/src/main/resources/static/css/home-legacy.css deleted file mode 100644 index b25fafc17..000000000 --- a/src/main/resources/static/css/home-legacy.css +++ /dev/null @@ -1,229 +0,0 @@ -#searchBar { - color: var(--md-sys-color-on-surface); - background-color: var(--md-sys-color-surface-container-low); - width: 100%; - font-size: 16px; - margin-bottom: 2rem; - padding: 0.75rem 3.5rem; - border: 1px solid var(--md-sys-color-outline-variant); - border-radius: 3rem; - outline-color: var(--md-sys-color-outline-variant); - } - - #filtersContainer { - display: flex; - width: 100%; - align-items: center; - justify-content: center; - gap: 10px; - } - - .filter-button { - color: var(--md-sys-color-secondary); - user-select: none; - cursor: pointer; - transition: transform 0.3s; - transform-origin: center center; - } - - .filter-button:hover { - transform: scale(1.08); - } - - .search-icon { - position: absolute; - margin: 0.75rem 1rem; - border: 0.1rem solid transparent; - } - - .features-container { - display: flex; - flex-direction: column; - gap: 30px; - } - - .feature-group-legacy { - display: flex; - flex-direction: column; - } - - .feature-group-header { - display: flex; - align-items: center; - justify-content: flex-start; - color: var(--md-sys-color-on-surface); - margin-bottom: 15px; - user-select: none; - cursor: pointer; - gap: 10px; - } - - .feature-group-container { - display: grid; - grid-template-columns: repeat(auto-fill, minmax(15rem, 3fr)); - gap: 30px 30px; - overflow: hidden; - margin: -20px; - padding: 20px; - box-sizing:content-box; - } - - .feature-group-container.animated-group { - transition: 0.5s all; - } - - .feature-group-legacy.collapsed>.feature-group-container { - max-height: 0 !important; - margin: 0; - padding: 0; - } - - .header-expand-button { - transition: 0.5s all; - transform: rotate(90deg); - } - - .header-expand-button.collapsed { - transform: rotate(0deg); - } - - .feature-card { - border: 1px solid var(--md-sys-color-surface-5); - border-radius: 1.75rem; - padding: 1.25rem; - display: flex; - flex-direction: column; - align-items: flex-start; - background: var(--md-sys-color-surface-5); - transition: - transform 0.3s, - border 0.3s; - transform-origin: center center; - outline: 0px solid transparent; - position:relative; - } - - .feature-card a { - text-decoration: none; - color: var(--md-sys-color-on-surface); - display: flex; - flex-direction: column; - width: 100%; - height: 100%; - } - - .feature-card .card-text { - font-size: .875rem; - } - - .feature-card:hover { - cursor: pointer; - transform: scale(1.08); - box-shadow: var(--md-sys-elevation-2); - } - - .card-title.text-primary { - color: #000; - } - - .home-card-icon { - width: 3rem; - height: 3rem; - transform: translateY(-5px); - } - - .favorite-icon { - display: none !important; - position: absolute; - top: 10px; - right: 10px; - color: var(--md-sys-color-secondary); - } - - #tool-icon { - height: 100%; - } - - #tool-text { - margin: 0.0rem 0 0 1.25rem; - } - - .card-title { - margin-bottom: 1rem; - font-size: 1.1rem; - } - - /* Only show the favorite icons when the parent card is being hovered over */ - .feature-card:hover .favorite-icon { - display: block !important; - } - - .favorite-icon img { - filter: brightness(0) invert(var(--md-theme-filter-color)); - } - - .favorite-icon:hover .material-symbols-rounded { - transform: scale(1.2); - } - - .favorite-icon .material-symbols-rounded.fill{ - color: #f5c000; - } - - .jumbotron { - padding: 3rem 3rem; - /* Reduce vertical padding */ - } - - .lookatme { - opacity: 1; - position: relative; - display: inline-block; - } - - .lookatme::after { - color: #e33100; - text-shadow: 0 0 5px #e33100; - /* in the html, the data-lookatme-text attribute must */ - /* contain the same text as the .lookatme element */ - content: attr(data-lookatme-text); - padding: inherit; - position: absolute; - inset: 0 0 0 0; - z-index: 1; - /* 20 steps / 2 seconds = 10fps */ - -webkit-animation: 2s infinite Pulse steps(20); - animation: 2s infinite Pulse steps(20); - } - - @keyframes Pulse { - from { - opacity: 0; - } - - 50% { - opacity: 1; - } - - to { - opacity: 0; - } - } - - .update-notice { - animation: scale 1s infinite alternate; - } - - @keyframes scale { - 0% { - transform: scale(0.96); - } - - 100% { - transform: scale(1); - } - } - - .hidden { - visibility: hidden; - } diff --git a/src/main/resources/static/js/favourites.js b/src/main/resources/static/js/favourites.js index 913c656b2..5aab52824 100644 --- a/src/main/resources/static/js/favourites.js +++ b/src/main/resources/static/js/favourites.js @@ -126,11 +126,7 @@ function addToFavorites(entryId) { localStorage.setItem('favoritesList', JSON.stringify(favoritesList)); updateFavoritesDropdown(); updateFavoriteIcons(); - const currentPath = window.location.pathname; - if (currentPath.includes('home-legacy')) { - syncFavoritesLegacy(); - } else { + initializeCards(); - } } } diff --git a/src/main/resources/static/js/homecard-legacy.js b/src/main/resources/static/js/homecard-legacy.js deleted file mode 100644 index a43453f1c..000000000 --- a/src/main/resources/static/js/homecard-legacy.js +++ /dev/null @@ -1,266 +0,0 @@ -function filterCardsLegacy() { - var input = document.getElementById('searchBar'); - var filter = input.value.toUpperCase(); - - let featureGroups = document.querySelectorAll('.feature-group-legacy'); - const collapsedGroups = getCollapsedGroups(); - - for (const featureGroup of featureGroups) { - var cards = featureGroup.querySelectorAll('.feature-card'); - - let groupMatchesFilter = false; - for (var i = 0; i < cards.length; i++) { - var card = cards[i]; - var title = card.querySelector('h5.card-title').innerText; - var text = card.querySelector('p.card-text').innerText; - - // Get the navbar tags associated with the card - var navbarItem = document.querySelector(`a.dropdown-item[href="${card.id}"]`); - var navbarTags = navbarItem ? navbarItem.getAttribute('data-bs-tags') : ''; - - var content = title + ' ' + text + ' ' + navbarTags; - - if (content.toUpperCase().indexOf(filter) > -1) { - card.style.display = ''; - groupMatchesFilter = true; - } else { - card.style.display = 'none'; - } - } - - if (!groupMatchesFilter) { - featureGroup.style.display = 'none'; - } else { - featureGroup.style.display = ''; - resetOrTemporarilyExpandGroup(featureGroup, filter, collapsedGroups); - } - } -} - -function getCollapsedGroups() { - return localStorage.getItem('collapsedGroups') ? JSON.parse(localStorage.getItem('collapsedGroups')) : []; -} - -function resetOrTemporarilyExpandGroup(featureGroup, filterKeywords = '', collapsedGroups = []) { - const shouldResetCollapse = filterKeywords.trim() === ''; - if (shouldResetCollapse) { - // Resetting the group's expand/collapse to its original state (as in collapsed groups) - const isCollapsed = collapsedGroups.indexOf(featureGroup.id) != -1; - expandCollapseToggle(featureGroup, !isCollapsed); - } else { - // Temporarily expands feature group without affecting the actual/stored collapsed groups - featureGroup.classList.remove('collapsed'); - featureGroup.querySelector('.header-expand-button').classList.remove('collapsed'); - } -} - -function updateFavoritesSectionLegacy() { - const favoritesContainer = document.getElementById('groupFavorites').querySelector('.feature-group-container'); - favoritesContainer.innerHTML = ''; - const cards = Array.from(document.querySelectorAll('.feature-card:not(.duplicate)')); - const addedCardIds = new Set(); - let favoritesAmount = 0; - - cards.forEach((card) => { - const favouritesList = JSON.parse(localStorage.getItem('favoritesList') || '[]'); - - if (favouritesList.includes(card.id) && !addedCardIds.has(card.id)) { - const duplicate = card.cloneNode(true); - duplicate.classList.add('duplicate'); - favoritesContainer.appendChild(duplicate); - addedCardIds.add(card.id); - favoritesAmount++; - } - }); - - if (favoritesAmount === 0) { - document.getElementById('groupFavorites').style.display = 'none'; - } else { - document.getElementById('groupFavorites').style.display = 'flex'; - } - reorderCards(favoritesContainer); -} - -function syncFavoritesLegacy() { - const cards = Array.from(document.querySelectorAll('.feature-card')); - cards.forEach((card) => { - const isFavorite = localStorage.getItem(card.id) === 'favorite'; - const starIcon = card.querySelector('.favorite-icon span.material-symbols-rounded'); - if (starIcon) { - if (isFavorite) { - starIcon.classList.remove('no-fill'); - starIcon.classList.add('fill'); - card.classList.add('favorite'); - } else { - starIcon.classList.remove('fill'); - starIcon.classList.add('no-fill'); - card.classList.remove('favorite'); - } - } - }); - updateFavoritesSectionLegacy(); - updateFavoritesDropdown(); - filterCardsLegacy(); -} - -function reorderCards(container) { - var cards = Array.from(container.querySelectorAll('.feature-card')); - cards.forEach(function (card) { - container.removeChild(card); - }); - cards.sort(function (a, b) { - var aIsFavorite = localStorage.getItem(a.id) === 'favorite'; - var bIsFavorite = localStorage.getItem(b.id) === 'favorite'; - if (a.id === 'update-link') { - return -1; - } - if (b.id === 'update-link') { - return 1; - } - - if (aIsFavorite && !bIsFavorite) { - return -1; - } else if (!aIsFavorite && bIsFavorite) { - return 1; - } else { - return a.id > b.id; - } - }); - cards.forEach(function (card) { - container.appendChild(card); - }); -} - -function reorderAllCards() { - const containers = Array.from(document.querySelectorAll('.feature-group-container')); - containers.forEach(function (container) { - reorderCards(container); - }); -} - -function initializeCardsLegacy() { - reorderAllCards(); - updateFavoritesSectionLegacy(); - updateFavoritesDropdown(); - filterCardsLegacy(); -} - -function showFavoritesOnly() { - const groups = Array.from(document.querySelectorAll('.feature-group-legacy')); - if (localStorage.getItem('favoritesOnly') === 'true') { - groups.forEach((group) => { - if (group.id !== 'groupFavorites') { - group.style.display = 'none'; - } - }); - } else { - groups.forEach((group) => { - if (group.id !== 'groupFavorites') { - group.style.display = 'flex'; - } - }); - } -} - -function toggleFavoritesOnly() { - if (localStorage.getItem('favoritesOnly') === 'true') { - localStorage.setItem('favoritesOnly', 'false'); - } else { - localStorage.setItem('favoritesOnly', 'true'); - } - showFavoritesOnly(); -} - -// Expands a feature group on true, collapses it on false and toggles state on null. -function expandCollapseToggle(group, expand = null) { - if (expand === null) { - group.classList.toggle('collapsed'); - group.querySelector('.header-expand-button').classList.toggle('collapsed'); - } else if (expand) { - group.classList.remove('collapsed'); - group.querySelector('.header-expand-button').classList.remove('collapsed'); - } else { - group.classList.add('collapsed'); - group.querySelector('.header-expand-button').classList.add('collapsed'); - } - - const collapsed = localStorage.getItem('collapsedGroups') ? JSON.parse(localStorage.getItem('collapsedGroups')) : []; - const groupIndex = collapsed.indexOf(group.id); - - if (group.classList.contains('collapsed')) { - if (groupIndex === -1) { - collapsed.push(group.id); - } - } else { - if (groupIndex !== -1) { - collapsed.splice(groupIndex, 1); - } - } - - localStorage.setItem('collapsedGroups', JSON.stringify(collapsed)); -} - -function expandCollapseAll(expandAll) { - const groups = Array.from(document.querySelectorAll('.feature-group-legacy')); - groups.forEach((group) => { - expandCollapseToggle(group, expandAll); - }); -} - -window.onload = function () { - initializeCardsLegacy(); - syncFavoritesLegacy(); // Ensure everything is in sync on page load -}; - -document.addEventListener('DOMContentLoaded', function () { - const materialIcons = new FontFaceObserver('Material Symbols Rounded'); - - materialIcons - .load() - .then(() => { - document.querySelectorAll('.feature-card.hidden').forEach((el) => { - el.classList.remove('hidden'); - }); - }) - .catch(() => { - console.error('Material Symbols Rounded font failed to load.'); - }); - - Array.from(document.querySelectorAll('.feature-group-header-legacy')).forEach((header) => { - const parent = header.parentNode; - const container = header.parentNode.querySelector('.feature-group-container'); - if (parent.id !== 'groupFavorites') { - // container.style.maxHeight = container.scrollHeight + 'px'; - } - header.onclick = () => { - expandCollapseToggle(parent); - }; - }); - - const collapsed = localStorage.getItem('collapsedGroups') ? JSON.parse(localStorage.getItem('collapsedGroups')) : []; - const groupsArray = Array.from(document.querySelectorAll('.feature-group-legacy')); - - groupsArray.forEach((group) => { - if (collapsed.indexOf(group.id) !== -1) { - expandCollapseToggle(group, false); - } - }); - - // Necessary in order to not fire the transition animation on page load, which looks wrong. - // The timeout isn't doing anything visible to the user, so it's not making the page load look slower. - setTimeout(() => { - groupsArray.forEach((group) => { - const container = group.querySelector('.feature-group-container'); - container.classList.add('animated-group'); - }); - }, 500); - - Array.from(document.querySelectorAll('.feature-group-header')).forEach((header) => { - const parent = header.parentNode; - header.onclick = () => { - expandCollapseToggle(parent); - }; - }); - - showFavoritesOnly(); -}); diff --git a/src/main/resources/static/js/pages/home.js b/src/main/resources/static/js/pages/home.js index bb1e1ad4a..d474e9439 100644 --- a/src/main/resources/static/js/pages/home.js +++ b/src/main/resources/static/js/pages/home.js @@ -55,10 +55,6 @@ hideCookieBanner(); updateFavoriteIcons(); const contentPath = /*[[${@contextPath}]]*/ ''; -const defaultView = localStorage.getItem('defaultView') || 'home'; // Default to "home" -if (defaultView === 'home-legacy') { - window.location.href = contentPath + 'home-legacy'; // Redirect to legacy view -} document.addEventListener('DOMContentLoaded', function () { const surveyVersion = '3.0'; diff --git a/src/main/resources/templates/fragments/featureGroupHeaderLegacy.html b/src/main/resources/templates/fragments/featureGroupHeaderLegacy.html deleted file mode 100644 index 0a8f7e9b1..000000000 --- a/src/main/resources/templates/fragments/featureGroupHeaderLegacy.html +++ /dev/null @@ -1,6 +0,0 @@ -
- - - chevron_right - -
\ No newline at end of file diff --git a/src/main/resources/templates/home-legacy.html b/src/main/resources/templates/home-legacy.html deleted file mode 100644 index d60ac220e..000000000 --- a/src/main/resources/templates/home-legacy.html +++ /dev/null @@ -1,528 +0,0 @@ - - - - - - - - -
-
- - -
-
-

-

-

-
-
-
- - -
-
- - search - - -
- - - - - home - - -
-
- - star - - - expand_all - - - collapse_all - - -
- -
- - - -
-
-
-
-
-
- - -
-
-
-
-
-
- -
-
-
-
-
-
-
-
- - - - -
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- -
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- -
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- -
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- -
-
-
-
-
-
-
-
-
-
- -
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- -
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- -
- - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/src/main/resources/templates/home.html b/src/main/resources/templates/home.html index a7cbbbd80..0bb9a2c06 100644 --- a/src/main/resources/templates/home.html +++ b/src/main/resources/templates/home.html @@ -82,13 +82,6 @@ visibility - - - home - -