caterpillar 0.9.6 → 0.9.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/ChangeLog +10 -0
- data/README +22 -6
- data/lib/caterpillar.rb +1 -1
- data/lib/caterpillar/helpers/liferay.rb +2 -3
- data/lib/caterpillar/liferay.rb +27 -6
- data/lib/caterpillar/navigation.rb +0 -2
- data/lib/caterpillar/task.rb +17 -6
- data/lib/caterpillar/util.rb +22 -13
- data/lib/web/portlet.rb +26 -0
- data/views/caterpillar/_navigation.html.erb +15 -2
- metadata +2 -2
data/ChangeLog
CHANGED
|
@@ -1,3 +1,13 @@
|
|
|
1
|
+
= 0.9.8
|
|
2
|
+
- fix problem with subcategories in liferay-display.xml
|
|
3
|
+
- model Rails portlets as Web::Portlets
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
= 0.9.7
|
|
7
|
+
- display version in navigation view
|
|
8
|
+
- comply link_to_exit_portlet with link_to api
|
|
9
|
+
|
|
10
|
+
|
|
1
11
|
= 0.9.6
|
|
2
12
|
- added some tables and a notice to sequence migrations
|
|
3
13
|
- no longer installs css and javascript files, everything is cramped inline into the view
|
data/README
CHANGED
|
@@ -1,21 +1,37 @@
|
|
|
1
1
|
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
|
-
Rails portlets
|
|
5
|
-
|
|
6
|
-
This package offers these functionalities:
|
|
4
|
+
Writing Rails portlets for Liferay is great fun!
|
|
5
|
+
Caterpillar tasks offer specialized methods for better Liferay integration:
|
|
7
6
|
|
|
7
|
+
++xml++ and ++xml:deploy++
|
|
8
8
|
- processes the portlet XML configuration in accordance with the named routes
|
|
9
9
|
See Caterpillar::Config
|
|
10
10
|
|
|
11
|
+
++jar:install++
|
|
12
|
+
- installs the Rails-portlet JAR into Liferay's classpath
|
|
13
|
+
|
|
14
|
+
++deploy++
|
|
15
|
+
- warbles the application, updates the XML configuration and copies these to Liferay
|
|
16
|
+
|
|
17
|
+
++pluginize++
|
|
11
18
|
- provides a navigation view in development (you will have to enable it manually)
|
|
12
19
|
See Caterpillar::Navigation
|
|
13
20
|
|
|
21
|
+
++db:migrate++
|
|
14
22
|
- offers a set of migrations to help with Liferay integration
|
|
15
23
|
|
|
16
|
-
-
|
|
17
|
-
|
|
24
|
+
- patches Web::Portlet in the lportal[http://lportal.rubyforge.org] library, so manipulating
|
|
25
|
+
portlets is easier. This requires running the migrations.
|
|
26
|
+
|
|
27
|
+
++fixtures++
|
|
28
|
+
- imports live data from the production database for testing
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
See the rdoc documentation and caterpillar --describe for the full feature list.
|
|
18
32
|
|
|
19
33
|
|
|
34
|
+
Caterpillar is open source! Patches and comments are welcome.
|
|
35
|
+
Join the bugs mailing list (http://rubyforge.org/mailman/listinfo/rails-portlet-bugs) to request help.
|
|
20
36
|
|
|
21
|
-
|
|
37
|
+
Caterpillar is written by Mikael Lammentausta for Cel'Amanzi Ltd.
|
data/lib/caterpillar.rb
CHANGED
|
@@ -174,9 +174,8 @@ module Helpers
|
|
|
174
174
|
|
|
175
175
|
|
|
176
176
|
# formulates a link that the rails286-portlet will leave unparsed.
|
|
177
|
-
def link_to_exit_portlet(
|
|
178
|
-
|
|
179
|
-
link_to label, url_to_exit_portlet(url)
|
|
177
|
+
def link_to_exit_portlet(name, options = {}, html_options = {})
|
|
178
|
+
link_to(name, url_to_exit_portlet(options), html_options)
|
|
180
179
|
end
|
|
181
180
|
|
|
182
181
|
end
|
data/lib/caterpillar/liferay.rb
CHANGED
|
@@ -26,7 +26,8 @@ module Caterpillar
|
|
|
26
26
|
File.join(self.root,'webapps','ROOT','WEB-INF')
|
|
27
27
|
end
|
|
28
28
|
|
|
29
|
-
|
|
29
|
+
# Reads Liferay portlet descriptor XML files and parses them with Hpricot.
|
|
30
|
+
def analyze(type=:native)
|
|
30
31
|
require 'hpricot'
|
|
31
32
|
return nil unless type==:native
|
|
32
33
|
|
|
@@ -55,9 +56,28 @@ module Caterpillar
|
|
|
55
56
|
_p.update(:name => (p/"../struts-path").text) if p.innerHTML==_p[:id]
|
|
56
57
|
end
|
|
57
58
|
|
|
58
|
-
# search the category - horribly ineffective
|
|
59
|
-
|
|
60
|
-
|
|
59
|
+
# search the category - horribly ineffective.
|
|
60
|
+
# the categories is an Array where each raising index is a new subcategory
|
|
61
|
+
display_xml.search("display/category").each do |c|
|
|
62
|
+
if (c/"//portlet[@id='#{_p[:id]}']").any?
|
|
63
|
+
# the portlet is in this category
|
|
64
|
+
categories = [c['name']]
|
|
65
|
+
|
|
66
|
+
# child categories
|
|
67
|
+
c.search("category").each do |child|
|
|
68
|
+
categories << child['name']
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
if categories.size > 1
|
|
72
|
+
_p.update(:categories => categories)
|
|
73
|
+
else
|
|
74
|
+
_p.update(:category => categories.first)
|
|
75
|
+
end
|
|
76
|
+
# debug
|
|
77
|
+
#puts _p.inspect
|
|
78
|
+
#portlets << _p
|
|
79
|
+
|
|
80
|
+
end
|
|
61
81
|
end
|
|
62
82
|
|
|
63
83
|
portlets << _p
|
|
@@ -81,12 +101,13 @@ module Caterpillar
|
|
|
81
101
|
xml = self.xml_header('display')
|
|
82
102
|
|
|
83
103
|
categories = []
|
|
104
|
+
# process Rails portlets
|
|
84
105
|
Util.categorize(portlets).each_pair do |category,portlets|
|
|
85
106
|
categories << category
|
|
86
107
|
xml << self.display_template(category,portlets)
|
|
87
108
|
end
|
|
88
109
|
|
|
89
|
-
# include other native Liferay categories
|
|
110
|
+
# include other native Liferay portlets and categories
|
|
90
111
|
if self.WEB_INF
|
|
91
112
|
require 'hpricot'
|
|
92
113
|
|
|
@@ -94,7 +115,7 @@ module Caterpillar
|
|
|
94
115
|
f=File.open(filename,'r')
|
|
95
116
|
doc = Hpricot.XML(f.read)
|
|
96
117
|
f.close
|
|
97
|
-
(doc
|
|
118
|
+
(doc/"display/category").each do |el|
|
|
98
119
|
unless categories.include?(el.attributes['name'])
|
|
99
120
|
xml << ' ' + el.to_original_html + "\n"
|
|
100
121
|
end
|
|
@@ -22,8 +22,6 @@ module Caterpillar
|
|
|
22
22
|
#
|
|
23
23
|
# This will go the body of your layout:
|
|
24
24
|
# <% if @caterpillar_navigation -%>
|
|
25
|
-
# <%= stylesheet_link_tag 'caterpillar/caterpillar' %>
|
|
26
|
-
# <%= javascript_include_tag 'caterpillar/caterpillar' %>
|
|
27
25
|
# <%= render :partial => "caterpillar/navigation" %>
|
|
28
26
|
# <% end -%>
|
|
29
27
|
#
|
data/lib/caterpillar/task.rb
CHANGED
|
@@ -43,7 +43,7 @@ module Caterpillar
|
|
|
43
43
|
@config = Util.eval_configuration(config)
|
|
44
44
|
yield self if block_given?
|
|
45
45
|
@xml_files = []
|
|
46
|
-
STDOUT.puts 'Caterpillar v.%s (c) Copyright 2008 Mikael Lammentausta' % VERSION
|
|
46
|
+
STDOUT.puts 'Caterpillar v.%s (c) Copyright 2008,2009 Mikael Lammentausta' % VERSION
|
|
47
47
|
#STDOUT.puts 'Caterpillar v.%s' % Caterpillar::VERSION
|
|
48
48
|
STDOUT.puts 'Provided under the terms of the MIT license.'
|
|
49
49
|
STDOUT.puts
|
|
@@ -481,17 +481,28 @@ module Caterpillar
|
|
|
481
481
|
protected
|
|
482
482
|
|
|
483
483
|
def print_portlets(hash)
|
|
484
|
-
|
|
485
|
-
|
|
484
|
+
# organize
|
|
485
|
+
_sorted = Util.categorize(hash)
|
|
486
|
+
|
|
487
|
+
# calculate the longest title
|
|
488
|
+
longest_title = 0
|
|
489
|
+
_sorted.each_pair do |category,portlets|
|
|
490
|
+
x = portlets.sort_by{|p| p[:title].size}.last[:title]
|
|
491
|
+
longest_title = x.size if x.size > longest_title
|
|
492
|
+
end
|
|
493
|
+
|
|
494
|
+
_sorted.each_pair do |category,portlets|
|
|
495
|
+
STDOUT.puts category
|
|
486
496
|
portlets.each do |portlet|
|
|
487
497
|
# spaces
|
|
488
498
|
spaces = ''
|
|
489
|
-
0.upto(
|
|
499
|
+
0.upto((longest_title + 5)-portlet[:title].size) do
|
|
490
500
|
spaces << ' '
|
|
491
501
|
end
|
|
492
502
|
|
|
493
|
-
field = :path
|
|
494
|
-
|
|
503
|
+
#field = :path
|
|
504
|
+
#fields = [:name, :id]
|
|
505
|
+
STDOUT.puts "\t" + portlet[:title] +spaces+ portlet[:id].inspect + "\t" + portlet[:name].inspect
|
|
495
506
|
end
|
|
496
507
|
end
|
|
497
508
|
end
|
data/lib/caterpillar/util.rb
CHANGED
|
@@ -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
|
#++
|
|
@@ -56,26 +56,35 @@ module Caterpillar
|
|
|
56
56
|
# {'Category 1' => [portlets], 'Category 2' => [portlets]}
|
|
57
57
|
def categorize(portlets)
|
|
58
58
|
ret = {}
|
|
59
|
-
# STDERR.puts portlets.first.inspect
|
|
60
59
|
|
|
61
|
-
# organize into categories
|
|
62
|
-
categories = portlets.collect{|p| p[:category]}
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
ret.update(category => _portlets)
|
|
66
|
-
end
|
|
60
|
+
# organize into main categories
|
|
61
|
+
categories = portlets.collect{|p| p[:category]}
|
|
62
|
+
categories << portlets.collect{|p| p[:categories].first if p[:categories]}
|
|
63
|
+
categories.flatten!.uniq!
|
|
67
64
|
|
|
68
|
-
|
|
65
|
+
categories.each do |category|
|
|
66
|
+
next if category.nil? # skip nil categories
|
|
69
67
|
|
|
68
|
+
# does this category have subcategories?
|
|
69
|
+
# skip them. TODO: parse internal categories
|
|
70
|
+
if (portlets.map{|p| (
|
|
71
|
+
!p[:categories].nil? && \
|
|
72
|
+
p[:categories].first==category)} & [true] ).any?
|
|
73
|
+
STDERR.puts '%s has subcategories, skipping' % category.inspect
|
|
74
|
+
next
|
|
75
|
+
end
|
|
76
|
+
|
|
77
|
+
# select the portlets in this category
|
|
78
|
+
_portlets = portlets.select do |p|
|
|
79
|
+
p[:category]==category or (!p[:categories].nil? and p[:categories].include?(category))
|
|
80
|
+
end
|
|
70
81
|
|
|
71
|
-
|
|
82
|
+
ret.update(category => _portlets)
|
|
83
|
+
end
|
|
72
84
|
|
|
73
85
|
return ret
|
|
74
86
|
end
|
|
75
87
|
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
88
|
end # static
|
|
80
89
|
end
|
|
81
90
|
end
|
data/lib/web/portlet.rb
CHANGED
|
@@ -2,9 +2,35 @@ require 'active_record'
|
|
|
2
2
|
|
|
3
3
|
module Web
|
|
4
4
|
class Portlet < ActiveRecord::Base
|
|
5
|
+
|
|
6
|
+
@@caterpillar_portlets = nil
|
|
7
|
+
|
|
8
|
+
def self.caterpillar_portlets
|
|
9
|
+
return @@caterpillar_portlets if @@caterpillar_portlets
|
|
10
|
+
|
|
11
|
+
config = Caterpillar::Util.eval_configuration
|
|
12
|
+
config.routes = Caterpillar::Util.parse_routes(config)
|
|
13
|
+
|
|
14
|
+
# transform objects
|
|
15
|
+
portlets = []
|
|
16
|
+
Caterpillar::Parser.new(config).portlets.each do |p|
|
|
17
|
+
portlets << self.new(
|
|
18
|
+
:portletid => p[:name].to_s
|
|
19
|
+
)
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
@@caterpillar_portlets = portlets
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
def self.find_caterpillar_portlet(name)
|
|
26
|
+
self.caterpillar_portlets.select{
|
|
27
|
+
|p| p.name=='%s' % name }.first # find_by_name
|
|
28
|
+
end
|
|
29
|
+
|
|
5
30
|
def title
|
|
6
31
|
p = Web::PortletName.find_by_portletid(self.portletid)
|
|
7
32
|
p ? p.title : nil
|
|
8
33
|
end
|
|
34
|
+
|
|
9
35
|
end
|
|
10
36
|
end
|
|
@@ -22,12 +22,14 @@
|
|
|
22
22
|
.caterpillar_navigation {
|
|
23
23
|
background: url('/images/caterpillar.gif') no-repeat;
|
|
24
24
|
padding: 10px 0 0 50px;
|
|
25
|
-
|
|
26
|
-
|
|
25
|
+
min-height: 55px;
|
|
26
|
+
overflow: auto;
|
|
27
|
+
|
|
27
28
|
filter:alpha(opacity=81);-moz-opacity:.81;opacity:.81;
|
|
28
29
|
/* css3 tags, works on Firefox and Safari */
|
|
29
30
|
-moz-border-radius: 15px;
|
|
30
31
|
-webkit-border-radius: 15px;
|
|
32
|
+
border-bottom: 1px dotted green;
|
|
31
33
|
}
|
|
32
34
|
|
|
33
35
|
.caterpillar_navigation ul {
|
|
@@ -67,6 +69,14 @@
|
|
|
67
69
|
-moz-border-radius: 8px;
|
|
68
70
|
-webkit-border-radius: 8px;
|
|
69
71
|
}
|
|
72
|
+
|
|
73
|
+
#cp_version {
|
|
74
|
+
font-style: italic;
|
|
75
|
+
font-size: 9px;
|
|
76
|
+
position: absolute;
|
|
77
|
+
left: 10px;
|
|
78
|
+
top: 55px;
|
|
79
|
+
}
|
|
70
80
|
</style>
|
|
71
81
|
|
|
72
82
|
<div class="caterpillar_navigation">
|
|
@@ -115,4 +125,7 @@
|
|
|
115
125
|
</ul>
|
|
116
126
|
</div>
|
|
117
127
|
<% end -%>
|
|
128
|
+
<div id="cp_version">
|
|
129
|
+
Caterpillar v<%= Caterpillar::VERSION -%>
|
|
130
|
+
</div>
|
|
118
131
|
</div>
|
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.8
|
|
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-02-
|
|
12
|
+
date: 2009-02-24 00:00:00 +02:00
|
|
13
13
|
default_executable: caterpillar
|
|
14
14
|
dependencies:
|
|
15
15
|
- !ruby/object:Gem::Dependency
|