caterpillar 1.0.1 → 1.0.5

Sign up to get free protection for your applications and to get access to all the features.
data/ChangeLog CHANGED
@@ -1,3 +1,17 @@
1
+ = 1.0.5
2
+ - comply XML with Liferay 5.2.3 - output more XML with default values
3
+ - cleanup program output
4
+ - generator cleanup
5
+ - added portlet test for flash messages
6
+
7
+ = 1.0.4
8
+ - bugfix release
9
+
10
+ = 1.0.2
11
+ - support for installing on JBoss/Tomcat
12
+ - refined the Liferay variable detection test
13
+ - cleanup
14
+
1
15
  = 1.0.1
2
16
  - added test for liferay session variables
3
17
  - fixed XML validation error on 5.2.3 (all portlets are now uninstanceable)
@@ -84,3 +98,4 @@ Released at 2008-12-17
84
98
  - the initial release
85
99
 
86
100
 
101
+
data/README CHANGED
@@ -9,21 +9,20 @@ that integrates into any Rails project when you 'pluginize' Caterpillar.
9
9
  == Quickstart ==
10
10
  Start up a new Rails project:
11
11
 
12
- $ rails shiny_app
13
- $ cd shiny_app
12
+ $ rails example
13
+ $ cd example
14
14
  $ caterpillar pluginize
15
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:
16
+ Caterpillar contains Rails portlet test bench, which can be activated by inserting
17
+ +map.caterpillar+ in RAILS_ROOT/config/routes.rb before any other routes.
19
18
 
19
+ If you are connecting to the Liferay database, add +require 'lportal'+ in the Rails startup:
20
20
  $ echo "require 'lportal'" > config/initializers/lportal.rb
21
+ And set up the database connection.
21
22
 
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
+ Now you should run +caterpillar portlets+ to check if your installation is working.
24
+ The output should include these lines:
23
25
 
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
26
  * Portlet configuration ***********************
28
27
  Caterpillar
29
28
  Rails-portlet test bench "portlet_test_bench" []
@@ -31,6 +30,10 @@ Finally, set up the database connection. Then you should run +caterpillar portle
31
30
  Then you can start up the server (./script/server) and navigate to http://localhost:3000/caterpillar/test_bench
32
31
 
33
32
 
33
+ == Quick production deployment using JRuby ==
34
+ See the documentation in the example app (SVN checkout).
35
+
36
+
34
37
  == Useful tasks ==
35
38
  Here are the most useful tasks; see the rdoc documentation and caterpillar --describe for the full feature list.
36
39
 
@@ -1,18 +1,31 @@
1
1
  # This generator installs the required files into the main Rails application.
2
2
  # This generator should always be run after upgrading the plugin.
3
3
  class CaterpillarGenerator < Rails::Generator::Base
4
- def manifest
4
+ def msg(txt)
5
+ _txt = " *\n"
6
+ txt.split("\n").each do |line|
7
+ _txt << " * %s\n" % line
8
+ end
9
+ _txt << " *\n"
10
+ STDOUT.puts _txt
11
+ STDOUT.flush
12
+ end
5
13
 
14
+ def after_generate
15
+ msg(
16
+ "If you want to use the portlet test bench,\n" + \
17
+ "put the following line in your config/routes.rb before other routes.\n" + \
18
+ " map.caterpillar"
19
+ )
20
+ end
21
+
22
+ def manifest
6
23
  require 'find'
7
24
  file = File.symlink?(__FILE__) ? File.readlink(__FILE__) : __FILE__
8
25
  this_dir = File.dirname(File.expand_path(file))
9
26
  tmpl = File.join(this_dir,'templates')
10
27
 
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 ' *'
28
+ msg 'Installing configuration file with images, stylesheets and javascripts.'
16
29
 
17
30
  record do |m|
18
31
 
@@ -17,7 +17,18 @@ Caterpillar::Config.new do |portlet|
17
17
  #
18
18
  # No changes are made to any of the files in this directory while making XML,
19
19
  # only the deploy and install tasks make any changes.
20
- portlet.container.root = '/usr/local/liferay/'
20
+ # portlet.container.root = '/usr/local/liferay/'
21
+
22
+ # The server that the container is running on.
23
+ # Possible values:
24
+ # - 'Tomcat' (default)
25
+ # - 'JBoss/Tomcat'
26
+ # portlet.container.server = 'JBoss/Tomcat'
27
+
28
+ # The server dir is only meaningful with JBoss.
29
+ # This is the name of the directory in server/.
30
+ # By default the first entry in the directory is chosen.
31
+ # portlet.container.server_dir = 'default'
21
32
 
22
33
  # The hostname and port.
23
34
  # By default the values are taken from the request.
data/init.rb CHANGED
@@ -1,4 +1,11 @@
1
- # Rails plugin initialization.
1
+ #--
2
+ # (c) Copyright 2008,2009 Mikael Lammentausta
3
+ #
4
+ # See the file MIT-LICENSE included with the distribution for
5
+ # software license details.
6
+ #++
7
+
8
+ ### Initialize the Rails plugin.
2
9
 
3
10
  file = File.symlink?(__FILE__) ? File.readlink(__FILE__) : __FILE__
4
11
  this_dir = File.dirname(File.expand_path(file))
@@ -6,30 +13,32 @@ this_dir = File.dirname(File.expand_path(file))
6
13
  # load the main file
7
14
  require File.join(this_dir, 'lib', 'caterpillar')
8
15
 
9
- STDERR.puts 'Caterpillar: version %s' % Caterpillar::VERSION
16
+ #STDERR.puts 'Caterpillar: version %s' % Caterpillar::VERSION
10
17
 
11
18
  # Add Caterpillar portlet navigation to views paths
12
19
  ActionController::Base.append_view_path File.join(this_dir, 'views')
