Merge branch 'release/0.9.31'

This commit is contained in:
Andy Miller
2015-07-09 17:31:21 -06:00
17 changed files with 123 additions and 130 deletions

View File

@@ -1,3 +1,16 @@
# v0.9.31
## 07/09/2015
1. [](#new)
* Added xml, json, css and js to valid media file types
2. [](#improved)
* Better handling of unsupported media type downloads
* Improved `bin/grav backup` command to mimic admin plugin location/name
3. [](#bugfix)
* Critical fix for broken language translations
* Fix for Twig markdown filter error
* Safety check for download extension
# v0.9.30
## 07/08/2015

Binary file not shown.

View File

@@ -75,6 +75,10 @@ txt:
type: file
thumb: media/thumb-txt.png
mime: text/plain
xml:
type: file
thumb: media/thumb-xml.png
mime: application/xml
doc:
type: file
thumb: media/thumb-doc.png
@@ -95,3 +99,16 @@ gz:
type: file
thumb: media/thumb-gz.png
mime: application/gzip
css:
type: file
thumb: media/thumb-css.png
mime: text/css
js:
type: file
thumb: media/thumb-js.png
mime: application/javascript
json:
type: file
thumb: media/thumb-json.png
mime: application/json

View File

@@ -30,7 +30,7 @@ pages:
special_chars: # List of special characters to automatically convert to entities
'>': 'gt'
'<': 'lt'
types: 'txt|xml|html|json|rss|atom' # Pipe separated list of valid page types
types: [txt,xml,html,json,rss,atom] # list of valid page types
expires: 604800 # Page expires time in seconds (604800 seconds = 7 days)
last_modified: false # Set the last modified date header based on file modifcation timestamp
etag: false # Set the etag header tag
@@ -82,11 +82,12 @@ images:
media:
enable_media_timestamp: false # Enable media timetsamps
upload_limit: 0 # Set maximum upload size in bytes (0 is unlimited)
unsupported_inline_types: [] # Array of unsupported media file types to try to display inline
session:
enabled: true # Enable Session support
timeout: 1800 # Timeout in seconds
name: grav-site # Name prefix of the session cookie
enabled: true # Enable Session support
timeout: 1800 # Timeout in seconds
name: grav-site # Name prefix of the session cookie
security:
default_hash: $2y$10$kwsyMVwM8/7j0K/6LHT.g.Fs49xOCTp2b8hh/S5.dPJuJcJB6T.UK

View File

@@ -2,7 +2,7 @@
// Some standard defines
define('GRAV', true);
define('GRAV_VERSION', '0.9.30');
define('GRAV_VERSION', '0.9.31');
define('DS', '/');
// Directories and Paths

View File

@@ -179,7 +179,7 @@ class Config extends Data
$this->loadCompiledConfig($this->configLookup, $this->pluginLookup, 'master');
// process languages if supported
if ($this->get('languages', false)) {
if ($this->get('system.languages', false)) {
$this->languagesLookup = $locator->findResources('languages://');
$this->loadCompiledLanguages($this->languagesLookup, $this->pluginLookup, 'master');
}

View File

@@ -437,11 +437,11 @@ class Grav extends Container
Utils::download($medium->path(), false);
}
// has an extension, try to download it...
if (isset($path_parts['extension'])) {
// unsupported media type, try to download it...
$extension = $uri->extension() ?: isset($path_parts['extension']) ? $path_parts['extension'] : null;
if ($extension) {
$download = true;
// little work-around to ensure .css and .js files are always sent inline not downloaded
if (in_array($path_parts['extension'], ['.css', '.js'])) {
if (in_array(ltrim($extension, '.'), $this['config']->get('system.media.unsupported_inline_types'))) {
$download = false;
}
Utils::download($page->path() . DIRECTORY_SEPARATOR . $uri->basename(), $download);

View File

@@ -138,7 +138,6 @@ class Page
}
}
$this->published();
$this->extension();
}
/**

View File

@@ -339,7 +339,7 @@ class TwigExtension extends \Twig_Extension
public function markdownFilter($string)
{
$page = $this->grav['page'];
$defaults = $this->$config->get('system.pages.markdown');
$defaults = $this->config->get('system.pages.markdown');
// Initialize the preferred variant of Parsedown
if ($defaults['extra']) {

View File

@@ -120,7 +120,9 @@ class Uri
// set the original basename
$this->basename = $parts['basename'];
if (preg_match("/\.(".$config->get('system.pages.types').")$/", $parts['basename'])) {
$valid_page_types = implode('|', $config->get('system.pages.types'));
if (preg_match("/\.(".$valid_page_types.")$/", $parts['basename'])) {
$uri = rtrim(str_replace(DIRECTORY_SEPARATOR, DS, $parts['dirname']), DS). '/' .$parts['filename'];
$this->extension = $parts['extension'];
}

View File

@@ -1,13 +1,15 @@
<?php
namespace Grav\Console\Cli;
use Grav\Common\Backup\ZipBackup;
use Grav\Console\ConsoleTrait;
use RocketTheme\Toolbox\File\JsonFile;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Formatter\OutputFormatterStyle;
use Symfony\Component\Console\Helper\ProgressBar;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Grav\Common\Backup\ZipBackup;
/**
* Class BackupCommand
@@ -15,19 +17,10 @@ use Grav\Common\Backup\ZipBackup;
*/
class BackupCommand extends Command
{
use ConsoleTrait;
/**
* @var
*/
protected $source;
/**
* @var
*/
protected $progress;
/**
* @var
*/
protected $output;
/**
*
@@ -39,13 +32,12 @@ class BackupCommand extends Command
->addArgument(
'destination',
InputArgument::OPTIONAL,
'Where to store the backup'
'Where to store the backup (/backup is default)'
)
->setDescription("Creates a backup of the Grav instance")
->setHelp('The <info>backup</info> creates a zipped backup. Optionally can be saved in a different destination.');
$this->source = getcwd();
}
@@ -57,19 +49,22 @@ class BackupCommand extends Command
*/
protected function execute(InputInterface $input, OutputInterface $output)
{
$this->output = $output;
$output->getFormatter()->setStyle('red', new OutputFormatterStyle('red'));
$output->getFormatter()->setStyle('cyan', new OutputFormatterStyle('cyan'));
$output->getFormatter()->setStyle('green', new OutputFormatterStyle('green'));
$output->getFormatter()->setStyle('magenta', new OutputFormatterStyle('magenta'));
$this->setupConsole($input, $output);
$this->progress = new ProgressBar($output);
$this->progress->setFormat('Archiving <cyan>%current%</cyan> files [<green>%bar%</green>] %elapsed:6s% %memory:6s%');
$destination = ($input->getArgument('destination')) ? $input->getArgument('destination') : ROOT_DIR;
self::getGrav()['config']->init();
ZipBackup::backup($destination, [$this, 'output']);
$destination = ($input->getArgument('destination')) ? $input->getArgument('destination') : null;
$log = JsonFile::instance(self::getGrav()['locator']->findResource("log://backup.log", true, true));
$backup = ZipBackup::backup($destination, [$this, 'output']);
$log->content([
'time' => time(),
'location' => $backup
]);
$log->save();
$output->writeln('');
$output->writeln('');
@@ -97,5 +92,6 @@ class BackupCommand extends Command
break;
}
}
}

View File

@@ -2,6 +2,7 @@
namespace Grav\Console\Cli;
use Grav\Common\Filesystem\Folder;
use Grav\Console\ConsoleTrait;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Formatter\OutputFormatterStyle;
use Symfony\Component\Console\Input\InputInterface;
@@ -13,6 +14,7 @@ use Symfony\Component\Console\Output\OutputInterface;
*/
class CleanCommand extends Command
{
use ConsoleTrait;
/**
* @var array
@@ -177,27 +179,14 @@ class CleanCommand extends Command
*/
protected function execute(InputInterface $input, OutputInterface $output)
{
// Create a red output option
$output->getFormatter()->setStyle('red', new OutputFormatterStyle('red'));
$output->getFormatter()->setStyle('cyan', new OutputFormatterStyle('cyan'));
$output->getFormatter()->setStyle('green', new OutputFormatterStyle('green'));
$output->getFormatter()->setStyle('magenta', new OutputFormatterStyle('magenta'));
$this->cleanPaths($output);
$this->setupConsole($input, $output);
$this->cleanPaths();
}
// loops over the array of paths and deletes the files/folders
/**
* @param OutputInterface $output
*/
private function cleanPaths(OutputInterface $output)
private function cleanPaths()
{
$output->writeln('');
$output->writeln('<red>DELETING</red>');
$this->output->writeln('');
$this->output->writeln('<red>DELETING</red>');
$anything = false;
@@ -206,16 +195,16 @@ class CleanCommand extends Command
if (is_dir($path) && @Folder::delete($path)) {
$anything = true;
$output->writeln('<red>dir: </red>' . $path);
$this->output->writeln('<red>dir: </red>' . $path);
} elseif (is_file($path) && @unlink($path)) {
$anything = true;
$output->writeln('<red>file: </red>' . $path);
$this->output->writeln('<red>file: </red>' . $path);
}
}
if (!$anything) {
$output->writeln('');
$output->writeln('<green>Nothing to clean...</green>');
$this->output->writeln('');
$this->output->writeln('<green>Nothing to clean...</green>');
}
}

View File

@@ -2,6 +2,7 @@
namespace Grav\Console\Cli;
use Grav\Common\Cache;
use Grav\Console\ConsoleTrait;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Formatter\OutputFormatterStyle;
use Symfony\Component\Console\Input\InputInterface;
@@ -14,6 +15,7 @@ use Symfony\Component\Console\Output\OutputInterface;
*/
class ClearCacheCommand extends Command
{
use ConsoleTrait;
/**
*
@@ -38,40 +40,33 @@ class ClearCacheCommand extends Command
*/
protected function execute(InputInterface $input, OutputInterface $output)
{
// Create a red output option
$output->getFormatter()->setStyle('red', new OutputFormatterStyle('red'));
$output->getFormatter()->setStyle('cyan', new OutputFormatterStyle('cyan'));
$output->getFormatter()->setStyle('green', new OutputFormatterStyle('green'));
$output->getFormatter()->setStyle('magenta', new OutputFormatterStyle('magenta'));
$this->cleanPaths($input, $output);
$this->setupConsole($input, $output);
$this->cleanPaths();
}
// loops over the array of paths and deletes the files/folders
/**
* @param InputInterface $input
* @param OutputInterface $output
* loops over the array of paths and deletes the files/folders
*/
private function cleanPaths(InputInterface $input, OutputInterface $output)
private function cleanPaths()
{
$output->writeln('');
$output->writeln('<magenta>Clearing cache</magenta>');
$output->writeln('');
$this->output->writeln('');
$this->output->writeln('<magenta>Clearing cache</magenta>');
$this->output->writeln('');
if ($input->getOption('all')) {
if ($this->input->getOption('all')) {
$remove = 'all';
} elseif ($input->getOption('assets-only')) {
} elseif ($this->input->getOption('assets-only')) {
$remove = 'assets-only';
} elseif ($input->getOption('images-only')) {
} elseif ($this->input->getOption('images-only')) {
$remove = 'images-only';
} elseif ($input->getOption('cache-only')) {
} elseif ($this->input->getOption('cache-only')) {
$remove = 'cache-only';
} else {
$remove = 'standard';
}
foreach (Cache::clearCache($remove) as $result) {
$output->writeln($result);
$this->output->writeln($result);
}
}
}

View File

@@ -66,6 +66,8 @@ class ComposerCommand extends Command
*/
protected function execute(InputInterface $input, OutputInterface $output)
{
$this->setupConsole($input, $output);
$action = 'update';
if ($input->getOption('install')) {

View File

@@ -65,6 +65,7 @@ class InstallCommand extends Command
*/
protected function execute(InputInterface $input, OutputInterface $output)
{
$this->setupConsole($input, $output);
$dependencies_file = '.dependencies';
$local_config_file = exec('eval echo ~/.grav/config');
@@ -74,12 +75,6 @@ class InstallCommand extends Command
$this->destination = rtrim($this->destination, DS) . DS;
$this->user_path = $this->destination . USER_PATH;
// Create a red output option
$output->getFormatter()->setStyle('red', new OutputFormatterStyle('red'));
$output->getFormatter()->setStyle('cyan', new OutputFormatterStyle('cyan'));
$output->getFormatter()->setStyle('green', new OutputFormatterStyle('green'));
$output->getFormatter()->setStyle('magenta', new OutputFormatterStyle('magenta'));
if (file_exists($local_config_file)) {
$this->local_config = Yaml::parse($local_config_file);
$output->writeln('Read local config from <cyan>' . $local_config_file . '</cyan>');
@@ -101,9 +96,9 @@ class InstallCommand extends Command
$output->writeln("\nInstalling vendor dependencies");
$output->writeln($this->composerUpdate(GRAV_ROOT, 'install'));
$this->gitclone($output);
$this->gitclone();
} else {
$this->symlink($output);
$this->symlink();
}
} else {
$output->writeln('<red>ERROR</red> invalid YAML in ' . $dependencies_file);
@@ -112,45 +107,43 @@ class InstallCommand extends Command
}
// loops over the array of paths and deletes the files/folders
/**
* @param OutputInterface $output
* Clones from Git
*/
private function gitclone(OutputInterface $output)
private function gitclone()
{
$output->writeln('');
$output->writeln('<green>Cloning Bits</green>');
$output->writeln('============');
$output->writeln('');
$this->output->writeln('');
$this->output->writeln('<green>Cloning Bits</green>');
$this->output->writeln('============');
$this->output->writeln('');
foreach ($this->config['git'] as $repo => $data) {
$path = $this->destination . DS . $data['path'];
if (!file_exists($path)) {
exec('cd "' . $this->destination . '" && git clone -b ' . $data['branch'] . ' ' . $data['url'] . ' ' . $data['path']);
$output->writeln('<green>SUCCESS</green> cloned <magenta>' . $data['url'] . '</magenta> -> <cyan>' . $path . '</cyan>');
$output->writeln('');
$this->output->writeln('<green>SUCCESS</green> cloned <magenta>' . $data['url'] . '</magenta> -> <cyan>' . $path . '</cyan>');
$this->output->writeln('');
} else {
$output->writeln('<red>' . $path . ' already exists, skipping...</red>');
$output->writeln('');
$this->output->writeln('<red>' . $path . ' already exists, skipping...</red>');
$this->output->writeln('');
}
}
}
// loops over the array of paths and deletes the files/folders
/**
* @param OutputInterface $output
* Symlinks
*/
private function symlink(OutputInterface $output)
private function symlink()
{
$output->writeln('');
$output->writeln('<green>Symlinking Bits</green>');
$output->writeln('===============');
$output->writeln('');
$this->output->writeln('');
$this->output->writeln('<green>Symlinking Bits</green>');
$this->output->writeln('===============');
$this->output->writeln('');
if (!$this->local_config) {
$output->writeln('<red>No local configuration available, aborting...</red>');
$output->writeln('');
$this->output->writeln('<red>No local configuration available, aborting...</red>');
$this->output->writeln('');
return;
}
@@ -162,15 +155,15 @@ class InstallCommand extends Command
if (file_exists($from)) {
if (!file_exists($to)) {
symlink($from, $to);
$output->writeln('<green>SUCCESS</green> symlinked <magenta>' . $data['src'] . '</magenta> -> <cyan>' . $data['path'] . '</cyan>');
$output->writeln('');
$this->output->writeln('<green>SUCCESS</green> symlinked <magenta>' . $data['src'] . '</magenta> -> <cyan>' . $data['path'] . '</cyan>');
$this->output->writeln('');
} else {
$output->writeln('<red>destination: ' . $to . ' already exists, skipping...</red>');
$output->writeln('');
$this->output->writeln('<red>destination: ' . $to . ' already exists, skipping...</red>');
$this->output->writeln('');
}
} else {
$output->writeln('<red>source: ' . $from . ' does not exists, skipping...</red>');
$output->writeln('');
$this->output->writeln('<red>source: ' . $from . ' does not exists, skipping...</red>');
$this->output->writeln('');
}
}

View File

@@ -1,6 +1,7 @@
<?php
namespace Grav\Console\Cli;
use Grav\Console\ConsoleTrait;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\ArrayInput;
use Symfony\Component\Console\Input\InputArgument;
@@ -14,6 +15,7 @@ use Symfony\Component\Console\Output\OutputInterface;
*/
class NewProjectCommand extends Command
{
use ConsoleTrait;
/**
*
@@ -45,6 +47,7 @@ class NewProjectCommand extends Command
*/
protected function execute(InputInterface $input, OutputInterface $output)
{
$this->setupConsole($input, $output);
$sandboxCommand = $this->getApplication()->find('sandbox');
$installCommand = $this->getApplication()->find('install');

View File

@@ -2,6 +2,7 @@
namespace Grav\Console\Cli;
use Grav\Common\Filesystem\Folder;
use Grav\Console\ConsoleTrait;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Formatter\OutputFormatterStyle;
use Symfony\Component\Console\Input\InputArgument;
@@ -15,6 +16,8 @@ use Symfony\Component\Console\Output\OutputInterface;
*/
class SandboxCommand extends Command
{
use ConsoleTrait;
/**
* @var array
*/
@@ -66,22 +69,8 @@ class SandboxCommand extends Command
protected $default_file = "---\ntitle: HomePage\n---\n# HomePage\n\nLorem ipsum dolor sit amet, consectetur adipiscing elit. Pellentesque porttitor eu felis sed ornare. Sed a mauris venenatis, pulvinar velit vel, dictum enim. Phasellus ac rutrum velit. Nunc lorem purus, hendrerit sit amet augue aliquet, iaculis ultricies nisl. Suspendisse tincidunt euismod risus, quis feugiat arcu tincidunt eget. Nulla eros mi, commodo vel ipsum vel, aliquet congue odio. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Pellentesque velit orci, laoreet at adipiscing eu, interdum quis nibh. Nunc a accumsan purus.";
/**
* @var
*/
protected $source;
/**
* @var
*/
protected $destination;
/**
* @var InputInterface $input
*/
protected $input;
/**
* @var OutputInterface $output
*/
protected $output;
/**
*
@@ -114,14 +103,8 @@ class SandboxCommand extends Command
*/
protected function execute(InputInterface $input, OutputInterface $output)
{
$this->setupConsole($input, $output);
$this->destination = $input->getArgument('destination');
$this->input = $input;
$this->output = $output;
// Create a red output option
$this->output->getFormatter()->setStyle('red', new OutputFormatterStyle('red'));
$this->output->getFormatter()->setStyle('cyan', new OutputFormatterStyle('cyan'));
$this->output->getFormatter()->setStyle('magenta', new OutputFormatterStyle('magenta'));
// Symlink the Core Stuff
if ($input->getOption('symlink')) {