netzke_widget_generators 0.1.0

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.
@@ -0,0 +1,5 @@
1
+ README.rdoc
2
+ lib/**/*.rb
3
+ bin/*
4
+ features/**/*.feature
5
+ LICENSE
@@ -0,0 +1,21 @@
1
+ ## MAC OS
2
+ .DS_Store
3
+
4
+ ## TEXTMATE
5
+ *.tmproj
6
+ tmtags
7
+
8
+ ## EMACS
9
+ *~
10
+ \#*
11
+ .\#*
12
+
13
+ ## VIM
14
+ *.swp
15
+
16
+ ## PROJECT::GENERAL
17
+ coverage
18
+ rdoc
19
+ pkg
20
+
21
+ ## PROJECT::SPECIFIC
data/LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2009 Kristian Mandrup
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,53 @@
1
+ # Netzke widget generators
2
+
3
+ Rails 3 generators to quickly generate skeletons for custom Netzke widgets based on a base class (typically in basepackage).
4
+
5
+ Currently there are generators for the following base widgets:
6
+
7
+ * Tree widget
8
+ * Border Layout Panel
9
+ * Grid Panel
10
+
11
+ ## Install
12
+
13
+ +As system gem:+
14
+
15
+ <code>gem install netzke_widget_generators</code>
16
+
17
+ +In rails app:+
18
+
19
+ Add to Gemfile:
20
+
21
+ <code>gem 'netzke_widget_generators'</code>
22
+
23
+ Run bundler
24
+
25
+ <code>$ bundle install</code>
26
+
27
+ ## Usage
28
+
29
+ ### Tree widget
30
+
31
+ <code>rails g tree_widget my_tree --root-node "All Bosses"</code>
32
+
33
+ ### Border Layout Panel
34
+
35
+ <code>rails g blp_widget my_blp Boss</code>
36
+
37
+ ### Grid Panel
38
+
39
+ <code>rails g grid_panel_widget my_grid</code>
40
+
41
+ ## Note on Patches/Pull Requests
42
+
43
+ * Fork the project.
44
+ * Make your feature addition or bug fix.
45
+ * Add tests for it. This is important so I don't break it in a
46
+ future version unintentionally.
47
+ * Commit, do not mess with rakefile, version, or history.
48
+ (if you want to have your own version, that is fine but bump version in a commit by itself I can ignore when I pull)
49
+ * Send me a pull request. Bonus points for topic branches.
50
+
51
+ ## Copyright
52
+
53
+ Copyright (c) 2010 Kristian Mandrup. See LICENSE for details.
@@ -0,0 +1,42 @@
1
+ begin
2
+ require 'jeweler'
3
+ Jeweler::Tasks.new do |gem|
4
+ gem.name = "netzke_widget_generators"
5
+ gem.summary = %Q{Rails 3 generators for Netzke widgets}
6
+ gem.description = %Q{Rails 3 generators for Netzke widgets}
7
+ gem.email = "kmandrup@gmail.com"
8
+ gem.homepage = "http://github.com/kristianmandrup/netzke_widget_generators"
9
+ gem.authors = ["Kristian Mandrup"]
10
+ # gem.add_development_dependency "rspec", ">= 1.2.9"
11
+ # gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
12
+ end
13
+ Jeweler::GemcutterTasks.new
14
+ rescue LoadError
15
+ puts "Jeweler (or a dependency) not available. Install it with: gem install jeweler"
16
+ end
17
+
18
+ # require 'spec/rake/spectask'
19
+ # Spec::Rake::SpecTask.new(:spec) do |spec|
20
+ # spec.libs << 'lib' << 'spec'
21
+ # spec.spec_files = FileList['spec/**/*_spec.rb']
22
+ # end
23
+ #
24
+ # Spec::Rake::SpecTask.new(:rcov) do |spec|
25
+ # spec.libs << 'lib' << 'spec'
26
+ # spec.pattern = 'spec/**/*_spec.rb'
27
+ # spec.rcov = true
28
+ # end
29
+ #
30
+ # task :spec => :check_dependencies
31
+ #
32
+ # task :default => :spec
33
+ #
34
+ # require 'rake/rdoctask'
35
+ # Rake::RDocTask.new do |rdoc|
36
+ # version = File.exist?('VERSION') ? File.read('VERSION') : ""
37
+ #
38
+ # rdoc.rdoc_dir = 'rdoc'
39
+ # rdoc.title = "netzke_widget_generators #{version}"
40
+ # rdoc.rdoc_files.include('README*')
41
+ # rdoc.rdoc_files.include('lib/**/*.rb')
42
+ # end
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.1.0
@@ -0,0 +1,8 @@
1
+ Description:
2
+ Creates a BorderLayoutPanel Netzke widget
3
+
4
+ Example:
5
+ rails g blp_widget my_blp Boss
6
+
7
+ This will create:
8
+ lib/netzke/blp/my_blp.rb
@@ -0,0 +1,27 @@
1
+ require 'active_support/inflector'
2
+
3
+ module Netzke
4
+ module Generators
5
+ class BlpWidgetGenerator < Rails::Generators::NamedBase
6
+ source_root File.expand_path('../templates', __FILE__)
7
+
8
+ argument :data_class, :type => :string, :required => true, :desc => 'Name of the data class to use in the grid'
9
+
10
+ def create_lib_netzke
11
+ inside 'lib' do
12
+ FileUtils.mkdir('netzke') if !File.directory?('netzke')
13
+ end
14
+ end
15
+
16
+ def create_widget
17
+ template 'blp_widget.erb', "lib/netzke/blp/#{name}_widget.rb"
18
+ end
19
+
20
+ protected
21
+
22
+ def class_name
23
+ name.camelize
24
+ end
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,21 @@
1
+ module Netzke
2
+ class <%= class_name %> < BorderLayoutPanel
3
+ def default_config
4
+ super.merge({
5
+ :regions => {
6
+ :center => {
7
+ :widget_class_name => "GridPanel",
8
+ :data_class_name => "<%= data_class %>",
9
+ :ext_config => {
10
+ :title => "<%= data_class.pluralize %>"
11
+ }
12
+ }
13
+ },
14
+ :ext_config => {
15
+ :header => false
16
+ }
17
+ })
18
+ end
19
+
20
+ end
21
+ end
@@ -0,0 +1,8 @@
1
+ Description:
2
+ Creates a GridPanel Netzke widget
3
+
4
+ Example:
5
+ rails g grid_panel_widget my_gridpanel
6
+
7
+ This will create:
8
+ lib/netzke/grid_panel/my_gridpanel.rb
@@ -0,0 +1,25 @@
1
+ require 'active_support/inflector'
2
+
3
+ module Netzke
4
+ module Generators
5
+ class GridPanelWidgetGenerator < Rails::Generators::NamedBase
6
+ source_root File.expand_path('../templates', __FILE__)
7
+
8
+ def create_lib_netzke
9
+ inside 'lib' do
10
+ FileUtils.mkdir('netzke') if !File.directory?('netzke')
11
+ end
12
+ end
13
+
14
+ def create_widget
15
+ template 'grid_panel_widget.erb', "lib/netzke/grid_panel/#{name}_widget.rb"
16
+ end
17
+
18
+ protected
19
+
20
+ def class_name
21
+ name.camelize
22
+ end
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,51 @@
1
+ module Netzke
2
+ class <%= class_name %> < GridPanel
3
+ DETAILS = "details"
4
+ SHOW_DETAILS = "show_#{DETAILS}"
5
+ MSG_WIDTH = 300
6
+
7
+ def actions
8
+ super.merge({
9
+ :show_details => {:text => SHOW_DETAILS.humanize, :disabled => true}
10
+ })
11
+ end
12
+
13
+ def default_bbar
14
+ [SHOW_DETAILS, "-", *super]
15
+ end
16
+
17
+ def default_context_menu
18
+ [SHOW_DETAILS, "-", *super]
19
+ end
20
+
21
+ def self.js_extend_properties
22
+ {
23
+ :init_component => <<-END_OF_JAVASCRIPT.l,
24
+ function(){
25
+ #{js_full_class_name}.superclass.initComponent.call(this);
26
+
27
+ this.getSelectionModel().on('selectionchange', function(selModel){
28
+ this.actions.showDetails.setDisabled(selModel.getCount() != 1);
29
+ }, this);
30
+ }
31
+ END_OF_JAVASCRIPT
32
+
33
+ :on_show_details => <<-END_OF_JAVASCRIPT.l,
34
+ function(){
35
+ var tmpl = new Ext.Template("<b>{0}</b>: {1}<br/>"), html = "";
36
+ Ext.iterate(this.getSelectionModel().getSelected().data, function(key, value){
37
+ html += tmpl.apply([key.humanize(), value]);
38
+ }, this);
39
+
40
+
41
+ Ext.Msg.show({
42
+ title: DETAILS.humanize,
43
+ width: MSG_WIDTH,
44
+ msg: html
45
+ });
46
+ }
47
+ END_OF_JAVASCRIPT
48
+ }
49
+ end
50
+ end
51
+ end
@@ -0,0 +1,8 @@
1
+ Description:
2
+ Creates a Tree Netzke widget
3
+
4
+ Example:
5
+ rails g tree_widget my_tree --root-node 'My root'
6
+
7
+ This will create:
8
+ lib/netzke/tree/my_tree.rb
@@ -0,0 +1,30 @@
1
+ class Netzke::<%= class_name %> < Netzke::Base
2
+ api :get_children
3
+
4
+ def self.js_base_class
5
+ "Ext.tree.TreePanel"
6
+ end
7
+
8
+ # New and overriden properties of the resulting JS class
9
+ def self.js_extend_properties
10
+ {
11
+ :root => {:text => '<%= root_node %>', :id => 'source'},
12
+ :init_component => <<-END_OF_JAVASCRIPT.l,
13
+ function(){
14
+ // dataUrl should be set to the API point which provides us with the nodes
15
+ this.dataUrl = this.buildApiUrl("get_children");
16
+ // Call the superclass' initComponent
17
+ #{js_full_class_name}.superclass.initComponent.call(this);
18
+ }
19
+ END_OF_JAVASCRIPT
20
+ }
21
+ end
22
+
23
+ def get_children(params)
24
+ klass = config[:model].constantize
25
+ node_id = params[:node].to_i
26
+ node = params[:node] == 'source' ? klass.where("parent_id is NULL").first : klass.find(params[:node].to_i)
27
+ node.children.map{|n| {:text => n.name, :id => n.id}}
28
+ end
29
+
30
+ end
@@ -0,0 +1,31 @@
1
+ require 'active_support/inflector'
2
+
3
+ module Netzke
4
+ module Generators
5
+ class TreeWidgetGenerator < Rails::Generators::NamedBase
6
+ source_root File.expand_path('../templates', __FILE__)
7
+
8
+ class_option :root_node, :type => :string, :default => 'Root', :desc => 'Name of the root node'
9
+
10
+ def create_lib_netzke
11
+ inside 'lib' do
12
+ FileUtils.mkdir('netzke') if !File.directory?('netzke')
13
+ end
14
+ end
15
+
16
+ def create_widget
17
+ template 'tree_widget.erb', "lib/netzke/tree/#{name}_widget.rb"
18
+ end
19
+
20
+ protected
21
+
22
+ def class_name
23
+ name.camelize
24
+ end
25
+
26
+ def root_node
27
+ options[:root_node]
28
+ end
29
+ end
30
+ end
31
+ end
File without changes
metadata ADDED
@@ -0,0 +1,80 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: netzke_widget_generators
3
+ version: !ruby/object:Gem::Version
4
+ prerelease: false
5
+ segments:
6
+ - 0
7
+ - 1
8
+ - 0
9
+ version: 0.1.0
10
+ platform: ruby
11
+ authors:
12
+ - Kristian Mandrup
13
+ autorequire:
14
+ bindir: bin
15
+ cert_chain: []
16
+
17
+ date: 2010-06-26 00:00:00 +02:00
18
+ default_executable:
19
+ dependencies: []
20
+
21
+ description: Rails 3 generators for Netzke widgets
22
+ email: kmandrup@gmail.com
23
+ executables: []
24
+
25
+ extensions: []
26
+
27
+ extra_rdoc_files:
28
+ - LICENSE
29
+ - README.markdown
30
+ files:
31
+ - .document
32
+ - .gitignore
33
+ - LICENSE
34
+ - README.markdown
35
+ - Rakefile
36
+ - VERSION
37
+ - lib/generators/netzke/blp_widget/USAGE
38
+ - lib/generators/netzke/blp_widget/blp_widget_generator.rb
39
+ - lib/generators/netzke/blp_widget/templates/blp_widget.erb
40
+ - lib/generators/netzke/grid_panel_widget/USAGE
41
+ - lib/generators/netzke/grid_panel_widget/grid_panel_widget_generator.rb
42
+ - lib/generators/netzke/grid_panel_widget/templates/grid_panel_widget.erb
43
+ - lib/generators/netzke/tree_widget/USAGE
44
+ - lib/generators/netzke/tree_widget/templates/tree_widget.erb
45
+ - lib/generators/netzke/tree_widget/tree_widget_generator.rb
46
+ - lib/netzke_widget_generators.rb
47
+ has_rdoc: true
48
+ homepage: http://github.com/kristianmandrup/netzke_widget_generators
49
+ licenses: []
50
+
51
+ post_install_message:
52
+ rdoc_options:
53
+ - --charset=UTF-8
54
+ require_paths:
55
+ - lib
56
+ required_ruby_version: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ segments:
62
+ - 0
63
+ version: "0"
64
+ required_rubygems_version: !ruby/object:Gem::Requirement
65
+ none: false
66
+ requirements:
67
+ - - ">="
68
+ - !ruby/object:Gem::Version
69
+ segments:
70
+ - 0
71
+ version: "0"
72
+ requirements: []
73
+
74
+ rubyforge_project:
75
+ rubygems_version: 1.3.7
76
+ signing_key:
77
+ specification_version: 3
78
+ summary: Rails 3 generators for Netzke widgets
79
+ test_files: []
80
+