13
20
 
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')
21
+ ### Initialize the portlet test bench
22
+
23
+ # Adding directories to the load path makes them appear just like files in the the main app directory.
24
+ %w{ controllers helpers }.each do |path|
25
+ ActiveSupport::Dependencies.load_paths << File.join(this_dir, 'portlet_test_bench', path)
26
+ end
18
27
 
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'))
28
+ # Removing a directory from the load once paths allow changes
29
+ # to be picked up as soon as you save the file – without having to restart the web server.
30
+ ActiveSupport::Dependencies.load_once_paths.delete(File.join(this_dir, 'portlet_test_bench'))
22
31
 
23
- # Add views
24
- ActionController::Base.append_view_path File.join(this_dir, 'portlet_test_bench','views')
32
+ # Add views
33
+ ActionController::Base.append_view_path File.join(this_dir, 'portlet_test_bench','views')
25
34
 
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
35
+ # Define routes
36
+ # NOTE: the routes need to be activated by 'map.caterpillar' in RAILS_ROOT/config/routes.rb
37
+ require File.join(this_dir, 'portlet_test_bench', 'routing')
38
+ ActionController::Routing::RouteSet::Mapper.send :include, Caterpillar::Routing::MapperExtensions
30
39
 
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
40
+ # hack; the application controller needs to be loaded explicitly,
41
+ # but NOT for standard Caterpillar tasks (breaks the tasks)
42
+ unless $0[/caterpillar|generate/]
43
+ require File.join(this_dir, 'portlet_test_bench','controllers','caterpillar','application')
44
+ end
@@ -1,11 +1,12 @@
1
1
  #--
2
2
  # (c) Copyright 2008,2009 Mikael Lammentausta
3
- # See the file LICENSES.txt included with the distribution for
3
+ #
4
+ # See the file MIT-LICENSE included with the distribution for
4
5
  # software license details.
5
6
  #++
6
7
 
7
8
  module Caterpillar
8
- VERSION='1.0.1'
9
+ VERSION='1.0.5'
9
10
  end
10
11
 
11
12
  this_file = File.symlink?(__FILE__) ? File.readlink(__FILE__) : __FILE__
@@ -19,38 +20,7 @@ require 'find'
19
20
  require 'rake'
20
21
  require 'rake/tasklib'
21
22
 
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'
23
+ require File.join(this_dir,'load_rails')
54
24
 
55
25
  # include all ruby files
56
26
  Find.find(this_dir) do |file|
@@ -50,7 +50,7 @@ module Caterpillar
50
50
 
51
51
  @warbler_conf = File.join(@rails_root,'config','warble.rb')
52
52
  unless File.exists?(@warbler_conf)
53
- STDERR.puts 'Warbler configuration file could not be found'
53
+ #STDERR.puts 'Warbler configuration file could not be found'
54
54
  end
55
55
 
56
56
  #@logger = (defined?(RAILS_DEFAULT_LOGGER) ? RAILS_DEFAULT_LOGGER : Logger.new)
@@ -60,7 +60,7 @@ module Caterpillar
60
60
 
61
61
  # The container class is used for parsing XML files.
62
62
  #
63
- # Possible values: Liferay (default)
63
+ # Possible values: Caterpillar::Liferay (default using Tomcat)
64
64
  def container
65
65
  self._container || Caterpillar::Liferay.new
66
66
  end
@@ -72,4 +72,4 @@ module Caterpillar
72
72
 
73
73
 
74
74
  end
75
- end
75
+ end
@@ -5,7 +5,8 @@
5
5
  # software license details.
6
6
  #++
7
7
 
8
- module Caterpillar
8
+ module Caterpillar # :nodoc:
9
+
9
10
  # Creates liferay-portlet XML and liferay-display XML.
10
11
  # The latter optionally combines your production portlet display configuration.
11
12
  #
@@ -43,11 +44,20 @@ module Caterpillar
43
44
  # the installation directory
44
45
  attr_accessor :root
45
46
 
47
+ # server type:
48
+ # - 'Tomcat'
49
+ # - 'JBoss/Tomcat'
50
+ attr_accessor :server
51
+
52
+ # the name of the JBoss server directory
53
+ attr_accessor :server_dir
54
+
46
55
  # Liferay version is given as a String, eg. '5.2.2'.
47
56
  # Defaults to +Lportal::Schema.version+.
48
57
  def initialize(version=nil)
49
58
  @version = version
50
59
  @root = '/usr/local/liferay'
60
+ @server = 'Tomcat'
51
61
  end
52
62
 
53
63
  # The name of the portal. Used in STDOUT messages.
@@ -55,11 +65,55 @@ module Caterpillar
55
65
  'Liferay'
56
66
  end
57
67
 
68
+ def deploy_dir
69
+ raise 'Configure container root folder' unless self.root
70
+ case @server
71
+
72
+ when 'Tomcat'
73
+ root_dir = 'ROOT'
74
+ File.join(self.root,'webapps')
75
+
76
+ when 'JBoss/Tomcat'
77
+ # detect server name if not configured
78
+ @server_dir ||= Dir.new(
79
+ File.join(self.root,'server')).entries.first
80
+ path = File.join(self.root,'server',@server_dir,'deploy')
81
+
82
+ unless File.exists?(path)
83
+ raise 'Portal deployment directory does not exist: %s' % path
84
+ end
85
+
86
+ return path
87
+ end
88
+ end
89
+
58
90
  # The location of Liferay's WEB-INF folder for XML analyzation.
59
91
  # This is relative to installation directory (self.root)
60
92
  def WEB_INF
61
93
  raise 'Configure container root folder' unless self.root
