Skip to content

Commit

Permalink
LANraragi Release 0.8.7
Browse files Browse the repository at this point in the history
Merge pull request #703 from Difegue/dev
  • Loading branch information
Difegue authored Oct 14, 2022
2 parents 3e25a66 + f80b3f6 commit fe84fa2
Show file tree
Hide file tree
Showing 43 changed files with 141 additions and 60 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/push-continous-delivery.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ jobs:
steps:
- uses: actions/checkout@master
- name: Set up QEMU
uses: docker/setup-qemu-action@v1
uses: docker/setup-qemu-action@v2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
- uses: actions/cache@v2
uses: docker/setup-buildx-action@v2
- uses: actions/cache@v3
with:
path: /tmp/buildxcache
key: ${{ runner.os }}-docker-buildx-${{ github.sha }}
Expand Down
9 changes: 5 additions & 4 deletions .github/workflows/release-delivery.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,15 @@ jobs:
- uses: actions/checkout@master
- name: Docker Build and export
run: |
docker build -t difegue/lanraragi -f ./tools/build/docker/Dockerfile .
docker build -t difegue/lanraragi -f ./tools/build/docker/Dockerfile-legacy .
docker create --name rootfs difegue/lanraragi
docker export --output=package.tar rootfs
- name: Upload rootfs
uses: actions/upload-artifact@v1
with:
name: package
path: package.tar

buildReleaseWSL:
name: Build Windows Installer
needs: exportDockerRootFS
Expand Down Expand Up @@ -74,10 +75,10 @@ jobs:
steps:
- uses: actions/checkout@master
- name: Set up QEMU
uses: docker/setup-qemu-action@v1
uses: docker/setup-qemu-action@v2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
- uses: actions/cache@v2
uses: docker/setup-buildx-action@v2
- uses: actions/cache@v3
with:
path: /tmp/buildxcache
key: ${{ runner.os }}-docker-buildx-${{ github.sha }}
Expand Down
34 changes: 27 additions & 7 deletions lib/LANraragi/Controller/Batch.pm
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,18 @@ sub index {
#Build plugin listing
my @pluginlist = get_plugins("metadata");

# Get static category list
my @categories = LANraragi::Model::Category->get_static_category_list;

$self->render(
template => "batch",
plugins => \@pluginlist,
title => $self->LRR_CONF->get_htmltitle,
descstr => $self->LRR_DESC,
csshead => generate_themes_header($self),
tagrules => restore_CRLF( $self->LRR_CONF->get_tagrules ),
version => $self->LRR_VERSION
template => "batch",
plugins => \@pluginlist,
title => $self->LRR_CONF->get_htmltitle,
descstr => $self->LRR_DESC,
csshead => generate_themes_header($self),
tagrules => restore_CRLF( $self->LRR_CONF->get_tagrules ),
categories => \@categories,
version => $self->LRR_VERSION
);
}

Expand Down Expand Up @@ -96,6 +100,22 @@ sub socket {
return;
}

if ( $operation eq "addcat" ) {
my $catid = $command->{"category"};
my ( $catsucc, $caterr ) = LANraragi::Model::Category::add_to_category( $catid, $id );

$client->send(
{ json => {
id => $id,
category => $catid,
success => $catsucc,
message => $caterr
}
}
);
return;
}

