diff --git a/app/views/common/_calendar.html.erb b/app/views/common/_calendar.html.erb index 393a09a..704f865 100644 --- a/app/views/common/_calendar.html.erb +++ b/app/views/common/_calendar.html.erb @@ -1,5 +1,3 @@ -<%= javascript_include_tag('dynamic_favicon', plugin: :redmine_qbo_calendar) %> - <% # Check if toggles are active via query params only_appointments = params[:only_appointments] == '1' diff --git a/app/views/customer_appointments/edit.html.erb b/app/views/customer_appointments/edit.html.erb index 0084ae4..8db5cd9 100644 --- a/app/views/customer_appointments/edit.html.erb +++ b/app/views/customer_appointments/edit.html.erb @@ -1,5 +1,3 @@ -<%= javascript_include_tag('dynamic_favicon', plugin: :redmine_qbo_calendar) %> -

Edit Appointment

<%= render "form" %> \ No newline at end of file diff --git a/app/views/customer_appointments/new.html.erb b/app/views/customer_appointments/new.html.erb index b440001..852510f 100644 --- a/app/views/customer_appointments/new.html.erb +++ b/app/views/customer_appointments/new.html.erb @@ -1,5 +1,3 @@ -<%= javascript_include_tag('dynamic_favicon', plugin: :redmine_qbo_calendar) %> -

New Appointment

