Archive for the 'Web' Category

Page 3 of 4

Website update

I've just recently added an 'Gallery' section to the site, finally.  There used to be one on my old site but I never quite got round to adding it to this one.  There are some funny pictures up – hopefully more to come soon.

WordPress and WYMeditor

EDIT 22/04/08:
If you use the latest versions of WordPress, Admin SSL and Simple WYMeditor, then this workaround is no longer necessary.

I currently use WordPress to publish my blog, and I recently discovered that there is a plugin () that lets you use my favourite online text editor – WYMeditor – to write blog posts.

So far so good – but I encountered a problem.  I enabled the plugin in WordPress but nothing happened.  Then I discovered that another plugin I use – Admin-SSL, which unsurprisingly secures the WordPress admin pages – was not securing pages from the /wp-content/ directory, which is where the plugins are.  The page was trying to call the WYMeditor plugin script using an unsecured link, which was causing it to break.

So I added the following code to admin-ssl.php at line 370:

370	$content_url = get_option("siteurl") . "/wp-content";371	$secure_content_url = $secure_url . "/wp-content";372	$replace_this[] = $content_url;373	$with_this[] = $secure_content_url;

This fixed the first problem.

However I noticed that the autosave function was not working either.  Apparently some people find it annoying, but I find it extremely useful while I'm writing blog posts.  After spending ages looking through the code of the WYMeditor plugin, through the WYMeditor documentation, and the autosave() function in WordPress, I found a way to fix it.

There is an HTML textarea element called 'content' which WYMeditor replaces, and which WordPress uses to get what you are writing.  When you click the 'Save' button, WYMeditor updates that textarea element with whatever you've written, and WordPress saves it.

However, the WYMeditor plugin only updates the textarea element when you click the save button, so the autosave() function doesn't work – when it looks at the 'content' textarea element, it's empty.  What we need to do, then, is automatically update the textarea element when the autosave() function is called.  Thankfully, WYMeditor has an inbuilt function to do this, called update().

