ShareCoffee is available

ShareCoffee is available

I’ve published ShareCoffee today on github. ShareCoffee is a small library containing cool stuff for SharePoint App developers. ShareCoffee is entirely written in CoffeeScript using TDD approach with (Mocha, ChaiJS and SinonJS). Since the SharePoint App model is available I thought about writing this library, but within the last four days I’ve sit down and created it! :)

ShareCoffee is offering all the stuff I was faced with since I started App development for SharePoint. The goal was for me to create a library which provides a single programming interface for any type of SharePoint App. What is ShareCoffee offering ShareCoffee is offering various functionality which I’ve grouped into the following namespaces

  • ShareCoffee.Commons
  • ShareCoffee.UI
  • ShareCoffee.REST
  • ShareCoffee.CSOM
  • ShareCoffee.CrossDomain

In this post I'm explaining how to install ShareCoffee in your project and the functionality offered by ShareCoffee.Commons and ShareCoffee.UI

Wiki and Samples on github

There are also a bunch of samples on github in a dedicated repository  And the entire API is documented within the WIKI on github

Installing ShareCoffee

You can install ShareCoffee by copying the JavaScript library from the repository to your project, which will work but it's quiet dirty. It's a better approach to install ShareCoffee from nuget or bower using the following commands

Install-Package ShareCoffee  
bower install ShareCoffe  

After the sources have been included in your project, you just have to add a script reference to your SharePoint App WebSite and you're ready to go. When writing JavaScripts you can enable basic IntelliSense using the reference syntax in VisualStudio by adding the following line to your JS file

/// <reference path="sharecoffee/sharecoffee.js" />

The commons are everyday helpers such as

  • ShareCoffee.Commons.getQueryString()
  • ShareCoffee.Commons.getQueryStringParameter(parameterName)
  • ShareCoffee.Commons.getFormDigest()
  • ShareCoffee.Commons.getAppWebUrl()
  • ShareCoffee.Commons.getHostWebUrl()
  • ShareCoffee.Commons.getApiRootUrl()

Most of the methods should be self-explaining, but getAppWebUrl() and getHostWebUrl() offer some great functionality. For both methods you can define custom load methods, which will be invoked to load this data from your custom storage (Database, Cookie,…) getAppWebUrl looks for _spPageContextInfo, if _spPageContextInfo is not present, it checks the URL fro the SPAppWebUrl parameter. For both methods, the custom load functions have highest priority, which means that if you pass a custom load function, getAppWebUrl and getHostWebUrl will only call these. You can set the custom load function for getAppWebUrl as shown here


ShareCoffee.UI is offering various functions for interacting with SharePoint’s UI. The most powerful method is of course ShareCoffee.UI.loadAppChrome(chromeSettings); which does the entire SharePoint-App-Chome loading stuff for you! The following Sample shows how loadAppChrome is configured.

Other methods in ShareCoffee.UI

  • ShareCoffee.UI.showNotification()
  • ShareCoffee.UI.removeNotification()
  • ShareCoffee.UI.showStatus()
  • ShareCoffee.UI.setStatusColor()
  • ShareCoffee.UI.removeStatus()
  • ShareCoffee.UI.removeAllStatus()

See notification samples here

And status samples here

What's next

Within the next post on ShareCoffee I'll explain how to work with the ShareCoffe.REST namespace!

Happy Scripting'    


comments powered by Disqus