62
- File.join(self.root,'webapps','ROOT','WEB-INF')
94
+ case @server
95
+
96
+ when 'Tomcat'
97
+ root_dir = 'ROOT'
98
+ File.join(self.deploy_dir,root_dir,'WEB-INF')
99
+
100
+ when 'JBoss/Tomcat'
101
+ # detect lportal dir (ROOT.war or lportal.war)
102
+ root_dir =
103
+ if File.exists?(File.join(self.deploy_dir,'ROOT.war'))
104
+ 'ROOT.war'
105
+ elsif File.exists?(File.join(self.deploy_dir,'lportal.war'))
106
+ 'lportal.war'
107
+ end
108
+ unless root_dir
109
+ STDERR.puts 'There seems to be a problem detecting the proper install paths.'
110
+ STDERR.puts 'Please file a bug on Caterpillar.'
111
+ raise 'Portal root directory not found at %s' % self.deploy_dir
112
+ end
113
+
114
+ File.join(self.deploy_dir,root_dir,'WEB-INF')
115
+
116
+ end
63
117
  end
64
118
 
65
119
  # Reads Liferay portlet descriptor XML files and parses them with Hpricot.
@@ -117,7 +171,6 @@ module Caterpillar
117
171
  end
118
172
  # debug
119
173
  #puts _p.inspect
120
- #portlets << _p
121
174
 
122
175
  end
123
176
  end
@@ -222,20 +275,40 @@ module Caterpillar
222
275
  end
223
276
  end
224
277
 
225
- # the actual portlet definition
278
+ # liferay-portlet-ext definition
279
+ #
280
+ # http://www.liferay.com/web/guest/community/wiki/-/wiki/Main/Liferay-portlet.xml
281
+ #
282
+ # The content of element type "portlet" must match "(portlet-name,icon?,virtual-path?,struts-path?,configuration-path?,configuration-action-class?,indexer-class?,open-search-class?,scheduler-class?,portlet-url-class?,friendly-url-mapper-class?,url-encoder-class?,portlet-data-handler-class?,portlet-layout-listener-class?,poller-processor-class?,pop-message-listener-class?,social-activity-interpreter-class?,social-request-interpreter-class?,webdav-storage-token?,webdav-storage-class?,control-panel-entry-category?,control-panel-entry-weight?,control-panel-entry-class?,preferences-company-wide?,preferences-unique-per-layout?,preferences-owned-by-group?,use-default-template?,show-portlet-access-denied?,show-portlet-inactive?,action-url-redirect?,restore-current-view?,maximize-edit?,maximize-help?,pop-up-print?,layout-cacheable?,instanceable?,scopeable?,user-principal-strategy?,private-request-attributes?,private-session-attributes?,render-weight?,ajaxable?,header-portal-css*,header-portlet-css*,header-portal-javascript*,header-portlet-javascript*,footer-portal-css*,footer-portlet-css*,footer-portal-javascript*,footer-portlet-javascript*,css-class-wrapper?,facebook-integration?,add-default-resource?,system?,active?,include?)".
226
283
  def portletapp_template(portlet)
227
284
  xml = " <portlet>\n"
228
285
  xml << " <portlet-name>%s</portlet-name>\n" % portlet[:name]
286
+ # portlet icon is favicon - FIXME: use proper host
229
287
  xml << " <icon>/%s/favicon.ico</icon>\n" % portlet[:servlet]
230
- # can there be several portlet instances on the same page?
231
- xml << " <instanceable>false</instanceable>\n"
232
- # define the control panel category for 5.2 and newer -
288
+
289
+ # define the control panel category for Liferay 5.2 and newer -
290
+ #
233
291
  # Note that when the control panel settings are defined,
234
292
  # the portlet cannot be instanceable.
235
293
  unless @version[/5.1/]
236
294
  xml << " <control-panel-entry-category>#{portlet[:category]}</control-panel-entry-category>\n"
237
- xml << " <control-panel-entry-weight>1.0</control-panel-entry-weight>\n"
295
+ xml << " <control-panel-entry-weight>420.0</control-panel-entry-weight>\n"
296
+ #xml << " <control-panel-entry-class></control-panel-entry-class>\n"
238
297
  end
298
+
299
+ # Set the use-default-template value to true if the portlet uses the default template to decorate and wrap content. Setting this to false allows the developer to own and maintain the portlet's entire outputted content. The default value is true.
300
+ #
301
+ # The most common use of this is if you want the portlet to look different from the other portlets or if you want the portlet to not have borders around the outputted content.
302
+ #
303
+ # RD: This is a nice option except that if you set it, then you loose all border functionality including drag, drop, min,max,edit,conf,close These should be controlled by a separate property.
304
+ xml << " <use-default-template>true</use-default-template>\n"
305
+
306
+ # can there be several portlet instances on the same page?
307
+ xml << " <instanceable>false</instanceable>\n"
308
+
309
+ # The default value of ajaxable is true. If set to false, then this portlet can never be displayed via Ajax.
310
+ xml << " <ajaxable>true</ajaxable>\n"
311
+
239
312
  # include javascripts?
240
313
  js_tag = (@version[/5.1/] ? 'header' : 'footer') + '-portal-javascript'
241
314
  portlet[:javascripts].each do |js|
@@ -243,6 +316,13 @@ module Caterpillar
243
316
  xml << "/#{portlet[:servlet]}/javascripts/#{js}"
244
317
  xml << "</#{js_tag}>\n"
245
318
  end
319
+
320
+ # If the add-default-resource value is set to true, the default portlet resources and permissions are added to the page. The user can then view the portlet.
321
+ xml << " <add-default-resource>true</add-default-resource>\n"
322
+ xml << " <system>false</system>\n"
323
+ xml << " <active>true</active>\n"
324
+ xml << " <include>true</include>\n"
325
+
246
326
  xml << " </portlet>\n\n"
247
327
  end
248
328
 
@@ -281,63 +361,68 @@ module Caterpillar
281
361
 
282
362
  # tables that are skipped when creating fixtures
283
363
  def skip_fixture_tables
