Ignore exported avatar images

This should enforce the build process to really export the images.
This commit is contained in:
Gabriel Arazas 2023-05-23 19:01:27 +08:00
parent 24b4db6783
commit 448527c85b
No known key found for this signature in database
GPG Key ID: ADE0C41DAB221FCC
13 changed files with 10 additions and 3 deletions

5
.gitignore vendored
View File

@ -3,7 +3,10 @@
.direnv .direnv
# The code workspace used for the dedicated branches for certain content. # The code workspace used for the dedicated branches for certain content.
./code-workspace/ /code-workspace/
# The exported avatar images.
/static/icons/avatars/
# Certain files just need to be ignored. # Certain files just need to be ignored.
/layouts/partials/openring.html /layouts/partials/openring.html

View File

@ -1,5 +1,6 @@
# frozen_string_literal: true # frozen_string_literal: true
require 'fileutils'
require 'json' require 'json'
require 'open3' require 'open3'
require 'shellwords' require 'shellwords'
@ -26,7 +27,10 @@ desc 'Export the avatar images'
task :export_avatars, [:base_dir, :output_dir, :output_extension] do |_, args| task :export_avatars, [:base_dir, :output_dir, :output_extension] do |_, args|
args.with_defaults(base_dir: './assets/svg/', output_dir: './static/icons/', output_extension: 'avif') args.with_defaults(base_dir: './assets/svg/', output_dir: './static/icons/', output_extension: 'avif')
Dir.glob('avatars/**/*.svg', base: args.base_dir) do |f| Dir.glob('avatars/**/*.svg', base: args.base_dir) do |f|
output_file = "#{File.dirname(f)}/#{File.basename(f, '.svg')}.#{args.output_extension}" dirname = File.dirname f
output_file = "#{dirname}/#{File.basename(f, '.svg')}.#{args.output_extension}"
FileUtils.mkdir_p "#{args.output_dir}#{dirname}", verbose: true
sh "magick #{args.base_dir}#{f} -quality 30 #{args.output_dir}#{output_file}" sh "magick #{args.base_dir}#{f} -quality 30 #{args.output_dir}#{output_file}"
end end
end end
@ -52,7 +56,7 @@ task :build_webring, [:limit, :input, :output, :file] do |_, args|
end end
desc 'Create a web server' desc 'Create a web server'
task :serve do task :serve => [:export_avatars] do
sh 'nix develop -c hugo serve --buildFuture --verboseLog --destination public' sh 'nix develop -c hugo serve --buildFuture --verboseLog --destination public'
end end