Skip to content
This repository has been archived by the owner on Sep 29, 2020. It is now read-only.

Commit

Permalink
Merge pull request #2 from akiko-pusu/develop
Browse files Browse the repository at this point in the history
ViewHook調整その1
  • Loading branch information
akiko-pusu committed Jun 10, 2018
2 parents c2ed0d4 + d2cf62f commit fa1ac26
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 0 deletions.
9 changes: 9 additions & 0 deletions app/views/settings/_redmine_issue_stamps.html.erb
@@ -0,0 +1,9 @@
<div class="form-inline issue_stamps">
<% unless Rails.env.production? %>
<p>
Display View Hook points
<%= hidden_field_tag("settings[display_view_hook_points]", 0, :id => nil).html_safe %>
<%= check_box_tag 'settings[display_view_hook_points]', true, @settings['display_view_hook_points'] == 'true' %>
</p>
<% end %>
</div>
4 changes: 4 additions & 0 deletions assets/stylesheets/redmine_issue_stamps.css
@@ -0,0 +1,4 @@
.redmine-issue-stamps-viewhook {
background: #FFFFBF;
color: darkred;
}
10 changes: 10 additions & 0 deletions init.rb
@@ -1,8 +1,18 @@
require 'redmine'
require 'issue_stamps/redmine_hook_patch'

Redmine::Plugin.register :redmine_issue_stamps do
name 'Redmine Issue Stamps plugin'
author 'Akiko Takano'
description 'This is a plugin for Redmine, which enables to display approval stamps on issue description page.'
version '0.0.1-dev'
url 'https://github.com/akiko-pusu/redmine_issue_stamps'
author_url 'https://github.com/akiko-pusu'

unless Rails.env.production?
settings partial: 'settings/redmine_issue_stamps',
default: {
'display_view_hook_points' => false
}
end
end
20 changes: 20 additions & 0 deletions lib/issue_stamps/redmine_hook_patch.rb
@@ -0,0 +1,20 @@
module IssueStamps
class Hooks < Redmine::Hook::ViewListener
include IssuesHelper

def view_layouts_base_html_head(context = {})
stylesheet_link_tag('redmine_issue_stamps', plugin: 'redmine_issue_stamps')
end
end

module RedmineHookPatch
def call_hook(hook, context = {})
flag = Setting.plugin_redmine_issue_stamps['display_view_hook_points']
result = super
return result unless flag == 'true'
result << "<span class='redmine-issue-stamps-viewhook'>Hook point: #{hook}</span>".html_safe
end
end
end

ApplicationHelper.prepend IssueStamps::RedmineHookPatch unless Rails.env.production?

0 comments on commit fa1ac26

Please sign in to comment.