sketchily 0.2.0 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # Sketchily
2
2
 
3
- Sketchily allows the easy integration of svg-edit with any rails application.
3
+ Sketchily allows the easy integration of [svg-edit](http://code.google.com/p/svg-edit/) with any rails application.
4
4
 
5
5
  Currently supports and provides `svg-edit-2.6`.
6
6
 
@@ -38,14 +38,15 @@ This gem also adds a helper method that can be called to display the resulting S
38
38
 
39
39
  Currently available options are:
40
40
 
41
- - `width`
42
- - `height`
43
- - `hide_menu` (true if you want svg-edit's menu to be hidden)
44
- - `hide_image_tool` (true if you want to hide the image tool button)
45
- - `canvas_width` (number specifying initial canvas width)
46
- - `canvas_height` (number specifying initial canvas height)
41
+ - `width` (total width of editor)
42
+ - `height` (total height of editor)
43
+ - `canvas_width` (initial canvas width)
44
+ - `canvas_height` (initial canvas height)
47
45
  - `canvas_expansion` (0 if you want to disable scrolling)
48
46
  - `hide_rulers` (true if you want to hide the canvas rulers)
47
+ - `hide_menu` (true if you want svg-edit's menu to be hidden)
48
+ - `hide_image_tool` (true if you want to hide the image tool button)
49
+ - `hide_hyperlink_tool` (true if you want to hide the hyperlink tool button)
49
50
  - other standard html attributes for the input tag
50
51
 
51
52
  It is recommended that the database entries associated with sketchily form elements be of type `text`.
@@ -81,7 +82,7 @@ Although more testing is needed, we currently believe sketchily supports any bro
81
82
  - Safari 4+
82
83
  - Chrome 1+
83
84
  - IE 9+
84
- - IE 6+ (with the Chrome Frame plugin)
85
+ - IE 6+ (with the [Chrome Frame plugin](http://www.google.com/chromeframe))
85
86
 
86
87
  ## Contributing
87
88
 
@@ -3,14 +3,15 @@
3
3
  # value
4
4
  #
5
5
  # Additionally, they may override the following variables:
6
- hide_menu ||= false
7
- hide_image_tool ||= false
6
+ width ||= "750px"
7
+ height ||= "650px"
8
8
  canvas_width ||= 640
9
9
  canvas_height ||= 480
10
10
  canvas_expansion ||= 3
11
11
  hide_rulers ||= false
12
- width ||= "750px"
13
- height ||= "650px" %>
12
+ hide_menu ||= false
13
+ hide_image_tool ||= false
14
+ hide_hyperlink_tool ||= false %>
14
15
 
15
16
  <%= javascript_include_tag "embedapi" %>
16
17
  <%= javascript_include_tag "svgutils" %>
@@ -21,7 +22,8 @@
21
22
  :locals => {:id => id,
22
23
  :value => value,
23
24
  :hide_menu => hide_menu,
24
- :hide_image_tool => hide_image_tool} %>
25
+ :hide_image_tool => hide_image_tool,
26
+ :hide_hyperlink_tool => hide_hyperlink_tool} %>
25
27
  </script>
26
28
 
27
29
  <iframe src="/assets/svg-editor.html?source=&dimensions=<%= "#{canvas_width},#{canvas_height}" %>&canvas_expansion=<%= canvas_expansion %>&showRulers=<%= !hide_rulers %>"
@@ -3,14 +3,15 @@
3
3
  # value
4
4
  #
5
5
  # Additionally, they may override the following variables:
6
- hide_menu ||= false
7
- hide_image_tool ||= false
6
+ width ||= "750px"
7
+ height ||= "650px"
8
8
  canvas_width ||= 640
9
9
  canvas_height ||= 480
10
10
  canvas_expansion ||= 3
11
+ hide_menu ||= false
11
12
  hide_rulers ||= false
12
- width ||= "750px"
13
- height ||= "650px" %>
13
+ hide_image_tool ||= false
14
+ hide_hyperlink_tool ||= false %>
14
15
 
15
16
  <%= javascript_include_tag "embedapi" %>
16
17
  <%= javascript_include_tag "svgutils" %>
@@ -20,8 +21,9 @@
20
21
  :formats => :js,
21
22
  :locals => {:id => id,
22
23
  :value => value,
23
- :show_menu => show_menu,
24
- :hide_image_tool => hide_image_tool} %>
24
+ :hide_menu => hide_menu,
25
+ :hide_image_tool => hide_image_tool,
26
+ :hide_hyperlink_tool => hide_hyperlink_tool} %>
25
27
  </script>
26
28
 
27
29
  <iframe src="/assets/svg-editor.html?source=&dimensions=<%= "#{canvas_width},#{canvas_height}" %>&canvas_expansion=<%= canvas_expansion %>&showRulers=<%= !hide_rulers %>"
@@ -4,7 +4,8 @@
4
4
  # id
5
5
  # value
6
6
  # hide_menu
7
- # hide_image_tool %>
7
+ # hide_image_tool
8
+ # hide_hyperlink_tool %>
8
9
 
9
10
  var svgCanvas_<%= id %> = null;
10
11
 
@@ -38,14 +39,19 @@ function initEmbed_<%= id %>() {
38
39
 
39
40
  <% if hide_menu %>
40
41
  var mainButton = doc.getElementById('main_button');
41
- mainButton.style.display = 'none';
42
+ mainButton.parentNode.removeChild(mainButton);
42
43
  var toolsTop = doc.getElementById('tools_top');
43
44
  toolsTop.style.left = '5px';
44
45
  <% end %>
45
46
 
46
47
  <% if hide_image_tool %>
47
48
  var imageTool = doc.getElementById('tool_image');
48
- imageTool.style.display = 'none';
49
+ imageTool.parentNode.removeChild(imageTool);
50
+ <% end %>
51
+
52
+ <% if hide_hyperlink_tool %>
53
+ var hyperlinkTool = doc.getElementById('tool_make_link');
54
+ hyperlinkTool.parentNode.removeChild(hyperlinkTool);
49
55
  <% end %>
50
56
 
51
57
  attachSubmitHandler_<%= id %>();
@@ -4,7 +4,8 @@
4
4
  # id
5
5
  # value
6
6
  # hide_menu
7
- # hide_image_tool %>
7
+ # hide_image_tool
8
+ # hide_hyperlink_tool %>
8
9
 
9
10
  var svgCanvas_<%= id %> = null;
10
11
 
@@ -38,14 +39,19 @@ function initEmbed_<%= id %>() {
38
39
 
39
40
  <% if hide_menu %>
40
41
  var mainButton = doc.getElementById('main_button');
41
- mainButton.style.display = 'none';
42
+ mainButton.parentNode.removeChild(mainButton);
42
43
  var toolsTop = doc.getElementById('tools_top');
43
- toolsTop.style.left = '0px';
44
+ toolsTop.style.left = '5px';
44
45
  <% end %>
45
46
 
46
47
  <% if hide_image_tool %>
47
48
  var imageTool = doc.getElementById('tool_image');
48
- imageTool.style.display = 'none';
49
+ imageTool.parentNode.removeChild(imageTool);
50
+ <% end %>
51
+
52
+ <% if hide_hyperlink_tool %>
53
+ var hyperlinkTool = doc.getElementById('tool_make_link');
54
+ //hyperlinkTool.parentNode.removeChild(hyperlinkTool);
49
55
  <% end %>
50
56
 
51
57
  attachSubmitHandler_<%= id %>();
@@ -8,16 +8,9 @@
8
8
 
9
9
  <%= render :partial => "sketchily/embed",
10
10
  :formats => :html,
11
- :locals => {:id => sketchily_tag.send(:tag_id),
12
- :value => sketchily_tag.value(sketchily_tag.object),
13
- :hide_menu => options[:hide_menu],
14
- :hide_rulers => options[:hide_rulers],
15
- :hide_image_tool => options[:hide_image_tool],
16
- :canvas_width => options[:canvas_width],
17
- :canvas_height => options[:canvas_height],
18
- :canvas_expansion => options[:canvas_expansion],
19
- :width => options[:width],
20
- :height => options[:height]} %>
11
+ :locals => options.slice(*Sketchily::OPTIONS).merge(
12
+ {:id => sketchily_tag.send(:tag_id),
13
+ :value => sketchily_tag.value(sketchily_tag.object)}) %>
21
14
 
22
- <%= sketchily_tag.to_input_field_tag("hidden", options.except(:hide_menu, :hide_rulers, :hide_image_tool, :canvas_width, :canvas_height, :canvas_expansion, :width, :height)) %>
15
+ <%= sketchily_tag.to_input_field_tag("hidden", options.except(*Sketchily::OPTIONS)) %>
23
16
 
@@ -9,15 +9,7 @@
9
9
  <%= render :partial => "sketchily/embed",
10
10
  :formats => :html,
11
11
  :locals => {:id => sketchily_tag.send(:tag_id),
12
- :value => sketchily_tag.value(sketchily_tag.object),
13
- :hide_menu => options[:hide_menu],
14
- :hide_image_tool => options[:hide_image_tool],
15
- :hide_rulers => options[:hide_rulers],
16
- :canvas_width => options[:canvas_width],
17
- :canvas_height => options[:canvas_height],
18
- :canvas_expansion => options[:canvas_expansion],
19
- :width => options[:width],
20
- :height => options[:height]} %>
12
+ :value => sketchily_tag.value(sketchily_tag.object)}.merge(options.slice(*Sketchily::OPTIONS)) %>
21
13
 
22
- <%= sketchily_tag.to_input_field_tag("hidden", options.except(:hide_menu, :hide_image_tool, :hide_rulers, :canvas_width, :canvas_height, :canvas_expansion, :width, :height)) %>
14
+ <%= sketchily_tag.to_input_field_tag("hidden", options.except(*Sketchily::OPTIONS)) %>
23
15
 
@@ -6,16 +6,9 @@
6
6
 
7
7
  <%= render :partial => "sketchily/embed",
8
8
  :formats => :html,
9
- :locals => {:id => id,
10
- :value => value,
11
- :hide_menu => options[:hide_menu],
12
- :hide_rulers => options[:hide_rulers],
13
- :hide_image_tool => options[:hide_image_tool],
14
- :canvas_width => options[:canvas_width],
15
- :canvas_height => options[:canvas_height],
16
- :canvas_expansion => options[:canvas_expansion],
17
- :width => options[:width],
18
- :height => options[:height]} %>
9
+ :locals => options.slice(*Sketchily::OPTIONS).merge(
10
+ {:id => id,
11
+ :value => value}) %>
19
12
 
20
- <%= tag :input, { "type" => "hidden", "name" => name, "id" => id, "value" => value }.update(options.except(:hide_menu, :hide_rulers, :hide_image_tool, :canvas_width, :canvas_height, :canvas_expansion, :width, :height).stringify_keys) %>
13
+ <%= tag :input, { "type" => "hidden", "name" => name, "id" => id, "value" => value }.update(options.except(*Sketchily::OPTIONS).stringify_keys) %>
21
14
 
@@ -7,15 +7,7 @@
7
7
  <%= render :partial => "sketchily/embed",
8
8
  :formats => :html,
9
9
  :locals => {:id => id,
10
- :value => value,
11
- :show_menu => options[:show_menu],
12
- :hide_image_tool => options[:hide_image_tool],
13
- :canvas_width => options[:canvas_width],
14
- :canvas_height => options[:canvas_height],
15
- :canvas_expansion => options[:canvas_expansion],
16
- :hide_rulers => options[:hide_rulers],
17
- :width => options[:width],
18
- :height => options[:height]} %>
10
+ :value => value}.merge(options.slice(*Sketchily::OPTIONS)) %>
19
11
 
20
- <%= tag :input, { "type" => "hidden", "name" => name, "id" => id, "value" => value }.update(options.except(:show_menu, :hide_image_tool, :canvas_width, :canvas_height, :canvas_expansion, :hide_rulers, :width, :height).stringify_keys) %>
12
+ <%= tag :input, { "type" => "hidden", "name" => name, "id" => id, "value" => value }.update(options.except(*Sketchily::OPTIONS).stringify_keys) %>
21
13
 
@@ -1,3 +1,3 @@
1
1
  module Sketchily
2
- VERSION = "0.2.0"
2
+ VERSION = "0.3.0"
3
3
  end
@@ -1,3 +1,3 @@
1
1
  module Sketchily
2
- VERSION = "0.1.0"
2
+ VERSION = "0.2.0"
3
3
  end
data/lib/sketchily.rb CHANGED
@@ -1,4 +1,6 @@
1
1
  module Sketchily
2
+ OPTIONS = [:width, :height, :canvas_width, :canvas_height, :canvas_expansion, :hide_rulers, :hide_menu, :hide_image_tool, :hide_hyperlink_tool]
3
+
2
4
  ROOT = File.expand_path('../..', __FILE__)
3
5
 
4
6
  VIEW = ActionView::Base.new
data/lib/sketchily.rb~ CHANGED
@@ -1,9 +1,10 @@
1
1
  module Sketchily
2
+ OPTIONS = [:width, :height, :canvas_width, :canvas_height, :canvas_expansion, :hide_menu, :hide_rulers, :hide_image_tool, :hide_hyperlink_tool]
3
+
2
4
  ROOT = File.expand_path('../..', __FILE__)
3
5
 
4
6
  VIEW = ActionView::Base.new
5
7
  VIEW.view_paths << "#{ROOT}/app/views"
6
- VIEW.view_paths << "#{ROOT}/app/views/sketchily"
7
8
 
8
9
  def self.render(options = {}, local_assigns = {}, &block)
9
10
  VIEW.render(options, local_assigns, &block)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sketchily
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.3.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-02-14 00:00:00.000000000 Z
12
+ date: 2013-02-15 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rails
@@ -77,10 +77,6 @@ files:
77
77
  - app/views/sketchily/_embed.html.erb~
78
78
  - app/views/sketchily/_embed.html.erb
79
79
  - lib/sketchily/version.rb~
80
- - lib/sketchily/svg_edit_tag.rb~
81
- - lib/sketchily/sketchily_tag.rb~
82
- - lib/sketchily/svg_edit.rb~
83
- - lib/sketchily/sketchily.rb~
84
80
  - lib/sketchily/engine.rb
85
81
  - lib/sketchily/sketchily_tag.rb
86
82
  - lib/sketchily/version.rb
@@ -92,10 +88,8 @@ files:
92
88
  - vendor/assets/svg-edit-2.6/spinbtn/JQuerySpinBtn.min.js
93
89
  - vendor/assets/svg-edit-2.6/spinbtn/spinbtn_updn.png
94
90
  - vendor/assets/svg-edit-2.6/spinbtn/JQuerySpinBtn.js
95
- - vendor/assets/svg-edit-2.6/svgedit.compiled.js~
96
91
  - vendor/assets/svg-edit-2.6/embedapi.html
97
92
  - vendor/assets/svg-edit-2.6/jquery.js
98
- - vendor/assets/svg-edit-2.6/svg-editor.js~
99
93
  - vendor/assets/svg-edit-2.6/jquery-ui/jquery-ui-1.8.custom.min.js
100
94
  - vendor/assets/svg-edit-2.6/jquery-ui/jquery-ui-1.8.17.custom.min.js
101
95
  - vendor/assets/svg-edit-2.6/jgraduate/jquery.jgraduate.js
@@ -122,7 +116,6 @@ files:
122
116
  - vendor/assets/svg-edit-2.6/path.js
123
117
  - vendor/assets/svg-edit-2.6/svgcanvas.js
124
118
  - vendor/assets/svg-edit-2.6/svgutils.js
125
- - vendor/assets/svg-edit-2.6/svg-editor.css~
126
119
  - vendor/assets/svg-edit-2.6/locale/lang.fi.js
127
120
  - vendor/assets/svg-edit-2.6/locale/lang.sq.js
128
121
  - vendor/assets/svg-edit-2.6/locale/lang.fr.js
@@ -220,7 +213,6 @@ files:
220
213
  - vendor/assets/svg-edit-2.6/extensions/shapelib/object.json
221
214
  - vendor/assets/svg-edit-2.6/extensions/shapelib/raphael.txt
222
215
  - vendor/assets/svg-edit-2.6/extensions/shapelib/flowchart.json
223
- - vendor/assets/svg-edit-2.6/extensions/ext-imagelib.js~
224
216
  - vendor/assets/svg-edit-2.6/extensions/ext-grid.js
225
217
  - vendor/assets/svg-edit-2.6/extensions/markers-icons.xml
226
218
  - vendor/assets/svg-edit-2.6/extensions/foreignobject-icons.xml
@@ -232,7 +224,6 @@ files:
232
224
  - vendor/assets/svg-edit-2.6/extensions/ext-server_moinsave.js
233
225
  - vendor/assets/svg-edit-2.6/extensions/closepath_icons.svg
234
226
  - vendor/assets/svg-edit-2.6/extensions/ext-imagelib.xml
235
- - vendor/assets/svg-edit-2.6/extensions/ext-server_opensave.js~
236
227
  - vendor/assets/svg-edit-2.6/extensions/ext-markers.js
237
228
  - vendor/assets/svg-edit-2.6/extensions/ext-arrows.js
238
229
  - vendor/assets/svg-edit-2.6/extensions/eyedropper.png
@@ -313,7 +304,6 @@ files:
313
304
  - vendor/assets/svg-edit-2.6/images/paste.png
314
305
  - vendor/assets/svg-edit-2.6/images/align-center.svg
315
306
  - vendor/assets/svg-edit-2.6/images/polygon.png
316
- - vendor/assets/svg-edit-2.6/svg-editor.html~
317
307
  - vendor/assets/svg-edit-2.6/browser.js
318
308
  - vendor/assets/svg-edit-2.6/select.js
319
309
  - vendor/assets/svg-edit-2.6/embedapi.js
@@ -353,7 +343,6 @@ files:
353
343
  - spec/dummy/public/404.html
354
344
  - spec/dummy/log/development.log
355
345
  - spec/dummy/config.ru
356
- - spec/spec_helper.rb~
357
346
  - spec/lib/sketchily_spec.rb
358
347
  homepage: http://github.com/lml/sketchily
359
348
  licenses: []
@@ -410,5 +399,4 @@ test_files:
410
399
  - spec/dummy/public/404.html
411
400
  - spec/dummy/log/development.log
412
401
  - spec/dummy/config.ru
413
- - spec/spec_helper.rb~
414
402
  - spec/lib/sketchily_spec.rb
@@ -1,28 +0,0 @@
1
- module Sketchily
2
- module FormBuilderInstanceMethods
3
- def sketchily(method, options = {})
4
- Sketchily.render(:partial => "sketchily/sketchily",
5
- :locals => {:template => @template, :object_name => @object_name,
6
- :method => method, :options => objectify_options(options)}).html_safe
7
- end
8
-
9
- def svg_edit(method, options = {})
10
- sketchily(method, options)
11
- end
12
- end
13
-
14
- module ActionViewBaseInstanceMethods
15
- def sketchily(object_name, method, options = {})
16
- Sketchily.render(:partial => "sketchily/sketchily",
17
- :locals => {:template => self, :object_name => object_name,
18
- :method => method, :options => objectify_options(options)}).html_safe
19
- end
20
-
21
- def svg_edit(object_name, method, options = {})
22
- sketchily(object_name, method, options)
23
- end
24
- end
25
- end
26
-
27
- ActionView::Helpers::FormBuilder.send :include, Sketchily::FormBuilderInstanceMethods
28
- ActionView::Base.send :include, Sketchily::ActionViewBaseInstanceMethods
@@ -1,15 +0,0 @@
1
- module SketchilyTag
2
- module ActionViewBaseInstanceMethods
3
- def sketchily_tag(name, value = nil, options = {})
4
- Sketchily.render(:partial => "sketchily/sketchily_tag",
5
- :locals => {:name => name, :id => sanitize_to_id(name),
6
- :value => value, :options => options}).html_safe
7
- end
8
-
9
- def svg_edit_tag(name, value = nil, options = {})
10
- sketchily_tag(name, value, options)
11
- end
12
- end
13
- end
14
-
15
- ActionView::Base.send :include, SketchilyTag::ActionViewBaseInstanceMethods
@@ -1,15 +0,0 @@
1
- module Sketchily
2
- module FormHelperInstanceMethods
3
- def sketchily(object_name, method, options = {})
4
- ActionView::Helpers::InstanceTag.new(object_name, method, self, options.delete(:object)).to_input_field_tag("hidden", options)
5
- end
6
- end
7
-
8
- module FormBuilderInstanceMethods
9
- def sketchily(method, options = {})
10
- @template.hidden_field(@object_name, method, objectify_options(options))
11
- end
12
- end
13
- end
14
-
15
- ActionView::Helpers::FormBuilder.send :include, Sketchily::InstanceMethods
@@ -1,9 +0,0 @@
1
- module SvgEditTag
2
- module InstanceMethods
3
- def svg_edit_tag(name, value = nil, options = {})
4
- tag :input, { "type" => "text", "name" => name, "id" => sanitize_to_id(name), "value" => value }.update(options.stringify_keys)
5
- end
6
- end
7
- end
8
-
9
- ActionView::Helpers::FormTagHelper.send :include, SvgEditTag::InstanceMethods
data/spec/spec_helper.rb~ DELETED
@@ -1,18 +0,0 @@
1
- # Configure Rails Environment
2
- ENV["RAILS_ENV"] = "test"
3
-
4
- require File.expand_path("../dummy/config/environment.rb", __FILE__)
5
- require "rails/test_help"
6
-
7
- require "minitest/autorun"
8
- require "minitest/rails"
9
-
10
- Rails.backtrace_cleaner.remove_silencers!
11
-
12
- # Load support files
13
- Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each { |f| require f }
14
-
15
- # Load fixtures from the engine
16
- if ActiveSupport::TestCase.method_defined?(:fixture_path=)
17
- ActiveSupport::TestCase.fixture_path = File.expand_path("../fixtures", __FILE__)
18
- end