Skip to content

Commit

Permalink
Merge branch 'release/0.9.31'
Browse files Browse the repository at this point in the history
  • Loading branch information
rhukster committed Jul 9, 2015
2 parents 34f6020 + 05e0013 commit 0ba1af2
Show file tree
Hide file tree
Showing 17 changed files with 123 additions and 130 deletions.
13 changes: 13 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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

Expand Down
Binary file modified bin/composer.phar
Binary file not shown.
17 changes: 17 additions & 0 deletions system/config/media.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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

9 changes: 5 additions & 4 deletions system/config/system.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
2 changes: 1 addition & 1 deletion system/defines.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion system/src/Grav/Common/Config/Config.php
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ public function init()
$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');
}
Expand Down
8 changes: 4 additions & 4 deletions system/src/Grav/Common/Grav.php
Original file line number Diff line number Diff line change
Expand Up @@ -437,11 +437,11 @@ protected function fallbackUrl($page, $path)
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);
Expand Down
1 change: 0 additions & 1 deletion system/src/Grav/Common/Page/Page.php
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,6 @@ public function init(\SplFileInfo $file)
}
}
$this->published();
$this->extension();
}

/**
Expand Down
2 changes: 1 addition & 1 deletion system/src/Grav/Common/TwigExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,7 @@ public function absoluteUrlFilter($string)
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']) {
Expand Down
4 changes: 3 additions & 1 deletion system/src/Grav/Common/Uri.php
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,9 @@ public function init()
// 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'];
}
Expand Down
38 changes: 17 additions & 21 deletions system/src/Grav/Console/Cli/BackupCommand.php
Original file line number Diff line number Diff line change
@@ -1,33 +1,26 @@
<?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
* @package Grav\Console\Cli
*/
class BackupCommand extends Command
{
use ConsoleTrait;

/**
* @var
*/
protected $source;
/**
* @var
*/
protected $progress;
/**
* @var
*/
protected $output;

/**
*
Expand All @@ -39,13 +32,12 @@ protected function configure()
->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();
}

Expand All @@ -57,19 +49,22 @@ protected function configure()
*/
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();

$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']);

ZipBackup::backup($destination, [$this, 'output']);
$log->content([
'time' => time(),
'location' => $backup
]);
$log->save();

$output->writeln('');
$output->writeln('');
Expand Down Expand Up @@ -97,5 +92,6 @@ public function output($args)
break;
}
}

}

33 changes: 11 additions & 22 deletions system/src/Grav/Console/Cli/CleanCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -13,6 +14,7 @@
*/
class CleanCommand extends Command
{
use ConsoleTrait;

/**
* @var array
Expand Down Expand Up @@ -177,27 +179,14 @@ protected function configure()
*/
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;

Expand All @@ -206,16 +195,16 @@ private function cleanPaths(OutputInterface $output)

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>');
}

}
Expand Down
33 changes: 14 additions & 19 deletions system/src/Grav/Console/Cli/ClearCacheCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -14,6 +15,7 @@
*/
class ClearCacheCommand extends Command
{
use ConsoleTrait;

/**
*
Expand All @@ -38,40 +40,33 @@ protected function configure()
*/
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);
}
}
}
Expand Down
2 changes: 2 additions & 0 deletions system/src/Grav/Console/Cli/ComposerCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,8 @@ protected function configure()
*/
protected function execute(InputInterface $input, OutputInterface $output)
{
$this->setupConsole($input, $output);

$action = 'update';

if ($input->getOption('install')) {
Expand Down
Loading

0 comments on commit 0ba1af2

Please sign in to comment.