Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
Y
Yii Bootstrap 3
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Common
Yii Bootstrap 3
Commits
0e319dd8
Commit
0e319dd8
authored
Mar 08, 2012
by
Crisu83
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added support for hero content capturing (thanks Christophe Boulain) and updated the less compiler
parent
5e3fec4d
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
56 additions
and
48 deletions
+56
-48
styles.css
demo/css/styles.css
+0
-0
highlight.less
demo/less/highlight.less
+0
-0
styles.less
demo/less/styles.less
+1
-1
LessCompiler.php
demo/protected/extensions/less/components/LessCompiler.php
+25
-24
Parser.php
...protected/extensions/less/lib/lessphp/lib/Less/Parser.php
+1
-1
main.php
demo/protected/views/layouts/main.php
+7
-8
index.php
demo/protected/views/site/index.php
+13
-9
BootHero.php
widgets/BootHero.php
+9
-5
No files found.
demo/css/styles.css
View file @
0e319dd8
This diff is collapsed.
Click to expand it.
demo/
css/highlight.c
ss
→
demo/
less/highlight.le
ss
View file @
0e319dd8
File moved
demo/less/styles.less
View file @
0e319dd8
// IMPORTS
@import "../../lib/bootstrap/less/mixins.less";
@import "
../css/highlight.c
ss";
@import "
highlight.le
ss";
// VARIABLES
...
...
demo/protected/extensions/less/components/LessCompiler.php
View file @
0e319dd8
...
...
@@ -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
$
auto
Compile
=
false
;
public
$
force
Compile
=
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
*/
p
ublic
function
hasChanges
()
p
rotected
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'
];
}
...
...
demo/protected/extensions/less/lib/lessphp/lib/Less/Parser.php
View file @
0e319dd8
...
...
@@ -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
);
}
}
...
...
demo/protected/views/layouts/main.php
View file @
0e319dd8
...
...
@@ -86,19 +86,18 @@
<div
class=
"container"
>
<?php
$this
->
w
idget
(
'bootstrap.widgets.BootHero'
,
array
(
<?php
$this
->
beginW
idget
(
'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.
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!
"
.
CHtml
::
link
(
'Yii-Bootstrap'
,
'http://www.yiiframework.com/extension/bootstrap/'
)
.
"
<?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 see
mlessly together with Bootstrap and its jQuery plugins.
All widgets have been developed following Yii's conventions and work sea
mlessly together with Bootstrap and its jQuery plugins.
</p>
"
,
));
?>
<?php
$this
->
endWidget
();
?>
<?php
if
(
!
empty
(
$this
->
breadcrumbs
))
:?>
<?
php
$this
->
widget
(
'bootstrap.widgets.BootBreadcrumbs'
,
array
(
...
...
demo/protected/views/site/index.php
View file @
0e319dd8
...
...
@@ -1190,13 +1190,12 @@ $('#buttonStateful').click(function() {
<h2>
Hero unit
<small>
Coming in version 0.9.10
</small></h2>
<?php
$this
->
w
idget
(
'bootstrap.widgets.BootHero'
,
array
(
<?php
$this
->
beginW
idget
(
'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
↑
</a>
...
...
widgets/BootHero.php
View file @
0e319dd8
...
...
@@ -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
);
if
(
isset
(
$this
->
heading
))
echo
CHtml
::
tag
(
'h1'
,
array
(),
$this
->
heading
);
echo
$this
->
content
;
echo
$content
;
echo
'</div>'
;
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment