caterpillar 0.9.4 → 0.9.5

Sign up to get free protection for your applications and to get access to all the features.
data/ChangeLog CHANGED
@@ -1,3 +1,13 @@
1
+ = 0.9.5
2
+ - portlet xml definition to Liferay 5.2.0 standards
3
+ - liferay xml files are tagged by selection based on the configured version
4
+ - portlet jar installation based on Liferay version
5
+ - Upgrade to rails-portlet 0.6.1 for Liferay 5.2.x
6
+ - Fixed the sequences migration
7
+ - include ActionView helpers, raise an error if given exit_portlet url is nil
8
+ - fixed a small bug with inline JS parsing
9
+
10
+
1
11
  = 0.9.4
2
12
  - Web::PortletNames migrations + model
3
13
  - random small fixes
@@ -6,7 +6,6 @@ class LportalSequences < ActiveRecord::Migration
6
6
  Address,
7
7
  Announcement::Delivery,
8
8
  Announcement::Entry,
9
- Asset,
10
9
  Contact,
11
10
  Group,
12
11
  Permission,
@@ -19,6 +18,7 @@ class LportalSequences < ActiveRecord::Migration
19
18
  MB::Thread,
20
19
  MB::Discussion,
21
20
  MB::Category,
21
+ Tag::Asset,
22
22
  Tag::Entry,
23
23
  Tag::Property,
24
24
  Web::Layout,
data/lib/caterpillar.rb CHANGED
@@ -5,7 +5,7 @@
5
5
  #++
6
6
 
7
7
  module Caterpillar
8
- VERSION='0.9.4'
8
+ VERSION='0.9.5'
9
9
  end
10
10
 
11
11
  this_file = File.symlink?(__FILE__) ? File.readlink(__FILE__) : __FILE__
@@ -1,8 +1,8 @@
1
1
  module Caterpillar
2
2
  module Helpers
3
3
  module Liferay
4
- # include ActionView::Helpers::UrlHelper
5
- # include ActionView::Helpers::TagHelper
4
+ include ActionView::Helpers::UrlHelper
5
+ include ActionView::Helpers::TagHelper
6
6
 
7
7
  # Formulates a link to Liferay.
8
8
  # Parameters:
@@ -69,9 +69,9 @@ module Helpers
69
69
 
70
70
  ### blog
71
71
  when 'com.liferay.portlet.blogs.model.BlogsEntry'
72
- title = _('Linkki blogimerkintään "%s"') % obj.title
73
- url = LiferayUrl.new(obj,@user,redirect).instance_url
74
- link_to_exit_portlet( title, url )
72
+ # title = _('Linkki blogimerkintään "%s"') % obj.title
73
+ # url = LiferayUrl.new(obj,@user,redirect).instance_url
74
+ # link_to_exit_portlet( title, url )
75
75
 
76
76
 
77
77
  ### document library file
@@ -175,6 +175,7 @@ module Helpers
175
175
 
176
176
  # formulates a link that the rails286-portlet will leave unparsed.
177
177
  def link_to_exit_portlet(label, url)
178
+ raise 'No url given' if url.nil?
178
179
  link_to label, url_to_exit_portlet(url)
179
180
  end
180
181
 
@@ -1,5 +1,5 @@
1
1
  #--
2
- # (c) Copyright 2008 Mikael Lammentausta
2
+ # (c) Copyright 2008,2009 Mikael Lammentausta
3
3
  # See the file LICENSES.txt included with the distribution for
4
4
  # software license details.
5
5
  #++
@@ -114,14 +114,17 @@ module Caterpillar
114
114
  xml << "\n"
115
115
  xml << '<!DOCTYPE %s PUBLIC' % doctype
116
116
  case doctype
117
+
117
118
  when 'liferay-portlet-app'
118
119
  xml << ' "-//Liferay//DTD Portlet Application %s//EN"' % version
119
120
  xml << ' "http://www.liferay.com/dtd/%s_%s.dtd">' % [
120
121
  doctype, version.gsub('.','_') ]
122
+
121
123
  when 'display'
122
124
  xml << ' "-//Liferay//DTD Display %s//EN"' % version
