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