Update on 11/25/2007: today this article presents mostly historical interest. Since Dojo 0.2 a lot of versions were published and many things were changed. At the time of this writing Dojo is at ripe 1.0. I had to disable all Ajax action in examples because I don’t use Dojo 0.2 anymore.
What is Filtering? It is a selection of items using some criteria (filter). In this tutorial I am going to filter documents of my blog (made with Django
, of course) matching titles against user-specified substring. Later on I’ll talk about generalization of this approach.
Dojo 0.2.1
is out. This is a maintenance release, which doesn’t change API but fixes some pesky bugs. Go and get it.
Many programmers have DIY
attitude. It is understandable: they want to do new exciting stuff themselves. In some cases it is perfectly reasonable: exotic functionality, special requirements, performance enhancements, and so on. Sometimes incorporating 3rd-party library makes overall API inconsistent, which is bad especially for programming tools, or big projects.
There is a fine line between DIY and NIH
, when DIY part is used without rational explanations. Of course, in some cases NIH is reasonable too, e.g., high price of acquisition of required 3rd-party tools, or intellectual property concerns.
Three weeks ago we had a discussion about Ajax support in Django, which resulted in "Ajax and Django"
wiki page. A short recap: it lists a vague goal, some general considerations, and possible strategies; it scratches the surface of existing implementations (mostly RoR), existing third-party toolkits (Mochikit/Dojo), and related RPC-style and REST-style services. No code was produced, no consensus was reached, but now it is a part of Django’s Version One roadmap
.
Finally I released WebUI 0.1 (Homunculus) alpha — AJAX-based web interface for OpenWrt
made with Dojo
! Highlights of this release: 5 more applets including firewall configurator and more network settings. Now proceed to install the package and to read release notes.
The package is here: webui-0.1-alpha.ipk
. You can install it using following command in OpenWrt shell:
ipkg install http://lazutkin.com/download/webui-0.1-alpha.ipk
Release notes:
- WebUI can be installed side-by side with webif (comes standard with OpenWrt White Russian RC4). To access it use following URL: http://your_router/webui.html.
- Five more applets are added to this release:
- System: provides a menu for existing applets.
- Firewall configurator: simple management of DMZ and port forwarding.
- Hosts configurator: manages a list of static hosts (used by DNS and by Firewall configurator).
- Ethers configurator: manages a list of static assignment of IP by MACs.
- WDS configurator: manages WDS connection settings.
- General clean up of user interface:
- More information is moved to tooltips.
- Help is provided by tooltips.
- Context-specific references to OpenWrt documentation.
- Tested on following browsers:
- Firefox: works.
- IE6: works.
- Opera 8.50: doesn’t work.
- Konqueror: doesn’t work.
- I decided to proceed with release in spite of Konqueror and Opera problems. I hope it will be solved later. For now use Firefox.
- As always I appreciate your feedback: openwrt [@] lazutkin [.] com.
I didn’t have a lot of time this weekend. So I decided to implement the simplest part of upcoming OpenWrt GUI (webui) — hosts editor. It is a perfect candidate to write something in 15 minutes or less — it has almost no "business" logic in it: read/edit/verify/write cycle. The hardest part was to learn how to upload dynamically generated files without writing them to disk first.
It turned out to be very simple. Right now it is implemented using Dojo
’s versatile dojo.io.bind()
facility and some external code.
Update: this document is officially obsolete — alpha is released
!
Finally I released a preview: /webui-0.1-pre-alpha.ipk!
I included two information applets and a simple network configuration applet. I think it would be enough for a proof of concept. I borrowed heavily from nbd’s webif
. So if it works for you, it is due to his OpenWrt expertise. If it doesn’t, it is my fault.
Both webif and webui can be installed side by side:
Finally I found time to finish it up. It is pre-alpha quality now, but shows the direction.
The only problem is a packaging. I didn’t mean OpenWrt
’s IPKG. I am talking about creating a custom build of Dojo
to reduce the foot print. Dojo has a special provision for that but so far I was not able to do it getting some strange errors. I hope I’ll get some help from developers.
I was able to spend several hours this week to work on upcoming OpenWrt
GUI. I use Dojo
as a foundation. At this point I coded a skeleton, which works as a proof of concept. As soon as I finish putting in AJAX guts, I’ll switch to meaty functionality. Add some nice skin to it and we have our homunculus
up and running.
Huh? AJAX? No, it’s not Ajax the detergent
. No, I didn’t mean Ajax the pro soccer club
. "Now I clearly remember that AJAX is a Trojan, and I don’t like Trojans and viruses" — clever, but no. Go see the movie
about Greek heroes and the Wooden Horse. And let’s skip "Trojan" discussion altogether — I’m trying to be PG-13 rated.
Finally I bit the bullet and decided to implement OpenWrt
web-based user interface using Felix Fietkau
’s code. Well, MIPS processors used by OpenWrt units
are not race horses and GUI is slow to my taste. Yes, I know that stock firmware is not faster. "Slow" is absolute category for me.
How do we combat latencies and slow network speed? Exactly. We can apply the same for OpenWrt, where "slow network speed" is replaced with "slow processor on local network". So I decided to do The Right Thing(tm) and implement it using AJAX approach. I will use Dojo
.
I decided to try how well Opera
works with my site. It mostly works. You can go and see stuff but all Dojo-related code doesn’t work. Interesting that Google Maps works properly.
When I switched to admin mode to edit this article, it turned out that TinyMCE
doesn’t work either.
But good news is Dojo and TinyMCE failed gracefully.
The best thing about Dojo 0.1: it’s quite easy to create portable widgets. Such widgets work similar to Microsoft IE’s behaviors but they are even more self-contained. Dojo widgets can work with fragments of HTML and CSS, which will be inserted during the object creation. The event system is very elaborate. Of course Dojo is more than a simple widget factory. For example I didn’t try the I/O facility yet.
New design is here. Well, some elements of it. I had bigger ideas, but CSS didn’t work reliably, and JavaScript option was in debugging mode. So I decided to update this site now and add other planned stuff later.
One reason I postponed JavaScript thingy is I want to try Dojo
. It looks like a good foundation for widgets. I am going to create a couple of them at least. If it works okay, I’ll be using it in other projects as well. Stay tuned.