komments 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 567c11064f4cc3f52a8d0de4a5c71ad61eaf039f
4
- data.tar.gz: 02608e46236dc6d65ffd62fa379c86d726542551
3
+ metadata.gz: ee719341eefbc78bd89d99d6d0aab23fcf70b069
4
+ data.tar.gz: dd3ab5a15f31123b025788a004ec78d51bd1b0b4
5
5
  SHA512:
6
- metadata.gz: d09398e14f20ca797a42fd26234b0f1440a9b8c5e5a895121d659f8dbdabf59ae36842d550d69a8ed69fceb15456f38f3dcbcab9475417bbefb5c90b2146feec
7
- data.tar.gz: f0430e37f9e76e1cc6a18ea81f3bf62894c8c0b83ec2cbaaa0acb5638c545903e84fce21ff329fce97741a450407de3cbbdb5767ee839d6905030e9dd8278088
6
+ metadata.gz: 17745af6c5ff415deecf72752e54f4b388c4cd8851b28193e70f3ed8e8b9c30e0b1c90ef3d9c24feb3a9fb4f8ef2bdf47a101a78fbfbe4893b1f2b69054685b0
7
+ data.tar.gz: f2d8ff6386d76c8485de897a14ecf75e0e5ff483b0cb0fd0eaf742a5679d2d991bf491d3667006762f89e1150ce3cd067be363c6a659065b67ebfc04ca134551
data/README.md CHANGED
@@ -1,5 +1,4 @@
1
1
  [![Gem Version](http://img.shields.io/gem/v/komments.svg?style=flat)](http://badge.fury.io/rb/komments)
2
- [![Build Status](http://img.shields.io/travis/mattpolito/komments_gem/master.svg?style=flat)](https://travis-ci.org/mattpolito/komments_gem)
3
2
  [![Code Climate](http://img.shields.io/codeclimate/github/mattpolito/komments_gem.svg?style=flat)](https://codeclimate.com/github/mattpolito/komments_gem)
4
3
 
5
4
  Ruby wrapper to get configured with the commenting engine, [Komments][]
@@ -26,7 +25,65 @@ gem install komments
26
25
 
27
26
  ## Usage
28
27
 
29
- TODO: Write usage instructions here
28
+ Currently the main functionality of this library is to configure your api key so that your personalized site url can be generated.
29
+
30
+ To do this:
31
+
32
+ ```ruby
33
+ Komments.configure do |config|
34
+ config.api_key = 'API_KEY_GOES_HERE'
35
+ end
36
+ ```
37
+
38
+ Would be the most straight forward way to go about this. If this were being used in a [Rails][] project, I would recommend putting this in your `config/initializers` directory.
39
+
40
+ Now that your credentials are out of the way, you'll be able to call:
41
+
42
+ ```ruby
43
+ Komments.website_url
44
+ ```
45
+
46
+ This will provide your site's url to [Komments][]. Add that to a `script` tag in your template and you will be good to go.
47
+
48
+ ```erb
49
+ <script async="async" src=<%= Komments.website_url %>></script>
50
+
51
+ ```
52
+
53
+ That will end up looking this this:
54
+
55
+
56
+ ```html
57
+ <script async="async" src="//komments.net/embed/{API_KEY_GOES_HERE}"></script>
58
+ ```
59
+
60
+ # Rails Usage
61
+
62
+ If you happen to be integrating Komments into your Rails application, you're covered as well.
63
+
64
+ When a Rails app is detected, you'll gain access to the `komments_script_tag` helper.
65
+
66
+ ```ruby
67
+ <%= komments_script_tag %>
68
+ ```
69
+
70
+ Which will render out to:
71
+
72
+ ```html
73
+ <script async="async" src="//komments.net/embed/{API_KEY_GOES_HERE}"></script>
74
+ ```
75
+
76
+ And if you [don't want the script to be loaded asynchronously][async vs defer]...
77
+
78
+ ```ruby
79
+ <%= komments_script_tag(false) %>
80
+ ```
81
+
82
+ Which will render out to:
83
+
84
+ ```html
85
+ <script defer="defer" src="//komments.net/embed/{API_KEY_GOES_HERE}"></script>
86
+ ```
30
87
 
31
88
  ## Contributing
32
89
 
@@ -37,3 +94,5 @@ TODO: Write usage instructions here
37
94
  5. Create a new Pull Request
38
95
 
39
96
  [Komments]: http://komments.net
97
+ [Rails]: http://rubyonrails.org
98
+ [async vs defer]: http://www.growingwiththeweb.com/2014/02/async-vs-defer-attributes.html
@@ -16,3 +16,7 @@ module Komments
16
16
  Configuration.instance
17
17
  end
18
18
  end
19
+
20
+ if defined?(Rails::Railtie)
21
+ require 'komments/railtie'
22
+ end
@@ -0,0 +1,10 @@
1
+ module Komments
2
+ class Railtie < Rails::Railtie
3
+ initializer "komments" do |app|
4
+ ActiveSupport.on_load(:action_view) do
5
+ require 'komments/view_helpers'
6
+ ::ActionView::Base.send :include, ViewHelpers
7
+ end
8
+ end
9
+ end
10
+ end
@@ -1,3 +1,3 @@
1
1
  module Komments
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
  end
@@ -0,0 +1,16 @@
1
+ module Komments
2
+ module ViewHelpers
3
+ def komments_script_tag(async = true)
4
+ options = Hash.new
5
+ options[:src] = Komments.website_url
6
+
7
+ if async
8
+ options[:async] = 'async'
9
+ else
10
+ options[:defer] = 'defer'
11
+ end
12
+
13
+ content_tag(:script, nil, options)
14
+ end
15
+ end
16
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: komments
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Matt Polito
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-11-13 00:00:00.000000000 Z
11
+ date: 2014-11-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -54,7 +54,9 @@ files:
54
54
  - lib/komments.rb
55
55
  - lib/komments/configuration.rb
56
56
  - lib/komments/errors.rb
57
+ - lib/komments/railtie.rb
57
58
  - lib/komments/version.rb
59
+ - lib/komments/view_helpers.rb
58
60
  homepage: https://github.com/mattpolito/komments_gem
59
61
  licenses:
60
62
  - MIT