planga 0.6.0 → 0.7.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (6) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +11 -0
  3. data/README.md +1 -0
  4. data/Rakefile +10 -0
  5. data/lib/planga.rb +31 -11
  6. metadata +3 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 763322693d99d01a54ad37f478207dec7c365ecd
4
- data.tar.gz: 7ed0e2f0b23e28c375d787d520efb7400426f180
3
+ metadata.gz: 68843a6c20aaf8415a10390b88987799404e1c0e
4
+ data.tar.gz: a964786e73ed3a07c6d967312ab81811725b4a32
5
5
  SHA512:
6
- metadata.gz: 326d4f47b3f0615deed9cb74ea269ec83652c28216a61a51e8b1e05ce86391978eb49d133213b8660507fdf3d67427eba7127636fe9f82ba7f0a775e6007bd01
7
- data.tar.gz: 9308434ab433890f5bc2800da817c49e45f08af14674c5054346e6f72d917b0ae8dfff704bdba47fc80f9d968b62fa45b929e84d7272da3f74ec3a247caef053
6
+ metadata.gz: 67b3eb434542646d4423a9fbd43e977230f2b869be0780796a9147da1b8d749fd5c7ea564959acb980cda1c5a15d1815481a59c4de0ceb9082d1fedb9260296b
7
+ data.tar.gz: c4d8a1a428ed6f4de4b18fe6b9ec03a07674d1ec2f2bed7e7fe69cbe18b6cbef438232cf78d54cc918581aa1fea045abd68bc4b6aa5f140dab7503933165aaf5
data/Gemfile ADDED
@@ -0,0 +1,11 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gemspec
4
+
5
+ group :test do
6
+ gem 'rspec', '~> 3.8', require: false
7
+ gem 'simplecov', '~> 0.16.1', require: false
8
+ gem 'html_validation', '~> 1.1.5', require: false
9
+ gem 'html-proofer', '~> 3.9', '>= 3.9.2', require: false
10
+ gem 'nokogiri', '~> 1.8', '>= 1.8.5', require: false
11
+ end
data/README.md CHANGED
@@ -4,6 +4,7 @@ Planga Ruby Wrapper:
4
4
  [![Planga](https://img.shields.io/badge/%F0%9F%98%8E%20planga-chat-ff00ff.svg)](http://www.planga.io/)
5
5
  [![Planga Docs](https://img.shields.io/badge/planga-docs-lightgrey.svg)](http://www.planga.io/docs)
6
6
  [![Gem](https://img.shields.io/gem/v/planga.svg)](https://rubygems.org/gems/planga)
7
+ [RubyDoc](https://www.rubydoc.info/github/ResiliaDev/planga-ruby/master)
7
8
 
8
9
  **Installation**
9
10
 
@@ -0,0 +1,10 @@
1
+ require 'rake'
2
+ require 'rspec/core/rake_task'
3
+
4
+ RSpec::Core::RakeTask.new(:spec) do |t|
5
+ t.pattern = Dir.glob('spec/**/*_spec.rb')
6
+ t.rspec_opts = '--format documentation'
7
+ # t.rspec_opts << ' more options'
8
+ # t.rcov = true
9
+ end
10
+ task :default => :spec
@@ -6,6 +6,7 @@ require 'json'
6
6
  # if included in a webpage, lets the visitor of that webpage
7
7
  # connect with the Planga Chat Server and start chatting.
8
8
  class Planga
9
+ attr_reader :public_api_id, :conversation_id, :current_user_id, :current_user_name, :remote_host, :container_id, :include_style, :debug
9
10
  # The following configuration options are available:
10
11
  #
11
12
  # Required are:
@@ -25,6 +26,10 @@ class Planga
25
26
  # It defaults to the URL of Planga's main chat server. (`//chat.planga.io`)
26
27
  # * container_id: If you want a custom HTML ID attribute specified to the created HTML element,
27
28
  # you can enter it here.
29
+ # * include_style: Can be the location of a custom stylesheet to include,
30
+ # or `false` if you do not want to include your own style
31
+ # (and do this manually somewhere else in the page).
32
+ # (Defaults to "#{remote_host}/css/chat-style-basic.css")
28
33
  # * debug: (defaults to `false`).
29
34
  #
30
35
  def initialize(**conf)
@@ -40,24 +45,39 @@ class Planga
40
45
  @container_id = conf[:container_id]
41
46
  @container_id ||= "planga-chat-" + SecureRandom.hex
42
47
 
48
+ @include_style = conf[:include_style]
49
+ if @include_style == nil
50
+ @include_style = "#{remote_host}/css/chat-style-basic.css"
51
+ end
43
52
  @debug = conf[:debug] || false
44
53
  end
45
54
 
46
55
 
47
56
  # Creates a full-fledged HTML snippet that includes Planga in your page.
48
57
  def chat_snippet
49
- <<-SNIPPET
50
- <script type="text/javascript" src="#{@remote_host}/js/js_snippet.js"></script>
51
- <div id="#{@container_id}"></div>
52
- <script type="text/javascript">
53
- new Planga(document.getElementById("#{@container_id}"), \{
54
- public_api_id: "#{@public_api_id}",
55
- encrypted_options: "#{encrypted_options()}",
56
- socket_location: "#{@remote_host}/socket",
57
- debug: #{@debug},
58
- \});
59
- </script>
58
+ snippet = <<-SNIPPET
59
+ #{style_tag()}
60
+ <script type="text/javascript" src="#{@remote_host}/js/js_snippet.js"></script>
61
+ <div id="#{@container_id}"></div>
62
+ <script type="text/javascript">
63
+ new Planga(document.getElementById("#{@container_id}"), \{
64
+ public_api_id: "#{@public_api_id}",
65
+ encrypted_options: "#{encrypted_options()}",
66
+ socket_location: "#{@remote_host}/socket",
67
+ debug: #{@debug},
68
+ \});
69
+ </script>
60
70
  SNIPPET
71
+
72
+ snippet.strip!
73
+ end
74
+
75
+ def style_tag()
76
+ return "" unless @include_style
77
+
78
+ <<-SNIPPET
79
+ <link rel="#{include_style}" />
80
+ SNIPPET
61
81
  end
62
82
 
63
83
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: planga
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.0
4
+ version: 0.7.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Wiebe Marten Wijnja
@@ -31,7 +31,9 @@ executables: []
31
31
  extensions: []
32
32
  extra_rdoc_files: []
33
33
  files:
34
+ - Gemfile
34
35
  - README.md
36
+ - Rakefile
35
37
  - lib/planga.rb
36
38
  homepage: https://github.com/ResiliaDev/planga-ruby
37
39
  licenses: