CHUVASH.eu

CHunky Universe of Vigouros Astonishing SHarepoint :)

Provisioning Google Maps JSLink with SPMeta2

kartta-000

Among PnP Samples there is a solution for using Google Maps. Great solution where where you can pick a point on a map and define a spacial area on the map. Unfortunately it is a sandbox solution. I rewrote it to a code based template with SPMeta2 Framework. Now it can be installed on any site very easily, without needing UserCode Service and a cumbersome process of uploading a wsp package and activating it. The code is very simple, you can see it on github.

kartta-001

Let’s take a look at it. It does not contain a single line of SharePoint Legacy XML. There are following SharePoint artefacts that are getting provisioned:

  1. Two site columns (Location Point and Location Area)
  2. A SharePoint List (Locations) with two additional fields mentioned above
  3. Google Maps code in and CSR in a jslink file
  4. Auxiliary pages for selecting points and areas on the map.

Field Definitions

In SPMeta2 everything is separated in meaningful definitions. First we define our fields. The preferred place in the VS solution is Definitions – IA – Fields.

kartta-002

List Definitions

Then we define our List – Locations. That is also a SPMeta2 Definition. List Definitions reside in Definitions – IA – Lists. We do not add fields in our list definition. The fields are added while “assembling” the model.

kartta-003

ListView Definitions

ListView Definitions are also in the Definitions – IA folder. We inherit from the OOB AllItems view:

kartta-004

Modules (a.k.a. Files)

Resource files like javascript, css, aspx, html and so on are Modules. They are in the “Modules – Implicit” folder. The internal structure is copied to the web folder. The upload of files is easy and is defined in the web model, see next section.

Web Model

Now it is time to pick the definitions and create a model. The most common model is a Web Model. The model is created programmatically and relies on “Add” methods: AddField, AddList and so on:

kartta-005

Provisioning

The actual provisioning is the most fun, it is easy and straight forward, it takes models and deploys it to a SharePoint site. You can easily switch between SSOM and CSOM.

kartta-006

Distribution

Another bonus of SPMeta2 Provisioning Framework is the ability to serialize and deserialize models to XML or JSON. In our project we define SharePoint Applications as SPMeta2 models serialized in XML and make them available for installation on any SharePoint Site.  A SharePoint Application is a meaningful collection of SharePoint artefacts that becomes an entity and solves a business need.

Summary

This Maps solution is a simple solution, but it is a very powerful one, originally created by the PnP team. If we just redesign the Provisioning Part, it becomes awesome. SPMeta2 provides a solid, well defined, easy-to-understand framework for define code-first models for SharePoint Applications.

Setting up Raspberry Pi2 for a Dashboard Monitor

I have set up Raspberry Pi as a Dashboard Monitor a couple of times. Here I want to summarize my steps. In fact, it is nothing special, a raspberry pi that is used as a browser showing a web based dashboard in full screen, but there are some important configuration steps needed to make it as good as possible.

Install Raspbian

Raspbian is the best operating system for Raspberry Pi. Just stick with that.

Expand file storage

When you boot up Raspberry Pi, the first thing you should do is to expand the file storage, otherwise it is hard to install anything. To do so, run raspi-config from command line and restart your raspberry pi after that.

dashboard-rasp-002

Rename your raspberry

You are advised to change the password. In my case I usually just want to keep the default password: “raspberry”. What I want is to change the hostname from raspberrypi to some unique hostname (in my example it will be “kallerasp”), so that I can access it from my network without running risk for name conflicts. To rename your raspberry, update the /etc/hostname file:

sudo vim /etc/hostname

After that restart your computer.

Install iceweasel

Iceweasel is a Firefox fork, which works just fine on the raspberry pi. Update your raspberry pi and install it:

sudo apt-get update
sudo apt-get upgrade -y
sudo apt-get install -y iceweasel

Make sure the screen is not getting blank

To use your raspberry pi as a dashboard monitor we need to prevent the screen from getting blank (dark).

