avatar

107

Merging Lightercss back into trunk. by pradador, 05 Oct, 2009 05:26 PM
Diff this changeset:
index.html
      <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
		<title>Syntax.js</title>
		<script type="text/javascript" src="Source/mootools.core.js"></script>
		<script type="text/javascript" src="Source/Fuel.js"></script>
		<script type="text/javascript" src="Source/Lighter.js"></script>
		
		<script type="text/javascript">
			window.addEvent('domready', function() {
				$$('pre').each(function(el) {
					var lighter = new Lighter(el, {
						altLines: 'hover',
						mode: 'div'
					});
				});
			});
		</script>
	</head>
	<body>
		<pre class="js:tutti">
Fuel.standard = new Class({ Extends: Fuel, initialize: function(lighter, options, wicks) { this.parent(lighter, options, wicks); } });

var Wick = new Class({

	initialize: function(match, type, index) {
		this.text   = match;
		this.type   = type;
		this.index  = index;
		this.length = this.text.length;
		this.end    = this.index + this.length;
	},
	contains: function(wick) { return (wick.index >= this.index && wick.index < this.end); },
	isBeyond: function(wick) { return (this.index >= wick.end); },
	overlaps: function(wick) { return (this.index == wick.index && this.length > wick.length); },
	toString: function() { return this.index+' - '+this.text+' - '+this.end; }
});
</pre>
		<pre class="php:tutti">//settings
$dir = 'js-libs/';
$url = 'http://code.google.com/apis/ajaxlibs/documentation/index.html';

//open file
$content = get_content($url);
echo 'Retrieved page from Google.';

//parse
$regex = '/http:\/\/ajax.googleapis.com\/ajax\/libs\/.*.js/isU';

//match?
preg_match_all($regex,$content,$matches);

//make sure there are no repeated files
$js_files = array_unique($matches[0]);

//download every file and save locally
foreach($js_files as $file) {
	//download
	$content = get_content($file);
	//save
	$filename = str_replace(array('http://ajax.googleapis.com/ajax/libs/','/'),array('','-'),$file);
	file_put_contents($dir.$filename,$content);
	//
	echo 'saving ',$file;
}

//function to grab content from a url
function get_content($url) {
	$ch = curl_init();
	curl_setopt($ch,CURLOPT_USERAGENT,'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.13) Gecko/20080311 Firefox/2.0.0.13');
	curl_setopt($ch,CURLOPT_URL,$url);
	curl_setopt($ch,CURLOPT_RETURNTRANSFER,1);
	curl_setopt($ch,CURLOPT_CONNECTTIMEOUT,5);
	$content = curl_exec($ch);
	curl_close($ch);
	return $content;
}</pre>
		<div id="container"></div>
	</body>
</html>
    

Check out the code: svn co svn://code.pradador.com/lighterjs/trunk/index.html