Skip to content

Commit

Permalink
[webui] take care of issue labels in markdown expansion
Browse files Browse the repository at this point in the history
  • Loading branch information
adrianschroeter committed May 16, 2014
1 parent 947db10 commit e660651
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 7 deletions.
6 changes: 5 additions & 1 deletion src/api/app/models/issue_tracker.rb
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,14 @@ def write_to_backend
def show_url_for(issue, html=nil)
return nil unless issue
url = show_url.gsub('@@@', issue)
return "<a href=\"#{url}\">#{label.gsub('@@@', issue)}</a>" if html
return "<a href=\"#{url}\">#{CGI::escapeHTML(show_label_for(issue))}</a>" if html
return url
end

def show_label_for(issue)
label.gsub('@@@', issue)
end

# expands all matches with defined urls
def get_html(text)
text.gsub(Regexp.new(regex)) { |m| show_url_for($1, true) }
Expand Down
5 changes: 2 additions & 3 deletions src/api/lib/obsapi/markdown_renderer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,8 @@ def preprocess(fulldoc)
# OBS requests
out = fulldoc.gsub(/(sr|req)#(\d+)/) {|s| "<a href=\"#{request_show_path(id: $2)}\">#{s}</a>" }
# issues
IssueTracker.all.each do |tracker|
exp = Regexp.new(tracker.regex)
out.gsub!(exp) {|s| "<a href=\"#{tracker.show_url_for($1)}\">#{s}</a>" }
IssueTracker.all.each do |t|
out = t.get_html(out)
end
out
end
Expand Down
4 changes: 2 additions & 2 deletions src/api/test/fixtures/issue_trackers.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ bco:
url: http://bugzilla.clutter-project.org/
show_url: http://bugzilla.clutter-project.org/show_bug.cgi?id=@@@
regex: bco#(\d+)
label: '@@@'
label: 'bco#@@@'
issues_updated: 2011-07-29 14:00:21.000000000 Z
enable_fetch: 0
bgo:
Expand Down Expand Up @@ -160,7 +160,7 @@ issue_trackers_40:
url: https://features.opensuse.org/
show_url: https://features.opensuse.org/@@@
regex: (?:fate|FATE|Fate)\s*#\s*(\d+)
label: '@@@'
label: 'fate#@@@'
issues_updated: 2011-07-29 14:00:21.000000000 Z
enable_fetch: 0
issue_trackers_41:
Expand Down
2 changes: 1 addition & 1 deletion src/api/test/unit/code_quality_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ def setup
'Webui::PackageController#branch' => 50.36,
'Webui::PackageController#save_new_link' => 75.86,
'Webui::PackageController#submit_request' => 123.99,
'Webui::PatchinfoController#new_tracker' => 68.43,
'Webui::PatchinfoController#new_tracker' => 64.68,
'Webui::PatchinfoController#read_patchinfo' => 75,
'Webui::PatchinfoController#save' => 244.01,
'Webui::ProjectController#calculate_repo_cycle' => 51.82,
Expand Down

0 comments on commit e660651

Please sign in to comment.