Skip to content

Commit

Permalink
Merge pull request #997 from Difegue/dev
Browse files Browse the repository at this point in the history
0.9.1 this time for real i swear
  • Loading branch information
Difegue authored Jun 27, 2024
2 parents 7747dbc + f752406 commit fbd98f4
Show file tree
Hide file tree
Showing 17 changed files with 88 additions and 46 deletions.
14 changes: 8 additions & 6 deletions .github/workflows/push-continous-delivery.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ jobs:
steps:
- uses: actions/checkout@master
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- uses: actions/cache@v3
uses: docker/setup-buildx-action@v3
- uses: actions/cache@v4
with:
path: /tmp/buildxcache
key: ${{ runner.os }}-docker-buildx-${{ github.sha }}
Expand All @@ -39,10 +39,10 @@ jobs:
steps:
- uses: actions/checkout@master
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- uses: actions/cache@v3
uses: docker/setup-buildx-action@v3
- uses: actions/cache@v4
with:
path: /tmp/buildxcache
key: ${{ runner.os }}-docker-buildx-${{ github.sha }}
Expand Down Expand Up @@ -121,6 +121,8 @@ jobs:
$ErrorActionPreference = 'Continue'
git submodule init
git submodule update
choco uninstall wixtoolset
choco install wixtoolset --version 3.14.0 --allow-downgrade --force
choco install nuget.commandline
./tools/build/windows/build.ps1
- name: Upload Installer
Expand Down
12 changes: 7 additions & 5 deletions .github/workflows/release-delivery.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
- uses: actions/checkout@master
- name: Docker Build and export
run: |
docker build -t difegue/lanraragi -f ./tools/build/docker/Dockerfile --build-arg INSTALL_PARAMETER=-w .
docker build -t difegue/lanraragi -f ./tools/build/docker/Dockerfile .
docker create --name rootfs difegue/lanraragi
docker export --output=package.tar rootfs
- name: Upload rootfs
Expand Down Expand Up @@ -41,13 +41,15 @@ jobs:
$ErrorActionPreference = 'Continue'
git submodule init
git submodule update
choco uninstall wixtoolset
choco install wixtoolset --version 3.14.0 --allow-downgrade --force
choco install nuget.commandline
./tools/build/windows/build.ps1
- name: Upload Installer
uses: actions/upload-artifact@v1
with:
name: wsl
path: ./tools/build/windows/Karen/Setup/bin/LANraragi.msi
path: ./tools/build/windows/Karen/LRR_WSL2.msi
uploadWSLRelease:
name: Add Windows Installer to release
needs: buildReleaseWSL
Expand Down Expand Up @@ -75,10 +77,10 @@ jobs:
steps:
- uses: actions/checkout@master
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- uses: actions/cache@v3
uses: docker/setup-buildx-action@v3
- uses: actions/cache@v4
with:
path: /tmp/buildxcache
key: ${{ runner.os }}-docker-buildx-${{ github.sha }}
Expand Down
14 changes: 7 additions & 7 deletions lib/LANraragi/Model/Stats.pm
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@ use Redis;
use File::Find;
use Mojo::JSON qw(encode_json);

use LANraragi::Utils::Generic qw(is_archive);
use LANraragi::Utils::String qw(trim trim_CRLF trim_url);
use LANraragi::Utils::Generic qw(is_archive);
use LANraragi::Utils::String qw(trim trim_CRLF trim_url);
use LANraragi::Utils::Database qw(redis_decode redis_encode);
use LANraragi::Utils::Logging qw(get_logger);
use LANraragi::Utils::Logging qw(get_logger);

sub get_archive_count {
my $redis = LANraragi::Model::Config->get_redis_search;
my $redis = LANraragi::Model::Config->get_redis_search;
return $redis->zcard("LRR_TITLES") + 0; # Total number of archives (as int)
}