284
- [
285
- "cyrususer","cyrusvirtual",
286
- "documentlibrary_fsentry","documentlibrary_binval","documentlibrary_node","documentlibrary_prop","documentlibrary_refs",
287
- "expandocolumn",
288
- "expandorow",
289
- "expandotable",
290
- "expandovalue",
291
- "image",
292
- "chat_entry",
293
- "chat_status",
294
- "journalcontentsearch",
295
- "mbban",
296
- "membershiprequest",
297
- "orglabor",
298
- "passwordpolicyrel",
299
- "passwordpolicy",
300
- "passwordtracker",
301
- "pluginsetting",
302
- "quartz_blob_triggers",
303
- "quartz_calendars",
304
- "quartz_cron_triggers",
305
- "quartz_fired_triggers",
306
- "quartz_job_details",
307
- "quartz_job_listeners",
308
- "quartz_locks",
309
- "quartz_paused_trigger_grps",
310
- "quartz_scheduler_state",
311
- "quartz_simple_triggers",
312
- "quartz_trigger_listeners",
313
- "quartz_triggers",
314
- "ratingsentry",
315
- "ratingsstats",
316
- "region",
317
- "scframeworkversion",
318
- "scframeworkversi_scproductvers",
319
- "schema_migrations",
320
- "sclicenses_scproductentries",
321
- "sclicense",
322
- "scproductentry",
323
- "scproductscreenshot",
324
- "scproductversion",
325
- "servicecomponent",
326
- "sessions",
327
- "shoppingcart",
328
- "shoppingcategory",
329
- "shoppingcoupon",
330
- "shoppingitemfield",
331
- "shoppingitemprice",
332
- "shoppingitem",
333
- "shoppingorderitem",
334
- "shoppingorder",
335
- "subscription",
336
- "tasksproposal",
337
- "tasksreview",
338
- "webdavprops",
339
- "website"
340
- ]
364
+ %w{
365
+ cyrususer
366
+ cyrusvirtual
367
+ documentlibrary_fsentry
368
+ documentlibrary_binval
369
+ documentlibrary_node
370
+ documentlibrary_prop
371
+ documentlibrary_refs
372
+ expandocolumn
373
+ expandorow
374
+ expandotable
375
+ expandovalue
376
+ image
377
+ chat_entry
378
+ chat_status
379
+ journalcontentsearch
380
+ mbban
381
+ membershiprequest
382
+ orglabor
383
+ passwordpolicyrel
384
+ passwordpolicy
385
+ passwordtracker
386
+ pluginsetting
387
+ quartz_blob_triggers
388
+ quartz_calendars
389
+ quartz_cron_triggers
390
+ quartz_fired_triggers
391
+ quartz_job_details
392
+ quartz_job_listeners
393
+ quartz_locks
394
+ quartz_paused_trigger_grps
395
+ quartz_scheduler_state
396
+ quartz_simple_triggers
397
+ quartz_trigger_listeners
398
+ quartz_triggers
399
+ ratingsentry
400
+ ratingsstats
401
+ region
402
+ scframeworkversion
403
+ scframeworkversi_scproductvers
404
+ schema_migrations
405
+ sclicenses_scproductentries
406
+ sclicense
407
+ scproductentry
408
+ scproductscreenshot
409
+ scproductversion
410
+ servicecomponent
411
+ sessions
412
+ shoppingcart
413
+ shoppingcategory
414
+ shoppingcoupon
415
+ shoppingitemfield
416
+ shoppingitemprice
417
+ shoppingitem
418
+ shoppingorderitem
419
+ shoppingorder
420
+ subscription
421
+ tasksproposal
422
+ tasksreview
423
+ webdavprops
424
+ website
425
+ }
341
426
  end
342
427
 
343
428
  end
@@ -172,6 +172,11 @@ module Caterpillar
172
172
  task :environment do
173
173
  require(File.join(@config.rails_root, 'config', 'environment'))
174
174
  if @config.container.is_a?(Caterpillar::Liferay)
175
+ if @config.container.version.nil? and !defined?(Lportal)
176
+ STDERR.puts 'Liferay version is undefined, and lportal gem is not present.'
177
+ STDERR.puts 'Please define portlet.container.version in %s.' % @config.class::FILE
178
+ raise 'Insufficient configuration'
179
+ end
175
180
  @config.container.version ||= Lportal::Schema.version
176
181
  portal_info
177
182
  end
@@ -337,19 +342,14 @@ module Caterpillar
337
342
  task :install => :environment do
338
343
  source = File.join(CATERPILLAR_LIBS,'java')
339
344
 
340
- unless @config.container.kind_of? Liferay
341
- info 'Installation of the JAR is only supported on Liferay. Patches are welcome.'
342
- info 'Copy the JAR from this directory into the CLASSPATH of the portlet container.'
343
- info source
344
- exit 1
345
- end
346
-
345
+ # detect (Liferay) container version
347
346
  container_v = @config.container.version
348
-
349
347
  unless container_v
350
348
  info 'Unable to detect the version of the portlet container. Installing the latest version.'
351
349
  end
352
350
 
351
+ # detect the version of the JAR to install
352
+ portlet_jar = nil
353
353
  version = (
354
354
  if container_v and container_v[/^5.1/]
355
355
  '0.6.0' #'0.5.2' # FIXME: branch properly
@@ -357,8 +357,21 @@ module Caterpillar
357
357
  '0.6.1'
358
358
  end
359
359
  )
360
+ require 'find'
361
+ Find.find(source) do |file|
362
+ if File.basename(file) == "rails-portlet-#{version}.jar"
363
+ portlet_jar = file
364
+ end
365
+ end
366
+
367
+ # check if requirements match
368
+ unless deployment_requirements_met?
369
+ info 'Installation of the JAR is only supported on Liferay on Tomcat. Patches are welcome.'
370
+ info 'Copy this JAR into the CLASSPATH of the portlet container.'
371
+ info portlet_jar
372
+ exit 1
373
+ end
360
374
 
