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 Dec 1, 2017
2 parents 66d8269 + b4cf789 commit 0524bd2
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 0 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,13 @@
## xx/xx/2017

1. [](#new)
* Added new core Twig templates for `partials/metadata.html.twig` and `partials/messages.html.twig`
* Added ability to work with GPM locally [#1742](https://github.com/getgrav/grav/issues/1742)
* Added new HTML5 audio controls [#1756](https://github.com/getgrav/grav/issues/1756)
* Added `Medium::copy()` method to create a copy of a medium object
* Added new `force_lowercase_urls` functionality on routes and slugs
* Added new `item-list` filter type to remove empty items
* Added new `setFlashCookieObject()` and `getFlashCookieObject()` methods to `Session` object
1. [](#bugfix)
* Fixed issue with multibyte Markdown link URLs [#1749](https://github.com/getgrav/grav/issues/1749)
* Fixed issue with multibyte folder names [#1751](https://github.com/getgrav/grav/issues/1751)
Expand Down
16 changes: 16 additions & 0 deletions system/src/Grav/Common/Session.php
Original file line number Diff line number Diff line change
Expand Up @@ -105,4 +105,20 @@ public function getFlashObject($name)

return $object;
}

// Store something in cookie temporarily
public function setFlashCookieObject($name, $object, $time = 60)
{
setcookie($name, json_encode($object), time() + $time, '/');
}

// Return object and remove it from the cookie
public function getFlashCookieObject($name)
{
if (isset($_COOKIE[$name])) {
$object = json_decode($_COOKIE[$name]);
setcookie($name, '', time() - 3600, '/');
return $object;
}
}
}
3 changes: 3 additions & 0 deletions system/src/Grav/Common/Twig/Twig.php
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,9 @@ public function init()

$active_language = $language->getActive();

// Add Grav core templates location
$this->twig_paths[] = $locator->findResource('system://templates');

// handle language templates if available
if ($language->enabled()) {
$lang_templates = $locator->findResource('theme://templates/' . ($active_language ? $active_language : $language->getDefault()));
Expand Down
14 changes: 14 additions & 0 deletions system/templates/partials/messages.html.twig
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{% set status_mapping = {'info':'green', 'error': 'red', 'warning': 'yellow'} %}

{% if grav.messages.all %}
<div id="messages">
{% for message in grav.messages.fetch %}

{% set scope = message.scope|e %}
{% set color = status_mapping[scope] %}

<div class="notices {{ scope }} {{ color }}"><p>{{ message.message|raw }}</p></div>

{% endfor %}
</div>
{% endif %}
3 changes: 3 additions & 0 deletions system/templates/partials/metadata.html.twig
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{% for meta in page.metadata %}
<meta {% if meta.name %}name="{{ meta.name }}" {% endif %}{% if meta.http_equiv %}http-equiv="{{ meta.http_equiv }}" {% endif %}{% if meta.charset %}charset="{{ meta.charset }}" {% endif %}{% if meta.property %}property="{{ meta.property }}" {% endif %}{% if meta.content %}content="{{ meta.content }}" {% endif %}/>
{% endfor %}

0 comments on commit 0524bd2

Please sign in to comment.