2 # ====================[ flashbox.pl ]====================
6 flashbox - An Oddmuse module for embedding offsite-hosted Flash videos within
7 an Oddmuse Wiki page - especially those hosted by Google Videos,
8 YouTube, and SlideShare.
12 flashbox is easily installable: move this file into the B<wiki/modules/>
13 directory of your Oddmuse Wiki.
18 $ModulesDescription .= '<p><a href="http://git.savannah.gnu.org/cgit/oddmuse.git/tree/modules/flashbox.pl">flashbox.pl</a>, see <a href="http://www.oddmuse.org/cgi-bin/oddmuse/Flashbox_Extension">Flashbox Extension</a></p>';
20 # ....................{ CONFIGURATION }....................
24 flashbox is easily configurable: set these variables in the B<wiki/config.pl>
25 file for your Oddmuse Wiki.
28 use vars
qw($FlashboxWidth
33 The width of the HTML object "frame" for Flash videos, in pixels.
35 The default value for this variable is (usually) fine.
40 =head2 $FlashboxHeight
42 The height of the HTML object "frame" for Flash videos, in pixels. For any
43 specific width, a height roughly 83.33% of that width tends to provide a
44 respectable frame for viewing Flash videos.
46 The default value for this variable is (usually) fine.
49 $FlashboxHeight = 350;
51 # ....................{ MARKUP }....................
55 flashbox provides a few new markup rules. These are:
59 =item [[GoogleVideo:${GoogleVideoID}]]
63 =item Embeds the Google Video uniquely identified by ${GoogleVideoID} into the
64 Oddmuse Wiki page, where ${GoogleVideoID} is the signed integer
65 following the "docID" parameter in the Google Video URL for that video;
66 for example, [[GoogleVideo:8649250863235826256]] embeds Derrick Jensen's
67 "Endgame: Part I" Google Video into the Oddmuse Wiki page.
71 =item [[YouTube:${YouTubeVideoID}]]
75 =item Embeds the YouTube video uniquely identified by ${YouTubeVideoID} into the
76 Oddmuse Wiki page, where ${YouTubeVideoID} is the string following the
77 "watch?v" parameter in the YouTube URL for that video; for example,
78 [[YouTube:Q1ZeXnmDZMQ]] embeds James Howard Kunstler's "The Tragedy of
79 Suburbia TED Talk" YouTube video into the Oddmuse Wiki page.
83 =item [[SlideShare:${SlideSharePresentationID}]]
87 =item Embeds the SlideShare presentation uniquely identified by
88 ${SlideSharePresentationID} into the Oddmuse Wiki page, where
89 ${SlideSharePresentationID} is a string composed of the title for that
90 presentation and an arbitrary signed integer. Unfortunately, this string
91 is more difficult to obtain than for Google Video and YouTube; for any
92 given presentation, see the small "Embed" box on that presentation's
93 SlideShare page and the string following the "doc" parameter in that
95 [[SlideShare:the-tyranny-of-human-civilization-13479]] embeds
96 huer1278ft's "The Tyranny of Human Civilization" SlideShare presentation
97 into the Oddmuse Wiki page.
104 push(@MyRules, \&FlashboxRule);
106 # "FlashboxRule" conflicts with "CreoleRule"-style interpretation of "[[...]]"
107 # syntax; and must, thus, be applied before that rule.
108 $RuleOrder{\&FlashboxRule} = -11;
111 if (/\G\[\[googlevideo:([0-9-]+)\]\]/cgi) {
112 return FlashboxHtml('googlevideo',
113 "http://video.google.com/googleplayer.swf?docId=${1}&hl=en");
115 elsif (/\G\[\[slideshare:([a-z0-9-]+)\]\]/cgi) {
116 return FlashboxHtml('slideshare',
117 "http://static.slideshare.net/swf/ssplayer2.swf?doc=${1}");
119 elsif (/\G\[\[youtube:([a-z0-9-_]{11})\]\]/cgi) {
120 return FlashboxHtml('youtube',
121 "http://www.youtube.com/v/${1}");
127 my ($paragraph_class, $flashbox_url) = @_;
130 ? CloseHtmlEnvironments().AddHtmlEnvironment('p', qq~class="flashbox ${paragraph_class}"~)
132 <object width="${FlashboxWidth}" height="${FlashboxHeight}">
133 <param name="movie" value="${flashbox_url}"/>
134 <param name="pluginurl" value="http://www.macromedia.com/go/getflashplayer"/>
135 <param name="quality" value="high"/>
136 <param name="wmode" value="transparent"/>
137 <param name="allowFullScreen" value="true"/>
138 <param name="allowScriptAccess" value="always"/>
139 <embed type="application/x-shockwave-flash"
140 width="${FlashboxWidth}" height="${FlashboxHeight}"
141 src="${flashbox_url}"
143 allowscriptaccess="always" allowfullscreen="true"/>
149 flashbox also provides a few new HTML classes for CSS-stylizing the HTML emitted
150 by these markup rules. Of necessity, flashbox embeds Flash videos in an
151 "<object>...</object>" HTML tag-set; technically, therefore, you can stylize
152 such videos with a CSS selector resembling:
154 # This CSS selector selects all HTML-embedded objects (e.g., Flash videos).
156 # These CSS properties are supposed to horizontally center such objects;
157 # however, they do not.
158 margin: 1.500em auto;
159 padding: 1.500em 0.000em 0.500em 0.000em;
161 text-indent: 0.000em;
164 Unfortunately, most browsers ignore most CSS properties on the CSS "object"
165 selector (including those in the example, above).
167 To circumvent this, flashbox enwraps all block-level, flashbox-specific markup
168 (i.e., flashbox-specific markup preceded by at least two newlines) within an
169 HTML paragraph having two unique classes. This HTML paragraph, unlike the
170 "<object>...</object>" HTML tag-set, is styleable by all browsers via CSS
171 selection of these classes:
175 =item "flashbox"; and
177 =item "googlevideo", "youtube", or "slideshare" - according to which offsite host
178 a Flash video is embedded from.
182 Let's illustrate with a crude example. Suppose some Oddmuse Wiki page contains
185 In this compelling reading of his, perhaps, most well-read poetry, Carl Sagan
186 thunders the truth, Vangelis supplies the angel’s harp and music, and YouTube
187 plies the photo-montage seas of "this pale, blue dot": our Earth, from afar.
189 [[YouTube:p86BPM1GV8M]]
191 Then, flashbox transmutes that text markup into HTML markup resembling:
194 In this compelling reading of his, perhaps, most well-read poetry, Carl Sagan
195 thunders the truth, Vangelis supplies the angel’s harp and music, and YouTube
196 plies the photo-montage seas of "this pale, blue dot": our Earth, from afar.
198 <p class="flashbox youtube">
199 <object width="420" height="350">
200 <param name="movie" value="http://www.youtube.com/v/p86BPM1GV8M"/>
201 <param name="pluginurl" value="http://www.macromedia.com/go/getflashplayer"/>
202 <embed type="application/x-shockwave-flash"
203 width="420" height="350"
204 src="http://www.youtube.com/v/p86BPM1GV8M"/>
208 Then, your CSS stylesheet can style this HTML markup with CSS resembling:
210 # This CSS selector selects flashbox-embedded Flash videos.
212 # These CSS properties horizontally center such videos.
213 margin: 1.500em auto;
214 padding: 1.500em 0.000em 0.500em 0.000em;
216 text-indent: 0.000em;
219 # This CSS selector selects flashbox-embedded, YouTube-specific Flash videos.
221 # These CSS properties background and border such videos.
223 border: #112255 0.125em solid;
226 Wew! There; that wasn't so gruesomely detailed, was it?
230 The oddmuse.org "YouTube" page off which this Oddmuse extension was founded, at:
232 L<http://www.oddmuse.org/cgi-bin/oddmuse/YouTube>
234 =head1 COPYRIGHT AND LICENSE
236 The information below applies to everything in this distribution,
239 Copyleft 2008 by B.w.Curry <http://www.raiazome.com>.
241 This file is free software; you can redistribute it and/or
242 modify it under the terms of the GNU General Public License
243 as published by the Free Software Foundation; either version 2
244 of the License, or (at your option) any later version.
246 This file is distributed in the hope that it will be useful,
247 but WITHOUT ANY WARRANTY; without even the implied warranty of
248 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
249 GNU General Public License for more details.
251 You should have received a copy of the GNU General Public License
252 along with this file; if not, write to the Free Software
253 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.