<%= render "form" %> \ No newline at end of file diff --git a/app/views/customer_appointments/show.html.erb b/app/views/customer_appointments/show.html.erb index 57950a9..6ad3250 100644 --- a/app/views/customer_appointments/show.html.erb +++ b/app/views/customer_appointments/show.html.erb @@ -1,5 +1,3 @@ -<%= javascript_include_tag('dynamic_favicon', plugin: :redmine_qbo_calendar) %> -
<%= link_to issues_calendar_path do %> <%= l(:button_calendar) %> diff --git a/assets/images/favicons/1.png b/assets/images/favicons/1.png new file mode 100644 index 0000000..29f030f Binary files /dev/null and b/assets/images/favicons/1.png differ diff --git a/assets/images/favicons/10.png b/assets/images/favicons/10.png new file mode 100644 index 0000000..cf7cf32 Binary files /dev/null and b/assets/images/favicons/10.png differ diff --git a/assets/images/favicons/11.png b/assets/images/favicons/11.png new file mode 100644 index 0000000..8d2e7dd Binary files /dev/null and b/assets/images/favicons/11.png differ diff --git a/assets/images/favicons/12.png b/assets/images/favicons/12.png new file mode 100644 index 0000000..e34acae Binary files /dev/null and b/assets/images/favicons/12.png differ diff --git a/assets/images/favicons/13.png b/assets/images/favicons/13.png new file mode 100644 index 0000000..eefd62a Binary files /dev/null and b/assets/images/favicons/13.png differ diff --git a/assets/images/favicons/14.png b/assets/images/favicons/14.png new file mode 100644 index 0000000..2a08ce9 Binary files /dev/null and b/assets/images/favicons/14.png differ diff --git a/assets/images/favicons/15.png b/assets/images/favicons/15.png new file mode 100644 index 0000000..86281dc Binary files /dev/null and b/assets/images/favicons/15.png differ diff --git a/assets/images/favicons/16.png b/assets/images/favicons/16.png new file mode 100644 index 0000000..2e20f31 Binary files /dev/null and b/assets/images/favicons/16.png differ diff --git a/assets/images/favicons/17.png b/assets/images/favicons/17.png new file mode 100644 index 0000000..45eda6b Binary files /dev/null and b/assets/images/favicons/17.png differ diff --git a/assets/images/favicons/18.png b/assets/images/favicons/18.png new file mode 100644 index 0000000..ba7ebd4 Binary files /dev/null and b/assets/images/favicons/18.png differ diff --git a/assets/images/favicons/19.png b/assets/images/favicons/19.png new file mode 100644 index 0000000..40a92b5 Binary files /dev/null and b/assets/images/favicons/19.png differ diff --git a/assets/images/favicons/2.png b/assets/images/favicons/2.png new file mode 100644 index 0000000..88ff679 Binary files /dev/null and b/assets/images/favicons/2.png differ diff --git a/assets/images/favicons/20.png b/assets/images/favicons/20.png new file mode 100644 index 0000000..93419c4 Binary files /dev/null and b/assets/images/favicons/20.png differ diff --git a/assets/images/favicons/21.png b/assets/images/favicons/21.png new file mode 100644 index 0000000..16be4da Binary files /dev/null and b/assets/images/favicons/21.png differ diff --git a/assets/images/favicons/22.png b/assets/images/favicons/22.png new file mode 100644 index 0000000..a23f378 Binary files /dev/null and b/assets/images/favicons/22.png differ diff --git a/assets/images/favicons/23.png b/assets/images/favicons/23.png new file mode 100644 index 0000000..aa01867 Binary files /dev/null and b/assets/images/favicons/23.png differ diff --git a/assets/images/favicons/24.png b/assets/images/favicons/24.png new file mode 100644 index 0000000..4e721cd Binary files /dev/null and b/assets/images/favicons/24.png differ diff --git a/assets/images/favicons/25.png b/assets/images/favicons/25.png new file mode 100644 index 0000000..d16ab07 Binary files /dev/null and b/assets/images/favicons/25.png differ diff --git a/assets/images/favicons/26.png b/assets/images/favicons/26.png new file mode 100644 index 0000000..a056897 Binary files /dev/null and b/assets/images/favicons/26.png differ diff --git a/assets/images/favicons/27.png b/assets/images/favicons/27.png new file mode 100644 index 0000000..74bfe29 Binary files /dev/null and b/assets/images/favicons/27.png differ diff --git a/assets/images/favicons/28.png b/assets/images/favicons/28.png new file mode 100644 index 0000000..afcb4b8 Binary files /dev/null and b/assets/images/favicons/28.png differ diff --git a/assets/images/favicons/29.png b/assets/images/favicons/29.png new file mode 100644 index 0000000..748e307 Binary files /dev/null and b/assets/images/favicons/29.png differ diff --git a/assets/images/favicons/3.png b/assets/images/favicons/3.png new file mode 100644 index 0000000..a29d9ad Binary files /dev/null and b/assets/images/favicons/3.png differ diff --git a/assets/images/favicons/30.png b/assets/images/favicons/30.png new file mode 100644 index 0000000..1fb1317 Binary files /dev/null and b/assets/images/favicons/30.png differ diff --git a/assets/images/favicons/31.png b/assets/images/favicons/31.png new file mode 100644 index 0000000..90fa132 Binary files /dev/null and b/assets/images/favicons/31.png differ diff --git a/assets/images/favicons/4.png b/assets/images/favicons/4.png new file mode 100644 index 0000000..bcadd15 Binary files /dev/null and b/assets/images/favicons/4.png differ diff --git a/assets/images/favicons/5.png b/assets/images/favicons/5.png new file mode 100644 index 0000000..4960708 Binary files /dev/null and b/assets/images/favicons/5.png differ diff --git a/assets/images/favicons/6.png b/assets/images/favicons/6.png new file mode 100644 index 0000000..eb131fa Binary files /dev/null and b/assets/images/favicons/6.png differ diff --git a/assets/images/favicons/7.png b/assets/images/favicons/7.png new file mode 100644 index 0000000..07a9f1f Binary files /dev/null and b/assets/images/favicons/7.png differ diff --git a/assets/images/favicons/8.png b/assets/images/favicons/8.png new file mode 100644 index 0000000..a5c9c86 Binary files /dev/null and b/assets/images/favicons/8.png differ diff --git a/assets/images/favicons/9.png b/assets/images/favicons/9.png new file mode 100644 index 0000000..7c8bcf9 Binary files /dev/null and b/assets/images/favicons/9.png differ diff --git a/assets/javascripts/dynamic_favicon.js b/assets/javascripts/dynamic_favicon.js deleted file mode 100644 index ffb57b1..0000000 --- a/assets/javascripts/dynamic_favicon.js +++ /dev/null @@ -1,140 +0,0 @@ -(function() { - 'use strict'; - - console.log('[Redmine QBO Calendar] dynamic_favicon.js loaded (Simplified Canvas PNG)'); - - const FAVICON_ID = 'redmine-qbo-calendar-favicon'; - - function generatePngFaviconUrl(day, callback) { - const svg = ` - - - - - - - - - - - - - - OSOR - - - - ${day} - - - - `; - - const cleanSvg = svg.replace(/\n/g, '').replace(/\s+/g, ' ').trim(); - const svgDataUrl = 'data:image/svg+xml;base64,' + btoa(unescape(encodeURIComponent(cleanSvg))); - - const canvas = document.createElement('canvas'); - canvas.width = 64; - canvas.height = 64; - const ctx = canvas.getContext('2d'); - - const img = new Image(); - - img.onload = function() { - ctx.drawImage(img, 0, 0, 64, 64); - const pngDataUrl = canvas.toDataURL('image/png'); - callback(pngDataUrl); - }; - - img.src = svgDataUrl; - } - - function setFavicon() { - const day = new Date().getDate(); - - generatePngFaviconUrl(day, function(newFaviconUrl) { - const existingIcons = document.querySelectorAll('link[rel*="icon"]'); - - if (existingIcons.length > 0) { - existingIcons.forEach(function(icon) { - icon.type = 'image/png'; - icon.rel = 'icon'; - icon.href = newFaviconUrl; - }); - } else { - const favicon = document.createElement('link'); - favicon.id = FAVICON_ID; - favicon.rel = 'icon'; - favicon.type = 'image/png'; - favicon.href = newFaviconUrl; - document.head.appendChild(favicon); - } - - console.log( - '[OSOR Calendar] favicon updated (Simplified PNG)', - { day: day } - ); - }); - } - - function initialize() { - console.log('[OSOR Calendar] initializing favicon'); - setTimeout(setFavicon, 150); - } - - if (document.readyState === 'loading') { - document.addEventListener( - 'DOMContentLoaded', - initialize - ); - } else { - initialize(); - } - -})(); \ No newline at end of file diff --git a/lib/redmine_qbo_calendar.rb b/lib/redmine_qbo_calendar.rb index be3f6ab..3001bb3 100644 --- a/lib/redmine_qbo_calendar.rb +++ b/lib/redmine_qbo_calendar.rb @@ -14,6 +14,7 @@ module RedmineQboCalendar Customer.prepend(RedmineQboCalendar::Patches::CustomerPatch) User.prepend(RedmineQboCalendar::Patches::UserPatch) CalendarsController.prepend(RedmineQboCalendar::Patches::CalendarsControllerPatch) + ApplicationHelper.prepend(RedmineQboCalendar::Patches::ApplicationHelperPatch) # Hooks RedmineQboCalendar::Hooks::ViewHookListener diff --git a/lib/redmine_qbo_calendar/patches/application_helper_patch.rb b/lib/redmine_qbo_calendar/patches/application_helper_patch.rb new file mode 100644 index 0000000..71282f8 --- /dev/null +++ b/lib/redmine_qbo_calendar/patches/application_helper_patch.rb @@ -0,0 +1,39 @@ +#The MIT License (MIT) +# +#Copyright (c) 2026 rick barrette +# +#Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: +# +#The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. +# +#THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +module RedmineQboCalendar + module Patches + module ApplicationHelperPatch + + def favicon + if calendar_or_appointments_view? + tag.link(rel: 'icon', type: 'image/png', href: favicon_path) + else + # Force an explicit type tag so the browser replaces the PNG on non-calendar pages + tag.link(rel: 'icon', type: 'image/x-icon', href: favicon_path) + end + end + + def favicon_path + if calendar_or_appointments_view? + image_path("plugin_assets/redmine_qbo_calendar/favicons/#{Date.current.day}.png") + else + super + end + end + + private + + def calendar_or_appointments_view? + controller_name == 'calendars' || controller_name == 'customer_appointments' + end + end + end +end \ No newline at end of file