Skip to content

Commit

Permalink
initial import
Browse files Browse the repository at this point in the history
  • Loading branch information
vicb committed Aug 17, 2010
0 parents commit d147507
Show file tree
Hide file tree
Showing 12 changed files with 840 additions and 0 deletions.
22 changes: 22 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
Copyright (c) 2010 Victor Berchet <https://github.com/vicb>

Permission is hereby granted, free of charge, to any person
obtaining a copy of this software and associated documentation
files (the "Software"), to deal in the Software without
restriction, including without limitation the rights to use,
copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following
conditions:

The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.
98 changes: 98 additions & 0 deletions README.markdown
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
# sfSassyCssPlugin #

sfSassyCssPlugin brings the power of [sass stylesheets](http://sass-lang.com) to symfony

**WARNING: This plugin is in an alpha state. Use with caution ! **

## Requirements ##

* PHP 5.2.4+
* Symfony 1.3 or 1.4

## Installation ##

### Installing the sass compiler ###

Follow [the instructions](http://sass-lang.com/tutorial.html).

### Installing sfSassyCssPlugin using git ###

$ cd /path/to/symfony/project
$ git clone git://github.com/vicb/sfSassyCssPlugin.git plugins/sfSassyCssPlugin

If your project already uses `git`, you can add the plugin as a submodule:

$ cd /path/to/symfony/project
$ git submodule add git://github.com/vicb/sfSassyCssPlugin.git plugins/sfSassyCssPlugin
$ git submodule update --init
$ git commit -a -m "added sfSassyCssPlugin submodule"

## Enabling the plugin ##

Edit your `config/ProjectConfiguration.class.php` file to enable the plugin:

<?php
class ProjectConfiguration extends sfProjectConfiguration
{
public function setup()
{
$this->enablePlugins(array(
// ... other plugin(s)
'sfSassyCssPlugin',
));
}
}

## Configuration ##

### Default ###

The default configuration can be found in the `app.yml` configuration file inside the plugin `config` folder:

all:
sfSassyCssPlugin:
enabled: false # Wether to trigger sass compilation
input_dir: %SF_DATA_DIR%/sass # Sass source folder
output_dir: %SF_WEB_DIR%/css # Target folder where to generate the files
format: scss # Input format: scss, sass
include_dirs: [] # Array of sass import path.
cache: true # Wether to use the cache
cache_dir: %SF_CACHE_DIR%/sass # The path to put cached Sass files
trace: false # Show a full traceback on error
style: compact # Output style: nested, compact, compressed, or expanded.
debug_info: false # Emit extra information in the generated CSS that can be used by the FireSass Firebug plugin.
line_numbers: false # Emit comments in the generated CSS indicating the corresponding sass line.
line_comments: false
toolbar: false # Wether to display the debug toolbar

dev:
sfSassyCssPlugin:
enabled: true # Wether to trigger sass compilation
style: expanded # Output style: nested, compact, compressed, or expanded.
toolbar: true # Wether to display the debug toolbar


## Usage ##

### In development ###

Using the default configuration the sass stylesheets are generated on each request.
The sass built-in cache helps speeding up the processing.

### In production ###

No automatic compilation is done in production with the default configuration for obvious speed reasons.

You should run the `sass:compile` task instead in order to re-generate your css files.

## Authors and contributors ##

* sfSassyCssPlugin has been created by [Victor Berchet](https://github.com/vicb)
* The inspiration and some parts of the code comes from [sfLESSPlugin](https://github.com/everzet/sfLESSPlugin) by [Kudryashov Konstantin](http://everzet.com)

##Changelog ##

### v0.1.0 - 2010-08-17 ###

* Initial release

21 changes: 21 additions & 0 deletions config/app.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
all:
sfSassyCssPlugin:
enabled: false # Wether to trigger sass compilation
input_dir: %SF_DATA_DIR%/sass # Sass source folder
output_dir: %SF_WEB_DIR%/css # Target folder where to generate the files
format: scss # Input format: scss, sass
include_dirs: [] # Array of sass import path.
cache: true # Wether to use the cache
cache_dir: %SF_CACHE_DIR%/sass # The path to put cached Sass files
trace: false # Show a full traceback on error
style: compact # Output style: nested, compact, compressed, or expanded.
debug_info: false # Emit extra information in the generated CSS that can be used by the FireSass Firebug plugin.
line_numbers: false # Emit comments in the generated CSS indicating the corresponding sass line.
line_comments: false
toolbar: false # Wether to display the debug toolbar

dev:
sfSassyCssPlugin:
enabled: true # Wether to trigger sass compilation
style: expanded # Output style: nested, compact, compressed, or expanded.
toolbar: true # Wether to display the debug toolbar
48 changes: 48 additions & 0 deletions config/sfSassyCssPluginConfiguration.class.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
<?php
/*
* This file is part of the sfSassyCssPlugin.
* (c) 2010 Victor Berchet <https://github.com/vicb>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

/**
* sfSassyCssPlugin configuration
*
* @package sfSassyCssPlugin
* @subpackage configuration
* @author Victor Berchet
*/
class sfSassyCssPluginConfiguration extends sfPluginConfiguration
{
/**
* @see sfPluginConfiguration
*/
public function initialize()
{
if (sfConfig::get('app_sfSassyCssPlugin_enabled'))
{
$this->dispatcher->connect('context.load_factories', array($this, 'compileSass'));

if (sfConfig::get('sf_web_debug') && sfConfig::get('app_sfSassyCssPlugin_toolbar'))
{
$this->dispatcher->connect('debug.web.load_panels', array(
'sfSassyWebDebugPanel',
'listenToLoadDebugWebPanelEvent'
));
}
}
}

public function compileSass()
{
$compiler = sfSassCompilerDefault::getInstance($this->dispatcher);

$compiler->compile(
sfConfig::get('app_sfSassyCssPlugin_input_dir'),
$out = sfConfig::get('app_sfSassyCssPlugin_output_dir')
);
}

}
103 changes: 103 additions & 0 deletions lib/debug/sfSassyWebDebugPanel.class.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
<?php
/*
* This file is part of the sfSassyCssPlugin.
* (c) 2010 Victor Berchet <https://github.com/vicb>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

/**
* sfSassyWebDebugPanel Web debug toolbar extension for sass
*
* @package sfSassyCssPlugin
* @subpackage debug
* @author Victor Berchet
*/
class sfSassyWebDebugPanel extends sfWebDebugPanel
{
protected $compiler;

/**
* Listens to LoadDebugWebPanel event & adds this panel to the Web Debug toolbar
*
* @param sfEvent $event
*/
public static function listenToLoadDebugWebPanelEvent(sfEvent $event)
{
$event->getSubject()->setPanel(
'documentation',
new self($event->getSubject())
);
}

/**
* @see sfWebDebugPanel
*/
public function getTitle()
{
return '<img src="/sfSassyCssPlugin/images/css_go.png" alt="Sassy Css" height="16" width="16" /> Sass';
}

/**
* @see sfWebDebugPanel
*/
public function getPanelTitle()
{
return 'Sass compiler';
}

/**
* @see sfWebDebugPanel
*/
public function getPanelContent()
{
$this->compiler = sfSassCompilerDefault::getInstance(sfContext::getInstance()->getEventDispatcher());

$stderr = $this->compiler->getStdErr();
$stdout = $this->compiler->getStdOut();
$cmd = $this->compiler->getCommand();

$content = <<<DEBUG
<h2>Command</h2>
<p style="display: block; border: 1px solid black; padding: 5px; background-color: white;">
{command}
</p>
<br/>
DEBUG;

if (!empty($stdout))
{
$content .= <<<STDOUT
<h2>Standard output</h2>
<div style="display: block; border: 1px solid black; padding: 5px; background-color: white;">
{stdout}
</div>
STDOUT;
}

if (!empty($stderr))
{
$content .= <<<STDERR
<h2>Error output</h2>
<div style="display: block; border: 1px solid black; padding: 5px; color: red; background-color: white;">
{stderr}
</div>
STDERR;
}

require sfConfig::get('sf_symfony_lib_dir') . '/helper/TextHelper.php';

$content = strtr($content, array(
'{command}' => htmlentities($cmd),
'{stdout}' => simple_format_text(htmlentities($stdout)),
'{stderr}' => simple_format_text(htmlentities($stderr))
));

$this->setStatus(!empty($stderr) || preg_match('/error /mi', $stdout) !== 0?sfLogger::ERR:sfLogger::INFO);

return $content;
}

}
35 changes: 35 additions & 0 deletions lib/sass/sfSassCompilerArgs.class.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<?php
/*
* This file is part of the sfSassyCssPlugin.
* (c) 2010 Victor Berchet <https://github.com/vicb>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

/**
* sfSassCompilerArgs Compiles using the provided arguments
*
* @package sfSassyCssPlugin
* @subpackage sass
* @author Victor Berchet
*/
class sfSassCompilerArgs extends sfSassCompilerBase
{
private static $instance;

/*
* Return the instance of the compiler
*
* @param sfEventDispatcher $dispatcher Event dispatcher
* @return sfSassCompiler The instance
*/
public static function getInstance(sfEventDispatcher $dispatcher)
{
if (!self::$instance)
{
self::$instance = new sfSassCompilerArgs($dispatcher);
}
return self::$instance;
}
}
Loading

0 comments on commit d147507

Please sign in to comment.