Category Archives: SharePoint

SharePoint + Twitter Bootstrap = Less Hack

Developing for SharePoint 2010 is unhealthy. You cannot use last .NET features, you cannot use last JavaScript stuff and at the end you cannot use last CSS goodies. Of course, I want all this stuff. This post is about small hack that will give you Bootstrap styles in your SharePoint pages.

What the problem?

Well, if you just reference Bootstrap it will conflict with SharePoint styles. Results are quite ugly.

Solution

Solution that looks best for me is just to use less to add “namespace” to CSS files.

  1. Get Less support for Visual Studio – Web Essentials.
  2. Create less file in your Layouts folder
  3. Add something like this
  4. .my {
      
      // Put content of Twitter Bootstrap  files you need
      // For example I added this
      // https://github.com/twbs/bootstrap/blob/master/less/variables.less
      // https://github.com/twbs/bootstrap/blob/master/less/tables.less
    }
    

2. Wrap part of the page you need with div with class my:

<div class="my">
    <!-- your html -->
</div>

 

Enjoy.

Tagged

SharePoint + TypeScript = Love

Few months ago I became SherePoint developer, and this is like developing in damn stone age. No async, no SignalR, no .. , actually there almost nothing from last years. Mad. If you need something post 2008, you are out of lack. But this is like 8-bit game. You know this feeling of playing games on ZX-Spectrum? So let’s play.

  • Obviously, you need install TypeScript. It will ask restart everything, I also restarted few servers, just in case.
  • Create new TS file (for example in Layouts folder), you need to use Add New Item dialog, because otherwise VisualStudio will not assign (and will not allow you)  TypeScriptCompile to Build Action property of the file. image
  • Try to compile. File.js under File.ts should be JavaScript compiled from TypeScript. For me it does not work however. Fix is here.  You just need to add BeforeBuild target to call compiler. Make sure that path to compiler is correct.
  • Try compile another time. This time it should work.
  • After I got this working, level of impression raised exponentially. Writing JavaScriptTypeScript became much more pleasant.

    Some missing points:

    1. Somehow I need remove TS files from result WSP file.
    2. I need better way to manage TypeScript definition files in solution, but this is general problem of how integrate NuGet content packages to SharePoint project.

    Overall impression is 4.5 from 5