Files
redux-scraper/app/helpers/domain/e621/posts_helper.rb
Dylan Knutson 4af584fffd Add GoodJob logging enhancements and custom styles
- Introduced a new `good_job_custom.css` file for custom styling of GoodJob logs.
- Added a new `pixiv.png` icon for domain-specific logging in the `e621` posts helper.
- Enhanced the `GoodJobHelper` module to parse ANSI escape codes for better log formatting.
- Implemented a new `GoodJobExecutionLogLinesCollection` model to store log lines associated with job executions.
- Updated views to display job execution details and logs with improved formatting and styling.
- Refactored `ColorLogger` to support log line accumulation for better log management.

These changes aim to improve the logging experience and visual representation of job execution details in the GoodJob dashboard.
2025-01-03 05:58:22 +00:00

97 lines
2.4 KiB
Ruby

# typed: false
module Domain::E621::PostsHelper
def icon_asset_for_url(url)
domain = extract_domain(url)
return nil unless domain
domain_patterns = {
%w[*.e621.net e621.net] => "e621.png",
%w[*.furaffinity.net furaffinity.net] => "fa.png",
%w[*.bsky.app bsky.app] => "bsky.png",
%w[*.itaku.ee itaku.ee] => "itaku.png",
%w[*.deviantart.com deviantart.com *.wixmp.com] => "deviantart.png",
%w[*.twitter.com twitter.com *.x.com x.com] => "x-twitter.png",
%w[*.inkbunny.net inkbunny.net *.ib.metapix.net ib.metapix.net] =>
"inkbunny.png",
%w[*.newgrounds.com newgrounds.com] => "newgrounds.png",
%w[*.patreon.com patreon.com] => "patreon.png",
%w[*.pixiv.net pixiv.net *.pximg.net pximg.net] => "pixiv.png",
}
domain_patterns.each do |patterns, icon|
patterns.each do |pattern|
if File.fnmatch?(pattern, domain, File::FNM_PATHNAME)
return asset_path("domain-icons/#{icon}")
end
end
end
nil
end
def tag_category_tw_class(category)
case category.to_sym
when :general
"bg-blue-300" # Light blue
when :artist
"bg-indigo-300" # Light indigo
when :copyright
"bg-purple-300" # Light purple
when :character
"bg-green-300" # Light green
when :species
"bg-teal-300" # Light teal
when :invalid
"bg-slate-300" # Medium gray
when :meta
"bg-amber-300" # Light amber
when :lore
"bg-cyan-300" # Light cyan
else
"bg-white" # White (default)
end
end
def tag_category_order
%i[artist copyright character species general meta lore invalid]
end
def font_awesome_category_icon(category)
case category.to_sym
when :artist
"fa-brush"
when :species
"fa-paw"
when :character
"fa-user"
when :copyright
"fa-copyright"
when :general
"fa-tag"
when :lore
"fa-book"
when :meta
"fa-info"
when :invalid
"fa-ban"
end
end
def fa_post_for_source(source)
uri = URI.parse(source)
return unless %w[www.furaffinity.net furaffinity.net].include?(uri.host)
fa_id = uri.path.match(%r{/view/(\d+)})[1]
return unless fa_id
Domain::Fa::Post.find_by(fa_id: fa_id)
rescue StandardError
nil
end
private
def extract_domain(url)
URI.parse(url).host
rescue URI::InvalidURIError
nil
end
end