Skip to content

Commit

Permalink
LANraragi Release 0.8.4
Browse files Browse the repository at this point in the history
Merge pull request #579 from Difegue/dev
  • Loading branch information
Difegue authored Jan 6, 2022
2 parents 2ad9c57 + f41dd83 commit 9c32ce6
Show file tree
Hide file tree
Showing 58 changed files with 1,012 additions and 592 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/push-continous-delivery.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ jobs:
- name: Build/Push Nightly Docker
run: |
docker buildx build \
--platform linux/386,linux/amd64,linux/arm/v6,linux/arm/v7,linux/arm64,linux/ppc64le,linux/s390x \
--platform linux/386,linux/amd64,linux/arm/v6,linux/arm/v7,linux/arm64 \
--output "type=image,push=true" \
--tag difegue/lanraragi:nightly \
--cache-from "type=local,src=/tmp/buildxcache" \
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release-delivery.yml
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ jobs:
run: |
TAG=${GITHUB_REF:10:10}
docker buildx build \
--platform linux/386,linux/amd64,linux/arm/v6,linux/arm/v7,linux/arm64,linux/ppc64le,linux/s390x \
--platform linux/386,linux/amd64,linux/arm/v6,linux/arm/v7,linux/arm64 \
--output "type=image,push=true" \
--tag difegue/lanraragi:latest \
--tag difegue/lanraragi:$TAG \
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ Open source server for archival of comics/manga, running on Mojolicious + Redis.

#### 💬 Talk with other fellow LANraragi Users on [Discord](https://discord.gg/aRQxtbg) or [Github Discussions](https://github.com/Difegue/LANraragi/discussions)

#### [📄 Documentation](https://sugoi.gitbook.io/lanraragi/) | [⏬ Download](https://github.com/Difegue/LANraragi/releases/latest) | [🎞 Demo](https://lrr.tvc-16.science) | [🪟🌃 Windows Nightlies](https://nightly.link/Difegue/LANraragi/workflows/push-continous-delivery/dev) | [💵 Sponsor Development](https://ko-fi.com/T6T2UP5N)
#### [📄 Documentation](https://sugoi.gitbook.io/lanraragi/v/dev) | [⏬ Download](https://github.com/Difegue/LANraragi/releases/latest) | [🎞 Demo](https://lrr.tvc-16.science) | [🪟🌃 Windows Nightlies](https://nightly.link/Difegue/LANraragi/workflows/push-continous-delivery/dev) | [💵 Sponsor Development](https://ko-fi.com/T6T2UP5N)

## The 2021 User Survey results have landed!

