redis_snippets 0.0.9 → 0.0.10
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 +11 -1
- data/app/helpers/redis_snippets/snippets_helper.rb +6 -5
- data/lib/redis_snippets/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d57ab380b6653a5a2bbadfd96bcb3f5c2b1033b0
|
4
|
+
data.tar.gz: c6ef4474551730d558e675fa49fde37e5f20219a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c81fa957b20f7e9d1b7cdf0164bae965e85cea2a51f6ad1c65d3ba6f17d24a4e0119cd8f5bd9889dbc9e54c12df67735cd43eac6ab2f84897837925bf90a000a
|
7
|
+
data.tar.gz: f5ed406436c21e5969129f901fcdea444f89f68b1dd10a17576a60798c7bab9790f542692e7b47823ff4487c49e272bd3614acb02ef5dae6da82a84832b385c0
|
data/README.md
CHANGED
@@ -6,7 +6,7 @@ Easily store snippets of content in Redis.
|
|
6
6
|
|
7
7
|
## How
|
8
8
|
|
9
|
-
It's a Rails
|
9
|
+
It's a Rails engine so add redis-snippets to your Gemfile and put this in an initializer:
|
10
10
|
|
11
11
|
``` ruby
|
12
12
|
App::Application.config.redis_snippets = {
|
@@ -23,6 +23,16 @@ In your views use helper snippet().
|
|
23
23
|
<%= snippet(:key1) %>
|
24
24
|
```
|
25
25
|
|
26
|
+
### Random snippets
|
27
|
+
|
28
|
+
One snippet area can include multiple snippets if you separate them with a
|
29
|
+
|
30
|
+
```
|
31
|
+
[snippet]
|
32
|
+
```
|
33
|
+
|
34
|
+
The snippet helper will randomly select the snippet. This is convenient for ad delivery for example.
|
35
|
+
|
26
36
|
## Multi Site
|
27
37
|
|
28
38
|
If you're using one app to serve multiple sites a little more configuration is necessary.
|
@@ -5,17 +5,18 @@ module RedisSnippets
|
|
5
5
|
def snippet_content(snippet_name)
|
6
6
|
RedisSnippets::Snippets.send(snippet_key(snippet_name))
|
7
7
|
end
|
8
|
-
|
8
|
+
|
9
9
|
# Return true if snippet has content.
|
10
10
|
def snippet_has_content?(snippet_name)
|
11
11
|
!snippet_content(snippet_name).blank?
|
12
12
|
end
|
13
|
-
|
13
|
+
|
14
14
|
def snippet(snippet_name, classes=nil)
|
15
15
|
return '' if controller.status == 404
|
16
|
-
|
17
|
-
return '' if
|
18
|
-
|
16
|
+
snippet = snippet_content(snippet_name)
|
17
|
+
return '' if snippet.blank?
|
18
|
+
snippets = snippet.split("[section]")
|
19
|
+
build_snippet(snippets[rand(snippets.length)], snippet_class_list(snippet_name, classes))
|
19
20
|
end
|
20
21
|
|
21
22
|
def snippet_class_list(snippet_name, classes)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: redis_snippets
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.10
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Martin Moen Wulffeld
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2015-07-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -107,7 +107,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
107
107
|
version: '0'
|
108
108
|
requirements: []
|
109
109
|
rubyforge_project:
|
110
|
-
rubygems_version: 2.
|
110
|
+
rubygems_version: 2.4.8
|
111
111
|
signing_key:
|
112
112
|
specification_version: 4
|
113
113
|
summary: Storing snippets of whatever in Redis.
|