From 561eab0f0e1518924c677742f8a5dfb466cde6d3 Mon Sep 17 00:00:00 2001 From: "stirlingbot[bot]" <195170888+stirlingbot[bot]@users.noreply.github.com> Date: Sun, 30 Mar 2025 12:11:05 +0100 Subject: [PATCH 1/3] :globe_with_meridians: Sync Translations + Update README Progress Table (#3263) ### Description of Changes This Pull Request was automatically generated to synchronize updates to translation files and documentation. Below are the details of the changes made: #### **1. Synchronization of Translation Files** - Updated translation files (`messages_*.properties`) to reflect changes in the reference file `messages_en_GB.properties`. - Ensured consistency and synchronization across all supported language files. - Highlighted any missing or incomplete translations. #### **2. Update README.md** - Generated the translation progress table in `README.md`. - Added a summary of the current translation status for all supported languages. - Included up-to-date statistics on translation coverage. #### **Why these changes are necessary** - Keeps translation files aligned with the latest reference updates. - Ensures the documentation reflects the current translation progress. --- Auto-generated by [create-pull-request][1]. [1]: https://github.com/peter-evans/create-pull-request --------- Co-authored-by: stirlingbot[bot] <195170888+stirlingbot[bot]@users.noreply.github.com> --- README.md | 2 +- src/main/resources/messages_pl_PL.properties | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index dc2270345..5aace9610 100644 --- a/README.md +++ b/README.md @@ -139,7 +139,7 @@ Stirling-PDF currently supports 39 languages! | Korean (한국어) (ko_KR) | ![95%](https://geps.dev/progress/95) | | Norwegian (Norsk) (no_NB) | ![89%](https://geps.dev/progress/89) | | Persian (فارسی) (fa_IR) | ![90%](https://geps.dev/progress/90) | -| Polish (Polski) (pl_PL) | ![82%](https://geps.dev/progress/82) | +| Polish (Polski) (pl_PL) | ![98%](https://geps.dev/progress/98) | | Portuguese (Português) (pt_PT) | ![93%](https://geps.dev/progress/93) | | Portuguese Brazilian (Português) (pt_BR) | ![96%](https://geps.dev/progress/96) | | Romanian (Română) (ro_RO) | ![77%](https://geps.dev/progress/77) | diff --git a/src/main/resources/messages_pl_PL.properties b/src/main/resources/messages_pl_PL.properties index 7cde4c3ed..dcc4350e9 100644 --- a/src/main/resources/messages_pl_PL.properties +++ b/src/main/resources/messages_pl_PL.properties @@ -1036,10 +1036,10 @@ decrypt.unexpectedError=Wystąpił błąd podczas przetwarzania pliku. Spróbuj decrypt.serverError=Błąd serwera podczas odszyfrowywania: {0} decrypt.success=Plik został pomyślnie odszyfrowany. -#multiTool-advert -multiTool-advert.message=Ta funkcja jest również dostępna na naszej stronie narzędzia wielofunkcyjnego. Sprawdź ją, aby uzyskać lepszy interfejs zarządzania stronami i dodatkowe funkcje! +#multiTool-advert +multiTool-advert.message=Ta funkcja jest również dostępna na naszej stronie narzędzia wielofunkcyjnego. Sprawdź ją, aby uzyskać lepszy interfejs zarządzania stronami i dodatkowe funkcje! -#view pdf +#view pdf viewPdf.title=Przeglądaj/Edytuj PDF viewPdf.header=Podejrzyj PDF From 7ba2884280e7c4a407b425e3691259b426246a61 Mon Sep 17 00:00:00 2001 From: "stirlingbot[bot]" <195170888+stirlingbot[bot]@users.noreply.github.com> Date: Sun, 30 Mar 2025 12:11:20 +0100 Subject: [PATCH 2/3] =?UTF-8?q?=F0=9F=A4=96=20format=20everything=20with?= =?UTF-8?q?=20pre-commit=20by=20=20(#3265)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Auto-generated by [create-pull-request][1] with **stirlingbot** [1]: https://github.com/peter-evans/create-pull-request Signed-off-by: stirlingbot[bot] <195170888+stirlingbot[bot]@users.noreply.github.com> Co-authored-by: stirlingbot[bot] <195170888+stirlingbot[bot]@users.noreply.github.com> --- src/main/resources/static/js/usage.js | 56 +++++++++++++-------------- 1 file changed, 28 insertions(+), 28 deletions(-) diff --git a/src/main/resources/static/js/usage.js b/src/main/resources/static/js/usage.js index a9c98ed9e..624e4ec78 100644 --- a/src/main/resources/static/js/usage.js +++ b/src/main/resources/static/js/usage.js @@ -27,7 +27,7 @@ function getChartColors() { } // Watch for theme changes and update chart if needed -function setupThemeChangeListener() { +function setupThemeChangeListener() { // Start observing theme changes document.addEventListener("modeChanged", (event) => { @@ -41,7 +41,7 @@ function setupThemeChangeListener() { } }, 100); }); - + // Also watch for system preference changes window .matchMedia('(prefers-color-scheme: dark)') @@ -60,22 +60,22 @@ function setupThemeChangeListener() { function filterData() { const includeHome = document.getElementById('hideHomeCheckbox').checked; const includeLogin = document.getElementById('hideLoginCheckbox').checked; - + filteredData = allEndpointData.filter(item => { if (!includeHome && item.endpoint === '/') return false; if (!includeLogin && item.endpoint === '/login') return false; return true; }); - + // Sort and calculate sortedData = [...filteredData].sort((a, b) => b.count - a.count); totalEndpoints = filteredData.length; totalVisits = filteredData.reduce((sum, item) => sum + item.count, 0); - + // Update stats document.getElementById('totalEndpoints').textContent = totalEndpoints.toLocaleString(); document.getElementById('totalVisits').textContent = totalVisits.toLocaleString(); - + // Update the chart with current limit const currentLimit = document.getElementById('currentlyShowing').textContent; const limit = (currentLimit === endpointStatsTranslations.all) @@ -96,33 +96,33 @@ async function fetchEndpointData() { ${endpointStatsTranslations.loading} `; chartContainer.appendChild(loadingDiv); - + // Also add animation to refresh button const refreshBtn = document.getElementById('refreshBtn'); refreshBtn.classList.add('refreshing'); refreshBtn.disabled = true; - + const response = await fetch('/api/v1/info/load/all'); if (!response.ok) { throw new Error('Network response was not ok'); } - + const data = await response.json(); allEndpointData = data; - + // Apply filters filterData(); - + // Remove loading state chartContainer.removeChild(loadingDiv); refreshBtn.classList.remove('refreshing'); refreshBtn.disabled = false; - + } catch (error) { console.error('Error fetching endpoint data:', error); // Show error message to user showError(endpointStatsTranslations.failedToLoad); - + // Reset refresh button const refreshBtn = document.getElementById('refreshBtn'); refreshBtn.classList.remove('refreshing'); @@ -141,24 +141,24 @@ function formatEndpointName(endpoint) { function updateTable(data) { const tableBody = document.getElementById('endpointTableBody'); tableBody.innerHTML = ''; - + data.forEach((item, index) => { const percentage = ((item.count / totalVisits) * 100).toFixed(2); const row = document.createElement('tr'); - + // Format endpoint for better readability let displayEndpoint = item.endpoint; if (displayEndpoint.length > 40) { displayEndpoint = displayEndpoint.substring(0, 37) + '...'; } - + row.innerHTML = ` ${index + 1} ${displayEndpoint} ${item.count.toLocaleString()} ${percentage}% `; - + tableBody.appendChild(row); }); } @@ -172,10 +172,10 @@ function updateChart(dataLimit) { const displayedPercentage = totalVisits > 0 ? ((displayedVisits / totalVisits) * 100).toFixed(2) : '0'; - + document.getElementById('displayedVisits').textContent = displayedVisits.toLocaleString(); document.getElementById('displayedPercentage').textContent = displayedPercentage; - + // If the limit equals the total filtered items, show "All"; otherwise "Top X" document.getElementById('currentlyShowing').textContent = (dataLimit === filteredData.length) @@ -303,30 +303,30 @@ function updateChart(dataLimit) { document.addEventListener('DOMContentLoaded', function() { // Set up theme change listener setupThemeChangeListener(); - + // Initial data fetch fetchEndpointData(); - + // Set up button event listeners document.getElementById('top10Btn').addEventListener('click', function() { updateChart(10); setActiveButton(this); }); - + document.getElementById('top20Btn').addEventListener('click', function() { updateChart(20); setActiveButton(this); }); - + document.getElementById('allBtn').addEventListener('click', function() { updateChart(filteredData.length); setActiveButton(this); }); - + document.getElementById('refreshBtn').addEventListener('click', function() { fetchEndpointData(); }); - + // Set up filter checkbox listeners document.getElementById('hideHomeCheckbox').addEventListener('change', filterData); document.getElementById('hideLoginCheckbox').addEventListener('change', filterData); @@ -350,14 +350,14 @@ function showError(message) { error ${message} `; - + chartContainer.innerHTML = ''; chartContainer.appendChild(errorDiv); - + // Add retry button functionality document.getElementById('errorRetryBtn').addEventListener('click', fetchEndpointData); } From bcf7fab825bc672ab6745e2fe77b2403a5cb1ad0 Mon Sep 17 00:00:00 2001 From: Ludy Date: Sun, 30 Mar 2025 16:20:05 +0200 Subject: [PATCH 3/3] Add default authority assignment and enhanced user creation method (#3266) # Description of Changes Please provide a summary of the changes, including: - **What was changed**: - Automatically assign the `USER` role to newly created users in the `saveUser(String username, String password)` method. - Introduced a new `saveUser(String username, String password, boolean firstLogin, boolean enabled)` method to allow setting `firstLogin` and `enabled` flags at creation time. - Added `"anonymoususer"` to the list of restricted usernames in `isUsernameValid`. - **Why the change was made**: - Ensures users have proper default roles assigned to avoid permission issues post-creation. - Provides more flexibility for user creation in scenarios like pre-provisioning or scripting users with specific states. - Prevents the creation of potentially reserved or insecure usernames like `anonymoususer`. --- ## Checklist ### General - [x] I have read the [Contribution Guidelines](https://github.com/Stirling-Tools/Stirling-PDF/blob/main/CONTRIBUTING.md) - [x] 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) - [x] I have performed a self-review of my own code - [x] 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. --- .../SPDF/config/security/UserService.java | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/main/java/stirling/software/SPDF/config/security/UserService.java b/src/main/java/stirling/software/SPDF/config/security/UserService.java index 155ed76b0..f3627d499 100644 --- a/src/main/java/stirling/software/SPDF/config/security/UserService.java +++ b/src/main/java/stirling/software/SPDF/config/security/UserService.java @@ -205,6 +205,7 @@ public class UserService implements UserServiceInterface { user.setPassword(passwordEncoder.encode(password)); user.setEnabled(true); user.setAuthenticationType(AuthenticationType.WEB); + user.addAuthority(new Authority(Role.USER.getRoleId(), user)); userRepository.save(user); databaseService.exportDatabase(); } @@ -230,6 +231,22 @@ public class UserService implements UserServiceInterface { saveUser(username, password, role, false); } + public void saveUser(String username, String password, boolean firstLogin, boolean enabled) + throws IllegalArgumentException, SQLException, UnsupportedProviderException { + if (!isUsernameValid(username)) { + throw new IllegalArgumentException(getInvalidUsernameMessage()); + } + User user = new User(); + user.setUsername(username); + user.setPassword(passwordEncoder.encode(password)); + user.addAuthority(new Authority(Role.USER.getRoleId(), user)); + user.setEnabled(enabled); + user.setAuthenticationType(AuthenticationType.WEB); + user.setFirstLogin(firstLogin); + userRepository.save(user); + databaseService.exportDatabase(); + } + public void deleteUser(String username) { Optional userOpt = findByUsernameIgnoreCase(username); if (userOpt.isPresent()) { @@ -352,6 +369,7 @@ public class UserService implements UserServiceInterface { List notAllowedUserList = new ArrayList<>(); notAllowedUserList.add("ALL_USERS".toLowerCase()); + notAllowedUserList.add("anonymoususer"); boolean notAllowedUser = notAllowedUserList.contains(username.toLowerCase()); return (isValidSimpleUsername || isValidEmail) && !notAllowedUser; }