wissel.net

Usability - Productivity - Business - The web - Singapore & Twins

LiveText and HashTags


Without vendor backing, a UN sub committee or never concluding standard consortia the standard for inline tagging has been established. It is the humble hash (or pound) sign: #. There is a bit of wobble if it should be lower or CamelCase, but the consensus on the # tag is universal. Using the Notes client's LiveText capabilities we can put hash tags in our applications or eMail messages to work.
Unfortunately the way to success is blocked by Regular Expressions which are a member of the three occult mysteries of IT ( Map-Reduce and XPath expressions would be the other two). There are approximately 10 people who really understand them: the one who came up with them and the other one is hiding. Luckily there is StackOverflow, the online Regex Tester and SourceForge's Regulator (courtesy of Roy Osherove).
Ideally the regular expression would give us access to the hash tag with and without the leading #. After probing around and testing what I found on StackOverflow I settled with \#([A-Za-z0-9_-]+)(?![A-Za-z0-9_\]-]). One free Starbucks beverage of your choice if you can explain that one in plain English .
To put this to use you need to perform 3 steps (you can do them inside the wizard, but we split them out here for greater clarity):
  1. Configure a content type
    Right Click on the My Widgets Toolbox
    Right click on the "My Widgets" toolbox and select configure Content Type. We will have 2 parts to the content: the full content including the # Tag and the content without it.
    The HashTag Content Type
    I named the two properties content and tag but you are free to name the second as you deem fit (don't change the first one). Eventually (if I can figure this out) I will add a 3rd property that returns the tag all lower case.
  2. Configure a recognizer
    Configure the recognizer
    The regular expression is \#([A-Za-z0-9_-]+)(?![A-Za-z0-9_\]-]) which roughly translates into: "give me everything that starts with a # and has more than one letter/number/dash in it, return it also without the #. You assign group 0, which stands for "all of it" to content and group 1 to tag". Now we are ready for some action(s)
  3. Configure an action for your content (more about that below)
Repeat step 3 for every target you are interested in. Once you have completed all of this LiveText will highlight your hash tags and offer you all configured actions:
Hash Tags with 3 configured actions
As an example we search for Tweets with that tag.The twitter search includes the hash tag. Let's get started:
  1. Click the widget toolbar's toolbox (No widget toolbar? Enable it in the Preferences). You will get the first dialog with the title Start comnfiguring Widgets
    First page of the widget wizard
    1. Select Web Page as Target
    2. Click on next
  2. The following dialog is titled "Configure a widget from a Web page"
    Pick the site
    1. Select Web page by URL. I find it more convenient just to type/paste the address than to surf with the build in browser only to click the toolbox again
    2. Our example is http://www.twitter.com
    3. Click on next
  3. You need to specify if you are interested in URL parameter (e.g. a Google search) or filling in a form. We select the second option HTTP POST
    Select POST
  4. The dialog has 3 areas. The first one lists all forms, the middle one shows the page and the lower one has buttons and navigation
    configure the Twitter search
    1. All forms will be shown in the first box. When you click through the forms the entry fields that belong to that form will be shown in green with the word Lotus in it. For Twitter it is Form 6
    2. Click on next
  5. In this wizard step we decide to configure an action, since our recognizer and content type is ready. The twitter search form has only one parameter q, so we don't need the advanced tab. We configure an action
    1. Give your action a name. Make it short and easy to recognise, that name will later show up in the sidebar and the LiveText menu
    2. Select Wire as an action
    3. Click on next
  6. We almost made it. Now we put everything together
    The final action configuration
    1. Select Recognized content
    2. In the dropdown pick HashTag. We could have configured content type and recognizer here, but then the separation between content, recognizer and action wouldn't have been obvious
    3. Select contents as source. If you want to search without the leading #, select tag
    4. It's a personal preference where to open the content. For demos floating windows give the best effect. For real world: I like the tab or (bonus tip) when I target a mobile site so it fits nicely into the sidebar.
    5. Click on Finish
    The configuration is now complete and you can start over with the next action. What will it be: Google+, Tumblr, IBM Connections?
Since you made it so far, you can just drag the ready made action into your widget panel. It will create content type, recognizer and action for you. Now you know, what other actions will you configure? Crazy brave developers have a look at the XML source code and edit their extra actions in gEdit, notepad, vi or emacs.

Posted by on 21 August 2011 | Comments (3) | categories: Show-N-Tell Thursday

Comments

  1. posted by Mikkel Flindt Heisterberg on Thursday 25 August 2011 AD:
    Well reading the regex from the left to right says: match a hash character (special char so escaped using \). Then match all ASCII upper and lower case chars as well as numbers and - and _ at least once and stick into a capture group for reuse. The weird thing about the regex is the second part which is a negative lookahead saying what the before mentioned cannot be followed by. Since most characters to match is also here (except ]) it only says that a hashtag cannot end in ]. It is however slightly more advanced as using a negative lookahead is the only way to entirely disallow a hashtag like #hashtag].

    Was that plain English? Emoticon wink.gif
  2. posted by Stephan H. Wissel on Thursday 25 August 2011 AD:
    @Mikkel The "negative lookahead" isn't real English (it's perfect GeekSpeak). Anyway you earn the Raffles IceTea Bonus pack. See you on Monday then. Emoticon biggrin.gif stw
  3. posted by milos on Thursday 15 December 2011 AD:
    useful article, thanks