poornerd

my thoughts on programming and other nerdy stuff

Wysiwyg Editing of Play! Framework Templates with the Aloha Editor

| 0 comments

aloha-savesOk, so it is only par­tial edit­ing, but still this is an inter­est­ing step in the “no CMS” direc­tion. What I have done is mod­i­fied the exam­ple code which I posted on github last week for inline edit­ing of HTML5 ele­ments with the Aloha WYSIWYG Edi­tor to actu­ally save the new con­tent back in to the Scala Template.

I find this use­ful for allow­ing non-techie col­leagues to edit and opti­mize text and word­ings in more con­tent ori­ented tem­plates. Of course it does directly mod­ify the source, so in the case of a live web­site you would want to do this in the devel­op­ment envi­ron­ment and then com­mit, push, deploy the new ver­sion — hence “no CMS”.

In my exam­ple I have lim­ited the fron­tend code to a block in the footer tem­plate. It is only ren­dered into the page if the fol­low­ing value is set to true in the application.conf:

play-aloha.admin=true

One of the non-elegant parts of the code is decid­ing which tem­plate file to look for the HTML to replace. Right now it is hard coded. I sup­posed the most prag­matic way would be to cre­ate a hashtable map­ping URL’s to filenames.

Here you can see the changed HTML in the scala template:

git-diff

 

The code is in github here: https://​github​.com/​p​o​o​r​n​e​r​d​/​p​l​a​y​-​a​l​oha

If you have read this far, you may as well fol­low me on Twit­ter:

Author: poornerd

Tech­nol­o­gist, Entre­pre­neur, Vision­ary, Pro­gram­mer :: Grad­u­ated from USC (Uni­ver­sity of South­ern Cal­i­for­nia) with a degree in Com­puter Sci­ence. After 10+ years of free­lance con­sult­ing and pro­gram­ming, he co-founded Site­Force AG eBusi­ness Solu­tions in 1999 in Munich (München), Ger­many.

Leave a Reply

Required fields are marked *.