Wednesday 1 January 2014

Hyde (backend)

I recently introduced my response to Jekyll on GitHub pages (which I've called Hyde) and promised that I'd go into more detail about it's usage, here goes...

In order to get started with Hyde let us start with the backend first. All you need is a Google Sheet to start with so head over to Drive and create a new Sheet - I've called mine mdblog but it really doesn't matter what it's called. We'll need 4 columns which I've called id, date, title and content. I'm guessing that we could also end up adding further columns like tags but for now that will do us I reckon.

Once the Sheet is made we need to make sure that we hit Publish to the web... on the File menu (don't forget to tick the Automatically republish when changes are made tickbox, and especially don't forget to click the button Start publishing) I've also named it but left it as that as I think that that will do in terms of sharing permissions. Now we need to look at the URI, it will be in the form of something like: https://docs.google.com/spreadsheet/ccc?key=0AiRgQIhodQXfdGVOMEZTcHFJbm95R1l0V1ljRWlBTHc#gid=0. That there long string of seemingly random numbers and letters after key= and before #gid=0 is what we're interested in (so: 0AiRgQIhodQXfdGVOMEZTcHFJbm95R1l0V1ljRWlBTHc). Copy that string and keep it somewhere safe. In order to check that we're cooking we'll need to populate at least one row so why not add some data? Keep things simple and add 1 to the id, a date in the format DD/MM/YYYY HH:MM:SS to the date, Hello World to the title and some markdown formatted text to the content.

Now with some data in our backend let's see if we can access it. Go back to your copied long string and copy it again onto another line then put https://spreadsheets.google.com/feeds/list/ in front and /od6/public/values?alt=json behind (you should end up with something like this : https://spreadsheets.google.com/feeds/list/0AiRgQIhodQXfdElYTEg2SmtBZTBrNjVlcC1ST3c1VEE/od6/public/values?alt=json). You should end up seeing a long string of json formatted text (Sometimes the ordering/naming of the pages within a spreadsheet can get confusing - if you're not seeing any json then take the same string and put https://spreadsheets.google.com/feeds/worksheets/ in front and /private/full behind (https://spreadsheets.google.com/feeds/worksheets/0AiRgQIhodQXfdElYTEg2SmtBZTBrNjVlcC1ST3c1VEE/private/full), this should give you an idea of the id of the specific page (in our case it is od6)).

That's it for your backend for now - that'll give you enough structure and data in order to get things working.

No comments:

Post a Comment