caterpillar 0.9.8 → 0.9.15

Sign up to get free protection for your applications and to get access to all the features.
@@ -12,6 +12,8 @@ module Caterpillar
12
12
  # Reads the configuration
13
13
  def eval_configuration(config=nil)
14
14
  cf = File.join([RAILS_ROOT,Caterpillar::Config::FILE])
15
+ STDERR.puts 'Caterpillar configuration file could not be found' unless File.exists?(cf)
16
+
15
17
  if config.nil? && File.exists?(cf)
16
18
  config = eval(File.open(cf) {|f| f.read})
17
19
  end
@@ -1,6 +1,8 @@
1
+ require 'rubygems'
1
2
  require 'active_record'
2
3
 
3
- module Web
4
+ module Web # :nodoc:
5
+ # Adds Caterpillar portlets to available portlets.
4
6
  class Portlet < ActiveRecord::Base
5
7
 
6
8
  @@caterpillar_portlets = nil
@@ -27,9 +29,36 @@ module Web
27
29
  |p| p.name=='%s' % name }.first # find_by_name
28
30
  end
29
31
 
30
- def title
31
- p = Web::PortletName.find_by_portletid(self.portletid)
32
- p ? p.title : nil
32
+ # def self.find_by_portletid(*args)
33
+ # puts args.inspect
34
+ # super(args)
35
+ # # TODO: find caterpillar_portlets
36
+ # end
37
+
38
+ # searches both Liferay and Caterpillar portlets
39
+ # TODO: DRY up with super
40
+ def self.find_by_name(name)
41
+ begin
42
+ pp = Web::PortletProperties.find_by_name(name)
43
+ if pp
44
+ p = self.find_by_portletid pp.portletid
45
+ return p if p
46
+ end
47
+
48
+ pp = find_caterpillar_portlet(name) unless pp
49
+
50
+ unless pp
51
+ raise ActiveRecord::RecordNotFound
52
+ else
53
+ return self.create(
54
+ :portletid => pp.portletid
55
+ )
56
+ end
57
+ rescue
58
+ STDERR.puts 'Portlet by name "%s" could not be found -- try "caterpillar db:migrate"' % name
59
+ logger.debug $!.message
60
+ return nil
61
+ end
33
62
  end
34
63
 
35
64
  end
@@ -24,7 +24,7 @@
24
24
  padding: 10px 0 0 50px;
25
25
  min-height: 55px;
26
26
  overflow: auto;
27
-
27
+
28
28
  filter:alpha(opacity=81);-moz-opacity:.81;opacity:.81;
29
29
  /* css3 tags, works on Firefox and Safari */
30
30
  -moz-border-radius: 15px;
@@ -36,6 +36,11 @@
36
36
  list-style-type: none;
37
37
  }
38
38
 
