redmine-more_view_hooks 0.0.1 → 0.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c4ec1b8064eee5a8d9e4883051a8112d2b64c8c5
4
- data.tar.gz: 6eb0ab718c2a6157664f8b8106f6701c1391a346
3
+ metadata.gz: 36a45bd7ab30331d67d0c2862e7f49632f35e807
4
+ data.tar.gz: e1553577e226189fe1bd9d94dcce99adbbd291f1
5
5
  SHA512:
6
- metadata.gz: 62a4584954d0f9685a220b73d6913a92e2284ffa2d4823606f60a197e109d3987bdf9cf6ec34a9d0bdf0b402657330210d210e48b285fe79251d338dc605381b
7
- data.tar.gz: f655718cd3a94c8ebc5f71ef49e66fd711c7764c795faa3c73a0eabab93e2bac229a683a8551d880df891574e4d7c39d1e65735c70a94c7d488a56ccb82989c6
6
+ metadata.gz: 96257c2dbcdb8b10a2448b73f0890b5da7fd6f06f385de6754e3e477a46d91792617defb67a692060115ffe40fd0a7286cc4d02bb5faf300e0b1338d91e20c08
7
+ data.tar.gz: 3e0767cfae4bfa9b04a3960fd8e886fa9b57f809ecc9a948c991892ccb040e25a36ebcda0af2e99e3965d4ee3187663f2f1f9b7fc7c6adf45850b85ca6c1afed
data/.rubocop.yml CHANGED
@@ -6,3 +6,7 @@ Style/FileName:
6
6
 
7
7
  Documentation:
8
8
  Enabled: false
9
+
10
+ Lint/HandleExceptions:
11
+ Exclude:
12
+ - rakelib/rubocop.rake
data/README.md CHANGED
@@ -1,5 +1,19 @@
1
+ [github]: https://github.com/neopoly/redmine-more_view_hooks
2
+ [doc]: http://rubydoc.info/github/neopoly/redmine-more_view_hooks/master/file/README.md
3
+ [gem]: https://rubygems.org/gems/redmine-more_view_hooks
4
+ [gem-badge]: https://img.shields.io/gem/v/redmine-more_view_hooks.svg
5
+ [inchpages]: https://inch-ci.org/github/neopoly/redmine-more_view_hooks
6
+ [inchpages-badge]: https://inch-ci.org/github/neopoly/redmine-more_view_hooks.svg?branch=master&style=flat
7
+
1
8
  # redmine-more_view_hooks
2
9
 
10
+ [![Gem Version][gem-badge]][gem]
11
+ [![Inline docs][inchpages-badge]][inchpages]
12
+
13
+ [Gem][gem] |
14
+ [Source][github] |
15
+ [Documentation][doc]
16
+
3
17
  Allows adding more view hooks into Redmine's templates
4
18
 
5
19
  ## Installation
@@ -20,20 +34,20 @@ Restart the Redmine application
20
34
 
21
35
  ## Usage
22
36
 
23
- Redmine already includes a concept of "view hooks", but not every place one can think already
24
- as such a hook. E.g. a hook before the user login status in the top menu is missing.
37
+ Redmine already includes a concept of "view hooks", but not every place already
38
+ has such a hook. For example, a hook before the user login status in the top menu is missing.
25
39
 
26
40
  Let's *assume* the needed view hook would already exists at the desired position and would be called `layout_base_logged_as_before`.
