At bemasc’s brilliant suggestion, I looked to data: URIs for generating files from web pages. I tried it in Firefox and it worked nicely. I even found some examples of very cool usage of data URIs on the web.
But when I tried it in Browse, I hit this bug: #1029. If you look at the dates, I opened that ticket 3 weeks ago. It really took that long to finally find a(n almost) proper solution for it. Of course I did other things as well in the meantime, but you get the point. There’s still the issue of title for the created file, right now it’s the actual data in the URI, which is not very pretty at all.
With that patch, you can save data URIs as Journal objects from Browse and open them in other activities as desired. Here’s a demo. I have yet to create the reverse, opening Journal items in web apps, but it should be possible with either Gears’s openFile or twFile. I consider this outside the scope of GSoC, though.
Oh, and about Gears, I have a workaround, but I probably need to fix my jhbuild.
There is one aspect I haven’t explored during my work: collaboration. bemasc has suggested that web apps already do collaboration quite well (Google Docs, Bespin, Wave), but I am concerned with the case of client-only activities, particularly Karma activities. One possibility is starting local servers in each Browse and using XMLHttpRequest to send data between them. The other choice is adding an API for this in window.sugar and using the existing Sugar collaboration Python API as a backend.
Here’s a screenshot of Browse with Google loaded, running the Black Google userscript:
There are still a lot of rough edges and the editing UI sucks, but I have most of the stumbling-around work done.
As you can infer from the title, I’m quite excited about my latest progress.
Firstly, Browse can now save bookmarklets. When you trigger the palette (right click) on a bookmarklet, the ‘Download link’ option in the palette is replaced with a ‘Save bookmarklet’ option. A new toolbar appears where all the bookmarklets are lined up as buttons. They work rather well and are saved through to SSBs.
Secondly, userstyles now work. There’s a new button in the edit toolbar (I’m open to suggestions about the UI) that opens a small window with a gtksourceview inside. You can write (or copy/paste) CSS in there and click ‘Save’. The CSS is immediately applied to the page and is saved in a file in the activity preferences.
There’s another small feature I’ve added. When you create an SSB, the activity preferences of Browse (without caches and cookies) are saved in the SSB bundle. When first run, they are copied over to that specific SSB’s activity data.
Here are some screenshots:
You can get this commit and try it out.
I’ve wrote a utility script that creates a copy of the current running activity and bundles it in an .xo (thank you Bobby Powers).
I’ve made a small modification to webtoolbar.py in Browse: the ‘create ssb’ button calls the create utility with the current web page title. In the process, I’ve had to also make a change in webactivity.py because the toolbar constructor did not get the activity object passed to the constructor, but the Browser object and I couldn’t find a way to get the title otherwise.
I’ve had a chat with bemasc, and he suggested I keep the ‘create ssb’ functionality in created SSBs. Since activities are immutable, they could instead be ‘curried’, like functions in functional languages. This would require including activity data (get_activity_root()/data) in the bundle and copy-ing it from the bundle on the first run. I’m a bit worried about confusing users with this, though.
I’ve been working on the Customisation toolbar that will be present in SSBs. For this to work nicely, I have to either allow webactivity.py check wether it rus as Browse or an SSB or subclass WebActivity in ssbactivity.py. I’m not yet sure which is the best way to do this.
I’d like some feedback on all this.
[update] Here‘s a created SSB. It includes the modifications I’ve done to Browse.
I’ve been thinking about the user experience for quite a while, but it hadn’t quite crystallised into words before.
To the user, this will be a new button in the Browse toolbar named something like ‘create activity’ or ‘sugarize’. When clicked, a new activity bundle gets created with a custom name. The user has to restart Sugar for the activity to be loaded.
At this time, the SSB has no integration with Sugar beyond being able to be saved to the Journal (what Browse already does for all websites). Some web apps may work offline if they use Gears or gecko LocalStorage. Some may have sounds with <audio>. But there is no functionality that Browse doesn’t have, at least not yet.
It would also be nice to have bundles of customisation that users can create and other can download. Since SSBs don’t depend on anything, perhaps a button in the SSBs ‘save as .xo’ or ‘save as bundle’, which simply archives SSB activity bundle into an .xo (after it has been customised). The .xo can later be uploaded to activities.sugarlabs.org.
So, I will be extending Browse:
- for proper Browse, there will be a new toolbar button for creating SSBs, with a backend script. Let’s call it ‘sugarizer’.
- for the Browse used in SSBs, more stuff: managing userstyles/userscripts, the bookmarklet toolbar. Perhaps other things as well, like forbidding domains not in a whitelist.
For the sugarizer, I was thinking of a manifest in Browse.activity that lists what files from Browse should be in the activity SSB. The sugarizer would also have to replace instances of ‘Browse’ and ‘WebActivity’ in activity.info and the locale files.
- GMail – probably the most complex, its offline feature is almost a unittest for Gears. With a lot of emails, it should show performance issues with Gears in Sugar. It also has several themes (some of which would look alright inside Sugar) and even allows users to choose their own colours.
- Google Calendar – there have been several interface customisations using userstyles and userscripts. It should be easy enough to make one for Sugar
- Google Docs (in particular, writer) – also quite complex, with a lot of Gears usage for the offline feature. Documents are plain HTML 4 (not quite valid), interesting
- MindMeister – very interesting, possible educational value
- Buxfer – impressive web app, seamless use of Gears. option to store the data only on the client with Firefox extension (firebux).
- Passpack – interesting use of client-side encryption (passpack.com can’t see your passwords). Gears for resource caching. 3 offline clients: desktop, AIR and Gears.
- Zoho Writer (and other docs) – much heavier and slower than google docs, interface tries to mimic MS Word and is probably very hard to customize. Plus, I already have an office suite on the list
- Google Books – not much of a web app, I can’t see how it would help to have it in a separate activity
I welcome any feedback and will probably edit the list accordingly.
I really hate my name. I have two surnames, sometimes spelled with a hyphen, sometimes without. Even fellow Romanians often have trouble understanding my name, let alone Brits. It was sooo hard to get the insurance company to admit I had payed for the insurance.
My laptop was (accidentally) damaged, and since it was insured I had to send it to be repaired or it would look suspicious. Its disc drive wasn’t working and the (flimsy) case was bent, but it was otherwise fine. Thankfully, I had a backup (Time Machine) and I use Dropbox for my important files, so none of my data was lost. Quick tip: don’t buy apple products if you can help it (mine was a gift).
Anyway, now I have to use Uni or friends’ computers, most of which run Windows. I’ve got some portable apps in my Dropbox (including portablegit) and I use loads of web services, so for anything but actual development I’m fine. I should be able to develop even if my laptop (or the XO) doesn’t get delivered on time, by borrowing my girlfriend’s computer. There’s also a fedora cluster in the Uni, but I’d probably have to set up a chroot/virtualbox vm.
Since I have less distractions, I’ve had time to think and do some research. I’ve looked at other SSBs and other efforts to add desktop features to browsers and the other way round, to see how they do things. Here’s what I found:
- Adobe AIR – basically a flash element that can embed web pages if it really wants to (ironic, right?). It has some desktop integration features, but it really fails at native look & feel. It provides filesystem access and several ways to store data. Decent security system.
- Prism – very simple SSB. SSBs created with it are applications in the desktop (icons, can have file associations, etc.) and recently they can minimize to the system tray. It has notifications, in the form of systray/dock icon changes and popup alerts. It also has a feature I really want to steal, the Refractor Firefox extension, which allows the creation of SSBs from inside Firefox.
- Gears – very popular for taking web apps offline, especially in open source. It does three important things: local storage via SQLite, WorkerPool and some desktop integration (including some filesystem access). It also very recently got a Geolocation API and it will soon (enough) get a Notifications API. What I really like about it is its non-intrusiveness. It adds some features that are really needed for developing web applications to most browsers that matter (including some mobile ones) without a separate runtime or alien technologies. Google Chrome uses Gears to create SSBs, but they don’t really do much besides being separate windows with no chrome (no systray, no notifications).
Wishlist for Webified:
- An option in Browse to ‘create new activity from this website’
- Gears, saving its state to the Journal.
- GreaseMonkey and Stylish (or perhaps steal Prism’s?) – essential for customisation and native look & feel
- Bookmarklets as toolbar buttons. There are tons of bookmarklets out there and they are used in the same way toolbar buttons are, they just usually reside on another bar.
- Ability to install bundles of userscripts, userstyles and bookmarklets to make SSBs more sugar-y. Or perhaps even include bundles for very popular websites. A bit like Prism’s bundles, but not necessarily with stuff specific to Webified.
This is just a wishlist, I probably won’t be able to get everything done during GSoC. My plan outlined here stays mostly unchanged. But I have had time to think more about these things and how I’d like them to work.