novector 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (78) hide show
  1. checksums.yaml +7 -0
  2. data/MIT-LICENSE +20 -0
  3. data/README.md +52 -0
  4. data/Rakefile +34 -0
  5. data/app/assets/javascripts/novector/application.js.coffee +0 -0
  6. data/app/assets/stylesheets/novector/application.css +13 -0
  7. data/app/controllers/novector/application_controller.rb +27 -0
  8. data/app/controllers/novector/vector_fallback_controller.rb +79 -0
  9. data/app/helpers/novector/application_helper.rb +27 -0
  10. data/app/views/layouts/novector/application.html.erb +14 -0
  11. data/config/routes.rb +26 -0
  12. data/lib/novector/engine.rb +28 -0
  13. data/lib/novector/railtie.rb +32 -0
  14. data/lib/novector/vector_tag_helper.rb +32 -0
  15. data/lib/novector/version.rb +26 -0
  16. data/lib/novector.rb +29 -0
  17. data/lib/tasks/novector_tasks.rake +0 -0
  18. data/test/dummy/README.rdoc +28 -0
  19. data/test/dummy/Rakefile +6 -0
  20. data/test/dummy/app/assets/images/test.svg +18 -0
  21. data/test/dummy/app/assets/javascripts/application.js.coffee +25 -0
  22. data/test/dummy/app/assets/stylesheets/application.css +13 -0
  23. data/test/dummy/app/controllers/application_controller.rb +28 -0
  24. data/test/dummy/app/controllers/novector_js_test_controller.rb +27 -0
  25. data/test/dummy/app/helpers/application_helper.rb +25 -0
  26. data/test/dummy/app/views/layouts/application.html.erb +14 -0
  27. data/test/dummy/app/views/novector_js_test/test_fallback.html.erb +1 -0
  28. data/test/dummy/bin/bundle +3 -0
  29. data/test/dummy/bin/rails +4 -0
  30. data/test/dummy/bin/rake +4 -0
  31. data/test/dummy/config/application.rb +46 -0
  32. data/test/dummy/config/boot.rb +28 -0
  33. data/test/dummy/config/database.yml +25 -0
  34. data/test/dummy/config/environment.rb +28 -0
  35. data/test/dummy/config/environments/development.rb +52 -0
  36. data/test/dummy/config/environments/production.rb +103 -0
  37. data/test/dummy/config/environments/test.rb +59 -0
  38. data/test/dummy/config/initializers/backtrace_silencers.rb +22 -0
  39. data/test/dummy/config/initializers/filter_parameter_logging.rb +24 -0
  40. data/test/dummy/config/initializers/inflections.rb +22 -0
  41. data/test/dummy/config/initializers/mime_types.rb +22 -0
  42. data/test/dummy/config/initializers/secret_token.rb +24 -0
  43. data/test/dummy/config/initializers/session_store.rb +25 -0
  44. data/test/dummy/config/initializers/wrap_parameters.rb +26 -0
  45. data/test/dummy/config/locales/en.yml +23 -0
  46. data/test/dummy/config/routes.rb +28 -0
  47. data/test/dummy/config.ru +4 -0
  48. data/test/dummy/db/development.sqlite3 +0 -0
  49. data/test/dummy/db/test.sqlite3 +0 -0
  50. data/test/dummy/log/development.log +4390 -0
  51. data/test/dummy/log/test.log +28 -0
  52. data/test/dummy/public/404.html +58 -0
  53. data/test/dummy/public/422.html +58 -0
  54. data/test/dummy/public/500.html +57 -0
  55. data/test/dummy/public/favicon.ico +0 -0
  56. data/test/dummy/public/index.html +5 -0
  57. data/test/dummy/tmp/cache/8B3/9F1/%23%7Bsource%7D_%23%7Basset_mtime%7D_%23%7Bwidth%7D_%23%7Bheight%7D_%23%7Bformat%7D +0 -0
  58. data/test/dummy/tmp/cache/assets/development/sprockets/0d3881005b0646df783d5c24683d34f5 +0 -0
  59. data/test/dummy/tmp/cache/assets/development/sprockets/13fe41fee1fe35b49d145bcc06610705 +0 -0
  60. data/test/dummy/tmp/cache/assets/development/sprockets/1a6846f0a837ae2524e2f9ec89e6ef43 +0 -0
  61. data/test/dummy/tmp/cache/assets/development/sprockets/357970feca3ac29060c1e3861e2c0953 +0 -0
  62. data/test/dummy/tmp/cache/assets/development/sprockets/3e0125f4f13be82bc5a02281674477ed +0 -0
  63. data/test/dummy/tmp/cache/assets/development/sprockets/4f718aff2230953fe8be999580618732 +0 -0
  64. data/test/dummy/tmp/cache/assets/development/sprockets/86e145a39f85cceeaffdff91ebb61449 +0 -0
  65. data/test/dummy/tmp/cache/assets/development/sprockets/b63b013eb2c61daded11152bb299bc21 +0 -0
  66. data/test/dummy/tmp/cache/assets/development/sprockets/c97695b571e457e7a757b449f8a1e4db +0 -0
  67. data/test/dummy/tmp/cache/assets/development/sprockets/d771ace226fc8215a3572e0aa35bb0d6 +0 -0
  68. data/test/dummy/tmp/cache/assets/development/sprockets/dca8a548218e0f8da42d69a1e8564bf4 +0 -0
  69. data/test/dummy/tmp/cache/assets/development/sprockets/de6a4845f72245338bbbcd74eb42dbc5 +0 -0
  70. data/test/dummy/tmp/cache/assets/development/sprockets/eff8385ae06988716d71bc33ba55546a +0 -0
  71. data/test/dummy/tmp/cache/assets/development/sprockets/f1460ae88a741d099a1375a9ffd77e1d +0 -0
  72. data/test/dummy/tmp/cache/assets/test/sprockets/c97695b571e457e7a757b449f8a1e4db +0 -0
  73. data/test/dummy/tmp/cache/assets/test/sprockets/dca8a548218e0f8da42d69a1e8564bf4 +0 -0
  74. data/test/integration/navigation_test.rb +10 -0
  75. data/test/novector_test.rb +35 -0
  76. data/test/test_helper.rb +38 -0
  77. data/vendor/assets/javascripts/novector.js.coffee +33 -0
  78. metadata +279 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 25d6fe0f7fd4cdea78517aee32a8b88c84dfdf85