cd /etc/lightdm
sudo cp lightdm.conf lightdm.conf.bak
sudo vim lightdm.conf

Update it so you have the following:

[SetDefaults]
xserver-command=X -s 0 -dpms

dashboard-rasp-001

Start dashboard page on startup

To automatically start iceweasel on startup, we need to configure autostart. To do so, run this from terminal:

cd ~/.config
mkdir autostart
cd autostart
vim .desktop

In the .desktop file write following:

[Desktop Entry]
Type=Application
Exec=iceweasel

Previously I had chromium-browser –kiosk http://someurl, but Chromiums is no longer available, and iceweasel does not have –kiosk parameter. On the other hand, you have to activate Full Screen the first time, then after OS restart iceweasel automatically will activate Full Screen and your dashboard page from the previous session.

Chuvash Keyboard Layout for Mac

I’ve got a Mac and one of my first questions was: How can I write in Chuvash on my Mac, obviously :) In this post I am going to tell how I created Chuvash Keyboard Layout. The solution and installation instructions are on Github:

Chuvash Keyboard Layout for Mac

cv-kbd-mac-000

What the heck is Chuvash?

For those who don’t know yet: Chuvash are people who live in Chuvash Republic in Russian Federation, and abroad, as me. We are 1.5 million. Chuvash is also a language, an official language of the Republic, a minority language, that is completely different from the second official language Russian. Chuvash uses Cyrillic letters, all 33 Russian letters plus 4 additional letters: A breve (Ӑ), E breve (Ӗ), C cedilla (Ҫ) and U with double acute (Ӳ).

Keyboard Layout

There is no official Chuvash keyboard layout. What we have is a de facto standard – a very humble layout. It is “humble” because it does not dare to put Chuvash letters on the buttons directly, they are accessible through modifiers: AltGr in Windows and Linux, Option on a Mac. To get A breve you press AltGr and A in the same time. That is not a good input method for Chuvash where additional letters with diacritics (breve, double acute and cedilla) are more common than some Russian letters. In fact, many Russian letters are just part of the Chuvash alphabet because the loan words are just imported in the original spelling.

The reason why this humble keyboard layout was introduced and became a de facto standard was a will to provide a fully functional Russian keyboard layout with a bonus – being able to write in Chuvash, although a hard way. It is hard to write, but it is very simple to have (you don’t need to switch input sources), it is easy to explain: want a diacritic, just press AltGr and the corresponding plain letter. I created the same layout for Mac, too. In future a better, more Chuvash, keyboard layout must be designed and agreed upon.

Keyboard Layouts on Mac

AFAIK, there is no keyboard layout (“input source”) for any minority language in Russia. On the other hand the process of creating and installing a custom keyboard layout is easiest on a Mac. I followed the steps described on Salvatore Testa’s blog: I installed Ukulele and created a new keyboard layout based on Russian PC. That bundle that is saved from Ukulele needs to be copied to ~/Library/Keyboard Layouts/ folder. Then (presumably after a computer restart), Chuvash can be added as an input source. Custom keyboard layouts are just files (bundles) in a user’s home folder. No need for Administrator rights (as in Windows for installing a custom keyboard layout as an exe file), no sudo access to X11 folder (as in Linux).

What I would like to wish is the presence of Chuvash and other minority languages’ keyboard layouts directly Out-of-the-Box on Mac OS, iOS, Android and Windows. Linux is the only OS family that natively supports Chuvash keyboard layout.

Other minority languages

I am just curious: what languages have already had custom keyboard layouts ready for install. I found those ones:

Some words in Chuvash and Russian

I want this text to be searchable and findable, so here come summary of this blog post in Chuvash and Russian.

Макинтош валли чӑваш сарӑмӗ