if ( $operation eq "tagrules" ) {

$logger->debug("Applying tag rules to $id...");
Expand Down
3 changes: 1 addition & 2 deletions lib/LANraragi/Controller/Index.pm
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,7 @@ sub index {
my $userlogged = $self->LRR_CONF->enable_pass == 0 || $self->session('is_logged');

# Get static category list to populate the right-click menu
my @categories = LANraragi::Model::Category->get_category_list;
@categories = grep { %$_{"search"} eq "" } @categories;
my @categories = LANraragi::Model::Category->get_static_category_list;

$self->render(
template => "index",
Expand Down
7 changes: 2 additions & 5 deletions lib/LANraragi/Controller/Reader.pm
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,8 @@ sub index {

if ( $self->req->param('id') ) {

# Allow adding to category
my @categories = LANraragi::Model::Category->get_category_list;

# But only to static categories
@categories = grep { %$_{"search"} eq "" } @categories;
# Allow adding to static categories
my @categories = LANraragi::Model::Category->get_static_category_list;

# Get query string from referrer URL, if there's one
my $referrer = $self->req->headers->referrer;
Expand Down
5 changes: 1 addition & 4 deletions lib/LANraragi/Controller/Upload.pm
Original file line number Diff line number Diff line change
Expand Up @@ -84,10 +84,7 @@ sub index {
my $self = shift;

# Allow adding to category on direct uploads
my @categories = LANraragi::Model::Category->get_category_list;

# But only to static categories
@categories = grep { %$_{"search"} eq "" } @categories;
my @categories = LANraragi::Model::Category->get_static_category_list;

$self->render(
template => "upload",
Expand Down
16 changes: 14 additions & 2 deletions lib/LANraragi/Model/Category.pm
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,17 @@ sub get_category_list {
return @result;
}

# get_static_category_list()
# Returns a list of all the static category objects.
sub get_static_category_list() {

my @categories = get_category_list;

# Filter out dynamic categories
@categories = grep { %$_{"search"} eq "" } @categories;
return @categories;
}

# get_categories_containing_archive(id)
# Returns a list of all the categories that contain the given archive.
sub get_categories_containing_archive {
Expand Down Expand Up @@ -178,7 +189,7 @@ sub add_to_category {
if ( $redis->exists($cat_id) ) {

unless ( $redis->hget( $cat_id, "search" ) eq "" ) {
$err = "$cat_id is a favorite search, can't add archives to it.";
$err = "$cat_id is a favorite search/dynamic category, can't add archives to it.";
$logger->error($err);
$redis->quit;
return ( 0, $err );
Expand All @@ -203,7 +214,8 @@ sub add_to_category {
}

if ( "@cat_archives" =~ m/$arc_id/ ) {
$logger->warn("$arc_id already present in category $cat_id, doing nothing.");
$err = "$arc_id already present in category $cat_id, doing nothing.";
$logger->warn($err);
$redis->quit;
return ( 1, $err );
}
Expand Down
8 changes: 5 additions & 3 deletions lib/LANraragi/Model/Upload.pm
Original file line number Diff line number Diff line change
Expand Up @@ -153,10 +153,12 @@ sub download_url {
die "Not a proper URL" unless $url;
$logger->info("Downloading URL $url...This will take some time.");

my $tempdir = tempdir();
my $tx = $ua->max_redirects(5)->get($url);
my $tempdir = tempdir();

# Download the URL, with 5 maximum redirects and unlimited response size.
my $tx = $ua->max_response_size(0)->max_redirects(5)->get($url);
my $content_disp = $tx->result->headers->content_disposition;
my $filename = "Not_an_archive"; #placeholder;
my $filename = "Not_an_archive"; #placeholder;

$logger->debug("Content-Disposition Header: $content_disp");
if ( $content_disp =~ /.*filename=\"(.*)\".*/gim ) {
Expand Down
6 changes: 6 additions & 0 deletions lib/LANraragi/Plugin/Metadata/Fakku.pm
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,12 @@ sub get_search_result_dom {
# * Added a space ahead of the - (hyphen) filter, to only remove hyphens directly prepended to something else (those are the only ones that break searches, probably because the search engine treats them as exclusions as most engines would).
$title =~ s/ -|'\w*|~|!|@//g;

# Removes everything inside [ ] as well as the brackets themselves
$title =~ s/\[([^\[\]]|(?0))*]//g;

# Removes everything inside () as well as the parentheses themselves
$title =~ s/\(.*$//g;

# Visit the base host once to set cloudflare cookies and jank
$ua->max_redirects(5)->get($fakku_host);

Expand Down
10 changes: 4 additions & 6 deletions lib/LANraragi/Plugin/Scripts/FolderToCat.pm
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,11 @@ sub run_script {
if ($delete_old_cats) {
$logger->info("Deleting all Static Categories before folder walking as instructed.");

my @categories = LANraragi::Model::Category->get_category_list;
my @categories = LANraragi::Model::Category->get_static_category_list;
for my $category (@categories) {
if ( %{$category}{"search"} eq "" ) {
my $cat_id = %{$category}{"id"};
$logger->debug("Deleting '$cat_id'");
LANraragi::Model::Category::delete_category($cat_id);
}
my $cat_id = %{$category}{"id"};
$logger->debug("Deleting '$cat_id'");
LANraragi::Model::Category::delete_category($cat_id);
}
}

Expand Down
1 change: 1 addition & 0 deletions lib/LANraragi/Utils/Database.pm
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,7 @@ sub clean_database {
$redis->hset( $id, "file", "" );
} else {
change_archive_id( $id, $newid, $redis );
$redis->hset( "LRR_FILEMAP", $file, $newid );
}

} else {
Expand Down
8 changes: 7 additions & 1 deletion lib/LANraragi/Utils/Generic.pm
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ sub trim_url {
# Checks if the provided file is an image.
# Uses non-capturing groups (?:) to avoid modifying the incoming argument.
sub is_image {
return $_[0] =~ /^.+\.(?:png|jpg|gif|bmp|jpeg|jfif|webp|avif|heif|heic)$/i;
return $_[0] =~ /^.+\.(?:png|jpg|gif|bmp|jpeg|jfif|webp|avif|heif|heic|jxl|)$/i;
}

# Checks if the provided file is an archive.
Expand Down Expand Up @@ -142,6 +142,9 @@ sub start_minion {

# Freeze the process object in the PID file
store \$proc, get_temp . "/minion.pid";
open( my $fh, ">", get_temp . "/minion.pid-s6" );
print $fh $proc->pid;
close($fh);
return $proc;
}

Expand All @@ -164,6 +167,9 @@ sub start_shinobu {

# Freeze the process object in the PID file
store \$proc, get_temp . "/shinobu.pid";
open( my $fh, ">", get_temp . "/shinobu.pid-s6" );
print $fh $proc->pid;
close($fh);
return $proc;
}

Expand Down
2 changes: 2 additions & 0 deletions lib/Shinobu.pm
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,8 @@ sub add_to_filemap {

LANraragi::Utils::Database::change_archive_id( $filemap_id, $id, $redis );

# Don't forget to update the filemap, later operations will behave incorrectly otherwise
$redis->hset( "LRR_FILEMAP", $file, $id );
} else {
$logger->debug(
"$file has the same ID as the one in the filemap. Duplicate inotify events? Cleaning cache just to make sure");
Expand Down
7 changes: 4 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "lanraragi",
"version": "0.8.6",
"version_name": "Buddha of Suburbia",
"version": "0.8.7",
"version_name": "Outside",
"description": "I'm under Japanese influence and my honor's at stake!",
"scripts": {
"test": "prove -r -l -v tests/",
Expand All @@ -11,7 +11,8 @@
"dev-server": "perl ./script/launcher.pl -m -v ./script/lanraragi",
"docker-build": "docker build -t difegue/lanraragi -f ./tools/build/docker/Dockerfile .",
"critic": "perlcritic ./lib/* ./script/* ./tools/install.pl",
"backup-db": "perl ./script/backup"
"backup-db": "perl ./script/backup",
"get-version": "perl -Mojo -E \"my \\$conf = j(f(qw(package.json))->slurp); say %\\$conf{version} .q/ - '/. %\\$conf{version_name} .q/'/ \""
},
"repository": {
"type": "git",
Expand Down
6 changes: 6 additions & 0 deletions public/js/batch.js
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,7 @@ Batch.startBatch = function () {
const commandBase = {
operation: Batch.currentOperation,
plugin: Batch.currentPlugin,
category: $("#category").val(),
args,
};

Expand Down Expand Up @@ -223,6 +224,11 @@ Batch.updateBatchStatus = function (event) {
case "tagrules":
$("#log-container").append(`Replaced tags for ID ${msg.id} (New tags: ${msg.tags})\n\n`);
break;
case "addcat":
// Append the message at the end of this log,
// as it can contain the warning about the ID already being in the category
$("#log-container").append(`Added ID ${msg.id} to category ${msg.category}! ${msg.message} \n\n`);
break;
case "clearnew": {
$("#log-container").append(`Cleared new flag for ID ${msg.id}\n\n`);
// Remove last character from matching row
Expand Down
14 changes: 13 additions & 1 deletion templates/batch.html.tt2
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
<script src="/js/vendor/preact.umd.js" type="text/JAVASCRIPT"></script>
<script src="/js/vendor/hooks.umd.js" type="text/JAVASCRIPT"></script>
<script src="/js/vendor/compat.umd.js" type="text/JAVASCRIPT"></script>
<script>window.React=window.preactCompat;window.react=window.preactCompat;</script>
<script>window.React = window.preactCompat; window.react = window.preactCompat;</script>
<script src="/js/vendor/clsx.min.js" type="text/JAVASCRIPT"></script>
<script src="/js/vendor/react-toastify.umd.js" type="text/JAVASCRIPT"></script>
<script src="/js/vendor/sweetalert2.min.js" type="text/JAVASCRIPT"></script>
Expand Down Expand Up @@ -54,6 +54,7 @@
<option value="plugin">🧩 Use Plugin</option>
<option value="clearnew">🆕 Remove New Flag</option>
<option value="tagrules">📏 Apply Tag Rules</option>
<option value="addcat">📚 Add To Category</option>
<option value="delete">🗑️ Delete Archive</option>
</select>
</td>
Expand Down Expand Up @@ -123,6 +124,17 @@
</td>
</tr>

<tr class="operation addcat-operation">
<td>Add to Category :</td>
<td>
<select id="category" class="favtag-btn">
[% FOREACH categories %]
<option value="[% id %]">[% name %]</option>
[% END %]
</select>
</td>
</tr>

<tr class="operation delete-operation">
<td></td>
<td style="font-size:36px; text-align: center;">
Expand Down
3 changes: 1 addition & 2 deletions templates/templates_config/config_tags.html.tt2
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,7 @@
<td class="config-td">
<input id="tagruleson" name="tagruleson" class="fa" type="checkbox" [% IF tagruleson %]checked[% END %]>
<br>
<textarea class="stdinput" size="20" style='width:100%; height:196px' name="tagrules"
maxlength='5000'>[% tagrules %]</textarea>
<textarea class="stdinput" size="20" style='width:100%; height:196px' name="tagrules">[% tagrules %]</textarea>
<br>When tagging archives using Plugins, the rules specified here will be applied to the tags before saving them
to the database.
<br>Split rules with linebreaks.
Expand Down
2 changes: 1 addition & 1 deletion tools/Documentation/installing-lanraragi/docker.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ Regular versions of Debian shouldn't have this issue.
## Changing the port

Since Docker allows for port mapping, you can most of times map the default port of 3000 to another port on your host quickly.
If you need something a bit more involved (like adding SSL), please check the Network Interfaces section for how to use thhe `LRR_NETWORK` environment variable.
If you need something a bit more involved (like adding SSL), please check the Network Interfaces section for how to use the `LRR_NETWORK` environment variable.

{% content-ref url="../advanced-usage/network-interfaces.md" %}
[network-interfaces.md](../advanced-usage/network-interfaces.md)
Expand Down
2 changes: 1 addition & 1 deletion tools/Documentation/installing-lanraragi/macos.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ brew install lanraragi

Your content folder is stored by default in `${HOME}/Library/Application Support/LANraragi`. (`${HOME}/LANraragi/content` on Linux.)
The Redis database is stored in `${HOME}/Library/Application Support/LANraragi/database`. (`${HOME}/LANraragi/database` on Linux.)
The content folder can be moved to any folder you want through the in-app settings page.
While the in-app settings page won't allow you to change the location of the content folder, you can do so by overriding the `LRR_DATA_DIRECTORY` environment variable before launching.

## Usage

Expand Down
2 changes: 1 addition & 1 deletion tools/Documentation/installing-lanraragi/source.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ For information, my personal tests are done using Debian's vendor Perl.
apt-get update
apt-get upgrade -y
apt-get install build-essential make gnupg pkg-config \
cpanminus redis-server libarchive-dev imagemagick webp libssl-dev zlib1g-dev \
cpanminus redis-server libarchive-dev imagemagick webp libssl-dev zlib1g-dev libjxl-dev \
perlmagick ghostscript npm
```

Expand Down
Loading

0 comments on commit fe84fa2

Please sign in to comment.