Wednesday, 26 June 2013

Umbraco Core Contributions Via Github

Umbraco CMS have recently moved their source code from CodePlex to Github which has triggered a flurry of contributions in the form of pull requests. Previously I had made a few small contributions to the project whilst on Codeplex and have now submitted some to Github.

Whilst GitHub is very easy to use and has excellent documentation I managed to get in a bit of a tangle trying to manage different issues, so mostly for my own future benefit, am noting two working processes here. If anyone else reads, first port of call should be the Umbraco contribution documentation and GiHub's own help pages on forking and pull requests.

One issue is that like other source control hosts, only one pull request can be submitted per branch. In order to keep things simple for the person on the other end, it makes sense not to combine several issues into one pull request.

Hence coding the first issue in master branch, pull requesting, and then trying to move onto a second in master branch will lead to problems. Really you'd have to wait until the first issue is accepted or rejected before working on a second issue in the same branch, which obviously isn't ideal.

Another issue is that, unlike Codeplex, you can only have one fork of a main repository - so you can't create a fork for each issue you work on.

Here are two methods to work around these two restrictions:

What To Do Right From The Start

This has been added to the Umbraco contribution page, so you can read it there under the section "When you're working on multiple issues at the same time".

Or Another Way... That I'm Currently Doing Given I Used Master Branch For My First Pull Request

Assuming you have a fork set up, and have cloned it locally, set up a remote of your fork called origin and one of the main repository called upstream

  1. Code and commit your work in your local master branch
  2. Create a new branch based on the upstream master branch (or other branch if more appropriate
        git branch [branch name] upstream/master
    
  3. Pull out just the commit(s) you want into your branch that you will create the pull request from. You can find the SHA of each commit using the Git GUI interface.
        git checkout [branch name]
        git cherry-pick [SHA of commit]
    
  4. Push your changes to your fork
        git push origin [branch name]
    
  5. Create a pull request from your branch into the master (or other if more appropriate) branch of the main repostory. It will now contain just the commits you want.

Tuesday, 18 June 2013

Using PhoneGap Build with a Durandal SPA

Been spending a bit of time recently looking at JavaScript frameworks, and having a prototype project avaialble as an excuse to work on something, built a small application using Durandal. Have been concious recently that my front-end code wasn't nearly as structured and well organised as that I would write on the server side, and found this a great library for helping organise this code into modules. It also utilises knockout for UI binding via view models and views.

Mostly the app runs as a SPA, though the prototype had an additional requirement to support offline access on devices. To support that I planned to package up the app using PhoneGap.

That's the background... mainly though for this blog post wanted to record some links and notes for getting set up with this framework, and in particular the phonegap build service.

Firstly I looked to use local PhoneGap. To get running found a couple of handy links:

Basic steps are:

  • Install JDK
  • Install ANT
  • Install Android ADK
  • Set PATH variables for java, ant and android

I went a bit further with that but had lots of problems with the emulator. Very slow and often failed to load. Maybe I need a new laptop but instead decided to turn to PhoneGap build and deploy direct to my device (a Samsung mobile running Android).

Getting started with this is very straightforward. Sign up using a Github account. In terms of code the only change I initially made was to add a script reference to phonegap.js - you don't need the file though, the service places the appropriate one in when compiling for each platform - and then upload a zip file of the SPA files.

Once build complete you can download the .apk for Android. Some other platforms weren't completing due to missing keys and config file - but can get to that later as the Android one was OK.

On the mobile device itself had to make a couple of setting changes under Applications:

  • enabling "unknown sources"
  • enabling USB debugging

Having already installed and setup the Android SDK could then use the command line to install to the device once connected via the USB port.

Firstly to check the device is found:

adb devices

Then to install:

adb install -r [path to apk file]

The -r flag ensures the app is overwritten even if it is already installed

For debugging the following command reveals the javascript logging:

adb logcat -s "CordovaLog"

In order to test in a browser the Ripple Emulator Chrome plugin is a useful tool. It implements a number of the PhoneGap APIs so you can test without installing on the device.