|
6 | 6 | author 'Stanislav German-Evtushenko'
|
7 | 7 | description 'Add the userpage macro.'
|
8 | 8 | author_url 'mailto:[email protected]'
|
9 |
| - version '0.1' |
| 9 | + version '0.2' |
10 | 10 | end
|
11 | 11 |
|
12 | 12 | Redmine::WikiFormatting::Macros.register do
|
13 | 13 | desc "Insert the link to the userpage. Examples: \n\n <pre>{{userpage}}\n{{userpage(project_id, user_login, parent_page)}}</pre>"
|
14 | 14 | macro :userpage do |obj, args|
|
15 | 15 | if args[0] and !args[0].empty?
|
16 | 16 | project_identifier = args[0].strip
|
17 |
| - project_id = Project.find_by_identifier(project_identifier).identifier |
| 17 | + project = Project.find_by_identifier(project_identifier) |
18 | 18 | 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 | + |
23 | 25 | if args[1] and !args[1].empty?
|
24 | 26 | user_login = args[1].strip.downcase
|
25 | 27 | end
|
|
31 | 33 | user_login = User.current.login unless user_login
|
32 | 34 | userpage_exists = Wiki.find_page(project_id + ":" + user_login)
|
33 | 35 | 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)) |
35 | 38 | end
|
36 | 39 | end
|
0 commit comments