caterpillar 0.9.0
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/LICENSES.txt +25 -0
- data/README +21 -0
- data/Rakefile +26 -0
- data/bin/caterpillar +39 -0
- data/db/migrate/20081205000001_lportal_portlets.rb +12 -0
- data/db/migrate/20081205000002_lportal_sequences.rb +50 -0
- data/generators/caterpillar/USAGE +1 -0
- data/generators/caterpillar/caterpillar_generator.rb +52 -0
- data/generators/caterpillar/templates/config/portlets.rb +59 -0
- data/generators/caterpillar/templates/images/caterpillar/caterpillar.gif +0 -0
- data/generators/caterpillar/templates/javascripts/caterpillar/caterpillar.js +15 -0
- data/generators/caterpillar/templates/stylesheets/caterpillar/caterpillar.css +48 -0
- data/init.rb +8 -0
- data/install.rb +3 -0
- data/lib/caterpillar.rb +27 -0
- data/lib/caterpillar/config.rb +57 -0
- data/lib/caterpillar/liferay.rb +235 -0
- data/lib/caterpillar/liferay_portlet.rb +8 -0
- data/lib/caterpillar/navigation.rb +40 -0
- data/lib/caterpillar/parser.rb +110 -0
- data/lib/caterpillar/portlet.rb +98 -0
- data/lib/caterpillar/task.rb +285 -0
- data/lib/caterpillar/usage.rb +21 -0
- data/lib/caterpillar/util.rb +80 -0
- data/lib/caterpillar/version.rb +9 -0
- data/lib/web/portlet_name.rb +8 -0
- data/test/portlets_test.rb +43 -0
- data/test/xml_test.rb +24 -0
- data/views/caterpillar/_navigation.html.erb +45 -0
- metadata +116 -0
data/LICENSES.txt
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
= Caterpillar
|
2
|
+
|
3
|
+
Caterpillar is provided under the terms of the MIT license.
|
4
|
+
|
5
|
+
(c) Copyright 2008 Cel'Amanzi Ltd and Mikael Lammentausta
|
6
|
+
|
7
|
+
Permission is hereby granted, free of charge, to any person
|
8
|
+
obtaining a copy of this software and associated documentation files
|
9
|
+
(the "Software"), to deal in the Software without restriction,
|
10
|
+
including without limitation the rights to use, copy, modify, merge,
|
11
|
+
publish, distribute, sublicense, and/or sell copies of the Software,
|
12
|
+
and to permit persons to whom the Software is furnished to do so,
|
13
|
+
subject to the following conditions:
|
14
|
+
|
15
|
+
The above copyright notice and this permission notice shall be
|
16
|
+
included in all copies or substantial portions of the Software.
|
17
|
+
|
18
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
19
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
20
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
21
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
|
22
|
+
BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
|
23
|
+
ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
24
|
+
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
25
|
+
SOFTWARE.
|
data/README
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
Caterpillar helps you with building Rails applications to be used in Java
|
2
|
+
JSR286 portlets. This is possible with the help of Rails-portlet[http://rails-portlet.rubyforge.org].
|
3
|
+
|
4
|
+
Rails portlets have been used on Liferay and the helpers offer specialized methods to support better Liferay integration.
|
5
|
+
|
6
|
+
This package offers these functionalities:
|
7
|
+
|
8
|
+
- processes the portlet XML configuration in accordance with the named routes
|
9
|
+
See Caterpillar::Config
|
10
|
+
|
11
|
+
- provides a navigation view in development (you will have to enable it manually)
|
12
|
+
See Caterpillar::Navigation
|
13
|
+
|
14
|
+
- offers a set of migrations to help with Liferay integration
|
15
|
+
|
16
|
+
- provides a Rake task 'fixtures', which imports live data
|
17
|
+
from the production database for testing
|
18
|
+
|
19
|
+
|
20
|
+
|
21
|
+
See the rdoc documentation and caterpillar --describe for the feature list.
|
data/Rakefile
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
require 'rake'
|
2
|
+
require 'rake/testtask'
|
3
|
+
require 'rake/rdoctask'
|
4
|
+
|
5
|
+
desc 'Default: create API doc.'
|
6
|
+
task :default => :rdoc
|
7
|
+
|
8
|
+
desc 'Test the example plugin.'
|
9
|
+
Rake::TestTask.new(:test) do |t|
|
10
|
+
t.libs << 'lib'
|
11
|
+
t.pattern = 'test/**/*_test.rb'
|
12
|
+
t.verbose = true
|
13
|
+
end
|
14
|
+
|
15
|
+
desc 'Generate documentation for the example plugin.'
|
16
|
+
Rake::RDocTask.new(:rdoc) do |rdoc|
|
17
|
+
rdoc.rdoc_dir = 'rdoc'
|
18
|
+
rdoc.title = 'Caterpillar'
|
19
|
+
rdoc.main = 'README'
|
20
|
+
rdoc.rdoc_files.include('README')
|
21
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
22
|
+
rdoc.rdoc_files.include('generators/**/*.rb')
|
23
|
+
rdoc.options << '--line-numbers' << '--inline-source' << '-U'
|
24
|
+
end
|
25
|
+
|
26
|
+
|
data/bin/caterpillar
ADDED
@@ -0,0 +1,39 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
#
|
3
|
+
#--
|
4
|
+
# (c) Copyright 2008 Mikael Lammentausta, Cel'Amanzi Ltd
|
5
|
+
#
|
6
|
+
# Constructed heavily upon Warbler's structure.
|
7
|
+
# Thanks to Nick Sieger!
|
8
|
+
#
|
9
|
+
# See the file LICENSES.txt included with the distribution for
|
10
|
+
# software license details.
|
11
|
+
#++
|
12
|
+
|
13
|
+
require 'rubygems'
|
14
|
+
require 'rake'
|
15
|
+
require 'caterpillar'
|
16
|
+
|
17
|
+
application = Rake.application
|
18
|
+
|
19
|
+
# Load any application rakefiles to aid in autodetecting applications
|
20
|
+
Caterpillar.project_application = Rake::Application.new
|
21
|
+
Rake.application = Caterpillar.project_application
|
22
|
+
Rake::Application::DEFAULT_RAKEFILES.each do |rf|
|
23
|
+
if File.exist?(rf)
|
24
|
+
load rf
|
25
|
+
break
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
Rake.application = application
|
30
|
+
application.standard_exception_handling do
|
31
|
+
application.init
|
32
|
+
|
33
|
+
# Load the main tasks - choose the namespace
|
34
|
+
Caterpillar::Task.new(ARGV[0] ? ARGV[0].gsub(/:.*/,'') : :usage)
|
35
|
+
|
36
|
+
task :default => :usage
|
37
|
+
|
38
|
+
application.top_level
|
39
|
+
end
|
@@ -0,0 +1,50 @@
|
|
1
|
+
require 'lportal'
|
2
|
+
|
3
|
+
class LportalSequences < ActiveRecord::Migration
|
4
|
+
@@tables = [
|
5
|
+
Account,
|
6
|
+
Address,
|
7
|
+
Asset,
|
8
|
+
Contact,
|
9
|
+
Group,
|
10
|
+
Permission,
|
11
|
+
Phone,
|
12
|
+
ResourceCode,
|
13
|
+
Resource,
|
14
|
+
Role,
|
15
|
+
User,
|
16
|
+
MB::Message,
|
17
|
+
MB::Thread,
|
18
|
+
MB::Discussion,
|
19
|
+
MB::Category,
|
20
|
+
Tag::Entry,
|
21
|
+
Tag::Property,
|
22
|
+
Web::Layout,
|
23
|
+
Web::LayoutSet,
|
24
|
+
Web::PortletPreferences,
|
25
|
+
Web::Portlet
|
26
|
+
]
|
27
|
+
|
28
|
+
def self.up
|
29
|
+
# start = 8400000 # bigint = 8^8 bytes = 16 million bits, this is halfway up the possible range, rounded up
|
30
|
+
# sql = ""
|
31
|
+
# @@tables.each do |model|
|
32
|
+
# table = model.table_name
|
33
|
+
# primkey = model.primary_key
|
34
|
+
# seq = table+'_'+primkey+'_seq'
|
35
|
+
# sql += "CREATE SEQUENCE #{seq} START #{start}; ALTER TABLE #{table} ALTER #{primkey} SET default nextval('#{seq}');"
|
36
|
+
# end
|
37
|
+
# ActiveRecord::Base.connection.execute(sql)
|
38
|
+
end
|
39
|
+
|
40
|
+
def self.down
|
41
|
+
# sql = ""
|
42
|
+
# @@tables.each do |model|
|
43
|
+
# table = model.table_name
|
44
|
+
# primkey = model.primary_key
|
45
|
+
# seq = table+'_'+primkey+'_seq'
|
46
|
+
# sql += "ALTER TABLE #{table} ALTER #{primkey} DROP default; DROP SEQUENCE #{seq};"
|
47
|
+
# end
|
48
|
+
# ActiveRecord::Base.connection.execute(sql)
|
49
|
+
end
|
50
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
This writes a set of Caterpillar files into the Rails application.
|
@@ -0,0 +1,52 @@
|
|
1
|
+
# This generator installs the required files into the main Rails application.
|
2
|
+
# This generator should always be run after upgrading the plugin.
|
3
|
+
class CaterpillarGenerator < Rails::Generator::Base
|
4
|
+
def manifest
|
5
|
+
|
6
|
+
require 'find'
|
7
|
+
file = File.symlink?(__FILE__) ? File.readlink(__FILE__) : __FILE__
|
8
|
+
this_dir = File.dirname(File.expand_path(file))
|
9
|
+
tmpl = this_dir+'/templates'
|
10
|
+
|
11
|
+
STDOUT.puts ' * Installing config, stylesheets and images'
|
12
|
+
|
13
|
+
record do |m|
|
14
|
+
|
15
|
+
### migrations ###
|
16
|
+
m.directory('config')
|
17
|
+
file = 'portlets.rb'
|
18
|
+
m.file('config/'+file, 'config/'+file)
|
19
|
+
####################################
|
20
|
+
|
21
|
+
|
22
|
+
### stylesheet ###
|
23
|
+
target = 'public/stylesheets/caterpillar'
|
24
|
+
m.directory(target)
|
25
|
+
file = 'caterpillar.css'
|
26
|
+
m.file('stylesheets/caterpillar/'+file, target+'/'+file)
|
27
|
+
####################################
|
28
|
+
|
29
|
+
### javascript ###
|
30
|
+
target = 'public/javascripts/caterpillar'
|
31
|
+
m.directory(target)
|
32
|
+
file = 'caterpillar.js'
|
33
|
+
m.file('javascripts/caterpillar/'+file, target+'/'+file)
|
34
|
+
####################################
|
35
|
+
|
36
|
+
### images ###
|
37
|
+
target = 'public/images/caterpillar'
|
38
|
+
m.directory(target)
|
39
|
+
file = 'caterpillar.gif'
|
40
|
+
m.file('images/caterpillar/'+file, target+'/'+file)
|
41
|
+
####################################
|
42
|
+
|
43
|
+
# ### views ###
|
44
|
+
# target = 'app/views/caterpillar'
|
45
|
+
# m.directory(target)
|
46
|
+
# file = '_navigation.html.erb'
|
47
|
+
# m.file('views/caterpillar/'+file, target+'/'+file)
|
48
|
+
# ####################################
|
49
|
+
#
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
@@ -0,0 +1,59 @@
|
|
1
|
+
Caterpillar::Config.new do |portlet|
|
2
|
+
|
3
|
+
# The portlet container.
|
4
|
+
# By default only portlet.xml is created.
|
5
|
+
# Currently only Liferay is supported. You may optionally define the version.
|
6
|
+
portlet.container = Liferay
|
7
|
+
# portlet.container.version = '5.1.1'
|
8
|
+
|
9
|
+
# Dince liferay-display-ext.xml does not exist, all portlets are categorized in
|
10
|
+
# liferay-display.xml. If you intend to keep other portlets still intact,
|
11
|
+
# you need to specify the location of WEB-INF.
|
12
|
+
# No changes are made to any of the files in this directory.
|
13
|
+
portlet.container.WEB_INF = '/usr/local/liferay/webapps/ROOT/WEB-INF/'
|
14
|
+
|
15
|
+
# The hostname and port.
|
16
|
+
# By default the values are taken from the request.
|
17
|
+
# portlet.host
|
18
|
+
|
19
|
+
# If the Rails is running inside a servlet container such as Tomcat,
|
20
|
+
# you can define the servlet here.
|
21
|
+
# By default the servlet is the name of the Rails app.
|
22
|
+
# Remember to update this if you override Warbler's default.
|
23
|
+
# portlet.servlet
|
24
|
+
|
25
|
+
# Portlet category. This is only available for Liferay.
|
26
|
+
# By default this is the same as the servlet.
|
27
|
+
# portlet.category = 'Zcore'
|
28
|
+
|
29
|
+
# Portlet instances.
|
30
|
+
#
|
31
|
+
# Each named route is mapped to a portlet.
|
32
|
+
#
|
33
|
+
# All keys except for 'name' are obligatory. If the name does not map to a route,
|
34
|
+
# you have to define the route here.
|
35
|
+
# You may override the host, servlet and category here.
|
36
|
+
# Most likely you will want to let ActionController::Routing to set the route.
|
37
|
+
#
|
38
|
+
# Available keys are:
|
39
|
+
# - :name -- named route
|
40
|
+
# - :category -- portlet category (Liferay only)
|
41
|
+
# - :title -- the title in portlet container's category (Liferay only)
|
42
|
+
# - :javascripts -- portlet-specific javascripts that are not in the HTML head section (Liferay only)
|
43
|
+
# - :host
|
44
|
+
# - :servlet
|
45
|
+
# - :path -- unless you're using named routes, you can define the path here
|
46
|
+
|
47
|
+
# example:
|
48
|
+
# portlet.instances << {
|
49
|
+
# :name => 'rails286_test',
|
50
|
+
# :title => 'Rails-portlet testing application',
|
51
|
+
# :category => 'Testing',
|
52
|
+
# :servlet => 'RailsTestBench',
|
53
|
+
# :path => '/'
|
54
|
+
# }
|
55
|
+
|
56
|
+
# this will include all named routes without further configuration
|
57
|
+
portlet.include_all_named_routes = true
|
58
|
+
|
59
|
+
end
|
Binary file
|
@@ -0,0 +1,15 @@
|
|
1
|
+
function cp_toggle_category(c,categories) {
|
2
|
+
c_el = document.getElementById(c);
|
3
|
+
p_el = document.getElementById(c+'_portlets');
|
4
|
+
|
5
|
+
if (p_el.style.display=='none') {
|
6
|
+
p_el.style.display='block';
|
7
|
+
c_el.style.background='yellow';
|
8
|
+
}
|
9
|
+
else {
|
10
|
+
p_el.style.display='none';
|
11
|
+
c_el.style.background='white';
|
12
|
+
}
|
13
|
+
|
14
|
+
|
15
|
+
}
|
@@ -0,0 +1,48 @@
|
|
1
|
+
.caterpillar_navigation {
|
2
|
+
background: url('/images/caterpillar/caterpillar.gif') no-repeat;
|
3
|
+
padding: 10px 0 0 50px;
|
4
|
+
margin-left: 10px;
|
5
|
+
min-height: 50px;
|
6
|
+
filter:alpha(opacity=81);-moz-opacity:.81;opacity:.81;
|
7
|
+
/* css3 tags, works on Firefox and Safari */
|
8
|
+
-moz-border-radius: 15px;
|
9
|
+
-webkit-border-radius: 15px;
|
10
|
+
}
|
11
|
+
|
12
|
+
.caterpillar_navigation ul {
|
13
|
+
list-style-type: none;
|
14
|
+
}
|
15
|
+
|
16
|
+
.cp_category {
|
17
|
+
float: left;
|
18
|
+
border: 3px double blue;
|
19
|
+
margin: 0 14px 5px 14px;
|
20
|
+
padding: 5px;
|
21
|
+
-moz-border-radius: 12px;
|
22
|
+
-webkit-border-radius: 12px;
|
23
|
+
background: white;
|
24
|
+
}
|
25
|
+
|
26
|
+
.cp_portlets {
|
27
|
+
float: break;
|
28
|
+
overflow: hidden;
|
29
|
+
margin: 0 40px 10px 40px;
|
30
|
+
border: 3px double green;
|
31
|
+
padding: 5px;
|
32
|
+
}
|
33
|
+
|
34
|
+
.navlink {
|
35
|
+
margin: 5px 14px 5px 14px;
|
36
|
+
padding: 5px;
|
37
|
+
-moz-border-radius: 12px;
|
38
|
+
-webkit-border-radius: 12px;
|
39
|
+
}
|
40
|
+
|
41
|
+
.navlink a {
|
42
|
+
text-decoration: none;
|
43
|
+
}
|
44
|
+
|
45
|
+
.navlink a:hover {
|
46
|
+
-moz-border-radius: 8px;
|
47
|
+
-webkit-border-radius: 8px;
|
48
|
+
}
|
data/init.rb
ADDED
@@ -0,0 +1,8 @@
|
|
1
|
+
file = File.symlink?(__FILE__) ? File.readlink(__FILE__) : __FILE__
|
2
|
+
this_dir = File.dirname(File.expand_path(file))
|
3
|
+
|
4
|
+
# append the views path
|
5
|
+
ActionController::Base.append_view_path File.join(this_dir, 'views')
|
6
|
+
|
7
|
+
# load the main file
|
8
|
+
require File.join(this_dir, 'lib', 'caterpillar')
|
data/install.rb
ADDED
data/lib/caterpillar.rb
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
#--
|
2
|
+
# (c) Copyright 2008 Mikael Lammentausta
|
3
|
+
# See the file LICENSES.txt included with the distribution for
|
4
|
+
# software license details.
|
5
|
+
#++
|
6
|
+
|
7
|
+
|
8
|
+
module Caterpillar
|
9
|
+
end
|
10
|
+
|
11
|
+
file = File.symlink?(__FILE__) ? File.readlink(__FILE__) : __FILE__
|
12
|
+
this_dir = File.dirname(File.expand_path(file))
|
13
|
+
|
14
|
+
require 'find'
|
15
|
+
|
16
|
+
# include all ruby files
|
17
|
+
Find.find(this_dir) do |file|
|
18
|
+
if FileTest.directory?(file)
|
19
|
+
if File.basename(file) == 'deprecated'
|
20
|
+
Find.prune # Don't look any further into this directory.
|
21
|
+
else
|
22
|
+
next
|
23
|
+
end
|
24
|
+
else
|
25
|
+
require file if file[/.rb$/]
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,57 @@
|
|
1
|
+
#--
|
2
|
+
# (c) Copyright 2008 Mikael Lammentausta
|
3
|
+
# See the file LICENSES.txt included with the distribution for
|
4
|
+
# software license details.
|
5
|
+
#++
|
6
|
+
|
7
|
+
module Caterpillar
|
8
|
+
# Portlet configuration. The config file 'config/portlets.rb' should be installed in your Rails application. See the comments in the configuration file for more specific information about each option.
|
9
|
+
class Config
|
10
|
+
FILE = "config/portlets.rb"
|
11
|
+
|
12
|
+
# Are all named routes used, or only the ones specifically defined in the config FILE?
|
13
|
+
attr_accessor :include_all_named_routes
|
14
|
+
|
15
|
+
attr_accessor :category
|
16
|
+
|
17
|
+
attr_accessor :host
|
18
|
+
|
19
|
+
attr_accessor :servlet
|
20
|
+
|
21
|
+
attr_accessor :instances
|
22
|
+
|
23
|
+
attr_reader :rails_root
|
24
|
+
|
25
|
+
attr_accessor :_container
|
26
|
+
|
27
|
+
attr_accessor :javascripts
|
28
|
+
|
29
|
+
attr_accessor :routes
|
30
|
+
|
31
|
+
# Sets sane defaults that are overridden in the config file.
|
32
|
+
def initialize
|
33
|
+
@rails_root = File.expand_path(defined?(RAILS_ROOT) ? RAILS_ROOT : Dir.getwd)
|
34
|
+
@servlet = File.basename(@rails_root)
|
35
|
+
@category = @servlet
|
36
|
+
@instances = []
|
37
|
+
@javascripts = []
|
38
|
+
@include_all_named_routes = true
|
39
|
+
|
40
|
+
yield self if block_given?
|
41
|
+
end
|
42
|
+
|
43
|
+
# The container class is used for parsing XML files.
|
44
|
+
#
|
45
|
+
# Possible values: Liferay
|
46
|
+
def container
|
47
|
+
self._container
|
48
|
+
end
|
49
|
+
|
50
|
+
# Accepts the configuration option, and instantates the container class.
|
51
|
+
def container=(_class)
|
52
|
+
self._container = _class.new
|
53
|
+
end
|
54
|
+
|
55
|
+
|
56
|
+
end
|
57
|
+
end
|