Commit 0e319dd8 by Crisu83

added support for hero content capturing (thanks Christophe Boulain) and updated the less compiler

parent 5e3fec4d
@import "../css/highlight.css";
.clearfix {
*zoom: 1;
}
.clearfix:before, .clearfix:after {
display: table;
content: "";
}
.clearfix:after {
clear: both;
}
body {
padding-top: 60px;
padding-bottom: 60px;
}
h1,
h2,
h3,
h4,
h5,
h6 {
margin-bottom: 0.6em;
}
p {
font-size: 14px;
margin-bottom: 1.6em;
}
.hero-unit h1 {
margin-bottom: 0.4em;
}
.hero-unit p {
margin-bottom: 0;
text-align: justify;
}
.navbar .add-this {
margin: 6px 0 6px 10px;
padding: 6px 0;
}
.subnav {
border: 1px solid #E5E5E5;
font-size: 12px;
-webkit-border-radius: 4px;
-moz-border-radius: 4px;
border-radius: 4px;
width: 100%;
height: 36px;
background-color: #f2f2f2;
background-image: -moz-linear-gradient(top, #f5f5f5, #eeeeee);
background-image: -ms-linear-gradient(top, #f5f5f5, #eeeeee);
background-image: -webkit-gradient(linear, 0 0, 0 100%, from(#f5f5f5), to(#eeeeee));
background-image: -webkit-linear-gradient(top, #f5f5f5, #eeeeee);
background-image: -o-linear-gradient(top, #f5f5f5, #eeeeee);
background-image: linear-gradient(top, #f5f5f5, #eeeeee);
background-repeat: repeat-x;
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#f5f5f5', endColorstr='#eeeeee', GradientType=0);
}
.subnav.subnav-fixed {
border-color: #D5D5D5;
border-width: 1px 0 0;
bottom: 0;
left: 0;
position: fixed;
right: 0;
z-index: 1030;
-webkit-border-radius: 0;
-moz-border-radius: 0;
border-radius: 0;
-webkit-box-shadow: inset 0 1px 0 #ffffff;
-moz-box-shadow: inset 0 1px 0 #ffffff;
box-shadow: inset 0 1px 0 #ffffff;
}
.subnav .nav {
margin: 0 auto;
max-width: 1170px;
}
.subnav .nav > li > a {
margin: 0;
padding: 11px;
border-left: 1px solid whiteSmoke;
border-right: 1px solid #E5E5E5;
-webkit-border-radius: 0;
-moz-border-radius: 0;
border-radius: 0;
}
.subnav .nav > li:first-child > a {
border-left: 0;
}
.subnav .nav > li:last-child > a {
border-right: 0;
}
.subnav .nav > .active > a, .subnav .nav .action > a:hover {
background-color: #E9E9E9;
border-right-color: #DDD;
color: #777;
-webkit-box-shadow: inset 0 3px 5px rgba(0, 0, 0, 0.05);
-moz-box-shadow: inset 0 3px 5px rgba(0, 0, 0, 0.05);
box-shadow: inset 0 3px 5px rgba(0, 0, 0, 0.05);
}
footer .powered {
color: #888;
margin-bottom: 20px;
}
footer .copy {
color: #666;
}
span.required {
color: #F00;
}
.popover h3.popover-title {
margin-bottom: 0;
}
section {
padding-top: 40px;
}
section a.top {
display: block;
text-align: right;
}
#bootNavbar .navbar-inner > .container {
width: auto;
}
#bootMenu .menuCol {
min-height: 140px;
}
#bootTabbable .tabbable {
margin-bottom: 20px;
}
#bootTabbable .tabbable.tabbable-placed {
width: 340px;
}
#bootThumbnails .list-view {
padding-top: 30px;
}
#bootActiveForm .form-vertical .control-group > label {
font-weight: bold;
}
#bootHero .hero-unit {
width: 650px;
}
#bootHero .hero-unit h1 {
margin-bottom: 0;
}
#bootHero .hero-unit p {
margin-bottom: 9px;
}
#bootHero .hero-unit p:last-child {
margin-bottom: 0;
}
#bootCarousel .carousel {
width: 770px;
}
#bootCarousel .carousel .carousel-caption p {
margin-bottom: 9px;
}
#bootTypeahead input {
margin-bottom: 0;
}
.hl-code {
margin-bottom: 20px;
}
.hl-code pre {
background: #FCFCFC;
border-color: #EEE transparent #EEE;
font-family: "Menlo", "Consolas", "Courier New", Courier, mono;
-webkit-border-radius: 0;
-moz-border-radius: 0;
border-radius: 0;
}
.maintenance .hero-unit {
text-align: center;
}
.maintenance .hero-unit p {
text-align: inherit;
}
@media (max-width: 980px) {
body {
padding-top: 0px;
}
}
.clearfix{*zoom:1;}.clearfix:before,.clearfix:after{display:table;content:"";}
.clearfix:after{clear:both;}
.php-hl-default{color:Black;}
.php-hl-code{color:Gray;}
.php-hl-brackets{color:Olive;}
.php-hl-comment{color:#808080;font-style:italic;}
.php-hl-quotes{color:red;}
.php-hl-string{color:Red;}
.php-hl-identifier{color:green;}
.php-hl-builtin{color:Teal;}
.php-hl-reserved{color:black;font-weight:bold;}
.php-hl-inlinedoc{color:Blue;}
.php-hl-var{color:blue;}
.php-hl-url{color:Blue;}
.php-hl-special{color:Navy;}
.php-hl-number{color:Maroon;}
.php-hl-inlinetags{color:Blue;}
.php-hl-main{font-family:'Courier New',Courier,monospace;font-weight:normal;font-size:12px;}
ol.php-hl-main pre{margin:0;padding:0;}
.php-hl-gutter{background-color:#999999;color:White;}
.php-hl-table{font-family:courier;font-size:12px;border:solid 1px #505050;}
.xml-hl-default{color:Black;}
.xml-hl-code{color:Gray;}
.xml-hl-brackets{color:Olive;}
.xml-hl-comment{color:#808080;font-style:italic;}
.xml-hl-quotes{color:red;}
.xml-hl-string{color:Red;}
.xml-hl-identifier{color:Blue;}
.xml-hl-builtin{color:Teal;}
.xml-hl-reserved{color:Green;}
.xml-hl-inlinedoc{color:Blue;}
.xml-hl-var{color:#000020;}
.xml-hl-url{color:Blue;}
.xml-hl-special{color:Navy;}
.xml-hl-number{color:Maroon;}
.xml-hl-inlinetags{color:Blue;}
.xml-hl-main{font-family:'Courier New',Courier,monospace;font-weight:normal;}
.xml-hl-gutter{background-color:#999999;color:White;}
.xml-hl-table{font-family:courier;font-size:12px;border:solid 1px #505050;}
.html-hl-default{color:Black;}
.html-hl-code{color:Gray;}
.html-hl-brackets{color:Olive;}
.html-hl-comment{color:#808080;font-style:italic;}
.html-hl-quotes{color:red;}
.html-hl-string{color:Red;}
.html-hl-identifier{color:Blue;}
.html-hl-builtin{color:Teal;}
.html-hl-reserved{color:Green;}
.html-hl-inlinedoc{color:Blue;}
.html-hl-var{color:#000020;}
.html-hl-url{color:Blue;}
.html-hl-special{color:Navy;}
.html-hl-number{color:Maroon;}
.html-hl-inlinetags{color:Blue;}
.html-hl-main{font-family:'Courier New',Courier,monospace;font-weight:normal;}
.html-hl-gutter{background-color:#999999;color:White;}
.html-hl-table{font-family:courier;font-size:12px;border:solid 1px #505050;}
.css-hl-default{color:Black;}
.css-hl-code{color:Gray;}
.css-hl-brackets{color:Olive;}
.css-hl-comment{color:#808080;font-style:italic;}
.css-hl-quotes{color:red;}
.css-hl-string{color:Red;}
.css-hl-identifier{color:Blue;}
.css-hl-builtin{color:Teal;}
.css-hl-reserved{color:Green;}
.css-hl-inlinedoc{color:Blue;}
.css-hl-var{color:#000020;}
.css-hl-url{color:Blue;}
.css-hl-special{color:Navy;}
.css-hl-number{color:Maroon;}
.css-hl-inlinetags{color:Blue;}
.css-hl-main{font-family:'Courier New',Courier,monospace;font-weight:normal;}
.css-hl-gutter{background-color:#999999;color:White;}
.css-hl-table{font-family:courier;font-size:12px;border:solid 1px #505050;}
.javascript-hl-default{color:Black;}
.javascript-hl-code{color:Gray;}
.javascript-hl-brackets{color:Olive;}
.javascript-hl-comment{color:#808080;font-style:italic;}
.javascript-hl-quotes{color:red;}
.javascript-hl-string{color:Red;}
.javascript-hl-identifier{color:Blue;}
.javascript-hl-builtin{color:Teal;}
.javascript-hl-reserved{color:Green;}
.javascript-hl-inlinedoc{color:Blue;}
.javascript-hl-var{color:#000020;}
.javascript-hl-url{color:Blue;}
.javascript-hl-special{color:Navy;}
.javascript-hl-number{color:Maroon;}
.javascript-hl-inlinetags{color:Blue;}
.javascript-hl-main{font-family:'Courier New',Courier,monospace;font-weight:normal;}
.javascript-hl-gutter{background-color:#999999;color:White;}
.javascript-hl-table{font-family:courier;font-size:12px;border:solid 1px #505050;}
.sql-hl-default{color:Black;}
.sql-hl-code{color:Gray;}
.sql-hl-brackets{color:Olive;}
.sql-hl-comment{color:#808080;font-style:italic;}
.sql-hl-quotes{color:red;}
.sql-hl-string{color:Red;}
.sql-hl-identifier{color:Blue;}
.sql-hl-builtin{color:Teal;}
.sql-hl-reserved{color:Green;}
.sql-hl-inlinedoc{color:Blue;}
.sql-hl-var{color:#000020;}
.sql-hl-url{color:Blue;}
.sql-hl-special{color:Navy;}
.sql-hl-number{color:Maroon;}
.sql-hl-inlinetags{color:Blue;}
.sql-hl-main{font-family:'Courier New',Courier,monospace;font-weight:normal;}
.sql-hl-gutter{background-color:#999999;color:White;}
.sql-hl-table{font-family:courier;font-size:12px;border:solid 1px #505050;}
.source .copycode{text-align:right;float:right;}
.source .copycode a{cursor:pointer;color:blue;}
.source .copycode_hover a{color:red;}
body{padding-top:60px;padding-bottom:60px;}
h1,h2,h3,h4,h5,h6{margin-bottom:0.6em;}
p{font-size:14px;margin-bottom:1.6em;}
.hero-unit h1{margin-bottom:0.4em;}
.hero-unit p{margin-bottom:0;text-align:justify;}
.navbar .add-this{margin:6px 0 6px 10px;padding:6px 0;}
.subnav{border:1px solid #E5E5E5;font-size:12px;-webkit-border-radius:4px;-moz-border-radius:4px;border-radius:4px;width:100%;height:36px;background-color:#f2f2f2;background-image:-moz-linear-gradient(top, #f5f5f5, #eeeeee);background-image:-ms-linear-gradient(top, #f5f5f5, #eeeeee);background-image:-webkit-gradient(linear, 0 0, 0 100%, from(#f5f5f5), to(#eeeeee));background-image:-webkit-linear-gradient(top, #f5f5f5, #eeeeee);background-image:-o-linear-gradient(top, #f5f5f5, #eeeeee);background-image:linear-gradient(top, #f5f5f5, #eeeeee);background-repeat:repeat-x;filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#f5f5f5', endColorstr='#eeeeee', GradientType=0);}.subnav.subnav-fixed{border-color:#D5D5D5;border-width:1px 0 0;bottom:0;left:0;position:fixed;right:0;z-index:1030;-webkit-border-radius:0;-moz-border-radius:0;border-radius:0;-webkit-box-shadow:inset 0 1px 0 #ffffff;-moz-box-shadow:inset 0 1px 0 #ffffff;box-shadow:inset 0 1px 0 #ffffff;}
.subnav .nav{margin:0 auto;max-width:1170px;}.subnav .nav >li>a{margin:0;padding:11px;border-left:1px solid whiteSmoke;border-right:1px solid #E5E5E5;-webkit-border-radius:0;-moz-border-radius:0;border-radius:0;}
.subnav .nav >li:first-child>a{border-left:0;}
.subnav .nav >li:last-child>a{border-right:0;}
.subnav .nav >.active>a,.subnav .nav .action>a:hover{background-color:#E9E9E9;border-right-color:#DDD;color:#777;-webkit-box-shadow:inset 0 3px 5px rgba(0, 0, 0, 0.05);-moz-box-shadow:inset 0 3px 5px rgba(0, 0, 0, 0.05);box-shadow:inset 0 3px 5px rgba(0, 0, 0, 0.05);}
footer .powered{color:#888;margin-bottom:20px;}
footer .copy{color:#666;}
span.required{color:#F00;}
.popover h3.popover-title{margin-bottom:0;}
section{padding-top:40px;}section a.top{display:block;text-align:right;}
#bootNavbar .navbar-inner>.container{width:auto;}
#bootMenu .menuCol{min-height:140px;}
#bootTabbable .tabbable{margin-bottom:20px;}#bootTabbable .tabbable.tabbable-placed{width:340px;}
#bootThumbnails .list-view{padding-top:30px;}
#bootActiveForm .form-vertical .control-group>label{font-weight:bold;}
#bootHero .hero-unit{width:650px;}#bootHero .hero-unit h1{margin-bottom:0;}
#bootHero .hero-unit p{margin-bottom:9px;}#bootHero .hero-unit p:last-child{margin-bottom:0;}
#bootCarousel .carousel{width:770px;}#bootCarousel .carousel .carousel-caption p{margin-bottom:9px;}
#bootTypeahead input{margin-bottom:0;}
.hl-code{margin-bottom:20px;}.hl-code pre{background:#FCFCFC;border-color:#EEE transparent #EEE;font-family:"Menlo","Consolas","Courier New",Courier,mono;-webkit-border-radius:0;-moz-border-radius:0;border-radius:0;}
.maintenance .hero-unit{text-align:center;}.maintenance .hero-unit p{text-align:inherit;}
@media (max-width: 980px){body{padding-top:0px;}}
// IMPORTS
@import "../../lib/bootstrap/less/mixins.less";
@import "../css/highlight.css";
@import "highlight.less";
// VARIABLES
......
......@@ -6,8 +6,12 @@
* @license http://www.opensource.org/licenses/bsd-license.php New BSD License
*/
Yii::setPathOfAlias('Less', realpath(dirname(__FILE__).'/../lib/lessphp/lib/Less'));
Yii::setPathOfAlias('Less', dirname(__FILE__).'/../lib/lessphp/lib/Less');
/**
* Less compiler application component.
* Preload the component to enable auto compiling.
*/
class LessCompiler extends CApplicationComponent
{
/**
......@@ -19,9 +23,9 @@ class LessCompiler extends CApplicationComponent
*/
public $paths = array();
/**
* @var boolean whether to auto compile
* @var boolean indicates whether to force compiling.
*/
public $autoCompile = false;
public $forceCompile = false;
/**
* @var boolean compiler debug mode.
*/
......@@ -30,29 +34,26 @@ class LessCompiler extends CApplicationComponent
* @var boolean whether to compress css or not.
*/
public $compress = false;
/**
* @var \Less\Parser the less parser.
*/
protected $_parser;
/**
* Initializes the component.
* @throws CException if the base path does not exist
*/
public function init()
{
if (!isset($this->basePath))
if ($this->basePath === null)
$this->basePath = Yii::getPathOfAlias('webroot');
if (!file_exists($this->basePath))
throw new CException(__CLASS__.': Failed to initialize compiler. Base path does not exist!');
throw new CException(__CLASS__.': Failed to initialize compiler. Base path does not exist.');
$env = new \Less\Environment();
$env->compress = $this->compress;
$env->debug = $this->debug;
$env->setDebug($this->debug);
$env->setCompress($this->compress);
$this->_parser = new \Less\Parser($env);
if ($this->autoCompile/* && $this->hasChanges()*/)
if ($this->forceCompile || $this->hasChanges())
$this->compile();
}
......@@ -70,17 +71,16 @@ class LessCompiler extends CApplicationComponent
if (file_exists($fromPath))
file_put_contents($toPath, $this->parse($fromPath));
else
throw new CException(__CLASS__.': Failed to compile less file. Source path does not exist!');
throw new CException(__CLASS__.': Failed to compile less file. Source path does not exist.');
$this->_parser->clearCss();
}
}
/**
* Parses the less code to css.
* Parses the less code to CSS.
* @param string $filename the file path to the less file
* @return string the css
* @throws CException
* @return string the CSS
*/
public function parse($filename)
{
......@@ -90,7 +90,7 @@ class LessCompiler extends CApplicationComponent
}
catch (\Less\Exception\ParserException $e)
{
throw new CException(__CLASS__.': Failed to compile less file with message: "'.$e->getMessage().'".');
throw new CException(__CLASS__.': Failed to parse less file. "'.$e->getMessage().'".');
}
return $css;
......@@ -100,16 +100,18 @@ class LessCompiler extends CApplicationComponent
* Returns whether any of files configured to be compiled has changed.
* @return boolean the result
*/
public function hasChanges()
protected function hasChanges()
{
$dirs = array();
foreach ($this->paths as $source => $destination)
{
$destination = realpath($destination);
$compiled = $this->getLastModified($destination);
if (!isset($lastCompiled) || $compiled < $lastCompiled )
$lastCompiled = $compiled;
if (!in_array(dirname($source), $dirs))
$source = realpath($source);
if (!in_array($source, $dirs))
$dirs[] = $source;
}
......@@ -142,20 +144,19 @@ class LessCompiler extends CApplicationComponent
{
$lastModified = null;
/** @var Directory $dir */
$dir = dir($path);
while ($entry = $dir->read())
{
if (strpos($entry, '.') === 0)
continue;
$path .= '/'.$entry;
$entry = $path.'/'.$entry;
if( is_dir($path) )
$modified = $this->getLastModified($path);
if( is_dir($entry) )
$modified = $this->getLastModified($entry);
else
{
$stat = stat($path);
$stat = stat($entry);
$modified = $stat['mtime'];
}
......
......@@ -305,7 +305,7 @@ class Parser {
if ($this->peek('/', 1)) {
return new \Less\Node\Comment($this->match('/^\/\/.*/'), true);
} else {
if ($comment = $this->match('/^\\/\*(?:[^*]|\*+[^\\/*])*\*+\\/\n?/')) {
if ($comment = $this->match('/\/\*.*?\*\//s')) {
return new \Less\Node\Comment($comment, false);
}
}
......
......@@ -86,19 +86,18 @@
<div class="container">
<?php $this->widget('bootstrap.widgets.BootHero', array(
<?php $this->beginWidget('bootstrap.widgets.BootHero', array(
'heading'=>Yii::app()->name,
'content'=>"
<p>
Bringing together the ".CHtml::link('Yii PHP framework', 'http://www.yiiframework.com')." and
".CHtml::link('Bootstrap', 'http://twitter.github.com/bootstrap/').", Twitter's new web development toolkit.
Now with support for Bootstrap 2!
".CHtml::link('Yii-Bootstrap', 'http://www.yiiframework.com/extension/bootstrap/')."
is an extension for Yii that provides a wide range of server-side widgets that allow you to easily use Bootstrap with Yii.
All widgets have been developed following Yii's conventions and work seemlessly together with Bootstrap and its jQuery plugins.
</p>
",
)); ?>
<p>
Bringing together the <?php echo CHtml::link('Yii PHP framework', 'http://www.yiiframework.com'); ?> and
<?php echo CHtml::link('Bootstrap', 'http://twitter.github.com/bootstrap/'); ?> Twitter's new web development toolkit.
Now with support for Bootstrap 2!
<?php echo CHtml::link('Yii-Bootstrap', 'http://www.yiiframework.com/extension/bootstrap/'); ?>
is an extension for Yii that provides a wide range of server-side widgets that allow you to easily use Bootstrap with Yii.
All widgets have been developed following Yii's conventions and work seamlessly together with Bootstrap and its jQuery plugins.
</p>
<?php $this->endWidget(); ?>
<?php if (!empty($this->breadcrumbs)):?>
<?php $this->widget('bootstrap.widgets.BootBreadcrumbs', array(
......
......@@ -1190,13 +1190,12 @@ $('#buttonStateful').click(function() {
<h2>Hero unit <small>Coming in version 0.9.10</small></h2>
<?php $this->widget('bootstrap.widgets.BootHero', array(
<?php $this->beginWidget('bootstrap.widgets.BootHero', array(
'heading'=>'Hello, world!',
'content'=>"
<p>This is a simple hero unit, a simple jumbotron-style component for calling extra attention to featured content or information.</p>
<p><a class=\"btn btn-primary btn-large\">Learn more</a></p>
",
)); ?>
<p>This is a simple hero unit, a simple jumbotron-style component for calling extra attention to featured content or information.</p>
<p><a class="btn btn-primary btn-large">Learn more</a></p>
<?php $this->endWidget(); ?>
<h4>Source code</h4>
......@@ -1204,11 +1203,16 @@ $('#buttonStateful').click(function() {
[php]
<?php \$this->widget('bootstrap.widgets.BootHero', array(
'heading'=>'Hello, world!',
'content'=>\"
<p>This is a simple hero unit, a simple jumbotron-style component for calling extra attention to featured content or information.</p>
<p><a class=\"btn btn-primary btn-large\">Learn more</a></p>
\",
)); ?>
~~~
~~~
[html]
<p>This is a simple hero unit, a simple jumbotron-style component for calling extra attention to featured content or information.</p>
<p><a class=\"btn btn-primary btn-large\">Learn more</a></p>
~~~
~~~
[php]
<?php \$this->endWidget(); ?>
~~~"); ?>
<a class="top" href="#top">Back to top &uarr;</a>
......
......@@ -12,6 +12,7 @@ Yii::import('bootstrap.widgets.BootWidget');
/**
* Modest bootstrap hero widget.
* Thanks to Christphe Boulain for suggesting content capturing.
*/
class BootHero extends BootWidget
{
......@@ -20,10 +21,6 @@ class BootHero extends BootWidget
*/
public $heading;
/**
* @var string the content text.
*/
public $content;
/**
* @var boolean indicates whether to encode the heading.
*/
public $encodeHeading = true;
......@@ -41,6 +38,9 @@ class BootHero extends BootWidget
if ($this->encodeHeading)
$this->heading = CHtml::encode($this->heading);
ob_start();
ob_implicit_flush(false);
}
/**
......@@ -48,9 +48,13 @@ class BootHero extends BootWidget
*/
public function run()
{
$content = ob_get_clean();
echo CHtml::openTag('div', $this->htmlOptions);
echo CHtml::tag('h1', array(), $this->heading);
echo $this->content;
if (isset($this->heading))
echo CHtml::tag('h1', array(), $this->heading);
echo $content;
echo '</div>';
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment