Add simplepie

pull/1/head
Mike Macgirvin 13 years ago
parent f5826105bf
commit 9f7ae0e95f

@ -0,0 +1,26 @@
Copyright (c) 2004-2007, Ryan Parman and Geoffrey Sneddon.
All rights reserved.
Redistribution and use in source and binary forms, with or without modification, are
permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice, this list of
conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice, this list
of conditions and the following disclaimer in the documentation and/or other materials
provided with the distribution.
* Neither the name of the SimplePie Team nor the names of its contributors may be used
to endorse or promote products derived from this software without specific prior
written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS
AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.

@ -0,0 +1,53 @@
# SimplePie
## Authors and contributors
* [Ryan Parman](http://ryanparman.com)
* [Geoffrey Sneddon](http://gsnedders.com)
* [Ryan McCue](http://ryanmccue.info)
* [Michael Shipley](http://michaelpshipley.com)
* [Steve Minutillo](http://minutillo.com/steve/)
## License
[New BSD license](http://www.opensource.org/licenses/bsd-license.php)
## Project status
SimplePie is currently maintained by Ryan McCue.
At the moment, there isn't a lot of active development happening. If the community decides that SimplePie is a valuable tool, then the community will come together to maintain it into the future.
If you're interested in getting involved with SimplePie, please get in touch with Ryan McCue.
## What comes in the package?
1. `simplepie.inc` - The SimplePie library. This is all that's required for your pages.
2. `README.markdown` - This document.
3. `LICENSE.txt` - A copy of the BSD license.
4. `compatibility_test/` - The SimplePie compatibility test that checks your server for required settings.
5. `demo/` - A basic feed reader demo that shows off some of SimplePie's more noticable features.
6. `idn/` - A third-party library that SimplePie can optionally use to understand Internationalized Domain Names (IDNs).
7. `test/` - SimplePie's unit test suite.
## To start the demo
1. Upload this package to your webserver.
2. Make sure that the cache folder inside of the demo folder is server-writable.
3. Navigate your browser to the demo folder.
## Need support?
For further setup and install documentation, function references, etc., visit:
[http://simplepie.org/wiki/](http://simplepie.org/wiki/)
For bug reports and feature requests, visit:
[http://github.com/rmccue/simplepie/issues](http://github.com/rmccue/simplepie/issues)
Support mailing list -- powered by users, for users.
[http://tech.groups.yahoo.com/group/simplepie-support/](http://tech.groups.yahoo.com/group/simplepie-support/)

@ -0,0 +1,7 @@
SIMPLEPIE COMPATIBILITY TEST
1) Upload sp_compatibility_test.php to the web-accessible root of your website.
For example, if your website is www.example.com, upload it so that you can get
to it at www.example.com/sp_compatibility_test.php
2) Open your web browser and go to the page you just uploaded.

File diff suppressed because one or more lines are too long

@ -0,0 +1,178 @@
<?php
require_once 'simplepie.inc';
function normalize_character_set($charset)
{
return strtolower(preg_replace('/(?:[^a-zA-Z0-9]+|([^0-9])0+)/', '\1', $charset));
}
function build_character_set_list()
{
$file = new SimplePie_File('http://www.iana.org/assignments/character-sets');
if (!$file->success && !($file->method & SIMPLEPIE_FILE_SOURCE_REMOTE === 0 || ($file->status_code === 200 || $file->status_code > 206 && $file->status_code < 300)))
{
return false;
}
else
{
$data = explode("\n", $file->body);
unset($file);
foreach ($data as $line)
{
// New character set
if (substr($line, 0, 5) === 'Name:')
{
// If we already have one, push it on to the array
if (isset($aliases))
{
for ($i = 0, $count = count($aliases); $i < $count; $i++)
{
$aliases[$i] = normalize_character_set($aliases[$i]);
}
$charsets[$preferred] = array_unique($aliases);
natsort($charsets[$preferred]);
}
$start = 5 + strspn($line, "\x09\x0A\x0B\xC\x0D\x20", 5);
$chars = strcspn($line, "\x09\x0A\x0B\xC\x0D\x20", $start);
$aliases = array(substr($line, $start, $chars));
$preferred = end($aliases);
}
// Another alias
elseif(substr($line, 0, 6) === 'Alias:')
{
$start = 7 + strspn($line, "\x09\x0A\x0B\xC\x0D\x20", 7);
$chars = strcspn($line, "\x09\x0A\x0B\xC\x0D\x20", $start);
$aliases[] = substr($line, $start, $chars);
if (end($aliases) === 'None')
{
array_pop($aliases);
}
elseif (substr($line, 7 + $chars + 1, 21) === '(preferred MIME name)')
{
$preferred = end($aliases);
}
}
}
// Compatibility replacements
$compat = array(
'EUC-KR' => 'windows-949',
'GB2312' => 'GBK',
'GB_2312-80' => 'GBK',
'ISO-8859-1' => 'windows-1252',
'ISO-8859-9' => 'windows-1254',
'ISO-8859-11' => 'windows-874',
'KS_C_5601-1987' => 'windows-949',
'TIS-620' => 'windows-874',
//'US-ASCII' => 'windows-1252',
'x-x-big5' => 'Big5',
);
foreach ($compat as $real => $replace)
{
if (isset($charsets[$real]) && isset($charsets[$replace]))
{
$charsets[$replace] = array_merge($charsets[$replace], $charsets[$real]);
unset($charsets[$real]);
}
elseif (isset($charsets[$real]))
{
$charsets[$replace] = $charsets[$real];
$charsets[$replace][] = normalize_character_set($replace);
unset($charsets[$real]);
}
else
{
$charsets[$replace][] = normalize_character_set($real);
}
$charsets[$replace] = array_unique($charsets[$replace]);
natsort($charsets[$replace]);
}
// Sort it
uksort($charsets, 'strnatcasecmp');
// Check that nothing matches more than one
$all = call_user_func_array('array_merge', $charsets);
$all_count = array_count_values($all);
if (max($all_count) > 1)
{
echo "Duplicated charsets:\n";
foreach ($all_count as $charset => $count)
{
if ($count > 1)
{
echo "$charset\n";
}
}
}
// And we're done!
return $charsets;
}
}
function charset($charset)
{
$normalized_charset = normalize_character_set($charset);
if ($charsets = build_character_set_list())
{
foreach ($charsets as $preferred => $aliases)
{
if (in_array($normalized_charset, $aliases))
{
return $preferred;
}
}
return $charset;
}
else
{
return false;
}
}
function build_function()
{
if ($charsets = build_character_set_list())
{
$return = <<<EOF
function charset(\$charset)
{
// Normalization from UTS #22
switch (strtolower(preg_replace('/(?:[^a-zA-Z0-9]+|([^0-9])0+)/', '\\1', \$charset)))
{
EOF;
foreach ($charsets as $preferred => $aliases)
{
foreach ($aliases as $alias)
{
$return .= "\t\tcase " . var_export($alias, true) . ":\n";
}
$return .= "\t\t\treturn " . var_export($preferred, true) . ";\n\n";
}
$return .= <<<EOF
default:
return \$charset;
}
}
EOF;
return $return;
}
else
{
return false;
}
}
if (php_sapi_name() === 'cli' && realpath($_SERVER['argv'][0]) === __FILE__)
{
echo build_function();
}
?>

@ -0,0 +1,38 @@
/* SQLite */
CREATE TABLE cache_data (
id TEXT NOT NULL,
items SMALLINT NOT NULL DEFAULT 0,
data BLOB NOT NULL,
mtime INTEGER UNSIGNED NOT NULL
);
CREATE UNIQUE INDEX id ON cache_data(id);
CREATE TABLE items (
feed_id TEXT NOT NULL,
id TEXT NOT NULL,
data TEXT NOT NULL,
posted INTEGER UNSIGNED NOT NULL
);
CREATE INDEX feed_id ON items(feed_id);
/* MySQL */
CREATE TABLE `cache_data` (
`id` TEXT CHARACTER SET utf8 NOT NULL,
`items` SMALLINT NOT NULL DEFAULT 0,
`data` BLOB NOT NULL,
`mtime` INT UNSIGNED NOT NULL,
UNIQUE (
`id`(125)
)
);
CREATE TABLE `items` (
`feed_id` TEXT CHARACTER SET utf8 NOT NULL,
`id` TEXT CHARACTER SET utf8 NOT NULL,
`data` TEXT CHARACTER SET utf8 NOT NULL,
`posted` INT UNSIGNED NOT NULL,
INDEX `feed_id` (
`feed_id`(125)
)
);

@ -0,0 +1,23 @@
#!/usr/bin/php
<?php
include_once('../simplepie.inc');
// Parse it
$feed = new SimplePie();
if (isset($argv[1]) && $argv[1] !== '')
{
$feed->set_feed_url($argv[1]);
$feed->enable_cache(false);
$feed->init();
}
$items = $feed->get_items();
foreach ($items as $item)
{
echo $item->get_title() . "\n";
}
var_dump($feed->get_item_quantity());
?>

Binary file not shown.

After

Width:  |  Height:  |  Size: 28 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 27 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 533 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 533 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 250 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 28 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 715 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.0 KiB

@ -0,0 +1,5 @@
<html>
<head>
<meta http-equiv="refresh" content="0;url=http://www.jeroenwijering.com/extras/readme.html">
</head>
</html>

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 851 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 36 KiB

@ -0,0 +1,35 @@
/*=:project
scalable Inman Flash Replacement (sIFR) version 3.
=:file
Copyright: 2006 Mark Wubben.
Author: Mark Wubben, <http://novemberborn.net/>
=:history
* IFR: Shaun Inman
* sIFR 1: Mike Davidson, Shaun Inman and Tomas Jogin
* sIFR 2: Mike Davidson, Shaun Inman, Tomas Jogin and Mark Wubben
=:license
This software is licensed and provided under the CC-GNU LGPL.
See <http://creativecommons.org/licenses/LGPL/2.1/>
*/
/* This is the print stylesheet to hide the Flash headlines from the browser... regular browser text headlines will now print as normal */
.sIFR-flash {
display: none !important;
height: 0;
width: 0;
position: absolute;
overflow: hidden;
}
.sIFR-alternate {
visibility: visible !important;
display: block !important;
position: static !important;
left: auto !important;
top: auto !important;
}

@ -0,0 +1,39 @@
/*=:project
scalable Inman Flash Replacement (sIFR) version 3.
=:file
Copyright: 2006 Mark Wubben.
Author: Mark Wubben, <http://novemberborn.net/>
=:history
* IFR: Shaun Inman
* sIFR 1: Mike Davidson, Shaun Inman and Tomas Jogin
* sIFR 2: Mike Davidson, Shaun Inman, Tomas Jogin and Mark Wubben
=:license
This software is licensed and provided under the CC-GNU LGPL.
See <http://creativecommons.org/licenses/LGPL/2.1/>
*/
/*---- sIFR ---*/
.sIFR-flash {
visibility: visible !important;
margin: 0;
padding: 0;
}
.sIFR-replaced {
visibility: visible !important;
}
.sIFR-alternate {
position: absolute;
left: 0;
top: 0;
width: 0;
height: 0;
display: block;
overflow: hidden;
}
/*---- Header styling ---*/

@ -0,0 +1,40 @@
var yanone_kaffeesatz = {
src: './for_the_demo/yanone-kaffeesatz-bold.swf'
};
var lucida_grande = {
src: './for_the_demo/lucida-grande-bold.swf'
};
sIFR.activate(yanone_kaffeesatz);
//sIFR.activate(lucida_grande);
sIFR.replace(yanone_kaffeesatz, {
//sIFR.replace(lucida_grande, {
selector: 'h3.header',
wmode: 'transparent',
css: {
'.sIFR-root': {
'text-align': 'center',
'color': '#000000',
'font-weight': 'bold',
'background-color': '#EEFFEE',
'font-size': '50px', // For Yanone Kaffeesatz
//'font-size': '40px', // For Lucida Grande
'letter-spacing': '0' // For Yanone Kaffeesatz
//'letter-spacing': '-4' // For Lucida Grande
},
'a': {
'text-decoration': 'none',
'color': '#000000'
},
'a:hover': {
'text-decoration': 'none',
'color': '#666666'
}
}
});

File diff suppressed because one or more lines are too long

@ -0,0 +1,397 @@
/*
Theme Name: SimplePie
Theme URI: http://simplepie.org
Description: A simple, yet beautiful theme inspired by several cleanly designed websites.
Version: 1.4
Author: Ryan Parman
Author URI: http://skyzyx.com
Updated: 21 June 2007
*/
/*********************************************
HYPERLINK STYLES
*********************************************/
a {
color:#369;
text-decoration:underline;
padding:0 1px;
}
a:hover {
color:#fff !important;
background-color:#333;
text-decoration:none;
padding:0 1px;
}
a.nohover {
text-decoration:none;
border:none;
}
a.nohover:hover {
background-color:transparent;
border:none;
}
a.namelink {
padding:0;
margin:0;
overflow:hidden;
height:1px;
}
h4 a,
.sample_feeds a {
color:#000;
}
/*********************************************
GENERAL STYLES
*********************************************/
body {
/*font:12px/18px Verdana, sans-serif;*/
font:14px/1.5em "Lucida Grande", Tahoma, sans-serif;
letter-spacing:0px;
color:#333;
background-color:#fff;
margin:0;
padding:0;
}
div#site {
width:600px;
margin:50px auto 0 auto;
}
h1#logo {
margin:0;
padding:0;
text-align:center;
}
h1#logo a,
h1#logo a:hover {
background-color:transparent;
text-decoration:none;
padding:0;
}
h2.image {
margin:0;
padding:0;
text-align:center;
}
h3 {
margin:20px 0 0 0;
padding:0;
font-size:1.5em;
}
h4 {
margin:20px 0 0 0;
padding:0;
font-size:1.2em;
letter-spacing:-1px;
}
h5 {
margin:10px 0 0 0;
padding:0;
font-size:1em;
font-weight:bold;
}
em {
font-style:normal;
background-color:#ffc;
}
p {
margin:0;
padding:5px 0;
}
ul, ol {
margin:10px 0 10px 20px;
padding:0 0 0 15px;
}
ul li, ol li {
margin:0 0 7px 0;
padding:0 0 0 3px;
}
form {
margin:0;
padding:0;
}
code {
font-size:1em;
background-color:#f3f3ff;
color:#000;
}
div#site pre {
background-color:#f3f3ff;
color:#000080;
border:1px dotted #000080;
overflow:auto;
padding:3px 5px;
}
blockquote {
font-size:1em;
color:#666;
border-left:4px solid #666;
margin:10px 0 10px 30px;
padding:0 5px 0 10px;
background:#f3f3f3 url(background_blockquote.png) repeat top left;
}
input, select, textarea {
font-size:12px;
line-height:1.2em;
padding:2px;
}
input[type=text], select, textarea {
background-color:#e9f5ff;
border:1px solid #333;
}
input[type=text]:focus, select:focus, textarea:focus {
background-color:#ffe;
}
.clearLeft {clear:left;}
.clearRight {clear:right;}
.clearBoth {clear:both;}
.hide {display:none;}
/*********************************************
NAVIGATION STYLES
*********************************************/
div#header {
background:#fff url(top_gradient.gif) repeat-x top left;
margin:0;
padding:0;
}
div#header form {
margin:0;
padding:0;
}
div#header div#headerInner {
margin:0;
padding:0;
}
div#header div#headerInner div#logoContainer {}
div#header div#headerInner div#logoContainerInner {
width:550px;
margin:0 auto;
padding:20px;
}
div#header div#headerInner div#logoContainer div#logo {
float:left;
width:200px;
}
div#header div#headerInner div#logoContainer div#logo a,
div#header div#headerInner div#logoContainer div#logo a:hover {
border:none;
background:none;
}
div#header div#headerInner div#logoContainer div#feed {
float:right;
width:300px;
text-align:right;
padding:10px 0 0 0;
}
div#header div#headerInner div#logoContainer div#feed input.text {
width:60%;
}
div#header div#headerInner div#menu {
background:#eee url(background_menuitem_shadow.gif) repeat-x top left;
border-top:2px solid #ccc;
border-bottom:1px solid #ddd;
text-align:center;
}
div#header div#headerInner div#menu table {
width:auto;
margin:0 auto;
}
div#header div#headerInner div#menu ul {
display:block;
width:100%;
margin:0 auto;
padding:0;
font-size:12px;
}
div#header div#headerInner div#menu ul li {
display:block;
float:left;
}
div#header div#headerInner div#menu ul li a {
display:block;
margin:-2px 0 0 0;
padding:5px 7px 8px 7px;
text-decoration:none;
color:#666 !important;
background-color:transparent;
}
div#header div#headerInner div#menu ul li a:hover {
display:block;
margin:-2px 0 0 0;
padding:5px 7px 8px 7px;
text-decoration:none;
color:#666;
background:#fff url(background_menuitem_off.gif) no-repeat bottom right;
}
body#bodydemo div#header div#headerInner div#menu ul li#demo a {
display:block;
margin:-2px 0 0 0;
padding:5px 7px 8px 7px;
text-decoration:none;
color:#333;
font-weight:bold;
background:#fff url(background_menuitem.gif) no-repeat bottom right;
}
/*********************************************
CONTENT STYLES
*********************************************/
div.chunk {
margin:20px 0 0 0;
padding:0 0 10px 0;
border-bottom:1px solid #ccc;
}
div.topchunk {
margin:0 !important;
}
.footnote,
.footnote a {
font-size:12px;
line-height:1.3em;
color:#aaa;
}
.footnote em {
background-color:transparent;
font-style:italic;
}
.footnote code {
background-color:transparent;
font:11px/14px monospace;
color:#aaa;
}
p.subscribe {
background-color:#f3f3f3;
font-size:12px;
text-align:center;
}
p.highlight {
background-color:#ffc;
font-size:12px;
text-align:center;
}
p.sample_feeds {
font-size:12px;
line-height:1.2em;
}
div.sp_errors {
background-color:#eee;
padding:5px;
text-align:center;
font-size:12px;
}
.noborder {
border:none !important;
}
img.favicon {
margin:0 4px -2px 0;
width:16px;
height:16px;
}
p.favicons a,
p.favicons a:hover {
border:none;
background-color:transparent;
}
p.favicons img {
border:none;
}
/*********************************************
DEMO STYLES
*********************************************/
div#sp_input {
background-color:#ffc;
border:2px solid #f90;
padding:5px;
text-align:center;
}
div#sp_input input.text {
border:1px solid #999;
background:#e9f5ff url(feed.png) no-repeat 4px 50%;
width:75%;
padding:2px 2px 2px 28px;
font:18px/22px "Lucida Grande", Verdana, sans-serif;
font-weight:bold;
letter-spacing:-1px;
}
form#sp_form {
margin:15px 0;
}
div.focus {
margin:0;
padding:10px 20px;
background-color:#efe;
}
p.sample_feeds {
text-align:justify;
}
/*********************************************
SIFR STYLES
*********************************************/
.sIFR-active h3.header {
visibility:hidden;
line-height:1em;
}

@ -0,0 +1,31 @@
/**********************************************************
Sleight
(c) 2001, Aaron Boodman
http://www.youngpup.net
**********************************************************/
if (navigator.platform == "Win32" && navigator.appName == "Microsoft Internet Explorer" && window.attachEvent)
{
document.writeln('<style type="text/css">img { visibility:hidden; } </style>');
window.attachEvent("onload", fnLoadPngs);
}
function fnLoadPngs()
{
var rslt = navigator.appVersion.match(/MSIE (\d+\.\d+)/, '');
var itsAllGood = (rslt != null && Number(rslt[1]) >= 5.5);
for (var i = document.images.length - 1, img = null; (img = document.images[i]); i--)
{
if (itsAllGood && img.src.match(/\.png$/i) != null)
{
var src = img.src;
var div = document.createElement("DIV");
div.style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + src + "', sizing='scale')"
div.style.width = img.width + "px";
div.style.height = img.height + "px";
img.replaceNode(div);
}
img.style.visibility = "visible";
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 38 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 113 KiB

@ -0,0 +1,71 @@
/*=:project
scalable Inman Flash Replacement (sIFR) version 3.
=:file
Copyright: 2006 Mark Wubben.
Author: Mark Wubben, <http://novemberborn.net/>
=:history
* IFR: Shaun Inman
* sIFR 1: Mike Davidson, Shaun Inman and Tomas Jogin
* sIFR 2: Mike Davidson, Shaun Inman, Tomas Jogin and Mark Wubben
=:license
This software is licensed and provided under the CC-GNU LGPL.
See <http://creativecommons.org/licenses/LGPL/2.1/>
*/
import TextField.StyleSheet;
class SifrStyleSheet extends TextField.StyleSheet {
public var fontSize;
public var latestLeading = 0;
public function parseCSS(cssText:String) {
var native = new TextField.StyleSheet();
var parsed = native.parseCSS(cssText);
if(!parsed) return false;
var selectors = native.getStyleNames();
for(var i = selectors.length - 1; i >= 0; i--) {
var selector = selectors[i];
var nativeStyle = native.getStyle(selector);
var style = this.getStyle(selector) || nativeStyle;
if(style != nativeStyle) {
for(var property in nativeStyle) style[property] = nativeStyle[property];
}
this.setStyle(selector, style);
}
return true;
}
// Apply leading to the textFormat. Much thanks to <http://www.blog.lessrain.com/?p=98>.
private function applyLeading(format, leading) {
this.latestLeading = leading;
if(leading >= 0) {
format.leading = leading;
return format;
}
// Workaround for negative leading, which is ignored otherwise.
var newFormat = new TextFormat(null, null, null, null, null, null, null, null, null, null, null, null, leading);
for(var property in format) if(property != 'leading') newFormat[property] = format[property];
return newFormat;
}
public function transform(style) {
var format = super.transform(style);
if(style.leading) format = applyLeading(format, style.leading);
if(style.letterSpacing) format.letterSpacing = style.letterSpacing;
// Support font sizes relative to the size of .sIFR-root.
if(this.fontSize && style.fontSize && style.fontSize.indexOf('%')) {
format.size = this.fontSize * parseInt(style.fontSize) / 100;
}
format.kerning = _root.kerning == 'true' || !(_root.kerning == 'false') || sIFR.defaultKerning;
return format;
}
}

@ -0,0 +1,12 @@
This is a pre-release nightly of sIFR 3 (r245 to be exact). We (the SimplePie team) will be updating the
sIFR code and font files from time to time as new releases of sIFR 3 are made available.
In this folder you'll find a few Flash 8 files. The only one of you might want to mess with is sifr.fla.
* Open it up
* Double-click the rectangle in the middle
* Select all
* Change the font
More information about sIFR 3 can be found here:
* http://dev.novemberborn.net/sifr3/
* http://wiki.novemberborn.net/sifr3/

@ -0,0 +1,12 @@
// MTASC only parses as-files with class definitions, so here goes...
class Options {
public static function apply() {
sIFR.fromLocal = true;
sIFR.domains = ['*'];
// Parsing `p.foo` might not work, see: <http://livedocs.macromedia.com/flash/mx2004/main_7_2/wwhelp/wwhimpl/common/html/wwhelp.htm?context=Flash_MX_2004&file=00001766.html>
// Appearantly you have to use hex color codes as well, names are not supported!
sIFR.styles.parseCSS('.foo { text-decoration: underline; }');
}
}

@ -0,0 +1,359 @@
/*=:project
scalable Inman Flash Replacement (sIFR) version 3.
=:file
Copyright: 2006 Mark Wubben.
Author: Mark Wubben, <http://novemberborn.net/>
=:history
* IFR: Shaun Inman
* sIFR 1: Mike Davidson, Shaun Inman and Tomas Jogin
* sIFR 2: Mike Davidson, Shaun Inman, Tomas Jogin and Mark Wubben
=:license
This software is licensed and provided under the CC-GNU LGPL.
See <http://creativecommons.org/licenses/LGPL/2.1/>
*/
import SifrStyleSheet;
class sIFR {
public static var DEFAULT_TEXT = 'Rendered with sIFR 3, revision 245';
public static var CSS_ROOT_CLASS = 'sIFR-root';
public static var DEFAULT_WIDTH = 300;
public static var DEFAULT_HEIGHT = 100;
public static var DEFAULT_ANTI_ALIAS_TYPE = 'advanced';
public static var MARGIN_LEFT = -3;
public static var PADDING_BOTTOM = 5; // Extra padding to make sure the movie is high enough in most cases.
public static var LEADING_REMAINDER = 2; // Flash uses the specified leading minus 2 as the applied leading.
public static var MAX_FONT_SIZE = 126;
public static var ALIASING_MAX_FONT_SIZE = 48;
//= Holds CSS properties and other rendering properties for the Flash movie.
// *Don't overwrite!*
public static var styles:SifrStyleSheet = new SifrStyleSheet();
//= Allow sIFR to be run from localhost
public static var fromLocal:Boolean = true;
//= Array containing domains for which sIFR may render text. Used to prevent
// hotlinking. Use `*` to allow all domains.
public static var domains:Array = [];
//= Whether kerning is enabled by default. This can be overriden from the client side.
// See also <http://livedocs.macromedia.com/flash/8/main/wwhelp/wwhimpl/common/html/wwhelp.htm?context=LiveDocs_Parts&file=00002811.html>.
public static var defaultKerning:Boolean = true;
//= Default value which can be overriden from the client side.
// See also <http://livedocs.macromedia.com/flash/8/main/wwhelp/wwhimpl/common/html/wwhelp.htm?context=LiveDocs_Parts&file=00002788.html>.
public static var defaultSharpness:Number = 0;
//= Default value which can be overriden from the client side.
// See also <http://livedocs.macromedia.com/flash/8/main/wwhelp/wwhimpl/common/html/wwhelp.htm?context=LiveDocs_Parts&file=00002787.html>.
public static var defaultThickness:Number = 0;
//= Default value which can be overriden from the client side.
// See also <http://livedocs.macromedia.com/flash/8/main/wwhelp/wwhimpl/common/html/wwhelp.htm?context=LiveDocs_Parts&file=00002732.html>.
public static var defaultOpacity:Number = -1; // Use client settings
//= Default value which can be overriden from the client side.
// See also <http://livedocs.macromedia.com/flash/8/main/wwhelp/wwhimpl/common/html/wwhelp.htm?context=LiveDocs_Parts&file=00002788.html>.
public static var defaultBlendMode:Number = -1; // Use cliest settings
//= Overrides the grid fit type as defined on the client side.
// See also <http://livedocs.macromedia.com/flash/8/main/wwhelp/wwhimpl/common/html/wwhelp.htm?context=LiveDocs_Parts&file=00002444.html>.
public static var enforcedGridFitType:String = null;
//= If `true` sIFR won't override the anti aliasing set in the Flash IDE when exporting.
// Thickness and sharpness won't be affected either.
public static var preserveAntiAlias:Boolean = false;
//= If `true` sIFR will disable anti-aliasing if the font size is larger than `ALIASING_MAX_FONT_SIZE`.
// This setting is *independent* from `preserveAntiAlias`.
public static var conditionalAntiAlias:Boolean = true;
//= Sets the anti alias type. By default it's `DEFAULT_ANTI_ALIAS_TYPE`.
// See also <http://livedocs.macromedia.com/flash/8/main/wwhelp/wwhimpl/common/html/wwhelp.htm?context=LiveDocs_Parts&file=00002733.html>.
public static var antiAliasType:String = null;
//= Flash filters can be added to this array and will be applied to the text field.
public static var filters:Array = [];
//= A mapping from the names of the filters to their actual objecs, used when transforming
// filters defined on the client. You can add additional filters here so they'll be supported
// when defined on the client.
public static var filterMap:Object = {
DisplacementMapFilter : flash.filters.DisplacementMapFilter,
ColorMatrixFilter : flash.filters.ColorMatrixFilter,
ConvolutionFilter : flash.filters.ConvolutionFilter,
GradientBevelFilter : flash.filters.GradientBevelFilter,
GradientGlowFilter : flash.filters.GradientGlowFilter,
BevelFilter : flash.filters.BevelFilter,
GlowFilter : flash.filters.GlowFilter,
BlurFilter : flash.filters.BlurFilter,
DropShadowFilter : flash.filters.DropShadowFilter
};
private static var instance;
private var textField;
private var content;
private var realHeight;
private var originalHeight;
private var currentHeight;
private var fontSize;
private var tuneWidth;
private var tuneHeight;
//= Sets the default styles for `sIFR.styles`. This method is called
// directly in `sifr.fla`, before options are applied.
public static function setDefaultStyles() {
sIFR.styles.parseCSS([
'.', CSS_ROOT_CLASS, ' { color: #000000; }',
'strong { display: inline; font-weight: bold; } ',
'em { display: inline; font-style: italic; }',
'a { color: #0000FF; text-decoration: underline; }',
'a:hover { color: #0000FF; text-decoration: none; }'
].join(''));
}
//= Validates the domain sIFR is being used on.
// Returns `true` if the domain is valid, `false` otherwise.
public static function checkDomain():Boolean {
if(sIFR.domains.length == 0) return true;
var domain = (new LocalConnection()).domain();
if(sIFR.fromLocal) sIFR.domains.push('localhost');
for(var i = 0; i < sIFR.domains.length; i++) {
var match = sIFR.domains[i];
if(match == '*' || match == domain) return true;
var wildcard = match.lastIndexOf('*');
if(wildcard > -1) {
match = match.substr(wildcard + 1);
var matchPosition = domain.lastIndexOf(match);
if(matchPosition > -1 && (matchPosition + match.length) == domain.length) return true;
}
}
return false;
}
//= Runs sIFR. Called automatically.
public static function run() {
var holder = _root.holder;
var content = checkDomain() ? unescape(_root.content) : DEFAULT_TEXT
if(content == 'undefined' || content == '') {
content = DEFAULT_TEXT;
fscommand('resetmovie', '');
} else fscommand('ping', '');
// Sets stage parameters
Stage.scaleMode = 'noscale';
Stage.align = 'TL';
Stage.showMenu = false;
// Other parameters
var opacity = parseInt(_root.opacity);
if(!isNaN(opacity)) holder._alpha = sIFR.defaultOpacity == -1 ? opacity : sIFR.defaultOpacity;
else holder._alpha = 100;
_root.blendMode = sIFR.defaultBlendMode == -1 ? _root.blendmode : sIFR.defaultBlendMode;
sIFR.instance = new sIFR(holder.txtF, content);
// This should ignore resizes from the callback. Disabled for now.
/* if(_root.zoomsupport == 'true') Stage.addListener({onResize: function() { sIFR.instance.scale() }});*/
// Setup callbacks
_root.watch('callbackTrigger', function() {
sIFR.callback();
return false;
});
}
private static function eval(str) {
var as;
if(str.charAt(0) == '{') { // Ah, we need to create an object
as = {};
str = str.substring(1, str.length - 1);
var $ = str.split(',');
for(var i = 0; i < $.length; i++) {
var $1 = $[i].split(':');
as[$1[0]] = sIFR.eval($1[1]);
}
} else if(str.charAt(0) == '"') { // String
as = str.substring(1, str.length - 1);
} else if(str == 'true' || str == 'false') { // Boolean
as = str == 'true';
} else { // Float
as = parseFloat(str);
}
return as;
}
private function applyFilters() {
var $filters = this.textField.filters;
$filters = $filters.concat(sIFR.filters);
var $ = _root.flashfilters.split(';'); // name,prop:value,...;
for(var i = 0; i < $.length; i++) {
var $1 = $[i].split(',');
var newFilter = new sIFR.filterMap[$1[0]]();
for(var j = 1; j < $1.length; j++) {
var $2 = $1[j].split(':');
newFilter[$2[0]] = sIFR.eval(unescape($2[1]));
}
$filters.push(newFilter);
}
this.textField.filters = $filters;
}
private function sIFR(textField, content) {
this.textField = textField;
this.content = content;
var offsetLeft = parseInt(_root.offsetleft);
textField._x = MARGIN_LEFT + (isNaN(offsetLeft) ? 0 : offsetLeft);
var offsetTop = parseInt(_root.offsettop);
if(!isNaN(offsetTop)) textField._y += offsetTop;
tuneWidth = parseInt(_root.tunewidth);
if(isNaN(tuneWidth)) tuneWidth = 0;
tuneHeight = parseInt(_root.tuneheight);
if(isNaN(tuneHeight)) tuneHeight = 0;
textField._width = tuneWidth + (isNaN(parseInt(_root.width)) ? DEFAULT_WIDTH : parseInt(_root.width));
textField._height = tuneHeight + (isNaN(parseInt(_root.height)) ? DEFAULT_HEIGHT : parseInt(_root.height));
textField.wordWrap = true;
textField.selectable = _root.selectable == 'true';
textField.gridFitType = sIFR.enforcedGridFitType || _root.gridfittype;
this.applyFilters();
// Determine font-size and the number of lines
this.fontSize = parseInt(_root.size);
if(isNaN(this.fontSize)) this.fontSize = 26;
styles.fontSize = this.fontSize;
if(!sIFR.preserveAntiAlias && (sIFR.conditionalAntiAlias && this.fontSize < ALIASING_MAX_FONT_SIZE
|| !sIFR.conditionalAntiAlias)) {
textField.antiAliasType = sIFR.antiAliasType || DEFAULT_ANTI_ALIAS_TYPE;
}
if(!sIFR.preserveAntiAlias || !isNaN(parseInt(_root.sharpness))) {
textField.sharpness = parseInt(_root.sharpness);
}
if(isNaN(textField.sharpness)) textField.sharpness = sIFR.defaultSharpness;
if(!sIFR.preserveAntiAlias || !isNaN(parseInt(_root.thickness))) {
textField.thickness = parseInt(_root.thickness);
}
if(isNaN(textField.thickness)) textField.thickness = sIFR.defaultThickness;
// Set font-size and other styles
sIFR.styles.parseCSS(unescape(_root.css));
var rootStyle = styles.getStyle('.sIFR-root') || {};
rootStyle.fontSize = this.fontSize; // won't go higher than 126!
styles.setStyle('.sIFR-root', rootStyle);
textField.styleSheet = styles;
this.write(content);
this.repaint();
}
private function repaint() {
var leadingFix = this.isSingleLine() ? sIFR.styles.latestLeading : 0;
if(leadingFix > 0) leadingFix -= LEADING_REMAINDER;
// Flash wants to scroll the movie by one line, by adding the fontSize to the
// textField height this is no longer happens. We also add the absolute tuneHeight,
// to prevent a negative value from triggering the bug. We won't send the fake
// value to the JavaScript side, though.
textField._height = textField.textHeight + PADDING_BOTTOM + this.fontSize + Math.abs(tuneHeight) + tuneHeight - leadingFix;
this.realHeight = textField._height - this.fontSize - Math.abs(tuneHeight);
var arg = 'height:' + this.realHeight;
if(_root.fitexactly == 'true') arg += ',width:' + (textField.textWidth + tuneWidth);
fscommand('resize', arg);
this.originalHeight = textField._height;
this.currentHeight = Stage.height;
textField._xscale = textField._yscale = parseInt(_root.zoom);
}
private function write(content) {
this.textField.htmlText = ['<p class="', CSS_ROOT_CLASS, '">',
content, '</p>'
].join('');
}
private function isSingleLine() {
return Math.round((this.textField.textHeight - sIFR.styles.latestLeading) / this.fontSize) == 1;