Should I Buy a Slow Loris? (.com)

In honor of the slow loris that purportedly bit Lady Gaga, I registered a domain in the wee hours of the morning last night and built a website:

Should I Buy a Slow Loris (.com)

Hopefully it provides an answer to that question. If it does generate any money from the Donate button, I’ll pass all of it right along to slow loris conservation and research efforts, primatologist’s honor.

Thanks to @mdo for the Bootstrap template, Mark Dumont for the Flickr photo (CC BY 2.0), Schulze & Meier 1995 for the Slender loris sound (since slow loris vocalization are hard to find,) and Raptorize for the jQuery animation fun.

New Lab Website Launched

We recently redesigned our lab’s website using weebly, which I highly recommend for academics looking to create a group or personal home page.

I wrote before of how I exported our lists of publications to HTML for insertion on the site. Here’s how I redirected all the pages on the old site using an .htaccess 301 redirect. For background info, see this tutorial. On the old site, in the directory containing pages that I wanted to be redirected, I placed a file named .htaccess that contained the following:

RedirectMatch 301 ^/.*$

It tells search engines and the browser that any URL matching ^/.*$ (the_current_directory/whatever) should redirect to Super simple, and good SEO!

Adding Your Mendeley Publications to Your Website

With the power out for about a week in Lower Manhattan, I took the time to attend to some loose ends. One was the redesign of the lab website. The last major hurdle was the addition of a list of publications by lab members. I had previously used LaTeX and BibTeX to add my own publications from Mendeley to my CV, and I figured it’d be a snap to add the lab’s publications to our weebly website. It turned out to be a bit tricky, so I’ll detail how I figured it out in this post.

The lab site created using the free service weebly was shaping up. The only gaping hole was the list of publications. We had a Mendeley group for our lab to share papers relating to our current research, and a folder within that contained a bunch of references by lab members.

I selected all the publications and chose File > Export.

This exported a BibTeX file of all our publications in entries that look something like this:

abstract = {The ranges of small kinda (Papio kindae) and [...]},
author = {Jolly, Clifford J. and Burrell, Andrew S. and Phillips-Conroy, Jane E. 
and Bergey, Christina M. and Rogers, Jeffrey},
doi = {10.1002/ajp.20896},
file = {:path/to/Jolly2011.pdf:pdf},
issn = {1098-2345},
journal = {American Journal of Primatology},
keywords = {Animal,Animals,DNA,Female,Genes,Genetic,[...]},
month = mar,
number = {3},
pages = {291--303},
pmid = {21274900},
title = {{Kinda baboons (Papio kindae) and grayfoot chacma baboons (P. ursinus 
griseipes) hybridize in the Kafue river valley, Zambia.}},
url = {},
volume = {73},
year = {2011}

OK, so I’d gotten the info out of Mendeley, but now I needed to get it into a nice HTML format. I poked around online and found people were recommending a Java reference manager called JabRef. I downloaded it and opened up my BibTeX file.

Looks good! Yeah, there are a few errors and inconsistencies, but this is just a first pass. I first tried the default export to HTML. Selecting File > Export, though, showed four different HTML options: HTML, HTML list, HTML table, HTML table (with Abstract & something else I can’t read), and Simple HTML.

I tried them all, but none was really what I wanted. The HTML list was neat, but weebly doesn’t let you muck with custom scripts or CSS, so that one was out. With a bit of Googling, I found that you can customize the export format by writing your own Export Filter. Essentially what you do is write a layout file which tells JabRef how to spit out the HTML. Whenever I’m in unfamiliar coding territory, I like to start out with a working example and then try to modify it to do my bidding without breaking everything. I found a simple HTML export filter at this site by Mark Schenk. I chose as my starting point his List of References Export Filter, which you can download here. Since I was going to be inserting the HTML in an existing page, I ignored the files that defined the start and end of the exported HTML, listrefs.begin.layout and listrefs.end.layout. I only downloaded listrefs.layout, which I renamed bergey.layout on my harddrive.

I decided to try it without modification first, just to see what happened. I first had to add this custom Export Filter to JabRef. To do that I clicked Options > Manage custom exports. I then clicked Add new and entered this info:

…with a real path to bergey.layout, of course. That done, I then went to File > Export. I gave my exported file a name, in this case “test” and chose bergey_lab_site (*.html) as my File Format.

It worked, but when I opened up test.html in my web browser, there was a bunch of extra stuff I didn’t want. The full abstract, the raw BibTeX, and links that should have toggled the abstract and BibTeX (which didn’t work because the JavaScript in the header wasn’t output because I hadn’t used listrefs.begin.layout.) There was also a link to the PDF, which pointed to a location on my local computer.

It was time to start cutting bits out, so I opened bergey.layout in a text editor. I then deleted the highlighted parts shown below:

