komments 0.0.2 → 0.0.3
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.
- checksums.yaml +4 -4
- data/README.md +61 -2
- data/lib/komments.rb +4 -0
- data/lib/komments/railtie.rb +10 -0
- data/lib/komments/version.rb +1 -1
- data/lib/komments/view_helpers.rb +16 -0
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ee719341eefbc78bd89d99d6d0aab23fcf70b069
|
4
|
+
data.tar.gz: dd3ab5a15f31123b025788a004ec78d51bd1b0b4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 17745af6c5ff415deecf72752e54f4b388c4cd8851b28193e70f3ed8e8b9c30e0b1c90ef3d9c24feb3a9fb4f8ef2bdf47a101a78fbfbe4893b1f2b69054685b0
|
7
|
+
data.tar.gz: f2d8ff6386d76c8485de897a14ecf75e0e5ff483b0cb0fd0eaf742a5679d2d991bf491d3667006762f89e1150ce3cd067be363c6a659065b67ebfc04ca134551
|
data/README.md
CHANGED
@@ -1,5 +1,4 @@
|
|
1
1
|
[](http://badge.fury.io/rb/komments)
|
2
|
-
[](https://travis-ci.org/mattpolito/komments_gem)
|
3
2
|
[](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
|
-
|
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
|
data/lib/komments.rb
CHANGED
data/lib/komments/version.rb
CHANGED
@@ -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.
|
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-
|
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
|