mirror of
				https://github.com/Frooodle/Stirling-PDF.git
				synced 2025-11-01 01:21:18 +01:00 
			
		
		
		
	
							parent
							
								
									30444fc9bb
								
							
						
					
					
						commit
						8c9d6f7b66
					
				@ -201,7 +201,7 @@ Stirling PDF allows easy customization of the app.
 | 
				
			|||||||
Includes things like
 | 
					Includes things like
 | 
				
			||||||
 | 
					
 | 
				
			||||||
- Custom application name
 | 
					- Custom application name
 | 
				
			||||||
- Custom slogans, icons, images css etc (via file overrides) (Does not currently support html)
 | 
					- Custom slogans, icons, HTML, images CSS etc (via file overrides) 
 | 
				
			||||||
 | 
					
 | 
				
			||||||
There are two options for this, either using the generated settings file ``settings.yml``
 | 
					There are two options for this, either using the generated settings file ``settings.yml``
 | 
				
			||||||
This file is located in the ``/configs`` directory and follows standard YAML formatting
 | 
					This file is located in the ``/configs`` directory and follows standard YAML formatting
 | 
				
			||||||
@ -229,6 +229,7 @@ system:
 | 
				
			|||||||
  customStaticFilePath: '/customFiles/static/' # Directory path for custom static files
 | 
					  customStaticFilePath: '/customFiles/static/' # Directory path for custom static files
 | 
				
			||||||
  showUpdate: true # see when a new update is available
 | 
					  showUpdate: true # see when a new update is available
 | 
				
			||||||
  showUpdateOnlyAdmin: false # Only admins can see when a new update is available, depending on showUpdate it must be set to 'true'
 | 
					  showUpdateOnlyAdmin: false # Only admins can see when a new update is available, depending on showUpdate it must be set to 'true'
 | 
				
			||||||
 | 
					  customHTMLFiles: false # enable to have files placed in /customFiles/templates override the existing template html files
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#ui:
 | 
					#ui:
 | 
				
			||||||
#  appName: exampleAppName # Application's visible name
 | 
					#  appName: exampleAppName # Application's visible name
 | 
				
			||||||
 | 
				
			|||||||
