mirror of
https://github.com/danpros/htmly.git
synced 2026-04-19 03:56:21 +05:30
updated Composer packages + changed the update process to "kanti/hub-updater"
This commit is contained in:
parent
2d0aad96d7
commit
a3e3930373
23 changed files with 4970 additions and 167 deletions
|
|
@ -1,6 +1,7 @@
|
||||||
{
|
{
|
||||||
"require": {
|
"require": {
|
||||||
"michelf/php-markdown": "1.4.*@dev",
|
"michelf/php-markdown": "1.4.*@dev",
|
||||||
"suin/php-rss-writer": ">=1.0"
|
"suin/php-rss-writer": ">=1.0",
|
||||||
|
"kanti/hub-updater": "dev-master"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
83
composer.lock
generated
83
composer.lock
generated
|
|
@ -1,22 +1,61 @@
|
||||||
{
|
{
|
||||||
"_readme": [
|
"_readme": [
|
||||||
"This file locks the dependencies of your project to a known state",
|
"This file locks the dependencies of your project to a known state",
|
||||||
"Read more about it at http://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file"
|
"Read more about it at http://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file",
|
||||||
|
"This file is @generated automatically"
|
||||||
],
|
],
|
||||||
"hash": "f4031afd76d9924ba9ef2f3fe17a97ab",
|
"hash": "09a845c7ac1f579f79cdd0196a86199d",
|
||||||
"packages": [
|
"packages": [
|
||||||
|
{
|
||||||
|
"name": "kanti/hub-updater",
|
||||||
|
"version": "dev-master",
|
||||||
|
"source": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "https://github.com/Kanti/hub-updater.git",
|
||||||
|
"reference": "fd965ed3524720d70a0cdddbd95e83f536c9b24f"
|
||||||
|
},
|
||||||
|
"dist": {
|
||||||
|
"type": "zip",
|
||||||
|
"url": "https://api.github.com/repos/Kanti/hub-updater/zipball/fd965ed3524720d70a0cdddbd95e83f536c9b24f",
|
||||||
|
"reference": "fd965ed3524720d70a0cdddbd95e83f536c9b24f",
|
||||||
|
"shasum": ""
|
||||||
|
},
|
||||||
|
"require": {
|
||||||
|
"php": ">=5.4.0"
|
||||||
|
},
|
||||||
|
"type": "library",
|
||||||
|
"autoload": {
|
||||||
|
"psr-4": {
|
||||||
|
"Kanti\\": ""
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"notification-url": "https://packagist.org/downloads/",
|
||||||
|
"license": [
|
||||||
|
"GPL-2.0"
|
||||||
|
],
|
||||||
|
"authors": [
|
||||||
|
{
|
||||||
|
"name": "Kanti",
|
||||||
|
"email": "git@kanti.de",
|
||||||
|
"homepage": "https://kanti.de",
|
||||||
|
"role": "Developer"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"description": "Simple Github Updater for Web Projects [PHP]",
|
||||||
|
"time": "2014-10-31 18:20:52"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"name": "michelf/php-markdown",
|
"name": "michelf/php-markdown",
|
||||||
"version": "dev-lib",
|
"version": "dev-lib",
|
||||||
"source": {
|
"source": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://github.com/michelf/php-markdown.git",
|
"url": "https://github.com/michelf/php-markdown.git",
|
||||||
"reference": "6f952ee180e9bd345f3dd6005aa11e0f5dcbd1b8"
|
"reference": "a8c56ecd5e9e7c7d37d00c814c864c3bc8b32694"
|
||||||
},
|
},
|
||||||
"dist": {
|
"dist": {
|
||||||
"type": "zip",
|
"type": "zip",
|
||||||
"url": "https://api.github.com/repos/michelf/php-markdown/zipball/6f952ee180e9bd345f3dd6005aa11e0f5dcbd1b8",
|
"url": "https://api.github.com/repos/michelf/php-markdown/zipball/a8c56ecd5e9e7c7d37d00c814c864c3bc8b32694",
|
||||||
"reference": "6f952ee180e9bd345f3dd6005aa11e0f5dcbd1b8",
|
"reference": "a8c56ecd5e9e7c7d37d00c814c864c3bc8b32694",
|
||||||
"shasum": ""
|
"shasum": ""
|
||||||
},
|
},
|
||||||
"require": {
|
"require": {
|
||||||
|
|
@ -54,20 +93,20 @@
|
||||||
"keywords": [
|
"keywords": [
|
||||||
"markdown"
|
"markdown"
|
||||||
],
|
],
|
||||||
"time": "2013-11-29 21:49:31"
|
"time": "2014-08-10 19:25:52"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "suin/php-rss-writer",
|
"name": "suin/php-rss-writer",
|
||||||
"version": "1.2",
|
"version": "1.3",
|
||||||
"source": {
|
"source": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "git://github.com/suin/php-rss-writer.git",
|
"url": "https://github.com/suin/php-rss-writer.git",
|
||||||
"reference": "1.2"
|
"reference": "82812ff988bb470f746d24e153cdc138e8838ff3"
|
||||||
},
|
},
|
||||||
"dist": {
|
"dist": {
|
||||||
"type": "zip",
|
"type": "zip",
|
||||||
"url": "https://github.com/suin/php-rss-writer/zipball/1.2",
|
"url": "https://api.github.com/repos/suin/php-rss-writer/zipball/82812ff988bb470f746d24e153cdc138e8838ff3",
|
||||||
"reference": "1.2",
|
"reference": "82812ff988bb470f746d24e153cdc138e8838ff3",
|
||||||
"shasum": ""
|
"shasum": ""
|
||||||
},
|
},
|
||||||
"require": {
|
"require": {
|
||||||
|
|
@ -99,23 +138,17 @@
|
||||||
"rss",
|
"rss",
|
||||||
"writer"
|
"writer"
|
||||||
],
|
],
|
||||||
"time": "2012-08-23 00:45:18"
|
"time": "2014-03-12 06:05:28"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"packages-dev": [
|
"packages-dev": [],
|
||||||
|
"aliases": [],
|
||||||
],
|
|
||||||
"aliases": [
|
|
||||||
|
|
||||||
],
|
|
||||||
"minimum-stability": "stable",
|
"minimum-stability": "stable",
|
||||||
"stability-flags": {
|
"stability-flags": {
|
||||||
"michelf/php-markdown": 20
|
"michelf/php-markdown": 20,
|
||||||
|
"kanti/hub-updater": 20
|
||||||
},
|
},
|
||||||
"platform": [
|
"prefer-stable": false,
|
||||||
|
"platform": [],
|
||||||
],
|
"platform-dev": []
|
||||||
"platform-dev": [
|
|
||||||
|
|
||||||
]
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
BIN
composer.phar
BIN
composer.phar
Binary file not shown.
|
|
@ -1228,8 +1228,8 @@ get('/feed/opml', function() {
|
||||||
get('/admin/update/now/:csrf', function($CSRF) {
|
get('/admin/update/now/:csrf', function($CSRF) {
|
||||||
|
|
||||||
$proper = is_csrf_proper($CSRF);
|
$proper = is_csrf_proper($CSRF);
|
||||||
$updater = new Updater;
|
$updater = new \Kanti\Updater;
|
||||||
if (login() && $proper && $updater->updateAble()) {
|
if (login() && $proper && $updater->able()) {
|
||||||
$updater->update();
|
$updater->update();
|
||||||
config('views.root', 'system/admin/views');
|
config('views.root', 'system/admin/views');
|
||||||
render('updated-to', array(
|
render('updated-to', array(
|
||||||
|
|
|
||||||
|
|
@ -1622,7 +1622,10 @@ function toolbar() {
|
||||||
|
|
||||||
$CSRF = get_csrf();
|
$CSRF = get_csrf();
|
||||||
|
|
||||||
$updater = new Updater;
|
$updater = new \Kanti\Updater(array(
|
||||||
|
'name' => 'danpros/htmly',
|
||||||
|
'prerelease' => config("prerelease"),
|
||||||
|
));
|
||||||
|
|
||||||
echo <<<EOF
|
echo <<<EOF
|
||||||
<link href="{$base}themes/default/css/toolbar.css" rel="stylesheet" />
|
<link href="{$base}themes/default/css/toolbar.css" rel="stylesheet" />
|
||||||
|
|
@ -1639,7 +1642,7 @@ EOF;
|
||||||
echo '<li><a href="' . $base . 'admin/import">Import</a></li>';
|
echo '<li><a href="' . $base . 'admin/import">Import</a></li>';
|
||||||
echo '<li><a href="' . $base . 'admin/backup">Backup</a></li>';
|
echo '<li><a href="' . $base . 'admin/backup">Backup</a></li>';
|
||||||
echo '<li><a href="' . $base . 'admin/clear-cache">Clear cache</a></li>';
|
echo '<li><a href="' . $base . 'admin/clear-cache">Clear cache</a></li>';
|
||||||
if ($updater->updateAble()) {
|
if ($updater->able()) {
|
||||||
echo '<li><a href="' . $base . 'admin/update/now/' . $CSRF . '">Update to ' . $updater->getName() . '</a></li>';
|
echo '<li><a href="' . $base . 'admin/update/now/' . $CSRF . '">Update to ' . $updater->getName() . '</a></li>';
|
||||||
}
|
}
|
||||||
echo '<li><a href="' . $base . 'logout">Logout</a></li>';
|
echo '<li><a href="' . $base . 'logout">Logout</a></li>';
|
||||||
|
|
|
||||||
2
vendor/autoload.php
vendored
2
vendor/autoload.php
vendored
|
|
@ -4,4 +4,4 @@
|
||||||
|
|
||||||
require_once __DIR__ . '/composer' . '/autoload_real.php';
|
require_once __DIR__ . '/composer' . '/autoload_real.php';
|
||||||
|
|
||||||
return ComposerAutoloaderInitd3ea151fa7d895c222811d503fe2be24::getLoader();
|
return ComposerAutoloaderInit181c8f31ce07c1aa29ef78a7a9b430c3::getLoader();
|
||||||
|
|
|
||||||
43
vendor/composer/ClassLoader.php
vendored
43
vendor/composer/ClassLoader.php
vendored
|
|
@ -143,6 +143,8 @@ class ClassLoader
|
||||||
* @param string $prefix The prefix/namespace, with trailing '\\'
|
* @param string $prefix The prefix/namespace, with trailing '\\'
|
||||||
* @param array|string $paths The PSR-0 base directories
|
* @param array|string $paths The PSR-0 base directories
|
||||||
* @param bool $prepend Whether to prepend the directories
|
* @param bool $prepend Whether to prepend the directories
|
||||||
|
*
|
||||||
|
* @throws \InvalidArgumentException
|
||||||
*/
|
*/
|
||||||
public function addPsr4($prefix, $paths, $prepend = false)
|
public function addPsr4($prefix, $paths, $prepend = false)
|
||||||
{
|
{
|
||||||
|
|
@ -204,8 +206,11 @@ class ClassLoader
|
||||||
*
|
*
|
||||||
* @param string $prefix The prefix/namespace, with trailing '\\'
|
* @param string $prefix The prefix/namespace, with trailing '\\'
|
||||||
* @param array|string $paths The PSR-4 base directories
|
* @param array|string $paths The PSR-4 base directories
|
||||||
|
*
|
||||||
|
* @throws \InvalidArgumentException
|
||||||
*/
|
*/
|
||||||
public function setPsr4($prefix, $paths) {
|
public function setPsr4($prefix, $paths)
|
||||||
|
{
|
||||||
if (!$prefix) {
|
if (!$prefix) {
|
||||||
$this->fallbackDirsPsr4 = (array) $paths;
|
$this->fallbackDirsPsr4 = (array) $paths;
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -266,7 +271,7 @@ class ClassLoader
|
||||||
public function loadClass($class)
|
public function loadClass($class)
|
||||||
{
|
{
|
||||||
if ($file = $this->findFile($class)) {
|
if ($file = $this->findFile($class)) {
|
||||||
include $file;
|
includeFile($file);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
@ -291,8 +296,25 @@ class ClassLoader
|
||||||
return $this->classMap[$class];
|
return $this->classMap[$class];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$file = $this->findFileWithExtension($class, '.php');
|
||||||
|
|
||||||
|
// Search for Hack files if we are running on HHVM
|
||||||
|
if ($file === null && defined('HHVM_VERSION')) {
|
||||||
|
$file = $this->findFileWithExtension($class, '.hh');
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($file === null) {
|
||||||
|
// Remember that this class does not exist.
|
||||||
|
return $this->classMap[$class] = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $file;
|
||||||
|
}
|
||||||
|
|
||||||
|
private function findFileWithExtension($class, $ext)
|
||||||
|
{
|
||||||
// PSR-4 lookup
|
// PSR-4 lookup
|
||||||
$logicalPathPsr4 = strtr($class, '\\', DIRECTORY_SEPARATOR) . '.php';
|
$logicalPathPsr4 = strtr($class, '\\', DIRECTORY_SEPARATOR) . $ext;
|
||||||
|
|
||||||
$first = $class[0];
|
$first = $class[0];
|
||||||
if (isset($this->prefixLengthsPsr4[$first])) {
|
if (isset($this->prefixLengthsPsr4[$first])) {
|
||||||
|
|
@ -321,7 +343,7 @@ class ClassLoader
|
||||||
. strtr(substr($logicalPathPsr4, $pos + 1), '_', DIRECTORY_SEPARATOR);
|
. strtr(substr($logicalPathPsr4, $pos + 1), '_', DIRECTORY_SEPARATOR);
|
||||||
} else {
|
} else {
|
||||||
// PEAR-like class name
|
// PEAR-like class name
|
||||||
$logicalPathPsr0 = strtr($class, '_', DIRECTORY_SEPARATOR) . '.php';
|
$logicalPathPsr0 = strtr($class, '_', DIRECTORY_SEPARATOR) . $ext;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isset($this->prefixesPsr0[$first])) {
|
if (isset($this->prefixesPsr0[$first])) {
|
||||||
|
|
@ -347,8 +369,15 @@ class ClassLoader
|
||||||
if ($this->useIncludePath && $file = stream_resolve_include_path($logicalPathPsr0)) {
|
if ($this->useIncludePath && $file = stream_resolve_include_path($logicalPathPsr0)) {
|
||||||
return $file;
|
return $file;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Remember that this class does not exist.
|
|
||||||
return $this->classMap[$class] = false;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Scope isolated include.
|
||||||
|
*
|
||||||
|
* Prevents access to $this/self from included files.
|
||||||
|
*/
|
||||||
|
function includeFile($file)
|
||||||
|
{
|
||||||
|
include $file;
|
||||||
|
}
|
||||||
|
|
|
||||||
1
vendor/composer/autoload_psr4.php
vendored
1
vendor/composer/autoload_psr4.php
vendored
|
|
@ -6,4 +6,5 @@ $vendorDir = dirname(dirname(__FILE__));
|
||||||
$baseDir = dirname($vendorDir);
|
$baseDir = dirname($vendorDir);
|
||||||
|
|
||||||
return array(
|
return array(
|
||||||
|
'Kanti\\' => array($vendorDir . '/kanti/hub-updater'),
|
||||||
);
|
);
|
||||||
|
|
|
||||||
14
vendor/composer/autoload_real.php
vendored
14
vendor/composer/autoload_real.php
vendored
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
// autoload_real.php @generated by Composer
|
// autoload_real.php @generated by Composer
|
||||||
|
|
||||||
class ComposerAutoloaderInitd3ea151fa7d895c222811d503fe2be24
|
class ComposerAutoloaderInit181c8f31ce07c1aa29ef78a7a9b430c3
|
||||||
{
|
{
|
||||||
private static $loader;
|
private static $loader;
|
||||||
|
|
||||||
|
|
@ -19,12 +19,9 @@ class ComposerAutoloaderInitd3ea151fa7d895c222811d503fe2be24
|
||||||
return self::$loader;
|
return self::$loader;
|
||||||
}
|
}
|
||||||
|
|
||||||
spl_autoload_register(array('ComposerAutoloaderInitd3ea151fa7d895c222811d503fe2be24', 'loadClassLoader'), true, true);
|
spl_autoload_register(array('ComposerAutoloaderInit181c8f31ce07c1aa29ef78a7a9b430c3', 'loadClassLoader'), true, true);
|
||||||
self::$loader = $loader = new \Composer\Autoload\ClassLoader();
|
self::$loader = $loader = new \Composer\Autoload\ClassLoader();
|
||||||
spl_autoload_unregister(array('ComposerAutoloaderInitd3ea151fa7d895c222811d503fe2be24', 'loadClassLoader'));
|
spl_autoload_unregister(array('ComposerAutoloaderInit181c8f31ce07c1aa29ef78a7a9b430c3', 'loadClassLoader'));
|
||||||
|
|
||||||
$vendorDir = dirname(__DIR__);
|
|
||||||
$baseDir = dirname($vendorDir);
|
|
||||||
|
|
||||||
$map = require __DIR__ . '/autoload_namespaces.php';
|
$map = require __DIR__ . '/autoload_namespaces.php';
|
||||||
foreach ($map as $namespace => $path) {
|
foreach ($map as $namespace => $path) {
|
||||||
|
|
@ -46,3 +43,8 @@ class ComposerAutoloaderInitd3ea151fa7d895c222811d503fe2be24
|
||||||
return $loader;
|
return $loader;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function composerRequire181c8f31ce07c1aa29ef78a7a9b430c3($file)
|
||||||
|
{
|
||||||
|
require $file;
|
||||||
|
}
|
||||||
|
|
|
||||||
50
vendor/composer/installed.json
vendored
50
vendor/composer/installed.json
vendored
|
|
@ -1,4 +1,44 @@
|
||||||
[
|
[
|
||||||
|
{
|
||||||
|
"name": "kanti/hub-updater",
|
||||||
|
"version": "dev-master",
|
||||||
|
"version_normalized": "9999999-dev",
|
||||||
|
"source": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "https://github.com/Kanti/hub-updater.git",
|
||||||
|
"reference": "fd965ed3524720d70a0cdddbd95e83f536c9b24f"
|
||||||
|
},
|
||||||
|
"dist": {
|
||||||
|
"type": "zip",
|
||||||
|
"url": "https://api.github.com/repos/Kanti/hub-updater/zipball/fd965ed3524720d70a0cdddbd95e83f536c9b24f",
|
||||||
|
"reference": "fd965ed3524720d70a0cdddbd95e83f536c9b24f",
|
||||||
|
"shasum": ""
|
||||||
|
},
|
||||||
|
"require": {
|
||||||
|
"php": ">=5.4.0"
|
||||||
|
},
|
||||||
|
"time": "2014-10-31 18:20:52",
|
||||||
|
"type": "library",
|
||||||
|
"installation-source": "dist",
|
||||||
|
"autoload": {
|
||||||
|
"psr-4": {
|
||||||
|
"Kanti\\": ""
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"notification-url": "https://packagist.org/downloads/",
|
||||||
|
"license": [
|
||||||
|
"GPL-2.0"
|
||||||
|
],
|
||||||
|
"authors": [
|
||||||
|
{
|
||||||
|
"name": "Kanti",
|
||||||
|
"email": "git@kanti.de",
|
||||||
|
"homepage": "https://kanti.de",
|
||||||
|
"role": "Developer"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"description": "Simple Github Updater for Web Projects [PHP]"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"name": "michelf/php-markdown",
|
"name": "michelf/php-markdown",
|
||||||
"version": "dev-lib",
|
"version": "dev-lib",
|
||||||
|
|
@ -6,25 +46,25 @@
|
||||||
"source": {
|
"source": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://github.com/michelf/php-markdown.git",
|
"url": "https://github.com/michelf/php-markdown.git",
|
||||||
"reference": "6f952ee180e9bd345f3dd6005aa11e0f5dcbd1b8"
|
"reference": "a8c56ecd5e9e7c7d37d00c814c864c3bc8b32694"
|
||||||
},
|
},
|
||||||
"dist": {
|
"dist": {
|
||||||
"type": "zip",
|
"type": "zip",
|
||||||
"url": "https://api.github.com/repos/michelf/php-markdown/zipball/6f952ee180e9bd345f3dd6005aa11e0f5dcbd1b8",
|
"url": "https://api.github.com/repos/michelf/php-markdown/zipball/a8c56ecd5e9e7c7d37d00c814c864c3bc8b32694",
|
||||||
"reference": "6f952ee180e9bd345f3dd6005aa11e0f5dcbd1b8",
|
"reference": "a8c56ecd5e9e7c7d37d00c814c864c3bc8b32694",
|
||||||
"shasum": ""
|
"shasum": ""
|
||||||
},
|
},
|
||||||
"require": {
|
"require": {
|
||||||
"php": ">=5.3.0"
|
"php": ">=5.3.0"
|
||||||
},
|
},
|
||||||
"time": "2013-11-29 21:49:31",
|
"time": "2014-08-10 19:25:52",
|
||||||
"type": "library",
|
"type": "library",
|
||||||
"extra": {
|
"extra": {
|
||||||
"branch-alias": {
|
"branch-alias": {
|
||||||
"dev-lib": "1.4.x-dev"
|
"dev-lib": "1.4.x-dev"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"installation-source": "source",
|
"installation-source": "dist",
|
||||||
"autoload": {
|
"autoload": {
|
||||||
"psr-0": {
|
"psr-0": {
|
||||||
"Michelf": ""
|
"Michelf": ""
|
||||||
|
|
|
||||||
32
vendor/kanti/hub-updater/CacheOneFile.php
vendored
Normal file
32
vendor/kanti/hub-updater/CacheOneFile.php
vendored
Normal file
|
|
@ -0,0 +1,32 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Kanti;
|
||||||
|
|
||||||
|
class CacheOneFile {
|
||||||
|
|
||||||
|
protected $fileName = "";
|
||||||
|
protected $holdTime = 43200; //12h
|
||||||
|
|
||||||
|
public function __construct($fileName, $holdTime = 43200) {
|
||||||
|
$this->fileName = $fileName;
|
||||||
|
$this->holdTime = $holdTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function is() {
|
||||||
|
if (!file_exists($this->fileName))
|
||||||
|
return false;
|
||||||
|
if (filemtime($this->fileName) < ( time() - $this->holdTime )) {
|
||||||
|
unlink($this->fileName);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function get() {
|
||||||
|
return file_get_contents($this->fileName);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function set($content) {
|
||||||
|
file_put_contents($this->fileName, $content);
|
||||||
|
}
|
||||||
|
}
|
||||||
197
vendor/kanti/hub-updater/HubUpdater.php
vendored
Normal file
197
vendor/kanti/hub-updater/HubUpdater.php
vendored
Normal file
|
|
@ -0,0 +1,197 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Kanti;
|
||||||
|
|
||||||
|
class HubUpdater {
|
||||||
|
|
||||||
|
protected $options = [
|
||||||
|
"cacheFile" => "downloadInfo.json",
|
||||||
|
"versionFile" => "installedVersion.json",
|
||||||
|
"zipFile" => "tmpZipFile.zip",
|
||||||
|
|
||||||
|
"name" => "",
|
||||||
|
"branch" => "master",
|
||||||
|
"cache" => "cache/",
|
||||||
|
"save" => "",
|
||||||
|
"prerelease" => false,
|
||||||
|
];
|
||||||
|
|
||||||
|
protected $allRelease = [];
|
||||||
|
protected $newestRelease = [];
|
||||||
|
protected $streamContext = null;
|
||||||
|
|
||||||
|
public function __construct($option) {
|
||||||
|
if(is_array($option))
|
||||||
|
{
|
||||||
|
if(! isset($option['name']))
|
||||||
|
{
|
||||||
|
throw new Exception('No Name in Option Set');
|
||||||
|
}
|
||||||
|
$this->options = $option + $this->options;
|
||||||
|
}
|
||||||
|
else if(is_string($option))
|
||||||
|
{
|
||||||
|
$this->options['name'] = $option;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
throw new Exception('No Option Set');
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->options['cache'] = rtrim($this->options['cache'],'/');
|
||||||
|
if($this->options['cache'] !== ''){
|
||||||
|
$this->options['cache'] .= '/';
|
||||||
|
if (!file_exists($this->options['cache'])) {
|
||||||
|
mkdir($this->options['cache']);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$this->options['save'] = rtrim($this->options['save'],'/');
|
||||||
|
if($this->options['save'] !== ''){
|
||||||
|
$this->options['save'] .= '/';
|
||||||
|
if (!file_exists($this->options['save'])) {
|
||||||
|
mkdir($this->options['save']);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->cachedInfo = new CacheOneFile($this->options['cache'] . $this->options['cacheFile']);
|
||||||
|
|
||||||
|
$this->streamContext = stream_context_create(
|
||||||
|
array(
|
||||||
|
'http' => array(
|
||||||
|
'header' => "User-Agent: Awesome-Update-My-Self-" . $this->options['name'] . "\r\n
|
||||||
|
Accept: application/vnd.github.v3+json",
|
||||||
|
),
|
||||||
|
'ssl' => array(
|
||||||
|
'cafile' => dirname(__FILE__) . '/ca_bundle.crt',
|
||||||
|
'verify_peer' => true,
|
||||||
|
),
|
||||||
|
)
|
||||||
|
);
|
||||||
|
$this->streamContext2 = stream_context_create(
|
||||||
|
array(
|
||||||
|
'http' => array(
|
||||||
|
'header' => "User-Agent: Awesome-Update-My-Self-" . $this->options['name'] . "\r\n",
|
||||||
|
),
|
||||||
|
'ssl' => array(
|
||||||
|
'cafile' => dirname(__FILE__) . '/ca_bundle.crt',
|
||||||
|
'verify_peer' => true,
|
||||||
|
),
|
||||||
|
)
|
||||||
|
);
|
||||||
|
$this->allRelease = $this->getRemoteInfos();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function getRemoteInfos() {
|
||||||
|
$path = "https://api.github.com/repos/" . $this->options['name'] ."/releases";
|
||||||
|
if ($this->cachedInfo->is()) {
|
||||||
|
$fileContent = $this->cachedInfo->get();
|
||||||
|
} else {
|
||||||
|
if (!in_array('https', stream_get_wrappers())) {
|
||||||
|
return array();
|
||||||
|
}
|
||||||
|
$fileContent = @file_get_contents($path, false, $this->streamContext);
|
||||||
|
|
||||||
|
if ($fileContent === false) {
|
||||||
|
return array();
|
||||||
|
}
|
||||||
|
$json = json_decode($fileContent, true);
|
||||||
|
if(isset($json['message']))
|
||||||
|
{
|
||||||
|
$json = [];
|
||||||
|
}
|
||||||
|
$fileContent = json_encode($json, JSON_PRETTY_PRINT);
|
||||||
|
$this->cachedInfo->set($fileContent);
|
||||||
|
return $json;
|
||||||
|
}
|
||||||
|
return json_decode($fileContent, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function able() {
|
||||||
|
if (!in_array('https', stream_get_wrappers()))
|
||||||
|
return false;
|
||||||
|
if (empty($this->allRelease))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
foreach($this->allRelease as $release)
|
||||||
|
{
|
||||||
|
if(!$this->options['prerelease'] && $release['prerelease'])
|
||||||
|
continue;
|
||||||
|
if($this->options['branch'] !== $release['target_commitish'])
|
||||||
|
continue;
|
||||||
|
$this->newestRelease = $release;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (file_exists($this->options['cache'] . $this->options['versionFile'])) {
|
||||||
|
$fileContent = file_get_contents($this->options['cache'] . $this->options['versionFile']);
|
||||||
|
$current = json_decode($fileContent, true);
|
||||||
|
|
||||||
|
if (isset($current['id']) && $current['id'] == $this->newestRelease['id'])
|
||||||
|
return false;
|
||||||
|
if (isset($current['tag_name']) && $current['tag_name'] == $this->newestRelease['tag_name'])
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function update() {
|
||||||
|
if ($this->able()) {
|
||||||
|
if ($this->download($this->newestRelease['zipball_url'] )) {
|
||||||
|
if ($this->unZip()) {
|
||||||
|
unlink($this->options['cache'] . $this->options['zipFile']);
|
||||||
|
file_put_contents($this->options['cache'] . $this->options['versionFile'], json_encode(array(
|
||||||
|
"id" => $this->newestRelease['id'],
|
||||||
|
"tag_name" => $this->newestRelease['tag_name']
|
||||||
|
), JSON_PRETTY_PRINT));
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function download($url) {
|
||||||
|
$file = @fopen($url, 'r', false, $this->streamContext2);
|
||||||
|
if ($file == false)
|
||||||
|
return false;
|
||||||
|
file_put_contents(dirname($_SERVER['SCRIPT_FILENAME']) . "/" . $this->options['cache'] . $this->options['zipFile'], $file);
|
||||||
|
fclose($file);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function unZip() {
|
||||||
|
$path = dirname($_SERVER['SCRIPT_FILENAME']) . "/" . $this->options['cache'] . $this->options['zipFile'];
|
||||||
|
|
||||||
|
$zip = new \ZipArchive;
|
||||||
|
if ($zip->open($path) === true) {
|
||||||
|
$cutLength = strlen($zip->getNameIndex(0));
|
||||||
|
for ($i = 1; $i < $zip->numFiles; $i++) {//iterate throw the Zip
|
||||||
|
$fileName = $zip->getNameIndex($i);
|
||||||
|
$stat = $zip->statIndex($i);
|
||||||
|
if ($stat["crc"] == 0) {
|
||||||
|
$dirName = $this->options['save'] . substr($fileName, $cutLength);
|
||||||
|
if (!file_exists($dirName)) {
|
||||||
|
mkdir($dirName);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
copy("zip://" . $path . "#" . $fileName, $this->options['save'] . substr($fileName, $cutLength));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$zip->close();
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function printOne() {
|
||||||
|
$string = "<h3>Updated to<h3>";
|
||||||
|
$string .= "<h2>[" . $this->newestRelease['tag_name'] . "] " . $this->newestRelease['name'] . "</h2>\n";
|
||||||
|
$string .= "<p>" . $this->newestRelease['body'] . "</p>\n";
|
||||||
|
return $string;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getName() {
|
||||||
|
return $this->newestRelease['tag_name'];
|
||||||
|
}
|
||||||
|
}
|
||||||
340
vendor/kanti/hub-updater/LICENSE
vendored
Normal file
340
vendor/kanti/hub-updater/LICENSE
vendored
Normal file
|
|
@ -0,0 +1,340 @@
|
||||||
|
GNU GENERAL PUBLIC LICENSE
|
||||||
|
Version 2, June 1991
|
||||||
|
|
||||||
|
Copyright (C) 1989, 1991 Free Software Foundation, Inc., <http://fsf.org/>
|
||||||
|
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
|
Everyone is permitted to copy and distribute verbatim copies
|
||||||
|
of this license document, but changing it is not allowed.
|
||||||
|
|
||||||
|
Preamble
|
||||||
|
|
||||||
|
The licenses for most software are designed to take away your
|
||||||
|
freedom to share and change it. By contrast, the GNU General Public
|
||||||
|
License is intended to guarantee your freedom to share and change free
|
||||||
|
software--to make sure the software is free for all its users. This
|
||||||
|
General Public License applies to most of the Free Software
|
||||||
|
Foundation's software and to any other program whose authors commit to
|
||||||
|
using it. (Some other Free Software Foundation software is covered by
|
||||||
|
the GNU Lesser General Public License instead.) You can apply it to
|
||||||
|
your programs, too.
|
||||||
|
|
||||||
|
When we speak of free software, we are referring to freedom, not
|
||||||
|
price. Our General Public Licenses are designed to make sure that you
|
||||||
|
have the freedom to distribute copies of free software (and charge for
|
||||||
|
this service if you wish), that you receive source code or can get it
|
||||||
|
if you want it, that you can change the software or use pieces of it
|
||||||
|
in new free programs; and that you know you can do these things.
|
||||||
|
|
||||||
|
To protect your rights, we need to make restrictions that forbid
|
||||||
|
anyone to deny you these rights or to ask you to surrender the rights.
|
||||||
|
These restrictions translate to certain responsibilities for you if you
|
||||||
|
distribute copies of the software, or if you modify it.
|
||||||
|
|
||||||
|
For example, if you distribute copies of such a program, whether
|
||||||
|
gratis or for a fee, you must give the recipients all the rights that
|
||||||
|
you have. You must make sure that they, too, receive or can get the
|
||||||
|
source code. And you must show them these terms so they know their
|
||||||
|
rights.
|
||||||
|
|
||||||
|
We protect your rights with two steps: (1) copyright the software, and
|
||||||
|
(2) offer you this license which gives you legal permission to copy,
|
||||||
|
distribute and/or modify the software.
|
||||||
|
|
||||||
|
Also, for each author's protection and ours, we want to make certain
|
||||||
|
that everyone understands that there is no warranty for this free
|
||||||
|
software. If the software is modified by someone else and passed on, we
|
||||||
|
want its recipients to know that what they have is not the original, so
|
||||||
|
that any problems introduced by others will not reflect on the original
|
||||||
|
authors' reputations.
|
||||||
|
|
||||||
|
Finally, any free program is threatened constantly by software
|
||||||
|
patents. We wish to avoid the danger that redistributors of a free
|
||||||
|
program will individually obtain patent licenses, in effect making the
|
||||||
|
program proprietary. To prevent this, we have made it clear that any
|
||||||
|
patent must be licensed for everyone's free use or not licensed at all.
|
||||||
|
|
||||||
|
The precise terms and conditions for copying, distribution and
|
||||||
|
modification follow.
|
||||||
|
|
||||||
|
GNU GENERAL PUBLIC LICENSE
|
||||||
|
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
|
||||||
|
|
||||||
|
0. This License applies to any program or other work which contains
|
||||||
|
a notice placed by the copyright holder saying it may be distributed
|
||||||
|
under the terms of this General Public License. The "Program", below,
|
||||||
|
refers to any such program or work, and a "work based on the Program"
|
||||||
|
means either the Program or any derivative work under copyright law:
|
||||||
|
that is to say, a work containing the Program or a portion of it,
|
||||||
|
either verbatim or with modifications and/or translated into another
|
||||||
|
language. (Hereinafter, translation is included without limitation in
|
||||||
|
the term "modification".) Each licensee is addressed as "you".
|
||||||
|
|
||||||
|
Activities other than copying, distribution and modification are not
|
||||||
|
covered by this License; they are outside its scope. The act of
|
||||||
|
running the Program is not restricted, and the output from the Program
|
||||||
|
is covered only if its contents constitute a work based on the
|
||||||
|
Program (independent of having been made by running the Program).
|
||||||
|
Whether that is true depends on what the Program does.
|
||||||
|
|
||||||
|
1. You may copy and distribute verbatim copies of the Program's
|
||||||
|
source code as you receive it, in any medium, provided that you
|
||||||
|
conspicuously and appropriately publish on each copy an appropriate
|
||||||
|
copyright notice and disclaimer of warranty; keep intact all the
|
||||||
|
notices that refer to this License and to the absence of any warranty;
|
||||||
|
and give any other recipients of the Program a copy of this License
|
||||||
|
along with the Program.
|
||||||
|
|
||||||
|
You may charge a fee for the physical act of transferring a copy, and
|
||||||
|
you may at your option offer warranty protection in exchange for a fee.
|
||||||
|
|
||||||
|
2. You may modify your copy or copies of the Program or any portion
|
||||||
|
of it, thus forming a work based on the Program, and copy and
|
||||||
|
distribute such modifications or work under the terms of Section 1
|
||||||
|
above, provided that you also meet all of these conditions:
|
||||||
|
|
||||||
|
a) You must cause the modified files to carry prominent notices
|
||||||
|
stating that you changed the files and the date of any change.
|
||||||
|
|
||||||
|
b) You must cause any work that you distribute or publish, that in
|
||||||
|
whole or in part contains or is derived from the Program or any
|
||||||
|
part thereof, to be licensed as a whole at no charge to all third
|
||||||
|
parties under the terms of this License.
|
||||||
|
|
||||||
|
c) If the modified program normally reads commands interactively
|
||||||
|
when run, you must cause it, when started running for such
|
||||||
|
interactive use in the most ordinary way, to print or display an
|
||||||
|
announcement including an appropriate copyright notice and a
|
||||||
|
notice that there is no warranty (or else, saying that you provide
|
||||||
|
a warranty) and that users may redistribute the program under
|
||||||
|
these conditions, and telling the user how to view a copy of this
|
||||||
|
License. (Exception: if the Program itself is interactive but
|
||||||
|
does not normally print such an announcement, your work based on
|
||||||
|
the Program is not required to print an announcement.)
|
||||||
|
|
||||||
|
These requirements apply to the modified work as a whole. If
|
||||||
|
identifiable sections of that work are not derived from the Program,
|
||||||
|
and can be reasonably considered independent and separate works in
|
||||||
|
themselves, then this License, and its terms, do not apply to those
|
||||||
|
sections when you distribute them as separate works. But when you
|
||||||
|
distribute the same sections as part of a whole which is a work based
|
||||||
|
on the Program, the distribution of the whole must be on the terms of
|
||||||
|
this License, whose permissions for other licensees extend to the
|
||||||
|
entire whole, and thus to each and every part regardless of who wrote it.
|
||||||
|
|
||||||
|
Thus, it is not the intent of this section to claim rights or contest
|
||||||
|
your rights to work written entirely by you; rather, the intent is to
|
||||||
|
exercise the right to control the distribution of derivative or
|
||||||
|
collective works based on the Program.
|
||||||
|
|
||||||
|
In addition, mere aggregation of another work not based on the Program
|
||||||
|
with the Program (or with a work based on the Program) on a volume of
|
||||||
|
a storage or distribution medium does not bring the other work under
|
||||||
|
the scope of this License.
|
||||||
|
|
||||||
|
3. You may copy and distribute the Program (or a work based on it,
|
||||||
|
under Section 2) in object code or executable form under the terms of
|
||||||
|
Sections 1 and 2 above provided that you also do one of the following:
|
||||||
|
|
||||||
|
a) Accompany it with the complete corresponding machine-readable
|
||||||
|
source code, which must be distributed under the terms of Sections
|
||||||
|
1 and 2 above on a medium customarily used for software interchange; or,
|
||||||
|
|
||||||
|
b) Accompany it with a written offer, valid for at least three
|
||||||
|
years, to give any third party, for a charge no more than your
|
||||||
|
cost of physically performing source distribution, a complete
|
||||||
|
machine-readable copy of the corresponding source code, to be
|
||||||
|
distributed under the terms of Sections 1 and 2 above on a medium
|
||||||
|
customarily used for software interchange; or,
|
||||||
|
|
||||||
|
c) Accompany it with the information you received as to the offer
|
||||||
|
to distribute corresponding source code. (This alternative is
|
||||||
|
allowed only for noncommercial distribution and only if you
|
||||||
|
received the program in object code or executable form with such
|
||||||
|
an offer, in accord with Subsection b above.)
|
||||||
|
|
||||||
|
The source code for a work means the preferred form of the work for
|
||||||
|
making modifications to it. For an executable work, complete source
|
||||||
|
code means all the source code for all modules it contains, plus any
|
||||||
|
associated interface definition files, plus the scripts used to
|
||||||
|
control compilation and installation of the executable. However, as a
|
||||||
|
special exception, the source code distributed need not include
|
||||||
|
anything that is normally distributed (in either source or binary
|
||||||
|
form) with the major components (compiler, kernel, and so on) of the
|
||||||
|
operating system on which the executable runs, unless that component
|
||||||
|
itself accompanies the executable.
|
||||||
|
|
||||||
|
If distribution of executable or object code is made by offering
|
||||||
|
access to copy from a designated place, then offering equivalent
|
||||||
|
access to copy the source code from the same place counts as
|
||||||
|
distribution of the source code, even though third parties are not
|
||||||
|
compelled to copy the source along with the object code.
|
||||||
|
|
||||||
|
4. You may not copy, modify, sublicense, or distribute the Program
|
||||||
|
except as expressly provided under this License. Any attempt
|
||||||
|
otherwise to copy, modify, sublicense or distribute the Program is
|
||||||
|
void, and will automatically terminate your rights under this License.
|
||||||
|
However, parties who have received copies, or rights, from you under
|
||||||
|
this License will not have their licenses terminated so long as such
|
||||||
|
parties remain in full compliance.
|
||||||
|
|
||||||
|
5. You are not required to accept this License, since you have not
|
||||||
|
signed it. However, nothing else grants you permission to modify or
|
||||||
|
distribute the Program or its derivative works. These actions are
|
||||||
|
prohibited by law if you do not accept this License. Therefore, by
|
||||||
|
modifying or distributing the Program (or any work based on the
|
||||||
|
Program), you indicate your acceptance of this License to do so, and
|
||||||
|
all its terms and conditions for copying, distributing or modifying
|
||||||
|
the Program or works based on it.
|
||||||
|
|
||||||
|
6. Each time you redistribute the Program (or any work based on the
|
||||||
|
Program), the recipient automatically receives a license from the
|
||||||
|
original licensor to copy, distribute or modify the Program subject to
|
||||||
|
these terms and conditions. You may not impose any further
|
||||||
|
restrictions on the recipients' exercise of the rights granted herein.
|
||||||
|
You are not responsible for enforcing compliance by third parties to
|
||||||
|
this License.
|
||||||
|
|
||||||
|
7. If, as a consequence of a court judgment or allegation of patent
|
||||||
|
infringement or for any other reason (not limited to patent issues),
|
||||||
|
conditions are imposed on you (whether by court order, agreement or
|
||||||
|
otherwise) that contradict the conditions of this License, they do not
|
||||||
|
excuse you from the conditions of this License. If you cannot
|
||||||
|
distribute so as to satisfy simultaneously your obligations under this
|
||||||
|
License and any other pertinent obligations, then as a consequence you
|
||||||
|
may not distribute the Program at all. For example, if a patent
|
||||||
|
license would not permit royalty-free redistribution of the Program by
|
||||||
|
all those who receive copies directly or indirectly through you, then
|
||||||
|
the only way you could satisfy both it and this License would be to
|
||||||
|
refrain entirely from distribution of the Program.
|
||||||
|
|
||||||
|
If any portion of this section is held invalid or unenforceable under
|
||||||
|
any particular circumstance, the balance of the section is intended to
|
||||||
|
apply and the section as a whole is intended to apply in other
|
||||||
|
circumstances.
|
||||||
|
|
||||||
|
It is not the purpose of this section to induce you to infringe any
|
||||||
|
patents or other property right claims or to contest validity of any
|
||||||
|
such claims; this section has the sole purpose of protecting the
|
||||||
|
integrity of the free software distribution system, which is
|
||||||
|
implemented by public license practices. Many people have made
|
||||||
|
generous contributions to the wide range of software distributed
|
||||||
|
through that system in reliance on consistent application of that
|
||||||
|
system; it is up to the author/donor to decide if he or she is willing
|
||||||
|
to distribute software through any other system and a licensee cannot
|
||||||
|
impose that choice.
|
||||||
|
|
||||||
|
This section is intended to make thoroughly clear what is believed to
|
||||||
|
be a consequence of the rest of this License.
|
||||||
|
|
||||||
|
8. If the distribution and/or use of the Program is restricted in
|
||||||
|
certain countries either by patents or by copyrighted interfaces, the
|
||||||
|
original copyright holder who places the Program under this License
|
||||||
|
may add an explicit geographical distribution limitation excluding
|
||||||
|
those countries, so that distribution is permitted only in or among
|
||||||
|
countries not thus excluded. In such case, this License incorporates
|
||||||
|
the limitation as if written in the body of this License.
|
||||||
|
|
||||||
|
9. The Free Software Foundation may publish revised and/or new versions
|
||||||
|
of the General Public License from time to time. Such new versions will
|
||||||
|
be similar in spirit to the present version, but may differ in detail to
|
||||||
|
address new problems or concerns.
|
||||||
|
|
||||||
|
Each version is given a distinguishing version number. If the Program
|
||||||
|
specifies a version number of this License which applies to it and "any
|
||||||
|
later version", you have the option of following the terms and conditions
|
||||||
|
either of that version or of any later version published by the Free
|
||||||
|
Software Foundation. If the Program does not specify a version number of
|
||||||
|
this License, you may choose any version ever published by the Free Software
|
||||||
|
Foundation.
|
||||||
|
|
||||||
|
10. If you wish to incorporate parts of the Program into other free
|
||||||
|
programs whose distribution conditions are different, write to the author
|
||||||
|
to ask for permission. For software which is copyrighted by the Free
|
||||||
|
Software Foundation, write to the Free Software Foundation; we sometimes
|
||||||
|
make exceptions for this. Our decision will be guided by the two goals
|
||||||
|
of preserving the free status of all derivatives of our free software and
|
||||||
|
of promoting the sharing and reuse of software generally.
|
||||||
|
|
||||||
|
NO WARRANTY
|
||||||
|
|
||||||
|
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
|
||||||
|
FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
|
||||||
|
OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
|
||||||
|
PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
|
||||||
|
OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||||
|
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
|
||||||
|
TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
|
||||||
|
PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
|
||||||
|
REPAIR OR CORRECTION.
|
||||||
|
|
||||||
|
12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
||||||
|
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
|
||||||
|
REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
|
||||||
|
INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
|
||||||
|
OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
|
||||||
|
TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
|
||||||
|
YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
|
||||||
|
PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
|
||||||
|
POSSIBILITY OF SUCH DAMAGES.
|
||||||
|
|
||||||
|
END OF TERMS AND CONDITIONS
|
||||||
|
|
||||||
|
How to Apply These Terms to Your New Programs
|
||||||
|
|
||||||
|
If you develop a new program, and you want it to be of the greatest
|
||||||
|
possible use to the public, the best way to achieve this is to make it
|
||||||
|
free software which everyone can redistribute and change under these terms.
|
||||||
|
|
||||||
|
To do so, attach the following notices to the program. It is safest
|
||||||
|
to attach them to the start of each source file to most effectively
|
||||||
|
convey the exclusion of warranty; and each file should have at least
|
||||||
|
the "copyright" line and a pointer to where the full notice is found.
|
||||||
|
|
||||||
|
{description}
|
||||||
|
Copyright (C) {year} {fullname}
|
||||||
|
|
||||||
|
This program is free software; you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation; either version 2 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License along
|
||||||
|
with this program; if not, write to the Free Software Foundation, Inc.,
|
||||||
|
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||||
|
|
||||||
|
Also add information on how to contact you by electronic and paper mail.
|
||||||
|
|
||||||
|
If the program is interactive, make it output a short notice like this
|
||||||
|
when it starts in an interactive mode:
|
||||||
|
|
||||||
|
Gnomovision version 69, Copyright (C) year name of author
|
||||||
|
Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
||||||
|
This is free software, and you are welcome to redistribute it
|
||||||
|
under certain conditions; type `show c' for details.
|
||||||
|
|
||||||
|
The hypothetical commands `show w' and `show c' should show the appropriate
|
||||||
|
parts of the General Public License. Of course, the commands you use may
|
||||||
|
be called something other than `show w' and `show c'; they could even be
|
||||||
|
mouse-clicks or menu items--whatever suits your program.
|
||||||
|
|
||||||
|
You should also get your employer (if you work as a programmer) or your
|
||||||
|
school, if any, to sign a "copyright disclaimer" for the program, if
|
||||||
|
necessary. Here is a sample; alter the names:
|
||||||
|
|
||||||
|
Yoyodyne, Inc., hereby disclaims all copyright interest in the program
|
||||||
|
`Gnomovision' (which makes passes at compilers) written by James Hacker.
|
||||||
|
|
||||||
|
{signature of Ty Coon}, 1 April 1989
|
||||||
|
Ty Coon, President of Vice
|
||||||
|
|
||||||
|
This General Public License does not permit incorporating your program into
|
||||||
|
proprietary programs. If your program is a subroutine library, you may
|
||||||
|
consider it more useful to permit linking proprietary applications with the
|
||||||
|
library. If this is what you want to do, use the GNU Lesser General
|
||||||
|
Public License instead of this License.
|
||||||
|
|
||||||
104
vendor/kanti/hub-updater/README.md
vendored
Normal file
104
vendor/kanti/hub-updater/README.md
vendored
Normal file
|
|
@ -0,0 +1,104 @@
|
||||||
|
HubUpdater
|
||||||
|
==========
|
||||||
|
|
||||||
|
Simple Github Updater for Web Projects [PHP]
|
||||||
|
|
||||||
|
is HubUpdater for me? [Checklist]
|
||||||
|
----------
|
||||||
|
- [ ] I have an little product/projekt on github. (~ 0-30MB)
|
||||||
|
- [ ] it uses PHP
|
||||||
|
- [ ] I want my users to update my Product with one click
|
||||||
|
|
||||||
|
Check for an update [simple]
|
||||||
|
----------
|
||||||
|
```php
|
||||||
|
<?php
|
||||||
|
require 'vendor/autoload.php';
|
||||||
|
|
||||||
|
$updater = new \Kanti\HubUpdater('kanti/test');
|
||||||
|
$updater->update();
|
||||||
|
```
|
||||||
|
|
||||||
|
how to provide an update?
|
||||||
|
----------
|
||||||
|
- Go to your Repository->
|
||||||
|
- click on ``releases``->
|
||||||
|
- ``Draft a new release``->
|
||||||
|
- Enter your details->
|
||||||
|
- click on ``Publish release``
|
||||||
|
|
||||||
|
|
||||||
|
Installing via Composer
|
||||||
|
----------
|
||||||
|
|
||||||
|
The recommended way to install hub-updater is through
|
||||||
|
[Composer](http://getcomposer.org).
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# Install Composer
|
||||||
|
curl -sS https://getcomposer.org/installer | php
|
||||||
|
```
|
||||||
|
|
||||||
|
Next, run the Composer command to install the latest stable version of Guzzle:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
composer require kanti/hub-updater dev-master
|
||||||
|
```
|
||||||
|
|
||||||
|
After installing, you need to require Composer's autoloader:
|
||||||
|
|
||||||
|
```php
|
||||||
|
<?php
|
||||||
|
require 'vendor/autoload.php';
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
Settings
|
||||||
|
----------
|
||||||
|
```php
|
||||||
|
$settings = array(
|
||||||
|
"settingsKey" => 'value',
|
||||||
|
);
|
||||||
|
new \Kanti\HubUpdater($settings);
|
||||||
|
```
|
||||||
|
|Setting|Description|default|
|
||||||
|
|---|---|---|
|
||||||
|
|name|the name your Repository has |must be set|
|
||||||
|
|branch|the branch you like to watch. |``master``|
|
||||||
|
|cache|the directory you like to put the cache stuff |``./cache/``|
|
||||||
|
|save|the directory you like to put the content of the zip. |``./``|
|
||||||
|
|prerelease|would you like to download the prereleases? |``false``|
|
||||||
|
|
||||||
|
Check for an update [complete]
|
||||||
|
----------
|
||||||
|
```php
|
||||||
|
<?php
|
||||||
|
require 'vendor/autoload.php';
|
||||||
|
|
||||||
|
$updater = new \Kanti\HubUpdater([
|
||||||
|
"name" => 'kanti/test',//Repository to watch
|
||||||
|
"branch" => 'master',//wich branch to watch
|
||||||
|
"cache" => 'cache/',//were to put the caching stuff
|
||||||
|
"save" => 'save/',//there to put the downloaded Version[default ./]
|
||||||
|
"prerelease" => true,//accept prereleases?
|
||||||
|
]);
|
||||||
|
if($updater->able())
|
||||||
|
{
|
||||||
|
if(isset($_GET['update']))
|
||||||
|
{
|
||||||
|
$updater->update();
|
||||||
|
echo '<p>updated :)</p>';
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
echo '<a href="?update">Update Me</a>'; //only update if they klick this link
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
echo '<p>uptodate :)</p>';
|
||||||
|
}
|
||||||
|
```
|
||||||
|
Thanks:
|
||||||
|
----------
|
||||||
|
- ca_bundle.crt form [bagder/ca-bundle](https://github.com/bagder/ca-bundle)
|
||||||
3894
vendor/kanti/hub-updater/ca_bundle.crt
vendored
Normal file
3894
vendor/kanti/hub-updater/ca_bundle.crt
vendored
Normal file
File diff suppressed because it is too large
Load diff
27
vendor/kanti/hub-updater/composer.json
vendored
Normal file
27
vendor/kanti/hub-updater/composer.json
vendored
Normal file
|
|
@ -0,0 +1,27 @@
|
||||||
|
{
|
||||||
|
"name": "kanti/hub-updater",
|
||||||
|
"description": "Simple Github Updater for Web Projects [PHP]",
|
||||||
|
"license": "GPL-2.0",
|
||||||
|
"authors": [
|
||||||
|
{
|
||||||
|
"name": "Kanti",
|
||||||
|
"email": "git@kanti.de",
|
||||||
|
"homepage": "https://kanti.de",
|
||||||
|
"role": "Developer"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"support": {
|
||||||
|
"forum": "https://github.com/Kanti/hub-updater/issues",
|
||||||
|
"issues": "https://github.com/Kanti/hub-updater/issues",
|
||||||
|
"source": "https://github.com/Kanti/hub-updater"
|
||||||
|
},
|
||||||
|
"minimum-stability": "dev",
|
||||||
|
"require": {
|
||||||
|
"php": ">=5.4.0"
|
||||||
|
},
|
||||||
|
"autoload": {
|
||||||
|
"psr-4": {
|
||||||
|
"Kanti\\": ""
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
5
vendor/kanti/hub-updater/example.php
vendored
Normal file
5
vendor/kanti/hub-updater/example.php
vendored
Normal file
|
|
@ -0,0 +1,5 @@
|
||||||
|
<?php
|
||||||
|
require 'vendor/autoload.php';
|
||||||
|
|
||||||
|
$updater = new \Kanti\HubUpdater('kanti/test');
|
||||||
|
$updater->update();
|
||||||
26
vendor/kanti/hub-updater/example2.php
vendored
Normal file
26
vendor/kanti/hub-updater/example2.php
vendored
Normal file
|
|
@ -0,0 +1,26 @@
|
||||||
|
<?php
|
||||||
|
require 'vendor/autoload.php';
|
||||||
|
|
||||||
|
$updater = new \Kanti\HubUpdater([
|
||||||
|
"name" => 'kanti/test',//Repository to watch
|
||||||
|
"branch" => 'master',//wich branch to watch
|
||||||
|
"cache" => 'cache/',//were to put the caching stuff
|
||||||
|
"save" => 'save/',//there to put the downloaded Version[default ./]
|
||||||
|
"prerelease" => true,//accept prereleases?
|
||||||
|
]);
|
||||||
|
if($updater->able())
|
||||||
|
{
|
||||||
|
if(isset($_GET['update']))
|
||||||
|
{
|
||||||
|
$updater->update();
|
||||||
|
echo '<p>updated :)</p>';
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
echo '<a href="?update">Update Me</a>'; //only update if they klick this link
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
echo '<p>uptodate :)</p>';
|
||||||
|
}
|
||||||
2
vendor/michelf/php-markdown/License.md
vendored
2
vendor/michelf/php-markdown/License.md
vendored
|
|
@ -1,5 +1,5 @@
|
||||||
PHP Markdown Lib
|
PHP Markdown Lib
|
||||||
Copyright (c) 2004-2013 Michel Fortin
|
Copyright (c) 2004-2014 Michel Fortin
|
||||||
<http://michelf.ca/>
|
<http://michelf.ca/>
|
||||||
All rights reserved.
|
All rights reserved.
|
||||||
|
|
||||||
|
|
|
||||||
248
vendor/michelf/php-markdown/Michelf/Markdown.php
vendored
248
vendor/michelf/php-markdown/Michelf/Markdown.php
vendored
|
|
@ -3,7 +3,7 @@
|
||||||
# Markdown - A text-to-HTML conversion tool for web writers
|
# Markdown - A text-to-HTML conversion tool for web writers
|
||||||
#
|
#
|
||||||
# PHP Markdown
|
# PHP Markdown
|
||||||
# Copyright (c) 2004-2013 Michel Fortin
|
# Copyright (c) 2004-2014 Michel Fortin
|
||||||
# <http://michelf.com/projects/php-markdown/>
|
# <http://michelf.com/projects/php-markdown/>
|
||||||
#
|
#
|
||||||
# Original Markdown
|
# Original Markdown
|
||||||
|
|
@ -21,7 +21,7 @@ class Markdown implements MarkdownInterface {
|
||||||
|
|
||||||
### Version ###
|
### Version ###
|
||||||
|
|
||||||
const MARKDOWNLIB_VERSION = "1.4.0";
|
const MARKDOWNLIB_VERSION = "1.4.1";
|
||||||
|
|
||||||
### Simple Function Interface ###
|
### Simple Function Interface ###
|
||||||
|
|
||||||
|
|
@ -59,6 +59,9 @@ class Markdown implements MarkdownInterface {
|
||||||
public $predef_urls = array();
|
public $predef_urls = array();
|
||||||
public $predef_titles = array();
|
public $predef_titles = array();
|
||||||
|
|
||||||
|
# Optional filter function for URLs
|
||||||
|
public $url_filter_func = null;
|
||||||
|
|
||||||
|
|
||||||
### Parser Implementation ###
|
### Parser Implementation ###
|
||||||
|
|
||||||
|
|
@ -209,7 +212,7 @@ class Markdown implements MarkdownInterface {
|
||||||
)? # title is optional
|
)? # title is optional
|
||||||
(?:\n+|\Z)
|
(?:\n+|\Z)
|
||||||
}xm',
|
}xm',
|
||||||
array(&$this, '_stripLinkDefinitions_callback'),
|
array($this, '_stripLinkDefinitions_callback'),
|
||||||
$text);
|
$text);
|
||||||
return $text;
|
return $text;
|
||||||
}
|
}
|
||||||
|
|
@ -242,7 +245,7 @@ class Markdown implements MarkdownInterface {
|
||||||
#
|
#
|
||||||
$block_tags_a_re = 'ins|del';
|
$block_tags_a_re = 'ins|del';
|
||||||
$block_tags_b_re = 'p|div|h[1-6]|blockquote|pre|table|dl|ol|ul|address|'.
|
$block_tags_b_re = 'p|div|h[1-6]|blockquote|pre|table|dl|ol|ul|address|'.
|
||||||
'script|noscript|form|fieldset|iframe|math|svg|'.
|
'script|noscript|style|form|fieldset|iframe|math|svg|'.
|
||||||
'article|section|nav|aside|hgroup|header|footer|'.
|
'article|section|nav|aside|hgroup|header|footer|'.
|
||||||
'figure';
|
'figure';
|
||||||
|
|
||||||
|
|
@ -297,9 +300,9 @@ class Markdown implements MarkdownInterface {
|
||||||
# match will start at the first `<div>` and stop at the first `</div>`.
|
# match will start at the first `<div>` and stop at the first `</div>`.
|
||||||
$text = preg_replace_callback('{(?>
|
$text = preg_replace_callback('{(?>
|
||||||
(?>
|
(?>
|
||||||
(?<=\n\n) # Starting after a blank line
|
(?<=\n) # Starting on its own line
|
||||||
| # or
|
| # or
|
||||||
\A\n? # the beginning of the doc
|
\A\n? # the at beginning of the doc
|
||||||
)
|
)
|
||||||
( # save in $1
|
( # save in $1
|
||||||
|
|
||||||
|
|
@ -356,7 +359,7 @@ class Markdown implements MarkdownInterface {
|
||||||
|
|
||||||
)
|
)
|
||||||
)}Sxmi',
|
)}Sxmi',
|
||||||
array(&$this, '_hashHTMLBlocks_callback'),
|
array($this, '_hashHTMLBlocks_callback'),
|
||||||
$text);
|
$text);
|
||||||
|
|
||||||
return $text;
|
return $text;
|
||||||
|
|
@ -500,7 +503,7 @@ class Markdown implements MarkdownInterface {
|
||||||
protected function doHardBreaks($text) {
|
protected function doHardBreaks($text) {
|
||||||
# Do hard breaks:
|
# Do hard breaks:
|
||||||
return preg_replace_callback('/ {2,}\n/',
|
return preg_replace_callback('/ {2,}\n/',
|
||||||
array(&$this, '_doHardBreaks_callback'), $text);
|
array($this, '_doHardBreaks_callback'), $text);
|
||||||
}
|
}
|
||||||
protected function _doHardBreaks_callback($matches) {
|
protected function _doHardBreaks_callback($matches) {
|
||||||
return $this->hashPart("<br$this->empty_element_suffix\n");
|
return $this->hashPart("<br$this->empty_element_suffix\n");
|
||||||
|
|
@ -531,7 +534,7 @@ class Markdown implements MarkdownInterface {
|
||||||
\]
|
\]
|
||||||
)
|
)
|
||||||
}xs',
|
}xs',
|
||||||
array(&$this, '_doAnchors_reference_callback'), $text);
|
array($this, '_doAnchors_reference_callback'), $text);
|
||||||
|
|
||||||
#
|
#
|
||||||
# Next, inline-style links: [link text](url "optional title")
|
# Next, inline-style links: [link text](url "optional title")
|
||||||
|
|
@ -558,7 +561,7 @@ class Markdown implements MarkdownInterface {
|
||||||
\)
|
\)
|
||||||
)
|
)
|
||||||
}xs',
|
}xs',
|
||||||
array(&$this, '_doAnchors_inline_callback'), $text);
|
array($this, '_doAnchors_inline_callback'), $text);
|
||||||
|
|
||||||
#
|
#
|
||||||
# Last, handle reference-style shortcuts: [link text]
|
# Last, handle reference-style shortcuts: [link text]
|
||||||
|
|
@ -572,7 +575,7 @@ class Markdown implements MarkdownInterface {
|
||||||
\]
|
\]
|
||||||
)
|
)
|
||||||
}xs',
|
}xs',
|
||||||
array(&$this, '_doAnchors_reference_callback'), $text);
|
array($this, '_doAnchors_reference_callback'), $text);
|
||||||
|
|
||||||
$this->in_anchor = false;
|
$this->in_anchor = false;
|
||||||
return $text;
|
return $text;
|
||||||
|
|
@ -593,7 +596,7 @@ class Markdown implements MarkdownInterface {
|
||||||
|
|
||||||
if (isset($this->urls[$link_id])) {
|
if (isset($this->urls[$link_id])) {
|
||||||
$url = $this->urls[$link_id];
|
$url = $this->urls[$link_id];
|
||||||
$url = $this->encodeAttribute($url);
|
$url = $this->encodeURLAttribute($url);
|
||||||
|
|
||||||
$result = "<a href=\"$url\"";
|
$result = "<a href=\"$url\"";
|
||||||
if ( isset( $this->titles[$link_id] ) ) {
|
if ( isset( $this->titles[$link_id] ) ) {
|
||||||
|
|
@ -617,7 +620,13 @@ class Markdown implements MarkdownInterface {
|
||||||
$url = $matches[3] == '' ? $matches[4] : $matches[3];
|
$url = $matches[3] == '' ? $matches[4] : $matches[3];
|
||||||
$title =& $matches[7];
|
$title =& $matches[7];
|
||||||
|
|
||||||
$url = $this->encodeAttribute($url);
|
// if the URL was of the form <s p a c e s> it got caught by the HTML
|
||||||
|
// tag parser and hashed. Need to reverse the process before using the URL.
|
||||||
|
$unhashed = $this->unhash($url);
|
||||||
|
if ($unhashed != $url)
|
||||||
|
$url = preg_replace('/^<(.*)>$/', '\1', $unhashed);
|
||||||
|
|
||||||
|
$url = $this->encodeURLAttribute($url);
|
||||||
|
|
||||||
$result = "<a href=\"$url\"";
|
$result = "<a href=\"$url\"";
|
||||||
if (isset($title)) {
|
if (isset($title)) {
|
||||||
|
|
@ -654,7 +663,7 @@ class Markdown implements MarkdownInterface {
|
||||||
|
|
||||||
)
|
)
|
||||||
}xs',
|
}xs',
|
||||||
array(&$this, '_doImages_reference_callback'), $text);
|
array($this, '_doImages_reference_callback'), $text);
|
||||||
|
|
||||||
#
|
#
|
||||||
# Next, handle inline images: 
|
# Next, handle inline images: 
|
||||||
|
|
@ -683,7 +692,7 @@ class Markdown implements MarkdownInterface {
|
||||||
\)
|
\)
|
||||||
)
|
)
|
||||||
}xs',
|
}xs',
|
||||||
array(&$this, '_doImages_inline_callback'), $text);
|
array($this, '_doImages_inline_callback'), $text);
|
||||||
|
|
||||||
return $text;
|
return $text;
|
||||||
}
|
}
|
||||||
|
|
@ -698,7 +707,7 @@ class Markdown implements MarkdownInterface {
|
||||||
|
|
||||||
$alt_text = $this->encodeAttribute($alt_text);
|
$alt_text = $this->encodeAttribute($alt_text);
|
||||||
if (isset($this->urls[$link_id])) {
|
if (isset($this->urls[$link_id])) {
|
||||||
$url = $this->encodeAttribute($this->urls[$link_id]);
|
$url = $this->encodeURLAttribute($this->urls[$link_id]);
|
||||||
$result = "<img src=\"$url\" alt=\"$alt_text\"";
|
$result = "<img src=\"$url\" alt=\"$alt_text\"";
|
||||||
if (isset($this->titles[$link_id])) {
|
if (isset($this->titles[$link_id])) {
|
||||||
$title = $this->titles[$link_id];
|
$title = $this->titles[$link_id];
|
||||||
|
|
@ -722,7 +731,7 @@ class Markdown implements MarkdownInterface {
|
||||||
$title =& $matches[7];
|
$title =& $matches[7];
|
||||||
|
|
||||||
$alt_text = $this->encodeAttribute($alt_text);
|
$alt_text = $this->encodeAttribute($alt_text);
|
||||||
$url = $this->encodeAttribute($url);
|
$url = $this->encodeURLAttribute($url);
|
||||||
$result = "<img src=\"$url\" alt=\"$alt_text\"";
|
$result = "<img src=\"$url\" alt=\"$alt_text\"";
|
||||||
if (isset($title)) {
|
if (isset($title)) {
|
||||||
$title = $this->encodeAttribute($title);
|
$title = $this->encodeAttribute($title);
|
||||||
|
|
@ -743,7 +752,7 @@ class Markdown implements MarkdownInterface {
|
||||||
# --------
|
# --------
|
||||||
#
|
#
|
||||||
$text = preg_replace_callback('{ ^(.+?)[ ]*\n(=+|-+)[ ]*\n+ }mx',
|
$text = preg_replace_callback('{ ^(.+?)[ ]*\n(=+|-+)[ ]*\n+ }mx',
|
||||||
array(&$this, '_doHeaders_callback_setext'), $text);
|
array($this, '_doHeaders_callback_setext'), $text);
|
||||||
|
|
||||||
# atx-style headers:
|
# atx-style headers:
|
||||||
# # Header 1
|
# # Header 1
|
||||||
|
|
@ -760,7 +769,7 @@ class Markdown implements MarkdownInterface {
|
||||||
\#* # optional closing #\'s (not counted)
|
\#* # optional closing #\'s (not counted)
|
||||||
\n+
|
\n+
|
||||||
}xm',
|
}xm',
|
||||||
array(&$this, '_doHeaders_callback_atx'), $text);
|
array($this, '_doHeaders_callback_atx'), $text);
|
||||||
|
|
||||||
return $text;
|
return $text;
|
||||||
}
|
}
|
||||||
|
|
@ -789,7 +798,6 @@ class Markdown implements MarkdownInterface {
|
||||||
# Re-usable patterns to match list item bullets and number markers:
|
# Re-usable patterns to match list item bullets and number markers:
|
||||||
$marker_ul_re = '[*+-]';
|
$marker_ul_re = '[*+-]';
|
||||||
$marker_ol_re = '\d+[\.]';
|
$marker_ol_re = '\d+[\.]';
|
||||||
$marker_any_re = "(?:$marker_ul_re|$marker_ol_re)";
|
|
||||||
|
|
||||||
$markers_relist = array(
|
$markers_relist = array(
|
||||||
$marker_ul_re => $marker_ol_re,
|
$marker_ul_re => $marker_ol_re,
|
||||||
|
|
@ -833,14 +841,14 @@ class Markdown implements MarkdownInterface {
|
||||||
^
|
^
|
||||||
'.$whole_list_re.'
|
'.$whole_list_re.'
|
||||||
}mx',
|
}mx',
|
||||||
array(&$this, '_doLists_callback'), $text);
|
array($this, '_doLists_callback'), $text);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$text = preg_replace_callback('{
|
$text = preg_replace_callback('{
|
||||||
(?:(?<=\n)\n|\A\n?) # Must eat the newline
|
(?:(?<=\n)\n|\A\n?) # Must eat the newline
|
||||||
'.$whole_list_re.'
|
'.$whole_list_re.'
|
||||||
}mx',
|
}mx',
|
||||||
array(&$this, '_doLists_callback'), $text);
|
array($this, '_doLists_callback'), $text);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -907,7 +915,7 @@ class Markdown implements MarkdownInterface {
|
||||||
(?:(\n+(?=\n))|\n) # tailing blank line = $5
|
(?:(\n+(?=\n))|\n) # tailing blank line = $5
|
||||||
(?= \n* (\z | \2 ('.$marker_any_re.') (?:[ ]+|(?=\n))))
|
(?= \n* (\z | \2 ('.$marker_any_re.') (?:[ ]+|(?=\n))))
|
||||||
}xm',
|
}xm',
|
||||||
array(&$this, '_processListItems_callback'), $list_str);
|
array($this, '_processListItems_callback'), $list_str);
|
||||||
|
|
||||||
$this->list_level--;
|
$this->list_level--;
|
||||||
return $list_str;
|
return $list_str;
|
||||||
|
|
@ -951,7 +959,7 @@ class Markdown implements MarkdownInterface {
|
||||||
)
|
)
|
||||||
((?=^[ ]{0,'.$this->tab_width.'}\S)|\Z) # Lookahead for non-space at line-start, or end of doc
|
((?=^[ ]{0,'.$this->tab_width.'}\S)|\Z) # Lookahead for non-space at line-start, or end of doc
|
||||||
}xm',
|
}xm',
|
||||||
array(&$this, '_doCodeBlocks_callback'), $text);
|
array($this, '_doCodeBlocks_callback'), $text);
|
||||||
|
|
||||||
return $text;
|
return $text;
|
||||||
}
|
}
|
||||||
|
|
@ -979,19 +987,19 @@ class Markdown implements MarkdownInterface {
|
||||||
|
|
||||||
|
|
||||||
protected $em_relist = array(
|
protected $em_relist = array(
|
||||||
'' => '(?:(?<!\*)\*(?!\*)|(?<!_)_(?!_))(?=\S|$)(?![\.,:;]\s)',
|
'' => '(?:(?<!\*)\*(?!\*)|(?<!_)_(?!_))(?![\.,:;]?\s)',
|
||||||
'*' => '(?<=\S|^)(?<!\*)\*(?!\*)',
|
'*' => '(?<![\s*])\*(?!\*)',
|
||||||
'_' => '(?<=\S|^)(?<!_)_(?!_)',
|
'_' => '(?<![\s_])_(?!_)',
|
||||||
);
|
);
|
||||||
protected $strong_relist = array(
|
protected $strong_relist = array(
|
||||||
'' => '(?:(?<!\*)\*\*(?!\*)|(?<!_)__(?!_))(?=\S|$)(?![\.,:;]\s)',
|
'' => '(?:(?<!\*)\*\*(?!\*)|(?<!_)__(?!_))(?![\.,:;]?\s)',
|
||||||
'**' => '(?<=\S|^)(?<!\*)\*\*(?!\*)',
|
'**' => '(?<![\s*])\*\*(?!\*)',
|
||||||
'__' => '(?<=\S|^)(?<!_)__(?!_)',
|
'__' => '(?<![\s_])__(?!_)',
|
||||||
);
|
);
|
||||||
protected $em_strong_relist = array(
|
protected $em_strong_relist = array(
|
||||||
'' => '(?:(?<!\*)\*\*\*(?!\*)|(?<!_)___(?!_))(?=\S|$)(?![\.,:;]\s)',
|
'' => '(?:(?<!\*)\*\*\*(?!\*)|(?<!_)___(?!_))(?![\.,:;]?\s)',
|
||||||
'***' => '(?<=\S|^)(?<!\*)\*\*\*(?!\*)',
|
'***' => '(?<![\s*])\*\*\*(?!\*)',
|
||||||
'___' => '(?<=\S|^)(?<!_)___(?!_)',
|
'___' => '(?<![\s_])___(?!_)',
|
||||||
);
|
);
|
||||||
protected $em_strong_prepared_relist;
|
protected $em_strong_prepared_relist;
|
||||||
|
|
||||||
|
|
@ -1151,7 +1159,7 @@ class Markdown implements MarkdownInterface {
|
||||||
)+
|
)+
|
||||||
)
|
)
|
||||||
/xm',
|
/xm',
|
||||||
array(&$this, '_doBlockQuotes_callback'), $text);
|
array($this, '_doBlockQuotes_callback'), $text);
|
||||||
|
|
||||||
return $text;
|
return $text;
|
||||||
}
|
}
|
||||||
|
|
@ -1165,7 +1173,7 @@ class Markdown implements MarkdownInterface {
|
||||||
# These leading spaces cause problem with <pre> content,
|
# These leading spaces cause problem with <pre> content,
|
||||||
# so we need to fix that:
|
# so we need to fix that:
|
||||||
$bq = preg_replace_callback('{(\s*<pre>.+?</pre>)}sx',
|
$bq = preg_replace_callback('{(\s*<pre>.+?</pre>)}sx',
|
||||||
array(&$this, '_doBlockQuotes_callback2'), $bq);
|
array($this, '_doBlockQuotes_callback2'), $bq);
|
||||||
|
|
||||||
return "\n". $this->hashBlock("<blockquote>\n$bq\n</blockquote>")."\n\n";
|
return "\n". $this->hashBlock("<blockquote>\n$bq\n</blockquote>")."\n\n";
|
||||||
}
|
}
|
||||||
|
|
@ -1257,6 +1265,33 @@ class Markdown implements MarkdownInterface {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
protected function encodeURLAttribute($url, &$text = null) {
|
||||||
|
#
|
||||||
|
# Encode text for a double-quoted HTML attribute containing a URL,
|
||||||
|
# applying the URL filter if set. Also generates the textual
|
||||||
|
# representation for the URL (removing mailto: or tel:) storing it in $text.
|
||||||
|
# This function is *not* suitable for attributes enclosed in single quotes.
|
||||||
|
#
|
||||||
|
if ($this->url_filter_func)
|
||||||
|
$url = call_user_func($this->url_filter_func, $url);
|
||||||
|
|
||||||
|
if (preg_match('{^mailto:}i', $url))
|
||||||
|
$url = $this->encodeEntityObfuscatedAttribute($url, $text, 7);
|
||||||
|
else if (preg_match('{^tel:}i', $url))
|
||||||
|
{
|
||||||
|
$url = $this->encodeAttribute($url);
|
||||||
|
$text = substr($url, 4);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$url = $this->encodeAttribute($url);
|
||||||
|
$text = $url;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $url;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
protected function encodeAmpsAndAngles($text) {
|
protected function encodeAmpsAndAngles($text) {
|
||||||
#
|
#
|
||||||
# Smart processing for ampersands and angle brackets that need to
|
# Smart processing for ampersands and angle brackets that need to
|
||||||
|
|
@ -1279,8 +1314,8 @@ class Markdown implements MarkdownInterface {
|
||||||
|
|
||||||
|
|
||||||
protected function doAutoLinks($text) {
|
protected function doAutoLinks($text) {
|
||||||
$text = preg_replace_callback('{<((https?|ftp|dict):[^\'">\s]+)>}i',
|
$text = preg_replace_callback('{<((https?|ftp|dict|tel):[^\'">\s]+)>}i',
|
||||||
array(&$this, '_doAutoLinks_url_callback'), $text);
|
array($this, '_doAutoLinks_url_callback'), $text);
|
||||||
|
|
||||||
# Email addresses: <address@domain.foo>
|
# Email addresses: <address@domain.foo>
|
||||||
$text = preg_replace_callback('{
|
$text = preg_replace_callback('{
|
||||||
|
|
@ -1301,48 +1336,46 @@ class Markdown implements MarkdownInterface {
|
||||||
)
|
)
|
||||||
>
|
>
|
||||||
}xi',
|
}xi',
|
||||||
array(&$this, '_doAutoLinks_email_callback'), $text);
|
array($this, '_doAutoLinks_email_callback'), $text);
|
||||||
$text = preg_replace_callback('{<(tel:([^\'">\s]+))>}i',array(&$this, '_doAutoLinks_tel_callback'), $text);
|
|
||||||
|
|
||||||
return $text;
|
return $text;
|
||||||
}
|
}
|
||||||
protected function _doAutoLinks_tel_callback($matches) {
|
|
||||||
$url = $this->encodeAttribute($matches[1]);
|
|
||||||
$tel = $this->encodeAttribute($matches[2]);
|
|
||||||
$link = "<a href=\"$url\">$tel</a>";
|
|
||||||
return $this->hashPart($link);
|
|
||||||
}
|
|
||||||
protected function _doAutoLinks_url_callback($matches) {
|
protected function _doAutoLinks_url_callback($matches) {
|
||||||
$url = $this->encodeAttribute($matches[1]);
|
$url = $this->encodeURLAttribute($matches[1], $text);
|
||||||
$link = "<a href=\"$url\">$url</a>";
|
$link = "<a href=\"$url\">$text</a>";
|
||||||
return $this->hashPart($link);
|
return $this->hashPart($link);
|
||||||
}
|
}
|
||||||
protected function _doAutoLinks_email_callback($matches) {
|
protected function _doAutoLinks_email_callback($matches) {
|
||||||
$address = $matches[1];
|
$addr = $matches[1];
|
||||||
$link = $this->encodeEmailAddress($address);
|
$url = $this->encodeURLAttribute("mailto:$addr", $text);
|
||||||
|
$link = "<a href=\"$url\">$text</a>";
|
||||||
return $this->hashPart($link);
|
return $this->hashPart($link);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
protected function encodeEmailAddress($addr) {
|
protected function encodeEntityObfuscatedAttribute($text, &$tail = null, $head_length = 0) {
|
||||||
#
|
#
|
||||||
# Input: an email address, e.g. "foo@example.com"
|
# Input: some text to obfuscate, e.g. "mailto:foo@example.com"
|
||||||
#
|
#
|
||||||
# Output: the email address as a mailto link, with each character
|
# Output: the same text but with most characters encoded as either a
|
||||||
# of the address encoded as either a decimal or hex entity, in
|
# decimal or hex entity, in the hopes of foiling most address
|
||||||
# the hopes of foiling most address harvesting spam bots. E.g.:
|
# harvesting spam bots. E.g.:
|
||||||
#
|
#
|
||||||
# <p><a href="mailto:foo
|
# mailto:foo
|
||||||
# @example.co
|
# @example.co
|
||||||
# m">foo@exampl
|
# m
|
||||||
# e.com</a></p>
|
#
|
||||||
|
# Note: the additional output $tail is assigned the same value as the
|
||||||
|
# ouput, minus the number of characters specified by $head_length.
|
||||||
#
|
#
|
||||||
# Based by a filter by Matthew Wickline, posted to BBEdit-Talk.
|
# Based by a filter by Matthew Wickline, posted to BBEdit-Talk.
|
||||||
# With some optimizations by Milian Wolff.
|
# With some optimizations by Milian Wolff. Forced encoding of HTML
|
||||||
|
# attribute special characters by Allan Odgaard.
|
||||||
#
|
#
|
||||||
$addr = "mailto:" . $addr;
|
if ($text == "") return $tail = "";
|
||||||
$chars = preg_split('/(?<!^)(?!$)/', $addr);
|
|
||||||
$seed = (int)abs(crc32($addr) / strlen($addr)); # Deterministic seed.
|
$chars = preg_split('/(?<!^)(?!$)/', $text);
|
||||||
|
$seed = (int)abs(crc32($text) / strlen($text)); # Deterministic seed.
|
||||||
|
|
||||||
foreach ($chars as $key => $char) {
|
foreach ($chars as $key => $char) {
|
||||||
$ord = ord($char);
|
$ord = ord($char);
|
||||||
|
|
@ -1351,17 +1384,17 @@ class Markdown implements MarkdownInterface {
|
||||||
$r = ($seed * (1 + $key)) % 100; # Pseudo-random function.
|
$r = ($seed * (1 + $key)) % 100; # Pseudo-random function.
|
||||||
# roughly 10% raw, 45% hex, 45% dec
|
# roughly 10% raw, 45% hex, 45% dec
|
||||||
# '@' *must* be encoded. I insist.
|
# '@' *must* be encoded. I insist.
|
||||||
if ($r > 90 && $char != '@') /* do nothing */;
|
# '"' and '>' have to be encoded inside the attribute
|
||||||
|
if ($r > 90 && strpos('@"&>', $char) === false) /* do nothing */;
|
||||||
else if ($r < 45) $chars[$key] = '&#x'.dechex($ord).';';
|
else if ($r < 45) $chars[$key] = '&#x'.dechex($ord).';';
|
||||||
else $chars[$key] = '&#'.$ord.';';
|
else $chars[$key] = '&#'.$ord.';';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$addr = implode('', $chars);
|
$text = implode('', $chars);
|
||||||
$text = implode('', array_slice($chars, 7)); # text without `mailto:`
|
$tail = $head_length ? implode('', array_slice($chars, $head_length)) : $text;
|
||||||
$addr = "<a href=\"$addr\">$text</a>";
|
|
||||||
|
|
||||||
return $addr;
|
return $text;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -1470,7 +1503,7 @@ class Markdown implements MarkdownInterface {
|
||||||
# appropriate number of space between each blocks.
|
# appropriate number of space between each blocks.
|
||||||
|
|
||||||
$text = preg_replace_callback('/^.*\t.*$/m',
|
$text = preg_replace_callback('/^.*\t.*$/m',
|
||||||
array(&$this, '_detab_callback'), $text);
|
array($this, '_detab_callback'), $text);
|
||||||
|
|
||||||
return $text;
|
return $text;
|
||||||
}
|
}
|
||||||
|
|
@ -1510,7 +1543,7 @@ class Markdown implements MarkdownInterface {
|
||||||
# Swap back in all the tags hashed by _HashHTMLBlocks.
|
# Swap back in all the tags hashed by _HashHTMLBlocks.
|
||||||
#
|
#
|
||||||
return preg_replace_callback('/(.)\x1A[0-9]+\1/',
|
return preg_replace_callback('/(.)\x1A[0-9]+\1/',
|
||||||
array(&$this, '_unhash_callback'), $text);
|
array($this, '_unhash_callback'), $text);
|
||||||
}
|
}
|
||||||
protected function _unhash_callback($matches) {
|
protected function _unhash_callback($matches) {
|
||||||
return $this->html_hashes[$matches[0]];
|
return $this->html_hashes[$matches[0]];
|
||||||
|
|
@ -1716,7 +1749,7 @@ abstract class _MarkdownExtra_TmpImpl extends \Michelf\Markdown {
|
||||||
(?:[ ]* '.$this->id_class_attr_catch_re.' )? # $5 = extra id & class attr
|
(?:[ ]* '.$this->id_class_attr_catch_re.' )? # $5 = extra id & class attr
|
||||||
(?:\n+|\Z)
|
(?:\n+|\Z)
|
||||||
}xm',
|
}xm',
|
||||||
array(&$this, '_stripLinkDefinitions_callback'),
|
array($this, '_stripLinkDefinitions_callback'),
|
||||||
$text);
|
$text);
|
||||||
return $text;
|
return $text;
|
||||||
}
|
}
|
||||||
|
|
@ -1733,17 +1766,17 @@ abstract class _MarkdownExtra_TmpImpl extends \Michelf\Markdown {
|
||||||
### HTML Block Parser ###
|
### HTML Block Parser ###
|
||||||
|
|
||||||
# Tags that are always treated as block tags:
|
# Tags that are always treated as block tags:
|
||||||
protected $block_tags_re = 'p|div|h[1-6]|blockquote|pre|table|dl|ol|ul|address|form|fieldset|iframe|hr|legend|article|section|nav|aside|hgroup|header|footer|figcaption';
|
protected $block_tags_re = 'p|div|h[1-6]|blockquote|pre|table|dl|ol|ul|address|form|fieldset|iframe|hr|legend|article|section|nav|aside|hgroup|header|footer|figcaption|figure';
|
||||||
|
|
||||||
# Tags treated as block tags only if the opening tag is alone on its line:
|
# Tags treated as block tags only if the opening tag is alone on its line:
|
||||||
protected $context_block_tags_re = 'script|noscript|ins|del|iframe|object|source|track|param|math|svg|canvas|audio|video';
|
protected $context_block_tags_re = 'script|noscript|style|ins|del|iframe|object|source|track|param|math|svg|canvas|audio|video';
|
||||||
|
|
||||||
# Tags where markdown="1" default to span mode:
|
# Tags where markdown="1" default to span mode:
|
||||||
protected $contain_span_tags_re = 'p|h[1-6]|li|dd|dt|td|th|legend|address';
|
protected $contain_span_tags_re = 'p|h[1-6]|li|dd|dt|td|th|legend|address';
|
||||||
|
|
||||||
# Tags which must not have their contents modified, no matter where
|
# Tags which must not have their contents modified, no matter where
|
||||||
# they appear:
|
# they appear:
|
||||||
protected $clean_tags_re = 'script|math|svg';
|
protected $clean_tags_re = 'script|style|math|svg';
|
||||||
|
|
||||||
# Tags that do not need to be closed.
|
# Tags that do not need to be closed.
|
||||||
protected $auto_close_tags_re = 'hr|img|param|source|track';
|
protected $auto_close_tags_re = 'hr|img|param|source|track';
|
||||||
|
|
@ -2227,7 +2260,7 @@ abstract class _MarkdownExtra_TmpImpl extends \Michelf\Markdown {
|
||||||
\]
|
\]
|
||||||
)
|
)
|
||||||
}xs',
|
}xs',
|
||||||
array(&$this, '_doAnchors_reference_callback'), $text);
|
array($this, '_doAnchors_reference_callback'), $text);
|
||||||
|
|
||||||
#
|
#
|
||||||
# Next, inline-style links: [link text](url "optional title")
|
# Next, inline-style links: [link text](url "optional title")
|
||||||
|
|
@ -2255,7 +2288,7 @@ abstract class _MarkdownExtra_TmpImpl extends \Michelf\Markdown {
|
||||||
(?:[ ]? '.$this->id_class_attr_catch_re.' )? # $8 = id/class attributes
|
(?:[ ]? '.$this->id_class_attr_catch_re.' )? # $8 = id/class attributes
|
||||||
)
|
)
|
||||||
}xs',
|
}xs',
|
||||||
array(&$this, '_doAnchors_inline_callback'), $text);
|
array($this, '_doAnchors_inline_callback'), $text);
|
||||||
|
|
||||||
#
|
#
|
||||||
# Last, handle reference-style shortcuts: [link text]
|
# Last, handle reference-style shortcuts: [link text]
|
||||||
|
|
@ -2269,7 +2302,7 @@ abstract class _MarkdownExtra_TmpImpl extends \Michelf\Markdown {
|
||||||
\]
|
\]
|
||||||
)
|
)
|
||||||
}xs',
|
}xs',
|
||||||
array(&$this, '_doAnchors_reference_callback'), $text);
|
array($this, '_doAnchors_reference_callback'), $text);
|
||||||
|
|
||||||
$this->in_anchor = false;
|
$this->in_anchor = false;
|
||||||
return $text;
|
return $text;
|
||||||
|
|
@ -2290,7 +2323,7 @@ abstract class _MarkdownExtra_TmpImpl extends \Michelf\Markdown {
|
||||||
|
|
||||||
if (isset($this->urls[$link_id])) {
|
if (isset($this->urls[$link_id])) {
|
||||||
$url = $this->urls[$link_id];
|
$url = $this->urls[$link_id];
|
||||||
$url = $this->encodeAttribute($url);
|
$url = $this->encodeURLAttribute($url);
|
||||||
|
|
||||||
$result = "<a href=\"$url\"";
|
$result = "<a href=\"$url\"";
|
||||||
if ( isset( $this->titles[$link_id] ) ) {
|
if ( isset( $this->titles[$link_id] ) ) {
|
||||||
|
|
@ -2317,8 +2350,13 @@ abstract class _MarkdownExtra_TmpImpl extends \Michelf\Markdown {
|
||||||
$title =& $matches[7];
|
$title =& $matches[7];
|
||||||
$attr = $this->doExtraAttributes("a", $dummy =& $matches[8]);
|
$attr = $this->doExtraAttributes("a", $dummy =& $matches[8]);
|
||||||
|
|
||||||
|
// if the URL was of the form <s p a c e s> it got caught by the HTML
|
||||||
|
// tag parser and hashed. Need to reverse the process before using the URL.
|
||||||
|
$unhashed = $this->unhash($url);
|
||||||
|
if ($unhashed != $url)
|
||||||
|
$url = preg_replace('/^<(.*)>$/', '\1', $unhashed);
|
||||||
|
|
||||||
$url = $this->encodeAttribute($url);
|
$url = $this->encodeURLAttribute($url);
|
||||||
|
|
||||||
$result = "<a href=\"$url\"";
|
$result = "<a href=\"$url\"";
|
||||||
if (isset($title)) {
|
if (isset($title)) {
|
||||||
|
|
@ -2356,7 +2394,7 @@ abstract class _MarkdownExtra_TmpImpl extends \Michelf\Markdown {
|
||||||
|
|
||||||
)
|
)
|
||||||
}xs',
|
}xs',
|
||||||
array(&$this, '_doImages_reference_callback'), $text);
|
array($this, '_doImages_reference_callback'), $text);
|
||||||
|
|
||||||
#
|
#
|
||||||
# Next, handle inline images: 
|
# Next, handle inline images: 
|
||||||
|
|
@ -2386,7 +2424,7 @@ abstract class _MarkdownExtra_TmpImpl extends \Michelf\Markdown {
|
||||||
(?:[ ]? '.$this->id_class_attr_catch_re.' )? # $8 = id/class attributes
|
(?:[ ]? '.$this->id_class_attr_catch_re.' )? # $8 = id/class attributes
|
||||||
)
|
)
|
||||||
}xs',
|
}xs',
|
||||||
array(&$this, '_doImages_inline_callback'), $text);
|
array($this, '_doImages_inline_callback'), $text);
|
||||||
|
|
||||||
return $text;
|
return $text;
|
||||||
}
|
}
|
||||||
|
|
@ -2401,7 +2439,7 @@ abstract class _MarkdownExtra_TmpImpl extends \Michelf\Markdown {
|
||||||
|
|
||||||
$alt_text = $this->encodeAttribute($alt_text);
|
$alt_text = $this->encodeAttribute($alt_text);
|
||||||
if (isset($this->urls[$link_id])) {
|
if (isset($this->urls[$link_id])) {
|
||||||
$url = $this->encodeAttribute($this->urls[$link_id]);
|
$url = $this->encodeURLAttribute($this->urls[$link_id]);
|
||||||
$result = "<img src=\"$url\" alt=\"$alt_text\"";
|
$result = "<img src=\"$url\" alt=\"$alt_text\"";
|
||||||
if (isset($this->titles[$link_id])) {
|
if (isset($this->titles[$link_id])) {
|
||||||
$title = $this->titles[$link_id];
|
$title = $this->titles[$link_id];
|
||||||
|
|
@ -2428,7 +2466,7 @@ abstract class _MarkdownExtra_TmpImpl extends \Michelf\Markdown {
|
||||||
$attr = $this->doExtraAttributes("img", $dummy =& $matches[8]);
|
$attr = $this->doExtraAttributes("img", $dummy =& $matches[8]);
|
||||||
|
|
||||||
$alt_text = $this->encodeAttribute($alt_text);
|
$alt_text = $this->encodeAttribute($alt_text);
|
||||||
$url = $this->encodeAttribute($url);
|
$url = $this->encodeURLAttribute($url);
|
||||||
$result = "<img src=\"$url\" alt=\"$alt_text\"";
|
$result = "<img src=\"$url\" alt=\"$alt_text\"";
|
||||||
if (isset($title)) {
|
if (isset($title)) {
|
||||||
$title = $this->encodeAttribute($title);
|
$title = $this->encodeAttribute($title);
|
||||||
|
|
@ -2458,7 +2496,7 @@ abstract class _MarkdownExtra_TmpImpl extends \Michelf\Markdown {
|
||||||
(?:[ ]+ '.$this->id_class_attr_catch_re.' )? # $3 = id/class attributes
|
(?:[ ]+ '.$this->id_class_attr_catch_re.' )? # $3 = id/class attributes
|
||||||
[ ]*\n(=+|-+)[ ]*\n+ # $3: Header footer
|
[ ]*\n(=+|-+)[ ]*\n+ # $3: Header footer
|
||||||
}mx',
|
}mx',
|
||||||
array(&$this, '_doHeaders_callback_setext'), $text);
|
array($this, '_doHeaders_callback_setext'), $text);
|
||||||
|
|
||||||
# atx-style headers:
|
# atx-style headers:
|
||||||
# # Header 1 {#header1}
|
# # Header 1 {#header1}
|
||||||
|
|
@ -2477,7 +2515,7 @@ abstract class _MarkdownExtra_TmpImpl extends \Michelf\Markdown {
|
||||||
[ ]*
|
[ ]*
|
||||||
\n+
|
\n+
|
||||||
}xm',
|
}xm',
|
||||||
array(&$this, '_doHeaders_callback_atx'), $text);
|
array($this, '_doHeaders_callback_atx'), $text);
|
||||||
|
|
||||||
return $text;
|
return $text;
|
||||||
}
|
}
|
||||||
|
|
@ -2528,7 +2566,7 @@ abstract class _MarkdownExtra_TmpImpl extends \Michelf\Markdown {
|
||||||
)
|
)
|
||||||
(?=\n|\Z) # Stop at final double newline.
|
(?=\n|\Z) # Stop at final double newline.
|
||||||
}xm',
|
}xm',
|
||||||
array(&$this, '_doTable_leadingPipe_callback'), $text);
|
array($this, '_doTable_leadingPipe_callback'), $text);
|
||||||
|
|
||||||
#
|
#
|
||||||
# Find tables without leading pipe.
|
# Find tables without leading pipe.
|
||||||
|
|
@ -2554,7 +2592,7 @@ abstract class _MarkdownExtra_TmpImpl extends \Michelf\Markdown {
|
||||||
)
|
)
|
||||||
(?=\n|\Z) # Stop at final double newline.
|
(?=\n|\Z) # Stop at final double newline.
|
||||||
}xm',
|
}xm',
|
||||||
array(&$this, '_DoTable_callback'), $text);
|
array($this, '_DoTable_callback'), $text);
|
||||||
|
|
||||||
return $text;
|
return $text;
|
||||||
}
|
}
|
||||||
|
|
@ -2678,7 +2716,7 @@ abstract class _MarkdownExtra_TmpImpl extends \Michelf\Markdown {
|
||||||
(?>\A\n?|(?<=\n\n))
|
(?>\A\n?|(?<=\n\n))
|
||||||
'.$whole_list_re.'
|
'.$whole_list_re.'
|
||||||
}mx',
|
}mx',
|
||||||
array(&$this, '_doDefLists_callback'), $text);
|
array($this, '_doDefLists_callback'), $text);
|
||||||
|
|
||||||
return $text;
|
return $text;
|
||||||
}
|
}
|
||||||
|
|
@ -2716,7 +2754,7 @@ abstract class _MarkdownExtra_TmpImpl extends \Michelf\Markdown {
|
||||||
(?=\n?[ ]{0,3}:[ ]) # lookahead for following line feed
|
(?=\n?[ ]{0,3}:[ ]) # lookahead for following line feed
|
||||||
# with a definition mark.
|
# with a definition mark.
|
||||||
}xm',
|
}xm',
|
||||||
array(&$this, '_processDefListItems_callback_dt'), $list_str);
|
array($this, '_processDefListItems_callback_dt'), $list_str);
|
||||||
|
|
||||||
# Process actual definitions.
|
# Process actual definitions.
|
||||||
$list_str = preg_replace_callback('{
|
$list_str = preg_replace_callback('{
|
||||||
|
|
@ -2733,7 +2771,7 @@ abstract class _MarkdownExtra_TmpImpl extends \Michelf\Markdown {
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
}xm',
|
}xm',
|
||||||
array(&$this, '_processDefListItems_callback_dd'), $list_str);
|
array($this, '_processDefListItems_callback_dd'), $list_str);
|
||||||
|
|
||||||
return $list_str;
|
return $list_str;
|
||||||
}
|
}
|
||||||
|
|
@ -2801,7 +2839,7 @@ abstract class _MarkdownExtra_TmpImpl extends \Michelf\Markdown {
|
||||||
# Closing marker.
|
# Closing marker.
|
||||||
\1 [ ]* (?= \n )
|
\1 [ ]* (?= \n )
|
||||||
}xm',
|
}xm',
|
||||||
array(&$this, '_doFencedCodeBlocks_callback'), $text);
|
array($this, '_doFencedCodeBlocks_callback'), $text);
|
||||||
|
|
||||||
return $text;
|
return $text;
|
||||||
}
|
}
|
||||||
|
|
@ -2811,7 +2849,7 @@ abstract class _MarkdownExtra_TmpImpl extends \Michelf\Markdown {
|
||||||
$codeblock = $matches[4];
|
$codeblock = $matches[4];
|
||||||
$codeblock = htmlspecialchars($codeblock, ENT_NOQUOTES);
|
$codeblock = htmlspecialchars($codeblock, ENT_NOQUOTES);
|
||||||
$codeblock = preg_replace_callback('/^\n+/',
|
$codeblock = preg_replace_callback('/^\n+/',
|
||||||
array(&$this, '_doFencedCodeBlocks_newlines'), $codeblock);
|
array($this, '_doFencedCodeBlocks_newlines'), $codeblock);
|
||||||
|
|
||||||
if ($classname != "") {
|
if ($classname != "") {
|
||||||
if ($classname{0} == '.')
|
if ($classname{0} == '.')
|
||||||
|
|
@ -2837,19 +2875,19 @@ abstract class _MarkdownExtra_TmpImpl extends \Michelf\Markdown {
|
||||||
# work in the middle of a word.
|
# work in the middle of a word.
|
||||||
#
|
#
|
||||||
protected $em_relist = array(
|
protected $em_relist = array(
|
||||||
'' => '(?:(?<!\*)\*(?!\*)|(?<![a-zA-Z0-9_])_(?!_))(?=\S|$)(?![\.,:;]\s)',
|
'' => '(?:(?<!\*)\*(?!\*)|(?<![a-zA-Z0-9_])_(?!_))(?![\.,:;]?\s)',
|
||||||
'*' => '(?<=\S|^)(?<!\*)\*(?!\*)',
|
'*' => '(?<![\s*])\*(?!\*)',
|
||||||
'_' => '(?<=\S|^)(?<!_)_(?![a-zA-Z0-9_])',
|
'_' => '(?<![\s_])_(?![a-zA-Z0-9_])',
|
||||||
);
|
);
|
||||||
protected $strong_relist = array(
|
protected $strong_relist = array(
|
||||||
'' => '(?:(?<!\*)\*\*(?!\*)|(?<![a-zA-Z0-9_])__(?!_))(?=\S|$)(?![\.,:;]\s)',
|
'' => '(?:(?<!\*)\*\*(?!\*)|(?<![a-zA-Z0-9_])__(?!_))(?![\.,:;]?\s)',
|
||||||
'**' => '(?<=\S|^)(?<!\*)\*\*(?!\*)',
|
'**' => '(?<![\s*])\*\*(?!\*)',
|
||||||
'__' => '(?<=\S|^)(?<!_)__(?![a-zA-Z0-9_])',
|
'__' => '(?<![\s_])__(?![a-zA-Z0-9_])',
|
||||||
);
|
);
|
||||||
protected $em_strong_relist = array(
|
protected $em_strong_relist = array(
|
||||||
'' => '(?:(?<!\*)\*\*\*(?!\*)|(?<![a-zA-Z0-9_])___(?!_))(?=\S|$)(?![\.,:;]\s)',
|
'' => '(?:(?<!\*)\*\*\*(?!\*)|(?<![a-zA-Z0-9_])___(?!_))(?![\.,:;]?\s)',
|
||||||
'***' => '(?<=\S|^)(?<!\*)\*\*\*(?!\*)',
|
'***' => '(?<![\s*])\*\*\*(?!\*)',
|
||||||
'___' => '(?<=\S|^)(?<!_)___(?![a-zA-Z0-9_])',
|
'___' => '(?<![\s_])___(?![a-zA-Z0-9_])',
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -2908,13 +2946,13 @@ abstract class _MarkdownExtra_TmpImpl extends \Michelf\Markdown {
|
||||||
.+ # actual text
|
.+ # actual text
|
||||||
|
|
|
|
||||||
\n # newlines but
|
\n # newlines but
|
||||||
(?!\[\^.+?\]:\s)# negative lookahead for footnote marker.
|
(?!\[.+?\][ ]?:\s)# negative lookahead for footnote or link definition marker.
|
||||||
(?!\n+[ ]{0,3}\S)# ensure line is not blank and followed
|
(?!\n+[ ]{0,3}\S)# ensure line is not blank and followed
|
||||||
# by non-indented content
|
# by non-indented content
|
||||||
)*
|
)*
|
||||||
)
|
)
|
||||||
}xm',
|
}xm',
|
||||||
array(&$this, '_stripFootnotes_callback'),
|
array($this, '_stripFootnotes_callback'),
|
||||||
$text);
|
$text);
|
||||||
return $text;
|
return $text;
|
||||||
}
|
}
|
||||||
|
|
@ -2942,7 +2980,7 @@ abstract class _MarkdownExtra_TmpImpl extends \Michelf\Markdown {
|
||||||
# Append footnote list to text.
|
# Append footnote list to text.
|
||||||
#
|
#
|
||||||
$text = preg_replace_callback('{F\x1Afn:(.*?)\x1A:}',
|
$text = preg_replace_callback('{F\x1Afn:(.*?)\x1A:}',
|
||||||
array(&$this, '_appendFootnotes_callback'), $text);
|
array($this, '_appendFootnotes_callback'), $text);
|
||||||
|
|
||||||
if (!empty($this->footnotes_ordered)) {
|
if (!empty($this->footnotes_ordered)) {
|
||||||
$text .= "\n\n";
|
$text .= "\n\n";
|
||||||
|
|
@ -2974,7 +3012,7 @@ abstract class _MarkdownExtra_TmpImpl extends \Michelf\Markdown {
|
||||||
$footnote .= "\n"; # Need to append newline before parsing.
|
$footnote .= "\n"; # Need to append newline before parsing.
|
||||||
$footnote = $this->runBlockGamut("$footnote\n");
|
$footnote = $this->runBlockGamut("$footnote\n");
|
||||||
$footnote = preg_replace_callback('{F\x1Afn:(.*?)\x1A:}',
|
$footnote = preg_replace_callback('{F\x1Afn:(.*?)\x1A:}',
|
||||||
array(&$this, '_appendFootnotes_callback'), $footnote);
|
array($this, '_appendFootnotes_callback'), $footnote);
|
||||||
|
|
||||||
$attr = str_replace("%%", ++$num, $attr);
|
$attr = str_replace("%%", ++$num, $attr);
|
||||||
$note_id = $this->encodeAttribute($note_id);
|
$note_id = $this->encodeAttribute($note_id);
|
||||||
|
|
@ -3057,7 +3095,7 @@ abstract class _MarkdownExtra_TmpImpl extends \Michelf\Markdown {
|
||||||
^[ ]{0,'.$less_than_tab.'}\*\[(.+?)\][ ]?: # abbr_id = $1
|
^[ ]{0,'.$less_than_tab.'}\*\[(.+?)\][ ]?: # abbr_id = $1
|
||||||
(.*) # text = $2 (no blank lines allowed)
|
(.*) # text = $2 (no blank lines allowed)
|
||||||
}xm',
|
}xm',
|
||||||
array(&$this, '_stripAbbreviations_callback'),
|
array($this, '_stripAbbreviations_callback'),
|
||||||
$text);
|
$text);
|
||||||
return $text;
|
return $text;
|
||||||
}
|
}
|
||||||
|
|
@ -3084,7 +3122,7 @@ abstract class _MarkdownExtra_TmpImpl extends \Michelf\Markdown {
|
||||||
'(?:'.$this->abbr_word_re.')'.
|
'(?:'.$this->abbr_word_re.')'.
|
||||||
'(?![\w\x1A])'.
|
'(?![\w\x1A])'.
|
||||||
'}',
|
'}',
|
||||||
array(&$this, '_doAbbreviations_callback'), $text);
|
array($this, '_doAbbreviations_callback'), $text);
|
||||||
}
|
}
|
||||||
return $text;
|
return $text;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@
|
||||||
# Markdown Extra - A text-to-HTML conversion tool for web writers
|
# Markdown Extra - A text-to-HTML conversion tool for web writers
|
||||||
#
|
#
|
||||||
# PHP Markdown Extra
|
# PHP Markdown Extra
|
||||||
# Copyright (c) 2004-2013 Michel Fortin
|
# Copyright (c) 2004-2014 Michel Fortin
|
||||||
# <http://michelf.com/projects/php-markdown/>
|
# <http://michelf.com/projects/php-markdown/>
|
||||||
#
|
#
|
||||||
# Original Markdown
|
# Original Markdown
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@
|
||||||
# Markdown - A text-to-HTML conversion tool for web writers
|
# Markdown - A text-to-HTML conversion tool for web writers
|
||||||
#
|
#
|
||||||
# PHP Markdown
|
# PHP Markdown
|
||||||
# Copyright (c) 2004-2013 Michel Fortin
|
# Copyright (c) 2004-2014 Michel Fortin
|
||||||
# <http://michelf.com/projects/php-markdown/>
|
# <http://michelf.com/projects/php-markdown/>
|
||||||
#
|
#
|
||||||
# Original Markdown
|
# Original Markdown
|
||||||
|
|
@ -32,6 +32,3 @@ interface MarkdownInterface {
|
||||||
public function transform($text);
|
public function transform($text);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
?>
|
|
||||||
38
vendor/michelf/php-markdown/Readme.md
vendored
38
vendor/michelf/php-markdown/Readme.md
vendored
|
|
@ -1,7 +1,7 @@
|
||||||
PHP Markdown
|
PHP Markdown
|
||||||
============
|
============
|
||||||
|
|
||||||
PHP Markdown Lib 1.4.0 - 29 Nov 2013
|
PHP Markdown Lib 1.4.1 - 4 May 2013
|
||||||
|
|
||||||
by Michel Fortin
|
by Michel Fortin
|
||||||
<http://michelf.ca/>
|
<http://michelf.ca/>
|
||||||
|
|
@ -160,9 +160,43 @@ too.
|
||||||
[MDTest]: https://github.com/michelf/mdtest/
|
[MDTest]: https://github.com/michelf/mdtest/
|
||||||
|
|
||||||
|
|
||||||
|
Donations
|
||||||
|
---------
|
||||||
|
|
||||||
|
If you wish to make a donation that will help me devote more time to
|
||||||
|
PHP Markdown, please visit [michelf.ca/donate] or send Bitcoin to
|
||||||
|
[1HiuX34czvVPPdhXbUAsAu7pZcesniDCGH].
|
||||||
|
|
||||||
|
[michelf.ca/donate]: https://michelf.ca/donate/#!Thanks%20for%20PHP%20Markdown
|
||||||
|
[1HiuX34czvVPPdhXbUAsAu7pZcesniDCGH]: bitcoin:1HiuX34czvVPPdhXbUAsAu7pZcesniDCGH
|
||||||
|
|
||||||
|
|
||||||
Version History
|
Version History
|
||||||
---------------
|
---------------
|
||||||
|
|
||||||
|
PHP Markdown Lib 1.4.1 (4 May 2014)
|
||||||
|
|
||||||
|
* The HTML block parser will now treat `<figure>` as a block-level element
|
||||||
|
(as it should) and no longer wrap it in `<p>` or parse it's content with
|
||||||
|
the as Markdown syntax (although with Extra you can use `markdown="1"`
|
||||||
|
if you wish to use the Markdown syntax inside it).
|
||||||
|
|
||||||
|
* The content of `<style>` elements will now be left alone, its content
|
||||||
|
won't be interpreted as Markdown.
|
||||||
|
|
||||||
|
* Corrected an bug where some inline links with spaces in them would not
|
||||||
|
work even when surounded with angle brackets:
|
||||||
|
|
||||||
|
[link](<s p a c e s>)
|
||||||
|
|
||||||
|
* Fixed an issue where email addresses with quotes in them would not always
|
||||||
|
have the quotes escaped in the link attribute, causing broken links (and
|
||||||
|
invalid HTML).
|
||||||
|
|
||||||
|
* Fixed the case were a link definition following a footnote definition would
|
||||||
|
be swallowed by the footnote unless it was separated by a blank line.
|
||||||
|
|
||||||
|
|
||||||
PHP Markdown Lib 1.4.0 (29 Nov 2013)
|
PHP Markdown Lib 1.4.0 (29 Nov 2013)
|
||||||
|
|
||||||
* Added support for the `tel:` URL scheme in automatic links.
|
* Added support for the `tel:` URL scheme in automatic links.
|
||||||
|
|
@ -233,7 +267,7 @@ Copyright and License
|
||||||
---------------------
|
---------------------
|
||||||
|
|
||||||
PHP Markdown Lib
|
PHP Markdown Lib
|
||||||
Copyright (c) 2004-2013 Michel Fortin
|
Copyright (c) 2004-2014 Michel Fortin
|
||||||
<http://michelf.ca/>
|
<http://michelf.ca/>
|
||||||
All rights reserved.
|
All rights reserved.
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue