redmine-more_view_hooks 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: c4ec1b8064eee5a8d9e4883051a8112d2b64c8c5
4
+ data.tar.gz: 6eb0ab718c2a6157664f8b8106f6701c1391a346
5
+ SHA512:
6
+ metadata.gz: 62a4584954d0f9685a220b73d6913a92e2284ffa2d4823606f60a197e109d3987bdf9cf6ec34a9d0bdf0b402657330210d210e48b285fe79251d338dc605381b
7
+ data.tar.gz: f655718cd3a94c8ebc5f71ef49e66fd711c7764c795faa3c73a0eabab93e2bac229a683a8551d880df891574e4d7c39d1e65735c70a94c7d488a56ccb82989c6
data/.gitignore ADDED
@@ -0,0 +1,2 @@
1
+ Gemfile.lock
2
+ pkg
data/.rubocop.yml ADDED
@@ -0,0 +1,8 @@
1
+ StringLiterals:
2
+ EnforcedStyle: "double_quotes"
3
+
4
+ Style/FileName:
5
+ Enabled: false
6
+
7
+ Documentation:
8
+ Enabled: false
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source "https://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in candy_check.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2015 Jonas Thiel
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,64 @@
1
+ # redmine-more_view_hooks
2
+
3
+ Allows adding more view hooks into Redmine's templates
4
+
5
+ ## Installation
6
+
7
+ Ensure you have a `Gemfile.local` file in your Redmine installation. Add to your `Gemfile.local`:
8
+
9
+ ```ruby
10
+ gem "redmine-more_view_hooks"
11
+ ```
12
+
13
+ And then execute:
14
+
15
+ ```
16
+ $ bundle
17
+ ```
18
+
19
+ Restart the Redmine application
20
+
21
+ ## Usage
22
+
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.
25
+
26
+ Let's *assume* the needed view hook would already exists at the desired position and would be called `layout_base_logged_as_before`.
27
+ 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
+
29
+ ```ruby
30
+ class Hooks < Redmine::Hook::ViewListener
31
+ # Redmine run's this method whenever a <%= call_hook(:layout_base_logged_as_before) %>
32
+ # is included into the templates.
33
+ # Attention: This view hook doesn't exists in Redmine and must be realized using this gem
34
+ def layout_base_logged_as_before(context)
35
+ content_tag :span, "Some additional content"
36
+ ends
37
+ end
38
+ ```
39
+
40
+ To bring this to live we need to add this new view hook into Redmine's base layout template.
41
+ Using this gem you can inject every needed view hooks into every possible template.
42
+ The needed hook can be achieved using the following statement:
43
+
44
+ ```ruby
45
+ MoreViewHooks.add(
46
+ # first the name of the new view hook
47
+ :layout_base_logged_as_before,
48
+ # now some Deface options to determine the correct position of the hook
49
+ virtual_path: "layouts/base",
50
+ insert_before: "#top-menu erb[loud]:contains('if User.current.logged?'):contains('content_tag')"
51
+ )
52
+ ```
53
+
54
+ For more information about the Deface options please have a look at [their documentation](https://github.com/spree/deface#usage).
55
+
56
+ The correct place to register new view hooks would be when initializing your Redmine plugin.
57
+
58
+ ## Contributing
59
+
60
+ 1. Fork it ( https://github.com/[my-github-username]/redmine-more_view_hooks/fork )
61
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
62
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
63
+ 4. Push to the branch (`git push origin my-new-feature`)
64
+ 5. Create a new Pull Request
data/Rakefile ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env rake
2
+
3
+ require "bundler/gem_tasks"
4
+ require "rubocop/rake_task"
5
+
6
+ RuboCop::RakeTask.new
7
+
8
+ task default: [:rubocop]
@@ -0,0 +1,21 @@
1
+ MoreViewHooks.instance_eval do
2
+ add(:view_projects_contextual,
3
+ virtual_path: "projects/show",
4
+ insert_top: "div.contextual"
5
+ )
6
+
7
+ add(:view_projects_show_top,
8
+ virtual_path: "projects/show",
9
+ insert_before: "div.splitcontentleft"
10
+ )
11
+
12
+ add(:view_projects_show_bottom,
13
+ virtual_path: "projects/show",
14
+ insert_after: "div.splitcontentright"
15
+ )
16
+
17
+ add(:view_projects_show_sidebar_top,
18
+ virtual_path: "projects/_sidebar",
19
+ insert_before: "erb[silent]:contains('if @total_hours.present?')"
20
+ )
21
+ end
@@ -0,0 +1,10 @@
1
+ require "more_view_hooks/redmine_plugin"
2
+
3
+ module MoreViewHooks
4
+ # Simple engine to support the Redmine plugin
5
+ class Engine < ::Rails::Engine
6
+ config.to_prepare do
7
+ RedminePlugin.new
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,18 @@
1
+ module MoreViewHooks
2
+ # Describes a preconfigured view hook which will be later applied
3
+ # by using the elegant Deface gem
4
+ class Hook
5
+ attr_reader :deface_options
6
+
7
+ def initialize(hook_name, context, options)
8
+ @deface_options = options.merge(
9
+ text: "<%= call_hook(:#{hook_name}, #{context || '{}'}) %>",
10
+ name: "more_view_hooks_#{hook_name}"
11
+ )
12
+ end
13
+
14
+ def apply!
15
+ Deface::Override.new(deface_options)
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,25 @@
1
+ module MoreViewHooks
2
+ # Manages hooks to be applied into Redmine's templates
3
+ class HookCollection
4
+ def initialize
5
+ @hooks = {}
6
+ @applied = false
7
+ end
8
+
9
+ # Applies all registered view hooks
10
+ def apply!
11
+ @hooks.values.each(&:apply!)
12
+ @applied = true
13
+ end
14
+
15
+ # Registers a new view hook
16
+ # @param name [String]
17
+ # @param options [Hash] for Defaced
18
+ def add(name, options)
19
+ fail ArgumentError, "A view hook '#{name}' already exists" if @hooks[name]
20
+ context = options.delete(:context)
21
+ hook = @hooks[name] = Hook.new(name, context, options)
22
+ hook.apply! if @applied
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,11 @@
1
+ module MoreViewHooks
2
+ module Infos
3
+ NAME = "redmine-more_view_hooks"
4
+ DESCRIPTION = "Allows adding more view hooks into Redmine's templates"
5
+ LICENSE = "MIT"
6
+ URL = "https://github.com/neopoly/redmine-more_view_hooks"
7
+ AUTHORS = {
8
+ "Jonas Thiel" => "jt@neopoly.de"
9
+ }.freeze
10
+ end
11
+ end
@@ -0,0 +1,33 @@
1
+ module MoreViewHooks
2
+ # Registers this gems a Redmine plugin and applies the needed patches
3
+ class RedminePlugin
4
+ include MoreViewHooks::Infos
5
+
6
+ def initialize
7
+ register!
8
+ boot!
9
+ end
10
+
11
+ private
12
+
13
+ def register!
14
+ Redmine::Plugin.register :more_view_hooks do
15
+ name NAME
16
+ author AUTHORS.keys.join(", ")
17
+ description DESCRIPTION
18
+ version VERSION
19
+ url URL
20
+ author_url URL
21
+ directory Engine.root
22
+ end
23
+ end
24
+
25
+ def boot!
26
+ MoreViewHooks.hooks.apply!
27
+ end
28
+
29
+ def mirror_assets!
30
+ @plugin.mirror_assets
31
+ end
32
+ end
33
+ end
@@ -0,0 +1,3 @@
1
+ module MoreViewHooks
2
+ VERSION = "0.0.1"
3
+ end
@@ -0,0 +1,22 @@
1
+ require "deface"
2
+
3
+ require "more_view_hooks/version"
4
+ require "more_view_hooks/infos"
5
+ require "more_view_hooks/engine"
6
+ require "more_view_hooks/hook"
7
+ require "more_view_hooks/hook_collection"
8
+
9
+ # Redmine plugin to allow injecting more view hooks
10
+ module MoreViewHooks
11
+ def hooks
12
+ @hooks ||= HookCollection.new
13
+ end
14
+ module_function :hooks
15
+
16
+ def add(*args)
17
+ hooks.add(*args)
18
+ end
19
+ module_function :add
20
+
21
+ require "more_view_hooks/default_additional_hooks"
22
+ end
@@ -0,0 +1,28 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path("../lib", __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require "more_view_hooks/version"
5
+ require "more_view_hooks/infos"
6
+
7
+ Gem::Specification.new do |spec|
8
+ spec.name = "redmine-more_view_hooks"
9
+ spec.version = MoreViewHooks::VERSION
10
+ spec.authors = MoreViewHooks::Infos::AUTHORS.keys
11
+ spec.email = MoreViewHooks::Infos::AUTHORS.values
12
+ spec.summary = MoreViewHooks::Infos::DESCRIPTION
13
+ spec.description = MoreViewHooks::Infos::DESCRIPTION
14
+ spec.homepage = MoreViewHooks::Infos::URL
15
+ spec.license = MoreViewHooks::Infos::LICENSE
16
+
17
+ spec.files = `git ls-files -z`.split("\x0")
18
+ spec.executables = spec.files.grep(/^bin\//) { |f| File.basename(f) }
19
+ spec.test_files = spec.files.grep(/^(test|spec|features)\//)
20
+ spec.require_paths = ["lib"]
21
+
22
+ spec.add_dependency "rails", "~> 4.2.0"
23
+ spec.add_dependency "deface", "~> 1.0.0"
24
+
25
+ spec.add_development_dependency "bundler", "~> 1.7"
26
+ spec.add_development_dependency "rake", "~> 10.0"
27
+ spec.add_development_dependency "rubocop"
28
+ end
metadata ADDED
@@ -0,0 +1,130 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: redmine-more_view_hooks
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Jonas Thiel
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-03-19 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rails
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: 4.2.0
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: 4.2.0
27
+ - !ruby/object:Gem::Dependency
28
+ name: deface
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: 1.0.0
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: 1.0.0
41
+ - !ruby/object:Gem::Dependency
42
+ name: bundler
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '1.7'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '1.7'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rake
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '10.0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '10.0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rubocop
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ description: Allows adding more view hooks into Redmine's templates
84
+ email:
85
+ - jt@neopoly.de
86
+ executables: []
87
+ extensions: []
88
+ extra_rdoc_files: []
89
+ files:
90
+ - ".gitignore"
91
+ - ".rubocop.yml"
92
+ - Gemfile
93
+ - LICENSE.txt
94
+ - README.md
95
+ - Rakefile
96
+ - lib/more_view_hooks/default_additional_hooks.rb
97
+ - lib/more_view_hooks/engine.rb
98
+ - lib/more_view_hooks/hook.rb
99
+ - lib/more_view_hooks/hook_collection.rb
100
+ - lib/more_view_hooks/infos.rb
101
+ - lib/more_view_hooks/redmine_plugin.rb
102
+ - lib/more_view_hooks/version.rb
103
+ - lib/redmine-more_view_hooks.rb
104
+ - redmine-more_view_hooks.gemspec
105
+ homepage: https://github.com/neopoly/redmine-more_view_hooks
106
+ licenses:
107
+ - MIT
108
+ metadata: {}
109
+ post_install_message:
110
+ rdoc_options: []
111
+ require_paths:
112
+ - lib
113
+ required_ruby_version: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - ">="
116
+ - !ruby/object:Gem::Version
117
+ version: '0'
118
+ required_rubygems_version: !ruby/object:Gem::Requirement
119
+ requirements:
120
+ - - ">="
121
+ - !ruby/object:Gem::Version
122
+ version: '0'
123
+ requirements: []
124
+ rubyforge_project:
125
+ rubygems_version: 2.4.6
126
+ signing_key:
127
+ specification_version: 4
128
+ summary: Allows adding more view hooks into Redmine's templates
129
+ test_files: []
130
+ has_rdoc: