Skip to content

Commit

Permalink
Merge branch 'develop' of https://github.com/getgrav/grav into 2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
mahagr committed Jun 6, 2017
2 parents c4fac41 + ff8a8dd commit 3468f59
Show file tree
Hide file tree
Showing 7 changed files with 20 additions and 12 deletions.
1 change: 0 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ php:
- '5.5'
- '5.6'
- '7.0'
- hhvm
branches:
only:
- develop
Expand Down
1 change: 1 addition & 0 deletions system/languages/en.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ NICETIME:
BAD_DATE: Bad date
AGO: ago
FROM_NOW: from now
JUST_NOW: just now
SECOND: second
MINUTE: minute
HOUR: hour
Expand Down
2 changes: 1 addition & 1 deletion system/src/Grav/Common/Page/Medium/ImageMedium.php
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ public function url($reset = true)
$this->reset();
}

return Grav::instance()['base_url'] . '/' . ltrim($output . $this->querystring() . $this->urlHash(), '/');
return trim(Grav::instance()['base_url'] . '/' . ltrim($output . $this->querystring() . $this->urlHash(), '/'), '\\');
}

/**
Expand Down
2 changes: 1 addition & 1 deletion system/src/Grav/Common/Page/Medium/Medium.php
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ public function url($reset = true)
$this->reset();
}

return Grav::instance()['base_url'] . '/' . ltrim($output . $this->querystring() . $this->urlHash(), '/');
return trim(Grav::instance()['base_url'] . '/' . ltrim($output . $this->querystring() . $this->urlHash(), '/'), '\\');
}

/**
Expand Down
12 changes: 6 additions & 6 deletions system/src/Grav/Common/Page/Page.php
Original file line number Diff line number Diff line change
Expand Up @@ -156,8 +156,8 @@ public function init(\SplFileInfo $file, $extension = null)
protected function processFrontmatter()
{
// Quick check for twig output tags in frontmatter if enabled
if (Utils::contains($this->frontmatter, '{{')) {
$process_fields = $this->file()->header();
$process_fields = (array)$this->header();
if (Utils::contains(json_encode(array_values($process_fields)), '{{')) {
$ignored_fields = [];
foreach ((array)Grav::instance()['config']->get('system.pages.frontmatter.ignore_fields') as $field) {
if (isset($process_fields[$field])) {
Expand Down Expand Up @@ -325,17 +325,17 @@ public function header($var = null)
$this->header = (object)$file->header();

if (!Utils::isAdminPlugin()) {
// Process frontmatter with Twig if enabled
if (Grav::instance()['config']->get('system.pages.frontmatter.process_twig') === true) {
$this->processFrontmatter();
}
// If there's a `frontmatter.yaml` file merge that in with the page header
// note page's own frontmatter has precedence and will overwrite any defaults
$frontmatter_file = $this->path . '/' . $this->folder . '/frontmatter.yaml';
if (file_exists($frontmatter_file)) {
$frontmatter_data = (array)Yaml::parse(file_get_contents($frontmatter_file));
$this->header = (object)array_replace_recursive($frontmatter_data, (array)$this->header);
}
// Process frontmatter with Twig if enabled
if (Grav::instance()['config']->get('system.pages.frontmatter.process_twig') === true) {
$this->processFrontmatter();
}
}
} catch (ParseException $e) {
$file->raw(Grav::instance()['language']->translate([
Expand Down
12 changes: 10 additions & 2 deletions system/src/Grav/Common/Twig/TwigExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -445,6 +445,9 @@ public function nicetimeFilter($date, $long_strings = true)
$difference = $now - $unix_date;
$tense = $this->grav['language']->translate('NICETIME.AGO', null, true);

} else if ($now == $unix_date) {
$tense = $this->grav['language']->translate('NICETIME.JUST_NOW', null, false);

} else {
$difference = $unix_date - $now;
$tense = $this->grav['language']->translate('NICETIME.FROM_NOW', null, true);
Expand All @@ -469,8 +472,13 @@ public function nicetimeFilter($date, $long_strings = true)
}

$periods[$j] = $this->grav['language']->translate($periods[$j], null, true);

return "$difference $periods[$j] {$tense}";

if ($now == $unix_date) {
return "{$tense}";
}
else {
return "$difference $periods[$j] {$tense}";
}
}

/**
Expand Down
2 changes: 1 addition & 1 deletion system/src/Grav/Console/Cli/NewProjectCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ protected function configure()
'Symlink the required bits'
)
->setDescription('Creates a new Grav project with all the dependencies installed')
->setHelp('The <info>new-project</info> command is a combination of the `setup` and `install` commands.\nCreates a new Grav instance and performs the installation of all the required dependencies.');
->setHelp("The <info>new-project</info> command is a combination of the `setup` and `install` commands.\nCreates a new Grav instance and performs the installation of all the required dependencies.");
}

/**
Expand Down

0 comments on commit 3468f59

Please sign in to comment.