Skip to content

Commit a87e09e

Browse files
committed
redmine_userpage_macro: mailer fixes
1) render macro without arguments (i.e. {{userpage}}) for mailer correctly 2) render full link path and not relative for mailer, i.e. https://myredmine/path/to/page instead of /path/to/page
1 parent 9ad9276 commit a87e09e

File tree

1 file changed

+10
-7
lines changed
  • redmine_plugins/redmine_userpage_macro

1 file changed

+10
-7
lines changed

redmine_plugins/redmine_userpage_macro/init.rb

+10-7
Original file line numberDiff line numberDiff line change
@@ -6,20 +6,22 @@
66
author 'Stanislav German-Evtushenko'
77
description 'Add the userpage macro.'
88
author_url 'mailto:[email protected]'
9-
version '0.1'
9+
version '0.2'
1010
end
1111

1212
Redmine::WikiFormatting::Macros.register do
1313
desc "Insert the link to the userpage. Examples: \n\n <pre>{{userpage}}\n{{userpage(project_id, user_login, parent_page)}}</pre>"
1414
macro :userpage do |obj, args|
1515
if args[0] and !args[0].empty?
1616
project_identifier = args[0].strip
17-
project_id = Project.find_by_identifier(project_identifier).identifier
17+
project = Project.find_by_identifier(project_identifier)
1818
end
19-
20-
project_id = @project.identifier unless project_id
21-
return nil unless project_id
22-
19+
20+
project = @project || (obj && obj.project) unless project
21+
return nil unless project
22+
23+
project_id = project.identifier
24+
2325
if args[1] and !args[1].empty?
2426
user_login = args[1].strip.downcase
2527
end
@@ -31,6 +33,7 @@
3133
user_login = User.current.login unless user_login
3234
userpage_exists = Wiki.find_page(project_id + ":" + user_login)
3335
url_class = 'wiki-page' + (userpage_exists ? '' : ' new')
34-
h(link_to(user_login, {:controller => 'wiki', :action => 'show', :project_id => project_id, :id => user_login, :parent => parent_page}, :class => url_class))
36+
url = url_for(:controller => 'wiki', :action => 'show', :project_id => project_id, :id => user_login, :parent => parent_page, :only_path => @only_path)
37+
h(link_to(user_login, url, :class => url_class))
3538
end
3639
end

0 commit comments

Comments
 (0)