Skip to content

Commit

Permalink
envs
Browse files Browse the repository at this point in the history
  • Loading branch information
Frooodle committed Apr 2, 2023
1 parent a80c585 commit 22be1a1
Show file tree
Hide file tree
Showing 25 changed files with 62 additions and 25 deletions.
4 changes: 3 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,9 @@ COPY build/libs/*.jar app.jar
EXPOSE 8080

# Set environment variables
ENV APP_NAME="Stirling PDF"
ENV APP_HOME_NAME="Stirling PDF"
#ENV APP_HOME_DESCRIPTION="Personal PDF Website!"
#ENV APP_NAVBAR_NAME="Stirling PDF"

# Run the application
ENTRYPOINT java -jar /app.jar
Expand Down
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ services:
image: frooodle/s-pdf
```


## Enable OCR/Compression feature
Please view https://github.com/Frooodle/Stirling-PDF/blob/main/HowToUseOCR.md

Expand All @@ -90,3 +91,7 @@ Also please note as i add new features i will google translate existing language
2. Use the application by following the instructions on the website.


## Customize App Name
Stirling PDF allows easy customization of the visible application name.
Simply use environment variables APP_HOME_NAME, APP_HOME_DESCRIPTION and APP_NAVBAR_NAME with Docker or Java.
If running Java directly, you can also pass these as properties using -D arguments.
25 changes: 23 additions & 2 deletions src/main/java/stirling/software/SPDF/config/AppConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,30 @@ public String appVersion() {

@Bean(name = "appName")
public String appName() {
String appName = System.getProperty("AppName");
String appName = System.getProperty("APP_HOME_NAME");
if(appName == null)
appName = System.getenv("APP_NAME");
appName = System.getenv("APP_HOME_NAME");
return (appName != null) ? appName : "Stirling PDF";
}

@Bean(name = "navBarText")
public String navBarText() {
String navBarText = System.getProperty("APP_NAVBAR_NAME");
if(navBarText == null)
navBarText = System.getenv("APP_NAVBAR_NAME");
if(navBarText == null)
navBarText = System.getProperty("APP_HOME_NAME");
if(navBarText == null)
navBarText = System.getenv("APP_HOME_NAME");

return (navBarText != null) ? navBarText : "Stirling PDF";
}

@Bean(name = "homeText")
public String homeText() {
String homeText = System.getProperty("APP_HOME_DESCRIPTION");
if(homeText == null)
homeText = System.getenv("APP_HOME_DESCRIPTION");
return (homeText != null) ? homeText : "null";
}
}
2 changes: 1 addition & 1 deletion src/main/resources/templates/add-image.html
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ <h2 th:text="#{addImage.header}"></h2>
<div class="form-group">
<label for="y">Y</label> <input type="number" class="form-control" id="y" name="y" step="0.01" required>
</div>
<button type="submit" class="btn btn-primary" th:text="#{addImage.submit}"></button>
<button type="submit" id="submitBtn" class="btn btn-primary" th:text="#{addImage.submit}"></button>
</form>
</div>
</div>
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/templates/compress-pdf.html
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ <h2 th:text="#{compress.header}"></h2>
<input type="checkbox" name="jbig2Lossy" id="jbig2Lossy">
<label for="jbig2Lossy" th:text="#{compress.selectText.7}"></label>
</div>
<button type="submit" class="btn btn-primary" th:text="#{compress.submit}"></button>
<button type="submit" id="submitBtn" class="btn btn-primary" th:text="#{compress.submit}"></button>
</form>
<p class="mt-3" th:text="#{compress.credit}"></p>

Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/templates/convert/file-to-pdf.html
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ <h2 th:text="#{fileToPDF.header}"></h2>
<form method="post" enctype="multipart/form-data" th:action="@{file-to-pdf}">
<div th:replace="~{fragments/common :: fileSelector(name='fileInput', multiple=false)}"></div>
<br>
<button type="submit" class="btn btn-primary" th:text="#{fileToPDF.submit}"></button>
<button type="submit" id="submitBtn" class="btn btn-primary" th:text="#{fileToPDF.submit}"></button>

</form>
<p class="mt-3" th:text="#{fileToPDF.credit}"></p>
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/templates/convert/img-to-pdf.html
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ <h2 th:text="#{imageToPDF.header}"></h2>
</div>

<br> <br>
<button type="submit" class="btn btn-primary" th:text="#{imageToPDF.submit}"></button>
<button type="submit" id="submitBtn" class="btn btn-primary" th:text="#{imageToPDF.submit}"></button>
<script>
$('#fileInput-input').on('change', function() {
var files = document.getElementById("fileInput-input").files;
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/templates/convert/pdf-to-img.html
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ <h2 th:text="#{pdfToImage.header}"></h2>
<label for="dpi">DPI:</label>
<input type="number" name="dpi" class="form-control" id="dpi" min="1" max="100" step="1" value="30" required>
</div>
<button type="submit" class="btn btn-primary" th:text="#{pdfToImage.submit}"></button>
<button type="submit" id="submitBtn" class="btn btn-primary" th:text="#{pdfToImage.submit}"></button>
</form>

</div>
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/templates/convert/pdf-to-pdfa.html
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ <h2 th:text="#{pdfToPDFA.header}"></h2>
<form method="post" enctype="multipart/form-data" th:action="@{pdf-to-pdfa}">
<div th:replace="~{fragments/common :: fileSelector(name='fileInput', multiple=false, accept='application/pdf')}"></div>
<br>
<button type="submit" class="btn btn-primary" th:text="#{pdfToPDFA.submit}"></button>
<button type="submit" id="submitBtn" class="btn btn-primary" th:text="#{pdfToPDFA.submit}"></button>
</form>
<p class="mt-3" th:text="#{pdfToPDFA.credit}"></p>
</div>
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/templates/extract-images.html
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ <h2 th:text="#{extractImages.header}"></h2>
<option value="gif">GIF</option>
</select>
</div>
<button type="submit" class="btn btn-primary" th:text="#{extractImages.submit}"></button>
<button type="submit" id="submitBtn" class="btn btn-primary" th:text="#{extractImages.submit}"></button>
</form>
</div>
</div>
Expand Down
11 changes: 10 additions & 1 deletion src/main/resources/templates/fragments/common.html
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,10 @@
<script>

$('form').submit(function(event) {
var processing = "Processing..."
var submitButtonText = $('#submitBtn').text()

$('#submitBtn').text('Processing...');
console.log("start download code")
var files = $('#fileInput-input')[0].files;
var url = this.action;
Expand Down Expand Up @@ -187,11 +191,16 @@

// Create an error message to display to the user
const message = `${errorMessage}\n\n${stackTrace}`;


$('#submitBtn').text(submitButtonText);

// Display the error message to the user
alert(message);

});

}
$('#submitBtn').text(submitButtonText);
});

async function submitMultiPdfForm(event, url) {
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/templates/fragments/navbar.html
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@
<nav class="navbar navbar-expand-lg navbar-light bg-light">
<div class="container ">

<a class="navbar-brand" href="#" th:href="@{/}" th:text="${@appName}"></a>
<a class="navbar-brand" href="#" th:href="@{/}" th:text="${@navBarText}"></a>

<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarNav" aria-controls="navbarNav" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/templates/home.html
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
<div class="jumbotron jumbotron-fluid" id="jumbotron">
<div class="container">
<h1 class="display-4" th:text="${@appName}"></h1>
<p class="lead" th:text="#{home.desc}"></p>
<p class="lead" th:text="${@homeText != 'null' and @homeText != null and @homeText != ''} ? ${@homeText} : #{home.desc}"></p>
</div>
</div>

Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/templates/merge-pdfs.html
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ <h2 th:text="#{merge.header}"></h2>
<ul id="selectedFiles" class="list-group"></ul>
</div>
<div class="form-group text-center">
<button type="submit" class="btn btn-primary" th:text="#{merge.submit}"></button>
<button type="submit" id="submitBtn" class="btn btn-primary" th:text="#{merge.submit}"></button>
</div>
</form>
<style>
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/templates/ocr-pdf.html
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ <h2 th:text="#{ocr.header}"></h2>
<label class="form-check-label" for="clean-final" th:text="#{ocr.selectText.5}"></label>
</div>
<br>
<button type="submit" class="btn btn-primary" th:text="#{ocr.submit}"></button>
<button type="submit" id="submitBtn" class="btn btn-primary" th:text="#{ocr.submit}"></button>
</form>
<p th:text="#{ocr.credit}"></p>
<p th:text="#{ocr.help}"></p>
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/templates/pdf-organizer.html
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ <h2 th:text="#{pdfOrganiser.header}"></h2>
<label for="pageOrder" th:text="#{pageOrderPrompt}"></label>
<input type="text" class="form-control" id="fileInput" name="pageOrder" placeholder="(e.g. 1,3,2 or 4-8,2,10-12)" required>
</div>
<button type="submit" class="btn btn-primary" th:text="#{pdfOrganiser.submit}"></button>
<button type="submit" id="submitBtn" class="btn btn-primary" th:text="#{pdfOrganiser.submit}"></button>
</form>

</div>
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/templates/remove-pages.html
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ <h2 th:text="#{pageRemover.header}"></h2>
<label for="pagesToDelete" th:text="#{pageRemover.pagesToDelete}"></label>
<input type="text" class="form-control" id="fileInput" name="pagesToDelete" placeholder="(e.g. 1,2,6 or 1-10,15-30)" required>
</div>
<button type="submit" class="btn btn-primary" th:text="#{pageRemover.submit}"></button>
<button type="submit" id="submitBtn" class="btn btn-primary" th:text="#{pageRemover.submit}"></button>
</form>
</div>
</div>
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/templates/rotate-pdf.html
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ <h2 th:text="#{rotate.header}"></h2>
<path d="M8 4.466V.534a.25.25 0 0 0-.41-.192L5.23 2.308a.25.25 0 0 0 0 .384l2.36 1.966A.25.25 0 0 0 8 4.466z" />
</svg>
</button>
<button type="submit" class="btn btn-primary" th:text="#{rotate.submit}"></button>
<button type="submit" id="submitBtn" class="btn btn-primary" th:text="#{rotate.submit}"></button>
<button type="button" class="btn btn-secondary" onclick="rotate(90)">
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-arrow-clockwise" viewBox="0 0 16 16">
<path fill-rule="evenodd" d="M8 3a5 5 0 1 0 4.546 2.914.5.5 0 0 1 .908-.417A6 6 0 1 1 8 2v1z" />
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/templates/security/add-password.html
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ <h2 th:text="#{addPassword.header}"></h2>
</div>
<br />
<div class="form-group text-center">
<button type="submit" class="btn btn-primary" th:text="#{addPassword.submit}"></button>
<button type="submit" id="submitBtn" class="btn btn-primary" th:text="#{addPassword.submit}"></button>
</div>

</form>
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/templates/security/add-watermark.html
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ <h2 th:text="#{watermark.header}"></h2>
<input type="text" id="heightSpacer" name="heightSpacer" class="form-control" value="50" />
</div>
<div class="form-group text-center">
<input type="submit" th:value="#{watermark.submit}" class="btn btn-primary" />
<input type="submit" id="submitBtn" th:value="#{watermark.submit}" class="btn btn-primary" />
</div>
</form>
</div>
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/templates/security/change-metadata.html
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ <h3 th:text="#{changeMetadata.selectText.4}"></h3>
<button type="button" class="btn btn-secondary" id="addMetadataBtn" th:text="#{changeMetadata.selectText.5}"></button>
<br>
<br>
<button class="btn btn-primary" type="submit" th:text="#{changeMetadata.submit}"></button>
<button class="btn btn-primary" type="submit" id="submitBtn" th:text="#{changeMetadata.submit}"></button>
<script>

const deleteAllCheckbox = document.querySelector("#deleteAll");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ <h2 th:text="#{permissions.header}"></h2>
</div>
<br />
<div class="form-group text-center">
<button type="submit" class="btn btn-primary" th:text="#{permissions.submit}"></button>
<button type="submit" id="submitBtn" class="btn btn-primary" th:text="#{permissions.submit}"></button>
</div>

</form>
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/templates/security/remove-password.html
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ <h2 th:text="#{removePassword.header}"></h2>
</div>
<br />
<div class="form-group text-center">
<button type="submit" class="btn btn-primary" th:text="#{removePassword.submit}"></button>
<button type="submit" id="submitBtn" class="btn btn-primary" th:text="#{removePassword.submit}"></button>
</div>
</form>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ <h2 th:text="#{remove-watermark.header}"></h2>
<input type="text" id="watermarkText" name="watermarkText" class="form-control" placeholder="Stirling-PDF" required />
</div>
<div class="form-group text-center">
<input type="submit" th:value="#{remove-watermark.submit}" class="btn btn-primary" />
<input type="submit" id="submitBtn" th:value="#{remove-watermark.submit}" class="btn btn-primary" />
</div>
</form>
</div>
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/templates/split-pdfs.html
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ <h1 th:text="#{split.header}"></h1>
<input type="text" class="form-control" id="pages" name="pages" placeholder="1,3,5-10" required>
</div>
<br>
<button type="submit" class="btn btn-primary" th:text="#{split.submit}"></button>
<button type="submit" id="submitBtn" class="btn btn-primary" th:text="#{split.submit}"></button>
</form>
</div>
</div>
Expand Down

0 comments on commit 22be1a1

Please sign in to comment.