Skip to content

Commit

Permalink
refs #2 Annotate画面にGithubへのリンクを表示する
Browse files Browse the repository at this point in the history
  • Loading branch information
xketanaka committed Sep 28, 2023
1 parent 6695032 commit 81e6d6b
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 1 deletion.
2 changes: 1 addition & 1 deletion app/models/repository/github.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ def supports_revision_graph?
end

def supports_annotate?
false
true
end

def repo_log_encoding
Expand Down
11 changes: 11 additions & 0 deletions app/views/repositories/_annotate_link_patch.js.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<% if @repository && @repository.class.name == "Repository::Github" && action_name == 'annotate' %>
<style>
p#errorExplanation { display: none }
</style>
<script>
$(function(){
<% url = "#{@repository.url}/blame/#{@rev}/#{@path}" %>
$('p#errorExplanation').after('<a target="_blank" href="<%= url %>">View in GitHub</a>')
})
</script>
<% end %>
1 change: 1 addition & 0 deletions init.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
require 'redmine'
require File.expand_path('../lib/github_repositories_helper_patch', __FILE__)
require File.expand_path('../lib/hooks', __FILE__)

Redmine::Plugin.register :redmine_github_adapter do
name 'Redmine Github Adapter plugin'
Expand Down
5 changes: 5 additions & 0 deletions lib/hooks.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
module RedmineGithubAdapter
class Hooks < Redmine::Hook::ViewListener
render_on :view_repositories_show_contextual, partial: 'annotate_link_patch.js'
end
end

0 comments on commit 81e6d6b

Please sign in to comment.