Frontpage          Newsfeed          Search     

A tool for them long posts ..
I wrote this tool some months ago while developing on the xPresso publishing system (NO), and has done some rewriting this week to implement further functionality.

The Codificator now provides:
- automatic code wrapping in DC board format
- conversion of regular HTML-formatted text to DC board formatted text
- link extraction from HTML to DC board format
- auto fetch of webpages, with on-select conversion of content to DC board format.

It won't boil your coffee or knit you a warm sweater for the winter, but it may help you to be more efficient when you're online discussing politics.
Published: 18.11 - 2007 00:56Printer version    
Knut Møgster

BreakdownThe Codificator main form is a replica of the DC board post form, but has a additional row of buttons for the auto-wrap functions. It uses client side scripts only (Javascript) and does not require serverside scripting at all.
The original version is here, with all code needed for it to run inline in the html-file.

The online version w/tools
I rewrote the main form this week to fix a Firefox bug, and also included some tools to convert HTML to DC-board format.
To use this form:
As you write, you can use the buttons to insert code to the form, and also wrap marked text with code.

The Preview is a window transforming the DC-code back to html to enable you to see how your post is coming on. When you're done, click Select text, then copy and paste it into the board where you are debating.
The actual use should be easy enough to understand as this is very much like similar routines used in phpBB and other board systems.

It is tested in IE and Mozilla Firefox for Windows, let me know if you use it in other browsers and how it works.

Here's a screenshot of the main form in my FF browser.

The Codificator Tools

I often write long blog posts and articles and has for some time pondered to make a conversion tool from HTML to DC board format. If I wanted my blogged inline links in the discussion text, I'd have to 're-code' them to DC format.
And why not post the whole blog post/article to the debate forum fray? After all, I'm the author of the material.
And of course, it was the technical challenge ;-)

The Convert tool

The idea was to do it as quick and simple as possible to convert the code, without too much fuss and lengthy technical explanations. So this is what I came up with; a form where you paste the text to convert in the upper text area, then click a button to convert it into DC code in the lower text area.

Pasted HTML text converted to DC board formatted text.
The conversion is performed automatically by clicking the Generate DCcode button. One may choose whether the code is line separated by the BR-tag or by linefeed.

Pasted HTML text - link extraction.
This is performed by clicking the Extract links button.
This extract all links from the HTML coded text and makes a list of clean links.

Pasted HTML text - link extraction.
This does the same as the above, but provides the links with link text.

There is also a function for returning the post as pure text, but this will probably not revolutionize the internets as this is what you get when you copy the text straight from the web page anyway.

The text in the upper field stays, so one can use one or more of these functions without too much copying and pasting. Note that the text in the lower field is autogenerated, so don't start writing the actual post there - select the text when you're done and copy it into the main form for further 'processing'.
The text is printed in a layer below the form. The layer content is read by a javascript, and used for the conversion procedure, so the layer content will change after which procedure you've asked it to perform.

The Fetch and Convert tool

OK, so I wanted some deeper codification challenges and this was it.
Was is possible to actually fetch a web page by PHP, select the text with your mouse and then process the selected HTML code to DC board code?
As it turned out, it was.

The Fetch and convert script uses Javascript and something I've dubbed 'Cheat Ajax', you can read more about it here.
It utilizes a short PHP script to fetch the url and returns the content at the url in a layer, Ajax style (no page reload). It's a really neat routine, I think.

Here's the routine explained, I've used the same article as in the example above.

Step one: Paste the url into the url-field and click Fetch content. It will appear as escaped HTML-code in the layer right below the field. The PHP-script used to fetch the web page strips all html-tags except links, bold and italic.
In the next step, the code becomes visible.

Step two: Click Make HTML to convert the code to readable format. You now need to scroll down to find the part you want to process.

Step three: Mark the text you want to convert to DC board code. You should note that you must mark 15 chars of clean text at the top and bottom of your selection. That means: no links, bold/italic tags or linebreaks must be among the first 15 and the last 15 chars if the selection is gonna be successful. When you've marked the text you want, click Process selected to go to step four.

Step four: The DC formatted code is generated. You can now process the text as in the previous tool; DC coded text, extract links and so forth. Your selections stays in a hidden field, so you can test several without reselecting.
If you do need to reselect, there's no need to fetch the page again; just click Restore page to put the original fetched content into the select area.
When you're done, clean the DC code for any residues you don't want, click Select below the DC code area and copy the text into the main form.

This tool uses html forms, javascript and a small php-script to fetch the data from the url specified.

All in all some useful tools for the savvy debater. I might write some more tools later, and will probably update the Fetch and Convert tool as time goes by.
Please let me know if you discover any bugs.

UPDATE: I have updated the Fetch and Convert tool with a new function that allows for converting all fetched code to DC code. That means this tool will have an additional button to the buttons shown in the screen shots.

The Codificator in xPresso.
Much the same, but it does produce html, not DC code, and has some additional functions.

Online version
The url for the online version of the Codificator is:

The scripts

The Codificator consists of the following files:


For convenient download, I've zipped it together:

To install: Just copy the scripts to your server. If you're gonna use the Fetch and Convert script, your server need to run PHP software.
NOTE: The PHP script must have executable rights set for the webserver, not only as ordinary PHP scripts; for the PHP parser. The reason is that it's included and run by Javascript, not PHP. You can change owner of the file to the webserver owner (as the user nobody for Apache).
Note on the pop-up tools: Don't edit the html-code of them to include links, in any form. The routine for converting uses the javascript link-object to validate, and if any links is found in the html-code, it will be included in that check and the script will err.

If you just want the main form with all code needed included in one page:
To install: If you're gonna implement it into the DC board post form, replace the subject input field and message text area with the corresponding script elements, include the script (and css) in the header, and your'e ready to go. It shouldn't be too hard, it's very little html code, mostly Javascript.

The DC Forum website is here:

The DC Forum software is in use at several political forum sites, most notably the Democratic Underground (DU), where I hang out for my daily political fix.
Hence the name of this tool; the DU-o-matic Codificator ;-)

 facebook    digg    reddit    furl   



Peace demonstrations in the US October 26-28 2007
29.10 - 2007


Large number of US citizens demonstrated against the war in Iraq (and the possible war in Iran) during this October weekend. Massive turnout in Boston and San Fransisco, and also in Chicago, LA and DC people took to the streets.
The message was: NO more war in Iraq! NO to a war with Iran!