123
125
  xml << ' "http://www.liferay.com/dtd/liferay-%s_%s.dtd">' % [
124
126
  doctype, version.gsub('.','_') ]
127
+
125
128
  end
126
129
  xml << "\n\n"
127
130
  xml << '<%s>' % doctype
@@ -138,9 +141,17 @@ module Caterpillar
138
141
  def dtd_version(type)
139
142
  case type
140
143
  when 'liferay-portlet-app'
141
- '5.1.0'
144
+ if @version[/5.1/]
145
+ '5.1.0'
146
+ elsif @version[/5.2/]
147
+ '5.2.0'
148
+ end
142
149
  when 'display'
143
- '5.1.0'
150
+ if @version[/5.1/]
151
+ '5.1.0'
152
+ elsif @version[/5.2/]
153
+ '5.2.0'
154
+ end
144
155
  end
145
156
  end
146
157
 
@@ -37,16 +37,18 @@ module Caterpillar
37
37
 
38
38
  protected
39
39
 
40
+ # JSR 286 portlet XML header. Opens portlet-app.
40
41
  def header
41
- xml = '<?xml version="1.0" encoding="UTF-8"?>'
42
- xml << "\n"
42
+ xml = '<?xml version="1.0" encoding="UTF-8"?>' +"\n"
43
43
  xml << '<portlet-app xmlns="http://java.sun.com/xml/ns/portlet/portlet-app_2_0.xsd"
44
44
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
45
- xsi:schemaLocation="http://java.sun.com/xml/ns/portlet/portlet-app_2_0.xsd http://java.sun.com/xml/ns/portlet/portlet-app_2_0.xsd">'
45
+ xsi:schemaLocation="http://java.sun.com/xml/ns/portlet/portlet-app_2_0.xsd"
46
+ version="2.0">'
46
47
  xml << "\n\n"
47
48
  return xml
48
49
  end
49
50
 
51
+ # Closes portlet-app.
50
52
  def footer
51
53
  '</portlet-app>' + "\n"
52
54
  end
@@ -43,6 +43,10 @@ module Caterpillar
43
43
  @config = Util.eval_configuration(config)
44
44
  yield self if block_given?
45
45
  @xml_files = []
46
+ info 'Caterpillar v.%s' % Caterpillar::VERSION
47
+ info 'Configured to use %s version %s' % [
48
+ @config.container.class.to_s.sub('Caterpillar::',''), @config.container.version
49
+ ]
46
50
  send tasks
47
51
  end
48
52
 
@@ -80,7 +84,10 @@ module Caterpillar
80
84
  tasks << "#{@name}:liferayportletapp"
81
85
  tasks << "#{@name}:liferaydisplay"
82
86
  end
83
- tasks << "portlets" # finally print produced portlets
87
+
88
+ # print produced portlets
89
+ tasks << :portlets
90
+
84
91
  task :xml => tasks
85
92
  end
86
93
 
@@ -112,6 +119,7 @@ module Caterpillar
112
119
  def define_portlets_task
113
120
  desc 'Prints portlet configuration'
114
121
  task :portlets => :parse do
122
+ info 'Portlet configuration ***********************'
115
123
  print_portlets(@portlets)
116
124
  end
117
125
  end
@@ -166,9 +174,9 @@ module Caterpillar
166
174
  @name = :xml
167
175
  # set the output filename
168
176
  if @config.container.kind_of? Liferay
169
- file = 'portlet-ext.xml'
177
+ file = File.join('tmp','portlet-ext.xml')
170
178
  else
171
- file = 'portlet.xml'
179
+ file = File.join('tmp','portlet.xml')
172
180
  end
173
181
  @xml_files << file
174
182
  with_namespace_and_config do |name, config|
@@ -178,7 +186,7 @@ module Caterpillar
178
186
  f=File.open(file,'w')
179
187
  f.write Portlet.xml(@portlets)
180
188
  f.close
181
- STDOUT.puts 'Created %s' % file
189
+ info '-> %s' % file
182
190
  end
183
191
  end
184
192
  end