39
+ #caterpillar_categories {
40
+ width: 99%;
41
+ overflow: auto;
42
+ }
43
+
39
44
  .cp_category {
40
45
  float: left;
41
46
  border: 3px double blue;
@@ -102,12 +107,17 @@
102
107
  <% begin -%>
103
108
  <%# check required variables -%>
104
109
  <% portlet[:vars].each do |var|
105
- raise if params[var].nil?
110
+ #puts params.inspect
111
+ raise if params[var].nil?
106
112
  end -%>
107
113
 
108
- <li><%= link_to( portlet[:title], portlet[:reqs] ) -%></li>
114
+ <li>
115
+ <%= link_to( portlet[:title], self.send('%s_url' % portlet[:name]) ) %>
116
+ <%#= link_to( portlet[:title], portlet[:reqs] ) -%>
117
+ </li>
109
118
 
110
119
  <% rescue
120
+ logger.error $!.message
111
121
  vars = {}
112
122
  undef_vars = []
113
123
  portlet[:vars].each do |var|
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.8
4
+ version: 0.9.15
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-24 00:00:00 +02:00
12
+ date: 2009-03-22 00:00:00 +02:00
13
13
  default_executable: caterpillar
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -20,7 +20,7 @@ dependencies:
20
20
  requirements:
21
21
  - - ">="
22
22
  - !ruby/object:Gem::Version
23
- version: 1.0.9
23
+ version: 1.0.17
24
24
  version:
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: rake
@@ -40,14 +40,16 @@ extensions: []
40
40
 
41
41
  extra_rdoc_files:
42
42
  - README
43
- - LICENSES.txt
43
+ - MIT-LICENSE
44
+ - ChangeLog
44
45
  files:
45
46
  - Rakefile
46
- - ChangeLog
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/rails-portlet-0.6.2.jar
51
53
  - lib/java/rails-portlet-0.6.1.jar
52
54
  - lib/caterpillar
53
55
  - lib/caterpillar/config.rb
@@ -62,8 +64,6 @@ files:
62
64
  - lib/caterpillar/task.rb
63
65
  - lib/caterpillar.rb
64
66
  - lib/web
65
- - lib/web/portlet_name.rb
66
- - lib/web/portlet_preferences.rb
67
67
  - lib/web/portlet.rb
68
68
  - generators/caterpillar
69
69
  - generators/caterpillar/templates
@@ -75,12 +75,11 @@ files:
75
75
  - generators/caterpillar/caterpillar_generator.rb
76
76
  - generators/caterpillar/USAGE
77
77
  - db/migrate
78
- - db/migrate/20081205000001_portlet_names.rb
79
- - db/migrate/20081205000002_lportal_sequences.rb
80
78
  - views/caterpillar
81
79
  - views/caterpillar/_navigation.html.erb
82
80
  - README
83
- - LICENSES.txt
81
+ - MIT-LICENSE
82
+ - ChangeLog
84
83
  has_rdoc: true
85
84
  homepage: http://rails-portlet.rubyforge.org
86
85
  post_install_message:
@@ -1,17 +0,0 @@
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
@@ -1,65 +0,0 @@
1
- require 'lportal'
2
-
3
- class LportalSequences < ActiveRecord::Migration
4
- @@tables = [
5
- Account,
6
- Address,
7
- Announcement::Delivery,
8
- Announcement::Entry,
9
- Contact,
10
- Group,
11
- Permission,
12
- Phone,
13
- ResourceCode,
14
- Resource,
15
- Role,
16
- User,
17
- MB::Category,
18
- MB::Discussion,
19
- MB::Message,
20
- MB::MessageFlag,
21
- MB::StatsUser,
22
- MB::Thread,
23
- RatingsStats,
24
- SocialActivity,
25
- SocialRelation,
26
- Tag::Asset,
27
- Tag::Entry,
28
- Tag::Property,
29
- Web::Layout,
30
- Web::LayoutSet,
31
- Web::PortletPreferences,
32
- Web::Portlet
33
- ]
34
-
35
- def self.up
36
- STDOUT.puts 'This migration does not do anything.'
37
- STDOUT.puts 'The process is not refined properly yet, and could be quite disastrous if reverted unappropriately.'
38
- STDOUT.puts 'If you are sure you need the sequences, copy this file to db/migrate and modify it.'
39
- STDOUT.puts __FILE__
40
-
41
- start = 8400000 # bigint = 8^8 bytes = 16 million bits, this is halfway up the possible range, rounded up
42
- sql = ""
43
- @@tables.each do |model|
44
- table = model.table_name
45
- primkey = model.primary_key
46
- seq = table+'_'+primkey+'_seq'
47
- sql += "CREATE SEQUENCE #{seq} START #{start}; ALTER TABLE #{table} ALTER #{primkey} SET default nextval('#{seq}');"
48
- end
49
-
50
- # To activate, uncomment this line.
51
- #ActiveRecord::Base.connection.execute(sql)
52
- end
53
-
54
- # This is VERY DANGEROUS and may lead to breakage.
55
- def self.down
56
- # sql = ""
57
- # @@tables.each do |model|
58
- # table = model.table_name
59
- # primkey = model.primary_key
60
- # seq = table+'_'+primkey+'_seq'
61
- # sql += "ALTER TABLE #{table} ALTER #{primkey} DROP default; DROP SEQUENCE #{seq};"
62
- # end
63
- # ActiveRecord::Base.connection.execute(sql)
64
- end
65
- end
@@ -1,8 +0,0 @@
1
- require 'active_record'
2
-
3
- module Web # :nodoc:
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 :portlet_names
7
- end
8
- end
@@ -1,10 +0,0 @@
1
- require 'active_record'
2
-
3
- module Web
4
- class PortletPreferences < ActiveRecord::Base
5
- def title
6
- p = Web::PortletName.find_by_portletid(self.name)
7
- p ? p.title : nil
8
- end
9
- end
10
- end