netzke-core 0.5.5 → 0.6.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.autotest +1 -1
- data/.gitignore +4 -2
- data/CHANGELOG.rdoc +37 -15
- data/README.rdoc +93 -28
- data/Rakefile +5 -7
- data/TODO +24 -3
- data/app/controllers/netzke_controller.rb +70 -0
- data/app/models/netzke_preference.rb +170 -0
- data/autotest/discover.rb +2 -3
- data/features/actions.feature +13 -0
- data/features/basic.feature +7 -0
- data/features/client-server.feature +15 -0
- data/features/complex_component.feature +18 -0
- data/features/component.feature +13 -0
- data/features/component_loader.feature +31 -0
- data/features/composition.feature +32 -0
- data/features/custom_css.feature +17 -0
- data/features/file_inclusion.feature +13 -0
- data/features/inheritance.feature +19 -0
- data/features/persistence.feature +16 -0
- data/features/scopes.feature +17 -0
- data/features/step_definitions/custom_css_steps.rb +7 -0
- data/features/step_definitions/generic_steps.rb +15 -0
- data/features/step_definitions/web_steps.rb +219 -0
- data/features/support/env.rb +62 -0
- data/features/support/paths.rb +45 -0
- data/generators/netzke_core/USAGE +3 -3
- data/generators/netzke_core/netzke_core_generator.rb +8 -0
- data/install.rb +1 -1
- data/javascripts/core.js +542 -499
- data/lib/generators/migration_helper.rb +32 -0
- data/lib/generators/netzke/USAGE +9 -0
- data/lib/generators/netzke/core_generator.rb +24 -0
- data/lib/netzke/actions.rb +102 -0
- data/lib/netzke/base.rb +77 -529
- data/lib/netzke/composition.rb +251 -0
- data/lib/netzke/configuration.rb +134 -0
- data/lib/netzke/core/masquerading.rb +34 -0
- data/lib/netzke/core/session.rb +30 -0
- data/lib/netzke/core/version.rb +11 -0
- data/lib/netzke/core.rb +53 -0
- data/lib/netzke/core_ext/array.rb +30 -0
- data/lib/netzke/core_ext/hash.rb +84 -0
- data/lib/netzke/core_ext/string.rb +26 -0
- data/lib/netzke/core_ext/symbol.rb +13 -0
- data/lib/netzke/core_ext/time_with_zone.rb +7 -0
- data/lib/netzke/core_ext.rb +5 -141
- data/lib/netzke/embedding.rb +21 -0
- data/lib/netzke/ext_component.rb +25 -0
- data/lib/netzke/javascript.rb +248 -0
- data/lib/netzke/persistence.rb +118 -0
- data/lib/netzke/rails/action_view_ext.rb +103 -0
- data/lib/netzke/{controller_extensions.rb → rails/controller_extensions.rb} +7 -2
- data/lib/netzke/rails/routes.rb +7 -0
- data/lib/netzke/services.rb +68 -0
- data/lib/netzke/session.rb +35 -0
- data/lib/netzke/stylesheets.rb +52 -0
- data/lib/netzke-core.rb +28 -29
- data/netzke-core.gemspec +253 -0
- data/spec/component/actions_spec.rb +94 -0
- data/spec/component/base_spec.rb +25 -0
- data/spec/component/composition_spec.rb +132 -0
- data/spec/component/javascript_spec.rb +15 -0
- data/spec/core_ext_spec.rb +16 -0
- data/spec/spec.opt +2 -0
- data/spec/spec_helper.rb +35 -0
- data/{test/app_root/db/migrate/20081222035855_create_netzke_preferences.rb → templates/core/create_netzke_preferences.rb} +4 -4
- data/test/rails_app/.gitignore +4 -0
- data/test/rails_app/Gemfile +36 -0
- data/test/rails_app/Gemfile.lock +137 -0
- data/test/rails_app/README +15 -0
- data/test/rails_app/Rakefile +7 -0
- data/test/rails_app/app/components/border_layout_panel.rb +4 -0
- data/test/rails_app/app/components/component_loader.rb +59 -0
- data/test/rails_app/app/components/component_with_actions.rb +58 -0
- data/test/rails_app/app/components/component_with_custom_css.rb +8 -0
- data/test/rails_app/app/components/component_with_included_js.rb +16 -0
- data/test/rails_app/app/components/component_with_session_persistence.rb +25 -0
- data/test/rails_app/app/components/custom.css +3 -0
- data/test/rails_app/app/components/deprecated/server_caller.rb +20 -0
- data/test/rails_app/app/components/extended_component_with_actions.rb +5 -0
- data/test/rails_app/app/components/extended_server_caller.rb +18 -0
- data/test/rails_app/app/components/included.js +5 -0
- data/test/rails_app/app/components/kinda_complex_component/basic_stuff.rb +35 -0
- data/test/rails_app/app/components/kinda_complex_component/extra_stuff.rb +16 -0
- data/test/rails_app/app/components/kinda_complex_component.rb +7 -0
- data/test/rails_app/app/components/loader_of_component_with_custom_css.rb +15 -0
- data/test/rails_app/app/components/scoped_components/deep_scoped_components/some_deep_scoped_component.rb +7 -0
- data/test/rails_app/app/components/scoped_components/extended_scoped_component.rb +5 -0
- data/test/rails_app/app/components/scoped_components/some_scoped_component.rb +5 -0
- data/test/rails_app/app/components/server_caller.rb +21 -0
- data/test/rails_app/app/components/simple_component.rb +5 -0
- data/test/rails_app/app/components/simple_tab_panel.rb +27 -0
- data/test/rails_app/app/components/simple_window.rb +3 -0
- data/test/rails_app/app/components/some_composite.rb +65 -0
- data/test/rails_app/app/components/some_ext_component.rb +8 -0
- data/test/{app_root → rails_app}/app/controllers/application_controller.rb +1 -0
- data/test/rails_app/app/controllers/components_controller.rb +12 -0
- data/test/rails_app/app/controllers/multiple_components_controller.rb +2 -0
- data/test/rails_app/app/controllers/welcome_controller.rb +5 -0
- data/test/rails_app/app/helpers/application_helper.rb +2 -0
- data/test/rails_app/app/views/layouts/application.html.erb +13 -0
- data/test/rails_app/app/views/multiple_components/set_one.html.erb +3 -0
- data/test/rails_app/config/application.rb +45 -0
- data/test/rails_app/config/boot.rb +13 -0
- data/test/rails_app/config/database.yml +22 -0
- data/test/rails_app/config/environment.rb +6 -0
- data/test/rails_app/config/environments/development.rb +22 -0
- data/test/rails_app/config/environments/production.rb +49 -0
- data/test/rails_app/config/environments/test.rb +35 -0
- data/test/rails_app/config/initializers/backtrace_silencers.rb +7 -0
- data/test/rails_app/config/initializers/inflections.rb +10 -0
- data/test/rails_app/config/initializers/mime_types.rb +5 -0
- data/test/rails_app/config/initializers/netzke.rb +3 -0
- data/test/rails_app/config/initializers/secret_token.rb +7 -0
- data/test/rails_app/config/initializers/session_store.rb +8 -0
- data/test/rails_app/config/locales/en.yml +5 -0
- data/test/rails_app/config/routes.rb +64 -0
- data/test/rails_app/config.ru +4 -0
- data/test/rails_app/db/development_structure.sql +4 -0
- data/{generators/netzke_core/templates/create_netzke_preferences.rb → test/rails_app/db/migrate/20100905214933_create_netzke_preferences.rb} +1 -3
- data/test/rails_app/db/schema.rb +24 -0
- data/test/rails_app/db/seeds.rb +7 -0
- data/test/{app_root/config/environments/in_memory.rb → rails_app/lib/tasks/.gitkeep} +0 -0
- data/test/rails_app/public/404.html +26 -0
- data/test/rails_app/public/422.html +26 -0
- data/test/rails_app/public/500.html +26 -0
- data/test/{app_root/config/environments/mysql.rb → rails_app/public/favicon.ico} +0 -0
- data/test/rails_app/public/images/rails.png +0 -0
- data/test/rails_app/public/robots.txt +5 -0
- data/test/rails_app/script/rails +6 -0
- data/test/{app_root/config/environments/postgresql.rb → rails_app/vendor/plugins/.gitkeep} +0 -0
- data/test/unit/netzke_core_test.rb +74 -75
- data/test/unit/netzke_preference_test.rb +2 -2
- metadata +176 -48
- data/lib/app/controllers/netzke_controller.rb +0 -46
- data/lib/app/models/netzke_preference.rb +0 -171
- data/lib/netzke/action_view_ext.rb +0 -81
- data/lib/netzke/base_js.rb +0 -339
- data/lib/netzke/routing.rb +0 -9
- data/test/app_root/app/models/role.rb +0 -3
- data/test/app_root/app/models/user.rb +0 -3
- data/test/app_root/config/boot.rb +0 -115
- data/test/app_root/config/database.yml +0 -31
- data/test/app_root/config/environment.rb +0 -14
- data/test/app_root/config/environments/sqlite.rb +0 -0
- data/test/app_root/config/environments/sqlite3.rb +0 -0
- data/test/app_root/config/routes.rb +0 -4
- data/test/app_root/db/migrate/20090423214303_create_roles.rb +0 -11
- data/test/app_root/db/migrate/20090423222114_create_users.rb +0 -12
- data/test/app_root/lib/console_with_fixtures.rb +0 -4
- data/test/app_root/script/console +0 -7
@@ -0,0 +1,32 @@
|
|
1
|
+
module MigrationHelper
|
2
|
+
include Rails::Generators::Migration
|
3
|
+
|
4
|
+
module ClassMethods
|
5
|
+
def migration_lookup_at(dirname) #:nodoc:
|
6
|
+
Dir.glob("#{dirname}/[0-9]*_*.rb")
|
7
|
+
end
|
8
|
+
|
9
|
+
def migration_exists?(dirname, file_name) #:nodoc:
|
10
|
+
migration_lookup_at(dirname).grep(/\d+_#{file_name}.rb$/).first
|
11
|
+
end
|
12
|
+
|
13
|
+
def current_migration_number(dirname) #:nodoc:
|
14
|
+
migration_lookup_at(dirname).collect do |file|
|
15
|
+
File.basename(file).split("_").first.to_i
|
16
|
+
end.max.to_i
|
17
|
+
end
|
18
|
+
|
19
|
+
def next_migration_number(dirname) #:nodoc:
|
20
|
+
orm = Rails.configuration.generators.options[:rails][:orm]
|
21
|
+
require "rails/generators/#{orm}"
|
22
|
+
"#{orm.to_s.camelize}::Generators::Base".constantize.next_migration_number(dirname)
|
23
|
+
rescue
|
24
|
+
raise NotImplementedError
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
def self.included(base) #:nodoc:
|
29
|
+
puts "MigrationHelper included by #{base}"
|
30
|
+
base.extend ClassMethods
|
31
|
+
end
|
32
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
require 'rails/generators'
|
2
|
+
require 'rails/generators/migration'
|
3
|
+
require 'generators/migration_helper'
|
4
|
+
|
5
|
+
module Netzke
|
6
|
+
module Generators
|
7
|
+
class CoreGenerator < Rails::Generators::Base
|
8
|
+
include ::MigrationHelper
|
9
|
+
|
10
|
+
def execute
|
11
|
+
migration_template 'create_netzke_preferences.rb', 'db/migrate/create_netzke_preferences.rb'
|
12
|
+
end
|
13
|
+
|
14
|
+
def self.source_root
|
15
|
+
File.join(gem_root, 'templates', 'core')
|
16
|
+
end
|
17
|
+
|
18
|
+
def self.gem_root
|
19
|
+
File.expand_path("../../../../", __FILE__)
|
20
|
+
end
|
21
|
+
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,102 @@
|
|
1
|
+
module Netzke
|
2
|
+
# Netzke component allows specifying Ext actions.
|
3
|
+
# An action can be defined in 2 different ways, both of which result in a method definition like this
|
4
|
+
# def _<some_action>_action
|
5
|
+
# ...
|
6
|
+
# end
|
7
|
+
#
|
8
|
+
# The 2 ways to define an action are:
|
9
|
+
# * as a hash:
|
10
|
+
# action :bug_server, :text => "Call server", :icon => "/images/icons/phone.png"
|
11
|
+
#
|
12
|
+
# * as a block:
|
13
|
+
# action :bug_server do
|
14
|
+
# {:text => config[:text], :disabled => true}
|
15
|
+
# end
|
16
|
+
#
|
17
|
+
# The block can optionally receive the configuration of an action being overridden:
|
18
|
+
# action :bug_server do |orig|
|
19
|
+
# {:text => config[:text] + orig[:text], :disabled => orig[:disabled]}
|
20
|
+
# end
|
21
|
+
module Actions
|
22
|
+
extend ActiveSupport::Concern
|
23
|
+
|
24
|
+
ACTION_METHOD_NAME = "%s_action"
|
25
|
+
ACTION_METHOD_REGEXP = /^(.+)_action$/
|
26
|
+
|
27
|
+
included do
|
28
|
+
alias_method_chain :js_config, :actions
|
29
|
+
end
|
30
|
+
|
31
|
+
module ClassMethods
|
32
|
+
def action(name, config = {}, &block)
|
33
|
+
config[:name] = name.to_s
|
34
|
+
method_name = ACTION_METHOD_NAME % name
|
35
|
+
|
36
|
+
if block_given?
|
37
|
+
define_method(method_name, &block)
|
38
|
+
else
|
39
|
+
if superclass.instance_methods.map(&:to_s).include?(method_name)
|
40
|
+
define_method(method_name) do
|
41
|
+
super().merge(config)
|
42
|
+
end
|
43
|
+
else
|
44
|
+
define_method(method_name) do
|
45
|
+
config
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
# Actions to be used in the config
|
53
|
+
def actions
|
54
|
+
# Call all the action related methods to collect the actions
|
55
|
+
self.class.instance_methods.grep(ACTION_METHOD_REGEXP).inject({}) do |r, m|
|
56
|
+
m.match(ACTION_METHOD_REGEXP)
|
57
|
+
r.merge($1.to_sym => normalize_action_config(send(m)))
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
def js_config_with_actions #:nodoc
|
62
|
+
actions.empty? ? js_config_without_actions : js_config_without_actions.merge(:actions => actions)
|
63
|
+
end
|
64
|
+
|
65
|
+
private
|
66
|
+
def normalize_action_config(config)
|
67
|
+
if config[:icon].is_a?(Symbol)
|
68
|
+
config[:icon] = Netzke::Core.with_icons ? Netzke::Core.icons_uri + "/" + config[:icon].to_s + ".png" : nil
|
69
|
+
end
|
70
|
+
|
71
|
+
config[:text] ||= config[:name].humanize
|
72
|
+
|
73
|
+
config
|
74
|
+
end
|
75
|
+
|
76
|
+
def auto_collect_actions_from_config_and_js_properties
|
77
|
+
# res = extract_actions(js_properties)
|
78
|
+
# puts %Q(!!! res: #{res.inspect}\n)
|
79
|
+
end
|
80
|
+
|
81
|
+
# def extract_actions(hsh)
|
82
|
+
# hsh.each_pair.inject({}) do |r,(k,v)|
|
83
|
+
# v.is_a?(Array) ? r.merge(extract_actions_from_array(v)) : r
|
84
|
+
# end
|
85
|
+
# end
|
86
|
+
#
|
87
|
+
# def extract_actions_from_array(arry)
|
88
|
+
# arry.inject({}) do |r, el|
|
89
|
+
# if el.is_a?(Hash)
|
90
|
+
# el[:action] ? r.merge(el[:action] => default_action_config(el[:action])) : r.merge(extract_actions(el))
|
91
|
+
# else
|
92
|
+
# r
|
93
|
+
# end
|
94
|
+
# end
|
95
|
+
# end
|
96
|
+
#
|
97
|
+
# def default_action_config(action_name)
|
98
|
+
# {:text => action_name.to_s.humanize}
|
99
|
+
# end
|
100
|
+
|
101
|
+
end
|
102
|
+
end
|