Saving, re-exporting from JabRef, and refreshing the page in the browser showed that doing so got rid of the abstract and BibTex text, but the unwanted links remained. To fix that, I changed this line in bergey.layout:

<p class="infolinks">
\begin{abstract}[<a href="javascript:toggleInfo('\format{\bibtexkey}',
\begin{review} [<a href="javascript:toggleInfo('\format{\bibtexkey}',
[<a href="javascript:toggleInfo('\format{\bibtexkey}','bibtex')">
\begin{doi} [<a href="\format[DOICheck]{\doi}" target="_blank">
\begin{url} [<a href="\format{\url}" target="_blank">URL</a>]\end{url}
\begin{file} [<a href="\format[WrapFileLinks(\r,,pdf)]{\file}" 

to this (without line breaks):

<p class="infolinks">\begin{doi} [<a href="\format[DOICheck]{\doi}" 
target="_blank">DOI</a>]\end{doi}\begin{url} [<a href="\format{\url}" 

Essentially getting rid of the abstract, review, BibTeX, and file links, but leaving those for DOI and URL. I cleaned things up a bit more, deleting some extraneous punctuation and line breaks, and changing the formatting. After all the tweaking, my bergey.layout file looked like this:

<tr id="\format{\bibtexkey}" class="entry">
	<td><p>\begin{author}\format[Authors(LastFirst,NoPunc,InitialsNoSpace),HTMLChars]{\author}\end{author} (\year). "\format[HTMLChars]{\title}"\begin{journal} \format[HTMLChars]{\journal}.\end{journal}\begin{booktitle} In \format[HTMLChars]{\booktitle}.\end{booktitle}\begin{howpublished} \howpublished.\end{howpublished}\begin{school}. Thesis at: \format[HTMLChars]{\school}.\end{school}\begin{address} \format[HTMLChars]{\address}\end{address}\begin{month} \format[HTMLChars]{\month}, \year.\end{month} \begin{volume} \volume\end{volume}\begin{number}(\format[FormatPagesForHTML]{\number})\end{number}\begin{pages}, \format[FormatPagesForHTML]{\pages}.\end{pages}
	\begin{doi} [<a href="\format[DOICheck]{\doi}" target="_blank">DOI</a>]\end{doi}\begin{url} [<a href="\format{\url}" target="_blank">URL</a>]\end{url}</p>

which output HTML that looked like this:

Not bad! A few errors remain, but mostly from needing to correct info in Mendeley. However, I want things sorted by year, not last name, even though that’s better for us alphabetically blessed first authors. Having JabRef sort by year on export rather than by Author last name is accomplished using the preferences menu, found at Options > Preferences and the selecting the File window. There you can chose to “Export in current table sort order” (click to embiggen):

I sort by year by clicking above the year column. The exported HTML is the same order as is in my JabRef screen. Nice! Now what if I could add a header for each year? That is pretty simple, I just add a grouped output command to the top of my .layout file. I’ll put the year above each group as an <h3> element:


Finally! All done! My bergey.layout file is this:

<tr id="\format{\bibtexkey}" class="entry">
	<td><p>\begin{author}\format[Authors(LastFirst,NoPunc,InitialsNoSpace),HTMLChars]{\author}\end{author} (\year). "\format[HTMLChars]{\title}"\begin{journal} \format[HTMLChars]{\journal}.\end{journal}\begin{booktitle} In \format[HTMLChars]{\booktitle}.\end{booktitle}\begin{howpublished} \howpublished.\end{howpublished}\begin{school}. Thesis at: \format[HTMLChars]{\school}.\end{school}\begin{address} \format[HTMLChars]{\address}\end{address}\begin{month} \format[HTMLChars]{\month}, \year.\end{month} \begin{volume} \volume\end{volume}\begin{number}(\format[FormatPagesForHTML]{\number})\end{number}\begin{pages}, \format[FormatPagesForHTML]{\pages}.\end{pages}
	\begin{doi} [<a href="\format[DOICheck]{\doi}" target="_blank">DOI</a>]\end{doi}\begin{url} [<a href="\format{\url}" target="_blank">URL</a>]\end{url}</p>

which outputs this HTML:

If I view source in the browser, or open the .html file in a text editor, I can see the raw HTML. I can now take the HTML and paste it onto my weebly site, using their Custom HTML element:

Ta-da! Not too onerous. Whenever new papers are published, it’s just a simple matter or adding them to the Mendeley group, ensuring their bibliographic info is correct, exporting the group’s contents as a BibTeX file, opening that file in JabRef, and exporting it using the custom filter I wrote. You can see the lab’s site here, which we’ll eventually give an NYU URL using an .htaccess 301 redirect. Hope this (long winded) tutorial is of use to someone out there!