Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TwigExtension - detect (in)human agent #1209

Closed
wants to merge 44 commits into from
Closed
Changes from all commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
f656330
Added CSS Group asset support #374
rhukster Oct 24, 2015
a7a5625
Revert "Added CSS Group asset support #374"
rhukster Oct 24, 2015
8bba0fd
Merge branch 'release/1.0.0-rc.2'
rhukster Oct 27, 2015
8de55a7
Merge branch 'release/1.0.0-rc.3'
rhukster Oct 29, 2015
695793b
Merge branch 'release/1.0.0-rc.4'
rhukster Oct 30, 2015
e62ff07
Merge branch 'release/1.0.0-rc.4'
rhukster Oct 30, 2015
50c6e81
Merge branch 'release/1.0.0-rc.5'
rhukster Nov 21, 2015
dba7347
Merge branch 'release/1.0.0-rc.6'
rhukster Dec 1, 2015
e4e0c06
Merge branch 'release/1.0.0'
rhukster Dec 11, 2015
2bb23ef
Merge branch 'release/1.0.1'
rhukster Dec 11, 2015
f7696b6
Merge branch 'release/1.0.2'
rhukster Dec 12, 2015
fcdd0bc
Reverted CleanCommand to pure Command
w00fz Dec 12, 2015
4a5a400
Merge branch 'release/1.0.3'
rhukster Dec 12, 2015
747daa4
Merge branch 'release/1.0.4'
rhukster Dec 12, 2015
08cbd95
Merge branch 'release/1.0.5'
rhukster Dec 18, 2015
f0145aa
Merge branch 'release/1.0.6'
rhukster Dec 23, 2015
4549574
Merge branch 'release/1.0.7'
rhukster Jan 7, 2016
8ca14c7
Merge branch 'release/1.0.7'
rhukster Jan 7, 2016
b48449d
Merge branch 'release/1.0.8'
rhukster Jan 8, 2016
652c5cd
Merge branch 'release/1.0.9'
rhukster Feb 5, 2016
7b6cadb
Merge branch 'release/1.0.10'
rhukster Feb 11, 2016
f8adf87
Merge branch 'release/1.1.0'
rhukster Jul 14, 2016
231bc81
Merge branch 'release/1.1.0'
rhukster Jul 14, 2016
1a1b291
Merge branch 'release/1.1.1'
rhukster Jul 16, 2016
1232eca
Merge branch 'release/1.1.2'
rhukster Aug 11, 2016
7843b30
Merge branch 'release/1.1.3'
rhukster Aug 14, 2016
6098608
Merge branch 'release/1.1.4'
rhukster Sep 7, 2016
3459fbc
Merge branch 'release/1.1.5'
rhukster Sep 9, 2016
5069088
Merge branch 'release/1.1.6'
rhukster Oct 19, 2016
68c660e
Update Taxonomy.php
gigago Oct 21, 2016
f7a12fa
Update TwigExtension.php
gigago Oct 21, 2016
e1c1273
Update TwigExtension.php
gigago Oct 23, 2016
9c1830d
Update TwigExtension.php
gigago Dec 13, 2016
102973d
Update TwigExtension.php
gigago Dec 13, 2016
7a59a84
Merge remote-tracking branch 'origin/develop' into develop
Dec 16, 2016
5a41348
Merge remote-tracking branch 'origin/master' into develop
Dec 17, 2016
50fc775
Revert "Merge remote-tracking branch 'origin/develop' into develop"
Dec 17, 2016
e2704d9
Revert "Revert "Merge remote-tracking branch 'origin/develop' into de…
Dec 17, 2016
07bc773
Attempt to resolve conflicts
Dec 17, 2016
445fd13
param comment corrected
Dec 17, 2016
b1f4a2c
Update TwigExtension.php
gigago Dec 17, 2016
5c089bf
Update TwigExtension.php
gigago Dec 17, 2016
8e0430a
Update TwigExtension.php
gigago Dec 17, 2016
f16ae0d
Update TwigExtension.php
gigago Dec 17, 2016
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions system/src/Grav/Common/Twig/TwigExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
use Grav\Common\Markdown\Parsedown;
use Grav\Common\Markdown\ParsedownExtra;
use Grav\Common\Uri;
use Grav\Common\Browser;
use RocketTheme\Toolbox\ResourceLocator\UniformResourceLocator;

class TwigExtension extends \Twig_Extension
Expand Down Expand Up @@ -116,6 +117,7 @@ public function getFunctions()
new \Twig_SimpleFunction('json_decode', [$this, 'jsonDecodeFilter']),
new \Twig_SimpleFunction('get_cookie', [$this, 'getCookie']),
new \Twig_SimpleFunction('redirect_me', [$this, 'redirectFunc']),
new \Twig_SimpleFunction('ishuman', [$this, 'isHuman']),
new \Twig_SimpleFunction('range', [$this, 'rangeFunc']),
];
}
Expand Down Expand Up @@ -835,6 +837,17 @@ public function redirectFunc($url, $statusCode = 303)
die();
}

/**
* detect (in)humane agent
*
* @return true if human, otherwise false
*/
public function isHuman()
{
$agent = new Browser;
return $agent->isHuman();
}

/**
* Generates an array containing a range of elements, optionally stepped
*
Expand Down