etherpad-lite 0.0.3 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG CHANGED
@@ -1,3 +1,7 @@
1
+ ** RELEASE 0.0.4 (09/12/2011) **
2
+
3
+ * Bugfix to Pads. A Pad initialied with a specific revision was not returning that revision's text.
4
+
1
5
  ** RELEASE 0.0.3 (09/06/2011) **
2
6
 
3
7
  * Added Instance#get_session
@@ -32,16 +32,61 @@ See https://github.com/Pita/etherpad-lite for information on how to install and
32
32
  puts pad_rev.text
33
33
  end
34
34
 
35
- For advanced functionality (i.e. Groups, Authors, Sessions), read the full docs at http://jordanhollinger.com/docs/ruby-etherpad-lite/. Also, the RSpec tests under /spec may provide some pointers.
35
+ Read the full docs at http://jordanhollinger.com/docs/ruby-etherpad-lite/.
36
36
 
37
- == 3 Why is the Ruby client so different from the others? What gives you the right?!?
38
- The PHP and Python clients are extremely thin wrappers around the HTTP API; their method names map directly to urls. The Ruby client offers a slightly higher level of abstration,
39
- with the goal of making Etherpad Lite integration in Ruby projects as simple, poweful, and dare I say fun, as possible.
37
+ == 3 Example use in Rails
38
+ For your view, I recommend the jQuery plugin at https://github.com/johnyma22/etherpad-lite-jquery-plugin.
39
+
40
+ Add the following to your Gemfile
41
+ gem 'etherpad-lite'
42
+
43
+ On login, create a Hash in your session to store EtherpadLite API sessions:
44
+ session[:ep_sessions] = {}
45
+
46
+ Some example controller actions:
47
+
48
+ class EtherpadController < ApplicationController
49
+ def index
50
+ # The idea is that your users are probably members of some kind of groups.
51
+ # These groups can be mapped to EtherpadLite Groups. List all the user's groups.
52
+ @app_groups = current_user.groups
53
+ end
40
54
 
41
- That said, there is certainly value in supporting the defacto standard set by the PHP and Python clients. With that in mind, the Ruby client is written in two layers,
42
- one conforming to the other clients, and a higher-level "models" API riding on top of it.
55
+ def group
56
+ ether = EtherpadLite.connect(:local, 'api key')
57
+ @app_group = YourAppGroup.find(params[:id])
58
+ # Map your app's group to an EtherpadLite Group
59
+ group = ether.group("my_app_group_#{@app_group.id}")
60
+ # List all the pads in group
61
+ @pads = group.pads
62
+ end
63
+
64
+ def pad
65
+ ether = EtherpadLite.connect(:local, 'api key')
66
+ # Get the EtherpadLite Group by id
67
+ @group = ether.get_group(params[:group_id])
68
+ # Get the pad
69
+ @pad = @group.pad(params[:pad_name])
70
+ # Map the user to an EtherpadLite Author
71
+ author = ether.author("my_app_user_#{current_user.id}", :name => current_user.name)
72
+ # Get or create an hour-long session for this Author in this Group
73
+ sess = session[:ep_sessions][@group.id] ? ether.get_session(session[:ep_sessions][@group.id]) : @group.create_session(author, 60)
74
+ if sess.expired?
75
+ sess.delete
76
+ sess = @group.create_session(author, 60)
77
+ end
78
+ session[:ep_sessions][@group.id] = sess.id
79
+ # Set the EtherpadLite session cookie. This will automatically be picked up by the jQuery plugin's iframe.
80
+ cookies[:sessionID] = {:value => sess.id, :domain => ".yourdomain.com"}
81
+ end
82
+ end
43
83
 
44
- In the examples above, the "traditional" client can be accessed with
84
+ == 4 Why is the Ruby client so different from the others? What gives you the right?!?
85
+ The PHP and Python clients are extremely thin wrappers around the HTTP API; their method names map directly to urls. The Ruby client offers a slightly higher level of abstration,
86
+ with the goal of making Etherpad Lite integration in Ruby projects as simple, poweful, and dare I say fun, as possible. That said, there is nothing wrong with the thinly-wrapped API.
87
+ So in the interests of being a good citizen, the Ruby client is written in two layers, one conforming to the other clients, and a higher-level "models" API riding on top of it.
88
+
89
+ In the examples above, the "standard" client can be accessed with
45
90
  client = ether.client
46
91
  client.getText('my first etherpad lite pad')
47
92
  => {:text => "What hath God wrought?"}
@@ -50,8 +95,9 @@ Or you can explicitly load only the standard client
50
95
  require 'etherpad-lite/client'
51
96
  client = EtherpadLite::Client.new('api key', 'http://beta.etherpad.org/api')
52
97
 
53
- == 4 License
98
+ == 5 License
54
99
  Copyright 2011 Jordan Hollinger
100
+
55
101
  Licensed under the Apache License
56
102
 
57
103
  == 5 Credit
@@ -67,6 +67,7 @@ module EtherpadLite
67
67
  #
68
68
  # rev => revision_number
69
69
  def text(options={})
70
+ options[:rev] ||= @rev unless @rev.nil?
70
71
  @instance.client.getText(@id, options[:rev])[:text]
71
72
  end
72
73
 
@@ -69,9 +69,12 @@ describe EtherpadLite::Pad do
69
69
  pad.name.should == pad.id
70
70
  end
71
71
 
72
- it "should be initialized as revision 1" do
73
- pad = @eth.get_pad 'another new pad', :rev => 1
74
- pad.text.should == "The initial text\n"
72
+ it "should be initialized as revision 0" do
73
+ pad = @eth.pad 'brand new pad', :text => 'Brand new text'
74
+ pad.text = 'Even newer text'
75
+ pad.text = 'Even even newer text'
76
+ pad = @eth.get_pad 'brand new pad', :rev => 0
77
+ pad.text.should == "Brand new text\n"
75
78
  end
76
79
 
77
80
  it "should be deleted" do
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 0
8
- - 3
9
- version: 0.0.3
8
+ - 4
9
+ version: 0.0.4
10
10
  platform: ruby
11
11
  authors:
12
12
  - Jordan Hollinger
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2011-09-06 00:00:00 -04:00
17
+ date: 2011-09-12 00:00:00 -04:00
18
18
  default_executable:
19
19
  dependencies: []
20
20