Category Archives: SharePoint 2013

App for SharePoint project​

Jasmine with Visual Studio and SharePoint Apps – Part 1

This blog does no​t describe how to perform JavaScript ​TDD (test-driven development) or BDD (behaviour-driven development). It does however describe how to set-​​up Visual Studio and configure an App for SharePoint project to get you started.

1. Install VS Extensions

Open Visual Studio 2013 > TOOLS > Extensions and Updates…

Within the Left panel, click on Online and search for Chutzpah Test

Download:

  • Chutzpah Test Adaptor for the Test Explorer
  • Chutzpah Test Runner Context Menu Extension

And then restart Visual Studio

2. Configure Test Explorer

Open Visual Studio 2013 > TEST > Windows > Test Explorer and pin the window to suite your preference…

Top left of the Test Explorer window, click on the button  “Run Test After Build” Run Test After Build

Create a new App for SharePoint Project​

Now that we have Visual Studio configured and ready to go, we need an App for SharePoint project to work with.

Create a new App for SharePoint project​

App for SharePoint project​

Choose where to debug the App and the type: Provider-hosted

Choose where to debug the App and the type

The type for project to create: ASP.NET MVC Web Application

ASP.NET MVC Web Application

And finally the authentication model: Windows Azure Access Services

Windows Azure Access Services

And finally You will then be prompted to sign into the portal your specified earlier.​

Adding Jasmine JS to a Project​

Now that we have an App for SharePoint project lets add Jasmine.

1. Install NuGet Package

Open Visual Studio 2013 > TOOLS > NuGet Package Manager > Manage NuGet Packages for Solution…

Within the Left panel, click on Online and search for SharePoint Jasmine Test Runner and click download.​

Search for SharePoint Jasmine Test Runner and click download

Note: the SharePoint Jasmine Test Runner package was created by Thorston Hans and at the time of writing this blog it was at version 0.0.1 and contained Jasmine 2.0. My reason for choosing SharePoint Jasmine Test Runner over Jasmine Test Adapter was because it did not include the VMC files which are not required if you plan to testing your code directly in Visual Studio.​

2. Configure Files/Package

Navigate to the Scripts folder for each of projects you added the package too and you will notice a folder containing JS files called  jasmine-samples. You do not need this scripts or this folder, so select the it and right click to see the context menu and then click either Delete or “Exclude from Project“.

3. Other Files

The Content folder contains a new folder called jasmine containing a single CSS file, don’t need to do anything with this.​

4. How to use Jasmine

After adding the SharePoint Jasmine Test Runner package, start by adding a “spec” file to your scripts folder. Spec files are where you will  describe your application and are the basis of your tests. After writing each test, you will immediately write the code (e.g. a function) within your “source” file fore fill the spec and therefore cause the test to pass. You repeat this process over and over again until you have written one or possible more spec that describes your JavaScript Application. Once all the tests pass have successfully passed then your development is finished (in theory).

5. Naming Convention

Depending on the size and complexity of your project, you many have one or more spec and source files. I would recommend pairing up the files so that a spec file always as a source file and vice versa.

For example:

  • filename_spec.js              contains the specs used to test the code.
  • filename.js                         contains the source code used by the application

4. What to look out for

  • Keep your spec and source files paired up and within the same folder.
  • If you are seeing duplicated tests then make sure that spec files are not being referenced. For example check the _references.js file and remove any reference:
    /// <reference path="_tests/filename_spec.js" />
  • Visual Studio add automatically adds references to the _references.js file every time a new JS file is added to the Scripts folder. You will need to open the _references.js file​ and remove spec file​ references each time a new JS file is added.
  • If your test continue to fail even when they look correct, make sure that your spec file has a reference to its related source file:​
    /// <reference path="filename.js" />
  • To enable your test to run every time you save a file, click on the button “Run Test After Build” located at the top left of the Test Explorer window.

Jasmine with Visual Studio and  SharePoint Apps​ – Part: 123

Useful links
Video Tutorials

Useful UI Branding tools for SharePoint 2013

Just thinking about branding my website and came across a tool by Microsoft called Color Palette Tool SharePoint 2013 which downloaded from http://social.technet.microsoft.com/wiki/contents/articles/16806.color-palette-tool-sharepoint-2013.aspx

And if you require inspiration for your theme one of colleges (Matthew Holden) pointed me in the direction Adobe Kuler https://kuler.adobe.com/create/color-wheel/

 

Disable mobile auto-redirect for SharePoint anonymous access website

The quickest way for all mobile devices and browsers add the following to the web applications web.config file:

However for a more granular approach, edit the App_Browsers\compat.browser changing the following to “false” for the relevant userAgent:

SharePoint: Enable Publishing features

To use the Web content management features, you need to turn on the Publishing feature on a site or site collection. You can then brand the site so that it has your corporate look and feel, and enable users to edit the corporate site within the context of the Web. Once the Publishing functionality has been turned on, you can also create a multilingual site by creating a source site and then translating the site into other languages, which can be publish as separate sites.​

Enable the SharePoint Server Publishing Infrastructure feature for a site collection

Use the following procedure to enable the SharePoint Server

Publishing Infrastructure feature at the site collection level.

  1. To enable the SharePoint Server Publishing Infrastructure feature for a site collection:
  2. On the Site Actions menu, point to Site Settings, and then click Modify All Site Settings.
  3. Note: If you do not see additional items when you point to Site Settings, click Site Settings.
  4. If you are not at the root of your site, under Site Collection Administration, click Go to top level site settings.
  5. On the Site Settings page, under Site Collection Administration, click Site collection features.
  6. On the Site Collection Features page, next to Office SharePoint Server Publishing Infrastructure, click Activate.

Enable the SharePoint Server Publishing feature for a site

Use the following procedure to enable the SharePoint Server Publishing feature for a site.

To enable the SharePoint Server Publishing feature for a site

  1. On the Site Actions menu, point to Site Settings, and then click Modify All Site Settings.
    Note:  If you do not see additional items when you point to Site Settings, click Site Settings.
  2. On the Site Settings page, in the Site Administration section, click Site features.
  3. Next to Office SharePoint Server Publishing, click Activate.

The source of this information is located here: http://office.microsoft.com/en-gb/sharepoint-server-help/enable-publishing-features-HA010157772.aspx

 

Definition of a SharePoint Feature

Represents a modular server-side, file system-level customization that contains items that can be installed and activated in a SharePoint environment within one of the following scopes:

  • Farm                       (Exclusing SharePoint Online)
  • WebApplication   (Exclusing SharePoint Online)
  • Site
  • Web

SharePoint: How to Update a Site Collection Date Format

A step-by-step guide on how set to a Site Collection’s Date Format

  1. Navigate to the root site* within your site collection and then follow these steps:
    Click on [Site Actions] –> [Site Settings], the Site Settings page will load.
  2. Under the Site Administration section of the Site Settings page click on Regional Settings link, this will load the Regional Settings page.
  3. Click on the Local drop down list and select the required language setting, e.g. English (United Kingdom). The page will reload to reflect your selection.
  4. Next, if your site collection contains sub-sites then, check the checkbox to have all sub-sites inherit these Regional Settings.
  5. And finally, click on the [OK] button.

*It is possible to update sub-sites; however updating the root (parent) site collection gives the opportunity to update all its sub-sites at the same time.

Tip: When the Site Settings page loads, if you see the Go to top level site settings link under the Site Collection Administration section then you can click on the link to navigate to the root site collection’s Site Settings page.​