Чӑваш сарӑмӗ Линукс, Виндовс, татат Андроид оператив системисенче пуррине халӑх пӗлет-ҫкӗ. Паян эпӗ Маккинтош (Mac OS) валли чӑваш сарӑмне турӑм. Вӑл виндовсри тата линуксри пекех, мӑйракаллисене ҫырас тесен Option (Alt) пускӑчне пусса мӑйракасӑррине пӗрле пусмалла. Option + А – Ӑ пулать. Ку ҫӗнни мар. Сарӑмӗ тата мӗнле лартмалли ку вырӑнта тупӑнать (хальлӗх акӑлчанла, анчах вӗҫ ӑнлантарнине ӳкерчӗклентертӗм).

Чувашская раскладка на Макинтош

Теперь есть чувашская раскладка для Mac OS, она такая же как и на Виндовс и Линукс. Чтобы написать Ӑ нужно нажать на Option (Alt) и на букву А. Раскладку и инструкцию по установке можно найти на этой странице (инструкция на английском пока, но все шаги проиллюстрированы картинками).

Working with Ukulele

I won’t go into details about how to work with Ukulele. But I was very surprised how easy it was to update the keyboard layout.

cv-kbd-mac-006

And more surprised I became when I saw that Chuvash was present in the list of available languages. cv-kbd-mac-007

Just to compare, Chuvash exists as a language in many systems in the Open Source world and close to it: Linux, Firefox, Wikipedia… For Microsoft Chuvash does not exist. No LCID, no locale, no way of referencing cv and cv-RU. There is one exception – Skype, but it was added before Skype was bought by Microsoft. I really hope it can be changed in future.

cv-kbd-mac-008

The last step was to rename to Chuvash – PC and generate an ID within the range for Cyrillic keyboards.

Microsoft again (update 2015-12-14)

After I installed my Chuvash keyboard layout and I was glad, suddenly I could not open Word, it just crashed. I didn’t realize  that it was due my custom keyboard layout. How painful, that Microsoft products crash on a custom keyboard layout. Sigh.

Chuvash Latin Script (update 2016-02-06)

I found that ABC Extended Keyboard Layout on Mac lets me write in Chuvash Latin Script using following dead keys:

  • Option b = Breve (ă, ĕ and maybe ĭ)
  • Option u = Diaeresis (ü)
  • Option c = Cedilla (ş)
  • Option v = Caron (š)

 

 

My first Office Add-In

Yesterday I participated in the Hackathon at European SharePoin Conference in Stockholm. The main goal was to learn more about Office Add-Ins. I wanted to create a very very simple app to learn the basics. Here in this post I’ll provide some links and describe the steps needed to start developing your Office Add-Ins.

The Add-in I created is an Outlook Add-In, it is called “Joke Inserter” and with it you can insert a random Chuck Norris joke. It is just for fun, but it demonstrated how an add-in can be installed, made available in “New E-mail” and interact with the e-mail you are writing.

All the code is on github. The random jokes come from The Internet Chuck Norris Database. As I said, the jokes were just for fun, this add-in is of course, not a business app. During the hackathon I got help from Pretish Abraham, Jeremy Thake and …

This is the result:

joke-inserter-video

Prerequisites

  • Any OS, I happened to have Windows :)
  • git, nodejs, npm (they should be in the $env:PATH)

Install following npm packages globally:

npm install -g tsd yeoman generator-office gulp

Creating the Add-In

Now with the yeoman support it is very easy:

Create a folder and scaffold an app:

mkdir joke-inserter
cd-joke-inserter
yo office

After that update the manifest file: Icon Url, and Support Url

Start the application on localhost:

gulp serve-static

Go to your Outook.office365.com. Click on Manage Apps and add the manifest file from your solution. I uploaded this app on azure: https://kultar.azurewebsites.net/appcompose/home/home.html. You can try this app by installing the manifest file in you Outlook client.

Now when one is done with that simple fun add-in, it is very easy to go ahead and create real add-ins that provide value to you and your colleages.

joke-inserter-video

 

Resources:

 

Working with resx files in Visual Studio

Today I found a nice Visual Studio Extension for working with localization and resx files: Resx Resource Manager. This extension provides an additional view in your project and scans all the resx files. I would recommend it to all projects where you have to translate your interface. Here is how it looks in my project:

resx-001