361
- portlet_jar = nil
362
375
  old_jar = nil
363
376
  target = File.join(@config.container.WEB_INF,'lib')
364
377
 
@@ -368,13 +381,6 @@ module Caterpillar
368
381
  exit 1
369
382
  end
370
383
 
371
- require 'find'
372
- Find.find(source) do |file|
373
- if File.basename(file) =~ /^rails-portlet-#{version}.jar$/
374
- portlet_jar = file
375
- end
376
- end
377
-
378
384
  # check for previous installs..
379
385
  Find.find(target) do |file|
380
386
  if File.basename(file) =~ /rails-portlet/
@@ -391,7 +397,8 @@ module Caterpillar
391
397
  end
392
398
 
393
399
  exit 1 unless system('cp %s %s' % [portlet_jar,target])
394
- info 'installed Rails-portlet version %s (%s)' % [version, File.join(target,portlet_jar)]
400
+ info 'installed Rails-portlet version %s (%s)' % [
401
+ version, File.join(target,File.basename(portlet_jar))]
395
402
  if old_jar
396
403
  exit 1 unless system('rm -f %s' % old_jar)
397
404
  info '..removed the old version %s' % old_jar
@@ -406,7 +413,7 @@ module Caterpillar
406
413
  with_namespace_and_config do |name, config|
407
414
  desc 'Uninstalls Rails-portlet JAR from the portlet container'
408
415
  task :uninstall do
409
- raise 'Only Liferay is supported' unless @config.container.kind_of? Liferay
416
+ raise 'Only Liferay is supported' unless deployment_requirements_met?
410
417
  target = File.join(@config.container.WEB_INF,'lib')
411
418
 
412
419
  # check that target exists
@@ -436,7 +443,7 @@ module Caterpillar
436
443
  with_namespace_and_config do |name, config|
437
444
  desc 'Checks the installed Rails-portlet version'
438
445
  task :version do
439
- raise 'Only Liferay is supported' unless @config.container.kind_of? Liferay
446
+ raise 'Only Liferay is supported' unless deployment_requirements_met?
440
447
  require 'find'
441
448
  target = File.join(@config.container.WEB_INF,'lib')
442
449
 
@@ -483,8 +490,8 @@ module Caterpillar
483
490
  info 'Warbler configuration file %s was not found, exiting' % @config.warbler_conf
484
491
  exit 1
485
492
  end
486
- info 'Building WAR using Warbler %s on JRuby %i (%s)' % [
487
- Warbler::VERSION, JRUBY_VERSION, jruby]
493
+ info 'Building WAR using Warbler %s on JRuby at %s' % [
494
+ Warbler::VERSION, jruby]
488
495
  info ''
489
496
  exit 1 unless system(jruby+' -S warble war')
490
497
  info 'Warbler finished successfully'
@@ -493,8 +500,12 @@ module Caterpillar
493
500
 
494
501
  def define_deploy_task
495
502
  desc 'Deploy XML files and the application WAR to the portlet container'
503
+ tasks = []
504
+
505
+ # only update the DB if the lportal gem is loaded
506
+ tasks << 'db:update' if defined?(Lportal)
496
507
 
497
- tasks = ['db:update', :xml, :warble, 'deploy:xml', 'deploy:war']
508
+ [:xml, :warble, 'deploy:xml', 'deploy:war'].each { |task| tasks << task }
498
509
  task :deploy => tasks
499
510
  end
500
511
 
@@ -503,7 +514,13 @@ module Caterpillar
503
514
  with_namespace_and_config do |name, config|
504
515
  desc 'Deploys the XML files'
505
516
  task :xml do
506
- raise 'Only deployment to Liferay on Tomcat is supported' unless @config.container.kind_of? Liferay
517
+ unless deployment_requirements_met?
518
+ info 'Deployment is only supported on Liferay on Tomcat. Patches are welcome.'
519
+ info 'Copy these XML files into the portlet container\'s WEB-INF.'
520
+ @xml_files.each { |f| info f }
521
+ exit 1
522
+ end
523
+
507
524
  target = @config.container.WEB_INF
508
525
  info 'deploying XML files to %s' % target
509
526
 
@@ -519,19 +536,28 @@ module Caterpillar
519
536
  with_namespace_and_config do |name, config|
520
537
  desc 'Deploys the WAR file'
521
538
  task :war do
522
- raise 'Only deployment to Liferay on Tomcat is supported' unless @config.container.kind_of? Liferay
523
539
  file = @config.servlet+'.war'
524
540
  unless File.exists?(file)
525
541
  info 'cannot find the WAR file %s, exiting' % file
526
542
  exit 1
527
543
  end
528
544
 
529
- target = File.join(@config.container.root,'webapps')
545
+ # check if requirements match
546
+ unless deployment_requirements_met?
547
+ info 'Deployment is only supported on Liferay on Tomcat. Patches are welcome.'
548
+ info 'Copy this WAR file into the portlet container\'s deployment directory.'
549
+ info file
550
+ exit 1
551
+ end
530
552
 
531
- info '..removing previous installs..'
532
- exit 1 unless system('rm -rf %s' % File.join(target,@config.servlet+'*'))
553
+ target = @config.container.deploy_dir
533
554
 
534
- info 'deploying the WAR package to %s' % target
555
+ if File.exists?(File.join(target,File.basename(file)))
556
+ info '..removing previous installs..'
557
+ exit 1 unless system('rm -rf %s' % File.join(target,@config.servlet+'*'))
558
+ end
559
+
560
+ info 'deploying the WAR package to %s' % File.join(target,file)
535
561
  exit 1 unless system('cp %s %s' % [file,target])
536
562
 
537
563
  end
@@ -550,6 +576,13 @@ module Caterpillar
550
576
 
551
577
  protected
552
578
 
