- Looks only in the issue's attributes for the field labelled exactly
"Mileage" (any case): no settings and no field id needed, and menus,
history, other plugins' text or fields like "Mileage Out" can't match;
issues without the field no longer throw a JavaScript error
- Shows "Copied!" only when the copy succeeded ("Couldn't copy"
otherwise), falls back when the Clipboard API isn't available, and
restores the value's original HTML afterwards
- Pointer cursor, "Click to copy" tooltip, keyboard support (Enter/Space)
- The script is written into the issue page by the
view_issues_show_details_bottom hook instead of being served as a
compiled asset, so it only loads on issue pages and can't 404 when
Redmine's asset manifest is stale; removes assets/javascripts and the
leftover console.log
- init.rb: requires Redmine 6.1+, points to the Gitea repository
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01BiwYMjhoQvL7XsKKfRz4pM
30 lines
1.7 KiB
Ruby
30 lines
1.7 KiB
Ruby
#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.
|
|
|
|
Redmine::Plugin.register :redmine_mileage_cp do
|
|
|
|
# About
|
|
name 'Redmine Mileage CP Plugin'
|
|
author 'Rick Barrette'
|
|
description 'Click an issue\'s Mileage value to copy it to the clipboard'
|
|
version '2026.3.0'
|
|
url 'https://gitea.rickbarrette.org/ricky/redmine_mileage_cp'
|
|
author_url 'https://barrettefabrication.com'
|
|
requires_redmine version_or_higher: '6.1.0'
|
|
|
|
end
|
|
|
|
# Dynamically load all Hooks & Patches recursively
|
|
base_dir = File.join(File.dirname(__FILE__), 'lib')
|
|
|
|
# '**' looks inside subdirectories, '*.rb' matches Ruby files
|
|
Dir.glob(File.join(base_dir, '**', '*.rb')).sort.each do |file|
|
|
require file
|
|
end |