Tags: Coding, Automation, Timesaving
Although I touched upon it in my previous blog, I thought it might be worth expanding upon the subject today because, as well as explaining (to anyone who might be interested) what has been involved in this project, it will also serve as a test run, now that the new blogging system that I have coded has gone ‘live’; there is always the possibility, of course, that something horrible might happen, and this blog will never appear (at least, not in this form: the whole point about blogs is that they should be relevant in a specific timeframe). I am feeling reasonably confident however: I say this because the system has been fully tested offline (on my local server), to make sure all the file reading and writing routines work as they should, and the primary indicator on the interface that I am using to write up a new blog is working as it should, whereas the slightest problem with coding seems to make it disappear. the thing that is most likely, if anything, to go wrong is a relative URI that is incorrect, now that the scripts are resident on the server of my ISP, and not on my local server. Time will tell!
In fact, I am now able to report (somewhat warily, it has to be said!) that the first hurdle has been cleared, which I will explain presently, and I will now continue with a reasonable expectation that the whole blog will be written and saved in the correct places. This is the culmination of about four months (give or take: I have lost track) of work, when time was available, and it is another, albeit primary and very useful, element of my own website that I coded up last year. I make no grandiose claims for it; to the technically savvy, it probably looks somewhat amateurish, but I have this stubborn streak in my character that demands that a project such as this on which I embark for 2 reasons - to learn and achieve something useful - has to be undertaken the hard way, without the safety net of drag and drop packages (some of which are even available free): in other words, writing all the code myself (and I am even too proud to utilise code libraries, although that could change), although I am not so deluded as to think that I am now competent enough to do this for a living, when there are probably plenty of unemployed graduates in the labour market who could do it ten times better and faster than I can.
On that subject, I am very lucky to have a graduate at my disposal, who is always cheerfully willing to help me out when I struggle (frequently!) so thanks again Ben. The system I have been striving to master is called AJAX, and it is a combination of JavaScript, PHP and XML, and these languages are called from the HTML page on my website. Most people will have heard of HTML (which also uses a page layout coding system called CSS, so that the content and the layout instructions can be kept separate), and having to use all these separate languages might seem unnecessarily complicated, so I will endeavour to explain it in the simplest possible terms (none of this helps me to tripe better, I hasten to add!). HTML can be superficially formatted (for example, adding bold sections to highlight certain words or phrases) but this is kept to a minimum, to make it easier to change the look of a page, or even a whole site, by changing the CSS code. JavaScript has been extensively developed since it was first introduced, and it enables a high degree of interactivity between the web page and the user (or client), but none of these changes can be saved: as soon as the page is closed, the changes are lost. The main reason cited for this is security, but the logic is somewhat faulty, in my humble opinion.
This is where PHP comes in, because it is one of the most popular scripting languages for making changes on the server side, so that information that might have been entered on a form (such as the one I am using to compile my blog) can be sent to a server and written for future use. I understand the concept of cookies for keeping track of users’ details, and I am sure that those better informed in these matters could explain how using PHP is more secure than allowing JavaScript to write files to remote servers, but (and without any false modesty, I can assure you, gentle reader) if a dunce such as I can master the writing of files to a remote server, that rather weakens the security argument, in my estimation; nevertheless, I can see the sense in keeping client and server separate. The final element is XML, which is a carrier system for information, using self-styled HTML-type tags, which can be used to create simple databases: for more sophisticated databases, SQL is normally used, but I really felt that this was a bridge too far! (for now, at least) Although the navigation of XML files is somewhat tricky initially (as is the layout formatting, using a subset called XSL), once mastered it is actually very elegant in its economy, and I think it was the only delivery system I could have used to enable me to write and upload my blogs automatically, which is the goal I wanted to, and hopefully, now have achieved. Onwards and upwards!