-
Notifications
You must be signed in to change notification settings - Fork 59
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
Issue 2912: Support folder browsing for static resources #2917
Issue 2912: Support folder browsing for static resources #2917
Conversation
api/build.gradle
Outdated
@@ -249,6 +249,9 @@ dependencies { | |||
compile('io.reflectoring.diffparser:diffparser:1.4') | |||
|
|||
compile 'dnsjava:dnsjava:3.4.3' | |||
|
|||
//Template engine | |||
compile group: 'org.freemarker', name: 'freemarker', version: '2.3.23' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you please try to use Velocity
- we already have in the dependencies, so I'd prefer not to add one more template manager here.
|
||
@Service | ||
@RequiredArgsConstructor | ||
public class StaticResourcesService { | ||
|
||
private static final String DELIMITER = "/"; | ||
private static final String TEMPLATE = "folder.ftlh"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you please move the settings (template folder, template name) to SystemPreferences
?
@@ -46,7 +68,54 @@ public DataStorageStreamingContent getContent(final String path) { | |||
Assert.isTrue(StringUtils.isNotBlank(filePath), | |||
messageHelper.getMessage(MessageConstants.ERROR_STATIC_RESOURCES_INVALID_PATH)); | |||
final AbstractDataStorage storage = dataStorageManager.loadByNameOrId(bucketName); | |||
if (Files.isDirectory(Paths.get(path))) { | |||
final List<AbstractDataStorageItem> items = dataStorageManager.getDataStorageItems(storage.getId(), | |||
path, false, null, null).getResults(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fix path
-> filePath
final String templateName, | ||
final String staticResourcesPrefix) throws IOException{ | ||
final VelocityEngine engine = new VelocityEngine(); | ||
engine.setProperty(RuntimeConstants.FILE_RESOURCE_LOADER_PATH, templatePath); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
With this configuration, classpath template is not loaded. We need to support both classpath and filesystem resources. Maybe it is easier to use an approach from SMTPNotificationManager
where template is passed as a string to Velocity.evaluate
method? In this case we can read template using ResourceUtils
class or similar. In this case we can leave only one preference STATIC_RESOURCES_FOLDER_TEMPLATE_PATH
with full path to template, e.g. classpath/views/folder.vm
or /opt/api/templates/folder.html
@@ -46,7 +68,54 @@ public DataStorageStreamingContent getContent(final String path) { | |||
Assert.isTrue(StringUtils.isNotBlank(filePath), | |||
messageHelper.getMessage(MessageConstants.ERROR_STATIC_RESOURCES_INVALID_PATH)); | |||
final AbstractDataStorage storage = dataStorageManager.loadByNameOrId(bucketName); | |||
if (Files.isDirectory(Paths.get(path))) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This check won't work for cloud resource, I will add a new method to check cloud object type
…ty template loading
Background
Support folder browsing for static resources #2912