liferay_content 0.1.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.
@@ -0,0 +1,4 @@
1
+ *.gem
2
+ .bundle
3
+ Gemfile.lock
4
+ pkg/*
data/Gemfile ADDED
@@ -0,0 +1,5 @@
1
+ source "http://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in liferay_content.gemspec
4
+ gemspec
5
+ gem 'hpricot'
@@ -0,0 +1,38 @@
1
+ == LiferayContent
2
+
3
+ LiferayContent is a gem library providing access to content hosted on Liferay portal (http://www.liferay.com). It works through the Liferay web service (JSON version). So far, only Article can be retrieved.
4
+
5
+ == Installation
6
+
7
+ Add it to your Gemfile:
8
+
9
+ gem "liferay_content"
10
+
11
+ Configure your Rails (or Ruby) application to use the related Liferay server. For example, in Rails, create a liferay_content.rb file inside the initializers folder and place inside this file the configuration:
12
+
13
+ LiferayContent.setup do |config|
14
+ config.host = "www.your-liferay-host.com"
15
+ config.port = 80
16
+ config.uri = "/tunnel-web/secure/json"
17
+ config.group_id = 112345
18
+ config.login = "fc@youcompany.com"
19
+ config.password = "abcde"
20
+ end
21
+
22
+ == Usage
23
+
24
+ === Controller
25
+
26
+ Retrieve the article content from a controller:
27
+
28
+ @content = LiferayContent::Article.get(39860).html_safe
29
+
30
+ === View
31
+
32
+ Display the content in a view:
33
+
34
+ <%= @content %>
35
+
36
+
37
+
38
+
@@ -0,0 +1,2 @@
1
+ require 'bundler'
2
+ Bundler::GemHelper.install_tasks
@@ -0,0 +1,31 @@
1
+ require 'net/http'
2
+ require 'rexml/document'
3
+ require 'liferay_content/article'
4
+
5
+ module LiferayContent
6
+
7
+ # Liferay hostname or IP address (without HTTP)
8
+ mattr_accessor :host
9
+ @@host = nil
10
+
11
+ mattr_accessor :port
12
+ @@port = 80
13
+
14
+ mattr_accessor :uri
15
+ @@uri = "/tunnel-web/secure/json"
16
+
17
+ mattr_accessor :group_id
18
+ @@group_id = nil
19
+
20
+ mattr_accessor :login
21
+ @@login = ""
22
+
23
+ mattr_accessor :password
24
+ @@password = ""
25
+
26
+ def self.setup
27
+ yield self
28
+ end
29
+
30
+ end
31
+
@@ -0,0 +1,35 @@
1
+ module LiferayContent
2
+
3
+ class Article
4
+
5
+ def self.get2(s)
6
+ "titi"
7
+ end
8
+
9
+ def self.get(article_id)
10
+
11
+ @params = {
12
+ "serviceClassName" => "com.liferay.portlet.journal.service.JournalArticleServiceUtil",
13
+ "serviceMethodName" => "getArticle",
14
+ "serviceParameters" => "[groupId,articleId]",
15
+ "groupId" => LiferayContent.group_id,
16
+ "articleId" => article_id
17
+ }
18
+
19
+ req = Net::HTTP::Post.new(LiferayContent.uri, initheader = {'Content-Type' =>'application/json'})
20
+ req.basic_auth LiferayContent.login, LiferayContent.password
21
+ req.set_form_data @params
22
+
23
+ response = Net::HTTP.new(LiferayContent.host, LiferayContent.port).start {|http| http.request(req) }
24
+
25
+ result = JSON.parse response.body
26
+
27
+ doc = Hpricot.XML(result["content"])
28
+ result = (doc/"static-content").first.inner_text
29
+
30
+ return result
31
+ end
32
+
33
+ end
34
+
35
+ end
@@ -0,0 +1,3 @@
1
+ module LiferayContent
2
+ VERSION = "0.1.0"
3
+ end
@@ -0,0 +1,22 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+ require "liferay_content/version"
4
+
5
+ Gem::Specification.new do |s|
6
+ s.name = "liferay_content"
7
+ s.version = LiferayContent::VERSION
8
+ s.platform = Gem::Platform::RUBY
9
+ s.authors = ["Fabrice Clari"]
10
+ s.email = ["fabrice@nooblee.fr"]
11
+ s.homepage = "https://github.com/clarif/liferay_content"
12
+ s.summary = %q{liferay_content provides access in Ruby to Liferay contents}
13
+ s.description = %q{}
14
+
15
+ s.rubyforge_project = "liferay_content"
16
+
17
+ s.files = `git ls-files`.split("\n")
18
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
19
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
20
+ s.require_paths = ["lib"]
21
+ s.add_development_dependency "rspec", "~> 2.0.0.beta.22"
22
+ end
@@ -0,0 +1,8 @@
1
+ require 'liferay_content/article'
2
+
3
+ describe LiferayContent::Article do
4
+ it "stupid test" do
5
+ #LiferayContent::Article.get2("toto").should eql("titi")
6
+ end
7
+ end
8
+
metadata ADDED
@@ -0,0 +1,75 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: liferay_content
3
+ version: !ruby/object:Gem::Version
4
+ prerelease:
5
+ version: 0.1.0
6
+ platform: ruby
7
+ authors:
8
+ - Fabrice Clari
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+
13
+ date: 2011-06-16 00:00:00 +02:00
14
+ default_executable:
15
+ dependencies:
16
+ - !ruby/object:Gem::Dependency
17
+ name: rspec
18
+ prerelease: false
19
+ requirement: &id001 !ruby/object:Gem::Requirement
20
+ none: false
21
+ requirements:
22
+ - - ~>
23
+ - !ruby/object:Gem::Version
24
+ version: 2.0.0.beta.22
25
+ type: :development
26
+ version_requirements: *id001
27
+ description: ""
28
+ email:
29
+ - fabrice@nooblee.fr
30
+ executables: []
31
+
32
+ extensions: []
33
+
34
+ extra_rdoc_files: []
35
+
36
+ files:
37
+ - .gitignore
38
+ - Gemfile
39
+ - README.rdoc
40
+ - Rakefile
41
+ - lib/liferay_content.rb
42
+ - lib/liferay_content/article.rb
43
+ - lib/liferay_content/version.rb
44
+ - liferay_content.gemspec
45
+ - spec/article_spec.rb
46
+ has_rdoc: true
47
+ homepage: https://github.com/clarif/liferay_content
48
+ licenses: []
49
+
50
+ post_install_message:
51
+ rdoc_options: []
52
+
53
+ require_paths:
54
+ - lib
55
+ required_ruby_version: !ruby/object:Gem::Requirement
56
+ none: false
57
+ requirements:
58
+ - - ">="
59
+ - !ruby/object:Gem::Version
60
+ version: "0"
61
+ required_rubygems_version: !ruby/object:Gem::Requirement
62
+ none: false
63
+ requirements:
64
+ - - ">="
65
+ - !ruby/object:Gem::Version
66
+ version: "0"
67
+ requirements: []
68
+
69
+ rubyforge_project: liferay_content
70
+ rubygems_version: 1.6.2
71
+ signing_key:
72
+ specification_version: 3
73
+ summary: liferay_content provides access in Ruby to Liferay contents
74
+ test_files:
75
+ - spec/article_spec.rb