caterpillar 0.9.16 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/ChangeLog +9 -1
- data/README +36 -6
- data/generators/caterpillar/USAGE +1 -1
- data/generators/caterpillar/caterpillar_generator.rb +44 -25
- data/generators/caterpillar/templates/config/portlets.rb +5 -5
- data/generators/caterpillar/templates/images/portlet_test_bench/Leafy_Sea_Dragon_1.jpg +0 -0
- data/generators/caterpillar/templates/images/portlet_test_bench/debug.jpg +0 -0
- data/generators/caterpillar/templates/images/portlet_test_bench/java.png +0 -0
- data/generators/caterpillar/templates/images/portlet_test_bench/rails.png +0 -0
- data/generators/caterpillar/templates/images/portlet_test_bench/ruby.gif +0 -0
- data/generators/caterpillar/templates/javascripts/portlet_test_bench/main.js +3 -0
- data/generators/caterpillar/templates/stylesheets/portlet_test_bench/main.css +163 -0
- data/init.rb +30 -3
- data/lib/caterpillar.rb +36 -1
- data/lib/caterpillar/config.rb +12 -2
- data/lib/caterpillar/liferay.rb +70 -14
- data/lib/caterpillar/portlet.rb +9 -0
- data/lib/caterpillar/task.rb +3 -12
- data/lib/web/portlet.rb +0 -7
- data/portlet_test_bench/controllers/caterpillar/application.rb +13 -0
- data/portlet_test_bench/controllers/caterpillar/css_controller.rb +9 -0
- data/portlet_test_bench/controllers/caterpillar/http_methods_controller.rb +35 -0
- data/portlet_test_bench/controllers/caterpillar/js_controller.rb +74 -0
- data/portlet_test_bench/controllers/caterpillar/login_controller.rb +41 -0
- data/portlet_test_bench/controllers/caterpillar/resource_controller.rb +23 -0
- data/portlet_test_bench/controllers/caterpillar/session_controller.rb +57 -0
- data/portlet_test_bench/controllers/caterpillar/user_controller.rb +6 -0
- data/portlet_test_bench/helpers/caterpillar/application_helper.rb +3 -0
- data/portlet_test_bench/routing.rb +43 -0
- data/portlet_test_bench/views/caterpillar/application/_back_to_menu.html.erb +13 -0
- data/portlet_test_bench/views/caterpillar/application/index.html.erb +70 -0
- data/portlet_test_bench/views/caterpillar/css/background.html.erb +30 -0
- data/portlet_test_bench/views/caterpillar/css/simple.html.erb +53 -0
- data/portlet_test_bench/views/caterpillar/http_methods/back.html.erb +2 -0
- data/portlet_test_bench/views/caterpillar/http_methods/parameter.html.erb +21 -0
- data/portlet_test_bench/views/caterpillar/http_methods/post.html.erb +43 -0
- data/portlet_test_bench/views/caterpillar/http_methods/post_and_redirect.html.erb +25 -0
- data/portlet_test_bench/views/caterpillar/http_methods/redirect.html.erb +4 -0
- data/portlet_test_bench/views/caterpillar/js/_scriptaculous_jquery.html.erb +19 -0
- data/portlet_test_bench/views/caterpillar/js/dragndrop.html.erb +40 -0
- data/portlet_test_bench/views/caterpillar/js/jquery.html.erb +5 -0
- data/portlet_test_bench/views/caterpillar/js/link_to_post.html.erb +5 -0
- data/portlet_test_bench/views/caterpillar/js/prototype.html.erb +5 -0
- data/portlet_test_bench/views/caterpillar/js/scriptaculous.html.erb +10 -0
- data/portlet_test_bench/views/caterpillar/js/simple.html.erb +34 -0
- data/portlet_test_bench/views/caterpillar/login/index.html.erb +52 -0
- data/portlet_test_bench/views/caterpillar/resource/exit_portlet.html.erb +3 -0
- data/portlet_test_bench/views/caterpillar/resource/images.html.erb +13 -0
- data/portlet_test_bench/views/caterpillar/user/home.html.erb +3 -0
- data/portlet_test_bench/views/layouts/basic.html.erb +20 -0
- metadata +61 -3
data/ChangeLog
CHANGED
@@ -1,4 +1,12 @@
|
|
1
|
-
|
1
|
+
= 1.0.0
|
2
|
+
- improved rubygem loading; detect RAILS_GEM_VERSION
|
3
|
+
- included portlet test bench
|
4
|
+
- generator is now filesystem independent
|
5
|
+
|
6
|
+
= 0.9.17
|
7
|
+
- add role definitions; all portlets are only addable by admin
|
8
|
+
- define control panel category in Liferay 5.2
|
9
|
+
|
2
10
|
= 0.9.16
|
3
11
|
- fixed undefined RAILS_ROOT bug
|
4
12
|
- cleaned out unused JARs; the gem is now smaller
|
data/README
CHANGED
@@ -2,7 +2,37 @@ Caterpillar helps you with building Rails applications to be used in Java
|
|
2
2
|
JSR286 portlets. This is possible with the help of Rails-portlet[http://rails-portlet.rubyforge.org].
|
3
3
|
|
4
4
|
Writing Rails portlets for Liferay is great fun!
|
5
|
-
Caterpillar tasks offer specialized
|
5
|
+
Caterpillar tasks offer specialized tasks for better Liferay integration,
|
6
|
+
the Rails-portlet JAR for the portlet container and a portlet test bench application,
|
7
|
+
that integrates into any Rails project when you 'pluginize' Caterpillar.
|
8
|
+
|
9
|
+
== Quickstart ==
|
10
|
+
Start up a new Rails project:
|
11
|
+
|
12
|
+
$ rails shiny_app
|
13
|
+
$ cd shiny_app
|
14
|
+
$ caterpillar pluginize
|
15
|
+
|
16
|
+
Activate the test bench portlet by inserting 'map.caterpillar' in RAILS_ROOT/config/routes.rb before any other routes.
|
17
|
+
|
18
|
+
If you are using Liferay, +require 'lportal'+ in the Rails startup:
|
19
|
+
|
20
|
+
$ echo "require 'lportal'" > config/initializers/lportal.rb
|
21
|
+
|
22
|
+
Finally, set up the database connection. Then you should run +caterpillar portlets+ to check if your installation is working. The output should be something like this:
|
23
|
+
|
24
|
+
Caterpillar: version 0.9.9999
|
25
|
+
Using Liferay schema build 5101, version 5.1.1
|
26
|
+
Caterpillar configured for Liferay version 5.1.1 at /usr/local/liferay/
|
27
|
+
* Portlet configuration ***********************
|
28
|
+
Caterpillar
|
29
|
+
Rails-portlet test bench "portlet_test_bench" []
|
30
|
+
|
31
|
+
Then you can start up the server (./script/server) and navigate to http://localhost:3000/caterpillar/test_bench
|
32
|
+
|
33
|
+
|
34
|
+
== Useful tasks ==
|
35
|
+
Here are the most useful tasks; see the rdoc documentation and caterpillar --describe for the full feature list.
|
6
36
|
|
7
37
|
++xml++ and ++xml:deploy++
|
8
38
|
- processes the portlet XML configuration in accordance with the named routes
|
@@ -15,10 +45,11 @@ See Caterpillar::Config
|
|
15
45
|
- warbles the application, updates the XML configuration and copies these to Liferay
|
16
46
|
|
17
47
|
++pluginize++
|
18
|
-
- provides a navigation view in development (you will have to enable it manually)
|
19
|
-
See Caterpillar::Navigation
|
48
|
+
- provides a navigation view in development (you will have to enable it manually).
|
49
|
+
See Caterpillar::Navigation
|
50
|
+
- includes the portlet test bench
|
20
51
|
|
21
|
-
++db:migrate++
|
52
|
+
++db:migrate++ and ++db:update++
|
22
53
|
- offers a set of migrations to help with Liferay integration
|
23
54
|
|
24
55
|
- patches Web::Portlet in the lportal[http://lportal.rubyforge.org] library, so manipulating
|
@@ -28,10 +59,9 @@ See Caterpillar::Navigation
|
|
28
59
|
- imports live data from the production database for testing
|
29
60
|
|
30
61
|
|
31
|
-
See the rdoc documentation and caterpillar --describe for the full feature list.
|
32
|
-
|
33
62
|
|
34
63
|
Caterpillar is open source! Patches and comments are welcome.
|
35
64
|
Join the bugs mailing list (http://rubyforge.org/mailman/listinfo/rails-portlet-bugs) to request help.
|
36
65
|
|
37
66
|
Caterpillar is written by Mikael Lammentausta for Cel'Amanzi Ltd.
|
67
|
+
|
@@ -1 +1 @@
|
|
1
|
-
This
|
1
|
+
This installs Caterpillar development navigation and the portlet test bench images, javascripts and stylesheets into the Rails' public folder.
|
@@ -6,40 +6,59 @@ class CaterpillarGenerator < Rails::Generator::Base
|
|
6
6
|
require 'find'
|
7
7
|
file = File.symlink?(__FILE__) ? File.readlink(__FILE__) : __FILE__
|
8
8
|
this_dir = File.dirname(File.expand_path(file))
|
9
|
-
tmpl = this_dir
|
9
|
+
tmpl = File.join(this_dir,'templates')
|
10
10
|
|
11
|
-
STDOUT.puts ' * Installing
|
11
|
+
STDOUT.puts ' * Installing configuration file with images, stylesheets and javascripts.'
|
12
|
+
STDOUT.puts ' * If you want to use the portlet test bench,'
|
13
|
+
STDOUT.puts ' * put the following line in your config/routes.rb before other routes.'
|
14
|
+
STDOUT.puts ' * map.caterpillar'
|
15
|
+
STDOUT.puts ' *'
|
12
16
|
|
13
17
|
record do |m|
|
14
18
|
|
15
19
|
### config ###
|
16
20
|
m.directory('config')
|
17
21
|
file = 'portlets.rb'
|
18
|
-
m.file('config
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
# ### stylesheet ###
|
24
|
-
# target = 'public/stylesheets/caterpillar'
|
25
|
-
# m.directory(target)
|
26
|
-
# file = 'caterpillar.css'
|
27
|
-
# m.file('stylesheets/caterpillar/'+file, target+'/'+file)
|
28
|
-
# ####################################
|
29
|
-
#
|
30
|
-
# ### javascript ###
|
31
|
-
# target = 'public/javascripts/caterpillar'
|
32
|
-
# m.directory(target)
|
33
|
-
# file = 'caterpillar.js'
|
34
|
-
# m.file('javascripts/caterpillar/'+file, target+'/'+file)
|
35
|
-
# ####################################
|
36
|
-
|
37
|
-
### images ###
|
38
|
-
target = 'public/images'
|
22
|
+
m.file(File.join('config',file), File.join('config',file))
|
23
|
+
|
24
|
+
|
25
|
+
### Navigation ###
|
26
|
+
target = File.join('public','images')
|
39
27
|
m.directory(target)
|
40
28
|
file = 'caterpillar.gif'
|
41
|
-
m.file('images
|
42
|
-
|
29
|
+
m.file(File.join('images','caterpillar',file), File.join(target,file))
|
30
|
+
|
31
|
+
|
32
|
+
### Test bench ###
|
33
|
+
testb = 'portlet_test_bench'
|
34
|
+
#
|
35
|
+
# images
|
36
|
+
#
|
37
|
+
target = File.join('public','images',testb)
|
38
|
+
m.directory(target)
|
39
|
+
Find.find(File.join(tmpl,'images',testb)) do |file|
|
40
|
+
if FileTest.directory?(file)
|
41
|
+
next
|
42
|
+
else
|
43
|
+
img = File.basename(file)
|
44
|
+
next unless img[/(.jpg|.png|.gif)$/]
|
45
|
+
m.file(File.join('images',testb,img), File.join(target,img))
|
46
|
+
end
|
47
|
+
end
|
48
|
+
#
|
49
|
+
# stylesheets
|
50
|
+
#
|
51
|
+
target = File.join('public','stylesheets',testb)
|
52
|
+
m.directory(target)
|
53
|
+
file = 'main.css'
|
54
|
+
m.file(File.join('stylesheets',testb,file), File.join(target,file))
|
55
|
+
#
|
56
|
+
# javascripts
|
57
|
+
#
|
58
|
+
target = File.join('public','javascripts',testb)
|
59
|
+
m.directory(target)
|
60
|
+
file = 'main.js'
|
61
|
+
m.file(File.join('javascripts',testb,file), File.join(target,file))
|
43
62
|
|
44
63
|
end
|
45
64
|
end
|
@@ -52,12 +52,12 @@ Caterpillar::Config.new do |portlet|
|
|
52
52
|
# - :servlet -- by default, the name of the Rails app (= name of the WAR package)
|
53
53
|
# - :path -- unless you're using named routes, you can define the path here
|
54
54
|
|
55
|
-
# Rails-portlet testing application
|
55
|
+
# Rails-portlet testing application.
|
56
|
+
# NOTE: this needs to be activated by 'map.caterpillar' in RAILS_ROOT/config/routes.rb
|
56
57
|
portlet.instances << {
|
57
|
-
:name => '
|
58
|
-
:title => 'Rails-portlet
|
59
|
-
:category => 'Caterpillar'
|
60
|
-
:path => '/RailsTestBench'
|
58
|
+
:name => 'portlet_test_bench',
|
59
|
+
:title => 'Rails-portlet test bench',
|
60
|
+
:category => 'Caterpillar'
|
61
61
|
}
|
62
62
|
|
63
63
|
# this will include all named routes without further configuration
|
Binary file
|
Binary file
|
Binary file
|
@@ -0,0 +1,163 @@
|
|
1
|
+
/* main.css */
|
2
|
+
|
3
|
+
body {
|
4
|
+
background-color: #FFFFCC;
|
5
|
+
}
|
6
|
+
|
7
|
+
/* testing leading whitespaces */
|
8
|
+
body {
|
9
|
+
font: 11px Arial,Helvetica;
|
10
|
+
}
|
11
|
+
|
12
|
+
/* testing another id with "body" */
|
13
|
+
#some_other_body {}
|
14
|
+
|
15
|
+
.info {
|
16
|
+
padding: 10px;
|
17
|
+
border: 5px double #000000;
|
18
|
+
background: #FFEE31;
|
19
|
+
text-align: center;
|
20
|
+
width: auto;
|
21
|
+
margin: 20%;
|
22
|
+
margin-top: 25px;
|
23
|
+
margin-bottom: 25px;
|
24
|
+
font: 17px Times New Roman;
|
25
|
+
}
|
26
|
+
|
27
|
+
.notice {
|
28
|
+
padding: 10px;
|
29
|
+
border: 5px double #000000;
|
30
|
+
background: #FF575A;
|
31
|
+
text-align: center;
|
32
|
+
width: auto;
|
33
|
+
margin: 20%;
|
34
|
+
margin-top: 25px;
|
35
|
+
margin-bottom: 25px;
|
36
|
+
font: 14px Times New Roman;
|
37
|
+
}
|
38
|
+
|
39
|
+
/* used on css test page */
|
40
|
+
#simple_content {
|
41
|
+
margin: 25px; padding: 10px; border: 1px solid #000000; background: #93FFE4;
|
42
|
+
}
|
43
|
+
|
44
|
+
/* resource test page */
|
45
|
+
.resource_image_box {
|
46
|
+
margin: 25px; padding: 10px; border: 3px groove #74FFF6; background: #FFFFFF;
|
47
|
+
text-align: center;
|
48
|
+
}
|
49
|
+
|
50
|
+
.resource_image_description {
|
51
|
+
/* width: 49%; */
|
52
|
+
/* float: break; */
|
53
|
+
margin-left: 0%;
|
54
|
+
border-bottom: 1px solid #000000;
|
55
|
+
/* padding-right: 12px; */
|
56
|
+
/* margin-top: 20px; */
|
57
|
+
|
58
|
+
font: 21px Times New Roman;
|
59
|
+
}
|
60
|
+
|
61
|
+
.resource_image_tag {
|
62
|
+
width: auto;
|
63
|
+
margin-top: 5px;
|
64
|
+
/* float: break; */
|
65
|
+
/* margin-left: 51%; */
|
66
|
+
/* border: 1px solid #000000; */
|
67
|
+
}
|
68
|
+
|
69
|
+
/* HTTP POST */
|
70
|
+
#http_post {
|
71
|
+
background: white;
|
72
|
+
border: 3px dashed #278F19;
|
73
|
+
|
74
|
+
margin: 30px;
|
75
|
+
margin-top: 0px;
|
76
|
+
margin-bottom: 5px;
|
77
|
+
padding: 30px;
|
78
|
+
padding-top: 0px;
|
79
|
+
}
|
80
|
+
/* form input label */
|
81
|
+
#http_postform span {
|
82
|
+
margin-left: 10px;
|
83
|
+
margin-right: 5px;
|
84
|
+
}
|
85
|
+
/* form input paragraph */
|
86
|
+
#http_postform p {
|
87
|
+
padding: 4px;
|
88
|
+
margin: 3px;
|
89
|
+
/* border: 1px dotted gray; */
|
90
|
+
}
|
91
|
+
/* form submit */
|
92
|
+
#submit_tags {
|
93
|
+
margin-left: 10px;
|
94
|
+
margin-right: 5px;
|
95
|
+
}
|
96
|
+
|
97
|
+
#http_post h1 {
|
98
|
+
font: 21px Times New Roman;
|
99
|
+
padding: 3px;
|
100
|
+
}
|
101
|
+
#http_post h2 {
|
102
|
+
font: 12px Times New Roman;
|
103
|
+
border-bottom: 1px dashed gray;
|
104
|
+
padding: 3px;
|
105
|
+
}
|
106
|
+
#post_msg {
|
107
|
+
font: 21px Arial;
|
108
|
+
font-style: italic;
|
109
|
+
padding-left: 20px;
|
110
|
+
}
|
111
|
+
#post_info {
|
112
|
+
font: 14px Arial;
|
113
|
+
font-style: italic;
|
114
|
+
padding-left: 20px;
|
115
|
+
}
|
116
|
+
|
117
|
+
/* login */
|
118
|
+
.login_link {
|
119
|
+
padding: 20px;
|
120
|
+
font: 14px Arial;
|
121
|
+
border: 3px solid green;
|
122
|
+
background: white;
|
123
|
+
/* float: left; */
|
124
|
+
width: 20%;
|
125
|
+
margin: 4px;
|
126
|
+
}
|
127
|
+
|
128
|
+
/* Drag & drop test */
|
129
|
+
.dragdrop {
|
130
|
+
height: 200px;
|
131
|
+
border: 3px dotted blue;
|
132
|
+
float:left;
|
133
|
+
margin: 2%;
|
134
|
+
}
|
135
|
+
|
136
|
+
.dragdrop_id, #drop_status{
|
137
|
+
padding: 20px;
|
138
|
+
font: 14px Arial;
|
139
|
+
border: 3px solid green;
|
140
|
+
background: white;
|
141
|
+
width: 20%;
|
142
|
+
margin: 4px;
|
143
|
+
-moz-border-radius: 0 0 2em 0;
|
144
|
+
-webkit-border-radius: 0 0 2em 0;
|
145
|
+
}
|
146
|
+
|
147
|
+
#draggables {
|
148
|
+
width: 25%;
|
149
|
+
}
|
150
|
+
#droppables {
|
151
|
+
width: 65%;
|
152
|
+
}
|
153
|
+
|
154
|
+
.draggable {
|
155
|
+
float: left;
|
156
|
+
margin: 40px 0 0 24%;
|
157
|
+
cursor: move;
|
158
|
+
/* padding-left: 12%; */
|
159
|
+
}
|
160
|
+
|
161
|
+
#drop_status {
|
162
|
+
font: 14px Arial;
|
163
|
+
}
|
data/init.rb
CHANGED
@@ -1,8 +1,35 @@
|
|
1
|
+
# Rails plugin initialization.
|
2
|
+
|
1
3
|
file = File.symlink?(__FILE__) ? File.readlink(__FILE__) : __FILE__
|
2
4
|
this_dir = File.dirname(File.expand_path(file))
|
3
5
|
|
4
|
-
# append the views path
|
5
|
-
ActionController::Base.append_view_path File.join(this_dir, 'views')
|
6
|
-
|
7
6
|
# load the main file
|
8
7
|
require File.join(this_dir, 'lib', 'caterpillar')
|
8
|
+
|
9
|
+
STDERR.puts 'Caterpillar: version %s' % Caterpillar::VERSION
|
10
|
+
|
11
|
+
# Add Caterpillar portlet navigation to views paths
|
12
|
+
ActionController::Base.append_view_path File.join(this_dir, 'views')
|
13
|
+
|
14
|
+
### Portlet test bench
|
15
|
+
# Adding directories to the load path makes them appear just like files in the the main app directory.
|
16
|
+
ActiveSupport::Dependencies.load_paths << File.join(this_dir, 'portlet_test_bench', 'controllers')
|
17
|
+
ActiveSupport::Dependencies.load_paths << File.join(this_dir, 'portlet_test_bench', 'helpers')
|
18
|
+
|
19
|
+
# Removing a directory from the load once paths allow changes
|
20
|
+
# to be picked up as soon as you save the file – without having to restart the web server.
|
21
|
+
ActiveSupport::Dependencies.load_once_paths.delete(File.join(this_dir, 'portlet_test_bench'))
|
22
|
+
|
23
|
+
# Add views
|
24
|
+
ActionController::Base.append_view_path File.join(this_dir, 'portlet_test_bench','views')
|
25
|
+
|
26
|
+
# Define routes
|
27
|
+
# NOTE: the routes need to be activated by 'map.caterpillar' in RAILS_ROOT/config/routes.rb
|
28
|
+
require File.join(this_dir, 'portlet_test_bench', 'routing')
|
29
|
+
ActionController::Routing::RouteSet::Mapper.send :include, Caterpillar::Routing::MapperExtensions
|
30
|
+
|
31
|
+
# hack; the application controller needs to be loaded explicitly,
|
32
|
+
# but NOT for standard Caterpillar tasks (breaks the tasks)
|
33
|
+
unless $0[/caterpillar|generate/]
|
34
|
+
require File.join(this_dir, 'portlet_test_bench','controllers','caterpillar','application')
|
35
|
+
end
|
data/lib/caterpillar.rb
CHANGED
@@ -5,7 +5,7 @@
|
|
5
5
|
#++
|
6
6
|
|
7
7
|
module Caterpillar
|
8
|
-
VERSION='0.
|
8
|
+
VERSION='1.0.0'
|
9
9
|
end
|
10
10
|
|
11
11
|
this_file = File.symlink?(__FILE__) ? File.readlink(__FILE__) : __FILE__
|
@@ -16,6 +16,41 @@ CATERPILLAR_LIBS=this_dir unless defined?(CATERPILLAR_LIBS)
|
|
16
16
|
RAILS_ROOT = Dir.pwd unless defined? RAILS_ROOT
|
17
17
|
|
18
18
|
require 'find'
|
19
|
+
require 'rake'
|
20
|
+
require 'rake/tasklib'
|
21
|
+
|
22
|
+
# NOTE: During normal startup (not while building the gem),
|
23
|
+
# ActiveRecord should be loaded at this point, before loading any of the models.
|
24
|
+
# However, this may conflict later when Rails' rake task activates the boot process.
|
25
|
+
# The correct versions should be loaded at this point.
|
26
|
+
# Otherwise only one version of Rails & co. rubygems should exist on the system.
|
27
|
+
|
28
|
+
if $0[/gem$/]
|
29
|
+
rails_gem_version = nil
|
30
|
+
else
|
31
|
+
# Attempt to guess proper Rails version by reading Rails' config file
|
32
|
+
f=File.open(
|
33
|
+
File.join(
|
34
|
+
File.expand_path(RAILS_ROOT),
|
35
|
+
'config',
|
36
|
+
'environment.rb'
|
37
|
+
)
|
38
|
+
)
|
39
|
+
config = f.read
|
40
|
+
rails_gem_version = config[/RAILS_GEM_VERSION.*(\d\.\d\.\d)/,1]
|
41
|
+
f.close
|
42
|
+
end
|
43
|
+
|
44
|
+
# Load the proper versions of Rails etc.
|
45
|
+
# Not tested on all setups.
|
46
|
+
require 'rubygems'
|
47
|
+
['activesupport',
|
48
|
+
'actionpack',
|
49
|
+
'activerecord'].each { |rg|
|
50
|
+
gem(rg, '= '+rails_gem_version) if rails_gem_version
|
51
|
+
require rg
|
52
|
+
}
|
53
|
+
require 'action_controller'
|
19
54
|
|
20
55
|
# include all ruby files
|
21
56
|
Find.find(this_dir) do |file|
|