Welcome Guest! To enable all features please Login or Register.

Notification

Icon
Error

Bundler for CSS and DotLess
Pickels
#1 Posted : Sunday, March 21, 2010 3:26:54 AM(UTC)
Rank: Advanced Member
Groups: Registered

Joined: 9/8/2009(UTC)
Posts: 91
Location: Belgium
Found this library a couple of days ago and thought it would be really great for bigger projects. Maybe in the future kooboo can integrate DotLess functionality also.

The library I am talking about is http://github.com/jetheredge/bundler. It looks very simular to what Kooboo does with JS and CSS files. The only difference is that it supports DotLess.

For those that don't know DotLess or Less I'll try and give a short explanation. DotLess is a port from the ruby library Less for asp.net. The biggest advantage to me is that you can write nested styles. This means you don't have to repeat yourself and for me it's alot more readable. It also has some other advantages over CSS but you can read that on their website.

Regular CSS:
Code:

#Content
{
color: blue;
}

#Content a
{
background-color: orange;
}


With DotLess you can write it like this:
Code:

#Content
{
color: blue;
a
{
background-color: orange;
}
}


You can also use the DotLess library directly in Kooboo ofcourse but I didn't want to change to much of the default kooboo code.

To use bundler get the library from github. Then you have to add the Bundler.Framework.dll to your kooboo bin folder. You only need that dll all the other dlls that go with the Bundler framework are already included in Kooboo.

After you did this you have a few options to use Bundler. The way I did it is to make a "Less" folder inside "theme/default". I then used the bundler framework to render that file to my "theme" folder.

To do this my LayoutTemplate looks something like this:
Code:

<head runat="server">
<title runat="server"></title>
</head>
<body>
<% Bundle.Css()
.Add("/Template/ApplicationName/BinaryResource/theme/default/less/main.less")
.Render("/Template/ApplicationName/BinaryResource/theme/default/Main.css");%>
</body>


Because I use <% and not <%= the string doesn't get written to the output but the file gets render. Kooboo will see the file in the theme folder and add it to the head of your page. This way the css files get minified twice though but I don't think it's a big problem.

Hope this helps for people wanting to use DotLess with Kooboo.
zguoqi
#2 Posted : Sunday, March 21, 2010 3:15:10 PM(UTC)
Rank: Administration
Groups: Registered, Administrators

Joined: 9/2/2009(UTC)
Posts: 695
Location: xiamen
Pickels,

Thanks a lot for the tip. Great for some users.
Regards,

Vincent

Kooboo Team
Pickels
#3 Posted : Monday, March 22, 2010 9:26:51 PM(UTC)
Rank: Advanced Member
Groups: Registered

Joined: 9/8/2009(UTC)
Posts: 91
Location: Belgium
Since I had some problems with Bundler I decided to add DotLess to Kooboo. Normally you can use DotLess with a HttpHandler or T4 templates. But if I am correct then custom HttpHandlers mostly don't work on shared hostings? The T4 template solution is very annoying since you need to click "run custom tool" or build the solution each time you make an adjustment.

I aint a super coder so my code might not be the best.

LessConverter.cs
TemplateFileManager.cs
ScriptController.cs
CmsViewPage.cs


The first file is a new one and is based on the CssMinify.cs file. All the other files are already in kooboo and are adjusted. I marked my adjustments with "#region Pickels" so you can see what I changed.

CSSRules.txt don't work with less I might add that later. I always found the CSSRules a little confusing but now I understand them but I'll make an other post about that soon.

I didn't add any code for modules either I will most likely do this later.

While writing this I noticed that there was a custom HttpHandler in the web.config of my Everst.Cms. So now I aint sure anymore that custom HttpHandlers mostly don't work in shared hostings. Can anybody confirm if this is true or not? I tried the DotLessHttpHandler before on a shared hosting and it didn't work but maybe I did something wrong.
Guillaume
#4 Posted : Wednesday, December 28, 2011 5:53:36 PM(UTC)
Rank: Member
Groups: Registered

Joined: 5/24/2011(UTC)
Posts: 16
I'm also interested in LESS css (and coffeescript) support in Kooboo, would be nice to implement these as plugins. Anyone already looked into that?
I would consider contributing if there's a project started somewhere :)

Guillaume
Users browsing this topic
Guest
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.

Powered by YAF 1.9.5.5 | YAF © 2003-2011, Yet Another Forum.NET
This page was generated in 0.105 seconds.