579
+ def deployment_requirements_met?
580
+ @config.container.kind_of? Liferay and (
581
+ @config.container.server == 'Tomcat' or
582
+ @config.container.server == 'JBoss/Tomcat'
583
+ )
584
+ end
585
+
553
586
  def print_portlets(hash)
554
587
  # organize
555
588
  _sorted = Util.categorize(hash)
@@ -0,0 +1,29 @@
1
+ # NOTE: During normal startup (not while building the gem),
2
+ # ActiveRecord should be loaded at this point, before loading any of the models.
3
+ # However, this may conflict later when Rails' rake task activates the boot process.
4
+ # The correct versions should be loaded at this point.
5
+ config_file = File.join(
6
+ File.expand_path(RAILS_ROOT),
7
+ 'config',
8
+ 'environment.rb'
9
+ )
10
+ if $0[/gem$/] or !File.exist?(config_file)
11
+ rails_gem_version = nil
12
+ else
13
+ # Attempt to guess proper Rails version by reading Rails' config file
14
+ f=File.open(config_file)
15
+ config = f.read
16
+ rails_gem_version = config[/RAILS_GEM_VERSION.*(\d\.\d\.\d)/,1]
17
+ f.close
18
+ #STDOUT.puts 'Detected Rails version %s from the config file %s' % [rails_gem_version,config_file]
19
+ end
20
+
21
+ # Load the proper versions of Rails etc.
22
+ require 'rubygems'
23
+ # gem build fails when activesupport is loaded here
24
+ %w{ actionpack activerecord }.each do |rg|
25
+ # %w{ activesupport actionpack activerecord }.each do |rg|
26
+ gem(rg, '= '+rails_gem_version) if rails_gem_version
27
+ require rg
28
+ end
29
+ require 'action_controller'
@@ -0,0 +1,23 @@
1
+ = Portlet test bench
2
+
3
+ This application is for testing the portlet features live.
4
+ Caterpillar includes this portlet into a vanilla Rails application:
5
+
6
+ rails new_app
7
+ cd new_app
8
+ caterpillar pluginize
9
+
10
+ Edit the config/routes as instructed by the previous command.
11
+
12
+ The command
13
+ caterpillar portlets
14
+
15
+ Should output
16
+
17
+ * Portlet configuration ***********************
18
+ Caterpillar
19
+ Rails-portlet test bench "portlet_test_bench" []
20
+
21
+
22
+ Now launch the Webrick server and navigate to http://localhost:3000/caterpillar/test_bench
23
+
@@ -6,6 +6,11 @@ class Caterpillar::ApplicationController < ActionController::Base
6
6
 
7
7
  before_filter :is_test_selected
8
8
 
9
+ # Rails-portlet does not have session cookie support.
10
+ # But flash messages require this.
11
+ #session :disabled => true
12
+
13
+ # If controller is not ApplicationController, test is selected.
9
14
  def is_test_selected
10
15
  @test_is_selected = self.class.to_s[/Application/].nil?
11
16
  end
@@ -1,57 +1,59 @@
1
1
  class Caterpillar::SessionController < Caterpillar::ApplicationController
2
2
 
3
- def initialize
4
-
5
- end
6
-
7
- def index
8
- render :inline => VERSION
9
- end
10
-
11
-
12
- # inspect the session variables
13
- def raw
14
- render :inline => session.inspect
3
+ # flash message.
4
+ def flash_msg
5
+ flash[:info] = "Flash works."
6
+ redirect_to :action => :flash_display
15
7
  end
16
8
 
17
-
18
- # inspect the session cookie
19
- def cookie
20
-
21
- s = "<html><body><pre>"
22
-
23
- cookies.each do |cookie|
24
- # s += "name: " + cookie[0]
25
- s += cookie.inspect
26
- s += "<br />"
27
- # s += "id: " + cookie[1].to_s
9
+ # def index
10
+ # render :inline => VERSION
11
+ # end
12
+ #
13
+ #
14
+ # # inspect the session variables
15
+ # def raw
16
+ # render :inline => session.inspect
17
+ # end
18
+ #
19
+ #
20
+ # # inspect the session cookie
21
+ # def cookie
22
+ #
23
+ # s = "<html><body><pre>"
24
+ #
25
+ # cookies.each do |cookie|
26
+ # # s += "name: " + cookie[0]
27
+ # s += cookie.inspect
28
28
  # s += "<br />"
29
- # cookie.methods.each { |m| s += m.to_s + "<br />" }
30
-
31
- end
32
-
33
- s += "</pre></body></html>"
34
- render :inline => s
35
- end
36
-
37
- def _id
38
- render :inline => session.session_id.inspect
39
- end
40
-
41
-
42
- # inspect the request variables
43
- def req
44
- s = "<html><body>"
45
-
46
- request.env.each_pair do |key,value|
47
- s += key
48
- s += " => "
49
- s += value unless value.nil?
50
- s += "<br />"
51
- end
52
-
53
- s += "</body></html>"
54
- render :inline => s
55
- end
29
+ # # s += "id: " + cookie[1].to_s
30
+ # # s += "<br />"
31
+ # # cookie.methods.each { |m| s += m.to_s + "<br />" }
32
+ #
33
+ # end
34
+ #
35
+ # s += "</pre></body></html>"
36
+ # render :inline => s
37
+ # end
38
+ #
39
+ # def _id
40
+ # render :inline => session.session_id.inspect
41
+ # end
42
+ #
43
+ #
44
+ # # inspect the request variables
45
+ # def req
46
+ # s = "<html><body>"
47
+ #
48
+ # request.env.each_pair do |key,value|
49
+ # s += key
50
+ # s += " => "
51
+ # s += value unless value.nil?
52
+ # s += "<br />"
53
+ # end
54
+ #
55
+ # s += "</body></html>"
56
+ # render :inline => s
57
+ # end
56
58
 