27
41
  In this case one can simple write a new view hook listener as [natively supported from Redmine](http://www.redmine.org/projects/redmine/wiki/Hooks):
28
42
 
29
43
  ```ruby
30
44
  class Hooks < Redmine::Hook::ViewListener
31
- # Redmine run's this method whenever a <%= call_hook(:layout_base_logged_as_before) %>
45
+ # Redmine runs this method whenever a <%= call_hook(:layout_base_logged_as_before) %>
32
46
  # is included into the templates.
33
47
  # Attention: This view hook doesn't exists in Redmine and must be realized using this gem
34
48
  def layout_base_logged_as_before(context)
35
49
  content_tag :span, "Some additional content"
36
- ends
50
+ end
37
51
  end
38
52
  ```
39
53
 
@@ -55,9 +69,41 @@ For more information about the Deface options please have a look at [their docum
55
69
 
56
70
  The correct place to register new view hooks would be when initializing your Redmine plugin.
57
71
 
72
+ ### Avoiding hook definitions with identical names
73
+
74
+ Redmine allows multiple hook definitions with identical names across separate hook listeners.
75
+
76
+ `MoreViewHooks.add` disallows hook definitions using the same name. So this won't work:
77
+
78
+ ```ruby
79
+ MoreViewHooks.add(:unique_name, ...)
80
+
81
+ # raises "A view hook 'unique_name' already exists (ArgumentError)"
82
+ MoreViewHooks.add(:unique_name, ...)
83
+ ```
84
+
85
+ Note: Defining a hook via `MoreViewHooks.add` re-using an existing Redmine hook name should work without problems.
86
+
87
+ Here is an example how to avoid duplicate hook names:
88
+
89
+ ```ruby
90
+ unless Redmine::Hook.hook_listeners(:view_projects_show_left).any?
91
+ MoreViewHooks.add(:view_projects_show_left,
92
+ virtual_path: "projects/show",
93
+ insert_top: "div.contextual"
94
+ )
95
+ end
96
+ ```
97
+
98
+ ## Tested Redmine versions
99
+
100
+ * Redmine 1.x
101
+ * Redmine 2.x
102
+ * Redmine 3.0 - 3.2
103
+
58
104
  ## Contributing
59
105
 
60
- 1. Fork it ( https://github.com/[my-github-username]/redmine-more_view_hooks/fork )
106
+ 1. Fork it ( https://github.com/neopoly/redmine-more_view_hooks/fork )
61
107
  2. Create your feature branch (`git checkout -b my-new-feature`)
62
108
  3. Commit your changes (`git commit -am 'Add some feature'`)
63
109
  4. Push to the branch (`git push origin my-new-feature`)
data/Rakefile CHANGED
@@ -3,6 +3,4 @@
3
3
  require "bundler/gem_tasks"
4
4
  require "rubocop/rake_task"
5
5
 
6
- RuboCop::RakeTask.new
7
-
8
6
  task default: [:rubocop]
@@ -14,8 +14,15 @@ MoreViewHooks.instance_eval do
14
14
  insert_after: "div.splitcontentright"
15
15
  )
16
16
 
17
- add(:view_projects_show_sidebar_top,
18
- virtual_path: "projects/_sidebar",
19
- insert_before: "erb[silent]:contains('if @total_hours.present?')"
20
- )
17
+ if redmine_version_at_least?("3.1")
18
+ add(:view_projects_show_sidebar_top,
19
+ virtual_path: "projects/_sidebar",
20
+ insert_before: "erb[silent]:contains('if User.current.allowed_to?(:view_time_entries, @project)')"
21
+ )
22
+ else
23
+ add(:view_projects_show_sidebar_top,
24
+ virtual_path: "projects/_sidebar",
25
+ insert_before: "erb[silent]:contains('if @total_hours.present?')"
26
+ )
27
+ end
21
28
  end
@@ -23,6 +23,7 @@ module MoreViewHooks
23
23
  end
24
24
 
25
25
  def boot!
26
+ MoreViewHooks.load_default_additional_hooks!
26
27
  MoreViewHooks.hooks.apply!
27
28
  end
28
29
 
@@ -1,3 +1,3 @@
1
1
  module MoreViewHooks
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
@@ -18,5 +18,13 @@ module MoreViewHooks
18
18
  end
19
19
  module_function :add
20
20
 
21
- require "more_view_hooks/default_additional_hooks"
21
+ def redmine_version_at_least?(other)
22
+ Gem::Version.new(::Redmine::VERSION) > Gem::Version.new(other)
23
+ end
24
+ module_function :redmine_version_at_least?
25
+
26
+ def load_default_additional_hooks!
27
+ require "more_view_hooks/default_additional_hooks"
28
+ end
29
+ module_function :load_default_additional_hooks!
22
30
  end
@@ -0,0 +1,18 @@
1
+ begin
2
+ require "rubocop/rake_task"
3
+
4
+ Rake::Task[:default].enhance [:rubocop]
5
+
6
+ RuboCop::RakeTask.new do |task|
7
+ task.options << "--display-cop-names"
8
+ end
9
+
10
+ namespace :rubocop do
11
+ desc "Generate a configuration file acting as a TODO list."
12
+ task :auto_gen_config do
13
+ exec "bundle exec rubocop --auto-gen-config"
14
+ end
15
+ end
16
+
17
+ rescue LoadError
18
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: redmine-more_view_hooks
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jonas Thiel
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-03-19 00:00:00.000000000 Z
11
+ date: 2016-02-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -101,6 +101,7 @@ files:
101
101
  - lib/more_view_hooks/redmine_plugin.rb
102
102
  - lib/more_view_hooks/version.rb
103
103
  - lib/redmine-more_view_hooks.rb
104
+ - rakelib/rubocop.rake
104
105
  - redmine-more_view_hooks.gemspec
105
106
  homepage: https://github.com/neopoly/redmine-more_view_hooks
106
107
  licenses:
@@ -127,4 +128,3 @@ signing_key:
127
128
  specification_version: 4
128
129
  summary: Allows adding more view hooks into Redmine's templates
129
130
  test_files: []
130
- has_rdoc: