jekyll-swfobject 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.
- checksums.yaml +15 -0
- data/.gitignore +6 -0
- data/Gemfile +4 -0
- data/History.md +9 -0
- data/LICENSE.txt +22 -0
- data/README.md +160 -0
- data/Rakefile +12 -0
- data/jekyll-swfobject.gemspec +29 -0
- data/lib/jekyll-swfobject.rb +175 -0
- data/lib/jekyll-swfobject/version.rb +5 -0
- data/test/test_helper.rb +72 -0
- data/test/test_swfobject_tag_attributes.rb +604 -0
- data/test/test_swfobject_tag_config.rb +503 -0
- metadata +144 -0
checksums.yaml
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
---
|
2
|
+
!binary "U0hBMQ==":
|
3
|
+
metadata.gz: !binary |-
|
4
|
+
ZDYwOWMyNjFhMzZmZmQ2Njc5NDg5MTljMDA0ZGZjYjkzMjllZmY2NA==
|
5
|
+
data.tar.gz: !binary |-
|
6
|
+
MmQ2NmQ0MDA5MjIyMGNiNDIxN2MxMGY1MjY0MDM1MDVkMjczODQ0MQ==
|
7
|
+
!binary "U0hBNTEy":
|
8
|
+
metadata.gz: !binary |-
|
9
|
+
ZjdlNTdmYjVlMGY3NjJmNGU2NzRkZmI5MGFlYjBiMDI1YzIyNDQxOTQ0MTVl
|
10
|
+
ZWNmYTAzZWU2YWU0ZWJlMGVmMjdkNzIyZmYxMDc3OWE1OWMzNWY5YWNiMjE3
|
11
|
+
MzBkNGEyNDA3ZWJjYTI4ZTY4ZDgzNzE0YjYzNTIwNDMzMGE0YjI=
|
12
|
+
data.tar.gz: !binary |-
|
13
|
+
NDZmNzc5ZDlkOWJmOWRhN2FlMmE1ODBkOWRmZTg1OTM4YmViYzYzNjgxMjMz
|
14
|
+
OGM4OWYwNTI5MDYzMzUyODI0MDEwZWIyNjI4NTg1OTAxZTMxZDk2MzUzZDIx
|
15
|
+
ODlkYTYzZDc3OTQ0OTA1ZWJkNmVmMGU3YmUzMGEwYmY0MWM1MjQ=
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/History.md
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2013 "sectore" Jens Krause // [WEBSECTOR.DE](http://websector.de)
|
2
|
+
|
3
|
+
MIT License
|
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.
|
data/README.md
ADDED
@@ -0,0 +1,160 @@
|
|
1
|
+
# Jekyll Plugin: SWFObject Tag
|
2
|
+
|
3
|
+
SWFObject Tag is a [Liquid](http://www.liquidmarkup.org/) plugin for [Jekyll](http://jekyllrb.com/) to embed Flash files (*.swf) using [SWFObject](http://code.google.com/p/swfobject/)
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
1 Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
gem 'jekyll-swfobject'
|
10
|
+
|
11
|
+
And then execute:
|
12
|
+
|
13
|
+
$ bundle
|
14
|
+
|
15
|
+
Or install it yourself as:
|
16
|
+
|
17
|
+
$ gem install jekyll-swfobject
|
18
|
+
|
19
|
+
|
20
|
+
2. Link SWFObject in your layout template or page within `<head>` or before `{% swfobject %}` :
|
21
|
+
|
22
|
+
`<script src="//ajax.googleapis.com/ajax/libs/swfobject/2.2/swfobject.js"></script>`
|
23
|
+
|
24
|
+
|
25
|
+
## Usage
|
26
|
+
|
27
|
+
### Tag
|
28
|
+
{% swfobject swf_url %}{% endswfobject %}
|
29
|
+
Note: Because SWFObject Tag is a `Liquid::Block`, you have to close any `{% swfobject %}` with `{% endswfobject %}` in your templates.
|
30
|
+
|
31
|
+
#### Optional parameters
|
32
|
+
|
33
|
+
All optional parameters are defined using `key:value` pairs.
|
34
|
+
|
35
|
+
{% swfobject swf_url id:myFlash content_id:flashcontent width:500 height:600 %}{% endswfobject %}
|
36
|
+
|
37
|
+
Note: Don't use whitespaces between `:` to avoid issues rendering templates.
|
38
|
+
|
39
|
+
For all optional parameters check section [Parameters](#parameters) below.
|
40
|
+
|
41
|
+
|
42
|
+
#### Alternative HTML content
|
43
|
+
|
44
|
+
{% swfobject swf_url %}
|
45
|
+
<p>Latest <a href='http://www.adobe.com/go/getflashplayer'>Flash Player Plugin</a> is required.</p>
|
46
|
+
{% endswfobject %}
|
47
|
+
|
48
|
+
#### Optional parameters defined in `_config.yml`
|
49
|
+
|
50
|
+
|
51
|
+
swfobject:
|
52
|
+
height: 350
|
53
|
+
width: 200
|
54
|
+
express_install_url: expressInstall.swf
|
55
|
+
alternative_content: <p>Please install latest <a href='http://www.adobe.com/go/getflashplayer'>Flash Player Plugin</a>.</p>
|
56
|
+
|
57
|
+
For all optional parameters check section [Parameters](#parameters) below.
|
58
|
+
|
59
|
+
|
60
|
+
## Parameters
|
61
|
+
|
62
|
+
### Required parameter
|
63
|
+
|
64
|
+
`swf_url` - Path to SWF, which has to be embedded
|
65
|
+
|
66
|
+
### Optional parameters
|
67
|
+
|
68
|
+
All optional parameters can be defined within `{% swfobject %}` and / or using `_config.yml`.
|
69
|
+
Parameters defined in `_config.yml` will be overridden by tag parameters.
|
70
|
+
|
71
|
+
`content_id` - Id of the div container, which will be replaced by SWFObject to embed SWF
|
72
|
+
|
73
|
+
`height` - Height (`px`, `%`, `em` or `rem`) of the embedded SWF and of the surrounded `<div>` (default: 100%)
|
74
|
+
|
75
|
+
`width` - Width (`px`, `%`, `em` or `rem`) of the embedded SWF and of the surrounded `<div>` (default: 100%).
|
76
|
+
|
77
|
+
Note: For a better support of fluid and responsive layouts using `em`, `rem` etc. the plugin creates an extra `div`,
|
78
|
+
which wrappes the generated `<object>` tag. This wrapper `div` will be sized using values of `height` and `width`.
|
79
|
+
The wrapper can be addressed by using the `content_id` + `-wrapper`, e.g. `flashcontent-wrapper`.
|
80
|
+
|
81
|
+
`version` - Version of the Flash Player Plugin (default: 10.0)
|
82
|
+
|
83
|
+
`flashvars` - String of flashvars using `key=value` pairs combinend with `&`, e.g. `name1=hello&name2=world`
|
84
|
+
|
85
|
+
`express_install_url` - URL of the expressInstall.swf
|
86
|
+
|
87
|
+
`callback_function` - Callback function to check success or failure of creating a Flash plug-in `<object>`
|
88
|
+
|
89
|
+
|
90
|
+
#### Optional Attributes of the `<object>` element
|
91
|
+
|
92
|
+
`id`
|
93
|
+
|
94
|
+
`align`
|
95
|
+
|
96
|
+
`name`
|
97
|
+
|
98
|
+
`styleclass`
|
99
|
+
|
100
|
+
For detailed information check SWF Object documentation: http://code.google.com/p/swfobject/wiki/documentation
|
101
|
+
|
102
|
+
#### Optional Flash specific parameters
|
103
|
+
|
104
|
+
`play`
|
105
|
+
|
106
|
+
`loop`
|
107
|
+
|
108
|
+
`menu`
|
109
|
+
|
110
|
+
`quality`
|
111
|
+
|
112
|
+
`scale`
|
113
|
+
|
114
|
+
`salign`
|
115
|
+
|
116
|
+
`wmode`
|
117
|
+
|
118
|
+
`bgcolor`
|
119
|
+
|
120
|
+
`base`
|
121
|
+
|
122
|
+
`swliveconnect`
|
123
|
+
|
124
|
+
`devicefont`
|
125
|
+
|
126
|
+
`allowscriptaccess`
|
127
|
+
|
128
|
+
`seamlesstabbing`
|
129
|
+
|
130
|
+
`allowfullscreen`
|
131
|
+
|
132
|
+
`allownetworking`
|
133
|
+
|
134
|
+
For detailed information check SWF Object documentation: http://code.google.com/p/swfobject/wiki/documentation
|
135
|
+
|
136
|
+
## Live example
|
137
|
+
|
138
|
+
SWFObject Tag is used by the Jekyll generated website [WEBSECTOR.DE](http://websector.de). You will find the [source](https://github.com/sectore/websector.de) of WEBSECTOR.DE [here](https://github.com/sectore/websector.de) at GitHub.
|
139
|
+
|
140
|
+
## Test
|
141
|
+
|
142
|
+
The plugin is well tested using [Test::Unit](http://www.ruby-doc.org/core/classes/Test/Unit.html) with [Shoulda](https://github.com/thoughtbot/shoulda) and [Mocha](http://gofreerange.com/mocha/). To start tests just run
|
143
|
+
|
144
|
+
rake test
|
145
|
+
|
146
|
+
|
147
|
+
|
148
|
+
## Contributing
|
149
|
+
|
150
|
+
1. Fork it
|
151
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
152
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
153
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
154
|
+
5. Create new Pull Request
|
155
|
+
|
156
|
+
## License
|
157
|
+
|
158
|
+
Copyright (c) 2013 "sectore" Jens Krause // [WEBSECTOR.DE](http://websector.de)
|
159
|
+
|
160
|
+
SWFObject Tag is free software and it may be redistributed under the terms specified in the MIT-LICENSE file.
|
data/Rakefile
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require "jekyll-swfobject/version"
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "jekyll-swfobject"
|
8
|
+
spec.version = Jekyll::SWFObject::VERSION
|
9
|
+
spec.authors = ["Jens Krause"]
|
10
|
+
spec.email = ["info@websector.de"]
|
11
|
+
spec.description = %q{Liquid plugin for using SWFObject with Jekyll}
|
12
|
+
spec.summary = %q{SWFObject Tag is a Liquid plugin for Jekyll to embed Flash files (*.swf) using SWFObject}
|
13
|
+
spec.homepage = "https://github.com/sectore/jekyll-swfobject"
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.required_ruby_version = '>= 1.9.3'
|
17
|
+
|
18
|
+
spec.files = `git ls-files`.split($/)
|
19
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
20
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
21
|
+
spec.require_paths = ["lib"]
|
22
|
+
|
23
|
+
spec.add_runtime_dependency "jekyll", "~> 1.0.3"
|
24
|
+
spec.add_development_dependency("bundler", "~> 1.3")
|
25
|
+
spec.add_development_dependency("rake")
|
26
|
+
spec.add_development_dependency("shoulda", "~> 3.5")
|
27
|
+
spec.add_development_dependency("shoulda-context", "~> 1.0")
|
28
|
+
spec.add_development_dependency("mocha", ">= 0.14")
|
29
|
+
end
|
@@ -0,0 +1,175 @@
|
|
1
|
+
# SWFObject Tag
|
2
|
+
# is a Jekyll plugin to embed Flash files (*.swf) using SWFObject http://code.google.com/p/swfobject/
|
3
|
+
#
|
4
|
+
# Example:
|
5
|
+
#
|
6
|
+
# {% swfobject swf_url %}{% endswfobject %}
|
7
|
+
# or
|
8
|
+
# {% swfobject swf_url id:swfID content_id:flashcontent width:500px height:600px %}{% endswfobject %}
|
9
|
+
# or
|
10
|
+
# {% swfobject swf_url %}
|
11
|
+
# <p>Alternative HTML content, e.g. Latest <a href='http://www.adobe.com/go/getflashplayer'>Flash Player Plugin</a> is required.</p>
|
12
|
+
# {% endswfobject %}
|
13
|
+
#
|
14
|
+
# Full documentation:
|
15
|
+
# https://github.com/sectore/jekyll-swfobject/blob/master/README.md
|
16
|
+
#
|
17
|
+
# Author: Jens Krause http://websector.de
|
18
|
+
# Source: https://github.com/sectore/jekyll-swfobject
|
19
|
+
# License: MIT
|
20
|
+
|
21
|
+
module Jekyll
|
22
|
+
module SWFObject
|
23
|
+
class SWFObjectTag < Liquid::Block
|
24
|
+
|
25
|
+
#
|
26
|
+
# constants
|
27
|
+
#
|
28
|
+
@@ATTRIBUTES = %w(
|
29
|
+
id align name styleclass
|
30
|
+
)
|
31
|
+
|
32
|
+
@@PARAMETERS = %w(
|
33
|
+
play loop menu quality scale salign wmode bgcolor base
|
34
|
+
swliveconnect devicefont allowscriptaccess seamlesstabbing allowfullscreen allownetworking
|
35
|
+
)
|
36
|
+
|
37
|
+
@@DEFAULTS = {
|
38
|
+
:content_id => 'flashcontent',
|
39
|
+
:width => '100%',
|
40
|
+
:height => '100%',
|
41
|
+
:version => '10.0',
|
42
|
+
:flashvars => '',
|
43
|
+
:alternative_content => "<p>Please install latest <a href='http://www.adobe.com/go/getflashplayer'>Flash Player Plugin</a>.</p>"
|
44
|
+
}
|
45
|
+
|
46
|
+
def self.DEFAULTS
|
47
|
+
return @@DEFAULTS
|
48
|
+
end
|
49
|
+
|
50
|
+
def initialize(tag_name, text, tokens)
|
51
|
+
super
|
52
|
+
|
53
|
+
@config = {}
|
54
|
+
# set defaults
|
55
|
+
override_config(@@DEFAULTS)
|
56
|
+
|
57
|
+
# override configuration with values defined within _config.yml
|
58
|
+
if Jekyll.configuration({}).has_key?('swfobject')
|
59
|
+
config = Jekyll.configuration({})['swfobject']
|
60
|
+
override_config(config)
|
61
|
+
end
|
62
|
+
|
63
|
+
params = text.split
|
64
|
+
|
65
|
+
# first argument (required) is url of swf
|
66
|
+
@swf_url = params.shift.strip
|
67
|
+
|
68
|
+
if params.size > 0
|
69
|
+
# override configuration with parameters defined within {% swfobject pathToSWF %}
|
70
|
+
config = {} # reset local config
|
71
|
+
params.each do |param|
|
72
|
+
param = param.gsub /\s+/, '' # remove whitespaces
|
73
|
+
key, value = param.split(':',2) # split first occurrence of ':' only
|
74
|
+
config[key.to_sym] = value
|
75
|
+
end
|
76
|
+
override_config(config)
|
77
|
+
end
|
78
|
+
|
79
|
+
end
|
80
|
+
|
81
|
+
def override_config(config)
|
82
|
+
config.each{ |key,value| @config[key] = value }
|
83
|
+
end
|
84
|
+
|
85
|
+
def render(context)
|
86
|
+
output = super
|
87
|
+
|
88
|
+
<<-HTML.gsub /^\s+/, '' # remove whitespaces from heredocs
|
89
|
+
<div id="#{@config[:content_id]}-wrapper" style="width: #{@config[:width]}; height: #{@config[:height]}">
|
90
|
+
<div id="#{@config[:content_id]}" style="width: 100%; height:100%">#{render_alternative_content(output)}</div>
|
91
|
+
</div>
|
92
|
+
<script type="text/javascript">
|
93
|
+
// <![CDATA[
|
94
|
+
#{render_flashvars()}
|
95
|
+
#{render_params()}
|
96
|
+
#{render_attributes()}
|
97
|
+
swfobject.embedSWF(
|
98
|
+
'#{@swf_url}',
|
99
|
+
'#{@config[:content_id]}',
|
100
|
+
'100%',
|
101
|
+
'100%',
|
102
|
+
'#{@config[:version]}',
|
103
|
+
#{render_express_install_url()},
|
104
|
+
flashvars,
|
105
|
+
params,
|
106
|
+
attributes,
|
107
|
+
#{render_callback_function()}
|
108
|
+
);
|
109
|
+
// ]]>
|
110
|
+
</script>
|
111
|
+
HTML
|
112
|
+
end
|
113
|
+
|
114
|
+
def render_alternative_content(output)
|
115
|
+
unless output.strip.size > 0
|
116
|
+
output = @config[:alternative_content]
|
117
|
+
end
|
118
|
+
output
|
119
|
+
end
|
120
|
+
|
121
|
+
def render_params
|
122
|
+
result = 'var params = {'
|
123
|
+
@config.each do |key, value|
|
124
|
+
if @@PARAMETERS.include?(key.to_s)
|
125
|
+
result += "#{key}:'#{value}',"
|
126
|
+
end
|
127
|
+
end
|
128
|
+
result = remove_last_comma(result)
|
129
|
+
result += '};'
|
130
|
+
end
|
131
|
+
|
132
|
+
def render_attributes
|
133
|
+
result = 'var attributes = {'
|
134
|
+
@config.each do |key, value|
|
135
|
+
if @@ATTRIBUTES.include?(key.to_s)
|
136
|
+
result += "#{key}:'#{value}',"
|
137
|
+
end
|
138
|
+
end
|
139
|
+
result = remove_last_comma(result)
|
140
|
+
result += '};'
|
141
|
+
end
|
142
|
+
|
143
|
+
def render_flashvars
|
144
|
+
result = 'var flashvars = {'
|
145
|
+
|
146
|
+
if !@config[:flashvars].nil?
|
147
|
+
vars = @config[:flashvars].split('&')
|
148
|
+
vars.each do |var|
|
149
|
+
key_value = var.split('=',2) # split first occurrence of '=' only
|
150
|
+
key = key_value.first
|
151
|
+
value = key_value.last
|
152
|
+
result += "#{key}:'#{value}',"
|
153
|
+
end
|
154
|
+
result = remove_last_comma(result)
|
155
|
+
end
|
156
|
+
result += '};'
|
157
|
+
end
|
158
|
+
|
159
|
+
def render_express_install_url
|
160
|
+
@config[:express_install_url] ? "'#{@config[:express_install_url]}'" : 'null'
|
161
|
+
end
|
162
|
+
|
163
|
+
def render_callback_function
|
164
|
+
@config[:callback_function] ? "#{@config[:callback_function]}" : 'null'
|
165
|
+
end
|
166
|
+
|
167
|
+
def remove_last_comma(content)
|
168
|
+
content.gsub(/,?$/, '')
|
169
|
+
end
|
170
|
+
|
171
|
+
end
|
172
|
+
end
|
173
|
+
end
|
174
|
+
|
175
|
+
Liquid::Template.register_tag('swfobject', Jekyll::SWFObject::SWFObjectTag)
|