57
59
  end
@@ -67,12 +67,14 @@ These are isolated test cases of the Rails-portlet. These cases cover the most c
67
67
  :controller => 'Caterpillar::Resource', :action => :exit_portlet -%><br />
68
68
 
69
69
  <%= link_to 'Liferay session variables',
70
- :controller => 'Caterpillar::Liferay', :action => :session_variables -%><br />
71
-
72
-
73
- <%#= link_to 'Login',
74
- :controller => 'Caterpillar::Login', :action => :index -%><br />
75
-
70
+ url_for(
71
+ :controller => 'Caterpillar::Liferay',
72
+ :action => :session_variables
73
+ )+'/uid/%UID%/gid/%GID%'
74
+ -%><br />
75
+
76
+ <%= link_to 'Flash message',
77
+ :controller => 'Caterpillar::Session', :action => :flash_msg -%><br />
76
78
 
77
79
 
78
80
  </body>
@@ -9,26 +9,30 @@ When the Rails-portlet receives a request where the URL contains keywords %UID%
9
9
  </p>
10
10
 
11
11
  <p>
12
- <%= link_to 'UID', url_for(:action => :session_variables)+'/uid/%UID%' -%><br/>
12
+ <%#= link_to 'UID', url_for(:action => :session_variables)+'/uid/%UID%' -%><br/>
13
13
  <%#= link_to 'UID debug', url_for(:action => :session_variables)+'/uid/10000' -%><br/>
14
14
  <% if @uid -%>
15
- <span style="font-size: 14px;">
15
+ <span style="font-size: 18px;">
16
16
  Received UID: <%= @uid %>
17
17
  </span>
18
+ <% else -%>
19
+ No UID found!
18
20
  <% end -%>
19
21
  </p>
20
22
 
21
23
  <p>
22
- <%= link_to 'GID', url_for(:action => :session_variables)+'/gid/%GID%' -%><br/>
24
+ <%#= link_to 'GID', url_for(:action => :session_variables)+'/gid/%GID%' -%><br/>
23
25
  <%#= link_to 'GID debug', url_for(:action => :session_variables)+'/gid/20000' -%><br/>
24
26
  <% if @gid -%>
25
- <span style="font-size: 14px;">
27
+ <span style="font-size: 18px;">
26
28
  Received GID: <%= @gid %>
27
29
  </span>
30
+ <% else -%>
31
+ No GID found!
28
32
  <% end -%>
29
33
  </p>
30
34
 
31
35
  <p style="font-size: 18px;">
32
- <%= link_to 'Reset', :action => :session_variables -%>
36
+ <%#= link_to 'Reset', :action => :session_variables -%>
33
37
  </p>
34
38
 
@@ -0,0 +1,19 @@
1
+ <h1>Flash message:</h1>
2
+
3
+ <% if flash[:info] -%>
4
+ <p style="border: 2px solid black; background: #ccff99; padding: 5px; color: green;">
5
+ <%= flash[:info] %>
6
+ </p>
7
+
8
+ <%= link_to 'GET',
9
+ :controller => 'Caterpillar::Session', :action => :flash_msg -%><br />
10
+
11
+ <% form_tag( :controller => 'Caterpillar::Session', :action => :flash_msg ) do -%>
12
+ <div><%= submit_tag 'POST' %></div>
13
+ <% end -%>
14
+
15
+
16
+ <% else -%>
17
+ There is something wrong with flash.
18
+
19
+ <% end -%>
@@ -0,0 +1,11 @@
1
+ # require 'test_helper'
2
+ require File.dirname(File.expand_path(__FILE__))+'/test_helper'
3
+
4
+ class GeneratorTest < Caterpillar::TestCase # :nodoc:
5
+
6
+ def test_generate
7
+
8
+ end
9
+
10
+ end
11
+ #sudo gem -y uninstall caterpillar ; gem build caterpillar.gemspec && sudo gem install --no-ri --no-rdoc caterpillar-1.0.4.gem && cd /tmp/ && rm -rf foobar && rails foobar && cd foobar && caterpillar pluginize ; cd ~/dev/rails-portlet/trunk/caterpillar
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: caterpillar
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 1.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mikael Lammentausta
@@ -9,18 +9,18 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-07-12 00:00:00 +03:00
12
+ date: 2009-10-05 00:00:00 +03:00
13
13
  default_executable: caterpillar
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
- name: lportal
16
+ name: hpricot
17
17
  type: :runtime
18
18
  version_requirement:
19
19
  version_requirements: !ruby/object:Gem::Requirement
20
20
  requirements:
21
21
  - - ">="
22
22
  - !ruby/object:Gem::Version
23
- version: 1.0.18
23
+ version: 0.6.164
24
24
  version:
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: rake
@@ -46,12 +46,9 @@ files:
46
46
  - Rakefile
47
47
  - install.rb
48
48
  - init.rb
49
- - lib/java
50
49
  - lib/java/rails-portlet-0.6.0.jar
51
50
  - lib/java/rails-portlet-0.6.1.jar
52
- - lib/caterpillar
53
51
  - lib/caterpillar/config.rb
54
- - lib/caterpillar/helpers
55
52
  - lib/caterpillar/helpers/liferay.rb
56
53
  - lib/caterpillar/navigation.rb
57
54
  - lib/caterpillar/usage.rb
@@ -61,38 +58,22 @@ files:
61
58
  - lib/caterpillar/util.rb
62
59
  - lib/caterpillar/task.rb
63
60
  - lib/caterpillar.rb
64
- - lib/web
61
+ - lib/load_rails.rb
65
62
  - lib/web/portlet.rb
66
- - generators/caterpillar
67
- - generators/caterpillar/templates
68
- - generators/caterpillar/templates/stylesheets
69
- - generators/caterpillar/templates/stylesheets/portlet_test_bench
70
63
  - generators/caterpillar/templates/stylesheets/portlet_test_bench/main.css