It can also assist with some machine translation from Bing and MyMemory:

resx-002

Another good thing is the Export and Import to and from Excel. Wonderful if you need help from Non-developers.

resx-003

Copy SharePoint WebDav Address to Clipboard

While configuring SharePoint sites and helping users I often use File Explorer View for editing pages, resources like css and javascript. In IE there is a dedicated button in the ribbon for that. Sometimes it works, sometimes it doesn’t, because of permissions or other restrictions. Anyway, I use Firefox and Chrome while troubleshooting and developing, so I have created a bookmarklet for copying the webdav address of a site that is open in the browser.

var uri = _spPageContextInfo.webAbsoluteUrl.replace(/https?:\/\//i, "\\\\").replace(/\//g, "\\");
window.prompt("Copy to clipboard: Ctrl+C, Enter", uri);

Unfortunately, there is no copy function in javascript, the prompt solution plus Ctrl-C works fine.

The bookmarklet:

javascript:void%20function(){var%20o=_spPageContextInfo.webAbsoluteUrl.replace(/https%3F:\/\//i,%22\\\\%22).replace(/\//g,%22\\%22);window.prompt(%22Copy%20to%20clipboard:%20Ctrl+C,%20Enter%22,o)}();

webdav-001

Enjoy

S01E01 IoT: Posting Temperature from Raspberry Pi to Azure

Recently I have looked more at IoT, Raspberry Pi in my spare time. In my blog post I want to share my experience in a series of posts. This post is about measuring temperature, humidity and pressure with Raspberry Pi 2 Model B and Sense Hat and posting this data to Azure Table Storage.

I followed this tutorial for connecting to azure with python and these instructions for reading data from Sense Hat.

The python script is on github. Along the way I learned that only python 2.x can be used with azure and table names cannot contain underscore (I got Bad Request error when I tried to create a table with the name “climate_data”). But overall, the process was straightforward. The temperature is not correct, maybe because the sensor is inbetween Raspberry Pi and Sense Hat where it gets warm. But it is just a Proof-of-Concept.

I have used Visual Studio 2015 to see the data in Azure Table Storage. For that I needed to install Azure SDK 2.7. There are many other “explorers” for Azure Storage.

sense-001

Other resources

Accessing Azure from Linux and Mac

Improvement #1 Corrected Temperature

I found a formula for calculating more correct temperature on the raspberry pi forum.

Ta = 0.0071*Tm*Tm+0.86*Tm-10.0
Tm = measured with the temp+humidity sensor
Ta = ambient temperature

I also added a notifcation when data is sent by showing an “S” on the Sense Hat.

Trying out Visual Studio Code on Ubuntu

I am very curious about the new .NET Core, ASP.NET 5, EF 7 and Visual Studio Code for Linux, Mac and Windows. I have tried it out on an Ubuntu 15.04 machine. The installation and configuration required a few steps, so it is not an usual “Next-next-next”-installation. But, hey, it is just a beta, a preview so far, and first of all: It worked. I am sharing a couple of screenshots and the commands I ran in the terminal, mixed with comments and links:

 

Selection_003

Selection_004

Selection_005

#install latest node and npm
#https://www.digitalocean.com/community/tutorials/how-to-install-node-js-on-an-ubuntu-14-04-server
curl -sL https://deb.nodesource.com/setup | sudo bash -
sudo apt-get install -y nodejs
sudo npm install -g yo
sudo npm install -g generator-aspnet
# download VS Code and make a link
# make a folder
mkdir workspace/tryvs
cd workspace/tryvs
# create "src/global.json" file:
# http://docs.asp.net/en/latest/tutorials/your-first-mac-aspnet.html
{
  "sdk": {
    "version": "1.0.0-beta7"
  }
}
nano src/global.json
# start VS Code 
# create 
# install omnisharp:
# http://docs.asp.net/en/latest/getting-started/installing-on-linux.html#installing-on-debian-ubuntu-and-derivatives
curl -sSL https://raw.githubusercontent.com/aspnet/Home/dev/dnvminstall.sh | DNX_BRANCH=dev sh && source ~/.dnx/dnvm/dnvm.sh
dnvm
#install dnx
sudo apt-get install -y libunwind8 gettext libssl-dev libcurl3-dev zlib1g libicu-dev
dnvm upgrade -r coreclr
cd EmptyApplication
dnu restore

#install libuv
#http://docs.asp.net/en/latest/getting-started/installing-on-linux.html#using-docker
sudo apt-get install make automake libtool curl
curl -sSL https://github.com/libuv/libuv/archive/v1.4.2.tar.gz | sudo tar zxfv - -C /usr/local/src
cd /usr/local/src/libuv-1.4.2
sudo sh autogen.sh
sudo ./configure
sudo make
sudo make install
sudo rm -rf /usr/local/src/libuv-1.4.2 && cd ~/
sudo ldconfig

#build, I got an error here
dnu build

#start the web server
dnx web

Export Any Web Part using a Bookmarklet

My blog post about exporting any webpart from a SharePoint Page is one of the most read articles on my blog. I use this method a lot. Now what I want to do is to simplify the process. Inspired by my colleague Dan Saedén’s awesome bookmarklet for reading and updating web properties, I decided to make my own bookmarklet. That was easy. Now we can export any web part from any SharePoint page without even looking at any ids in the html markup and assembling the export url manually. Just add the bookmarklet or run  the javascript code in the browser console. The code (js and bookmarklet) is on Github.

Here is an animated gif that explains how to use it:

export-webpart-002

Add Search Verticals by code

search-verticals-001

Adding own search verticals is a common task in the Search Configuration in SharePoint. Here I want to share a code sample for achieving this programmatically. I hope, this model can be added to SPMeta2.

First of all, Search Verticals are dedicated Search Results Pages and links to them. How to add them manually is described on technet:

There is no API in CSOM for that. Luckily, Mikael Svenson found how to get the Search Navigation and contributed to PnP by writing an Extension: web.LoadSearchNavigation.

Here is my sample code for adding new Search Verticals programmatically:

NavigationNode searchNav = context.Web.Navigation.GetNodeById(1040);
NavigationNodeCollection nodeCollection = searchNav.Children;
NavigationNodeCreationInformation everything = new NavigationNodeCreationInformation
{
    Title = "Everyting",
    Url = "/search/Pages/results.aspx",
};
NavigationNodeCreationInformation myresults = new NavigationNodeCreationInformation
{
    Title = "My Results",
    Url = "/search/Pages/myresults.aspx",
};
nodeCollection.Add(everything);
nodeCollection.Add(myresults);
context.ExecuteQuery();
Discovering SharePoint

And having fun doing it

Bram de Jager's SharePoint blog

My view and thoughts on SharePoint.

My programming life

and everything in between

SharePoint Development Lab by @avishnyakov

It is a good place to share some SharePoint stories and development practices.

SharePoint Dragons

Nikander & Margriet on SharePoint

Mai Omar Desouki - Avid SharePointer

Egyptian & Vodafoner - Senior SharePoint Consultant

Cameron Dwyer | SharePoint, Outlook, OnePlaceMail

OnePlaceMail, SharePoint, Outlook & Life's Other Little Wonders

.:paul.tavares:.

Me and My doings!

Share SharePoint Points!!

By Mohit Vashishtha

Jimmy Janlén "Den Scrummande Konsulten"

Erfarenheter, synpunkter och raljerande om Scrum från Jimmy Janlén

SPJoel

SharePoint for everyone

SharePointRyan.com

Ryan Dennis is a SharePoint Solution Architect with a passion for SharePoint and PowerShell

SharePoint 2020

The Vision for a Future of Clarity

Aharoni in Unicode, ya mama

Treacle tarts for great justice

... And All That JS

JavaScript, Web Apps and SharePoint

blksthl

Mostly what I know about SharePoint - CommunicoCuspis

Follow

Get every new post delivered to your Inbox.

Join 307 other followers