Various fixes
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -33,6 +33,7 @@ pom.xml.tag
|
||||
pom.xml.releaseBackup
|
||||
pom.xml.versionsBackup
|
||||
release.properties
|
||||
.factorypath
|
||||
|
||||
application.yaml
|
||||
build.sh
|
||||
|
||||
4
pom.xml
4
pom.xml
@@ -12,10 +12,10 @@
|
||||
<maven.compiler.target>11</maven.compiler.target>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
|
||||
<quarkus-plugin.version>2.5.1.Final</quarkus-plugin.version>
|
||||
<quarkus-plugin.version>2.5.4.Final</quarkus-plugin.version>
|
||||
<quarkus.platform.artifact-id>quarkus-bom</quarkus.platform.artifact-id>
|
||||
<quarkus.platform.group-id>io.quarkus</quarkus.platform.group-id>
|
||||
<quarkus.platform.version>2.5.1.Final</quarkus.platform.version>
|
||||
<quarkus.platform.version>2.5.4.Final</quarkus.platform.version>
|
||||
<surefire-plugin.version>2.22.1</surefire-plugin.version>
|
||||
</properties>
|
||||
<dependencyManagement>
|
||||
|
||||
@@ -42,8 +42,12 @@ public class AdventAccessService {
|
||||
try {
|
||||
int day = Integer.parseInt(dayString);
|
||||
LocalDateTime now = LocalDateTime.now();
|
||||
if (now.getYear() >= event.year() && now.getMonthValue() >= event.month()
|
||||
&& now.getDayOfMonth() >= day) {
|
||||
if ((now.getYear() > event.year())
|
||||
|| (now.getYear() == event.year()
|
||||
&& now.getMonthValue() > event.month())
|
||||
|| (now.getYear() == event.year()
|
||||
&& now.getMonthValue() == event.month()
|
||||
&& now.getDayOfMonth() >= day)) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
|
||||
@@ -85,10 +85,8 @@ public class FileInfoService {
|
||||
Path requestedThumbPath =
|
||||
path.getParent().resolve(".thumbnails").resolve(requestedFilename + ".jpg");
|
||||
if (Files.exists(requestedThumbPath)) {
|
||||
requestedThumbUrl =
|
||||
rootFolderPath.relativize(requestedThumbPath).toUri().getRawPath();
|
||||
// For some reason, url starts with '/work'
|
||||
requestedThumbUrl = requestedThumbUrl.substring(5);
|
||||
requestedThumbUrl = Paths.get("/").resolve(
|
||||
rootFolderPath.relativize(requestedThumbPath)).toUri().getRawPath();
|
||||
}
|
||||
} catch (Exception ignored) {
|
||||
}
|
||||
@@ -97,7 +95,7 @@ public class FileInfoService {
|
||||
requestedFilename = "/";
|
||||
}
|
||||
FolderInfo folderInfo = new FolderInfo(requestedFilename, requestedThumbUrl,
|
||||
"/file" + requestedUri, "/view" + requestedUri + "/1");
|
||||
"/file" + requestedUri + "/", "/view" + requestedUri + "/1");
|
||||
try {
|
||||
Files.list(path).forEach(p -> {
|
||||
String fileName = p.getFileName().toString();
|
||||
@@ -122,7 +120,7 @@ public class FileInfoService {
|
||||
FileInfoBase contentInfo;
|
||||
if (Files.isDirectory(p)) {
|
||||
contentInfo = new FolderInfo(fileName,
|
||||
"/file" + requestedUri + "/" + fileUri);
|
||||
"/file" + requestedUri + "/" + fileUri + "/");
|
||||
} else {
|
||||
contentInfo =
|
||||
new FileInfo(fileName, "/file" + requestedUri + "/" + fileUri);
|
||||
|
||||
@@ -12,8 +12,8 @@ import javax.enterprise.context.ApplicationScoped;
|
||||
import javax.inject.Inject;
|
||||
import javax.ws.rs.core.Response;
|
||||
import javax.ws.rs.core.Response.ResponseBuilder;
|
||||
import io.quarkus.qute.Template;
|
||||
import io.quarkus.qute.Location;
|
||||
import io.quarkus.qute.Template;
|
||||
import sh.rhiobet.lalafin.api.configuration.FileApiConfiguration;
|
||||
import sh.rhiobet.lalafin.api.model.FileInfo;
|
||||
import sh.rhiobet.lalafin.api.model.FileInfoBase;
|
||||
@@ -44,24 +44,24 @@ public class FileServeService {
|
||||
Path path = Paths.get(fileApiConfiguration.directory(),
|
||||
URLDecoder.decode(fileInfo.directUrl, StandardCharsets.UTF_8));
|
||||
FileChannel channel = FileChannel.open(path);
|
||||
InputStream is = Channels.newInputStream(channel);
|
||||
ResponseBuilder response;
|
||||
long fileSize = channel.size();
|
||||
long rangeStart = 0;
|
||||
if (range != null) {
|
||||
rangeStart = Long.parseLong(range.substring(6, range.length() - 1));
|
||||
long rangeStart = Long.parseLong(range.substring(6, range.length() - 1));
|
||||
InputStream is = Channels.newInputStream(channel);
|
||||
is.skip(rangeStart);
|
||||
}
|
||||
ResponseBuilder response = Response.ok(path.toFile());
|
||||
response = Response.ok(path.toFile());
|
||||
response.entity(is);
|
||||
response.header("Accept-Ranges", "bytes");
|
||||
response.header("Content-Length", fileSize);
|
||||
response.header("Content-Disposition",
|
||||
"inline; filename=\"" + fileInfo.filename + "\"");
|
||||
if (rangeStart > 0) {
|
||||
response.header("Content-Length", Long.toString(fileSize - rangeStart));
|
||||
response.status(Response.Status.PARTIAL_CONTENT);
|
||||
response.header("Content-Range",
|
||||
"bytes " + rangeStart + "-" + fileSize + "/" + fileSize);
|
||||
"bytes " + rangeStart + "-" + (fileSize - 1) + "/" + fileSize);
|
||||
} else {
|
||||
response = Response.ok(path.toFile());
|
||||
response.header("Content-Length", Long.toString(fileSize));
|
||||
}
|
||||
response.header("Content-Disposition",
|
||||
"inline; filename=\"" + fileInfo.filename + "\"");
|
||||
response.header("Content-Type", FileHelper.getMimeType(fileInfo.filename));
|
||||
if (path.toString().contains("/.thumbnails/")) {
|
||||
response.header("Cache-Control", "max-age=604800");
|
||||
|
||||
@@ -9,9 +9,9 @@
|
||||
<body>
|
||||
<h1>{info.filename}</h1>
|
||||
{#if !info.filename is '/'}
|
||||
<a href="{info.directUrl}/..">back</a>
|
||||
<a href="{info.directUrl}..">back</a>
|
||||
<span style="float:right;">
|
||||
<a href="{info.viewUrl}/">viewer</a>
|
||||
<a href="{info.viewUrl}">viewer</a>
|
||||
</span>
|
||||
{/if}
|
||||
<hr />
|
||||
|
||||
@@ -16,9 +16,9 @@
|
||||
</table>
|
||||
<hr />
|
||||
{#if currpage < totpage}<a href="{nexturi}">{/if}
|
||||
{#if image != null}
|
||||
{#if image??}
|
||||
<img style="position: absolute; left: 50%; transform: translate(-50%, 0);" src="{image}" />
|
||||
{#else if video != null}
|
||||
{#else if video??}
|
||||
<video src="{video}" controls style="width: 100%"></video>
|
||||
{/if}
|
||||
{#if currpage < totpage}</a>{/if}
|
||||
|
||||
Reference in New Issue
Block a user