From 81450d937e3753f5b38db62ebf59e2ae41b63e36 Mon Sep 17 00:00:00 2001 From: Ippei Ukai Date: Thu, 31 May 2012 19:11:39 +0900 Subject: [PATCH] Forgot to commit those files before... --- app/views/issues/_changeset_github.rhtml | 7 +++++++ lib/issue_changeset_listener.rb | 22 ++++++++++++++++++++++ 2 files changed, 29 insertions(+) create mode 100644 app/views/issues/_changeset_github.rhtml create mode 100644 lib/issue_changeset_listener.rb diff --git a/app/views/issues/_changeset_github.rhtml b/app/views/issues/_changeset_github.rhtml new file mode 100644 index 0000000..fc42e32 --- /dev/null +++ b/app/views/issues/_changeset_github.rhtml @@ -0,0 +1,7 @@ +
+

<% link_to(url_for_revision) do %><%="#{l(:label_revision)} #{changeset.format_identifier}" %><% end %>
+ <%= authoring(changeset.committed_on, changeset.author) %>

+
+ <%= textilizable(changeset, :comments) %> +
+
diff --git a/lib/issue_changeset_listener.rb b/lib/issue_changeset_listener.rb new file mode 100644 index 0000000..df6f686 --- /dev/null +++ b/lib/issue_changeset_listener.rb @@ -0,0 +1,22 @@ +class IssueChangesetListener < Redmine::Hook::ViewListener + + def view_issue_show_changeset(context) + changeset = context[:changeset] + + projects_github = Setting.plugin_redmine_issue_changesets_view_link_github + github_repo = nil + github_repo = projects_github[changeset.project.identifier] unless projects_github.blank? + + unless github_repo.blank? + url = "https://github.com/%s/commit/%s" % [github_repo, changeset.identifier] + else + rev = changeset.respond_to?(:identifier) ? revision.identifier : revision + url = url_for({:controller => 'repositories', :action => 'revision', :id => project.identifier, :rev => rev}) + end + context[:controller].send(:render_to_string, { + :partial => "changeset_github", + :locals => context.merge({:url_for_revision=>url}) + }) + end + +end \ No newline at end of file