Xinha Open Source Online HTML Editor

I've searched for a good quality HTML editor that I can incorporate in my projects. I want something that is open source, being actively developed and easy for users to understand and use. The control that I found is called Xinha (pronounced similarly to Xena, the Warrior Princess). This control offers a handsome appearance controlled by CSS with an easy to understand and use interface. It overlays an HTML TEXTAREA form field. You can configure it to allow your users the editing features needed for a particular situation. For example, you can decide whether or not to let the user change fonts in the text being edited. Some Xinha features include:
  • Excellent configuration options
  • Plug-ins for additional features
  • Good interface design
  • Good API
Xinha Plugins include:
  • Spell checker
  • Context menu
  • Fullscreen toggling
  • CSS style integration in edited text.
  • Superclean HTML cleaning function
  • Table operations
  • Character map
  • List formatting
The download for Xinha includes demo HTML code. Documentation is currently scant, but hacking the demo code quickly leads to an understanding of how to incorporate and configure the control. The Xinha site includes a pretty fair Newbie Guide.

Reading from and Writing to the Xinha editor with Javascript

Some programming information is difficult to find. I had to do some digging in forums to discover how to read and write to the editor with Javascript. I suspect that a lot of other people have the same problem. In the following code,
  • txtDocument is the TEXTAREA.
  • The second line reads from the editor to my string variable sVariable1
  • The third line writes string variable sVariable2 to the editor.
var editor = xinha_editors.txtDocument; sVariable1= editor.outwardHtml(editor.getHTML()); editor.setHTML(sVariable2); I hope this bit of code will save others a bit of trouble looking for it.


Setting up multiple virtual servers on Apache for web development

I like to develop and test on my local machine and then to upload to the live website server when testing is completed. A little problem I've experienced is that my local Apache server only has one IP address and one website root. I guess this is not so much a "problem" but a typical condition. With only one web server, I cannot test more than one website at a time unless I put each site in a sub directory in the web root. This actually works fine except that I am then forced to use relative path names in the files on the site, which can make for more convoluted logic in some cases and make it more difficult to share common code throughout the site. In any case, I'd like multiple web servers to test with. I could use separate machines, but that would be a waste of resources and be awkward. It is possible to run multiple instances of Apache, but that would not solve name resolution and would not gain any benefits. I'd like the system to be logical and easily extensible so I can add more sites as required. The solution I found is to keep a single IP address and a single Apache web server. I just need to resolve more than one URL to my single existing IP address and then have Apache (listening on port 80 as usual) have multiple virtual servers and take use the correct directory for a given web site name. There are two steps to this solution. Name resolution and creating virtual servers.

Step One: Name Resolution

Usually name resolution is done by a DNS server. This server takes a URL like "www.thecuriousdreamer.com" and returns an IP number (the Internet Protocol address is actually a number, but we humans find numbers more difficult to remember than text addresses). In addition to the DNS server, the operating system has a text file that can be used to resolve URLs.

I need my operating system (Linux in my case) to resolve URLs that I specify to my machine's IP number. This is very easy. I just need to edit the file called "/etc/hosts" to add the names I want to resolve. In this file I found an entry for “localhost” which is standard name for the default Apache web server on a local machine. The entry was: localhost As my machine came, typing “http://localhost” into a web browser would serve up documents in the standard web server on the machine. So I added a couple of lines to the hosts file so this part of it no read: localhost my.thecuriousdreamer.com my.andrewault.net I needed to be root to be able to edit and save the hosts file.

Step Two: Setting up a Virtual Server

I found that Apache will handle virtual servers easily. You just need to modify one setup file called "\etc\apache2\httpd.conf". I found the section for virtual hosts in httpd.conf and added a few more lines. I read about virtual hosting on the Apache site. I learned that the first virtual host that is specified is used by default in case the URL is not resolved by Apache. I wanted to use the existing directory in this case. I added the following lines to the httpd.conf file: <virtualhost> DocumentRoot /home/andrewault/public_html/ </virtualhost> <virtualhost> DocumentRoot /home/andrewault/public_html/www.thecuriousdreamer.com ServerName my.thecuriousdreamer.com </virtualhost> <virtualhost> DocumentRoot /home/andrewault/public_html/www.andrewault.net ServerName my.andrewault.net </virtualhost> The first block of code makes the existing server the default virtual server. The next two blocks each add a new virtual server. Note that I use the target URL except that instead of “www” I use”my”. This allows be to keep the same name and keep my system organized. Notes: You have to restart Apache for these changes to be effected. I just stopped and restarted the Apache daemon, but you could just restart the computer. Also, as with the hosts file, you need to be root to edit the httpd.conf file.


Apache Documentation for Name-based Virtural Servers