71
- - generators/caterpillar/templates/config
72
64
  - generators/caterpillar/templates/config/portlets.rb
73
- - generators/caterpillar/templates/images
74
- - generators/caterpillar/templates/images/caterpillar
75
65
  - generators/caterpillar/templates/images/caterpillar/caterpillar.gif
76
- - generators/caterpillar/templates/images/portlet_test_bench
77
66
  - generators/caterpillar/templates/images/portlet_test_bench/Leafy_Sea_Dragon_1.jpg
78
67
  - generators/caterpillar/templates/images/portlet_test_bench/rails.png
79
68
  - generators/caterpillar/templates/images/portlet_test_bench/ruby.gif
80
69
  - generators/caterpillar/templates/images/portlet_test_bench/java.png
81
70
  - generators/caterpillar/templates/images/portlet_test_bench/debug.jpg
82
- - generators/caterpillar/templates/javascripts
83
- - generators/caterpillar/templates/javascripts/portlet_test_bench
84
71
  - generators/caterpillar/templates/javascripts/portlet_test_bench/main.js
85
72
  - generators/caterpillar/caterpillar_generator.rb
86
73
  - generators/caterpillar/USAGE
87
- - db/migrate
88
- - views/caterpillar
89
74
  - views/caterpillar/_navigation.html.erb
90
75
  - portlet_test_bench/routing.rb
91
- - portlet_test_bench/helpers
92
- - portlet_test_bench/helpers/caterpillar
93
76
  - portlet_test_bench/helpers/caterpillar/application_helper.rb
94
- - portlet_test_bench/controllers
95
- - portlet_test_bench/controllers/caterpillar
96
77
  - portlet_test_bench/controllers/caterpillar/application.rb
97
78
  - portlet_test_bench/controllers/caterpillar/resource_controller.rb
98
79
  - portlet_test_bench/controllers/caterpillar/session_controller.rb
@@ -102,31 +83,22 @@ files:
102
83
  - portlet_test_bench/controllers/caterpillar/user_controller.rb
103
84
  - portlet_test_bench/controllers/caterpillar/css_controller.rb
104
85
  - portlet_test_bench/controllers/caterpillar/liferay_controller.rb
105
- - portlet_test_bench/views
106
- - portlet_test_bench/views/caterpillar
107
- - portlet_test_bench/views/caterpillar/application
86
+ - portlet_test_bench/README
108
87
  - portlet_test_bench/views/caterpillar/application/_back_to_menu.html.erb
109
88
  - portlet_test_bench/views/caterpillar/application/index.html.erb
110
- - portlet_test_bench/views/caterpillar/http_methods
111
89
  - portlet_test_bench/views/caterpillar/http_methods/parameter.html.erb
112
90
  - portlet_test_bench/views/caterpillar/http_methods/back.html.erb
113
91
  - portlet_test_bench/views/caterpillar/http_methods/post_and_redirect.html.erb
114
92
  - portlet_test_bench/views/caterpillar/http_methods/post.html.erb
115
93
  - portlet_test_bench/views/caterpillar/http_methods/redirect.html.erb
116
- - portlet_test_bench/views/caterpillar/css
117
94
  - portlet_test_bench/views/caterpillar/css/background.html.erb
118
95
  - portlet_test_bench/views/caterpillar/css/simple.html.erb
119
- - portlet_test_bench/views/caterpillar/user
120
96
  - portlet_test_bench/views/caterpillar/user/home.html.erb
121
- - portlet_test_bench/views/caterpillar/session
122
- - portlet_test_bench/views/caterpillar/resource
97
+ - portlet_test_bench/views/caterpillar/session/flash_display.html.erb
123
98
  - portlet_test_bench/views/caterpillar/resource/exit_portlet.html.erb
124
99
  - portlet_test_bench/views/caterpillar/resource/images.html.erb
125
- - portlet_test_bench/views/caterpillar/login
126
100
  - portlet_test_bench/views/caterpillar/login/index.html.erb
127
- - portlet_test_bench/views/caterpillar/liferay
128
101
  - portlet_test_bench/views/caterpillar/liferay/session_variables.html.erb
129
- - portlet_test_bench/views/caterpillar/js
130
102
  - portlet_test_bench/views/caterpillar/js/jquery.html.erb
131
103
  - portlet_test_bench/views/caterpillar/js/link_to_post.html.erb
132
104
  - portlet_test_bench/views/caterpillar/js/prototype.html.erb
@@ -134,13 +106,14 @@ files:
134
106
  - portlet_test_bench/views/caterpillar/js/simple.html.erb
135
107
  - portlet_test_bench/views/caterpillar/js/dragndrop.html.erb
136
108
  - portlet_test_bench/views/caterpillar/js/_scriptaculous_jquery.html.erb
137
- - portlet_test_bench/views/layouts
138
109
  - portlet_test_bench/views/layouts/basic.html.erb
139
110
  - README
140
111
  - MIT-LICENSE
141
112
  - ChangeLog
142
113
  has_rdoc: true
143
114
  homepage: http://rails-portlet.rubyforge.org
115
+ licenses: []
116
+
144
117
  post_install_message:
145
118
  rdoc_options:
146
119
  - --main
@@ -164,11 +137,12 @@ required_rubygems_version: !ruby/object:Gem::Requirement
164
137
  requirements: []
165
138
 
166
139
  rubyforge_project: rails-portlet
167
- rubygems_version: 1.3.1
140
+ rubygems_version: 1.3.5
168
141
  signing_key:
169
142
  specification_version: 2
170
143
  summary: Caterpillar helps building Rails applications for JSR286 portlets.
171
144
  test_files:
145
+ - test/generator_test.rb
172
146
  - test/portlets_test.rb
173
147
  - test/liferay_helpers_test.rb
174
148
  - test/xml_test.rb