mirror of
https://github.com/there4/markdown-resume.git
synced 2024-12-03 08:59:35 -05:00
Initial commit of Markdown Resume
This includes several vendor libraries: Assetic, LessPHP, Mustache, SmartyPants, Markdown
This commit is contained in:
112
vendor/Assetic/Factory/Resource/CoalescingDirectoryResource.php
vendored
Executable file
112
vendor/Assetic/Factory/Resource/CoalescingDirectoryResource.php
vendored
Executable file
@@ -0,0 +1,112 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Assetic package, an OpenSky project.
|
||||
*
|
||||
* (c) 2010-2011 OpenSky Project Inc
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Assetic\Factory\Resource;
|
||||
|
||||
/**
|
||||
* Coalesces multiple directories together into one merged resource.
|
||||
*
|
||||
* @author Kris Wallsmith <kris.wallsmith@gmail.com>
|
||||
*/
|
||||
class CoalescingDirectoryResource implements IteratorResourceInterface
|
||||
{
|
||||
private $directories;
|
||||
|
||||
public function __construct($directories)
|
||||
{
|
||||
$this->directories = array();
|
||||
|
||||
foreach ($directories as $directory) {
|
||||
$this->addDirectory($directory);
|
||||
}
|
||||
}
|
||||
|
||||
public function addDirectory(IteratorResourceInterface $directory)
|
||||
{
|
||||
$this->directories[] = $directory;
|
||||
}
|
||||
|
||||
public function isFresh($timestamp)
|
||||
{
|
||||
foreach ($this->getFileResources() as $file) {
|
||||
if (!$file->isFresh($timestamp)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public function getContent()
|
||||
{
|
||||
$parts = array();
|
||||
foreach ($this->getFileResources() as $file) {
|
||||
$parts[] = $file->getContent();
|
||||
}
|
||||
|
||||
return implode("\n", $parts);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a string to uniquely identify the current resource.
|
||||
*
|
||||
* @return string An identifying string
|
||||
*/
|
||||
public function __toString()
|
||||
{
|
||||
$parts = array();
|
||||
foreach ($this->directories as $directory) {
|
||||
$parts[] = (string) $directory;
|
||||
}
|
||||
|
||||
return implode(',', $parts);
|
||||
}
|
||||
|
||||
public function getIterator()
|
||||
{
|
||||
return new \ArrayIterator($this->getFileResources());
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the relative version of a filename.
|
||||
*
|
||||
* @param ResourceInterface $file The file
|
||||
* @param ResourceInterface $directory The directory
|
||||
*
|
||||
* @return string The name to compare with files from other directories
|
||||
*/
|
||||
protected function getRelativeName(ResourceInterface $file, ResourceInterface $directory)
|
||||
{
|
||||
return substr((string) $file, strlen((string) $directory));
|
||||
}
|
||||
|
||||
/**
|
||||
* Performs the coalesce.
|
||||
*
|
||||
* @return array An array of file resources
|
||||
*/
|
||||
private function getFileResources()
|
||||
{
|
||||
$paths = array();
|
||||
|
||||
foreach ($this->directories as $directory) {
|
||||
foreach ($directory as $file) {
|
||||
$relative = $this->getRelativeName($file, $directory);
|
||||
|
||||
if (!isset($paths[$relative])) {
|
||||
$paths[$relative] = $file;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return array_values($paths);
|
||||
}
|
||||
}
|
||||
133
vendor/Assetic/Factory/Resource/DirectoryResource.php
vendored
Executable file
133
vendor/Assetic/Factory/Resource/DirectoryResource.php
vendored
Executable file
@@ -0,0 +1,133 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Assetic package, an OpenSky project.
|
||||
*
|
||||
* (c) 2010-2011 OpenSky Project Inc
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Assetic\Factory\Resource;
|
||||
|
||||
/**
|
||||
* A resource is something formulae can be loaded from.
|
||||
*
|
||||
* @author Kris Wallsmith <kris.wallsmith@gmail.com>
|
||||
*/
|
||||
class DirectoryResource implements IteratorResourceInterface
|
||||
{
|
||||
private $path;
|
||||
private $pattern;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param string $path A directory path
|
||||
* @param string $pattern A filename pattern
|
||||
*/
|
||||
public function __construct($path, $pattern = null)
|
||||
{
|
||||
if (DIRECTORY_SEPARATOR != substr($path, -1)) {
|
||||
$path .= DIRECTORY_SEPARATOR;
|
||||
}
|
||||
|
||||
$this->path = $path;
|
||||
$this->pattern = $pattern;
|
||||
}
|
||||
|
||||
public function isFresh($timestamp)
|
||||
{
|
||||
if (!is_dir($this->path) || filemtime($this->path) > $timestamp) {
|
||||
return false;
|
||||
}
|
||||
|
||||
foreach ($this as $resource) {
|
||||
if (!$resource->isFresh($timestamp)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the combined content of all inner resources.
|
||||
*/
|
||||
public function getContent()
|
||||
{
|
||||
$content = array();
|
||||
foreach ($this as $resource) {
|
||||
$content[] = $resource->getContent();
|
||||
}
|
||||
|
||||
return implode("\n", $content);
|
||||
}
|
||||
|
||||
public function __toString()
|
||||
{
|
||||
return $this->path;
|
||||
}
|
||||
|
||||
public function getIterator()
|
||||
{
|
||||
return is_dir($this->path)
|
||||
? new DirectoryResourceIterator($this->getInnerIterator())
|
||||
: new \EmptyIterator();
|
||||
}
|
||||
|
||||
protected function getInnerIterator()
|
||||
{
|
||||
return new DirectoryResourceFilterIterator(new \RecursiveDirectoryIterator($this->path), $this->pattern);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* An iterator that converts file objects into file resources.
|
||||
*
|
||||
* @author Kris Wallsmith <kris.wallsmith@gmail.com>
|
||||
* @access private
|
||||
*/
|
||||
class DirectoryResourceIterator extends \RecursiveIteratorIterator
|
||||
{
|
||||
public function current()
|
||||
{
|
||||
return new FileResource(parent::current()->getPathname());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Filters files by a basename pattern.
|
||||
*
|
||||
* @author Kris Wallsmith <kris.wallsmith@gmail.com>
|
||||
* @access private
|
||||
*/
|
||||
class DirectoryResourceFilterIterator extends \RecursiveFilterIterator
|
||||
{
|
||||
protected $pattern;
|
||||
|
||||
public function __construct(\RecursiveDirectoryIterator $iterator, $pattern = null)
|
||||
{
|
||||
parent::__construct($iterator);
|
||||
|
||||
$this->pattern = $pattern;
|
||||
}
|
||||
|
||||
public function accept()
|
||||
{
|
||||
$file = $this->current();
|
||||
$name = $file->getBasename();
|
||||
|
||||
if ($file->isDir()) {
|
||||
return '.' != $name[0];
|
||||
} else {
|
||||
return null === $this->pattern || 0 < preg_match($this->pattern, $name);
|
||||
}
|
||||
}
|
||||
|
||||
public function getChildren()
|
||||
{
|
||||
return new self(new \RecursiveDirectoryIterator($this->current()->getPathname()), $this->pattern);
|
||||
}
|
||||
}
|
||||
47
vendor/Assetic/Factory/Resource/FileResource.php
vendored
Executable file
47
vendor/Assetic/Factory/Resource/FileResource.php
vendored
Executable file
@@ -0,0 +1,47 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Assetic package, an OpenSky project.
|
||||
*
|
||||
* (c) 2010-2011 OpenSky Project Inc
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Assetic\Factory\Resource;
|
||||
|
||||
/**
|
||||
* A resource is something formulae can be loaded from.
|
||||
*
|
||||
* @author Kris Wallsmith <kris.wallsmith@gmail.com>
|
||||
*/
|
||||
class FileResource implements ResourceInterface
|
||||
{
|
||||
private $path;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param string $path The path to a file
|
||||
*/
|
||||
public function __construct($path)
|
||||
{
|
||||
$this->path = $path;
|
||||
}
|
||||
|
||||
public function isFresh($timestamp)
|
||||
{
|
||||
return file_exists($this->path) && filemtime($this->path) <= $timestamp;
|
||||
}
|
||||
|
||||
public function getContent()
|
||||
{
|
||||
return file_exists($this->path) ? file_get_contents($this->path) : '';
|
||||
}
|
||||
|
||||
public function __toString()
|
||||
{
|
||||
return $this->path;
|
||||
}
|
||||
}
|
||||
21
vendor/Assetic/Factory/Resource/IteratorResourceInterface.php
vendored
Executable file
21
vendor/Assetic/Factory/Resource/IteratorResourceInterface.php
vendored
Executable file
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Assetic package, an OpenSky project.
|
||||
*
|
||||
* (c) 2010-2011 OpenSky Project Inc
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Assetic\Factory\Resource;
|
||||
|
||||
/**
|
||||
* A resource is something formulae can be loaded from.
|
||||
*
|
||||
* @author Kris Wallsmith <kris.wallsmith@gmail.com>
|
||||
*/
|
||||
interface IteratorResourceInterface extends ResourceInterface, \IteratorAggregate
|
||||
{
|
||||
}
|
||||
43
vendor/Assetic/Factory/Resource/ResourceInterface.php
vendored
Executable file
43
vendor/Assetic/Factory/Resource/ResourceInterface.php
vendored
Executable file
@@ -0,0 +1,43 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Assetic package, an OpenSky project.
|
||||
*
|
||||
* (c) 2010-2011 OpenSky Project Inc
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Assetic\Factory\Resource;
|
||||
|
||||
/**
|
||||
* A resource is something formulae can be loaded from.
|
||||
*
|
||||
* @author Kris Wallsmith <kris.wallsmith@gmail.com>
|
||||
*/
|
||||
interface ResourceInterface
|
||||
{
|
||||
/**
|
||||
* Checks if a timestamp represents the latest resource.
|
||||
*
|
||||
* @param integer $timestamp A UNIX timestamp
|
||||
*
|
||||
* @return Boolean True if the timestamp is up to date
|
||||
*/
|
||||
function isFresh($timestamp);
|
||||
|
||||
/**
|
||||
* Returns the content of the resource.
|
||||
*
|
||||
* @return string The content
|
||||
*/
|
||||
function getContent();
|
||||
|
||||
/**
|
||||
* Returns a unique string for the current resource.
|
||||
*
|
||||
* @return string A unique string to identity the current resource
|
||||
*/
|
||||
function __toString();
|
||||
}
|
||||
Reference in New Issue
Block a user