jekyll-svg-plugin 1.0.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.
@@ -0,0 +1,2 @@
1
+ === 1.0.0 (2010-8-14)
2
+ * Initial release.
@@ -0,0 +1,6 @@
1
+ History.rdoc
2
+ Manifest.txt
3
+ README.rdoc
4
+ Rakefile
5
+ lib/jekyll-svg-plugin/base.rb
6
+ lib/jekyll-svg-plugin.rb
@@ -0,0 +1,66 @@
1
+ = jekyll-svg-plugin
2
+
3
+ * http://github.com/dekellum/jekyll-svg-plugin
4
+
5
+ == Description
6
+
7
+ A plugin for adding an SVG liquid tag to Jekyll. This tag expands and
8
+ SVG reference to object with dimensions obtains from an associated PNG
9
+ file.
10
+
11
+ == Usage
12
+
13
+ Add the following to the file _plugin/svg.rb in your Jekyll site tree:
14
+
15
+ require 'jekyll-svg-plugin'
16
+
17
+ Then you can include an SVG reference HTML object via liquid tag:
18
+
19
+ {% svg svg/mygraph.svg %}
20
+
21
+ Note that both an *.svg and *.png are expected at the specified
22
+ location. The later is used as a fallback and also to obtain
23
+ dimensions (via imagesize gem, pure ruby) from the png file.
24
+
25
+ I typically use Graphviz dot to generate my SVG/PNG graphs, with a Rakefile like this:
26
+
27
+ directory 'svg'
28
+
29
+ FileList[ '_dot/*.dot' ].each do |dot|
30
+ svg = dot.sub( /(\.dot)$/, '.svg' ).sub( /^(_dot)/, 'svg' )
31
+ png = dot.sub( /(\.dot)$/, '.png' ).sub( /^(_dot)/, 'svg' )
32
+
33
+ file svg => [ dot, 'svg' ] do
34
+ sh "dot -Tsvg -o #{svg} #{dot}"
35
+ end
36
+
37
+ file png => [ dot, 'svg' ] do
38
+ sh "dot -Tpng -o #{png} #{dot}"
39
+ end
40
+
41
+ task :dot => [ svg, png ]
42
+ end
43
+
44
+ == License
45
+
46
+ Copyright (c) 2010 David Kellum
47
+ All rights reserved.
48
+
49
+ Permission is hereby granted, free of charge, to any person obtaining
50
+ a copy of this software and associated documentation files (the
51
+ "Software"), to deal in the Software without restriction, including
52
+ without limitation the rights to use, copy, modify, merge, publish,
53
+ distribute, sublicense, and/or sell copies of the Software, and to
54
+ permit persons to whom the Software is furnished to do so, subject to
55
+ the following conditions:
56
+
57
+ The above copyright notice and this permission notice shall be
58
+ included in all copies or substantial portions of the Software.
59
+
60
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
61
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
62
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
63
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
64
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
65
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
66
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,30 @@
1
+ # -*- ruby -*-
2
+
3
+ $LOAD_PATH << './lib'
4
+ require 'jekyll-svg-plugin/base'
5
+
6
+ require 'rubygems'
7
+ gem 'rjack-tarpit', '~> 1.2.2'
8
+ require 'rjack-tarpit'
9
+
10
+ t = RJack::TarPit.new( 'jekyll-svg-plugin', JekyllSVGPlugin::VERSION )
11
+
12
+ t.specify do |h|
13
+ h.developer( 'David Kellum', 'dek-oss@gravitext.com' )
14
+ h.extra_deps << [ 'imagesize', '>= 0.1.1' ]
15
+ end
16
+
17
+ task :check_history_version do
18
+ t.test_line_match( 'History.rdoc', /^==/, / #{ t.version } / )
19
+ end
20
+ task :check_history_date do
21
+ t.test_line_match( 'History.rdoc', /^==/, /\([0-9\-]+\)$/ )
22
+ end
23
+
24
+ task :gem => [ :check_history_version, ]
25
+ task :tag => [ :check_history_version, :check_history_date ]
26
+ task :push => [ :check_history_version, :check_history_date ]
27
+
28
+ task :test #noop
29
+
30
+ t.define_tasks
@@ -0,0 +1,57 @@
1
+ #--
2
+ # Copyright (c) 2010 David Kellum
3
+ # All rights reserved.
4
+ #
5
+ # Permission is hereby granted, free of charge, to any person obtaining
6
+ # a copy of this software and associated documentation files (the
7
+ # "Software"), to deal in the Software without restriction, including
8
+ # without limitation the rights to use, copy, modify, merge, publish,
9
+ # distribute, sublicense, and/or sell copies of the Software, and to
10
+ # permit persons to whom the Software is furnished to do so, subject to
11
+ # the following conditions:
12
+ #
13
+ # The above copyright notice and this permission notice shall be
14
+ # included in all copies or substantial portions of the Software.
15
+ #
16
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23
+ #++
24
+
25
+ require 'jekyll-svg-plugin/base'
26
+
27
+ # FIXME: Should create a bug to get this added to jekyll
28
+ require 'webrick'
29
+ mime_types = WEBrick::HTTPUtils::DefaultMimeTypes
30
+ mime_types.store 'svg', 'image/svg+xml'
31
+
32
+ require 'image_size'
33
+ module Jekyll
34
+
35
+ class SvgTag < Liquid::Tag
36
+ def initialize( tag_name, svg, tokens )
37
+ super
38
+ @svg = svg.strip
39
+ end
40
+
41
+ def render(context)
42
+ png = @svg.sub( /(\.svg)$/, '.png' )
43
+ w,h = open( png, 'rb' ) do |fpng|
44
+ ImageSize.new( fpng.read ).get_size
45
+ end
46
+ <<END
47
+ <div class="svg-object">
48
+ <object data="#{@svg}" type="image/svg+xml" width="#{w}" height="#{h}">
49
+ <img src="#{png}" width="#{w}" height="#{h}">
50
+ </object>
51
+ </div>
52
+ END
53
+ end
54
+ end
55
+ end
56
+
57
+ Liquid::Template.register_tag('svg', Jekyll::SvgTag)
@@ -0,0 +1,27 @@
1
+ #--
2
+ # Copyright (c) 2010 David Kellum
3
+ # All rights reserved.
4
+ #
5
+ # Permission is hereby granted, free of charge, to any person obtaining
6
+ # a copy of this software and associated documentation files (the
7
+ # "Software"), to deal in the Software without restriction, including
8
+ # without limitation the rights to use, copy, modify, merge, publish,
9
+ # distribute, sublicense, and/or sell copies of the Software, and to
10
+ # permit persons to whom the Software is furnished to do so, subject to
11
+ # the following conditions:
12
+ #
13
+ # The above copyright notice and this permission notice shall be
14
+ # included in all copies or substantial portions of the Software.
15
+ #
16
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23
+ #++
24
+
25
+ module JekyllSVGPlugin
26
+ VERSION='1.0.0'
27
+ end
metadata ADDED
@@ -0,0 +1,110 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: jekyll-svg-plugin
3
+ version: !ruby/object:Gem::Version
4
+ hash: 23
5
+ prerelease: false
6
+ segments:
7
+ - 1
8
+ - 0
9
+ - 0
10
+ version: 1.0.0
11
+ platform: ruby
12
+ authors:
13
+ - David Kellum
14
+ autorequire:
15
+ bindir: bin
16
+ cert_chain: []
17
+
18
+ date: 2010-08-14 00:00:00 -07:00
19
+ default_executable:
20
+ dependencies:
21
+ - !ruby/object:Gem::Dependency
22
+ name: imagesize
23
+ prerelease: false
24
+ requirement: &id001 !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ">="
28
+ - !ruby/object:Gem::Version
29
+ hash: 25
30
+ segments:
31
+ - 0
32
+ - 1
33
+ - 1
34
+ version: 0.1.1
35
+ type: :runtime
36
+ version_requirements: *id001
37
+ - !ruby/object:Gem::Dependency
38
+ name: rjack-tarpit
39
+ prerelease: false
40
+ requirement: &id002 !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ~>
44
+ - !ruby/object:Gem::Version
45
+ hash: 27
46
+ segments:
47
+ - 1
48
+ - 2
49
+ - 2
50
+ version: 1.2.2
51
+ type: :development
52
+ version_requirements: *id002
53
+ description: |-
54
+ A plugin for adding an SVG liquid tag to Jekyll. This tag expands and
55
+ SVG reference to object with dimensions obtains from an associated PNG
56
+ file.
57
+ email:
58
+ - dek-oss@gravitext.com
59
+ executables: []
60
+
61
+ extensions: []
62
+
63
+ extra_rdoc_files:
64
+ - Manifest.txt
65
+ - History.rdoc
66
+ - README.rdoc
67
+ files:
68
+ - History.rdoc
69
+ - Manifest.txt
70
+ - README.rdoc
71
+ - Rakefile
72
+ - lib/jekyll-svg-plugin/base.rb
73
+ - lib/jekyll-svg-plugin.rb
74
+ has_rdoc: true
75
+ homepage: http://github.com/dekellum/jekyll-svg-plugin
76
+ licenses: []
77
+
78
+ post_install_message:
79
+ rdoc_options:
80
+ - --main
81
+ - README.rdoc
82
+ require_paths:
83
+ - lib
84
+ required_ruby_version: !ruby/object:Gem::Requirement
85
+ none: false
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ hash: 3
90
+ segments:
91
+ - 0
92
+ version: "0"
93
+ required_rubygems_version: !ruby/object:Gem::Requirement
94
+ none: false
95
+ requirements:
96
+ - - ">="
97
+ - !ruby/object:Gem::Version
98
+ hash: 3
99
+ segments:
100
+ - 0
101
+ version: "0"
102
+ requirements: []
103
+
104
+ rubyforge_project: jekyll-svg-plugin
105
+ rubygems_version: 1.3.7
106
+ signing_key:
107
+ specification_version: 3
108
+ summary: A plugin for adding an SVG liquid tag to Jekyll
109
+ test_files: []
110
+