njacobeus-tokboxer 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +19 -0
- data/Manifest.txt +24 -0
- data/PostInstall.txt +7 -0
- data/README.rdoc +109 -0
- data/Rakefile +28 -0
- data/config/website.yml.sample +2 -0
- data/lib/TokBoxer.rb +28 -0
- data/lib/TokBoxer/Api.rb +290 -0
- data/lib/TokBoxer/Call.rb +42 -0
- data/lib/TokBoxer/User.rb +137 -0
- data/lib/TokBoxer/VMail.rb +17 -0
- data/script/console +10 -0
- data/script/destroy +14 -0
- data/script/generate +14 -0
- data/script/txt2html +71 -0
- data/spec/TokBoxer_spec.rb +11 -0
- data/spec/spec.opts +1 -0
- data/spec/spec_helper.rb +10 -0
- data/tasks/rspec.rake +21 -0
- data/website/index.html +84 -0
- data/website/index.txt +81 -0
- data/website/javascripts/rounded_corners_lite.inc.js +285 -0
- data/website/stylesheets/screen.css +159 -0
- data/website/template.html.erb +50 -0
- metadata +108 -0
@@ -0,0 +1,42 @@
|
|
1
|
+
module TokBoxer
|
2
|
+
|
3
|
+
class Call
|
4
|
+
|
5
|
+
attr_reader :callerName, :callId, :callerJabberId, :persistent, :server
|
6
|
+
alias :id :callId
|
7
|
+
|
8
|
+
def initialize(callerName, callId, callerJabberId, persistent, server, api)
|
9
|
+
@callerName = callerName
|
10
|
+
@callId = callId
|
11
|
+
@callerJabberId = callerJabberId
|
12
|
+
@persistent = persistent
|
13
|
+
@server = server
|
14
|
+
@api = api
|
15
|
+
end
|
16
|
+
|
17
|
+
def embed_code(width="322", height="321")
|
18
|
+
<<-END
|
19
|
+
<object width="#{width}" height="#{height}">
|
20
|
+
<param name="movie" value="#{@api.api_server_url}#{API_SERVER_CALL_WIDGET}#{id}" />
|
21
|
+
<param name="allowFullScreen" value="true" />
|
22
|
+
<param name="allowScriptAccess" value="true" />
|
23
|
+
<param name="flashVars" value="textChat=true&guestList=false&inviteButton=false" />
|
24
|
+
<embed src="#{@api.api_server_url}#{API_SERVER_CALL_WIDGET}#{id}"
|
25
|
+
type="application/x-shockwave-flash"
|
26
|
+
allowfullscreen="true"
|
27
|
+
allowScriptAccess="always"
|
28
|
+
width="#{width}"
|
29
|
+
height="#{height}"
|
30
|
+
flashvars="textChat=true&guestList=false&inviteButton=false" >
|
31
|
+
</embed>
|
32
|
+
</object>
|
33
|
+
END
|
34
|
+
end
|
35
|
+
|
36
|
+
def to_s
|
37
|
+
id
|
38
|
+
end
|
39
|
+
|
40
|
+
end
|
41
|
+
|
42
|
+
end
|
@@ -0,0 +1,137 @@
|
|
1
|
+
module TokBoxer
|
2
|
+
|
3
|
+
class User
|
4
|
+
|
5
|
+
attr_reader :jabberId, :secret
|
6
|
+
alias :id :jabberId
|
7
|
+
|
8
|
+
def initialize(jabberId, secret, api)
|
9
|
+
@jabberId = jabberId
|
10
|
+
@secret = secret
|
11
|
+
@api = api
|
12
|
+
self.login
|
13
|
+
end
|
14
|
+
|
15
|
+
# TODO add a method which calls get_request_token from the API
|
16
|
+
# to get the jabberId and secret from the email and password
|
17
|
+
|
18
|
+
def login
|
19
|
+
@api.login_user(self.jabberId,self.secret)
|
20
|
+
end
|
21
|
+
|
22
|
+
def create_call(full_name,persistent=false)
|
23
|
+
result = @api.create_call(@jabberId, full_name, persistent)
|
24
|
+
if result['createCall'] and (createCall=result['createCall'].first)
|
25
|
+
Call.new createCall['callerName'],
|
26
|
+
createCall['callId'].first,
|
27
|
+
createCall['callerJabberId'],
|
28
|
+
createCall['persistent'],
|
29
|
+
createCall['server'].first,
|
30
|
+
@api
|
31
|
+
else
|
32
|
+
nil
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
def access_token_valid?
|
37
|
+
result = @api.validate_access_token(@jabberId, @secret)
|
38
|
+
result['validateAccessToken'].first["isValid"].first == "true"
|
39
|
+
end
|
40
|
+
|
41
|
+
# Feeds ============================================================================================
|
42
|
+
|
43
|
+
def vmails
|
44
|
+
@api.get_feed(@jabberId,"all")["feed"].first["item"].map do |m|
|
45
|
+
VMail.new m["videoMail"].first["content"]["messageId"].first
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
def sent_vmails
|
50
|
+
@api.get_feed(@jabberId,"vmailSent")["feed"].first["item"].map do |m|
|
51
|
+
VMail.new m["videoMail"].first["content"]["messageId"].first
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
def received_vmails
|
56
|
+
@api.get_feed(@jabberId,"vmailRecv")["feed"].first["item"].map do |m|
|
57
|
+
VMail.new m["videoMail"].first["content"]["messageId"].first
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
def recorder_embed_code(width="322", height="321",vmailToEmail="")
|
62
|
+
# TODO: this comes from the PHP api. Not yet implemented here
|
63
|
+
# if($isGuest) {
|
64
|
+
# $apiObj = new TokBoxApi(API_Config::PARTNER_KEY, API_Config::PARTNER_SECRET);
|
65
|
+
# $apiObj->updateToken($apiObj->getRequestToken(API_Config::CALLBACK_URL));
|
66
|
+
#
|
67
|
+
# $htmlCode .= "<script language=\"javascript\" src=\"SDK/js/TokBoxScript.js\"></script>\n";
|
68
|
+
# $htmlCode .= "<body onclick=\"setToken('".$apiObj->getAuthToken()."');\">\n";
|
69
|
+
# }
|
70
|
+
<<-END
|
71
|
+
<object width="#{width}" height="#{height}">
|
72
|
+
<param name="movie" value="#{@api.api_server_url}#{API_SERVER_RECORDER_WIDGET}"></param>
|
73
|
+
<param name="allowFullScreen" value="true"></param>
|
74
|
+
<param name="allowScriptAccess" value="true"></param>
|
75
|
+
<param name="FlashVars" value="tokboxPartnerKey=#{@api.api_key}&tokboxJid=#{jabberId}&tokboxAccessSecret=#{secret}&offsiteAuth=true&vmailToEmail=#{vmailToEmail}"></param>
|
76
|
+
<embed id="tbx_recorder" src="#{@api.api_server_url}#{API_SERVER_RECORDER_WIDGET}"
|
77
|
+
type="application/x-shockwave-flash"
|
78
|
+
allowfullscreen="true"
|
79
|
+
allowScriptAccess="always"
|
80
|
+
width="#{width}"
|
81
|
+
height="#{height}"
|
82
|
+
FlashVars="tokboxPartnerKey=#{@api.api_key}&tokboxJid=#{jabberId}&tokboxAccessSecret=#{secret}&offsiteAuth=true&vmailToEmail=#{vmailToEmail}"
|
83
|
+
>
|
84
|
+
</embed>
|
85
|
+
</object>
|
86
|
+
END
|
87
|
+
end
|
88
|
+
|
89
|
+
def player_embed_code(messageId, width="425", height="344")
|
90
|
+
<<-END
|
91
|
+
<object width="#{width}" height="#{height}">
|
92
|
+
|
93
|
+
<param name="movie" value="#{@api.api_server_url}#{API_SERVER_PLAYER_WIDGET}"></param>
|
94
|
+
<param name="allowFullScreen" value="true"></param>
|
95
|
+
<param name="allowScriptAccess" value="true"></param>
|
96
|
+
<embed id="tbx_player" src="#{@api.api_server_url}#{API_SERVER_PLAYER_WIDGET}"
|
97
|
+
type="application/x-shockwave-flash"
|
98
|
+
allowfullscreen="true"
|
99
|
+
allowScriptAccess="always"
|
100
|
+
flashvars="targetVmail=#{messageId}"
|
101
|
+
width="#{width}"
|
102
|
+
height="#{height}"
|
103
|
+
>
|
104
|
+
</embed>
|
105
|
+
</object>
|
106
|
+
END
|
107
|
+
end
|
108
|
+
|
109
|
+
def is_online?
|
110
|
+
info["isOnline"].first == "true"
|
111
|
+
end
|
112
|
+
|
113
|
+
def display_name
|
114
|
+
info["displayName"].first
|
115
|
+
end
|
116
|
+
|
117
|
+
def username
|
118
|
+
info["username"].first
|
119
|
+
end
|
120
|
+
|
121
|
+
def userid
|
122
|
+
info["userid"].first
|
123
|
+
end
|
124
|
+
|
125
|
+
def show
|
126
|
+
info["show"].first
|
127
|
+
end
|
128
|
+
|
129
|
+
protected
|
130
|
+
|
131
|
+
def info
|
132
|
+
@info ||= @api.get_user_profile(self.jabberId)["getUserProfile"].first
|
133
|
+
end
|
134
|
+
|
135
|
+
end
|
136
|
+
|
137
|
+
end
|
data/script/console
ADDED
@@ -0,0 +1,10 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# File: script/console
|
3
|
+
irb = RUBY_PLATFORM =~ /(:?mswin|mingw)/ ? 'irb.bat' : 'irb'
|
4
|
+
|
5
|
+
libs = " -r irb/completion"
|
6
|
+
# Perhaps use a console_lib to store any extra methods I may want available in the cosole
|
7
|
+
# libs << " -r #{File.dirname(__FILE__) + '/../lib/console_lib/console_logger.rb'}"
|
8
|
+
libs << " -r #{File.dirname(__FILE__) + '/../lib/TokBoxer.rb'}"
|
9
|
+
puts "Loading TokBoxer gem"
|
10
|
+
exec "#{irb} #{libs} --simple-prompt"
|
data/script/destroy
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
APP_ROOT = File.expand_path(File.join(File.dirname(__FILE__), '..'))
|
3
|
+
|
4
|
+
begin
|
5
|
+
require 'rubigen'
|
6
|
+
rescue LoadError
|
7
|
+
require 'rubygems'
|
8
|
+
require 'rubigen'
|
9
|
+
end
|
10
|
+
require 'rubigen/scripts/destroy'
|
11
|
+
|
12
|
+
ARGV.shift if ['--help', '-h'].include?(ARGV[0])
|
13
|
+
RubiGen::Base.use_component_sources! [:rubygems, :newgem, :newgem_theme, :test_unit]
|
14
|
+
RubiGen::Scripts::Destroy.new.run(ARGV)
|
data/script/generate
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
APP_ROOT = File.expand_path(File.join(File.dirname(__FILE__), '..'))
|
3
|
+
|
4
|
+
begin
|
5
|
+
require 'rubigen'
|
6
|
+
rescue LoadError
|
7
|
+
require 'rubygems'
|
8
|
+
require 'rubigen'
|
9
|
+
end
|
10
|
+
require 'rubigen/scripts/generate'
|
11
|
+
|
12
|
+
ARGV.shift if ['--help', '-h'].include?(ARGV[0])
|
13
|
+
RubiGen::Base.use_component_sources! [:rubygems, :newgem, :newgem_theme, :test_unit]
|
14
|
+
RubiGen::Scripts::Generate.new.run(ARGV)
|
data/script/txt2html
ADDED
@@ -0,0 +1,71 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
load File.dirname(__FILE__) + "/../Rakefile"
|
4
|
+
require 'rubyforge'
|
5
|
+
require 'redcloth'
|
6
|
+
require 'syntax/convertors/html'
|
7
|
+
require 'erb'
|
8
|
+
|
9
|
+
download = "http://rubyforge.org/projects/#{$hoe.rubyforge_name}"
|
10
|
+
version = $hoe.version
|
11
|
+
|
12
|
+
def rubyforge_project_id
|
13
|
+
RubyForge.new.configure.autoconfig["group_ids"][$hoe.rubyforge_name]
|
14
|
+
end
|
15
|
+
|
16
|
+
class Fixnum
|
17
|
+
def ordinal
|
18
|
+
# teens
|
19
|
+
return 'th' if (10..19).include?(self % 100)
|
20
|
+
# others
|
21
|
+
case self % 10
|
22
|
+
when 1: return 'st'
|
23
|
+
when 2: return 'nd'
|
24
|
+
when 3: return 'rd'
|
25
|
+
else return 'th'
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
class Time
|
31
|
+
def pretty
|
32
|
+
return "#{mday}#{mday.ordinal} #{strftime('%B')} #{year}"
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
def convert_syntax(syntax, source)
|
37
|
+
return Syntax::Convertors::HTML.for_syntax(syntax).convert(source).gsub(%r!^<pre>|</pre>$!,'')
|
38
|
+
end
|
39
|
+
|
40
|
+
if ARGV.length >= 1
|
41
|
+
src, template = ARGV
|
42
|
+
template ||= File.join(File.dirname(__FILE__), '/../website/template.html.erb')
|
43
|
+
else
|
44
|
+
puts("Usage: #{File.split($0).last} source.txt [template.html.erb] > output.html")
|
45
|
+
exit!
|
46
|
+
end
|
47
|
+
|
48
|
+
template = ERB.new(File.open(template).read)
|
49
|
+
|
50
|
+
title = nil
|
51
|
+
body = nil
|
52
|
+
File.open(src) do |fsrc|
|
53
|
+
title_text = fsrc.readline
|
54
|
+
body_text_template = fsrc.read
|
55
|
+
body_text = ERB.new(body_text_template).result(binding)
|
56
|
+
syntax_items = []
|
57
|
+
body_text.gsub!(%r!<(pre|code)[^>]*?syntax=['"]([^'"]+)[^>]*>(.*?)</\1>!m){
|
58
|
+
ident = syntax_items.length
|
59
|
+
element, syntax, source = $1, $2, $3
|
60
|
+
syntax_items << "<#{element} class='syntax'>#{convert_syntax(syntax, source)}</#{element}>"
|
61
|
+
"syntax-temp-#{ident}"
|
62
|
+
}
|
63
|
+
title = RedCloth.new(title_text).to_html.gsub(%r!<.*?>!,'').strip
|
64
|
+
body = RedCloth.new(body_text).to_html
|
65
|
+
body.gsub!(%r!(?:<pre><code>)?syntax-temp-(\d+)(?:</code></pre>)?!){ syntax_items[$1.to_i] }
|
66
|
+
end
|
67
|
+
stat = File.stat(src)
|
68
|
+
created = stat.ctime
|
69
|
+
modified = stat.mtime
|
70
|
+
|
71
|
+
$stdout << template.result(binding)
|
data/spec/spec.opts
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
--colour
|
data/spec/spec_helper.rb
ADDED
data/tasks/rspec.rake
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
begin
|
2
|
+
require 'spec'
|
3
|
+
rescue LoadError
|
4
|
+
require 'rubygems'
|
5
|
+
require 'spec'
|
6
|
+
end
|
7
|
+
begin
|
8
|
+
require 'spec/rake/spectask'
|
9
|
+
rescue LoadError
|
10
|
+
puts <<-EOS
|
11
|
+
To use rspec for testing you must install rspec gem:
|
12
|
+
gem install rspec
|
13
|
+
EOS
|
14
|
+
exit(0)
|
15
|
+
end
|
16
|
+
|
17
|
+
desc "Run the specs under spec/models"
|
18
|
+
Spec::Rake::SpecTask.new do |t|
|
19
|
+
t.spec_opts = ['--options', "spec/spec.opts"]
|
20
|
+
t.spec_files = FileList['spec/**/*_spec.rb']
|
21
|
+
end
|
data/website/index.html
ADDED
@@ -0,0 +1,84 @@
|
|
1
|
+
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
|
2
|
+
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
3
|
+
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
4
|
+
<head>
|
5
|
+
<link rel="stylesheet" href="stylesheets/screen.css" type="text/css" media="screen" />
|
6
|
+
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
7
|
+
<title>
|
8
|
+
TokBoxer
|
9
|
+
</title>
|
10
|
+
<script src="javascripts/rounded_corners_lite.inc.js" type="text/javascript"></script>
|
11
|
+
<style>
|
12
|
+
|
13
|
+
</style>
|
14
|
+
<script type="text/javascript">
|
15
|
+
window.onload = function() {
|
16
|
+
settings = {
|
17
|
+
tl: { radius: 10 },
|
18
|
+
tr: { radius: 10 },
|
19
|
+
bl: { radius: 10 },
|
20
|
+
br: { radius: 10 },
|
21
|
+
antiAlias: true,
|
22
|
+
autoPad: true,
|
23
|
+
validTags: ["div"]
|
24
|
+
}
|
25
|
+
var versionBox = new curvyCorners(settings, document.getElementById("version"));
|
26
|
+
versionBox.applyCornersToAll();
|
27
|
+
}
|
28
|
+
</script>
|
29
|
+
</head>
|
30
|
+
<body>
|
31
|
+
<div id="main">
|
32
|
+
|
33
|
+
<h1>TokBoxer</h1>
|
34
|
+
<div class="sidebar">
|
35
|
+
<div id="version" class="clickable" onclick='document.location = "http://rubyforge.org/projects/tokboxer"; return false'>
|
36
|
+
<p>Get Version</p>
|
37
|
+
<a href="http://rubyforge.org/projects/tokboxer" class="numbers">0.1.0</a>
|
38
|
+
</div>
|
39
|
+
</div>
|
40
|
+
<h2>What</h2>
|
41
|
+
<h2>Installing</h2>
|
42
|
+
<p><pre class='syntax'><span class="ident">sudo</span> <span class="ident">gem</span> <span class="ident">install</span> <span class="constant">TokBoxer</span></pre></p>
|
43
|
+
<h2>The basics</h2>
|
44
|
+
<h2>Demonstration of usage</h2>
|
45
|
+
<h2>Forum</h2>
|
46
|
+
<p><a href="http://groups.google.com/group/TokBoxer">http://groups.google.com/group/TokBoxer</a></p>
|
47
|
+
<p><span class="caps">TODO</span> – create Google Group – TokBoxer</p>
|
48
|
+
<h2>How to submit patches</h2>
|
49
|
+
<p>Read the <a href="http://drnicwilliams.com/2007/06/01/8-steps-for-fixing-other-peoples-code/">8 steps for fixing other people’s code</a> and for section <a href="http://drnicwilliams.com/2007/06/01/8-steps-for-fixing-other-peoples-code/#8b-google-groups">8b: Submit patch to Google Groups</a>, use the Google Group above.</p>
|
50
|
+
<p><span class="caps">TODO</span> – pick <span class="caps">SVN</span> or Git instructions</p>
|
51
|
+
<p>The trunk repository is <code>svn://rubyforge.org/var/svn/TokBoxer/trunk</code> for anonymous access.</p>
|
52
|
+
<p><span class="caps">OOOORRRR</span></p>
|
53
|
+
<p>You can fetch the source from either:</p>
|
54
|
+
<ul>
|
55
|
+
<li>rubyforge: <a href="http://rubyforge.org/scm/?group_id=7264">http://rubyforge.org/scm/?group_id=7264</a></li>
|
56
|
+
</ul>
|
57
|
+
<pre>git clone git://rubyforge.org/TokBoxer.git</pre>
|
58
|
+
<ul>
|
59
|
+
<li>github: <a href="http://github.com/GITHUB_USERNAME/TokBoxer/tree/master">http://github.com/GITHUB_USERNAME/TokBoxer/tree/master</a></li>
|
60
|
+
</ul>
|
61
|
+
<pre>git clone git://github.com/GITHUB_USERNAME/TokBoxer.git</pre>
|
62
|
+
<p><span class="caps">TODO</span> – add “github_username: username” to ~/.rubyforge/user-config.yml and newgem will reuse it for future projects.</p>
|
63
|
+
<ul>
|
64
|
+
<li>gitorious: <a href="git://gitorious.org/TokBoxer/mainline.git">git://gitorious.org/TokBoxer/mainline.git</a></li>
|
65
|
+
</ul>
|
66
|
+
<pre>git clone git://gitorious.org/TokBoxer/mainline.git</pre>
|
67
|
+
<h3>Build and test instructions</h3>
|
68
|
+
<pre>cd TokBoxer
|
69
|
+
rake test
|
70
|
+
rake install_gem</pre>
|
71
|
+
<h2>License</h2>
|
72
|
+
<p>This code is free to use under the terms of the <span class="caps">MIT</span> license.</p>
|
73
|
+
<h2>Contact</h2>
|
74
|
+
<p>Comments are welcome. Send an email to <a href="mailto:nj@belighted.com">Nicolas Jacobeus</a> via the <a href="http://groups.google.com/group/TokBoxer">forum</a></p>
|
75
|
+
<p class="coda">
|
76
|
+
<a href="nj@belighted.com">Nicolas Jacobeus</a>, 3rd November 2008<br>
|
77
|
+
Theme extended from <a href="http://rb2js.rubyforge.org/">Paul Battley</a>
|
78
|
+
</p>
|
79
|
+
</div>
|
80
|
+
|
81
|
+
<!-- insert site tracking codes here, like Google Urchin -->
|
82
|
+
|
83
|
+
</body>
|
84
|
+
</html>
|