Expand Down Expand Up @@ -74,7 +74,7 @@ sub build_stat_hashes {
$t = trim_CRLF($t);

# The following are basic and therefore don't count as "tagged"
$has_tags = 1 unless $t =~ /(artist|parody|series|language|event|group|date_added|timestamp):.*/;
$has_tags = 1 unless $t =~ /(artist|parody|series|language|event|group|date_added|timestamp|source):.*/;

# If the tag is a source: tag, add it to the URL index
if ( $t =~ /source:(.*)/i ) {
Expand Down Expand Up @@ -187,14 +187,14 @@ sub compute_content_size {

$redis_db->multi;
foreach my $id (@keys) {
LANraragi::Utils::Database::get_arcsize($redis_db, $id);
LANraragi::Utils::Database::get_arcsize( $redis_db, $id );
}
my @result = $redis_db->exec;
$redis_db->quit;

my $size = 0;
foreach my $row (@result) {
if (defined($row)) {
if ( defined($row) ) {
$size = $size + $row;
}
}
Expand Down
6 changes: 4 additions & 2 deletions lib/LANraragi/Model/Upload.pm
Original file line number Diff line number Diff line change
Expand Up @@ -110,11 +110,13 @@ sub handle_incoming_file {

# Move the file to the content folder.
# Move to a .upload first in case copy to the content folder takes a while...
move( $tempfile, $output_file . ".upload" );
move( $tempfile, $output_file . ".upload" ) or return ( 0, $id, $name, "The file couldn't be moved to your content folder: $!" );

# Then rename inside the content folder itself to proc Shinobu.
move( $output_file . ".upload", $output_file );
move( $output_file . ".upload", $output_file ) or return ( 0, $id, $name, "The file couldn't be renamed in your content folder: $!" );

# If the move didn't signal an error, but still doesn't exist, something is quite spooky indeed!
# Really funky permissions that prevents viewing folder contents?
unless ( -e $output_file ) {
return ( 0, $id, $name, "The file couldn't be moved to your content folder!" );
}
Expand Down
8 changes: 4 additions & 4 deletions lib/LANraragi/Utils/Database.pm
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ sub add_archive_to_redis ( $id, $file, $redis ) {
$logger->debug("File Name: $name");
$logger->debug("Filesystem Path: $file");

$redis->hset( $id, "name", redis_encode($name) );
$redis->hset( $id, "tags", "" );
$redis->hset( $id, "name", redis_encode($name) );
$redis->hset( $id, "tags", "" );
$redis->hset( $id, "summary", "" );

if ( defined($file) && -e $file ) {
Expand Down Expand Up @@ -376,7 +376,7 @@ sub set_tags ( $id, $newtags, $append = 0 ) {
invalidate_cache();
}

sub set_summary ($id, $summary) {
sub set_summary ( $id, $summary ) {

my $redis = LANraragi::Model::Config->get_redis;
$redis->hset( $id, "summary", redis_encode($summary) );
Expand Down Expand Up @@ -432,7 +432,7 @@ sub update_indexes ( $id, $oldtags, $newtags ) {
foreach my $tag (@newtags) {

# The following are basic and therefore don't count as "tagged"
$has_tags = 1 unless $tag =~ /(artist|parody|series|language|event|group|date_added|timestamp):.*/;
$has_tags = 1 unless $tag =~ /(artist|parody|series|language|event|group|date_added|timestamp|source):.*/;

# If the tag is a source: tag, add it to the URL index
if ( $tag =~ /source:(.*)/i ) {
Expand Down
8 changes: 8 additions & 0 deletions public/js/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -317,6 +317,14 @@ LRR.getImgSize = function (target) {
return imgSize;
};

LRR.getImgSizeAsync = function (target) {
return $.ajax({
url: target,
cache: true,
type: "HEAD",
});
};

/**
* Show a generic toast with a given header and message.
* This is a compatibility layer to migrate jquery-toast-plugin to react-toastify.
Expand Down
18 changes: 10 additions & 8 deletions public/js/reader.js
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ Reader.initializeAll = function () {
$("#tagContainer").append(LRR.buildTagsDiv(Reader.tags));

if (data.summary) {
$("#tagContainer").append(`<div class="archive-summary"/>`);
$("#tagContainer").append("<div class=\"archive-summary\"/>");
$(".archive-summary").text(data.summary);
}

Expand Down Expand Up @@ -551,6 +551,12 @@ Reader.loadImage = function (index) {
const img = new Image();
img.src = src;
Reader.preloadedImg[src] = img;
if (!Reader.preloadedSizes[index]) {
LRR.getImgSizeAsync(src).done((data, textStatus, request) => {
const size = parseInt(request.getResponseHeader("Content-Length") / 1024, 10);
Reader.preloadedSizes[index] = size;
});
}
}

return Reader.preloadedImg[src];
Expand Down Expand Up @@ -724,22 +730,18 @@ Reader.initializeArchiveOverlay = function () {

// Queue a single minion job for thumbnails and check on its progress regularly
const thumbProgress = function (notes) {

if (notes.progress === undefined) { return; }
for (let index = 0; index < notes.progress; ++index) {

const page = index + 1;
// If the spinner is still visible, update the thumbnail
if ($(`#${index}_spinner`).attr("loaded") !== "true") {

// Set image source to the thumbnail
const thumbnailUrl = `./api/archives/${Reader.id}/thumbnail?page=${page}&cachebust=${Date.now()}`;
$(`#${index}_thumb`).attr("src", thumbnailUrl);
$(`#${index}_spinner`).attr("loaded", true);
$(`#${index}_spinner`).hide();
}
}

};

fetch(`/api/archives/${Reader.id}/files/thumbnails`, { method: "POST" })
Expand All @@ -749,14 +751,14 @@ Reader.initializeArchiveOverlay = function () {
$(".ttspinner").hide();
return;
}
if (response.status === 202) {
// Check status and update progress
if (response.status === 202) {
// Check status and update progress
response.json().then((data) => Server.checkJobStatus(
data.job,
false,
(data) => thumbProgress(data.notes), // call progress callback one last time to ensure all thumbs are loaded
() => LRR.showErrorToast("The page thumbnailing job didn't conclude properly. Your archive might be corrupted."),
thumbProgress
thumbProgress,
));
}
});
Expand Down
2 changes: 0 additions & 2 deletions tests/mocks.pl
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,13 @@ sub setup_redis_mock {
},
"SET_1589141306": {
"archives": "[\\\"e69e43e1355267f7d32a4f9b7f2fe108d2401ebf\\\",\\\"e69e43e1355267f7d32a4f9b7f2fe108d2401ebg\\\"]",
"last_used": "1589141306",
"name": "Segata Sanshiro",
"pinned": "1",
"search": ""
},
"SET_1589138380":{
"archives": "[]",
"id": "SET_1589138380",
"last_used": "1589138380",
"name": "AMERICA ONRY",
"pinned": "0",
"search": "American"
Expand Down
1 change: 0 additions & 1 deletion tools/Documentation/api-documentation/archive-api.md
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,6 @@ ID of the Archive to process.
"7f03b8b1f337e1e42b2c2890533c0de7479d41ca"
],
"id": "SET_1613080290",
"last_used": "1614298062",
"name": "My great category",
"pinned": "0",
"search": ""
Expand Down
4 changes: 0 additions & 4 deletions tools/Documentation/api-documentation/category-api.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,13 @@ Get all the categories saved on the server.
{
"archives": [],
"id": "SET_1589227137",
"last_used": "1589487499",
"name": "doujinshi 💦💦💦",
"pinned": "1",
"search": "doujinshi"
},
{
"archives": [],
"id": "SET_1589291510",
"last_used": "1589487501",
"name": "All archives by uo denim",
"pinned": "0",
"search": "artist:uo denim"
Expand All @@ -33,7 +31,6 @@ Get all the categories saved on the server.
"32f0edeb5d5b3cf71a02b39279a69d0a903e4aed"
],
"id": "SET_1589493021",
"last_used": "1589493776",
"name": "The very best",
"pinned": "0",
"search": ""
Expand All @@ -57,7 +54,6 @@ ID of the Category desired.
{
"archives": [],
"id": "SET_1613080290",
"last_used": "1613080930",
"name": "My great category",
"pinned": "0",
"search": ""
Expand Down
18 changes: 18 additions & 0 deletions tools/Documentation/installing-lanraragi/docker.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,24 @@ difegue/lanraragi
You can tell Docker to auto-restart the LRR container on boot by adding the `--restart always` flag to this command.
{% endhint %}

{% hint style="info" %}
Alternatively, if you prefer a `docker-compose.yml` file, use:
```yaml
---
services:
lanraragi:
image: difegue/lanraragi
container_name: lanraragi
ports:
- "3000:3000"
volumes:
- [YOUR_CONTENT_DIRECTORY]:/home/koyomi/lanraragi/content
- [YOUR_THUMBNAIL_DIRECTORY]:/home/koyomi/lanraragi/content/thumb
- [YOUR_DATABASE_DIRECTORY]:/home/koyomi/lanraragi/database
restart: unless-stopped
```
{% endhint %}
The content directory you have to specify in the command above will contain archives you either upload through the software or directly drop in, alongside generated thumbnails.
The database directory houses the LANraragi database(As database.rdb), allowing you to hotswap containers without losing any data.
Expand Down
1 change: 1 addition & 0 deletions tools/build/docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -76,4 +76,5 @@ COPY /tools/build/docker/s6/cont-init.d/01-lrr-setup /etc/s6-overlay/s6-rc.d/ini

# Persistent volumes
VOLUME [ "/home/koyomi/lanraragi/content" ]
VOLUME [ "/home/koyomi/lanraragi/content/thumb" ]
VOLUME [ "/home/koyomi/lanraragi/database"]
1 change: 1 addition & 0 deletions tools/build/docker/Dockerfile-legacy
Original file line number Diff line number Diff line change
Expand Up @@ -74,4 +74,5 @@ COPY /tools/build/docker/s6/legacy-services.d/ /etc/services.d/

# Persistent volumes
VOLUME [ "/home/koyomi/lanraragi/content" ]
VOLUME [ "/home/koyomi/lanraragi/content/thumb" ]
VOLUME [ "/home/koyomi/lanraragi/database"]
6 changes: 6 additions & 0 deletions tools/build/docker/install-everything.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#!/bin/sh

set -e

usage() { echo "Usage: $0 [-d (devmode) -w (wsl cpan packages)]" 1>&2; exit 1; }

DEV=0
Expand Down Expand Up @@ -68,7 +70,11 @@ fi

#Install the LRR dependencies proper
cd tools && cpanm --notest --installdeps . -M https://cpan.metacpan.org && cd ..
if [ $WSL -eq 1 ]; then
npm run lanraragi-installer install-full legacy
else
npm run lanraragi-installer install-full
fi

if [ $DEV -eq 0 ]; then
#Cleanup to lighten the image
Expand Down
2 changes: 1 addition & 1 deletion tools/build/windows/Karen
9 changes: 7 additions & 2 deletions tools/build/windows/build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,16 @@ nuget restore
msbuild /p:Configuration=Release

Get-FileHash .\Setup\bin\LANraragi.msi | Format-List

mv .\Setup\bin\LANraragi.msi .\LRR_WSL2.msi

# Do it again for legacy image
# Do it again for legacy image if it exists
cd ..\..\..\..
if (Test-Path .\package-legacy\package.tar) {
echo "WSL1 package found, building legacy version..."
} else {
echo "No WSL1 package found, skipping legacy build..."
exit 0
}
mv .\package-legacy\package.tar .\tools\build\windows\Karen\External\package.tar
cd .\tools\build\windows\Karen
msbuild /p:Configuration=Release /p:DefineConstants=WSL1_LEGACY
Expand Down
Loading

0 comments on commit fbd98f4

Please sign in to comment.