├── .gitignore
├── .travis.yml
├── DflydevGitHubGistTwigBundle.php
├── phpunit.xml.dist
├── README.md
├── LICENSE
├── Resources
└── config
│ └── services.xml
├── composer.json
├── DependencyInjection
├── Configuration.php
└── DflydevGitHubGistTwigExtension.php
├── Command
└── Cache
│ └── ClearCommand.php
└── Tests
└── DependencyInjection
└── DflydevGitHubGistTwigExtensionTest.php
/.gitignore:
--------------------------------------------------------------------------------
1 | composer.lock
2 | phpunit.xml
3 | vendor
4 |
--------------------------------------------------------------------------------
/.travis.yml:
--------------------------------------------------------------------------------
1 | language: php
2 |
3 | php:
4 | - 5.3.3
5 | - 5.3
6 | - 5.4
7 |
8 | before_script:
9 | - curl -s http://getcomposer.org/installer | php -- --quiet
10 | - php composer.phar install --dev
11 |
12 | script: phpunit --coverage-text
13 |
--------------------------------------------------------------------------------
/DflydevGitHubGistTwigBundle.php:
--------------------------------------------------------------------------------
1 |
20 | */
21 | class DflydevGitHubGistTwigBundle extends Bundle
22 | {
23 |
24 | }
25 |
--------------------------------------------------------------------------------
/phpunit.xml.dist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | ./Tests
6 |
7 |
8 |
9 |
10 |
11 | ./
12 |
13 | vendor
14 | Tests
15 |
16 |
17 |
18 |
19 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | GitHub Gist Twig Bundle
2 | =======================
3 |
4 | A [Symfony2](http://symfony.com) bundle to provide the ability to
5 | embed [GitHub](http://github.com) [Gist](http://gist.github.com)
6 | snippets into [Twig](http://twig.sensiolabs.org/) formatted pages.
7 |
8 |
9 | Usage
10 | -----
11 |
12 | Add the following to `composer.json`:
13 |
14 | ```json
15 | {
16 | "require": {
17 | "dflydev/github-gist-twig-bundle": "1.*"
18 | }
19 | }
20 | ```
21 |
22 | Add the following to `config.yml` or whichever configuration
23 | is most appropriate for your Kernel site:
24 |
25 | Dflydev\Bundle\GitHubGistTwigBundle\DflydevGitHubGistTwigBundle
26 |
27 |
28 | License
29 | -------
30 |
31 | MIT, see LICENSE.
32 |
33 |
34 | Community
35 | ---------
36 |
37 | Want to get involved? Here are a few ways:
38 |
39 | * Find us in the [#dflydev](irc://irc.freenode.org/dflydev) IRC
40 | channel on irc.freenode.org.
41 | * Mention [@dflydev](http://twitter.com/dflydev) on Twitter.
42 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | Copyright (c) 2012 Dragonfly Development Inc.
2 |
3 | Permission is hereby granted, free of charge, to any person obtaining a copy
4 | of this software and associated documentation files (the "Software"), to deal
5 | in the Software without restriction, including without limitation the rights
6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7 | copies of the Software, and to permit persons to whom the Software is furnished
8 | to do so, subject to the following conditions:
9 |
10 | The above copyright notice and this permission notice shall be included in all
11 | copies or substantial portions of the Software.
12 |
13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19 | THE SOFTWARE.
20 |
--------------------------------------------------------------------------------
/Resources/config/services.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
7 | %kernel.cache_dir%/dflydevGitHubGistTwig
8 | Dflydev\Twig\Extension\GitHubGist\Cache\FilesystemCache
9 | Dflydev\Twig\Extension\GitHubGist\GistTwigExtension
10 |
11 |
12 |
13 |
14 | %dflydev_github_gist_twig.cache_dir%
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
--------------------------------------------------------------------------------
/composer.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "dflydev/github-gist-twig-bundle",
3 | "description": "GitHub Gist Twig Bundle",
4 | "homepage": "http://github.com/dflydev/dflydev-github-gist-twig-bundle",
5 | "keywords": ["github", "gist", "twig"],
6 | "license": "MIT",
7 | "authors": [
8 | {
9 | "name": "Dragonfly Development Inc.",
10 | "email": "info@dflydev.com",
11 | "homepage": "http://dflydev.com"
12 | },
13 | {
14 | "name": "Beau Simensen",
15 | "email": "beau@dflydev.com",
16 | "homepage": "http://beausimensen.com"
17 | }
18 | ],
19 | "require": {
20 | "php": ">=5.3.2",
21 | "dflydev/github-gist-twig-extension": "2.*",
22 | "symfony/http-kernel": "~2.1",
23 | "symfony/config": "~2.1",
24 | "symfony/console": "~2.1",
25 | "symfony/dependency-injection": "~2.1"
26 | },
27 | "autoload": {
28 | "psr-0": {
29 | "Dflydev\\Bundle\\GitHubGistTwigBundle": ""
30 | }
31 | },
32 | "target-dir": "Dflydev/Bundle/GitHubGistTwigBundle",
33 | "extra": {
34 | "branch-alias": {
35 | "dev-master": "1.0-dev"
36 | }
37 | },
38 | "minimum-stability": "beta"
39 | }
40 |
--------------------------------------------------------------------------------
/DependencyInjection/Configuration.php:
--------------------------------------------------------------------------------
1 |
21 | */
22 | class Configuration implements ConfigurationInterface
23 | {
24 | /**
25 | * {@inheritdoc}
26 | */
27 | public function getConfigTreeBuilder()
28 | {
29 | $treeBuilder = new TreeBuilder;
30 |
31 | $rootNode = $treeBuilder->root('dflydev_github_gist_twig');
32 |
33 | $rootNode
34 | ->children()
35 | ->arrayNode('cache')
36 | ->addDefaultsIfNotSet()
37 | ->children()
38 | ->booleanNode('enabled')->defaultTrue()->end()
39 | ->end()
40 | ->end()
41 | ->end();
42 |
43 | return $treeBuilder;
44 | }
45 | }
46 |
--------------------------------------------------------------------------------
/DependencyInjection/DflydevGitHubGistTwigExtension.php:
--------------------------------------------------------------------------------
1 |
24 | */
25 | class DflydevGitHubGistTwigExtension extends Extension
26 | {
27 | /**
28 | * {@inheritdoc}
29 | */
30 | public function load(array $configs, ContainerBuilder $container)
31 | {
32 | $configuration = new Configuration;
33 | $config = $this->processConfiguration($configuration, $configs);
34 |
35 | $loader = new Loader\XmlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config'));
36 | $loader->load('services.xml');
37 |
38 | if (isset($config['cache']) && isset($config['cache']['enabled']) && $config['cache']['enabled']) {
39 | $container
40 | ->findDefinition('dflydev_github_gist_twig.extension')
41 | ->addMethodCall('setCache', array(new Reference('dflydev_github_gist_twig.cache.filesystem')));
42 | }
43 | }
44 | }
45 |
--------------------------------------------------------------------------------
/Command/Cache/ClearCommand.php:
--------------------------------------------------------------------------------
1 |
22 | */
23 | class ClearCommand extends Command
24 | {
25 | /**
26 | * {@inheritdoc}
27 | */
28 | protected function configure()
29 | {
30 | $this
31 | ->setName('cache:clear:gitHubGist')
32 | ->setDescription('Clear GitHub Gist Twig cache')
33 | ->setHelp(<<cache:clear:gitHubGist command clears the gitHubGist cache.
35 | EOT
36 | );
37 | }
38 |
39 | /**
40 | * {@inheritdoc}
41 | */
42 | protected function execute(InputInterface $input, OutputInterface $output)
43 | {
44 | $container = $this->getApplication()->getKernel()->getContainer();
45 | $cacheDir = $container->getParameter('dflydev_github_gist_twig.cache_dir');
46 |
47 | $kernel = $container->get('kernel');
48 | $output->writeln(sprintf('Clearing the GitHub Gist Twig cache for the %s environment with debug %s', $kernel->getEnvironment(), var_export($kernel->isDebug(), true)));
49 |
50 | $container->get('filesystem')->remove($cacheDir);
51 | }
52 | }
53 |
--------------------------------------------------------------------------------
/Tests/DependencyInjection/DflydevGitHubGistTwigExtensionTest.php:
--------------------------------------------------------------------------------
1 |
21 | */
22 | class DflydevGitHubGistTwigExtensionTest extends \PHPUnit_Framework_TestCase
23 | {
24 | protected $configuration;
25 |
26 | /**
27 | * Test default cache settings
28 | */
29 | public function testCacheDefault()
30 | {
31 | $this->configuration = new ContainerBuilder;
32 | $loader = new DflydevGitHubGistTwigExtension;
33 | $config = $this->getEmptyConfig();
34 |
35 | $loader->load(array($config), $this->configuration);
36 |
37 | $definition = $this->configuration->getDefinition('dflydev_github_gist_twig.extension');
38 | $calls = $definition->getMethodCalls();
39 |
40 | foreach ($calls as $call) {
41 | list ($methodName, $args) = $call;
42 | if ('setCache' === $methodName) {
43 | // Default should be to set cache to the filesystem cache.
44 | $this->assertEquals('dflydev_github_gist_twig.cache.filesystem', $args[0]);
45 |
46 | return;
47 | }
48 | }
49 |
50 | $this->fail('setCache method should be called');
51 | }
52 |
53 | /**
54 | * Test enabled cache
55 | */
56 | public function testCacheEnabled()
57 | {
58 | $this->configuration = new ContainerBuilder;
59 | $loader = new DflydevGitHubGistTwigExtension;
60 | $config = $this->getEmptyConfig();
61 |
62 | $config['cache'] = array('enabled' => true);
63 |
64 | $loader->load(array($config), $this->configuration);
65 |
66 | $definition = $this->configuration->getDefinition('dflydev_github_gist_twig.extension');
67 | $calls = $definition->getMethodCalls();
68 |
69 | foreach ($calls as $call) {
70 | list ($methodName, $args) = $call;
71 | if ('setCache' === $methodName) {
72 | // Default should be to set cache to the filesystem cache.
73 | $this->assertEquals('dflydev_github_gist_twig.cache.filesystem', $args[0]);
74 |
75 | return;
76 | }
77 | }
78 |
79 | $this->fail('setCache method should be called');
80 | }
81 |
82 | /**
83 | * Test disabled cache
84 | */
85 | public function testCacheDisabled()
86 | {
87 | $this->configuration = new ContainerBuilder;
88 | $loader = new DflydevGitHubGistTwigExtension;
89 | $config = $this->getEmptyConfig();
90 |
91 | $config['cache'] = array('enabled' => false);
92 |
93 | $loader->load(array($config), $this->configuration);
94 |
95 | $definition = $this->configuration->getDefinition('dflydev_github_gist_twig.extension');
96 | $calls = $definition->getMethodCalls();
97 |
98 | foreach ($calls as $call) {
99 | list ($methodName, $args) = $call;
100 | if ('setCache' === $methodName) {
101 | // Default should be to set cache to the filesystem cache.
102 | $this->fail('setCache method should not be called');
103 |
104 | return;
105 | }
106 | }
107 | }
108 |
109 | /**
110 | * Get empty configuration
111 | *
112 | * @return array
113 | */
114 | protected function getEmptyConfig()
115 | {
116 | return array();
117 | }
118 |
119 | protected function tearDown()
120 | {
121 | unset($this->configuration);
122 | }
123 | }
124 |
--------------------------------------------------------------------------------