Using Gravatars in Unify
Republished because of my weird fixation on everything having to last forever
Dealing with complex data types in XSL
My motivation for creating this article comes from wanting to implement Gravatars on a blog/comment feature on a Unify site. To create a link to a Gravatar you need to generate a URL that contains an MD5 hash of an email adress in HEX formatting and XSL simply doesn't help much with that sort of thing. In Java code however generating an MD5 hash from an email address is a trivial task.
VYRE Unify uses XSL a lot to generate HTML from the XML data stored in it's content repository. This can often lead to issues for users trying to produce output with anything more complicated than plain text with simple HTML tags and URLs. For example reformating dates is a nightmare to do with just plain XSL and XPath.
This is where XSL Java extensions come in to save the day. Using XSL Java extensions you can effectively call any Java method available from an XSL script. VYRE Unify fully supports XSL Java extensions.
To explain what XSL Java extensions are, here is a simple example that prints the cosinus of a number in the XML source.
To explain what's going on here, I have defined a new namespace “math” to be a Java class format namespace. I can then call static methods on that class in XPath by using the namespace. Note the parameter is a XPath that resolves to a tag containing a number and is automatically cast to a javatype double.
A slightly more complicated example would be printing the current date:
This is the equivalent of the Java code:
You might notice that the method calls in the XPath look a bit backward compared to the Java syntax. The rule is a methods declaring class is the first parameter of the method and the following parameters are the Java methods parameters. Calling constructors is the same syntax as calling a static method with the name "new".
Both the examples above use so called Class format namespace, there is also package format namespace and Java format namespace that you can read about in the Xalan documentation.
Using gravatars
Now finally I'll show how I managed to create gravatar links in an item list XSL in Unify. The first place to look was the Gravatar implementor's guide Java section. Where they show a class that can generate the MD5 hash with a simple static method call. What I actually did was cheat, because I knew there was a class in Unify that does exactly the same thing, so I did:
http://www.gravatar.com/avatar/
But for non Unify developers it is trivial to compile the class given on the Gravatar site, put it on your Unify servers classpath and calling it like so:
Better practices
In the examples above I define the xml namespaces in the outermost tag of the example, this has an annoying side effect of making the xmlns attribute appear in the html output. This can be avoided by defining the namespace in the xsl:stylesheet tag and adding the namespace to xclude-result-prefixes to the xsl:stylesheet tag.
In general you would also usually want to keep this sort of complicated XSL code in separate includable XSL scripts in callable named templates supported in Unify 4.4+.
Das Kapital
“Owners of capital will stimulate the working class to buy more and more of expensive goods, houses and technology, pushing them to take more and more expensive credits, until their debt becomes unbearable. The unpaid debt will lead to bankruptcy of banks, which will have to be nationalised, …”-- Karl Marx in Das Kapital published 1867 source
Pro blogger
I've finally, after this minimal amount of training, gone pro in my blogging career. My first attempt at pro blogging is this quick overview of my trip to Belgium last year. Expect more to come soonish, so watch this space!
Generic and special laws of laptop relativity
The Atlassian blog just published an theory on Laptop Relavitity. This law, which I have observed myself, is exactly why I think coders should not use laptops for coding. Since desktops rarely have much velocity they are much less affected by the general relativity law, and never by special relativity because public transport workers never let people on the train with a desktop. Especially not if it's as big as mine.
DataMarket
I just bumped into DataMarket, a Icelandic company specializing in custom data aggregation. The concept of a company selling data aggregation as it's product, and buying raw data feeds as raw material somehow makes perfect sense to me. The "Damn, why didn't I think of that." moment made me want to blog.
I also need to get into the habit of blogging since I'll be going pro soon.
Wiki wiki!
For those of the three of you who haven't...
Financial expert
There is a short interview with yours truly on page 4 of Fréttablaðið today, here is the web version. For those who don't understand the language, I'm making huge claims about the everlasting friendship between Britain and Iceland. The reporter seemed to think Icelanders have some reason to fear going to Britain because some Icelandic banks lost British money.
Comments:
Hetjan mín
Gaman að þekkja svona frægann mann í útlöndum sem gefur álit á stöðu heimsmála og hagi íslendinga í útlöndum.
Javascript brainfuck interpreter
Last night I wrote a javascript brainfuck interpreter. You can try it out.
It works by reading the brainfuck code from the textarea and compiling it to the equivalent javascript code. That output is then passed to eval(). The input and output are put into arrays of javascript numbers. The string to/from byte array conversion is done before and after evaluating the program.
As far as I can tell my compiler meets brainfucks official portability standard. It should be a good testing platform for those crazy enough to want to write brainfuck programs, but to lazy to install a compiler.
Google Chrome crash window
Just bumped into this. Nice and quirky:
I'm not sure exactly what I did to cause this. I simply browsed a few pages and then left it running for a few hours.
My pet peeve
I'm hugely annoyed by people that put a space before question marks at the end of questions in languages other than French. Usage of question marks seems have at least three different types, illustrated below.
- ¿Habla Español?
- Parlez-vous français ?
- Do you speak English?
- Talar þú íslensku?
Internet confectionary
It may interest the Icelandic reader of this blog that Gommit & co. have recently launched the Icelandic digg equivalent.
Egoblog
I've noticed when egobrowsing Google Analytics that for some reason this page gets a lot more hits that my amazing mobile blog.
The mobile blog generally has a lot more activity with up to 12 posts per month, so I'd like to recommend it's atom feed to both you syndicators out there.
Money
I recommend watching all 5 parts of this documentary about where money comes from.
Comments:
Mjög athyglisvert.
Ég hef raunar einmitt velt þessum málum fyrir mér, en ekki haft þekkingu á innri lagagerð banka til að draga neinar ályktanir. Raunar hefur einhver basic hagfræðibók fyrir framhaldsskólana verið á leslistanum lengi, sem byrjunar punktur í þessari stúdíu. En af einhverjum ástæðum hafa önnur mál heillað meira. Þetta var hinsvegar fínt skref í rétta átt, opnaði augu mín fyrir eðli málsins að einhverju leyti. - Ég er enn efins þó. Ef við hugsum okkur að lán jafngildi greiðum, þá má vera að samfélagi sé nauðsynlegt að byggja upp slíkt safn greiða. Á móti kemur að þessi veldisvöxtur er farinn að vera þeim sem vilja sjá það, augljós galli á 'kerfinu'. - Aftur játa ég þó fáfræði mína og hafna dómi í málinu, að svo komnu, en mun án efa íhuga þetta ( jafnvel gegn vilja mínum - því þannig er ég nú einu sinni gerður ). - Góð ábending Sindri! ;)
DAPSinn
Sæll Sindri, er bara að velta fyrir mér hvort DAPS hugbúnaðurinn sé keyrandi í bakgrunni á vefsvæðinu þínu, og hvort þú notir hann til að vinna allar myndir til birtingar?
Hi Sindri
In 1969, the conceptual artist Douglas Huebler wrote, "The world is full of objects, more or less interesting; I do not wish to add any more." I've come to embrace Huebler's ideas, though it might be retooled as, "The world is full of texts, more or less interesting; I do not wish to add any more." It seems an appropriate response to a new condition in writing today: faced with an unprecedented amount of available text, the problem is not needing to write more of it; instead, we must learn to negotiate the vast quantity that exists. That's what we need to think about, when talking about money, in my opinion.
DAPS
DAPS er internetið, og húnakóngur ræður öllu þar.
Ruth Kinght
I like your blog website, can you add this to the demo site. Sorry to be a pain, but we are demoing to Singha tomorrow afternoon, please.
Mony
I think that wen mony is here, we can have food. But let's not forget that there are other important things that we need. We need more food, water, and shelter. Of course, we only really need lots of food and water to make beer because those are our fundamental biological needs. But in order to have stuff that we need as well as stuff that we "need" (you know, the "state-of-the-market" computer that is about to be outdated by the next one), we need something else. But what is that somthing I ask you?
Comeback
And with the local BBC news Osama Bin Laden with a triumphant comeback , said the following in his new video:
Dont call it a comeback
I been here for years
Rockin my peers and puttin suckas in fear
Makin the tears rain down like a mon soon
Listen to the bass go boom
Explosion overpowerin
Over the competition Im towerin
Wreckin shop when I drop these lyrics thatll make you call the cops
Dont you dare stare, you betta move
Dont ever compare
Me to the rest thatll all get sliced and diced
Competitions payin the price
Migrating monkeys
I had to migrate from one PC to another slightly newer one at work. After being extremely frustrated about Outlook 2007 not being able to pick up what my setup was on the newer PC I did some googling and found the USMT. The User State Migration Tool will with an amazingly good command line interface (for M$) gather your user settings on one Windows box and restore them on the newer one. I've yet to find anything it missed. You can get the USMT here.
Google webmasters tools
I've decided to share my superb experience with Googles webmaster tools. Apart form having a name that makes me feel like I'm the master of something, it manages to fully serve all my egobrowsing needs. It actually shows a list of all other websites that link to mine, and I can download the information as csv.
Comments:
titill
töff, en er ekki hægt að splæsa þeim saman? og má ekki taka út þetta texta verification? Feature creep >:o)
herra
Duglegasti bloggari internetsins mættur með nýja síðu! maður hefur þá ekki undan ef það á að fylgjast með báðum!
Fancy features
I've added a fancy feature to the site. Now the posts on my mobile blog are mirrored here by transforming the Atom feed from blogspot.com via xsl.
Comments:
feature creep
Fítusar eru skemmtilegir, mætti ekki sulla bloggunum saman í eina síðu? ég get svo ekki blokkað textann í þessu commenti nema með Ctrl+a (IE7@work) Svo er ég í miðri krossferð gegn stafarugli >:o) (ég tapaði einmitt commentinu mínu hérna í gær því ég gat ekki blokkað textann með músinni til að kópera - klikkaði á stafaruglinu og commentið hvarf í matrixið - sem betur var það samt lélegt comment ;)
hmmm
það kom í ljós að ég er tregari en ég hélt - kommentið mitt virðist hafa farið í gegn eftir allt saman - það hefur bara farið fram hjá mér - eníhú ég er þá bara official commenta kóngur á þessu bloggi :oD
Website launch
I've had this domain for a while now and always intended to start a personal/professional blog here. Finally now I have access to a instance of VYRE Unify to play around with so now the only thing that can possibly stop me is finding the time away from making Unify to use it to blog.
Comments:
Going pro?
Was this some pun I did not get or are you going pro? Pro what? :)
Posted by Arnþór L. Arnarson at 07.02.2009 07:07.
Pro
Pro blogger...
Posted by Sindri at 07.02.2009 13:11.