4
+ data.tar.gz: 815a0f5da6211b2abfb11a756b15af11138ec6cf
5
+ SHA512:
6
+ metadata.gz: f706f3271a6f3017d933341a3c9b5ebe24398c6207e700d1e8c0780f81273326ac20937e694078f81af8a4841d452c9950e57d623d852c737e2ab19ea040aea8
7
+ data.tar.gz: c42614d44cb1758cf7ff693bbee55869e10aa7479112edd58541759dbc7bb1692247d5eac62b3b9a0966be95fee7ce9148aae90d27566d958b828d9af13b46f2
data/MIT-LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright 2013 (c) John Colanduoni
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,52 @@
1
+ # NoVector
2
+
3
+ NoVector is a Rails plugin automatically generates fallback bitmaps for vector images (e.g. SVG) when a client does not support them. It automatically caches the images, so the whole process only impacts performance the first time the images are viewed.
4
+
5
+ It currently supports the following vector image formats:
6
+
7
+ * [Scalable Vector Graphic (SVG)][svg]
8
+
9
+ and the following output bitmap formats:
10
+
11
+ * [Portable Network Graphics (PNG)][png]
12
+ * [Graphics Interchange Format (GIF)][gif]
13
+
14
+ ## Dependencies
15
+
16
+ NoVector requires the following non-gem dependencies:
17
+
18
+ * [RSVG][rsvg] binaries (namely `rsvg-convert`)
19
+
20
+ ## Using NoVector
21
+
22
+ ### Automatic
23
+
24
+ The primary method of using NoVector is through a simple [JQuery][jquery] script and a helper tag in your views. To use this method, simply write
25
+
26
+ <%= vector_tag asset, options %>
27
+
28
+ The `asset` and `options` arguments work precisely the same way they do for `image_tag`. In addition you will need to include `novector.js.coffee` in your applications's JavaScript. The recommended way of doing this is adding the following line in your `application.js`, at some place after the inclusion of JQuery:
29
+
30
+ //= require novector
31
+
32
+ Also, you will need to mount the NoVector engine in the default location by adding the following in your `routes.rb`:
33
+
34
+ mount Novector::Engine => '/novector'
35
+
36
+ ### Manual
37
+
38
+ You can also use NoVector's SVG rendering facilities directly through the following url:
39
+
40
+ /novector/fallback.FORMAT?src=ASSET&width=WIDTH&height=HEIGHT
41
+
42
+ where `FORMAT` is replaced with a supported bitmap format, `ASSET` is replaced by a supported vector asset, `WIDTH` is width in pixels, and `HEIGHT` is height in pixels.
43
+
44
+ ## License
45
+
46
+ NoVector is released under the MIT license, which can be found in the `MIT-LICENSE` file.
47
+
48
+ [svg]: http://www.w3.org/Graphics/SVG/
49
+ [png]: http://www.w3.org/TR/PNG/
50
+ [gif]: http://www.w3.org/Graphics/GIF/spec-gif87.txt
51
+ [jquery]: http://jquery.com/
52
+ [rsvg]: https://developer.gnome.org/rsvg/stable/
data/Rakefile ADDED
@@ -0,0 +1,34 @@
1
+ begin
2
+ require 'bundler/setup'
3
+ rescue LoadError
4
+ puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
5
+ end
6
+
7
+ require 'rdoc/task'
8
+
9
+ RDoc::Task.new(:rdoc) do |rdoc|
10
+ rdoc.rdoc_dir = 'rdoc'
11
+ rdoc.title = 'NoVector'
12
+ rdoc.options << '--line-numbers'
13
+ rdoc.rdoc_files.include('README.rdoc')
14
+ rdoc.rdoc_files.include('lib/**/*.rb')
15
+ end
16
+
17
+ APP_RAKEFILE = File.expand_path("../test/dummy/Rakefile", __FILE__)
18
+ load 'rails/tasks/engine.rake'
19
+
20
+
21
+
22
+ Bundler::GemHelper.install_tasks
23
+
24
+ require 'rake/testtask'
25
+
26
+ Rake::TestTask.new(:test) do |t|
27
+ t.libs << 'lib'
28
+ t.libs << 'test'
29
+ t.pattern = 'test/**/*_test.rb'
30
+ t.verbose = false
31
+ end
32
+
33
+
34
+ task default: :test
@@ -0,0 +1,13 @@
1
+ /*
2
+ * This is a manifest file that'll be compiled into application.css, which will include all the files
3
+ * listed below.
4
+ *
5
+ * Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
6
+ * or vendor/assets/stylesheets of plugins, if any, can be referenced here using a relative path.
7
+ *
8
+ * You're free to add application-wide styles to this file and they'll appear at the top of the
9
+ * compiled file, but it's generally better to create a new file per style scope.
10
+ *
11
+ *= require_self
12
+ *= require_tree .
13
+ */
@@ -0,0 +1,27 @@
1
+ #
2
+ # Copyright 2013 (c) John Colanduoni
3
+ #
4
+ # Permission is hereby granted, free of charge, to any person obtaining
5
+ # a copy of this software and associated documentation files (the
6
+ # "Software"), to deal in the Software without restriction, including
7
+ # without limitation the rights to use, copy, modify, merge, publish,
8
+ # distribute, sublicense, and/or sell copies of the Software, and to
9
+ # permit persons to whom the Software is furnished to do so, subject to
10
+ # the following conditions:
11
+ #
12
+ # The above copyright notice and this permission notice shall be
13
+ # included in all copies or substantial portions of the Software.
14
+ #
15
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16
+ # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17
+ # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
18
+ # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
19
+ # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
20
+ # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
21
+ # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22
+ #
23
+
24
+ module Novector
25
+ class ApplicationController < ActionController::Base
26
+ end
27
+ end
@@ -0,0 +1,79 @@
1
+ #
2
+ # Copyright 2013 (c) John Colanduoni
3
+ #
4
+ # Permission is hereby granted, free of charge, to any person obtaining
5
+ # a copy of this software and associated documentation files (the
6
+ # "Software"), to deal in the Software without restriction, including
7
+ # without limitation the rights to use, copy, modify, merge, publish,
8
+ # distribute, sublicense, and/or sell copies of the Software, and to
9
+ # permit persons to whom the Software is furnished to do so, subject to
10
+ # the following conditions:
11
+ #
12
+ # The above copyright notice and this permission notice shall be
13
+ # included in all copies or substantial portions of the Software.
14
+ #
15
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16
+ # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17
+ # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
18
+ # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
19
+ # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
20
+ # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
21
+ # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22
+ #
23
+
24
+ require 'rmagick'
25
+
26
+ module Novector
27
+ class VectorFallbackController < ActionController::Base
28
+ public
29
+
30
+ def render_fallback
31
+ width = Integer(params[:width])
32
+ height = Integer(params[:height])
33
+ source = params[:src]
34
+ format = params[:format]
35
+
36
+ raise 'Asset is not an SVG file.' unless source =~ /\.svg$/
37
+ raise 'Unsupported output format.' unless ['png', 'gif'].include? format
38
+
39
+ # Open asset
40
+ asset = Rails.application.assets.find_asset source
41
+ raise ActionController::RoutingError.new('Asset not found') unless asset
42
+ asset_mtime = File.mtime(asset.pathname)
43
+
44
+ # If the asset is up to date on the client, don't waste the bandwidth
45
+ last_time = Time.rfc2822(request.env['HTTP_IF_MODIFIED_SINCE']) rescue nil
46
+ if last_time and asset_mtime < last_time
47
+ render :text => '304 Not Modified', :status => 304
48
+ return
49
+ end
50
+
51
+ cache_name = '#{source}_#{asset_mtime}_#{width}_#{height}_#{format}'
52
+ blob = Rails.cache.read(cache_name)
53
+ unless blob
54
+ blob = convert_svg(asset.pathname, width, height, format)
55
+ Rails.cache.write(cache_name, blob)
56
+ end
57
+
58
+ # Send asset
59
+ response.header['Last-Modified'] = asset_mtime.to_s
60
+ send_data(blob, :type => "image/#{format}", :disposition => 'inline')
61
+ end
62
+
63
+ protected
64
+
65
+ def convert_svg(source_filename, width, height, format)
66
+ blob = nil
67
+ IO::popen(['rsvg-convert', '--width', width.to_s, '--height', height.to_s, source_filename.to_s]) do |pipe|
68
+ blob = pipe.read
69
+ end
70
+ # Convert from png if neccessary
71
+ if format == 'png'
72
+ return blob
73
+ else
74
+ png_image = (Magick::Image.from_blob(blob) { self.format = 'PNG'})[0]
75
+ return png_image.to_blob { self.format = format.upcase; self.quality = 10 }
76
+ end
77
+ end
78
+ end
79
+ end
@@ -0,0 +1,27 @@
1
+ #
2
+ # Copyright 2013 (c) John Colanduoni
3
+ #
4
+ # Permission is hereby granted, free of charge, to any person obtaining
5
+ # a copy of this software and associated documentation files (the
6
+ # "Software"), to deal in the Software without restriction, including
7
+ # without limitation the rights to use, copy, modify, merge, publish,
8
+ # distribute, sublicense, and/or sell copies of the Software, and to
9
+ # permit persons to whom the Software is furnished to do so, subject to
10
+ # the following conditions:
11
+ #
12
+ # The above copyright notice and this permission notice shall be
13
+ # included in all copies or substantial portions of the Software.
14
+ #
15
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16
+ # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17
+ # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
18
+ # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
19
+ # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
20
+ # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
21
+ # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22
+ #
23
+
24
+ module Novector
25
+ module ApplicationHelper
26
+ end
27
+ end
@@ -0,0 +1,14 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>NoVector</title>
5
+ <%= stylesheet_link_tag "novector/application", media: "all" %>
6
+ <%= javascript_include_tag "novector/application" %>
7
+ <%= csrf_meta_tags %>
8
+ </head>
9
+ <body>
10
+
11
+ <%= yield %>
12
+
13
+ </body>
14
+ </html>
data/config/routes.rb ADDED
@@ -0,0 +1,26 @@
1
+ #
2
+ # Copyright 2013 (c) John Colanduoni
3
+ #
4
+ # Permission is hereby granted, free of charge, to any person obtaining
5
+ # a copy of this software and associated documentation files (the
6
+ # "Software"), to deal in the Software without restriction, including
7
+ # without limitation the rights to use, copy, modify, merge, publish,
8
+ # distribute, sublicense, and/or sell copies of the Software, and to
9
+ # permit persons to whom the Software is furnished to do so, subject to
10
+ # the following conditions:
11
+ #
12
+ # The above copyright notice and this permission notice shall be
13
+ # included in all copies or substantial portions of the Software.
14
+ #
15
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16
+ # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17
+ # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
18
+ # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
19
+ # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
20
+ # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
21
+ # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22
+ #
23
+
24
+ Novector::Engine.routes.draw do
25
+ get '/fallback', to: 'vector_fallback#render_fallback'
26
+ end
@@ -0,0 +1,28 @@
1
+ #
2
+ # Copyright 2013 (c) John Colanduoni
3
+ #
4
+ # Permission is hereby granted, free of charge, to any person obtaining
5
+ # a copy of this software and associated documentation files (the
6
+ # "Software"), to deal in the Software without restriction, including
7
+ # without limitation the rights to use, copy, modify, merge, publish,
8
+ # distribute, sublicense, and/or sell copies of the Software, and to
9
+ # permit persons to whom the Software is furnished to do so, subject to
10
+ # the following conditions:
11
+ #
12
+ # The above copyright notice and this permission notice shall be
13
+ # included in all copies or substantial portions of the Software.
14
+ #
15
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16
+ # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17
+ # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
18
+ # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
19
+ # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
20
+ # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
21
+ # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22
+ #
23
+
24
+ module Novector
25
+ class Engine < ::Rails::Engine
26
+ isolate_namespace Novector
27
+ end
28
+ end
@@ -0,0 +1,32 @@
1
+ #
2
+ # Copyright 2013 (c) John Colanduoni
3
+ #
4
+ # Permission is hereby granted, free of charge, to any person obtaining
5
+ # a copy of this software and associated documentation files (the
6
+ # "Software"), to deal in the Software without restriction, including
7
+ # without limitation the rights to use, copy, modify, merge, publish,
8
+ # distribute, sublicense, and/or sell copies of the Software, and to
9
+ # permit persons to whom the Software is furnished to do so, subject to
10
+ # the following conditions:
11
+ #
12
+ # The above copyright notice and this permission notice shall be
13
+ # included in all copies or substantial portions of the Software.
14
+ #
15
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16
+ # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17
+ # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
18
+ # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
19
+ # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
20
+ # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
21
+ # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22
+ #
23
+
24
+ require 'novector/vector_tag_helper'
25
+
26
+ module Novector
27
+ class Railtie < Rails::Railtie
28
+ initializer 'novector.view_helpers' do
29
+ ActionView::Base.send :include, VectorTagHelper
30
+ end
31
+ end
32
+ end
@@ -0,0 +1,32 @@
1
+ #
2
+ # Copyright 2013 (c) John Colanduoni
3
+ #
4
+ # Permission is hereby granted, free of charge, to any person obtaining
5
+ # a copy of this software and associated documentation files (the
6
+ # "Software"), to deal in the Software without restriction, including
7
+ # without limitation the rights to use, copy, modify, merge, publish,
8
+ # distribute, sublicense, and/or sell copies of the Software, and to
9
+ # permit persons to whom the Software is furnished to do so, subject to
10
+ # the following conditions:
11
+ #
12
+ # The above copyright notice and this permission notice shall be
13
+ # included in all copies or substantial portions of the Software.
14
+ #
15
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16
+ # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17
+ # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
18
+ # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
19
+ # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
20
+ # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
21
+ # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22
+ #
23
+
24
+ module Novector
25
+ module VectorTagHelper
26
+ def vector_tag(source, options={})
27
+ new_options = options
28
+ new_options[:'data-novector-source'] = source
29
+ return image_tag(source, new_options)
30
+ end
31
+ end
32
+ end
@@ -0,0 +1,26 @@
1
+ #
2
+ # Copyright 2013 (c) John Colanduoni
3
+ #
4
+ # Permission is hereby granted, free of charge, to any person obtaining
5
+ # a copy of this software and associated documentation files (the
6
+ # "Software"), to deal in the Software without restriction, including
7
+ # without limitation the rights to use, copy, modify, merge, publish,
8
+ # distribute, sublicense, and/or sell copies of the Software, and to
9
+ # permit persons to whom the Software is furnished to do so, subject to
10
+ # the following conditions:
11
+ #
12
+ # The above copyright notice and this permission notice shall be
13
+ # included in all copies or substantial portions of the Software.
14
+ #
15
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16
+ # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17
+ # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
18
+ # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
19
+ # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
20
+ # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
21
+ # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22
+ #
23
+
24
+ module Novector
25
+ VERSION = '0.2.0'
26
+ end
data/lib/novector.rb ADDED
@@ -0,0 +1,29 @@
1
+ #
2
+ # Copyright 2013 (c) John Colanduoni
3
+ #
4
+ # Permission is hereby granted, free of charge, to any person obtaining
5
+ # a copy of this software and associated documentation files (the
6
+ # "Software"), to deal in the Software without restriction, including
7
+ # without limitation the rights to use, copy, modify, merge, publish,
8
+ # distribute, sublicense, and/or sell copies of the Software, and to
9
+ # permit persons to whom the Software is furnished to do so, subject to
10
+ # the following conditions:
11
+ #
12
+ # The above copyright notice and this permission notice shall be
13
+ # included in all copies or substantial portions of the Software.
14
+ #
15
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16
+ # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17
+ # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
18
+ # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
19
+ # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
20
+ # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
21
+ # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22
+ #
23
+
24
+ require 'novector/engine'
25
+ require 'novector/railtie' if defined?(Rails)
26
+ require 'novector/version'
27
+
28
+ module Novector
29
+ end
File without changes
@@ -0,0 +1,28 @@
1
+ == README
2
+
3
+ This README would normally document whatever steps are necessary to get the
4
+ application up and running.
5
+
6
+ Things you may want to cover:
7
+
8
+ * Ruby version
9
+
10
+ * System dependencies
11
+
12
+ * Configuration
13
+
14
+ * Database creation
15
+
16
+ * Database initialization
17
+
18
+ * How to run the test suite
19
+
20
+ * Services (job queues, cache servers, search engines, etc.)
21
+
22
+ * Deployment instructions
23
+
24
+ * ...
25
+
26
+
27
+ Please feel free to use a different markup language if you do not plan to run
28
+ <tt>rake doc:app</tt>.
@@ -0,0 +1,6 @@
1
+ # Add your own tasks in files placed in lib/tasks ending in .rake,
2
+ # for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
3
+
4
+ require File.expand_path('../config/application', __FILE__)
5
+
6
+ Dummy::Application.load_tasks
@@ -0,0 +1,18 @@
1
+ <?xml version="1.0" encoding="utf-8"?>
2
+ <!-- Generator: Adobe Illustrator 16.0.1, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
3
+ <!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
4
+ <svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
5
+ width="512px" height="512px" viewBox="0 0 512 512" enable-background="new 0 0 512 512" xml:space="preserve">
6
+ <rect x="36.099" y="38.191" fill="none" width="315.603" height="81.561"/>
7
+ <text transform="matrix(1 0 0 1 36.0991 46.7114)" font-family="Times-Roman" font-size="12">This is text.</text>
8
+ <rect x="64.468" y="150.958" width="388.653" height="217.73"/>
9
+ <ellipse cx="408.794" cy="70.815" rx="50" ry="40.426"/>
10
+ <path fill="none" stroke="#000000" stroke-miterlimit="10" d="M38.227,470.815c6.44-0.065,15.535-9.021,21.418-12.693
11
+ c6.953-4.341,13.845-8.825,21.053-12.727c5.535-2.996,10.906-6.181,16.439-9.268c15.529-8.663,31.347-18.944,48.918-22.714
12
+ c23.515-5.045,43.482,5.131,64.337,15.289c23.698,11.544,49.37,20.606,74.562,28.339c13.407,4.114,27.689,6.4,41.493,8.75
13
+ c8.428,1.436,18.973,3.184,27.465,1.138c10.279-2.477,18.574-9.314,18.354-19.743c-0.188-8.983-3.396-8.358-12.09-10.413
14
+ c-11.992-2.835-24.74-2.666-37.025-2.873c-9.05-0.153-20.566-1.762-29.433,0.482c-9.373,2.373-19.335,10.153-28.136,14.442
15
+ c-24.092,11.74-100.578,58.046-102.618,2.968c-0.664-17.918,7.171-26.632,23.594-32.243c6.103-2.085,12.434-3.259,18.823-3.895
16
+ c12.763-1.271,24.397-4.426,36.986-6.812c46.81-8.874,97.575-3.984,144.94-3.984c19.207,0,39.672,2.03,58.808,0.034
17
+ c3.216-0.336,5.914-0.364,8.423-2.162"/>
18
+ </svg>
@@ -0,0 +1,25 @@
1
+ #
2
+ # Copyright 2013 (c) John Colanduoni
3
+ #
4
+ # Permission is hereby granted, free of charge, to any person obtaining
5
+ # a copy of this software and associated documentation files (the
6
+ # "Software"), to deal in the Software without restriction, including
7
+ # without limitation the rights to use, copy, modify, merge, publish,
8
+ # distribute, sublicense, and/or sell copies of the Software, and to
9
+ # permit persons to whom the Software is furnished to do so, subject to
10
+ # the following conditions:
11
+ #
12
+ # The above copyright notice and this permission notice shall be
13
+ # included in all copies or substantial portions of the Software.
14
+ #
15
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16
+ # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17
+ # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
18
+ # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
19
+ # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
20
+ # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
21
+ # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22
+ #
23
+
24
+ //= require jquery
25
+ //= require novector
@@ -0,0 +1,13 @@
1
+ /*
2
+ * This is a manifest file that'll be compiled into application.css, which will include all the files
3
+ * listed below.
4
+ *
5
+ * Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
6
+ * or vendor/assets/stylesheets of plugins, if any, can be referenced here using a relative path.
7
+ *
8
+ * You're free to add application-wide styles to this file and they'll appear at the top of the
9
+ * compiled file, but it's generally better to create a new file per style scope.
10
+ *
11
+ *= require_self
12
+ *= require_tree .
13
+ */
@@ -0,0 +1,28 @@
1
+ #
2
+ # Copyright 2013 (c) John Colanduoni
3
+ #
4
+ # Permission is hereby granted, free of charge, to any person obtaining
5
+ # a copy of this software and associated documentation files (the
6
+ # "Software"), to deal in the Software without restriction, including
7
+ # without limitation the rights to use, copy, modify, merge, publish,
8
+ # distribute, sublicense, and/or sell copies of the Software, and to
9
+ # permit persons to whom the Software is furnished to do so, subject to
10
+ # the following conditions:
11
+ #
12
+ # The above copyright notice and this permission notice shall be
13
+ # included in all copies or substantial portions of the Software.
14
+ #
15
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16
+ # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17
+ # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
18
+ # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
19
+ # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
20
+ # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
21
+ # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22
+ #
23
+
24
+ class ApplicationController < ActionController::Base
25
+ # Prevent CSRF attacks by raising an exception.
26
+ # For APIs, you may want to use :null_session instead.
27
+ protect_from_forgery with: :exception
28
+ end
@@ -0,0 +1,27 @@
1
+ #
2
+ # Copyright 2013 (c) John Colanduoni
3
+ #
4
+ # Permission is hereby granted, free of charge, to any person obtaining
5
+ # a copy of this software and associated documentation files (the
6
+ # "Software"), to deal in the Software without restriction, including
7
+ # without limitation the rights to use, copy, modify, merge, publish,
8
+ # distribute, sublicense, and/or sell copies of the Software, and to
9
+ # permit persons to whom the Software is furnished to do so, subject to
10
+ # the following conditions:
11
+ #
12
+ # The above copyright notice and this permission notice shall be
13
+ # included in all copies or substantial portions of the Software.
14
+ #
15
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16
+ # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17
+ # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
18
+ # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
19
+ # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
20
+ # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
21
+ # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22
+ #
23
+
24
+ class NovectorJsTestController < ApplicationController
25
+ def test_fallback
26
+ end
27
+ end
@@ -0,0 +1,25 @@
1
+ #
2
+ # Copyright 2013 (c) John Colanduoni
3
+ #
4
+ # Permission is hereby granted, free of charge, to any person obtaining
5
+ # a copy of this software and associated documentation files (the
6
+ # "Software"), to deal in the Software without restriction, including
7
+ # without limitation the rights to use, copy, modify, merge, publish,
8
+ # distribute, sublicense, and/or sell copies of the Software, and to
9
+ # permit persons to whom the Software is furnished to do so, subject to
10
+ # the following conditions:
11
+ #
12
+ # The above copyright notice and this permission notice shall be
13
+ # included in all copies or substantial portions of the Software.
14
+ #
15
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16
+ # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17
+ # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
18
+ # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
19
+ # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
20
+ # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
21
+ # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22
+ #
23
+
24
+ module ApplicationHelper
25
+ end