Files
baupm-core/init.rb

69 lines
2.1 KiB
Ruby
Raw Normal View History

2023-04-15 10:14:26 +02:00
require 'redmine'
class Hooks < Redmine::Hook::ViewListener
render_on :view_layouts_base_html_head, :partial => 'header', :layout => false
end
Redmine::Plugin.register :baupm_core do
name 'BauPM Core Plugin'
2023-11-04 15:36:39 +01:00
url 'https://src.bundespruefstelle.ch/magdev/baupm-core'
2023-04-15 10:14:26 +02:00
author 'Marco Grätsch'
2023-11-04 15:36:39 +01:00
author_url 'https://src.bundespruefstelle.ch/magdev'
2023-04-15 10:14:26 +02:00
description "Common modifications for BauPM"
2023-12-03 16:59:56 +01:00
version '0.2.2'
2023-04-15 10:14:26 +02:00
requires_redmine :version_or_higher => '4.1.0'
settings :default => {
'baupm_background_color' => '#ffffff',
'baupm_theme_color' => '#575757',
'baupm_application_title' => 'BauPM',
'baupm_application_short_title' => 'BauPM',
'baupm_application_description' => 'Baustellen-Management-System auf Redmine-Basis',
'baupm_manifest_orientation' => 'portrait',
'baupm_manifest_display' => 'standalone',
2023-05-06 12:08:27 +02:00
'baupm_manifest_start_url' => '.',
2023-04-29 18:00:27 +02:00
'baupm_enable_webapp' => '1'
2023-04-15 10:14:26 +02:00
}, :partial => 'settings/baupm_settings'
end
2023-12-12 01:53:22 +01:00
Redmine::WikiFormatting::Macros.register do
desc <<-DESCRIPTION
2023-12-12 01:55:07 +01:00
Embed video attachments
2023-12-12 01:53:22 +01:00
2023-12-12 01:55:07 +01:00
{{video(attachment.mp4)}} show video with default size 640x360
{{video(attachment.mp4, width=480, height=320)}} show video with size 480x320
DESCRIPTION
2023-12-12 01:53:22 +01:00
macro :video do |obj, args|
@width = args[1].gsub(/\D/,'') if args[1]
@height = args[2].gsub(/\D/,'') if args[2]
@width ||= 640
@height ||= 360
attachment = obj.attachments.find_by_filename(args[0]) if obj.respond_to?('attachments')
if attachment
file_url = url_for(
:only_path => false,
:controller => 'attachments',
:action => 'download',
:id => attachment,
:filename => attachment.filename
)
out = <<END
<video width="#{@width}" height="#{@height}" playsinline controls class="embedded-video">
<source src="#{file_url}">
Your browser does not support the video tag.
</video>
END
else
file_url = args[0].gsub(/<.*?>/, '').gsub(/&lt;.*&gt;/,'')
out = <<END
<iframe width="#{@width}" height="#{@height}" src="#{file_url}" class="embedded-video"></iframe>
END
end
out.html_safe
end
end