diff options
author | mms <git@sapka.me> | 2025-01-08 22:20:17 +0100 |
---|---|---|
committer | mms <git@sapka.me> | 2025-01-08 22:20:17 +0100 |
commit | 3d13bedaaffdae466621788d808a6b71b9ed9f59 (patch) | |
tree | 5e941bb44ad7cd37252459bfe48d57778b76342a /new/lib/crys/processors/mixins | |
parent | 4004a55b0e324c35cbc7d58b831e49efd484ab93 (diff) |
feat: batch-first
Diffstat (limited to 'new/lib/crys/processors/mixins')
-rw-r--r-- | new/lib/crys/processors/mixins/common_functions.rb | 36 | ||||
-rw-r--r-- | new/lib/crys/processors/mixins/common_parts.rb | 18 |
2 files changed, 54 insertions, 0 deletions
diff --git a/new/lib/crys/processors/mixins/common_functions.rb b/new/lib/crys/processors/mixins/common_functions.rb new file mode 100644 index 00000000..52ce65ac --- /dev/null +++ b/new/lib/crys/processors/mixins/common_functions.rb @@ -0,0 +1,36 @@ +# frozen_string_literal: true + +require 'rss' + +module Crys + module CommonFunctions + def project_root + File.dirname(File.dirname(File.dirname(File.dirname(File.dirname(File.dirname(File.expand_path(__FILE__))))))).to_s + end + + def process_image(file:, width: :auto) + full_path = "#{image_dir}/#{file}" + + image = ::Crys::ImageProcessor.new(path: full_path, filename: file, width: width) + assets << image + + image + end + + def fetch_rss(url: nil, name: nil) + if name + path = case name + when :main + '/public/index.xml' + end + + rss = File.read(project_root + path) + else + puts url + + end + + RSS::Parser.parse(rss) + end + end +end diff --git a/new/lib/crys/processors/mixins/common_parts.rb b/new/lib/crys/processors/mixins/common_parts.rb new file mode 100644 index 00000000..a6c2dc16 --- /dev/null +++ b/new/lib/crys/processors/mixins/common_parts.rb @@ -0,0 +1,18 @@ +# frozen_string_literal: true + +module Crys + module CommonParts + def webbutton(file:, url:, alt:) + full_path = "#{image_dir}/buttons/#{file}" + + image = ::Crys::ImageProcessor.new(path: full_path, filename: file, width: 88) + assets << image + + code = ERB.new <<~EOF + <a href="<%=url%>"><img src="<%=image.relative_path%>" width="88" height="31" class="webbutton" alt="<%=alt%>"></a> + EOF + + code.result(binding) + end + end +end |