on_the_spot 1.0.0 → 1.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/README.markdown +1 -1
- data/VERSION +1 -1
- data/lib/generators/on_the_spot/install/install_generator.rb +1 -0
- data/lib/generators/on_the_spot/install/templates/on_the_spot.en.yml +2 -1
- data/lib/generators/on_the_spot/install/templates/on_the_spot.fr.yml +6 -0
- data/lib/on_the_spot/controller_extension.rb +3 -3
- data/lib/on_the_spot/on_the_spot_helpers.rb +2 -2
- data/on_the_spot.gemspec +3 -2
- data/spec/on_the_spot_spec.rb +12 -2
- metadata +6 -5
data/README.markdown
CHANGED
@@ -12,7 +12,7 @@ On-the-spot is a Rails3 compliant unobtrusive javascript in-place-editing plugin
|
|
12
12
|
* will check your server-side validations and show the error
|
13
13
|
* you can check the access-rights before doing any update (to check against tampering)
|
14
14
|
* you can use custom display methods, e.g when using markdown
|
15
|
-
* watch the demo-project [here]() ([source](https://github.com/nathanvda/on_the_spot_tester))
|
15
|
+
* watch the demo-project [here](http://on-the-spot-demo.heroku.com/) ([source](https://github.com/nathanvda/on_the_spot_tester))
|
16
16
|
|
17
17
|
|
18
18
|
## Installation
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.0.
|
1
|
+
1.0.1
|
@@ -29,14 +29,14 @@ module OnTheSpot
|
|
29
29
|
end
|
30
30
|
render :text => field_or_method
|
31
31
|
else
|
32
|
-
parsed_data = JSON.parse(select_data.gsub("'", '"'))
|
32
|
+
parsed_data = JSON.parse(select_data.gsub("'", '"').gsub('\"', "'"))
|
33
33
|
render :text => parsed_data[object.send(field).to_s]
|
34
34
|
end
|
35
35
|
else
|
36
36
|
render :text => object.errors.full_messages.join("\n"), :status => 422
|
37
37
|
end
|
38
38
|
else
|
39
|
-
render :text =>
|
39
|
+
render :text => t('on_the_spot.access_not_allowed'), :status => 422
|
40
40
|
end
|
41
41
|
end
|
42
42
|
|
@@ -50,7 +50,7 @@ module OnTheSpot
|
|
50
50
|
if is_allowed
|
51
51
|
render :text => object.send(field)
|
52
52
|
else
|
53
|
-
render :text =>
|
53
|
+
render :text => t('on_the_spot.access_not_allowed'), :status => 422
|
54
54
|
end
|
55
55
|
end
|
56
56
|
end
|
@@ -81,8 +81,8 @@ module OnTheSpot
|
|
81
81
|
end
|
82
82
|
|
83
83
|
def convert_array_to_json(id_value_array, selected_id)
|
84
|
-
conv_arr = id_value_array.map{|idv| "'#{idv[0]}':'#{idv[1]}'" }
|
85
|
-
result = "{ #{conv_arr.join', '}"
|
84
|
+
conv_arr = id_value_array.map{|idv| "'#{idv[0]}':'#{escape_javascript(idv[1])}'" }
|
85
|
+
result = "{ #{conv_arr.join(', ')}"
|
86
86
|
result += ", 'selected':'#{ selected_id.to_s}'" unless selected_id.nil?
|
87
87
|
result += "}"
|
88
88
|
result
|
data/on_the_spot.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = "on_the_spot"
|
8
|
-
s.version = "1.0.
|
8
|
+
s.version = "1.0.1"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Nathan Van der Auwera"]
|
12
|
-
s.date = "2012-
|
12
|
+
s.date = "2012-05-17"
|
13
13
|
s.description = "Unobtrusive in place editing, using jEditable; only works in Rails 3"
|
14
14
|
s.email = "nathan@dixis.com"
|
15
15
|
s.extra_rdoc_files = [
|
@@ -36,6 +36,7 @@ Gem::Specification.new do |s|
|
|
36
36
|
"lib/generators/on_the_spot/install/install_generator.rb",
|
37
37
|
"lib/generators/on_the_spot/install/templates/jquery.jeditable.mini.js",
|
38
38
|
"lib/generators/on_the_spot/install/templates/on_the_spot.en.yml",
|
39
|
+
"lib/generators/on_the_spot/install/templates/on_the_spot.fr.yml",
|
39
40
|
"lib/on_the_spot.rb",
|
40
41
|
"lib/on_the_spot/controller_extension.rb",
|
41
42
|
"lib/on_the_spot/on_the_spot_helpers.rb",
|
data/spec/on_the_spot_spec.rb
CHANGED
@@ -12,7 +12,7 @@ describe "OnTheSpot" do
|
|
12
12
|
end
|
13
13
|
|
14
14
|
@tester = TestClass.new
|
15
|
-
@test_array_nr = [[1,"abc"], [2, "def"], [3, "ghi"]]
|
15
|
+
@test_array_nr = [[1,"abc"], [2, "def"], [3, "ghi"], [4, "Freddy's Nightmare"]]
|
16
16
|
@test_array_str = [["key", "value"], ["key2", "value2"]]
|
17
17
|
end
|
18
18
|
|
@@ -29,11 +29,21 @@ describe "OnTheSpot" do
|
|
29
29
|
@tester.lookup_display_value(@test_array_str, 'key1').should == ''
|
30
30
|
end
|
31
31
|
|
32
|
+
it "can handle single quotes normally" do
|
33
|
+
@tester.lookup_display_value(@test_array_nr, 4).should == "Freddy's Nightmare"
|
34
|
+
end
|
35
|
+
|
32
36
|
end
|
33
37
|
|
34
38
|
context "convert array to json" do
|
35
39
|
it "should convert correctly" do
|
36
|
-
@tester.convert_array_to_json(@test_array_nr, 1).should == "{ '1':'abc', '2':'def', '3':'ghi', 'selected':'1'}"
|
40
|
+
@tester.convert_array_to_json(@test_array_nr, 1).should == "{ '1':'abc', '2':'def', '3':'ghi', '4':'Freddy\\'s Nightmare', 'selected':'1'}"
|
41
|
+
end
|
42
|
+
|
43
|
+
it "convert an array containing an item with single quotes to valid JSON" do
|
44
|
+
test_array_with_single_quote = [[1, "tree"], [2, "bike"], [3, "John's hat"]]
|
45
|
+
json_str = @tester.convert_array_to_json(test_array_with_single_quote, 1)
|
46
|
+
json_str.should == "{ '1':'tree', '2':'bike', '3':'John\\'s hat', 'selected':'1'}"
|
37
47
|
end
|
38
48
|
end
|
39
49
|
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: on_the_spot
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 21
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 1
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 1.0.
|
9
|
+
- 1
|
10
|
+
version: 1.0.1
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Nathan Van der Auwera
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2012-
|
18
|
+
date: 2012-05-17 00:00:00 Z
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
21
21
|
requirement: &id001 !ruby/object:Gem::Requirement
|
@@ -23,7 +23,7 @@ dependencies:
|
|
23
23
|
requirements:
|
24
24
|
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
hash:
|
26
|
+
hash: 28106001
|
27
27
|
segments:
|
28
28
|
- 2
|
29
29
|
- 0
|
@@ -95,6 +95,7 @@ files:
|
|
95
95
|
- lib/generators/on_the_spot/install/install_generator.rb
|
96
96
|
- lib/generators/on_the_spot/install/templates/jquery.jeditable.mini.js
|
97
97
|
- lib/generators/on_the_spot/install/templates/on_the_spot.en.yml
|
98
|
+
- lib/generators/on_the_spot/install/templates/on_the_spot.fr.yml
|
98
99
|
- lib/on_the_spot.rb
|
99
100
|
- lib/on_the_spot/controller_extension.rb
|
100
101
|
- lib/on_the_spot/on_the_spot_helpers.rb
|