update the favicon without java script
No files matched your search
@@ -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'
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
<%= javascript_include_tag('dynamic_favicon', plugin: :redmine_qbo_calendar) %>
|
||||
|
||||
<h2>Edit Appointment</h2>
|
||||
|
||||
<%= render "form" %>
|
||||
@@ -1,5 +1,3 @@
|
||||
<%= javascript_include_tag('dynamic_favicon', plugin: :redmine_qbo_calendar) %>
|
||||
|
||||
<h2>New Appointment</h2>
|
||||
|
||||
<%= render "form" %>
|
||||
@@ -1,5 +1,3 @@
|
||||
<%= javascript_include_tag('dynamic_favicon', plugin: :redmine_qbo_calendar) %>
|
||||
|
||||
<div class="contextual">
|
||||
<%= link_to issues_calendar_path do %>
|
||||
<i class="fa-regular fa-calendar-days"></i> <%= l(:button_calendar) %>
|
||||
|
||||
|
After Width: | Height: | Size: 1.2 KiB |
|
After Width: | Height: | Size: 1.9 KiB |
|
After Width: | Height: | Size: 1.3 KiB |
|
After Width: | Height: | Size: 1.8 KiB |
|
After Width: | Height: | Size: 1.9 KiB |
|
After Width: | Height: | Size: 1.5 KiB |
|
After Width: | Height: | Size: 1.8 KiB |
|
After Width: | Height: | Size: 1.9 KiB |
|
After Width: | Height: | Size: 1.5 KiB |
|
After Width: | Height: | Size: 2.0 KiB |
|
After Width: | Height: | Size: 2.0 KiB |
|
After Width: | Height: | Size: 1.6 KiB |
|
After Width: | Height: | Size: 2.2 KiB |
|
After Width: | Height: | Size: 1.8 KiB |
|
After Width: | Height: | Size: 1.7 KiB |
|
After Width: | Height: | Size: 2.2 KiB |
|
After Width: | Height: | Size: 1.9 KiB |
|
After Width: | Height: | Size: 2.1 KiB |
|
After Width: | Height: | Size: 2.2 KiB |
|
After Width: | Height: | Size: 1.9 KiB |
|
After Width: | Height: | Size: 2.2 KiB |
|
After Width: | Height: | Size: 2.3 KiB |
|
After Width: | Height: | Size: 1.7 KiB |
|
After Width: | Height: | Size: 2.3 KiB |
|
After Width: | Height: | Size: 1.9 KiB |
|
After Width: | Height: | Size: 1.3 KiB |
|
After Width: | Height: | Size: 1.6 KiB |
|
After Width: | Height: | Size: 1.8 KiB |
|
After Width: | Height: | Size: 1.3 KiB |
|
After Width: | Height: | Size: 1.8 KiB |
|
After Width: | Height: | Size: 1.8 KiB |
@@ -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 = `
|
||||
<svg xmlns="http://www.w3.org/2000/svg"
|
||||
width="64" height="64" viewBox="0 0 64 64">
|
||||
|
||||
<rect
|
||||
x="3"
|
||||
y="4"
|
||||
width="58"
|
||||
height="57"
|
||||
rx="7"
|
||||
fill="#ffffff"
|
||||
stroke="#888888"
|
||||
stroke-width="2"/>
|
||||
|
||||
<rect
|
||||
x="3"
|
||||
y="4"
|
||||
width="58"
|
||||
height="18"
|
||||
rx="7"
|
||||
fill="#d92626"/>
|
||||
|
||||
<rect
|
||||
x="3"
|
||||
y="15"
|
||||
width="58"
|
||||
height="7"
|
||||
fill="#d92626"/>
|
||||
|
||||
<rect
|
||||
x="14"
|
||||
y="1"
|
||||
width="6"
|
||||
height="12"
|
||||
rx="3"
|
||||
fill="#555555"/>
|
||||
|
||||
<rect
|
||||
x="44"
|
||||
y="1"
|
||||
width="6"
|
||||
height="12"
|
||||
rx="3"
|
||||
fill="#555555"/>
|
||||
|
||||
<text
|
||||
x="32"
|
||||
y="17"
|
||||
text-anchor="middle"
|
||||
font-family="Arial, sans-serif"
|
||||
font-size="8"
|
||||
font-weight="bold"
|
||||
fill="#ffffff">
|
||||
OSOR
|
||||
</text>
|
||||
|
||||
<text
|
||||
x="32"
|
||||
y="50"
|
||||
text-anchor="middle"
|
||||
font-family="Arial, sans-serif"
|
||||
font-size="36"
|
||||
font-weight="bold"
|
||||
fill="#222222">
|
||||
${day}
|
||||
</text>
|
||||
|
||||
</svg>
|
||||
`;
|
||||
|
||||
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();
|
||||
}
|
||||
|
||||
})();
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||