redis_snippets 0.0.5 → 0.0.6
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/app/assets/redis_snippets/redis_snippets.sass +3 -0
- data/app/controllers/redis_snippets/snippets_controller.rb +22 -0
- data/app/views/redis_snippets/snippets/show.html.erb +23 -0
- data/config/routes.rb +2 -4
- data/lib/redis_snippets.rb +1 -4
- data/lib/redis_snippets/engine.rb +5 -0
- data/lib/redis_snippets/help.rb +1 -1
- data/lib/redis_snippets/redis.rb +3 -3
- data/redis_snippets.gemspec +7 -6
- metadata +11 -10
- data/app/controllers/admin/snippets_controller.rb +0 -16
- data/app/views/admin/snippets/show.html.erb +0 -15
- data/lib/redis_snippets/railtie.rb +0 -20
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0.
|
1
|
+
0.0.6
|
@@ -0,0 +1,22 @@
|
|
1
|
+
class RedisSnippets::SnippetsController < ApplicationController
|
2
|
+
include RedisSnippets::Help
|
3
|
+
|
4
|
+
if respond_to?(:authenticate_admin_user!)
|
5
|
+
before_filter :authenticate_admin_user!
|
6
|
+
end
|
7
|
+
|
8
|
+
layout 'admin'
|
9
|
+
|
10
|
+
def show
|
11
|
+
end
|
12
|
+
|
13
|
+
def update
|
14
|
+
params[:snippets].each do |key, content|
|
15
|
+
raise "#{key} not in the specified keys." unless RedisSnippets::Engine.config.redis_snippets[:keys].include?(key.to_sym)
|
16
|
+
RedisSnippets::Snippets.update(snippet_key(key), params[:snippets][key])
|
17
|
+
end
|
18
|
+
|
19
|
+
flash[:notice] = 'Snippets updated.'
|
20
|
+
redirect_to redis_snippets.snippets_path
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
<div id="redis_snippets">
|
2
|
+
<h1>Snippets</h1>
|
3
|
+
|
4
|
+
<%= form_tag '', :method => :put, :class => "formtastic" do |f| %>
|
5
|
+
<fieldset class="inputs">
|
6
|
+
<ol>
|
7
|
+
<% RedisSnippets::Engine.config.redis_snippets[:keys].each do |key| %>
|
8
|
+
<li class="text input optional">
|
9
|
+
<%= label_tag key.to_s, key.to_s, class: "label" %>
|
10
|
+
<%= text_area_tag "snippets[#{key}]", RedisSnippets::Snippets.send(snippet_key(key)), cols: 120, rows: 10 %>
|
11
|
+
</li>
|
12
|
+
<% end -%>
|
13
|
+
</ol>
|
14
|
+
</fieldset>
|
15
|
+
<fieldset class="actions">
|
16
|
+
<ol>
|
17
|
+
<li class="action button_action">
|
18
|
+
<%= button_tag 'Submit' %>
|
19
|
+
</li>
|
20
|
+
</ol>
|
21
|
+
</field>
|
22
|
+
<% end -%>
|
23
|
+
</div>
|
data/config/routes.rb
CHANGED
@@ -1,5 +1,3 @@
|
|
1
|
-
|
2
|
-
resource :
|
3
|
-
resource :snippets, :controller => 'admin/snippets', :only => [:show, :update]
|
4
|
-
end
|
1
|
+
RedisSnippets::Engine.routes.draw do
|
2
|
+
resource :snippets, controller: 'snippets', only: [:show, :update]
|
5
3
|
end
|
data/lib/redis_snippets.rb
CHANGED
@@ -1,10 +1,7 @@
|
|
1
1
|
require 'redis'
|
2
2
|
require 'redis/namespace'
|
3
3
|
|
4
|
-
|
5
|
-
engine_name :redis_snippets
|
6
|
-
end
|
4
|
+
require 'redis_snippets/engine'
|
7
5
|
|
8
|
-
require 'redis_snippets/railtie'
|
9
6
|
require 'redis_snippets/redis'
|
10
7
|
require 'redis_snippets/help'
|
data/lib/redis_snippets/help.rb
CHANGED
@@ -5,7 +5,7 @@ module RedisSnippets
|
|
5
5
|
# redis_snippet_site_key should simply return a unique string per site. For instance
|
6
6
|
# it could be the domain of the site.
|
7
7
|
def snippet_key(key)
|
8
|
-
s =
|
8
|
+
s = RedisSnippets::Engine.config.redis_snippets[:multi_site] ? redis_snippet_site_key + ':' : ''
|
9
9
|
s << key.to_s
|
10
10
|
s.to_sym
|
11
11
|
end
|
data/lib/redis_snippets/redis.rb
CHANGED
@@ -3,15 +3,15 @@ module RedisSnippets
|
|
3
3
|
class << self
|
4
4
|
# Can't do method_missing on get/set as they're defined somewhere by Ruby.
|
5
5
|
def get(key)
|
6
|
-
|
6
|
+
RedisSnippets::Engine.config.redis_snippets[:connection].get(key)
|
7
7
|
end
|
8
8
|
|
9
9
|
def set(key, value)
|
10
|
-
|
10
|
+
RedisSnippets::Engine.config.redis_snippets[:connection].set(key, value)
|
11
11
|
end
|
12
12
|
|
13
13
|
def method_missing(method, *args)
|
14
|
-
|
14
|
+
RedisSnippets::Engine.config.redis_snippets[:connection].send(method, *args)
|
15
15
|
end
|
16
16
|
end
|
17
17
|
end
|
data/redis_snippets.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = "redis_snippets"
|
8
|
-
s.version = "0.0.
|
8
|
+
s.version = "0.0.6"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Martin Moen Wulffeld"]
|
12
|
-
s.date = "
|
12
|
+
s.date = "2013-01-09"
|
13
13
|
s.description = ""
|
14
14
|
s.email = "martin@wulffeld.org"
|
15
15
|
s.extra_rdoc_files = [
|
@@ -19,19 +19,20 @@ Gem::Specification.new do |s|
|
|
19
19
|
"README.md",
|
20
20
|
"Rakefile",
|
21
21
|
"VERSION",
|
22
|
-
"app/
|
22
|
+
"app/assets/redis_snippets/redis_snippets.sass",
|
23
|
+
"app/controllers/redis_snippets/snippets_controller.rb",
|
23
24
|
"app/helpers/redis_snippets/snippets_helper.rb",
|
24
25
|
"app/models/redis_snippets/snippets.rb",
|
25
|
-
"app/views/
|
26
|
+
"app/views/redis_snippets/snippets/show.html.erb",
|
26
27
|
"config/routes.rb",
|
27
28
|
"lib/redis_snippets.rb",
|
29
|
+
"lib/redis_snippets/engine.rb",
|
28
30
|
"lib/redis_snippets/help.rb",
|
29
|
-
"lib/redis_snippets/railtie.rb",
|
30
31
|
"lib/redis_snippets/redis.rb",
|
31
32
|
"redis_snippets.gemspec"
|
32
33
|
]
|
33
34
|
s.require_paths = ["lib"]
|
34
|
-
s.rubygems_version = "1.8.
|
35
|
+
s.rubygems_version = "1.8.16"
|
35
36
|
s.summary = "View snippets held in Redis storage."
|
36
37
|
|
37
38
|
if s.respond_to? :specification_version then
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
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.6
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2013-01-09 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: redis
|
16
|
-
requirement: &
|
16
|
+
requirement: &70118499570200 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: '0'
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *70118499570200
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: redis-namespace
|
27
|
-
requirement: &
|
27
|
+
requirement: &70118499567780 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ! '>='
|
@@ -32,7 +32,7 @@ dependencies:
|
|
32
32
|
version: '0'
|
33
33
|
type: :runtime
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *70118499567780
|
36
36
|
description: ''
|
37
37
|
email: martin@wulffeld.org
|
38
38
|
executables: []
|
@@ -43,14 +43,15 @@ files:
|
|
43
43
|
- README.md
|
44
44
|
- Rakefile
|
45
45
|
- VERSION
|
46
|
-
- app/
|
46
|
+
- app/assets/redis_snippets/redis_snippets.sass
|
47
|
+
- app/controllers/redis_snippets/snippets_controller.rb
|
47
48
|
- app/helpers/redis_snippets/snippets_helper.rb
|
48
49
|
- app/models/redis_snippets/snippets.rb
|
49
|
-
- app/views/
|
50
|
+
- app/views/redis_snippets/snippets/show.html.erb
|
50
51
|
- config/routes.rb
|
51
52
|
- lib/redis_snippets.rb
|
53
|
+
- lib/redis_snippets/engine.rb
|
52
54
|
- lib/redis_snippets/help.rb
|
53
|
-
- lib/redis_snippets/railtie.rb
|
54
55
|
- lib/redis_snippets/redis.rb
|
55
56
|
- redis_snippets.gemspec
|
56
57
|
homepage:
|
@@ -73,7 +74,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
73
74
|
version: '0'
|
74
75
|
requirements: []
|
75
76
|
rubyforge_project:
|
76
|
-
rubygems_version: 1.8.
|
77
|
+
rubygems_version: 1.8.16
|
77
78
|
signing_key:
|
78
79
|
specification_version: 3
|
79
80
|
summary: View snippets held in Redis storage.
|
@@ -1,16 +0,0 @@
|
|
1
|
-
class Admin::SnippetsController < AdminController
|
2
|
-
include RedisSnippets::Help
|
3
|
-
|
4
|
-
def index
|
5
|
-
end
|
6
|
-
|
7
|
-
def update
|
8
|
-
params[:snippets].each do |key, content|
|
9
|
-
raise "#{key} not in the specified keys." unless RedisSnippetsEngine.config.redis_snippets[:keys].include?(key.to_sym)
|
10
|
-
RedisSnippets::Snippets.update(snippet_key(key), params[:snippets][key])
|
11
|
-
end
|
12
|
-
|
13
|
-
flash[:notice] = 'Snippets updated.'
|
14
|
-
redirect_to admin_snippets_path
|
15
|
-
end
|
16
|
-
end
|
@@ -1,15 +0,0 @@
|
|
1
|
-
<h1>Snippets</h1>
|
2
|
-
|
3
|
-
<%= form_tag admin_snippets_path, :method => :put, :class => "formtastic" do |f| %>
|
4
|
-
<fieldset>
|
5
|
-
<ol>
|
6
|
-
<% RedisSnippetsEngine.config.redis_snippets[:keys].each do |key| %>
|
7
|
-
<li>
|
8
|
-
<%= label_tag key.to_s, key.to_s %>
|
9
|
-
<%= text_area_tag "snippets[#{key}]", RedisSnippets::Snippets.send(snippet_key(key)), :cols => 120, :rows => 10 %>
|
10
|
-
</li>
|
11
|
-
<% end -%>
|
12
|
-
</ol>
|
13
|
-
</fieldset>
|
14
|
-
<%= submit_tag 'Submit' %>
|
15
|
-
<% end -%>
|
@@ -1,20 +0,0 @@
|
|
1
|
-
module RedisSnippets
|
2
|
-
class Railtie < Rails::Railtie
|
3
|
-
# This shouldn't be required when 3.1 arrives.
|
4
|
-
# https://github.com/drogus/rails_helpers_fix
|
5
|
-
if Rails.version < "3.1.0"
|
6
|
-
initializer "redis_snippets.include_railties_helpers_fix" do
|
7
|
-
helpers_paths = []
|
8
|
-
Rails.application.railties.all do |r|
|
9
|
-
if r.config.respond_to?(:paths) && r.config.paths.app.helpers
|
10
|
-
helpers_paths += r.config.paths.app.helpers.to_a
|
11
|
-
end
|
12
|
-
end
|
13
|
-
|
14
|
-
ActiveSupport.on_load(:action_controller) do
|
15
|
-
config.helpers_path += helpers_paths
|
16
|
-
end
|
17
|
-
end
|
18
|
-
end
|
19
|
-
end
|
20
|
-
end
|