Working on fa macros

This commit is contained in:
Alexander Meindl 2018-08-30 17:27:34 +02:00
parent c583f14735
commit 137f20ec29
8 changed files with 69 additions and 1 deletions

View File

@ -45,7 +45,7 @@ module Additionals
require_dependency 'additionals/hooks'
# Macros
load_macros(%w[calendar cryptocompare date gist gmap group_users iframe issue
load_macros(%w[calendar cryptocompare date fa gist gmap group_users iframe issue
last_updated_at last_updated_by meteoblue member new_issue project
recently_updated reddit slideshare tradingview twitter user vimeo youtube])
end

0
lib/additionals/wiki_macros/date_macro.rb Executable file → Normal file
View File

View File

@ -0,0 +1,68 @@
# Font Awesome wiki macros
module Additionals
module WikiMacros
Redmine::WikiFormatting::Macros.register do
desc <<-DESCRIPTION
Show Font Awesome icon.
Syntax:
{{fa(ICON [, class=CLASS, title=TITLE, text=TEXT size=SIZE, color=COLOR)}}
ICON of fontawesome icon, eg. fa-adjust
CLASS = additional css classes
TITLE = mouseover title
TEXT = Text to show
LINK = Link icon and text (if specified) to this URL
color = css color
Examples:
{{fa(adjust)}}
...show fontawesome icon "fas fa-adjust"
{{fa(adjust, class=fa-inverse)}}
...show fontawesome icon "fas fa-stack" and inverse
{{fa(adjust, size=4x)}}
...show fontawesome icon "fas fa-adjust" with size 4x
{{fa(fas_adjust, title=Show icon)}}
...show fontawesome icon "fas fa-adjust" with title "Show icon"
{{fa(fab_angellist)}}
...Show fontawesome icon "fab fa-angellist"
{{fa(adjust, link=https=//www.redmine.org))}}
...Show fontawesome icon "fas fa-adjust" and link it to https://www.redmine.org
{{fa(adjust, link=https=//www.redmine.de, name=Go to Redmine.org))}}
...Show fontawesome icon "fas fa-adjust" with name "Go to Redmine.org" and link it to https://www.redmine.org
DESCRIPTION
macro :fa do |_obj, args|
args, options = extract_macro_options(args, :class, :title, :text, :size, :color, :link)
raise 'The correct usage is {{fa(<ICON>, class=CLASS, title=TITLE, text=TEXT, size=SIZE, color=COLOR)}}' if args.empty?
values = args[0].split('_')
classes = []
if values.count == 2
classes << values[0]
classes << "fa-#{values[1]}"
else
classes << 'fas'
classes << "fa-#{values[0]}"
end
classes += options[:class].split(' ') if options[:class].present?
classes << "fa-#{options[:size]}" if options[:size].present?
content_options = { class: classes.uniq.join(' ') }
content_options[:title] = options[:title] if options[:title].present?
content_options[:style] = "color: #{options[:color]}" if options[:color].present?
if options[:link].present?
content_tag(:a, href: options[:link]) do
content_tag(:i, ' ' + options[:text], content_options)
end
else
content_tag(:i, options[:text], content_options)
end
end
end
end
end

0
lib/additionals/wiki_macros/gist_macro.rb Executable file → Normal file
View File

0
lib/additionals/wiki_macros/member_macro.rb Executable file → Normal file
View File

0
lib/additionals/wiki_macros/project_macro.rb Executable file → Normal file
View File

0
lib/additionals/wiki_macros/vimeo_macro.rb Executable file → Normal file
View File

0
lib/additionals/wiki_macros/youtube_macro.rb Executable file → Normal file
View File