Two things need to be done.  First, open simple-wymeditor.php, which is the main file for the WYMeditor plugin (it's probably in /wp-content/plugins/simple-wymeditor/).  Comment out lines 143 and 168, to look like this:

143	//jQuery( function() {...168	//});

This allows us to access the WYMeditor functions through jQuery.  Save the file and close it.  Now open the WordPress autosave.js file (in /wp-includes/js/).  At line 98 insert the following:

98	if(wym = jQuery.wymeditors(0)) wym.update();

This updates the 'content' textarea element if it can find a WYMeditor object, so the code won't break if you disable the WYMeditor plugin.

So there you have it – my WordPress now works with the WYMeditor plugin, and I'm very happy, and very tired after a couple of hours reading other people's code!

Addendum

In writing this post I used <pre></pre> tags to display the code.  Due to a bizarre filter, WordPress doesn't let you do things like have <br/> tags inside <pre></pre> tags (and many more such combinations).  So the code above, although one block of it is on four lines, WordPress was displaying it all on one long line, having stripped out the <br/> tags.

Cue much more learning of WordPress and code-reading – I now have two plugins.  The first removes the 'wpautop' filter from the 'the_content' and 'the_excerpt' tags.  This stops WordPress stripping tags that it shouldn't – now I'm using WYMeditor it is unnecessary anyway, because it creates XHTML.

The second plugin replaces all the curly quotation marks that WordPress 'helpfully' adds in with straight ones.  Sigh – at least I'm much more aware of how WordPress works than I was!  It's an absolute beast – functions and classes all over the place.  I'm sure it isn't necessary for it to be so complicated.

Broadband

At last! The great broadband scam is being curtailed by Ofcom, and not a moment too soon. The old 'up to 8mb' line so beloved of broadband providers has finally come under harsh criticism by Ofcom.

The recommendations are that on purchase, customers are advised of the likely speed they will actually get, and be able to switch to a lower/cheaper/different package if they do not receive that speed in the first two weeks.

However, what they don't address, and which is a bigger problem for me, is line contention. During the day the speed of my broadband at home (Tiscali up to 8mb, never more than 4mb) is absolutely fine. But in the evenings, and at weekends, it is pitifully slow. I mean so slow that simple web pages like the Google home page won't load. The reason is that you share your broadband 'pipe' with, usually, 30-50 other people. Therefore, if everyone uses it at the same time (such as evenings and weekends) the speed drops dramatically.

As more and more people use broadband, I would like to see companies do something about this. My previous broadband provider, plus.net, had a specific policy whereby they prioritised normal web traffic, such as viewing websites, so we were always able to check the news at a decent speed and check our emails, no matter what time it was. The trouble is, with so many online TV and video services, streaming is becoming more popular, and using up loads more bandwidth that was previously the case. I'm not interesting in streaming – but I am interested in fast email, and fast browsing.

jQuery UI

My favourite javascript framework, jQuery, has recently released jQuery UI, a set of user interface javascript components. These can be used for displaying websites, having sliding menus, sortable tables, that kind of thing. All of it is written for you!

I've had a look at them, and the ones I'm most interested in are the sortable tables, 'accordion', and calendar. If you want to see a demo of how these work, click on 'See the Demos' on the jQuery UI home page. Don't be surprised if some of these make it onto my website at some point..!

However, the best UI component is the gallery – don't be surprised if you see that on the site very soon.

New Website

It has been a long time (nearly two years) since I last updated my website. I have been working on something for ages – then I recently got fed up and used a template for another site I wrote last year! I hope you enjoy using it as much as I enjoyed setting it up. It looks best in Firefox and Internet Explorer 7.

Everything is searchable, as before, but I have added a lot of new content – most of the sermons I've preached, and a few of my best essays. I will continue to add new things, particularly to the Essay and Sermon sections.

Please have a play with the site – if you particularly like something, break anything, or have a suggestion for any improvements, please let me know and I'll see what I can do!

Gmail Storage

So in the last four or five days, the storage on my Gmail account has shot up from 2.8Gb to just under 3.6Gb! I should have bought some shares in Seagate or Western Digital..

Top Web Development Tools (Pt. 2)

Part 1: Applications
Part 2: Code Libraries/Resources

6. Smarty

Separating form from content is a holy grail in web design – it allows you to update the user interface of a website without altering how it works. You can even have different colour schemes or skins. Smarty is a template engine for PHP which forces you to separate form and content. It is easy to use, quick to master, and has good documentation.

7. jQuery (not Prototype)

Writing JavaScript can be frustrating at best. Using a JavaScript framework (there are many available) makes things quicker and easier, and they often include simple to use Ajax funcionality. The most common (thanks to Scriptaculous) is Prototype, but I prefer jQuery. It is much smaller, and has similar effects to Scriptaculous (although, admittedly, not as many). It also (I think) has a more logical structure.

8. WYMeditor

WYSIWYG text editors are the scourge of web developers. They often create hideous code and don't work properly, no matter what they claim, and allow users to define what their text looks like, rather than your template. Cue WYMeditor, an What-You-See-Is-What-You-MEAN editor, which creates perfectly structured XHTML code. It allows the user basic formatting tools (bold, italic etc) but not font, size, colour etc. Instead, the user chooses a style type (heading, paragraph, list etc), which can fit into your template easily.

Added to that, it works extremely well, and uses jQuery. It's brilliant!

9. Behaviour

Adding JavaScript events to HTML is as simple as CSS with the Behaviour framework. It is faster than any full JavaScript framework, and works like a charm. I use it in all my projects, and highly recommend it. The script file is small as well, especially if you pack it.

10. JavaScript Packer

If you include JavaScript files in your websites, you'll want to reduce their size as much as possible. Enter Dean Edwards' JavaScript Packer. It hugely reduces the size of JavaScript files, without losing any functionality. I love it.

That's it for now – there may be a part 3, in which I will add any new tools. I hope that someone at least has found these two useful!

Categories

Twitter

Recent Comments

Archives