Expand Down
12 changes: 9 additions & 3 deletions lib/LANraragi/Controller/Api/Archive.pm
Original file line number Diff line number Diff line change
Expand Up @@ -88,15 +88,21 @@ sub get_categories {

sub serve_thumbnail {
my $self = shift;
my $id = check_id_parameter( $self, "thumbnail" ) || return;
my $id = check_id_parameter( $self, "serve_thumbnail" ) || return;
LANraragi::Model::Archive::serve_thumbnail( $self, $id );
}

sub update_thumbnail {
my $self = shift;
my $id = check_id_parameter( $self, "update_thumbnail" ) || return;
LANraragi::Model::Archive::update_thumbnail( $self, $id );
}

# Use RenderFile to get the file of the provided id to the client.
sub serve_file {

my $self = shift;
my $id = check_id_parameter( $self, "servefile" ) || return;
my $id = check_id_parameter( $self, "serve_file" ) || return;
my $redis = $self->LRR_CONF->get_redis();

my $file = $redis->hget( $id, "file" );
Expand Down Expand Up @@ -126,7 +132,7 @@ sub get_file_list {
if ($err) {
render_api_response( $self, "get_file_list", $err );
} else {
$self->render( json => decode_json($reader_json) );
$self->render( json => $reader_json );
}
}

Expand Down
72 changes: 38 additions & 34 deletions lib/LANraragi/Controller/Config.pm
Original file line number Diff line number Diff line change
Expand Up @@ -15,33 +15,35 @@ sub index {
my $self = shift;

$self->render(
template => "config",
version => $self->LRR_VERSION,
vername => $self->LRR_VERNAME,
descstr => $self->LRR_DESC,
motd => $self->LRR_CONF->get_motd,
dirname => $self->LRR_CONF->get_userdir,
thumbdir => $self->LRR_CONF->get_thumbdir,
forceddirname => ( defined $ENV{LRR_DATA_DIRECTORY} ? 1 : 0 ),
forcedthumbdir => ( defined $ENV{LRR_THUMB_DIRECTORY} ? 1 : 0 ),
pagesize => $self->LRR_CONF->get_pagesize,
enablepass => $self->LRR_CONF->enable_pass,
password => $self->LRR_CONF->get_password,
tagruleson => $self->LRR_CONF->enable_tagrules,
tagrules => restore_CRLF( $self->LRR_CONF->get_tagrules ),
title => $self->LRR_CONF->get_htmltitle,
tempmaxsize => $self->LRR_CONF->get_tempmaxsize,
localprogress => $self->LRR_CONF->enable_localprogress,
devmode => $self->LRR_CONF->enable_devmode,
nofunmode => $self->LRR_CONF->enable_nofun,
apikey => $self->LRR_CONF->get_apikey,
enablecors => $self->LRR_CONF->enable_cors,
enableresize => $self->LRR_CONF->enable_resize,
sizethreshold => $self->LRR_CONF->get_threshold,
readerquality => $self->LRR_CONF->get_readquality,
theme => $self->LRR_CONF->get_style,
csshead => generate_themes_header($self),
tempsize => get_tempsize
template => "config",
version => $self->LRR_VERSION,
vername => $self->LRR_VERNAME,
descstr => $self->LRR_DESC,
motd => $self->LRR_CONF->get_motd,
dirname => $self->LRR_CONF->get_userdir,
thumbdir => $self->LRR_CONF->get_thumbdir,
forceddirname => ( defined $ENV{LRR_DATA_DIRECTORY} ? 1 : 0 ),
forcedthumbdir => ( defined $ENV{LRR_THUMB_DIRECTORY} ? 1 : 0 ),
pagesize => $self->LRR_CONF->get_pagesize,
enablepass => $self->LRR_CONF->enable_pass,
password => $self->LRR_CONF->get_password,
tagruleson => $self->LRR_CONF->enable_tagrules,
tagrules => restore_CRLF( $self->LRR_CONF->get_tagrules ),
title => $self->LRR_CONF->get_htmltitle,
tempmaxsize => $self->LRR_CONF->get_tempmaxsize,
localprogress => $self->LRR_CONF->enable_localprogress,
devmode => $self->LRR_CONF->enable_devmode,
nofunmode => $self->LRR_CONF->enable_nofun,
apikey => $self->LRR_CONF->get_apikey,
enablecors => $self->LRR_CONF->enable_cors,
enableresize => $self->LRR_CONF->enable_resize,
sizethreshold => $self->LRR_CONF->get_threshold,
readerquality => $self->LRR_CONF->get_readquality,
theme => $self->LRR_CONF->get_style,
usedateadded => $self->LRR_CONF->enable_dateadded,
usedatemodified => $self->LRR_CONF->use_lastmodified,
csshead => generate_themes_header($self),
tempsize => get_tempsize
);
}

Expand Down Expand Up @@ -69,13 +71,15 @@ sub save_config {

# For checkboxes,
# we check if the parameter exists in the POST to return either 1 or 0.
enablepass => ( scalar $self->req->param('enablepass') ? '1' : '0' ),
enablecors => ( scalar $self->req->param('enablecors') ? '1' : '0' ),
localprogress => ( scalar $self->req->param('localprogress') ? '1' : '0' ),
devmode => ( scalar $self->req->param('devmode') ? '1' : '0' ),
enableresize => ( scalar $self->req->param('enableresize') ? '1' : '0' ),
tagruleson => ( scalar $self->req->param('tagruleson') ? '1' : '0' ),
nofunmode => ( scalar $self->req->param('nofunmode') ? '1' : '0' )
enablepass => ( scalar $self->req->param('enablepass') ? '1' : '0' ),
enablecors => ( scalar $self->req->param('enablecors') ? '1' : '0' ),
localprogress => ( scalar $self->req->param('localprogress') ? '1' : '0' ),
devmode => ( scalar $self->req->param('devmode') ? '1' : '0' ),
enableresize => ( scalar $self->req->param('enableresize') ? '1' : '0' ),
tagruleson => ( scalar $self->req->param('tagruleson') ? '1' : '0' ),
nofunmode => ( scalar $self->req->param('nofunmode') ? '1' : '0' ),
usedateadded => ( scalar $self->req->param('usedateadded') ? '1' : '0' ),
usedatemodified => ( scalar $self->req->param('usedatemodified') ? '1' : '0' )
);

# Only add newpassword field as password if enablepass = 1
Expand Down
10 changes: 10 additions & 0 deletions lib/LANraragi/Controller/Reader.pm
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package LANraragi::Controller::Reader;
use Mojo::Base 'Mojolicious::Controller';
use Mojo::URL;

use Encode;

Expand All @@ -20,6 +21,14 @@ sub index {
# But only to static categories
@categories = grep { %$_{"search"} eq "" } @categories;

# Get query string from referrer URL, if there's one
my $referrer = $self->req->headers->referrer;
my $query = "";

if ($referrer) {
$query = Mojo::URL->new($referrer)->query->to_string;
}

$self->render(
template => "reader",
title => $self->LRR_CONF->get_htmltitle,
Expand All @@ -28,6 +37,7 @@ sub index {
categories => \@categories,
csshead => generate_themes_header($self),
version => $self->LRR_VERSION,
ref_query => $query,
userlogged => $self->LRR_CONF->enable_pass == 0 || $self->session('is_logged')
);
} else {
Expand Down
73 changes: 69 additions & 4 deletions lib/LANraragi/Model/Archive.pm
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ use Mojo::Util qw(xml_escape);
use LANraragi::Utils::Generic qw(get_tag_with_namespace remove_spaces remove_newlines render_api_response);
use LANraragi::Utils::TempFolder qw(get_temp);
use LANraragi::Utils::Logging qw(get_logger);
use LANraragi::Utils::Archive qw(extract_single_file);
use LANraragi::Utils::Archive qw(extract_single_file extract_thumbnail);
use LANraragi::Utils::Database qw(redis_encode redis_decode invalidate_cache get_archive_json get_archive_json_multi);

# Functions used when dealing with archives.
Expand Down Expand Up @@ -124,7 +124,6 @@ sub find_untagged_archives {
remove_newlines($t);

# The following are basic and therefore don't count as "tagged"
# date_added added for convenience as running the matching plugin doesn't really count as tagging
$nondefaulttags += 1 unless $t =~ /(artist|parody|series|language|event|group|date_added):.*/;
}

Expand All @@ -139,21 +138,87 @@ sub find_untagged_archives {
return @untagged;
}

sub update_thumbnail {

my ( $self, $id ) = @_;

my $page = $self->req->param('page');
$page = 1 unless $page;

my $thumbdir = LANraragi::Model::Config->get_thumbdir;

# Thumbnails are stored in the content directory, thumb subfolder.
# Another subfolder with the first two characters of the id is used for FS optimization.
my $subfolder = substr( $id, 0, 2 );
my $thumbname = "$thumbdir/$subfolder/$id.jpg"; # Path to main thumbnail

my $newthumb = "";

# Get the required thumbnail we want to make the main one
eval { $newthumb = extract_thumbnail( $thumbdir, $id, $page ) };

if ( $@ || !$newthumb ) {
render_api_response( $self, "update_thumbnail", $@ );
} else {
if ( $newthumb ne $thumbname && $newthumb ne "" ) {

# Copy the thumbnail to the main thumbnail location
cp( $newthumb, $thumbname );
}

$self->render(
json => {
operation => "update_thumbnail",
new_thumbnail => $newthumb,
success => 1
}
);
}

}

sub serve_thumbnail {

my ( $self, $id ) = @_;

my $page = $self->req->param('page');
$page = 0 unless $page;

my $no_fallback = $self->req->param('no_fallback');
$no_fallback = ( $no_fallback && $no_fallback eq "true" ) || "0"; # Prevent undef warnings by checking the variable first

my $thumbdir = LANraragi::Model::Config->get_thumbdir;

# Thumbnails are stored in the content directory, thumb subfolder.
# Another subfolder with the first two characters of the id is used for FS optimization.
my $subfolder = substr( $id, 0, 2 );
my $thumbname = "$thumbdir/$subfolder/$id.jpg";

if ( $page > 0 ) {
$thumbname = "$thumbdir/$subfolder/$id/$page.jpg";
}

# Queue a minion job to generate the thumbnail. Thumbnail jobs have the lowest priority.
unless ( -e $thumbname ) {
$self->minion->enqueue( thumbnail_task => [ $thumbdir, $id ] => { priority => 0 } );
$self->render_file( filepath => "./public/img/noThumb.png" );
my $job_id = $self->minion->enqueue( thumbnail_task => [ $thumbdir, $id, $page ] => { priority => 0, attempts => 3 } );

if ($no_fallback) {

$self->render(
json => {
operation => "serve_thumbnail",
success => 1,
job => $job_id
},
status => 202 # 202 Accepted
);
} else {

# If the thumbnail doesn't exist, serve the default thumbnail.
$self->render_file( filepath => "./public/img/noThumb.png" );
}
return;

} else {

# Simply serve the thumbnail.
Expand Down
30 changes: 16 additions & 14 deletions lib/LANraragi/Model/Config.pm
Original file line number Diff line number Diff line change
Expand Up @@ -131,19 +131,21 @@ sub get_tagrules {
);
}

sub get_htmltitle { return &get_redis_conf( "htmltitle", "LANraragi" ) }
sub get_motd { return &get_redis_conf( "motd", "Welcome to this Library running LANraragi!" ) }
sub get_tempmaxsize { return &get_redis_conf( "tempmaxsize", "500" ) }
sub get_pagesize { return &get_redis_conf( "pagesize", "100" ) }
sub enable_pass { return &get_redis_conf( "enablepass", "1" ) }
sub enable_nofun { return &get_redis_conf( "nofunmode", "0" ) }
sub enable_cors { return &get_redis_conf( "enablecors", "0" ) }
sub get_apikey { return &get_redis_conf( "apikey", "" ) }
sub enable_localprogress { return &get_redis_conf( "localprogress", "0" ) }
sub enable_tagrules { return &get_redis_conf( "tagruleson", "1" ) }
sub enable_resize { return &get_redis_conf( "enableresize", "0" ) }
sub get_threshold { return &get_redis_conf( "sizethreshold", "1000" ) }
sub get_readquality { return &get_redis_conf( "readerquality", "50" ) }
sub get_style { return &get_redis_conf( "theme", "modern.css" ) }
sub get_htmltitle { return &get_redis_conf( "htmltitle", "LANraragi" ) }
sub get_motd { return &get_redis_conf( "motd", "Welcome to this Library running LANraragi!" ) }
sub get_tempmaxsize { return &get_redis_conf( "tempmaxsize", "500" ) }
sub get_pagesize { return &get_redis_conf( "pagesize", "100" ) }
sub enable_pass { return &get_redis_conf( "enablepass", "1" ) }
sub enable_nofun { return &get_redis_conf( "nofunmode", "0" ) }
sub enable_cors { return &get_redis_conf( "enablecors", "0" ) }
sub get_apikey { return &get_redis_conf( "apikey", "" ) }
sub enable_localprogress { return &get_redis_conf( "localprogress", "0" ) }
sub enable_tagrules { return &get_redis_conf( "tagruleson", "1" ) }
sub enable_resize { return &get_redis_conf( "enableresize", "0" ) }
sub get_threshold { return &get_redis_conf( "sizethreshold", "1000" ) }
sub get_readquality { return &get_redis_conf( "readerquality", "50" ) }
sub get_style { return &get_redis_conf( "theme", "modern.css" ) }
sub enable_dateadded { return &get_redis_conf( "usedateadded", "1" ) }
sub use_lastmodified { return &get_redis_conf( "usedatemodified", "0" ) }

1;
16 changes: 14 additions & 2 deletions lib/LANraragi/Model/Plugins.pm
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,18 @@ sub exec_enabled_plugins_on_file {

my @plugins = LANraragi::Utils::Plugins::get_enabled_plugins("metadata");

# If the regex plugin is in the list, make sure it's ran first.
foreach my $plugin (@plugins) {
if ( $plugin->{namespace} eq "regexplugin" ) {
my $regex_plugin = $plugin;

# Remove element from array
@plugins = grep { $_->{namespace} ne "regexplugin" } @plugins;
unshift @plugins, $regex_plugin;
last;
}
}

foreach my $pluginfo (@plugins) {
my $name = $pluginfo->{namespace};
my @args = LANraragi::Utils::Plugins::get_plugin_parameters($name);
Expand Down Expand Up @@ -195,8 +207,8 @@ sub exec_metadata_plugin {
$logger->info("Thumbnail hash invalid, regenerating.");
my $thumbdir = LANraragi::Model::Config->get_thumbdir;

#eval the thumbnail extraction as it can error out and die
eval { extract_thumbnail( $thumbdir, $id ) };
# Eval the thumbnail extraction, as it can error out and die
eval { extract_thumbnail( $thumbdir, $id, 0 ) };
if ($@) {
$logger->warn("Error building thumbnail: $@");
$thumbhash = "";
Expand Down
Loading

0 comments on commit 9c32ce6

Please sign in to comment.