Wednesday, 5 August 2015

Umbraco Lucene Examine search in foreign languages

Today I had to implement search using Lucene/Examine on a German Umbraco site. It wasn't easy working out what to do, so here's the lowdown, for future reference.

 I installed Lucene.Net.Contrib using the Nuget Package Manager console:
PM> Install-Package Lucene.Net.Contrib -Version 2.9.4.1
Then I updated the index providers in the ExamineSettings.config file, like this example:
<add name="InternalIndexer" type="UmbracoExamine.UmbracoContentIndexer, UmbracoExamine"
           supportUnpublished="true"
           supportProtected="true"
           analyzer="Lucene.Net.Analysis.De.GermanAnalyzer, Lucene.Net.Contrib.Analyzers"/>
Then, re-index the whole site.

Umbraco Lucene search without case sensitivity

I've been working on a new site build in a small team, using Umbraco 7. My task today was to implement site search, and in doing so I had a problem with case sensitivity - searching for "word" did not return results containing "Word". After some investigation it turned out we were using the WhiteSpaceAnalyzer for the indexing. Switching to the StandardAnalyzer solved my case problem.

Friday, 24 July 2015

Razor syntax is loop odd or even

I had to render a table of data today, and alternate classes on the rows. Here's the Razor:
tr class="@(rowCounter%2 == 0 ? "even" : "odd")"

Wednesday, 24 June 2015

Prevent browser from loading drag and dropped file

I've been implementing a drag-and-drop uploader today but found that if the user missed the drop area the browser would load the file directly. Annoying huh? I overcame this with this nifty bit of javascript:
window.addEventListener("dragover",function(e){
  e = e || event;
  e.preventDefault();
},false);
window.addEventListener("drop",function(e){
  e = e || event;
  e.preventDefault();
},false);

Tuesday, 9 June 2015

Untappable areas with Android 4.x and Phonegap

I came across a problem today while using jQuery to hide one div and show another in its place. The touchable elements on the revealed (buttons, input fields) weren't responding to touch. I found on SO that adding the following style to the problem div fixes the problem:
.androidpaintfix {
-webkit-transform: translate3d(0,0,0);
transform: translate3d(0, 0, 0);
}
If you're doing this to a div that needs to be hidden then you need to do it dynamically in JS like so:
$("#formLogin").addClass('androidpaintfix');

Friday, 29 May 2015

Throw an exception in Obj C

I've just been implementing HockeyApp and GetSentry crash reporting in one of our iOS native apps, and this handy piece of code came in useful for testing what happens when an exception is thrown.


   
        NSException* myException = [NSException
                                    exceptionWithName:@"TestExcpetion"
                                    reason:@"Just testing"
                                    userInfo:nil];
        @throw myException;