Wednesday, 23 March 2016

An easier, better, tastier (!) BeerGraphGuide in the Neo4j Browser!

I recently wrote two blogposts about a fancy new way to create "Guides" right in the Neo4j Browser - a system that we at Neo have used ourselves to create learning experiences for the Neo4j Graph Database - but that we are now also extending and making available to our community and Enterprise customers. The first post showed you what the result was, and the second post showed you how easy it was to create such a guide. And of course, since this is still all very new and under development by the inimitable Michael Hunger, it is still evolving at warp speed.

So that's why I am adding a third post to this series, based on the lastest version of Michael's github repo. In this version, he has added a much more convenient way to serve the HTML page that we use as the basis for the Browser Guide: we essentially don't need a CORS-enabled webserver anymore - we can just use the webserver that is already baked into Neo4j and which the Browser already uses. Michael did this by developing an unmanaged extension that picks up the HTML file from a local directory, and then serves it when you call the :play command in the browser. So how does it work? Let's show you.

Installing the Unmanaged Extension

You will find the extension on the github repo under the "guide-extension" directory. Michael has added some detailed installation instructions if you would be able and willing to compile the software yourself - but he has also added a compiled version link for Neo4j Enterprise 2.3.2. You can download the .jar file, and then just add this to the right directory of your Neo4j Enterprise 2.3.2 installation: the "plugins" subdirectory.



Once you have that, we do still need to do a few manual interventions to activate and enable the extension.

Creating the directory and copying the guide's html file

The extension assumes that you add a new directory in the "data" directory of your Neo4j installation: "guides". Once you have created that, you can copy the HTML file that I had created in the previous post, into this directory - this is where we will serve all future Guides from.

Configuring the Neo4j server

Then we need to make a few more easy configs to the neo4j-server.properties file in the ./conf directory of your Neo4j installation.

1. Disable authentication for the Neo4j server

Michael has not added a way to authenticate to the server yet, and therefore you just turn the dbms.security.auth_enabled switch from true to false.

2. Donfigure the extension .jar file

Two things we need to do:
  • In order to load the extension from a specific URL (in this case: http://localhost:7474/guides) we add property to the neo4j-server.properties file. 
  • We let the extension know where the guides will be located (the data/guides directory)
You could of course configure these differently if that would be useful.

3. Edit the whitelist for the browser to load Guides from

Again, we edit a particular section of the neo4j-server.properties file, and allow the browser to load data from the localhost server. Two ways to do that:
  • simply allow ANY server with a "*"
  • or specifically allow the localhost on the specific port that your server is running
And that should do it. All we need to do now is bounce the Neo4j server, and we should have our guide in the browser: just try

:play http://localhost:7474/guides/beer_graph.html

in the browser, and tah-daaaaaah:

Yey! That was easy!

Hope you like this as much as I did. Big kudos to Michael, again - and I look forward to seeing your Guides somewhere in our community.

Cheers

Rik

No comments:

Post a comment