dawarich/lib/tasks/webmanifest.rake
Evgenii Burmakin 18b13fb915
Add yearly digest (#2073)
* Add yearly digest

* Rename YearlyDigests to Users::Digests

* Minor changes

* Update yearly digest layout and styles

* Add flags and chart to email

* Update colors

* Fix layout of stats in yearly digest view

* Remove cron job for yearly digest scheduling

* Update CHANGELOG.md

* Update digest email setting handling

* Allow sharing digest for 1 week or 1 month

* Change Digests Distance to Bigint

* Fix settings page
2025-12-28 17:33:35 +01:00

45 lines
1.4 KiB
Ruby

# frozen_string_literal: true
namespace :webmanifest do
desc 'Generate site.webmanifest in public directory with correct asset paths'
task generate: :environment do
require 'erb'
# Make sure assets are compiled first by loading the manifest
Rails.application.assets_manifest.assets
# Get the correct asset paths
icon_192_path = ActionController::Base.helpers.asset_path('favicon/android-chrome-192x192.png')
icon_512_path = ActionController::Base.helpers.asset_path('favicon/android-chrome-512x512.png')
# Generate the manifest content
manifest_content = {
"name": 'Dawarich',
"short_name": 'Dawarich',
"icons": [
{
"src": icon_192_path,
"sizes": '192x192',
"type": 'image/png'
},
{
"src": icon_512_path,
"sizes": '512x512',
"type": 'image/png'
}
],
"theme_color": '#ffffff',
"background_color": '#ffffff',
"display": 'standalone'
}.to_json
# Write to public/site.webmanifest
File.write(Rails.root.join('public/site.webmanifest'), manifest_content)
puts 'Generated public/site.webmanifest with correct asset paths'
end
end
# Hook to automatically generate webmanifest after assets:precompile
# Rake::Task['assets:precompile'].enhance do
# Rake::Task['webmanifest:generate'].invoke
# end