@ -12,7 +12,7 @@ plugins {
 | 
				
			|||||||
import com.github.jk1.license.render.*
 | 
					import com.github.jk1.license.render.*
 | 
				
			||||||
 | 
					
 | 
				
			||||||
group = 'stirling.software'
 | 
					group = 'stirling.software'
 | 
				
			||||||
version = '0.23.0'
 | 
					version = '0.23.1'
 | 
				
			||||||
sourceCompatibility = '17'
 | 
					sourceCompatibility = '17'
 | 
				
			||||||
 | 
					
 | 
				
			||||||
repositories {
 | 
					repositories {
 | 
				
			||||||
 | 
				
			|||||||
@ -7,18 +7,34 @@ import java.util.Properties;
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
import org.springframework.beans.factory.annotation.Autowired;
 | 
					import org.springframework.beans.factory.annotation.Autowired;
 | 
				
			||||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingClass;
 | 
					import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingClass;
 | 
				
			||||||
 | 
					import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
 | 
				
			||||||
import org.springframework.context.annotation.Bean;
 | 
					import org.springframework.context.annotation.Bean;
 | 
				
			||||||
import org.springframework.context.annotation.Configuration;
 | 
					import org.springframework.context.annotation.Configuration;
 | 
				
			||||||
 | 
					import org.springframework.context.annotation.Lazy;
 | 
				
			||||||
import org.springframework.core.io.ClassPathResource;
 | 
					import org.springframework.core.io.ClassPathResource;
 | 
				
			||||||
import org.springframework.core.io.Resource;
 | 
					import org.springframework.core.io.Resource;
 | 
				
			||||||
 | 
					import org.springframework.core.io.ResourceLoader;
 | 
				
			||||||
 | 
					import org.thymeleaf.spring6.SpringTemplateEngine;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import stirling.software.SPDF.model.ApplicationProperties;
 | 
					import stirling.software.SPDF.model.ApplicationProperties;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@Configuration
 | 
					@Configuration
 | 
				
			||||||
 | 
					@Lazy
 | 
				
			||||||
public class AppConfig {
 | 
					public class AppConfig {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    @Autowired ApplicationProperties applicationProperties;
 | 
					    @Autowired ApplicationProperties applicationProperties;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Bean
 | 
				
			||||||
 | 
					    @ConditionalOnProperty(
 | 
				
			||||||
 | 
					            name = "system.customHTMLFiles",
 | 
				
			||||||
 | 
					            havingValue = "true",
 | 
				
			||||||
 | 
					            matchIfMissing = false)
 | 
				
			||||||
 | 
					    public SpringTemplateEngine templateEngine(ResourceLoader resourceLoader) {
 | 
				
			||||||
 | 
					        SpringTemplateEngine templateEngine = new SpringTemplateEngine();
 | 
				
			||||||
 | 
					        templateEngine.addTemplateResolver(new FileFallbackTemplateResolver(resourceLoader));
 | 
				
			||||||
 | 
					        return templateEngine;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    @Bean(name = "loginEnabled")
 | 
					    @Bean(name = "loginEnabled")
 | 
				
			||||||
    public boolean loginEnabled() {
 | 
					    public boolean loginEnabled() {
 | 
				
			||||||
        return applicationProperties.getSecurity().getEnableLogin();
 | 
					        return applicationProperties.getSecurity().getEnableLogin();
 | 
				
			||||||
 | 
				
			|||||||
@ -0,0 +1,48 @@
 | 
				
			|||||||
 | 
					package stirling.software.SPDF.config;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import java.io.IOException;
 | 
				
			||||||
 | 
					import java.util.Map;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import org.springframework.core.io.Resource;
 | 
				
			||||||
 | 
					import org.springframework.core.io.ResourceLoader;
 | 
				
			||||||
 | 
					import org.thymeleaf.IEngineConfiguration;
 | 
				
			||||||
 | 
					import org.thymeleaf.templateresolver.AbstractConfigurableTemplateResolver;
 | 
				
			||||||
 | 
					import org.thymeleaf.templateresource.ClassLoaderTemplateResource;
 | 
				
			||||||
 | 
					import org.thymeleaf.templateresource.FileTemplateResource;
 | 
				
			||||||
 | 
					import org.thymeleaf.templateresource.ITemplateResource;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					public class FileFallbackTemplateResolver extends AbstractConfigurableTemplateResolver {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    private final ResourceLoader resourceLoader;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public FileFallbackTemplateResolver(ResourceLoader resourceLoader) {
 | 
				
			||||||
 | 
					        super();
 | 
				
			||||||
 | 
					        this.resourceLoader = resourceLoader;
 | 
				
			||||||
 | 
					        setSuffix(".html");
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    // Note this does not work in local IDE, Prod jar only.
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    protected ITemplateResource computeTemplateResource(
 | 
				
			||||||
 | 
					            IEngineConfiguration configuration,
 | 
				
			||||||
 | 
					            String ownerTemplate,
 | 
				
			||||||
 | 
					            String template,
 | 
				
			||||||
 | 
					            String resourceName,
 | 
				
			||||||
 | 
					            String characterEncoding,
 | 
				
			||||||
 | 
					            Map<String, Object> templateResolutionAttributes) {
 | 
				
			||||||
 | 
					        Resource resource =
 | 
				
			||||||
 | 
					                resourceLoader.getResource("file:./customFiles/templates/" + resourceName);
 | 
				
			||||||
 | 
					        try {
 | 
				
			||||||
 | 
					            if (resource.exists() && resource.isReadable()) {
 | 
				
			||||||
 | 
					                return new FileTemplateResource(resource.getFile().getPath(), characterEncoding);
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        } catch (IOException e) {
 | 
				
			||||||
 | 
					            
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        return new ClassLoaderTemplateResource(
 | 
				
			||||||
 | 
					                Thread.currentThread().getContextClassLoader(),
 | 
				
			||||||
 | 
					                "classpath:/templates/" + resourceName,
 | 
				
			||||||
 | 
					                characterEncoding);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
@ -212,6 +212,15 @@ public class ApplicationProperties {
 | 
				
			|||||||
        private Integer maxFileSize;
 | 
					        private Integer maxFileSize;
 | 
				
			||||||
        private boolean showUpdate;
 | 
					        private boolean showUpdate;
 | 
				
			||||||
        private Boolean showUpdateOnlyAdmin;
 | 
					        private Boolean showUpdateOnlyAdmin;
 | 
				
			||||||
 | 
					        private boolean customHTMLFiles;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        public boolean isCustomHTMLFiles() {
 | 
				
			||||||
 | 
					            return customHTMLFiles;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        public void setCustomHTMLFiles(boolean customHTMLFiles) {
 | 
				
			||||||
 | 
					            this.customHTMLFiles = customHTMLFiles;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        public boolean getShowUpdateOnlyAdmin() {
 | 
					        public boolean getShowUpdateOnlyAdmin() {
 | 
				
			||||||
            return showUpdateOnlyAdmin;
 | 
					            return showUpdateOnlyAdmin;
 | 
				
			||||||
 | 
				
			|||||||
@ -14,7 +14,8 @@ system:
 | 
				
			|||||||
  enableAlphaFunctionality: false # Set to enable functionality which might need more testing before it fully goes live (This feature might make no changes)
 | 
					  enableAlphaFunctionality: false # Set to enable functionality which might need more testing before it fully goes live (This feature might make no changes)
 | 
				
			||||||
  showUpdate: true # see when a new update is available
 | 
					  showUpdate: true # see when a new update is available
 | 
				
			||||||
  showUpdateOnlyAdmin: false # Only admins can see when a new update is available, depending on showUpdate it must be set to 'true'
 | 
					  showUpdateOnlyAdmin: false # Only admins can see when a new update is available, depending on showUpdate it must be set to 'true'
 | 
				
			||||||
 | 
					  customHTMLFiles: false # Enable to have files placed in /customFiles/templates override the existing template html files
 | 
				
			||||||
 | 
					  
 | 
				
			||||||
#ui:
 | 
					#ui:
 | 
				
			||||||
#  appName: exampleAppName # Application's visible name
 | 
					#  appName: exampleAppName # Application's visible name
 | 
				
			||||||
#  homeDescription: I am a description # Short description or tagline shown on homepage.
 | 
					#  homeDescription: I am a description # Short description or tagline shown on homepage.
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
		Reference in New Issue
	
	Block a user