├── .gitignore
├── Resources
└── config
│ └── sculpin.yml
├── .travis.yml
├── Tests
├── bootstrap.php
└── dflydev
│ └── tests
│ └── sculpin
│ └── bundle
│ └── twigGitHubGistBundle
│ └── TwigGitHubGistBundleTest.php
├── phpunit.xml.dist
├── composer.json
├── LICENSE
├── Command
└── Cache
│ └── ClearCommand.php
├── README.md
└── TwigGitHubGistBundle.php
/.gitignore:
--------------------------------------------------------------------------------
1 | composer.lock
2 | phpunit.xml
3 | vendor
4 |
--------------------------------------------------------------------------------
/Resources/config/sculpin.yml:
--------------------------------------------------------------------------------
1 | twig_github_gist:
2 | enabled: true
3 | cache:
4 | enabled: true
5 | directory: twigGitHubGist
6 |
--------------------------------------------------------------------------------
/.travis.yml:
--------------------------------------------------------------------------------
1 | language: php
2 |
3 | php:
4 | - 5.3.3
5 | - 5.3
6 | - 5.4
7 |
8 | before_script:
9 | - wget -nc http://getcomposer.org/composer.phar
10 | - php composer.phar install --dev
11 |
12 | script: phpunit --coverage-text
13 |
--------------------------------------------------------------------------------
/Tests/bootstrap.php:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | ./Tests
6 |
7 |
8 |
9 |
10 |
11 | .
12 |
13 | ./Resources
14 | ./Tests
15 | ./vendor
16 |
17 |
18 |
19 |
20 |
--------------------------------------------------------------------------------
/composer.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "dflydev/twig-github-gist-sculpin-bundle",
3 | "type": "sculpin-bundle",
4 | "description": "GitHub Gist Sculpin Bundle",
5 | "homepage": "http://github.com/dflydev/dflydev-twig-gitHub-gist-sculpin-bundle",
6 | "keywords": ["twig", "github", "gist", "sculpin"],
7 | "license": "MIT",
8 | "authors": [
9 | {
10 | "name": "Dragonfly Development Inc.",
11 | "email": "info@dflydev.com",
12 | "homepage": "http://dflydev.com"
13 | },
14 | {
15 | "name": "Beau Simensen",
16 | "email": "beau@dflydev.com",
17 | "homepage": "http://beausimensen.com"
18 | }
19 | ],
20 | "require": {
21 | "php": ">=5.3.2",
22 | "sculpin/sculpin": "2.*",
23 | "dflydev/github-gist-twig-extension": "1.*"
24 | },
25 | "autoload": {
26 | "psr-0": {
27 | "Dflydev\\Sculpin\\Bundle\\TwigGitHubGistBundle": ""
28 | }
29 | },
30 | "target-dir": "Dflydev/Sculpin/Bundle/TwigGitHubGistBundle",
31 | "minimum-stability": "dev"
32 | }
33 |
--------------------------------------------------------------------------------
/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 |
--------------------------------------------------------------------------------
/Command/Cache/ClearCommand.php:
--------------------------------------------------------------------------------
1 | setName('cache:clear:gitHubGist')
29 | ->setDescription('Clear gitHubGist cache')
30 | ->setHelp(<<cache:clear:gitHubGist command clears the gitHubGist cache.
32 | EOT
33 | )
34 | ;
35 | }
36 |
37 | /**
38 | * @{inheritdoc}
39 | */
40 | protected function execute(InputInterface $input, OutputInterface $output)
41 | {
42 | $sculpin = $this->getSculpinApplication()->createSculpin();
43 | $sculpin->start();
44 | $sculpin->clearCacheFor($sculpin->configuration()->get(TwigGitHubGistBundle::CONFIG_CACHE_DIRECTORY));
45 | }
46 | }
47 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | Twig GitHub Gist Sculpin Bundle
2 | ===============================
3 |
4 | A [Sculpin](http://getsculpin.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 | Deprecated
10 | ==========
11 |
12 | This project has been deprecated in favor of a generic Symfony2 bundle
13 | [dflydev/github-gist-twig-bundle](https://github.com/dflydev/dflydev-github-gist-twig-bundle).
14 |
15 |
16 | Requirements
17 | ------------
18 |
19 | * PHP: >=5.3.2
20 |
21 |
22 | Usage
23 | -----
24 |
25 | Add the following to `composer.json` for the Sculpin site:
26 |
27 | ```json
28 | {
29 | "require": {
30 | "dflydev/twig-github-gist-sculpin-bundle": "1.*"
31 | }
32 | }
33 | ```
34 |
35 | Run `sculpin composer:update` to download the bundle and its
36 | dependencies.
37 |
38 | Add the following to `sculpin.yml` or whichever configuration
39 | is most appropriate for the Sculpin site:
40 |
41 | ```yaml
42 | bundles:
43 | - dflydev\sculpin\bundle\twigGitHubGistBundle\TwigGitHubGistBundle
44 | ```
45 |
46 |
47 | License
48 | -------
49 |
50 | MIT, see LICENSE.
51 |
52 |
53 | Community
54 | ---------
55 |
56 | Want to get involved? Here are a few ways:
57 |
58 | * Find us in the [#sculpin](irc://irc.freenode.org/sculpin) IRC
59 | channel on irc.freenode.org.
60 | * Join the [Sculpin Users](http://groups.google.com/group/sculpin-users)
61 | mailing list.
62 | * Mention [@getsculpin](http://twitter.com/getsculpin) on Twitter.
63 |
--------------------------------------------------------------------------------
/TwigGitHubGistBundle.php:
--------------------------------------------------------------------------------
1 |
29 | */
30 | class TwigGitHubGistBundle extends AbstractBundle
31 | {
32 | /**
33 | * Is this bundle enabled?
34 | *
35 | * @var string
36 | */
37 | const CONFIG_ENABLED = 'twig_github_gist.enabled';
38 |
39 | /**
40 | * Is cache enabled?
41 | *
42 | * @var string
43 | */
44 | const CONFIG_CACHE_ENABLED = 'twig_github_gist.cache.enabled';
45 |
46 | /**
47 | * Name of cache directory
48 | *
49 | * @var string
50 | */
51 | const CONFIG_CACHE_DIRECTORY = 'twig_github_gist.cache.directory';
52 |
53 | /**
54 | * Cache directory
55 | *
56 | * @var string
57 | */
58 | protected $cacheDirectory;
59 |
60 |
61 | /**
62 | * {@inheritdoc}
63 | */
64 | public function boot()
65 | {
66 | if ($this->configuration->get(self::CONFIG_ENABLED)) {
67 | $this->cacheDirectory = $this->sculpin->prepareCacheFor(
68 | $this->configuration->get(self::CONFIG_CACHE_DIRECTORY)
69 | );
70 | $this->sculpin->registerFormatterConfigurationCallback(
71 | TwigBundle::FORMATTER_NAME,
72 | array($this, 'configureTwigFormatter')
73 | );
74 | }
75 | }
76 |
77 | /**
78 | * Configure Twig formatter callback
79 | *
80 | * @param Sculpin $sculpin Sculpin
81 | * @param IFormatter $formatter Formatter
82 | */
83 | public function configureTwigFormatter(Sculpin $sculpin, IFormatter $formatter)
84 | {
85 | if ($formatter instanceof TwigFormatter) {
86 | if ($this->configuration->get(self::CONFIG_CACHE_ENABLED)) {
87 | $cache = new FilesystemCache($this->cacheDirectory);
88 | } else {
89 | $cache = null;
90 | }
91 | $gistTwigExtension = new GistTwigExtension(null, $cache);
92 | $formatter->twig()->addExtension($gistTwigExtension);
93 | }
94 | }
95 | }
96 |
--------------------------------------------------------------------------------
/Tests/dflydev/tests/sculpin/bundle/twigGitHubGistBundle/TwigGitHubGistBundleTest.php:
--------------------------------------------------------------------------------
1 | getMockBuilder('sculpin\configuration\Configuration')
26 | ->disableOriginalConstructor()
27 | ->getMock();
28 | $map = array(
29 | array(TwigGitHubGistBundle::CONFIG_ENABLED, $enabled),
30 | array(TwigGitHubGistBundle::CONFIG_CACHE_ENABLED, $cacheEnabled),
31 | array(TwigGitHubGistBundle::CONFIG_CACHE_DIRECTORY, $cacheDirectory),
32 | array('exclude', array()),
33 | array('core_exclude', array()),
34 | );
35 | $configuration
36 | ->expects($this->any())
37 | ->method('get')
38 | ->will($this->returnValueMap($map));
39 | return $configuration;
40 | }
41 |
42 | public function testConfigureBundleDisabled()
43 | {
44 | $this->markTestSkipped('Requires update after major updates to Sculpin (needs to be aware of DIC)');
45 | $sculpin = $this
46 | ->getMockBuilder('sculpin\Sculpin')
47 | ->disableOriginalConstructor()
48 | ->getMock();
49 | $sculpin
50 | ->expects($this->once())
51 | ->method('configuration')
52 | ->will($this->returnValue($this->getConfigurationMock(false)));
53 | $sculpin
54 | ->expects($this->never())
55 | ->method('prepareCacheFor');
56 | $twigGitHubGistBundle = new TwigGitHubGistBundle();
57 | $twigGitHubGistBundle;
58 | }
59 |
60 | public function testConfigureBundleEnabled()
61 | {
62 | $this->markTestSkipped('Requires update after major updates to Sculpin (needs to be aware of DIC)');
63 | $sculpin = $this
64 | ->getMockBuilder('sculpin\Sculpin')
65 | ->disableOriginalConstructor()
66 | ->getMock();
67 | $sculpin
68 | ->expects($this->exactly(2))
69 | ->method('configuration')
70 | ->will($this->returnValue($this->getConfigurationMock(true, false)));
71 | $sculpin
72 | ->expects($this->once())
73 | ->method('prepareCacheFor')
74 | ->with('twigGitHubGist');
75 | $sculpin
76 | ->expects($this->once())
77 | ->method('registerFormatterConfigurationCallback')
78 | ->with($this->equalTo(TwigBundle::FORMATTER_NAME));
79 | $twigGitHubGistBundle = new TwigGitHubGistBundle();
80 | $twigGitHubGistBundle->boot();
81 | }
82 |
83 | public function testConfigureTwigFormatterNotTwigFormatter()
84 | {
85 | $this->markTestSkipped('Requires update after major updates to Sculpin (needs to be aware of DIC)');
86 | $sculpin = $this
87 | ->getMockBuilder('sculpin\Sculpin')
88 | ->disableOriginalConstructor()
89 | ->getMock();
90 | $sculpin
91 | ->expects($this->never())
92 | ->method('configuration');
93 | $formatter = $this
94 | ->getMock('sculpin\formatter\IFormatter');
95 | $twigGitHubGistBundle = new TwigGitHubGistBundle();
96 | $twigGitHubGistBundle->configureTwigFormatter($sculpin, $formatter);
97 | /*
98 | if ($formatter instanceof TwigFormatter) {
99 | if ($sculpin->configuration()->get(self::CONFIG_CACHE_EANBLED)) {
100 | $cache = new FilesystemCache($this->cacheDirectory);
101 | } else {
102 | $cache = null;
103 | }
104 | $gistTwigExtension = new GistTwigExtension(null, $cache);
105 | $formatter->twig()->addExtension($gistTwigExtension);
106 | }
107 | */
108 | }
109 |
110 | public function testConfigureTwigFormatterCacheEnabled()
111 | {
112 | $this->markTestSkipped('Requires update after major updates to Sculpin (needs to be aware of DIC)');
113 | $sculpin = $this
114 | ->getMockBuilder('sculpin\Sculpin')
115 | ->disableOriginalConstructor()
116 | ->getMock();
117 | $sculpin
118 | ->expects($this->exactly(3))
119 | ->method('configuration')
120 | ->will($this->returnValue($this->getConfigurationMock()));
121 | $twig = $this
122 | ->getMock('\Twig_Environment');
123 | $twig
124 | ->expects($this->once())
125 | ->method('addExtension')
126 | ->with($this->isInstanceOf('dflydev\twig\extension\gitHub\gist\GistTwigExtension'));
127 | $formatter = $this
128 | ->getMockBuilder('sculpin\bundle\twigBundle\TwigFormatter')
129 | ->disableOriginalConstructor()
130 | ->getMock();
131 | $formatter
132 | ->expects($this->once())
133 | ->method('twig')
134 | ->will($this->returnValue($twig));
135 | $twigGitHubGistBundle = new TwigGitHubGistBundle();
136 | $twigGitHubGistBundle->configureBundle($sculpin);
137 | $twigGitHubGistBundle->configureTwigFormatter($sculpin, $formatter);
138 | }
139 |
140 | public function testConfigureTwigFormatterCacheDisabled()
141 | {
142 | $this->markTestSkipped('Requires update after major updates to Sculpin (needs to be aware of DIC)');
143 | $sculpin = $this
144 | ->getMockBuilder('sculpin\Sculpin')
145 | ->disableOriginalConstructor()
146 | ->getMock();
147 | $sculpin
148 | ->expects($this->exactly(3))
149 | ->method('configuration')
150 | ->will($this->returnValue($this->getConfigurationMock(true, false)));
151 | $twig = $this
152 | ->getMock('\Twig_Environment');
153 | $twig
154 | ->expects($this->once())
155 | ->method('addExtension')
156 | ->with($this->isInstanceOf('dflydev\twig\extension\gitHub\gist\GistTwigExtension'));
157 | $formatter = $this
158 | ->getMockBuilder('sculpin\bundle\twigBundle\TwigFormatter')
159 | ->disableOriginalConstructor()
160 | ->getMock();
161 | $formatter
162 | ->expects($this->once())
163 | ->method('twig')
164 | ->will($this->returnValue($twig));
165 | $twigGitHubGistBundle = new TwigGitHubGistBundle();
166 | $twigGitHubGistBundle->configureBundle($sculpin);
167 | $twigGitHubGistBundle->configureTwigFormatter($sculpin, $formatter);
168 | }
169 |
170 | public function testConfigureConsoleApplication()
171 | {
172 | $this->markTestSkipped('Requires update after major updates to Sculpin (needs to be aware of DIC)');
173 | $application = $this
174 | ->getMockBuilder('\sculpin\console\Application')
175 | ->disableOriginalConstructor()
176 | ->getMock();
177 | $inputInterface = $this->getMock('\Symfony\Component\Console\Input\InputInterface');
178 | $outputInterface = $this->getMock('\Symfony\Component\Console\Output\OutputInterface');
179 | $application
180 | ->expects($this->once())
181 | ->method('add')
182 | ->with($this->isInstanceOf('\dflydev\sculpin\bundle\twigGitHubGistBundle\command\cache\ClearCommand'));
183 | TwigGitHubGistBundle::CONFIGURE_CONSOLE_APPLICATION($application, $inputInterface, $outputInterface);
184 | }
185 | }
186 |
--------------------------------------------------------------------------------