@@ -186,7 +194,7 @@ module Caterpillar
186
194
  # Writes liferay-portlet-ext.xml
187
195
  def define_liferayportletappxml_task
188
196
  @name = :xml
189
- file = 'liferay-portlet-ext.xml'
197
+ file = File.join('tmp','liferay-portlet-ext.xml')
190
198
  @xml_files << file
191
199
  with_namespace_and_config do |name, config|
192
200
  desc 'Create Liferay portlet XML'
@@ -195,7 +203,7 @@ module Caterpillar
195
203
  f=File.open(file,'w')
196
204
  f.write config.container.portletapp_xml(@portlets)
197
205
  f.close
198
- STDOUT.puts 'Created %s' % file
206
+ info '-> %s' % file
199
207
  end
200
208
  end
201
209
  end
@@ -203,8 +211,10 @@ module Caterpillar
203
211
  # Writes liferay-display.xml
204
212
  def define_liferaydisplayxml_task
205
213
  @name = :xml
206
- file = 'liferay-display.xml'
214
+ file = File.join('tmp','liferay-display.xml')
207
215
  @xml_files << file
216
+ raise 'This version of Liferay is broken!' if @config.container.version == '5.1.2'
217
+
208
218
  with_namespace_and_config do |name, config|
209
219
  desc 'Create Liferay display XML'
210
220
  task :liferaydisplay do
@@ -212,7 +222,7 @@ module Caterpillar
212
222
  f=File.open(file,'w')
213
223
  f.write config.container.display_xml(@portlets)
214
224
  f.close
215
- STDOUT.puts 'Created %s' % file
225
+ info '-> %s' % file
216
226
  end
217
227
  end
218
228
  end
@@ -277,8 +287,13 @@ module Caterpillar
277
287
  raise 'Only Liferay is supported' unless @config.container.kind_of? Liferay
278
288
  require 'find'
279
289
 
280
- #version = '0.5.2'
281
- version = '0.6.0'
290
+ version = (
291
+ if @config.container.version[/^5.2/]
292
+ '0.6.1'
293
+ else
294
+ version = '0.5.2' # think of a way to branch properly
295
+ end
296
+ )
282
297
 
283
298
  portlet_jar = nil
284
299
  old_jar = nil
@@ -306,11 +321,11 @@ module Caterpillar
306
321
  end
307
322
  end
308
323
 
309
- info 'Installing Rails-portlet version %s to %s' % [version, target]
310
324
  system('cp %s %s' % [portlet_jar,target])
325
+ info 'installed Rails-portlet version %s to %s' % [version, target]
311
326
  if old_jar
312
- info 'Removing old version'
313
327
  system('rm -f %s' % old_jar)
328
+ info '..removed the old version %s' % old_jar
314
329
  end
315
330
 
316
331
  end
@@ -371,30 +386,41 @@ module Caterpillar
371
386
  desc 'Create a WAR package with Warbler'
372
387
  task :warble do
373
388
  unless ENV['JRUBY_HOME']
374
- info 'Environment variable JRUBY_HOME is not set, exiting'
389
+ info ''
390
+ info 'Environment variable JRUBY_HOME is not set, exiting -'
391
+ info 'You should `export JRUBY_HOME="/usr/local/jruby"` and `sudo -E caterpillar %s`' % ARGV[0]
392
+ info ''
375
393
  exit 1
376
394
  end
377
395
  jruby = File.join(ENV['JRUBY_HOME'],'bin','jruby')
378
396
  unless File.exists?(jruby)
397
+ info ''
379
398
  info 'JRuby executable was not found in %s, exiting' % jruby
380
399
  exit 1
381
400
  end
382
- unless system('which warble')
383
- info 'Warbler was not found in PATH, exiting'
401
+ begin
402
+ require 'warbler'
403
+ rescue
404
+ info ''
405
+ info 'Warbler module was not found, exiting. Install Warbler for JRuby.'
384
406
  exit 1
385
407
  end
386
408
  unless File.exists?(@config.warbler_conf)
409
+ info ''
387
410
  info 'Warbler configuration file %s was not found, exiting' % @config.warbler_conf
