caterpillar 0.9.2 → 0.9.4
Sign up to get free protection for your applications and to get access to all the features.
- data/ChangeLog +6 -1
- data/db/migrate/20081205000001_portlet_names.rb +17 -0
- data/db/migrate/20081205000002_lportal_sequences.rb +2 -0
- data/lib/caterpillar.rb +1 -1
- data/lib/caterpillar/helpers/liferay.rb +183 -0
- data/lib/caterpillar/liferay.rb +15 -13
- data/lib/caterpillar/task.rb +25 -16
- data/lib/java/commons-codec-1.3.jar +0 -0
- data/lib/java/commons-httpclient-3.1.jar +0 -0
- data/lib/java/htmlparser-1.6.jar +0 -0
- data/lib/java/rails-portlet-0.6.0.jar +0 -0
- data/lib/web/portlet.rb +10 -0
- data/lib/web/portlet_name.rb +2 -2
- data/lib/web/portlet_preferences.rb +10 -0
- data/test/liferay_helpers_test.rb +10 -0
- metadata +12 -5
- data/db/migrate/20081205000001_lportal_portlets.rb +0 -12
- data/lib/caterpillar/liferay_portlet.rb +0 -8
data/ChangeLog
CHANGED
@@ -1,3 +1,8 @@
|
|
1
|
+
= 0.9.4
|
2
|
+
- Web::PortletNames migrations + model
|
3
|
+
- random small fixes
|
4
|
+
|
5
|
+
|
1
6
|
= 0.9.2
|
2
7
|
- fixed a problem with navigation; enhanced css
|
3
8
|
- deployment task
|
@@ -10,4 +15,4 @@ Released at 2008-12-18
|
|
10
15
|
|
11
16
|
= 0.9.0
|
12
17
|
Released at 2008-12-17
|
13
|
-
- the initial release
|
18
|
+
- the initial release
|
@@ -0,0 +1,17 @@
|
|
1
|
+
class PortletNames < ActiveRecord::Migration
|
2
|
+
def self.up
|
3
|
+
# dealing with tables that have no id is a pain with ActiveRecord,
|
4
|
+
# and using the 'id' column for portletid does not work either,
|
5
|
+
# ActiveRecord does not let that column to be set manually.
|
6
|
+
create_table :portlet_names do |t|
|
7
|
+
t.column :portletid, :string, :null => false
|
8
|
+
t.column :name, :string, :null => false
|
9
|
+
t.column :title, :string, :null => false
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
def self.down
|
14
|
+
drop_table :portlet_names
|
15
|
+
#ActiveRecord::Base.connection.execute("DROP TABLE IF EXISTS portlet_names")
|
16
|
+
end
|
17
|
+
end
|
data/lib/caterpillar.rb
CHANGED
@@ -0,0 +1,183 @@
|
|
1
|
+
module Caterpillar
|
2
|
+
module Helpers
|
3
|
+
module Liferay
|
4
|
+
# include ActionView::Helpers::UrlHelper
|
5
|
+
# include ActionView::Helpers::TagHelper
|
6
|
+
|
7
|
+
# Formulates a link to Liferay.
|
8
|
+
# Parameters:
|
9
|
+
# - obj is an instance of a model from the lportal library.
|
10
|
+
# - options
|
11
|
+
def link_to_liferay(obj,options={})
|
12
|
+
options.update(:use_large_igpreview => false) unless options[:use_large_igpreview]
|
13
|
+
|
14
|
+
# Rails-portlet cannot pass the actual redirect parameter.
|
15
|
+
# Workaround with JavaScript.
|
16
|
+
redirect = 'javascript: history.go(-1)'
|
17
|
+
|
18
|
+
title = 'n/a' # link title
|
19
|
+
begin
|
20
|
+
STDERR.puts 'This method is DEPRECATED - use obj.path instead'
|
21
|
+
logger.debug "Formulating Liferay link for #{obj}"
|
22
|
+
case obj.liferay_class
|
23
|
+
|
24
|
+
### group
|
25
|
+
when 'com.liferay.portal.model.Group'
|
26
|
+
# title = (obj.name.empty? ? obj.owner.fullname : obj.name)
|
27
|
+
# urls = LiferayUrl.new(obj,nil,nil).static_url
|
28
|
+
# logger.debug urls
|
29
|
+
# if options[:private]
|
30
|
+
# label = _('yksityiset sivut')
|
31
|
+
# urls[:private] ?
|
32
|
+
# link_to_exit_portlet( label, urls[:private] ) :
|
33
|
+
# link_to_function(
|
34
|
+
# label, "alert('%s')" % _('Yhteisöllä ei ole yksityisiä sivuja'))
|
35
|
+
# else
|
36
|
+
# label = _('julkiset sivut')
|
37
|
+
# urls[:public] ?
|
38
|
+
# link_to_exit_portlet( label, urls[:public] ) :
|
39
|
+
# link_to_function(
|
40
|
+
# label, "alert('%s')" % _('Yhteisöllä ei ole julkisia sivuja'))
|
41
|
+
# end
|
42
|
+
|
43
|
+
|
44
|
+
# siirretty malliin
|
45
|
+
# when 'com.liferay.portal.model.Layout'
|
46
|
+
# url = LiferayUrl.new(obj).static_url
|
47
|
+
# return url_to_exit_portlet(url)
|
48
|
+
|
49
|
+
|
50
|
+
### user
|
51
|
+
when 'com.liferay.portal.model.User'
|
52
|
+
# urls = LiferayUrl.new(obj,nil,nil).static_url
|
53
|
+
# #logger.debug urls
|
54
|
+
# if options[:private]
|
55
|
+
# label = options[:label]
|
56
|
+
# label ||= _('yksityiset sivut')
|
57
|
+
# urls[:private] ?
|
58
|
+
# link_to_exit_portlet( label, urls[:private] ) :
|
59
|
+
# link_to_function(
|
60
|
+
# label, "alert('%s')" % _('Tunnuksella ei ole yksityisiä sivuja'))
|
61
|
+
# else
|
62
|
+
# label = options[:label] || _('julkiset sivut')
|
63
|
+
# urls[:public] ?
|
64
|
+
# link_to_exit_portlet( label, urls[:public] ) :
|
65
|
+
# link_to_function(
|
66
|
+
# label, "alert('%s')" % _('Tunnuksella ei ole julkisia sivuja'))
|
67
|
+
# end
|
68
|
+
|
69
|
+
|
70
|
+
### blog
|
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 )
|
75
|
+
|
76
|
+
|
77
|
+
### document library file
|
78
|
+
#
|
79
|
+
# tämä toimii hiukan eri logiikalla kuin toiset, koska
|
80
|
+
# sama malli joutuu mallintamaan myös tyyppinsä tiedostopäätteestä
|
81
|
+
when 'com.liferay.portlet.documentlibrary.model.DLFileEntry'
|
82
|
+
redirect_link=request.env["PATH_INFO"] # ei toimi portletissa
|
83
|
+
|
84
|
+
label = 'Tiedostotyyppiä %s ei vielä tueta' % obj.type[:name]
|
85
|
+
#_('Lataa tiedosto "%s"') % obj.asset.title
|
86
|
+
case obj.type[:uuid]
|
87
|
+
when :video
|
88
|
+
label = _('Linkki videoon "%s"') % obj.asset.title
|
89
|
+
link_to_exit_portlet( label, url_for(
|
90
|
+
{ :controller => :video,
|
91
|
+
:action => :asset,
|
92
|
+
:id => obj.asset.id,
|
93
|
+
:uid => @user.id,
|
94
|
+
:redirect => redirect_link
|
95
|
+
}))
|
96
|
+
|
97
|
+
when :pdf
|
98
|
+
label = _('Linkki dokumenttiin "%s"') % obj.asset.title
|
99
|
+
redirect = ''
|
100
|
+
url = LiferayUrl.new(obj,nil,redirect).static_url
|
101
|
+
link_to_exit_portlet( label, url )
|
102
|
+
|
103
|
+
end
|
104
|
+
|
105
|
+
|
106
|
+
### galleriakuva
|
107
|
+
when 'com.liferay.portlet.imagegallery.model.IGImage'
|
108
|
+
base_url = "#{$LIFERAY_SERVER}/image/image_gallery"
|
109
|
+
img_id = (options[:use_large_igpreview] == true ? obj.large.id : obj.small.id)
|
110
|
+
|
111
|
+
img = link_to_exit_portlet(
|
112
|
+
image_tag( "#{base_url}?img_id=#{img_id}", :alt => obj.description, :class => 'asset_image' ),
|
113
|
+
"#{base_url}?img_id=#{obj.large.id}"
|
114
|
+
)
|
115
|
+
logger.debug img
|
116
|
+
return img
|
117
|
+
|
118
|
+
|
119
|
+
when 'com.liferay.portlet.journal.model.JournalArticle'
|
120
|
+
url = LiferayUrl.new(obj,@user,redirect).instance_url
|
121
|
+
link_to_exit_portlet( _('Lue koko artikkeli "%s"') % obj.asset.title, url )
|
122
|
+
|
123
|
+
when 'com.liferay.portlet.messageboards.model.MBCategory'
|
124
|
+
# url = LiferayUrl.new(obj,@user,redirect).static_url
|
125
|
+
# link_to_exit_portlet( obj.name, url )
|
126
|
+
|
127
|
+
|
128
|
+
when 'com.liferay.portlet.messageboards.model.MBMessage'
|
129
|
+
url = LiferayUrl.new(obj,@user,redirect).instance_url
|
130
|
+
link_to_exit_portlet( _('Lue viesti "%s"') % obj.asset.title, url )
|
131
|
+
|
132
|
+
# when 'com.liferay.portlet.messageboards.model.MBThread'
|
133
|
+
|
134
|
+
when 'com.liferay.portlet.wiki.model.WikiNode'
|
135
|
+
logger.debug "WikiNode"
|
136
|
+
# url = LiferayUrl.new(obj,@user,redirect).instance_url
|
137
|
+
# link_to_exit_portlet( _('Lue sivu "%s"') % obj.asset.title, url )
|
138
|
+
|
139
|
+
when 'com.liferay.portlet.wiki.model.WikiPage'
|
140
|
+
logger.debug "WikiPage"
|
141
|
+
url = LiferayUrl.new(obj,@user,redirect).instance_url
|
142
|
+
link_to_exit_portlet( _('Lue sivu "%s"') % obj.asset.title, url )
|
143
|
+
|
144
|
+
else
|
145
|
+
logger.debug obj.liferay_class
|
146
|
+
raise _('Tämän tyyppistä linkkiä ei vielä hallita')
|
147
|
+
|
148
|
+
end
|
149
|
+
|
150
|
+
rescue Exception => err
|
151
|
+
logger.error '*** ERROR ***: %s' % err.message
|
152
|
+
link_to_function( _('Kohteeseen ei voi linkittää.'), "alert('#{err.message}')" )
|
153
|
+
end
|
154
|
+
end
|
155
|
+
|
156
|
+
|
157
|
+
def url_to_exit_portlet(url)
|
158
|
+
directive = { :exit_portlet => 'true' }
|
159
|
+
|
160
|
+
if url.is_a? Hash
|
161
|
+
url.update directive
|
162
|
+
|
163
|
+
elsif url.is_a? String
|
164
|
+
if url[/\?[\w]*\=/] # url has parameters
|
165
|
+
delimiter = '&'
|
166
|
+
else # no parameters
|
167
|
+
delimiter = '?'
|
168
|
+
end
|
169
|
+
url += "#{delimiter}#{directive.keys.first}=#{directive.values.first}"
|
170
|
+
|
171
|
+
end
|
172
|
+
return url
|
173
|
+
end
|
174
|
+
|
175
|
+
|
176
|
+
# formulates a link that the rails286-portlet will leave unparsed.
|
177
|
+
def link_to_exit_portlet(label, url)
|
178
|
+
link_to label, url_to_exit_portlet(url)
|
179
|
+
end
|
180
|
+
|
181
|
+
end
|
182
|
+
end
|
183
|
+
end
|
data/lib/caterpillar/liferay.rb
CHANGED
@@ -33,6 +33,10 @@ module Caterpillar
|
|
33
33
|
portlets = []
|
34
34
|
|
35
35
|
f=File.open(self.WEB_INF+'/portlet-custom.xml','r')
|
36
|
+
custom_xml = Hpricot.XML(f.read)
|
37
|
+
f.close
|
38
|
+
|
39
|
+
f=File.open(self.WEB_INF+'/liferay-portlet.xml','r')
|
36
40
|
portlet_xml = Hpricot.XML(f.read)
|
37
41
|
f.close
|
38
42
|
|
@@ -40,15 +44,20 @@ module Caterpillar
|
|
40
44
|
display_xml = Hpricot.XML(f.read)
|
41
45
|
f.close
|
42
46
|
|
43
|
-
(
|
47
|
+
(custom_xml/'portlet').each do |portlet|
|
44
48
|
_p = {
|
45
|
-
:
|
49
|
+
:id => (portlet/'portlet-name').innerHTML,
|
46
50
|
:title => (portlet/'display-name').innerHTML
|
47
51
|
}
|
48
52
|
|
49
|
-
#
|
53
|
+
# search the name
|
54
|
+
portlet_xml.search("//portlet-name").each do |p|
|
55
|
+
_p.update(:name => (p/"../struts-path").text) if p.innerHTML==_p[:id]
|
56
|
+
end
|
57
|
+
|
58
|
+
# search the category - horribly ineffective
|
50
59
|
display_xml.search("//category").each do |c|
|
51
|
-
_p.update(:category => c['name'] ) if (c/"//portlet[@id='#{_p[:
|
60
|
+
_p.update(:category => c['name'] ) if (c/"//portlet[@id='#{_p[:id]}']").any?
|
52
61
|
end
|
53
62
|
|
54
63
|
portlets << _p
|
@@ -167,7 +176,7 @@ module Caterpillar
|
|
167
176
|
# tables that are skipped when creating fixtures
|
168
177
|
def skip_fixture_tables
|
169
178
|
[
|
170
|
-
"
|
179
|
+
"cyrususer","cyrusvirtual",
|
171
180
|
"documentlibrary_fsentry","documentlibrary_binval","documentlibrary_node","documentlibrary_prop","documentlibrary_refs",
|
172
181
|
"expandocolumn",
|
173
182
|
"expandorow",
|
@@ -177,10 +186,6 @@ module Caterpillar
|
|
177
186
|
"chat_entry",
|
178
187
|
"chat_status",
|
179
188
|
"journalcontentsearch",
|
180
|
-
"journalfeed",
|
181
|
-
"journalstructure",
|
182
|
-
"journaltemplate",
|
183
|
-
"listtype",
|
184
189
|
"mbban",
|
185
190
|
"mbmessageflag",
|
186
191
|
"mbstatsuser",
|
@@ -190,9 +195,6 @@ module Caterpillar
|
|
190
195
|
"passwordpolicy",
|
191
196
|
"passwordtracker",
|
192
197
|
"pluginsetting",
|
193
|
-
"pollschoice",
|
194
|
-
"pollsquestion",
|
195
|
-
"pollsvote",
|
196
198
|
"quartz_blob_triggers",
|
197
199
|
"quartz_calendars",
|
198
200
|
"quartz_cron_triggers",
|
@@ -238,4 +240,4 @@ module Caterpillar
|
|
238
240
|
end
|
239
241
|
|
240
242
|
end
|
241
|
-
end
|
243
|
+
end
|
data/lib/caterpillar/task.rb
CHANGED
@@ -238,13 +238,15 @@ module Caterpillar
|
|
238
238
|
ActiveRecord::Migrator.migrate(
|
239
239
|
File.expand_path(
|
240
240
|
File.dirname(__FILE__) + "/../../db/migrate"))
|
241
|
-
|
241
|
+
STDOUT.puts 'Now, run rake db:schema:dump'
|
242
|
+
#Rake::Task["db:schema:dump"].invoke if ActiveRecord::Base.schema_format == :ruby
|
242
243
|
|
243
244
|
@portlets = config.container.analyze(:native)
|
244
245
|
@portlets.each do |portlet|
|
245
|
-
|
246
|
-
:
|
247
|
-
:
|
246
|
+
Web::PortletName.create(
|
247
|
+
:portletid => portlet[:id],
|
248
|
+
:name => portlet[:name],
|
249
|
+
:title => portlet[:title]
|
248
250
|
)
|
249
251
|
end
|
250
252
|
end
|
@@ -261,7 +263,8 @@ module Caterpillar
|
|
261
263
|
ActiveRecord::Migrator.migrate(
|
262
264
|
File.expand_path(
|
263
265
|
File.dirname(__FILE__) + "/../../db/migrate"), version)
|
264
|
-
|
266
|
+
STDOUT.puts 'Now, run rake db:schema:dump'
|
267
|
+
#Rake::Task["db:schema:dump"].invoke if ActiveRecord::Base.schema_format == :ruby
|
265
268
|
end
|
266
269
|
end
|
267
270
|
end
|
@@ -274,16 +277,17 @@ module Caterpillar
|
|
274
277
|
raise 'Only Liferay is supported' unless @config.container.kind_of? Liferay
|
275
278
|
require 'find'
|
276
279
|
|
280
|
+
#version = '0.5.2'
|
281
|
+
version = '0.6.0'
|
282
|
+
|
277
283
|
portlet_jar = nil
|
278
284
|
old_jar = nil
|
279
|
-
version = nil
|
280
285
|
source = File.join(CATERPILLAR_LIBS,'java')
|
281
286
|
target = File.join(@config.container.WEB_INF,'lib')
|
282
287
|
|
283
288
|
Find.find(source) do |file|
|
284
|
-
if File.basename(file) =~ /rails-portlet/
|
289
|
+
if File.basename(file) =~ /rails-portlet-#{version}/
|
285
290
|
portlet_jar = file
|
286
|
-
version = file[/(\d.\d.\d).jar/,1]
|
287
291
|
end
|
288
292
|
end
|
289
293
|
|
@@ -361,10 +365,20 @@ module Caterpillar
|
|
361
365
|
end
|
362
366
|
|
363
367
|
|
364
|
-
|
368
|
+
# Using JRuby to build the WAR file is necessary, as MRI Ruby can build broken files, even with the same set of rubygems.
|
369
|
+
# Especially gettext seems to be a problem.
|
365
370
|
def define_warble_task
|
366
371
|
desc 'Create a WAR package with Warbler'
|
367
372
|
task :warble do
|
373
|
+
unless ENV['JRUBY_HOME']
|
374
|
+
info 'Environment variable JRUBY_HOME is not set, exiting'
|
375
|
+
exit 1
|
376
|
+
end
|
377
|
+
jruby = File.join(ENV['JRUBY_HOME'],'bin','jruby')
|
378
|
+
unless File.exists?(jruby)
|
379
|
+
info 'JRuby executable was not found in %s, exiting' % jruby
|
380
|
+
exit 1
|
381
|
+
end
|
368
382
|
unless system('which warble')
|
369
383
|
info 'Warbler was not found in PATH, exiting'
|
370
384
|
exit 1
|
@@ -373,14 +387,9 @@ module Caterpillar
|
|
373
387
|
info 'Warbler configuration file %s was not found, exiting' % @config.warbler_conf
|
374
388
|
exit 1
|
375
389
|
end
|
376
|
-
info 'building WAR package'
|
377
|
-
|
378
|
-
system('ruby -S warble war')
|
390
|
+
info 'building WAR package using JRuby (%s)' % jruby
|
391
|
+
system(jruby+' -S warble war')
|
379
392
|
|
380
|
-
unless File.exists?(@config.servlet+'.war')
|
381
|
-
info 'cannot find the WAR file, exiting'
|
382
|
-
exit 1
|
383
|
-
end
|
384
393
|
end
|
385
394
|
end
|
386
395
|
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
data/lib/web/portlet.rb
ADDED
data/lib/web/portlet_name.rb
CHANGED
@@ -2,7 +2,7 @@ require 'active_record'
|
|
2
2
|
|
3
3
|
module Web # :nodoc:
|
4
4
|
# This model does not appear in the lportal database. This is created by a migration and contains the portlet id => name mappings.
|
5
|
-
class PortletName < ActiveRecord::Base
|
6
|
-
set_table_name :
|
5
|
+
class PortletName < ActiveRecord::Base
|
6
|
+
set_table_name :portlet_names
|
7
7
|
end
|
8
8
|
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
|
+
version: 0.9.4
|
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:
|
12
|
+
date: 2009-01-23 00:00:00 +02:00
|
13
13
|
default_executable: caterpillar
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
@@ -47,11 +47,16 @@ files:
|
|
47
47
|
- install.rb
|
48
48
|
- init.rb
|
49
49
|
- lib/java
|
50
|
+
- lib/java/rails-portlet-0.6.0.jar
|
50
51
|
- 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
55
|
- lib/caterpillar
|
52
56
|
- lib/caterpillar/config.rb
|
57
|
+
- lib/caterpillar/helpers
|
58
|
+
- lib/caterpillar/helpers/liferay.rb
|
53
59
|
- lib/caterpillar/navigation.rb
|
54
|
-
- lib/caterpillar/liferay_portlet.rb
|
55
60
|
- lib/caterpillar/usage.rb
|
56
61
|
- lib/caterpillar/liferay.rb
|
57
62
|
- lib/caterpillar/portlet.rb
|
@@ -61,6 +66,8 @@ files:
|
|
61
66
|
- lib/caterpillar.rb
|
62
67
|
- lib/web
|
63
68
|
- lib/web/portlet_name.rb
|
69
|
+
- lib/web/portlet_preferences.rb
|
70
|
+
- lib/web/portlet.rb
|
64
71
|
- generators/caterpillar
|
65
72
|
- generators/caterpillar/templates
|
66
73
|
- generators/caterpillar/templates/stylesheets
|
@@ -77,7 +84,7 @@ files:
|
|
77
84
|
- generators/caterpillar/caterpillar_generator.rb
|
78
85
|
- generators/caterpillar/USAGE
|
79
86
|
- db/migrate
|
80
|
-
- db/migrate/
|
87
|
+
- db/migrate/20081205000001_portlet_names.rb
|
81
88
|
- db/migrate/20081205000002_lportal_sequences.rb
|
82
89
|
- views/caterpillar
|
83
90
|
- views/caterpillar/_navigation.html.erb
|
@@ -91,7 +98,6 @@ rdoc_options:
|
|
91
98
|
- README
|
92
99
|
- --line-numbers
|
93
100
|
- --inline-source
|
94
|
-
- -U
|
95
101
|
require_paths:
|
96
102
|
- lib
|
97
103
|
required_ruby_version: !ruby/object:Gem::Requirement
|
@@ -115,4 +121,5 @@ specification_version: 2
|
|
115
121
|
summary: Caterpillar helps building Rails applications for JSR286 portlets.
|
116
122
|
test_files:
|
117
123
|
- test/portlets_test.rb
|
124
|
+
- test/liferay_helpers_test.rb
|
118
125
|
- test/xml_test.rb
|
@@ -1,8 +0,0 @@
|
|
1
|
-
require 'active_record'
|
2
|
-
|
3
|
-
module Caterpillar
|
4
|
-
# This model does not appear in the lportal database. This is created by a migration and contains the portlet id => name mappings.
|
5
|
-
class LiferayPortlet < ActiveRecord::Base
|
6
|
-
set_table_name :lportal_portlets
|
7
|
-
end
|
8
|
-
end
|