sketchily 1.0.3 → 1.1.0
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.
- data/README.md +20 -9
- data/app/views/sketchily/_sketchily.html.erb +5 -5
- data/app/views/sketchily/_sketchily.html.erb~ +6 -4
- data/app/views/sketchily/_sketchily_tag.html.erb +5 -4
- data/app/views/sketchily/_sketchily_tag.html.erb~ +6 -3
- data/lib/sketchily/sketchily.rb +2 -2
- data/lib/sketchily/sketchily.rb~ +1 -0
- data/lib/sketchily/sketchily_tag.rb +1 -1
- data/lib/sketchily/sketchily_tag.rb~ +1 -0
- data/lib/sketchily/version.rb +1 -1
- data/lib/sketchily/version.rb~ +1 -1
- data/lib/sketchily.rb +4 -2
- data/lib/sketchily.rb~ +4 -4
- metadata +1 -1
data/README.md
CHANGED
@@ -56,17 +56,28 @@ This gem also adds a helper method that can be called to display the resulting S
|
|
56
56
|
|
57
57
|
Currently available options are:
|
58
58
|
|
59
|
-
- `width`
|
60
|
-
- `height`
|
61
|
-
|
62
|
-
- `
|
63
|
-
- `
|
64
|
-
- `
|
65
|
-
|
66
|
-
- `
|
67
|
-
- `
|
59
|
+
- `width` total width of editor
|
60
|
+
- `height` total height of editor
|
61
|
+
|
62
|
+
- `canvas_width` initial canvas width
|
63
|
+
- `canvas_height` initial canvas height
|
64
|
+
- `canvas_expansion` 0 if you want to disable scrolling
|
65
|
+
|
66
|
+
- `hide_rulers` true if you want to hide the canvas rulers
|
67
|
+
- `hide_menu` true if you want svg-edit's menu to be hidden
|
68
|
+
- `hide_image_tool` true if you want to hide the image tool button
|
69
|
+
- `hide_hyperlink_tool` true if you want to hide the hyperlink tool button
|
70
|
+
|
71
|
+
- `id` override the default id (see explanation below)
|
72
|
+
- `value` override the default value (the svg itself; can be useful when using form_for)
|
73
|
+
- `index` override the default index (affects the tag name; can be useful when using form_for)
|
74
|
+
|
68
75
|
- other standard html attributes for the input tag
|
69
76
|
|
77
|
+
Sketchily requires a unique `id` (by default, this is set in the same way as hidden_field) each time it is called in the same page.
|
78
|
+
However, some uses of `form_for` can generate repeated ids (e.g. multiple `form_for @my_object.new` in the same page).
|
79
|
+
In those cases, you need to generate and specify your own unique ids. A possible solution is to use one of the many uuid generator gems.
|
80
|
+
|
70
81
|
It is recommended that the database entries associated with sketchily form elements be of type `text`.
|
71
82
|
|
72
83
|
The following examples assume that the database table for `@my_object` has a `sketch` column of type `text`.
|
@@ -4,13 +4,13 @@
|
|
4
4
|
# method
|
5
5
|
# options %>
|
6
6
|
|
7
|
-
<% sketchily_tag = ActionView::Helpers::InstanceTag.new(object_name, method, template, options.delete(:object))
|
7
|
+
<% sketchily_tag = ActionView::Helpers::InstanceTag.new(object_name, method, template, options.delete(:object))
|
8
|
+
options = {:id => sketchily_tag.send(:tag_id),
|
9
|
+
:value => sketchily_tag.value(sketchily_tag.object)}.merge(options) %>
|
8
10
|
|
9
11
|
<%= render :partial => "sketchily/embed",
|
10
12
|
:formats => :html,
|
11
|
-
:locals => options.slice(*Sketchily::OPTIONS)
|
12
|
-
{:id => sketchily_tag.send(:tag_id),
|
13
|
-
:value => sketchily_tag.value(sketchily_tag.object)}) %>
|
13
|
+
:locals => options.slice(*Sketchily::OPTIONS) %>
|
14
14
|
|
15
|
-
<%= sketchily_tag.to_input_field_tag("hidden", options.except(*Sketchily::
|
15
|
+
<%= sketchily_tag.to_input_field_tag("hidden", options.except(*Sketchily::SKETCHILY_OPTIONS)) %>
|
16
16
|
|
@@ -4,12 +4,14 @@
|
|
4
4
|
# method
|
5
5
|
# options %>
|
6
6
|
|
7
|
-
<% sketchily_tag = ActionView::Helpers::InstanceTag.new(object_name, method, template, options.delete(:object))
|
7
|
+
<% sketchily_tag = ActionView::Helpers::InstanceTag.new(object_name, method, template, options.delete(:object))
|
8
|
+
options = {:id => sketchily_tag.send(:tag_id),
|
9
|
+
:value => sketchily_tag.value(sketchily_tag.object)}.merge(
|
10
|
+
options) %>
|
8
11
|
|
9
12
|
<%= render :partial => "sketchily/embed",
|
10
13
|
:formats => :html,
|
11
|
-
:locals =>
|
12
|
-
:value => sketchily_tag.value(sketchily_tag.object)}.merge(options.slice(*Sketchily::OPTIONS)) %>
|
14
|
+
:locals => options.slice(*Sketchily::OPTIONS) %>
|
13
15
|
|
14
|
-
<%= sketchily_tag.to_input_field_tag("hidden", options.except(*Sketchily::
|
16
|
+
<%= sketchily_tag.to_input_field_tag("hidden", options.except(*Sketchily::SKETCHILY_OPTIONS)) %>
|
15
17
|
|
@@ -4,11 +4,12 @@
|
|
4
4
|
# value
|
5
5
|
# options %>
|
6
6
|
|
7
|
+
<% options = {:id => id,
|
8
|
+
:value => value}.merge(options) %>
|
9
|
+
|
7
10
|
<%= render :partial => "sketchily/embed",
|
8
11
|
:formats => :html,
|
9
|
-
:locals => options.slice(*Sketchily::OPTIONS)
|
10
|
-
{:id => id,
|
11
|
-
:value => value}) %>
|
12
|
+
:locals => options.slice(*Sketchily::OPTIONS) %>
|
12
13
|
|
13
|
-
<%= tag :input, {
|
14
|
+
<%= tag :input, {"type" => "hidden", "name" => name}.update(options.except(*Sketchily::SKETCHILY_OPTIONS).stringify_keys) %>
|
14
15
|
|
@@ -4,10 +4,13 @@
|
|
4
4
|
# value
|
5
5
|
# options %>
|
6
6
|
|
7
|
+
<% options = {:id => id,
|
8
|
+
:value => value}.merge(
|
9
|
+
options.slice(*Sketchily::OPTIONS)) %>
|
10
|
+
|
7
11
|
<%= render :partial => "sketchily/embed",
|
8
12
|
:formats => :html,
|
9
|
-
:locals =>
|
10
|
-
:value => value}.merge(options.slice(*Sketchily::OPTIONS)) %>
|
13
|
+
:locals => options %>
|
11
14
|
|
12
|
-
<%= tag :input, {
|
15
|
+
<%= tag :input, {"type" => "hidden", "name" => name}.update(options.except(*Sketchily::SKETCHILY_OPTIONS).stringify_keys) %>
|
13
16
|
|
data/lib/sketchily/sketchily.rb
CHANGED
@@ -3,7 +3,7 @@ module Sketchily
|
|
3
3
|
def sketchily(method, options = {})
|
4
4
|
Sketchily.render(:partial => "sketchily/sketchily",
|
5
5
|
:locals => {:template => @template, :object_name => @object_name,
|
6
|
-
:method => method, :options => objectify_options(options)})
|
6
|
+
:method => method, :options => objectify_options(options)})
|
7
7
|
end
|
8
8
|
|
9
9
|
def svg_edit(method, options = {})
|
@@ -15,7 +15,7 @@ module Sketchily
|
|
15
15
|
def sketchily(object_name, method, options = {})
|
16
16
|
Sketchily.render(:partial => "sketchily/sketchily",
|
17
17
|
:locals => {:template => self, :object_name => object_name,
|
18
|
-
:method => method, :options => options})
|
18
|
+
:method => method, :options => options})
|
19
19
|
end
|
20
20
|
|
21
21
|
def svg_edit(object_name, method, options = {})
|
data/lib/sketchily/sketchily.rb~
CHANGED
@@ -3,7 +3,7 @@ module SketchilyTag
|
|
3
3
|
def sketchily_tag(name, value = nil, options = {})
|
4
4
|
Sketchily.render(:partial => "sketchily/sketchily_tag",
|
5
5
|
:locals => {:name => name, :id => sanitize_to_id(name),
|
6
|
-
:value => value, :options => options})
|
6
|
+
:value => value, :options => options})
|
7
7
|
end
|
8
8
|
|
9
9
|
def svg_edit_tag(name, value = nil, options = {})
|
data/lib/sketchily/version.rb
CHANGED
data/lib/sketchily/version.rb~
CHANGED
data/lib/sketchily.rb
CHANGED
@@ -5,7 +5,9 @@ require "sketchily/sketchily_tag"
|
|
5
5
|
module Sketchily
|
6
6
|
ASSET_FILES = %w(sketchily.css sketchily.js sketchily_embed.js canvg/canvg.js canvg/rgbcolor.js extensions/ext-*.js locale/lang.*.js)
|
7
7
|
|
8
|
-
|
8
|
+
SKETCHILY_OPTIONS = [:width, :height, :canvas_width, :canvas_height, :canvas_expansion, :hide_rulers, :hide_menu, :hide_image_tool, :hide_hyperlink_tool]
|
9
|
+
TAG_OPTIONS = [:id, :value, :index]
|
10
|
+
OPTIONS = SKETCHILY_OPTIONS + TAG_OPTIONS
|
9
11
|
|
10
12
|
ROOT = File.expand_path('../..', __FILE__)
|
11
13
|
|
@@ -17,7 +19,7 @@ module Sketchily
|
|
17
19
|
end
|
18
20
|
|
19
21
|
def self.render(options = {}, local_assigns = {}, &block)
|
20
|
-
VIEW.render(options, local_assigns, &block)
|
22
|
+
VIEW.render(options, local_assigns, &block).html_safe
|
21
23
|
end
|
22
24
|
end
|
23
25
|
|
data/lib/sketchily.rb~
CHANGED
@@ -5,7 +5,9 @@ require "sketchily/sketchily_tag"
|
|
5
5
|
module Sketchily
|
6
6
|
ASSET_FILES = %w(sketchily.css sketchily.js sketchily_embed.js canvg/canvg.js canvg/rgbcolor.js extensions/ext-*.js locale/lang.*.js)
|
7
7
|
|
8
|
-
|
8
|
+
SKETCHILY_OPTIONS = [:width, :height, :canvas_width, :canvas_height, :canvas_expansion, :hide_rulers, :hide_menu, :hide_image_tool, :hide_hyperlink_tool]
|
9
|
+
TAG_OPTIONS = [:id, :value]
|
10
|
+
OPTIONS = SKETCHILY_OPTIONS + TAG_OPTIONS
|
9
11
|
|
10
12
|
ROOT = File.expand_path('../..', __FILE__)
|
11
13
|
|
@@ -17,9 +19,7 @@ module Sketchily
|
|
17
19
|
end
|
18
20
|
|
19
21
|
def self.render(options = {}, local_assigns = {}, &block)
|
20
|
-
VIEW.render(options, local_assigns, &block)
|
22
|
+
VIEW.render(options, local_assigns, &block).html_safe
|
21
23
|
end
|
22
24
|
end
|
23
25
|
|
24
|
-
|
25
|
-
|