mirror of
https://code.mensbeam.com/MensBeam/Arsse.git
synced 2024-12-22 21:22:40 +00:00
Use Robo to extract zip archive
This commit is contained in:
parent
b514ac983b
commit
b3566f8d48
3 changed files with 40 additions and 99 deletions
79
RoboFile.php
79
RoboFile.php
|
@ -208,49 +208,46 @@ class RoboFile extends \Robo\Tasks {
|
||||||
// compile the stylesheet
|
// compile the stylesheet
|
||||||
$t->taskExec($postcss)->arg($scss)->option("-o", $css);
|
$t->taskExec($postcss)->arg($scss)->option("-o", $css);
|
||||||
// download highlight.js
|
// download highlight.js
|
||||||
if (extension_loaded("zip")) {
|
$t->addCode(function() use ($tmp, $themeout) {
|
||||||
$t->addCode(function() use ($tmp, $themeout) {
|
$languages = ["php", "bash", "shell", "xml", "nginx", "apache"];
|
||||||
$languages = ["php", "bash", "shell", "xml", "nginx", "apache"];
|
$post = http_build_query((function($langs) {
|
||||||
$post = http_build_query((function($langs) {
|
$out = [];
|
||||||
$out = [];
|
foreach($langs as $l) {
|
||||||
foreach($langs as $l) {
|
$out[$l.".js"] = "on";
|
||||||
$out[$l.".js"] = "on";
|
|
||||||
}
|
|
||||||
return $out;
|
|
||||||
})($languages));
|
|
||||||
$conn = @fopen("https://highlightjs.org/download/", "r");
|
|
||||||
if ($conn === false) {
|
|
||||||
throw new Exception("Unable to download Highlight.js");
|
|
||||||
}
|
}
|
||||||
foreach (stream_get_meta_data($conn)['wrapper_data'] as $field) {
|
return $out;
|
||||||
if (preg_match("/^Set-Cookie: csrftoken=([^;]+)/i", $field, $cookie)) {
|
})($languages));
|
||||||
break;
|
$conn = @fopen("https://highlightjs.org/download/", "r");
|
||||||
}
|
if ($conn === false) {
|
||||||
|
throw new Exception("Unable to download Highlight.js");
|
||||||
|
}
|
||||||
|
foreach (stream_get_meta_data($conn)['wrapper_data'] as $field) {
|
||||||
|
if (preg_match("/^Set-Cookie: csrftoken=([^;]+)/i", $field, $cookie)) {
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
$token = stream_get_contents($conn);
|
}
|
||||||
preg_match("/<input type='hidden' name='csrfmiddlewaretoken' value='([^']*)'/", $token, $token);
|
$token = stream_get_contents($conn);
|
||||||
$post = "csrfmiddlewaretoken={$token[1]}&$post";
|
preg_match("/<input type='hidden' name='csrfmiddlewaretoken' value='([^']*)'/", $token, $token);
|
||||||
$hljs = @file_get_contents("https://highlightjs.org/download/", false, stream_context_create(['http' => [
|
$post = "csrfmiddlewaretoken={$token[1]}&$post";
|
||||||
'method' => "POST",
|
$hljs = @file_get_contents("https://highlightjs.org/download/", false, stream_context_create(['http' => [
|
||||||
'content' => $post,
|
'method' => "POST",
|
||||||
'header' => [
|
'content' => $post,
|
||||||
"Referer: https://highlightjs.org/download/",
|
'header' => [
|
||||||
"Cookie: csrftoken={$cookie[1]}",
|
"Referer: https://highlightjs.org/download/",
|
||||||
"Content-Type: application/x-www-form-urlencoded",
|
"Cookie: csrftoken={$cookie[1]}",
|
||||||
],
|
"Content-Type: application/x-www-form-urlencoded",
|
||||||
]]));
|
],
|
||||||
if ($hljs === false) {
|
]]));
|
||||||
throw new Exception("Unable to download Highlight.js");
|
if ($hljs === false) {
|
||||||
} else {
|
throw new Exception("Unable to download Highlight.js");
|
||||||
file_put_contents($tmp."highlightjs.zip", $hljs);
|
} else {
|
||||||
}
|
file_put_contents($tmp."highlightjs.zip", $hljs);
|
||||||
$z = new \ZipArchive;
|
}
|
||||||
$z->open($tmp."highlightjs.zip");
|
$this->taskExtract($tmp."highlightjs.zip")->to($tmp."hljs")->run();
|
||||||
$z->extractTo($themeout, "highlight.pack.js");
|
$this->taskFilesystemStack()->copy($tmp."hljs/highlight.pack.js", $themeout."/highlight.pack.js")->run();
|
||||||
}, "downloadHighlightjs");
|
}, "downloadHighlightjs");
|
||||||
} else {
|
// copy JavaScript files from the Daux theme
|
||||||
$this->say("Zip extension not installed; not updating hightlight.js");
|
# TODO
|
||||||
}
|
|
||||||
// execute the collection
|
// execute the collection
|
||||||
return $t->run();
|
return $t->run();
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,6 +5,5 @@
|
||||||
"symfony/process": "^3.0"
|
"symfony/process": "^3.0"
|
||||||
},
|
},
|
||||||
"require-dev": {
|
"require-dev": {
|
||||||
"splitbrain/php-archive": "^1.1"
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
59
vendor-bin/robo/composer.lock
generated
59
vendor-bin/robo/composer.lock
generated
|
@ -4,7 +4,7 @@
|
||||||
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
|
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
|
||||||
"This file is @generated automatically"
|
"This file is @generated automatically"
|
||||||
],
|
],
|
||||||
"content-hash": "0f7d93d4c470b72b0f6f0bc0317d603f",
|
"content-hash": "d95cf402fed434140db8ae87c3c8bf32",
|
||||||
"packages": [
|
"packages": [
|
||||||
{
|
{
|
||||||
"name": "consolidation/annotated-command",
|
"name": "consolidation/annotated-command",
|
||||||
|
@ -1734,62 +1734,7 @@
|
||||||
"time": "2019-04-06T14:04:46+00:00"
|
"time": "2019-04-06T14:04:46+00:00"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"packages-dev": [
|
"packages-dev": [],
|
||||||
{
|
|
||||||
"name": "splitbrain/php-archive",
|
|
||||||
"version": "1.1.1",
|
|
||||||
"source": {
|
|
||||||
"type": "git",
|
|
||||||
"url": "https://github.com/splitbrain/php-archive.git",
|
|
||||||
"reference": "10d89013572ba1f4d4ad7fcb74860242f4c3860b"
|
|
||||||
},
|
|
||||||
"dist": {
|
|
||||||
"type": "zip",
|
|
||||||
"url": "https://api.github.com/repos/splitbrain/php-archive/zipball/10d89013572ba1f4d4ad7fcb74860242f4c3860b",
|
|
||||||
"reference": "10d89013572ba1f4d4ad7fcb74860242f4c3860b",
|
|
||||||
"shasum": ""
|
|
||||||
},
|
|
||||||
"require": {
|
|
||||||
"php": ">=5.4"
|
|
||||||
},
|
|
||||||
"require-dev": {
|
|
||||||
"ext-bz2": "*",
|
|
||||||
"ext-zip": "*",
|
|
||||||
"mikey179/vfsstream": "^1.6",
|
|
||||||
"phpunit/phpunit": "^4.8"
|
|
||||||
},
|
|
||||||
"suggest": {
|
|
||||||
"ext-iconv": "Used for proper filename encode handling",
|
|
||||||
"ext-mbstring": "Can be used alternatively for handling filename encoding"
|
|
||||||
},
|
|
||||||
"type": "library",
|
|
||||||
"autoload": {
|
|
||||||
"psr-4": {
|
|
||||||
"splitbrain\\PHPArchive\\": "src"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"notification-url": "https://packagist.org/downloads/",
|
|
||||||
"license": [
|
|
||||||
"MIT"
|
|
||||||
],
|
|
||||||
"authors": [
|
|
||||||
{
|
|
||||||
"name": "Andreas Gohr",
|
|
||||||
"email": "andi@splitbrain.org"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"description": "Pure-PHP implementation to read and write TAR and ZIP archives",
|
|
||||||
"keywords": [
|
|
||||||
"archive",
|
|
||||||
"extract",
|
|
||||||
"tar",
|
|
||||||
"unpack",
|
|
||||||
"unzip",
|
|
||||||
"zip"
|
|
||||||
],
|
|
||||||
"time": "2018-09-09T12:13:53+00:00"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"aliases": [],
|
"aliases": [],
|
||||||
"minimum-stability": "stable",
|
"minimum-stability": "stable",
|
||||||
"stability-flags": [],
|
"stability-flags": [],
|
||||||
|
|
Loading…
Reference in a new issue