diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile index 273c229..a13a7fa 100644 --- a/.devcontainer/Dockerfile +++ b/.devcontainer/Dockerfile @@ -9,7 +9,7 @@ ENV LC_ALL=en_US.UTF-8 LANG=en_US.UTF-8 LANGUAGE=en_US.UTF-8 # Install needed packages and setup non-root user. Use a separate RUN statement to add your own dependencies. ARG USERNAME=root -ARG USER_UID=1000 +ARG USER_UID=0 ARG USER_GID=$USER_UID RUN export DEBIAN_FRONTEND=noninteractive \ && apt-get -y update && apt-get -y install wget \ @@ -27,7 +27,8 @@ RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \ # Dropping copies of the files in the .devcontainer folder should also work, but I cba to duplicate my build files for this and symlinks aint working I hate computers RUN wget -P /tools https://raw.githubusercontent.com/WindyCloudCute/LANraragi_Chinese/dev/tools/cpanfile \ && wget -P /tools https://raw.githubusercontent.com/WindyCloudCute/LANraragi_Chinese/dev/tools/install.pl \ - && wget https://raw.githubusercontent.com/WindyCloudCute/LANraragi_Chinese/dev/package.json + && wget https://raw.githubusercontent.com/WindyCloudCute/LANraragi_Chinese/dev/package.json \ + && wget https://raw.githubusercontent.com/WindyCloudCute/LANraragi_Chinese/dev/package-lock.json RUN npm run lanraragi-installer install-full diff --git a/.gitignore b/.gitignore index fd83668..e0d4c3f 100644 --- a/.gitignore +++ b/.gitignore @@ -13,4 +13,4 @@ autobackup.json lib/LANraragi/Plugin/Scripts/ETagConverter.pm lib/LANraragi/Plugin/Metadata/ETagCN.pm Makefile -oshino \ No newline at end of file +oshino diff --git a/lib/LANraragi/Controller/Batch.pm b/lib/LANraragi/Controller/Batch.pm index 6289bcd..2666ac8 100644 --- a/lib/LANraragi/Controller/Batch.pm +++ b/lib/LANraragi/Controller/Batch.pm @@ -43,7 +43,7 @@ sub socket { my $logger = get_logger( "Batch Tagging", "lanraragi" ); - $logger->info('客户端连接到 Batch Tagging 服务'); + $logger->info('Client connected to Batch Tagging service'); # Increase inactivity timeout for connection a bit to account for clientside timeouts $self->inactivity_timeout(80); @@ -81,7 +81,7 @@ sub socket { my @args = @{ $command->{"args"} }; if ( !@args ) { - $logger->debug("没有覆盖插件全局参数."); + $logger->debug("No user overrides given."); # Try getting the saved defaults @args = get_plugin_parameters($pluginname); @@ -127,7 +127,7 @@ sub socket { if ( $operation eq "tagrules" ) { - $logger->debug("将标签规则应用于$id..."); + $logger->debug("Applying tag rules to $id..."); my $tags = $redis->hget( $id, "tags" ); $tags = redis_decode($tags); @@ -137,7 +137,7 @@ sub socket { # Merge array with commas my $newtags = join( ', ', @tagarray ); - $logger->debug("新标签: $newtags"); + $logger->debug("New tags: $newtags"); set_tags( $id, $newtags ); $client->send( @@ -155,7 +155,7 @@ sub socket { } if ( $operation eq "delete" ) { - $logger->debug("正在删除 $id..."); + $logger->debug("Deleting $id..."); my $delStatus = LANraragi::Model::Archive::delete_archive($id); @@ -187,7 +187,7 @@ sub socket { # If the client doesn't respond, halt processing finish => sub { - $logger->info('客户端断开连接,停止剩余操作'); + $logger->info('Client disconnected, halting remaining operations'); $cancelled = 1; $redis->quit(); } diff --git a/lib/LANraragi/Model/Archive.pm b/lib/LANraragi/Model/Archive.pm index b08fff0..a715910 100644 --- a/lib/LANraragi/Model/Archive.pm +++ b/lib/LANraragi/Model/Archive.pm @@ -271,4 +271,50 @@ sub update_metadata { return ""; } +# Deletes the archive with the given id from redis, and the matching archive file/thumbnail. +sub delete_archive ($id) { + + my $redis = LANraragi::Model::Config->get_redis; + my $filename = $redis->hget( $id, "file" ); + my $oldtags = $redis->hget( $id, "tags" ); + $oldtags = redis_decode($oldtags); + + my $oldtitle = lc( redis_decode( $redis->hget( $id, "title" ) ) ); + $oldtitle = trim($oldtitle); + $oldtitle = trim_CRLF($oldtitle); + $oldtitle = redis_encode($oldtitle); + + $redis->del($id); + $redis->quit(); + + # Remove matching data from the search indexes + my $redis_search = LANraragi::Model::Config->get_redis_search; + $redis_search->zrem( "LRR_TITLES", "$oldtitle\0$id" ); + $redis_search->srem( "LRR_NEW", $id ); + $redis_search->srem( "LRR_UNTAGGED", $id ); + $redis_search->quit(); + + LANraragi::Utils::Database::update_indexes( $id, $oldtags, "" ); + + if ( -e $filename ) { + my $status = unlink $filename; + + my $thumbdir = LANraragi::Model::Config->get_thumbdir; + my $subfolder = substr( $id, 0, 2 ); + + my $jpg_thumbname = "$thumbdir/$subfolder/$id.jpg"; + unlink $jpg_thumbname; + + my $jxl_thumbname = "$thumbdir/$subfolder/$id.jxl"; + unlink $jxl_thumbname; + + # Delete the thumbpages folder + remove_tree("$thumbdir/$subfolder/$id/"); + + return $status ? $filename : "0"; + } + + return "0"; +} + 1; diff --git a/lib/LANraragi/Model/Opds.pm b/lib/LANraragi/Model/Opds.pm index 5d9ccd4..8790769 100644 --- a/lib/LANraragi/Model/Opds.pm +++ b/lib/LANraragi/Model/Opds.pm @@ -60,7 +60,7 @@ sub generate_opds_catalog { version => $mojo->LRR_VERSION, api_key_query => $api_key ? "?key=" . $api_key : "", api_key_and => $api_key ? "&key=" . $api_key : "" - ); + ); }else{ return $mojo->render_to_string( template => "opds", diff --git a/lib/LANraragi/Model/Plugins.pm b/lib/LANraragi/Model/Plugins.pm index 7843293..a16e973 100644 --- a/lib/LANraragi/Model/Plugins.pm +++ b/lib/LANraragi/Model/Plugins.pm @@ -2,7 +2,7 @@ package LANraragi::Model::Plugins; use strict; use warnings; - +use utf8; use feature 'fc'; use Redis; diff --git a/lib/LANraragi/Model/Reader.pm b/lib/LANraragi/Model/Reader.pm index 3d7bc17..64f67a0 100644 --- a/lib/LANraragi/Model/Reader.pm +++ b/lib/LANraragi/Model/Reader.pm @@ -2,7 +2,7 @@ package LANraragi::Model::Reader; use strict; use warnings; - +use utf8; use Redis; use File::Basename; diff --git a/lib/LANraragi/Model/Search.pm b/lib/LANraragi/Model/Search.pm index e607c8a..14b2c68 100644 --- a/lib/LANraragi/Model/Search.pm +++ b/lib/LANraragi/Model/Search.pm @@ -2,8 +2,8 @@ package LANraragi::Model::Search; use strict; use warnings; - use utf8; + use List::Util qw(min); use Redis; use Storable qw/ nfreeze thaw /; @@ -27,7 +27,7 @@ sub do_search { my $logger = get_logger( "Search Engine", "lanraragi" ); unless ( $redis->exists("LAST_JOB_TIME") ) { - $logger->error("搜索引擎尚未初始化。 请稍等几秒钟。"); + $logger->error("Search engine is not initialized yet. Please wait a few seconds."); return ( -1, -1, () ); } @@ -41,7 +41,7 @@ sub do_search { my ( $cachehit, @filtered ) = check_cache( $cachekey, $cachekey_inv ); unless ($cachehit) { - $logger->debug("没有可用的缓存,进行完整的DB解析。"); + $logger->debug("No cache available, doing a full DB parse."); @filtered = search_uncached( $category_id, $filter, $sortkey, $sortorder, $newonly, $untaggedonly ); # Cache this query in the search database @@ -70,10 +70,10 @@ sub check_cache { my @filtered = (); my $cachehit = 0; - $logger->debug("搜索请求: $cachekey"); + $logger->debug("Search request: $cachekey"); if ( $redis->exists("LRR_SEARCHCACHE") && $redis->hexists( "LRR_SEARCHCACHE", $cachekey ) ) { - $logger->debug("将缓存用于此查询。"); + $logger->debug("Using cache for this query."); $cachehit = 1; # Thaw cache and use that as the filtered list @@ -81,7 +81,7 @@ sub check_cache { @filtered = @{ thaw $frozendata }; } elsif ( $redis->exists("LRR_SEARCHCACHE") && $redis->hexists( "LRR_SEARCHCACHE", $cachekey_inv ) ) { - $logger->debug("与对面的排序订单存在缓存密钥."); + $logger->debug("A cache key exists with the opposite sortorder."); $cachehit = 1; # Thaw cache, invert the list to match the sortorder and use that as the filtered list @@ -147,7 +147,7 @@ sub search_uncached { my $isneg = $token->{isneg}; my $isexact = $token->{isexact}; - $logger->debug("正在搜索 $tag, isneg=$isneg, isexact=$isexact"); + $logger->debug("Searching for $tag, isneg=$isneg, isexact=$isexact"); # Encode tag as we'll use it in redis operations $tag = redis_encode($tag); @@ -162,7 +162,7 @@ sub search_uncached { my $operator = $2; my $pagecount = $3; - $logger->debug("搜索具有页面的ID $operator $pagecount $col"); + $logger->debug("Searching for IDs with $operator $pagecount $col"); # If no operator is specified, we assume it's an exact match $operator = "=" if !$operator; @@ -194,7 +194,7 @@ sub search_uncached { # Get the list of IDs for this tag @ids = $redis->smembers("INDEX_$tag"); - $logger->debug( "找到了 $tag 的索引,包含 " . scalar @ids . "个 ID" ); + $logger->debug( "Found tag index for $tag, containing " . scalar @ids . " IDs" ); } else { # Get index keys that match this tag. @@ -206,7 +206,7 @@ sub search_uncached { # Get the list of IDs for each key foreach my $key (@keys) { my @keyids = $redis->smembers($key); - $logger->trace( "找到了 $tag 的索引 $key,包含了 " . scalar @ids . " 个 ID" ); + $logger->trace( "Found index $key for $tag, containing " . scalar @ids . " IDs" ); push @ids, @keyids; } } @@ -218,7 +218,7 @@ sub search_uncached { # First iteration if ( $scan == -1 ) { $scan = 0; } - $logger->trace("正在扫描 $namesearch, cursor=$scan"); + $logger->trace("Scanning for $namesearch, cursor=$scan"); my @result = $redis->zscan( "LRR_TITLES", $scan, "MATCH", $namesearch, "COUNT", 100 ); $scan = $result[0]; @@ -226,7 +226,7 @@ sub search_uncached { foreach my $title ( @{ $result[1] } ) { if ( $title eq "0" ) { next; } # Skip scores - $logger->trace("找到标题匹配项: $title"); + $logger->trace("Found title match: $title"); # Strip everything before \x00 to get the ID out of the key my $id = substr( $title, index( $title, "\x00" ) + 1 ); @@ -237,11 +237,11 @@ sub search_uncached { if ( scalar @ids == 0 && !$isneg ) { # No more results, we can end search here - $logger->trace("该标记没有结果,正在停止搜索。"); + $logger->trace("No results for this token, halting search."); @filtered = (); last; } else { - $logger->trace( "找到此标记的 " . scalar @ids . " 个结果." ); + $logger->trace( "Found " . scalar @ids . " results for this token." ); # Intersect the new list with the previous ones @filtered = intersect_arrays( \@ids, \@filtered, $isneg ); @@ -250,7 +250,7 @@ sub search_uncached { } if ( $#filtered > 0 ) { - $logger->debug( "筛选后找到了 " . $#filtered . " 个结果" ); + $logger->debug( "Found " . $#filtered . " results after filtering." ); if ( !$sortkey ) { $sortkey = "title"; @@ -268,7 +268,7 @@ sub search_uncached { # Remove the titles from the keys, which are stored as "title\x00id" @ordered = map { substr( $_, index( $_, "\x00" ) + 1 ) } @ordered; - $logger->trace( "有序列表中的示例元素: " . $ordered[0] ); + $logger->trace( "Example element from ordered list: " . $ordered[0] ); # Just intersect the ordered list with the filtered one to get the final result @filtered = intersect_arrays( \@filtered, \@ordered, 0 ); @@ -382,7 +382,7 @@ sub compute_search_filter { } # Escape already present regex characters - $logger->debug("预转义标签: $tag"); + $logger->debug("Pre-escaped tag: $tag"); $tag = trim($tag); diff --git a/lib/LANraragi/Model/Stats.pm b/lib/LANraragi/Model/Stats.pm index 53ca1bc..0acdbc2 100644 --- a/lib/LANraragi/Model/Stats.pm +++ b/lib/LANraragi/Model/Stats.pm @@ -2,7 +2,7 @@ package LANraragi::Model::Stats; use strict; use warnings; - +use utf8; use Redis; use File::Find; @@ -21,7 +21,7 @@ sub get_archive_count { sub get_page_stat { my $redis = LANraragi::Model::Config->get_redis_config; - my $stat = $redis->get("LRR_TOTALPAGESTAT") || 0; + my $stat = $redis->get("LRR_TOTALPAGESTAT") || 0; $redis->quit(); return $stat; diff --git a/lib/LANraragi/Plugin/Metadata/Koromo.pm b/lib/LANraragi/Plugin/Metadata/Koromo.pm index 2c6471d..d647485 100644 --- a/lib/LANraragi/Plugin/Metadata/Koromo.pm +++ b/lib/LANraragi/Plugin/Metadata/Koromo.pm @@ -23,7 +23,7 @@ sub plugin_info { author => "CirnoT, Difegue", version => "2.1", description => " 在Koromo 风格的 Info.json 文件收集作为嵌入到档案中的元数据. ( {'Tags': [xxx] } syntax)", - icon => + icon => "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAABhGlDQ1BJQ0MgcHJvZmlsZQAAKJF9kT1Iw1AUhU9TpVoqDmYQcchQnSyIijhKFYtgobQVWnUweekfNDEkKS6OgmvBwZ/FqoOLs64OroIg+APi4uqk6CIl3pcUWsR44fE+zrvn8N59gNCoMs3qGgc03TbTibiUy69IoVeE0QsRAYgys4xkZiEL3/q6pz6quxjP8u/7s/rUgsWAgEQ8ywzTJl4nnt60Dc77xCIryyrxOfGYSRckfuS64vEb55LLAs8UzWx6jlgklkodrHQwK5sa8RRxVNV0yhdyHquctzhr1Rpr3ZO/MFLQlzNcpzWMBBaRRAoSFNRQQRU2YrTrpFhI03ncxz/k+lPkUshVASPHPDagQXb94H/we7ZWcXLCS4rEge4Xx/kYAUK7QLPuON/HjtM8AYLPwJXe9m80gJlP0uttLXoE9G8DF9dtTdkDLneAwSdDNmVXCtISikXg/Yy+KQ8M3ALhVW9urXOcPgBZmtXSDXBwCIyWKHvN5909nXP7t6c1vx8dzXKFeWpUawAAAAZiS0dEAOwAEABqpSa6lwAAAAlwSFlzAAAuIwAALiMBeKU/dgAAAAd0SU1FB+MKCRQBJSKMeg0AAAGVSURBVDjLpZMxa9tQFIXPeaiyhxiZzKFjBme1JFfYgYAe9Bd0yA8JIaQhkJLBP6T/wh3qpZYzm2I8dyilJJMTW7yTIVGRFasE8uAt93K+d+5991IS8Ybj1SVIer24ty8Jk2wyl5S/GkDSi+O4s9PaOYOQh91wSHK2DeLViVut1pmkTwAQtAPUQcz/xCRBEpKOg3ZwEnbDDklvK6AQ+77fds4tSJbBcM7Nm83GbhXiVcXj8fiHpO/WWgfgHAAkXYxGoy8k/UG/nzxDnsqRxF7cO0iS5AhAQxKLm6bpVZqmn8sxAI3kQ2KjKDqQ9GRFEqDNfpQcukrMkDRF3ADAJJvM1+v1n0G/n5D0AcBaew3gFMCFtfbyuVT/cHCYrFarX1mWLQCgsAWSXtgNO81mY/ed7380xpyUn3XOXefr/Ntyufw9vZn+LL7zn21J+fRmOru/f/hrjNmThFLOGWPeV8UvBklSTnIWdsNh0A4g6RiAI/n17vZuWBVvncQNSBAYEK5OvNGDbSMdRdE+AJdl2aJumfjWdX4EIwDvDt7UjSEAAAAASUVORK5CYII=", parameters => [] ); diff --git a/lib/LANraragi/Plugin/Metadata/Ksk.pm b/lib/LANraragi/Plugin/Metadata/Ksk.pm index 5173793..1b249b8 100644 --- a/lib/LANraragi/Plugin/Metadata/Ksk.pm +++ b/lib/LANraragi/Plugin/Metadata/Ksk.pm @@ -2,7 +2,7 @@ package LANraragi::Plugin::Metadata::Ksk; use strict; use warnings; - +use utf8; use LANraragi::Model::Plugins; use LANraragi::Utils::Logging qw(get_plugin_logger); use LANraragi::Utils::Archive qw(is_file_in_archive extract_file_from_archive); diff --git a/lib/LANraragi/Utils/Database.pm b/lib/LANraragi/Utils/Database.pm index 3ea71f9..8f4ae75 100644 --- a/lib/LANraragi/Utils/Database.pm +++ b/lib/LANraragi/Utils/Database.pm @@ -344,7 +344,7 @@ sub set_title ( $id, $newtitle ) { # Set $append to 1 if you want to append the tags instead of replacing them. sub set_tags ( $id, $newtags, $append = 0 ) { - my $redis = LANraragi::Model::Config->get_redis; + my $redis = LANraragi::Model::Config->get_redis; my $oldtags = $redis->hget( $id, "tags" ); $oldtags = redis_decode($oldtags); diff --git a/lib/LANraragi/Utils/Generic.pm b/lib/LANraragi/Utils/Generic.pm index fdfd4f1..ef85856 100644 --- a/lib/LANraragi/Utils/Generic.pm +++ b/lib/LANraragi/Utils/Generic.pm @@ -93,7 +93,7 @@ sub start_minion { my $logger = get_logger( "Minion", "minion" ); my $numcpus = Sys::CpuAffinity::getNumCpus(); - $logger->info("在子进程中使用 $numcpus 并行作业启动新的 Minion 工作进程。"); + $logger->info("Starting new Minion worker in subprocess with $numcpus parallel jobs."); my $worker = $mojo->app->minion->worker; $worker->status->{jobs} = $numcpus; @@ -103,9 +103,9 @@ sub start_minion { my $proc = Proc::Simple->new(); $proc->start( sub { - $logger->info("Minion 工作线程 $$ 开始运行"); + $logger->info("Minion worker $$ started"); $worker->run; - $logger->info("Minion 工作线程 $$ 停止运行"); + $logger->info("Minion worker $$ stopped"); return 1; } ); @@ -123,7 +123,7 @@ sub _spawn { my ( $job, $pid ) = @_; my ( $id, $task ) = ( $job->id, $job->task ); my $logger = get_logger( "Minion Worker", "minion" ); - $job->app->log->debug(qq{进程 $pid 正在执行作业 "$id" 和任务 "$task"}); + $job->app->log->debug(qq{Process $pid is performing job "$id" with task "$task"}); } # Start Shinobu and return its Proc::Background object. @@ -134,7 +134,7 @@ sub start_shinobu { $proc->start( $^X, "./lib/Shinobu.pm" ); $proc->kill_on_destroy(0); - $mojo->LRR_LOGGER->debug( "Shinobu 工作进程新的 PID 为 " . $proc->pid ); + $mojo->LRR_LOGGER->debug( "Shinobu Worker new PID is " . $proc->pid ); # Freeze the process object in the PID file store \$proc, get_temp() . "/shinobu.pid"; @@ -159,7 +159,7 @@ sub shasum { }; if ($@) { - $logger->error( "创建哈希时出错" . $_[0] . " -- " . $@ ); + $logger->error( "Error building hash for " . $_[0] . " -- " . $@ ); return ""; } diff --git a/lib/LANraragi/Utils/Logging.pm b/lib/LANraragi/Utils/Logging.pm index 9643df9..21f64ae 100644 --- a/lib/LANraragi/Utils/Logging.pm +++ b/lib/LANraragi/Utils/Logging.pm @@ -3,7 +3,7 @@ package LANraragi::Utils::Logging; use strict; use warnings; use utf8; -use open ':std', ':encoding(UTF-8)'; + use feature 'say'; use POSIX; use FindBin; @@ -123,7 +123,7 @@ sub get_lines_from_file { return decode_utf8($res); } - return "找不到可以显示的日志!\n或者程序没有产生日志。"; + return "No logs to be found here!"; } diff --git a/lib/LANraragi/Utils/Minion.pm b/lib/LANraragi/Utils/Minion.pm index 6fd384d..008f872 100644 --- a/lib/LANraragi/Utils/Minion.pm +++ b/lib/LANraragi/Utils/Minion.pm @@ -2,7 +2,7 @@ package LANraragi::Utils::Minion; use strict; use warnings; -use utf8; + use Encode; use Mojo::UserAgent; use Parallel::Loops; @@ -56,14 +56,14 @@ sub add_tasks { my @keys = $redis->keys('????????????????????????????????????????'); $redis->quit(); - $logger->info("开始缩略图重新生成作业 (强制模式 = $force)"); + $logger->info("Starting thumbnail regen job (force = $force)"); my @errors = (); my $numCpus = Sys::CpuAffinity::getNumCpus(); my $pl = Parallel::Loops->new($numCpus); $pl->share( \@errors ); - $logger->debug("可用于处理的核心数量: $numCpus"); + $logger->debug("Number of available cores for processing: $numCpus"); my @sections = split_workload_by_cpu( $numCpus, @keys ); # Regen thumbnails for errythang if $force = 1, only missing thumbs otherwise @@ -80,12 +80,12 @@ sub add_tasks { unless ( $force == 0 && -e $thumbname ) { eval { - $logger->debug("正在重新生成:$id..."); + $logger->debug("Regenerating for $id..."); extract_thumbnail( $thumbdir, $id, 0, 1 ); }; if ($@) { - $logger->warn("生成缩略图时出错: $@"); + $logger->warn("Error while generating thumbnail: $@"); push @errors, $@; } } @@ -130,7 +130,7 @@ sub add_tasks { or die "Bullshit! File path could not be converted back to a byte sequence!" ; # This error happening would not make any sense at all so it deserves the EYE reference - $logger->info("正在处理上传的文件 $file..."); + $logger->info("Processing uploaded file $file..."); # Since we already have a file, this goes straight to handle_incoming_file. my ( $status, $id, $title, $message ) = LANraragi::Model::Upload::handle_incoming_file( $file, $catid, "" ); @@ -153,7 +153,7 @@ sub add_tasks { my $ua = Mojo::UserAgent->new; my $logger = get_logger( "Minion", "minion" ); - $logger->info("正在下载 $url..."); + $logger->info("Downloading url $url..."); # Keep a clean copy of the url for display and tagging my $og_url = $url; @@ -166,7 +166,7 @@ sub add_tasks { { success => 0, url => $og_url, id => $recorded_id, - message => "链接已被下载!" + message => "URL already downloaded!" } ); return; @@ -177,7 +177,7 @@ sub add_tasks { if ($downloader) { - $logger->info( "发现下载器 " . $downloader->{namespace} ); + $logger->info( "Found downloader " . $downloader->{namespace} ); # Use the downloader to transform the URL my $plugname = $downloader->{namespace}; @@ -197,15 +197,15 @@ sub add_tasks { $ua = $plugin_result->{user_agent}; $url = $plugin_result->{download_url}; - $logger->info("插件将 URL 转换为 $url"); + $logger->info("URL transformed by plugin to $url"); } else { - $logger->debug("找不到下载器,尝试直接下载 URL."); + $logger->debug("No downloader found, trying direct URL."); } # Download the URL eval { my $tempfile = LANraragi::Model::Upload::download_url( $url, $ua ); - $logger->info("URL将会被保存为 $tempfile "); + $logger->info("URL downloaded to $tempfile"); # Add the url as a source: tag my $tag = "source:$og_url"; @@ -243,7 +243,7 @@ sub add_tasks { my ( $namespace, $id, $scriptarg ) = @args; my $logger = get_logger( "Minion", "minion" ); - $logger->info("运行插件 $namespace..."); + $logger->info("Running plugin $namespace..."); my ( $pluginfo, $plugin_result ) = use_plugin( $namespace, $id, $scriptarg ); diff --git a/lib/LANraragi/Utils/Plugins.pm b/lib/LANraragi/Utils/Plugins.pm index e2dca64..69f4509 100644 --- a/lib/LANraragi/Utils/Plugins.pm +++ b/lib/LANraragi/Utils/Plugins.pm @@ -2,7 +2,7 @@ package LANraragi::Utils::Plugins; use strict; use warnings; - +use utf8; use Mojo::JSON qw(decode_json); use LANraragi::Utils::Database qw(redis_decode); diff --git a/lib/LANraragi/Utils/Routing.pm b/lib/LANraragi/Utils/Routing.pm index fdc1a79..44356db 100644 --- a/lib/LANraragi/Utils/Routing.pm +++ b/lib/LANraragi/Utils/Routing.pm @@ -2,7 +2,7 @@ package LANraragi::Utils::Routing; use strict; use warnings; - +use utf8; use Mojolicious::Plugin::Status; use Mojolicious::Plugin::Minion::Admin; diff --git a/lib/LANraragi/Utils/Tags.pm b/lib/LANraragi/Utils/Tags.pm index 541028b..9b2a131 100644 --- a/lib/LANraragi/Utils/Tags.pm +++ b/lib/LANraragi/Utils/Tags.pm @@ -2,7 +2,7 @@ package LANraragi::Utils::Tags; use strict; use warnings; - +use utf8; use feature "switch"; no warnings 'experimental'; diff --git a/lib/LANraragi/Utils/TempFolder.pm b/lib/LANraragi/Utils/TempFolder.pm index f4ca5b9..2dcf839 100644 --- a/lib/LANraragi/Utils/TempFolder.pm +++ b/lib/LANraragi/Utils/TempFolder.pm @@ -2,7 +2,7 @@ package LANraragi::Utils::TempFolder; use strict; use warnings; - +use utf8; use Cwd 'abs_path'; use FindBin; diff --git a/lib/Shinobu.pm b/lib/Shinobu.pm index 139042d..b512e4c 100644 --- a/lib/Shinobu.pm +++ b/lib/Shinobu.pm @@ -47,7 +47,7 @@ my $inotifysub = sub { my $e = shift; my $name = $e->path; my $type = $e->type; - $logger->debug("收到 $name 上的 inotify 事件 $type"); + $logger->debug("Received inotify event $type on $name"); if ( $type eq "create" || $type eq "modify" ) { new_file_callback($name); @@ -63,11 +63,11 @@ sub initialize_from_new_process { my $userdir = LANraragi::Model::Config->get_userdir; - $logger->info("Shinobu文件监视器启动."); - $logger->info("内容文件夹为: $userdir."); + $logger->info("Shinobu File Watcher started."); + $logger->info("Content folder is $userdir."); update_filemap(); - $logger->info("初始扫描完成! 将观监视器添加到内容文件夹以监视进一步的文件变动。"); + $logger->info("Initial scan complete! Adding watcher to content folder to monitor for further file edits."); # Add watcher to content directory my $contentwatcher = File::ChangeNotify->instantiate_watcher( @@ -75,17 +75,17 @@ sub initialize_from_new_process { filter => qr/\.(?:zip|rar|7z|tar|tar\.gz|lzma|xz|cbz|cbr|cb7|cbt|pdf|epub)$/i, follow_symlinks => 1, exclude => [ 'thumb', '.' ], #excluded subdirs - depth => 5, #扫描档案目录时扫描的最大目录深度 + depth => 10, #扫描档案目录时扫描的最大目录深度 ); my $class = ref($contentwatcher); - $logger->debug("文件监视器类名为: $class"); + $logger->debug("Watcher class is $class"); # Add watcher to tempfolder my $tempwatcher = File::ChangeNotify->instantiate_watcher( directories => [ get_temp() ] ); # manual event loop - $logger->info("全部初始化已经完成,文件监视器正在全力监测文件变动。"); + $logger->info("All done! Now dutifully watching your files. "); while (1) { @@ -107,22 +107,22 @@ sub initialize_from_new_process { # This computes IDs for all new archives and henceforth can get rather expensive! sub update_filemap { - $logger->info("正在扫描内容文件夹以查找更改..."); + $logger->info("Scanning content folder for changes..."); my $redis = LANraragi::Model::Config->get_redis_config; # Clear hash my $dirname = LANraragi::Model::Config->get_userdir; my @files; - # 在内容目录和子目录中获取所有文件。 + # Get all files in content directory and subdirectories. find( { wanted => sub { - return if -d $_; #目录当场被排除在外 + return if -d $_; #Directories are excluded on the spot return unless is_archive($_); - push @files, $_; #将文件推入数组 + push @files, $_; #Push files to array }, - no_chdir => 5, - follow_fast => 1 #扫描档案目录时扫描的最大目录深度 + no_chdir => 1, + follow_fast => 1 }, $dirname ); @@ -136,13 +136,13 @@ sub update_filemap { my @newfiles = grep { !$filemaphash{$_} } @files; my @deletedfiles = grep { !$fshash{$_} } @filemapfiles; - $logger->info( "找到 " . scalar @newfiles . " 个新文件." ); - $logger->info( scalar @deletedfiles . " 个文件在数据库里找到文件,但在文件系统上找不到文件。" ); + $logger->info( "Found " . scalar @newfiles . " new files." ); + $logger->info( scalar @deletedfiles . " files were found on the filemap but not on the filesystem." ); # Delete old files from filemap foreach my $deletedfile (@deletedfiles) { - $logger->debug("正在从数据库中删除 $deletedfile"); - $redis->hdel( "LRR_FILEMAP", $deletedfile ) || $logger->warn("无法从数据库中删除以前的文件数据。"); + $logger->debug("Removing $deletedfile from filemap."); + $redis->hdel( "LRR_FILEMAP", $deletedfile ) || $logger->warn("Couldn't delete previous filemap data."); } $redis->quit(); @@ -151,7 +151,7 @@ sub update_filemap { my $numCpus = Sys::CpuAffinity::getNumCpus(); my $pl = Parallel::Loops->new($numCpus); - $logger->debug("可用于处理的核心数量: $numCpus"); + $logger->debug("Number of available cores for processing: $numCpus"); my @sections = split_workload_by_cpu( $numCpus, @newfiles ); # Eval the parallelized file crawl to avoid taking down the entire process in case one of the forked processes dies @@ -166,7 +166,7 @@ sub update_filemap { eval { add_to_filemap( $redis, $file ); }; if ($@) { - $logger->error("扫描 $file 文件时出现错误: $@"); + $logger->error("Error scanning $file: $@"); } } $redis->quit(); @@ -175,7 +175,7 @@ sub update_filemap { }; if ($@) { - $logger->error("扫描内容文件夹时出错: $@"); + $logger->error("Error while scanning content folder: $@"); } } @@ -184,14 +184,14 @@ sub add_to_filemap ( $redis_cfg, $file ) { my $redis_arc = LANraragi::Model::Config->get_redis; if ( is_archive($file) ) { - $logger->debug("将 $file 添加到 Shinobu 数据库。"); + $logger->debug("Adding $file to Shinobu filemap."); #Freshly created files might not be complete yet. #We have to wait before doing any form of calculation. while (1) { last unless -e $file; # Sanity check to avoid sticking in this loop if the file disappears last if open( my $handle, '<', $file ); - $logger->debug("等待文件允许被打开"); + $logger->debug("Waiting for file to be openable"); sleep(1); } @@ -199,7 +199,7 @@ sub add_to_filemap ( $redis_cfg, $file ) { my $cnt = 0; while (1) { last if ( ( ( -s $file ) >= 512000 ) || $cnt >= 5 ); - $logger->debug("等待文件完全写入磁盘"); + $logger->debug("Waiting for file to be fully written"); sleep(1); $cnt++; } @@ -209,23 +209,23 @@ sub add_to_filemap ( $redis_cfg, $file ) { eval { $id = compute_id($file); }; if ($@) { - $logger->error("无法打开 $file 进行ID计算: $@"); - $logger->error("放弃将文件添加到数据库."); + $logger->error("Couldn't open $file for ID computation: $@"); + $logger->error("Giving up on adding it to the filemap."); return; } - $logger->debug("计算出的ID为: $id."); + $logger->debug("Computed ID is $id."); # If the id already exists on the server, throw a warning about duplicates if ( $redis_cfg->hexists( "LRR_FILEMAP", $file ) ) { my $filemap_id = $redis_cfg->hget( "LRR_FILEMAP", $file ); - $logger->debug("$file 文件已经存在于数据库中!"); + $logger->debug("$file was logged but is already in the filemap!"); if ( $filemap_id ne $id ) { - $logger->debug("$file 文件的ID与数据库中现有的ID不同! ($filemap_id)"); - $logger->info("$file 文件已被修改,已将其在数据库中的ID从 $filemap_id 修改为 $id."); + $logger->debug("$file has a different ID than the one in the filemap! ($filemap_id)"); + $logger->info("$file has been modified, updating its ID from $filemap_id to $id."); change_archive_id( $filemap_id, $id ); @@ -233,7 +233,7 @@ sub add_to_filemap ( $redis_cfg, $file ) { $redis_cfg->hset( "LRR_FILEMAP", $file, $id ); } else { $logger->debug( - "$file 文件的ID与数据库内的ID一致. 可能是重复的 inotify 事件触发? 为了防止出现其他意外情况现在开始清理缓存"); + "$file has the same ID as the one in the filemap. Duplicate inotify events? Cleaning cache just to make sure"); invalidate_cache(); } @@ -251,12 +251,12 @@ sub add_to_filemap ( $redis_cfg, $file ) { #Update the real file path and title if they differ from the saved one #This is meant to always track the current filename for the OS. unless ( $file eq $filecheck ) { - $logger->debug("在数据库和文件系统之间检测到文件名差异!"); - $logger->debug("文件系统: $file"); - $logger->debug("数据库内: $filecheck"); + $logger->debug("File name discrepancy detected between DB and filesystem!"); + $logger->debug("Filesystem: $file"); + $logger->debug("Database: $filecheck"); my ( $name, $path, $suffix ) = fileparse( $file, qr/\.[^.]*/ ); - $redis_arc->hset( $id, " 所属文件: ", $file ); - $redis_arc->hset( $id, " 所属名字: ", redis_encode($name) ); + $redis_arc->hset( $id, "file", $file ); + $redis_arc->hset( $id, "name", redis_encode($name) ); $redis_arc->wait_all_responses; invalidate_cache(); } @@ -268,7 +268,7 @@ sub add_to_filemap ( $redis_cfg, $file ) { # Set pagecount in case it's not already there unless ( $redis_arc->hget( $id, "pagecount" ) ) { - $logger->debug("未计算 $id 的页数,立即执行!"); + $logger->debug("Pagecount not calculated for $id, doing it now!"); LANraragi::Utils::Database::add_pagecount( $redis_arc, $id ); } @@ -279,7 +279,7 @@ sub add_to_filemap ( $redis_cfg, $file ) { invalidate_cache(); } } else { - $logger->debug("$file 未被识别为存档,正在跳过。"); + $logger->debug("$file not recognized as archive, skipping."); } $redis_arc->quit; } @@ -288,7 +288,7 @@ sub add_to_filemap ( $redis_cfg, $file ) { # "handles the addition of new subdirectories by adding them to the watch list" sub new_file_callback ($name) { - $logger->debug("检测到新文件: $name"); + $logger->debug("New file detected: $name"); unless ( -d $name ) { my $redis = LANraragi::Model::Config->get_redis_config; @@ -296,7 +296,7 @@ sub new_file_callback ($name) { $redis->quit(); if ($@) { - $logger->error("处理新文件时出错: $@"); + $logger->error("Error while handling new file: $@"); } } } @@ -305,7 +305,7 @@ sub new_file_callback ($name) { # Deleted subdirectories trigger deleted events for every file deleted. sub deleted_file_callback ($name) { - $logger->info("$name 已从内容文件夹中删除!"); + $logger->info("$name was deleted from the content folder!"); unless ( -d $name ) { my $redis = LANraragi::Model::Config->get_redis_config; @@ -322,7 +322,7 @@ sub deleted_file_callback ($name) { sub add_new_file ( $id, $file ) { my $redis = LANraragi::Model::Config->get_redis; - $logger->info("添加 ID 为 $id 的新文件 $file"); + $logger->info("Adding new file $file with ID $id"); eval { LANraragi::Utils::Database::add_archive_to_redis( $id, $file, $redis ); @@ -334,7 +334,7 @@ sub add_new_file ( $id, $file ) { }; if ($@) { - $logger->error("添加文件时出错: $@"); + $logger->error("Error while adding file: $@"); } $redis->quit; } diff --git a/package.json b/package.json index 2c90c3c..699e79e 100644 --- a/package.json +++ b/package.json @@ -1,8 +1,8 @@ { "name": "lanraragi", "version": "0.9.10", - "version_name": "行尸走肉", - "description": "我一世英名恐怕要毁在日本文化的影响下了!", + "version_name": "Dead Man Walking", + "description": "I'm under Japanese influence and my honor's at stake!", "scripts": { "test": "prove -r -l -v tests/", "lanraragi-installer": "perl ./tools/install.pl", @@ -11,21 +11,21 @@ "dev-server": "perl ./script/launcher.pl -m -v ./script/lanraragi", "dev-server-verbose": "export LRR_DEVSERVER=1 && perl ./script/launcher.pl -m -v ./script/lanraragi", "kill-workers": "(kill -15 `cat ./public/temp/shinobu.pid-s6` || true) && (kill -15 `cat ./public/temp/minion.pid-s6` || true) && (pkill -9 -f ./script/lanraragi || true)", - "docker-build": "docker build -t windycloud/lanraragi_cn:dev -f ./tools/build/docker/Dockerfile .", + "docker-build": "docker build -t difegue/lanraragi -f ./tools/build/docker/Dockerfile .", "critic": "perlcritic ./lib/* ./script/* ./tools/install.pl", "backup-db": "perl ./script/backup", "get-version": "perl ./script/get_version" }, "repository": { "type": "git", - "url": "git+https://github.com/WindyCloudCute/LANraragi_Chinese.git" + "url": "git+https://github.com/Difegue/LANraragi.git" }, "author": "dfug", "license": "MIT", "bugs": { - "url": "https://github.com/WindyCloudCute/LANraragi_Chinese/issues" + "url": "https://github.com/Difegue/LANraragi/issues" }, - "homepage": "https://github.com/WindyCloudCute/LANraragi_Chinesei#readme", + "homepage": "https://github.com/Difegue/LANraragi#readme", "dependencies": { "@fortawesome/fontawesome-free": "^6.2.1", "@jcubic/tagger": "^0.4.2", @@ -52,4 +52,4 @@ "eslint-config-airbnb-base": "^15.0.0", "eslint-plugin-import": "^2.26.0" } -} +} \ No newline at end of file diff --git a/public/themes/modern_clear.css b/public/themes/modern_clear.css index 47aacbf..f3dc142 100644 --- a/public/themes/modern_clear.css +++ b/public/themes/modern_clear.css @@ -201,6 +201,18 @@ table.itg th { color: #34495E !important; } +.caption-tags>*>*>span { + color: #34495E !important; +} + +#archive-categories .gt a { + color: #E1E7E9; +} + +#archive-categories .gt a:hover { + color: #ed2553; +} + .tippy-arrow { color: #E1E7E9; } diff --git a/script/launcher.pl b/script/launcher.pl index 325ba91..4dd4cf8 100644 --- a/script/launcher.pl +++ b/script/launcher.pl @@ -3,12 +3,12 @@ use strict; use warnings; use Cwd 'abs_path'; + use Mojo::Base -strict; use Mojo::Server::Morbo; use Mojo::Server::Prefork; use Mojo::Util qw(extract_usage getopt); use File::Path qw(make_path); -use utf8; getopt 'm|morbo' => \my $morbo, @@ -55,7 +55,7 @@ $backend->daemon->listen(@listen); $backend->run($app); } else { - print "服务器PID存放在 " . $hypno_pid . "\n"; + print "Server PID will be at " . $hypno_pid . "\n"; $backend = Mojo::Server::Prefork->new( keep_alive_timeout => 30 ); $backend->pid_file($hypno_pid); diff --git a/tools/_screenshots/archive_list.png b/tools/_screenshots/archive_list.png index 3a1647a..b6a512a 100644 Binary files a/tools/_screenshots/archive_list.png and b/tools/_screenshots/archive_list.png differ diff --git a/tools/build/docker/Dockerfile-dev b/tools/build/docker/Dockerfile-dev index 83be840..846765c 100644 --- a/tools/build/docker/Dockerfile-dev +++ b/tools/build/docker/Dockerfile-dev @@ -7,7 +7,7 @@ EXPOSE 3000 # Enable UTF-8 (might not do anything extra on alpine tho) ENV LC_ALL=en_US.UTF-8 LANG=en_US.UTF-8 LANGUAGE=en_US.UTF-8 \ # rootless user id - LRR_UID=1000 LRR_GID=1000 \ + LRR_UID=0 LRR_GID=0 \ # Environment variables overridable by the user on container deployment LRR_NETWORK=http://*:3000 \ # extra variables @@ -31,7 +31,7 @@ WORKDIR /tmp/lrr #This allows for Docker cache to preserve cpan dependencies COPY --chown=root:root /tools/cpanfile /tools/install.pl /tools/build/docker/install-everything.sh tools/ COPY --chown=root:root /package.json package.json -COPY --chown=root:root /package-lock.json package-lock.json +COPY --chown=root:root /package-lock.json package-lock.json # Run the install script as root, in dev mode to prevent wget etc from being uninstalled RUN sh ./tools/install-everything.sh -d diff --git a/tools/build/docker/docker-compose.yml b/tools/build/docker/docker-compose.yml index c98f590..1ab23ac 100644 --- a/tools/build/docker/docker-compose.yml +++ b/tools/build/docker/docker-compose.yml @@ -4,9 +4,9 @@ services: lanraragi: build: dockerfile: tools/build/docker/Dockerfile-dev - context: ../../.. + context: ../.. volumes: - - ../../../:/root/lanraragi + - ../../:/root/lanraragi ports: - "3000:3000" environment: diff --git a/tools/build/docker/s6/cont-init.d/01-lrr-setup b/tools/build/docker/s6/cont-init.d/01-lrr-setup index 621e345..7c71116 100755 --- a/tools/build/docker/s6/cont-init.d/01-lrr-setup +++ b/tools/build/docker/s6/cont-init.d/01-lrr-setup @@ -24,10 +24,10 @@ chmod -R u+rwx /root/lanraragi/database if [ "$FIX_PERMS" -eq 1 ]; then echo "Fixing permissions, hold on!" -#Ensure thumbnail folder is writable -chown -R root /root/lanraragi/content/thumb -find /root/lanraragi/content/thumb -type f -exec chmod u+rw {} \; -find /root/lanraragi/content/thumb -type d -exec chmod u+rwx {} \; + #Ensure thumbnail folder is writable + chown -R root /root/lanraragi/content/thumb + find /root/lanraragi/content/thumb -type f -exec chmod u+rw {} \; + find /root/lanraragi/content/thumb -type d -exec chmod u+rwx {} \; # Ensure the rest of the content folder is at least readable find /root/lanraragi/content -name thumb -prune -o -type f -exec chmod u+r {} \; diff --git a/tools/install.pl b/tools/install.pl index 0fb709c..0f88d6c 100755 --- a/tools/install.pl +++ b/tools/install.pl @@ -2,11 +2,11 @@ use strict; use warnings; - +use utf8; use open ':std', ':encoding(UTF-8)'; use Cwd; use Config; -use utf8; + use File::Copy; use feature qw(say); use File::Path qw(make_path);