388
411
  exit 1
389
412
  end
390
- info 'building WAR package using JRuby (%s)' % jruby
413
+ info ''
414
+ info 'Building WAR using Warbler on JRuby (%s)' % jruby
415
+ info ''
391
416
  system(jruby+' -S warble war')
392
417
 
393
418
  end
394
419
  end
395
420
 
396
421
  def define_deploy_task
397
- desc 'Deploy XML files and WAR package to the portlet container'
422
+ desc 'Deploy XML files and the application WAR to the portlet container'
423
+ #info 'Deploying XML files and the application WAR'
398
424
 
399
425
  raise 'Only deployment to Liferay on Tomcat is supported' unless @config.container.kind_of? Liferay
400
426
  tasks = [:xml, :warble, 'deploy:xml', 'deploy:war']
@@ -406,12 +432,12 @@ module Caterpillar
406
432
  with_namespace_and_config do |name, config|
407
433
  desc 'Deploys the XML files'
408
434
  task :xml do
409
- info 'deploying XML files'
410
435
  target = @config.container.WEB_INF
436
+ info 'deploying XML files to %s' % target
411
437
 
412
438
  @xml_files.each do |file|
413
439
  system('cp %s %s' % [file,target])
414
- info 'copied %s into %s' % [file,target]
440
+ info ' %s' % [file]
415
441
  end
416
442
  end
417
443
  end
@@ -11,8 +11,9 @@ module Caterpillar
11
11
 
12
12
  # Reads the configuration
13
13
  def eval_configuration(config=nil)
14
- if config.nil? && File.exists?(Config::FILE)
15
- config = eval(File.open(Config::FILE) {|f| f.read})
14
+ cf = File.join([RAILS_ROOT,Caterpillar::Config::FILE])
15
+ if config.nil? && File.exists?(cf)
16
+ config = eval(File.open(cf) {|f| f.read})
16
17
  end
17
18
  config ||= Config.new
18
19
  unless config.kind_of? Config
data/test/xml_test.rb CHANGED
@@ -10,15 +10,23 @@ class XmlTest < Caterpillar::TestCase # :nodoc:
10
10
  end
11
11
 
12
12
  def test_liferay_display_xml
13
- xml = Caterpillar::Liferay.new(@config).display_xml(@portlets)
13
+ xml = @config.container.display_xml(@portlets)
14
14
  assert_not_nil xml
15
15
  assert !xml.empty?
16
16
  end
17
17
 
18
18
  def test_liferay_portlet_xml
19
- xml = Caterpillar::Liferay.new(@config).portletapp_xml(@portlets)
20
- assert_not_nil xml
21
- assert !xml.empty?
19
+ { '5.1.1' => '5.1.0',
20
+ '5.2.0' => '5.2.0' }.each_pair do |version,tld|
21
+
22
+ @config.container.version = version
23
+ xml = @config.container.portletapp_xml(@portlets)
24
+ assert_not_nil xml
25
+ assert !xml.empty?
26
+ assert_not_nil xml[/liferay-portlet-app.*#{tld}/], 'Failed to create DTD with proper version; liferay %s' % version
27
+ end
22
28
  end
23
29
 
30
+
31
+
24
32
  end
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: 0.9.4
4
+ version: 0.9.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mikael Lammentausta
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-01-23 00:00:00 +02:00
12
+ date: 2009-02-07 00:00:00 +02:00
13
13
  default_executable: caterpillar
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -47,11 +47,8 @@ files:
47
47
  - install.rb
48
48
  - init.rb
49
49
  - lib/java
50
- - lib/java/rails-portlet-0.6.0.jar
51
50
  - lib/java/rails-portlet-0.5.2.jar
52
- - lib/java/commons-httpclient-3.1.jar
53
- - lib/java/htmlparser-1.6.jar
54
- - lib/java/commons-codec-1.3.jar
51
+ - lib/java/rails-portlet-0.6.1.jar
55
52
  - lib/caterpillar
56
53
  - lib/caterpillar/config.rb
57
54
  - lib/caterpillar/helpers
Binary file
Binary file
Binary file