Welcome to the new version of European Tribune. It's just a new layout, so everything should work as before - please report bugs here.

Falling into a black hole

by someone Wed Mar 14th, 2007 at 11:44:30 AM EST

This story begins a few weeks back, when I was sitting here in front of this very same computer, reading this very same Eurotrib. There were some comments in various diaries that I though added up to something interesting. As I began my work of copy-paste I quickly grew annoyed. First, copy some text, then slap it in a block quote and provide a link with the author name. These several steps ought to be done by the computer, not me! This is true as well when getting material from other web sites, except then we'd like to link to the main site, and not to as specific content marker as in a comment. Well, we are here, the Word Wide Internet 2.0 is here, Firefox is here, and all the infrastructure to define ones own functionality is in place. Thus my choice was made, and I began what I can only describe as a thrilling fall into the Black Hole that is xul, javascript, and the Document Object Model.


Let me thus introduce you to what I wrested from this bottomless pit of despair.(It's not pretty, this code interface, but it does get the job done once one takes the time to learn how.)
I call it the Update [2007-3-15 5:45:45 by someone]:(new version)TribExt, and it is intended to grow into a site-specific browser extension for Firefox.

Features:
When text is highlighted the right-click context menu has an option to "Copy Html, URL, title" of the page, a command also available using Ctrl-Shift-C. If the selection is made wholly within one comment on the Eurotrib, we copy instead the selected html, name of the comment author, and link to the comment. These are wrapped up in a blockquote, with the author or title providing the text of the link.
Under the "View" - "Sidebar" menu there is a new option called the "Copy Sidebar". It can also be toggled on and off with Ctrl-Shift-S. It contains all the things copied in this manner, and saves its info in a file for when you close the browser. It has a "clear" button, and each copied item has a small red "x" by which it can be discarded. Items are copied to this sidebar regardless of whether it is open or not, they will show when it is opened. The last copied item is also placed on the system clipboard for easy access. The items in the sidebar can be pasted within Firefox with a simple drag-and-drop action into a text area. Oh, and if you hover the mouse over an item it will popup as it would display when pasted.

Having developed thus version 0.1 I am now hoping someone would like to give it a try. So, are you running Firefox? (If not, you really should get it here) If so, would you consider downloading and installing the Update [2007-3-15 5:45:45 by someone]:(new version) TribExt? To do this, download the file to your computer. Then open it with Firefox ("File" - "Open File" == Ctrl-O) which will install it in the appropriate place.

Note that version 0.1 means it is a bit under tested. It might not always copy what you want it to if the html in the selected text is a bit weird. I do filter it right now, and transform into Html allowed by ET comments. (minus div, they gave me some trouble... And images, as they would otherwise be hot-linked.) If you copy a portion of a table you will likely have to slap the html table tags around the <tr>'s and <td>'s. But it should mostly work. I hope.
Two known minor bugs: You have to click the "Clear" button twice for it to have any effect. The ampersand character is turned into its html character code equivalent for display in the copy popup window since it otherwise causes a bit of a mess. This doesn't work right, and the character code (&#38;) is displayed instead. The pasted html doesn't have this problem. The blue text in the sidebar are links, though the pointer doesn't change when you move the mouse over them. They will open the linked page in the currently selected tag in the main browser area if you click on them. Tell me if you find other problems or have ideas of how things should work.

So, if you have some time, please consider giving this a test. I am hoping to do some more interesting Eurotrib content specific extension work later, and some interest from the community would be nice. Use the comments below for testing if you wish. (It is possible to display content from a website any way one wishes! One can in fact assemble content. Thus, client side development will allow for those features I have always wished for the Eurotrib: A page of responses to my comments, sorted by whether I have seen them or not, and responded or not. The possibility to "read" only part of a comment thread and leave the rest of the comments as unread, etc. This can be done entirely on the client side, keeping track of the information locally, and presenting content differently than served. This is all very exciting!)

Examples:
Copied from the Guardian:
Comment is free: A year to change the world

The Guardian's Comment is free website is celebrating its first birthday today with a special series of blogs from dozens of its regular contributors - all giving their own answer to a single question:

What is the one thing you would most like to see happen by this time next year?


(What would I like to see from "Comment is free"?? Some intelligent content, perhaps?)

Copied from an ET comment:
Sven Triloqvist:

That book was largely superceded by the classic work of D. Gital, 'Principals 0f Regressive Enumeration' which unified the Cascading Theories of the 17th century Dutch mathematician Count Backvoord.

Screen shot, with mouse hovering over one of the copied items, displaying its popup. (or "tooltip" as it is called...) Click for larger picture.

I'm looking forward to reading the Eurotrib again now, since I can apparently not both learn a new code interface and read at the same time. And with that, I'm off for a drink! Cheers!

Display:
Sven Triloqvist:
Interesting Finnish poll published today:

40,000 students at 431 further education establishments, high schools etc were polled on party support.

  • The Centre Party 22.6%
  • Coalition (conservative) 17%
  • Greens 13.1 %

The Social Democrats did not do well.

The Finnish Communist Party got 4.4%



"The basis of optimism is sheer terror" - Oscar Wilde
by NordicStorm (m<-at->sturmbaum.net) on Wed Mar 14th, 2007 at 12:01:50 PM EST
Worked pretty good, though it seem to lose a few <li> tags, which I had to add by hand. I did a bit of work creating a Thunderbird extension for a project I was working on. You can do some pretty fun stuff with it...

"The basis of optimism is sheer terror" - Oscar Wilde
by NordicStorm (m<-at->sturmbaum.net) on Wed Mar 14th, 2007 at 12:11:02 PM EST
[ Parent ]
Yes, indeed. I seem to have made a typo in the list of allowed Html. Fixed for next version.
by someone (s0me1smail(a)gmail(d)com) on Thu Mar 15th, 2007 at 02:49:40 AM EST
[ Parent ]
European Tribune - Falling into a black hole
When text is highlighted the right-click context menu has an option to "Copy Html, URL, title" of the page, a command also available using Ctrl-Shift-C. If the selection is made wholly within one comment on the Eurotrib, we copy instead the selected html, name of the comment author, and link to the comment. These are wrapped up in a blockquote, with the author or title providing the text of the link.

Comment is free: Rest is better than a change

QUESTION: What is the one thing you would most like to see happen by this time next year?

No news would be great news.

When you're thinking about a wish-list for the next 12 months, it's tempting to come up with all sorts of pie-in-the-sky possibilities. Rather than world peace, global justice or national sporting success, I have a single wish, which I think is eminently achievable.

by Metatone (metatone [a|t] gmail (dot) com) on Wed Mar 14th, 2007 at 12:29:59 PM EST
This is brilliant!

someone, you're brilliant.

Wow.

by Metatone (metatone [a|t] gmail (dot) com) on Wed Mar 14th, 2007 at 12:30:43 PM EST
[ Parent ]
European Tribune - Falling into a black hole
Let me thus introduce you to what I wrested from this bottomless pit of despair.(It's not pretty, this code interface, but it does get the job done once one takes the time to learn how.)
I call it the TribExt, and it is intended to grow into a site-specific browser extension for Firefox.


The struggle of man against tyranny is the struggle of memory against forgetting.(Kundera)
by Elco B (elcob at scarlet dot be) on Wed Mar 14th, 2007 at 12:52:28 PM EST
By site-specific do you mean European Tribune, or SCOOP, someone?

"It's the statue, man, The Statue."
by Migeru (migeru at eurotrib dot com) on Wed Mar 14th, 2007 at 12:54:32 PM EST
[ Parent ]
Eurotrib. That way I don't have deal with the possibility of different markeup which is what characterises the various ways in which one can interact with site content.
by someone (s0me1smail(a)gmail(d)com) on Wed Mar 14th, 2007 at 02:06:55 PM EST
[ Parent ]
uh-uh : amazing !
Works just fine, links included.

The struggle of man against tyranny is the struggle of memory against forgetting.(Kundera)
by Elco B (elcob at scarlet dot be) on Wed Mar 14th, 2007 at 12:55:27 PM EST
[ Parent ]
I'll try it later this evening, but already, thanks for the effort! It sounds like a great idea!
by afew (afew(a in a circle)eurotrib_dot_com) on Wed Mar 14th, 2007 at 01:36:02 PM EST
I just got home and figured out that on my mac it doesn't work at all unless I change the file permissions for the file that contains the copied info. Look in ~/Library/Application Support/Firefox/Profiles
Unless you have setup multiple profiles it will be in the directory called something.default. You need to run
chmod 700 ~/Library/Application Support/Firefox/Profiles/something.default/extensions/tribext@someone/chrome/content/csb.js
by someone (s0me1smail(a)gmail(d)com) on Wed Mar 14th, 2007 at 02:37:30 PM EST
Melanchthon:
Tony Halme (4.00 / 4)
Since then, he has accused Finnish president Tarja Halonen of being a lesbian, had an unlicensed firearm discharged in his home, resulting in a highly publicised trial, was convicted for DWI, and last year was (involuntarily) committed to a mental institution

He should run for the French presidency...

"Ne te courbe que pour aimer..." René Char

It works perfectly well! I just had to remove: class="commenttitle" fromthe title.

"Dieu se rit des hommes qui se plaignent des conséquences alors qu'ils en chérissent les causes" Jacques-Bénigne Bossuet

by Melanchthon on Wed Mar 14th, 2007 at 03:11:49 PM EST
Thanks a lot, someone!

"Dieu se rit des hommes qui se plaignent des conséquences alors qu'ils en chérissent les causes" Jacques-Bénigne Bossuet
by Melanchthon on Wed Mar 14th, 2007 at 03:22:12 PM EST
[ Parent ]
Sven Triloqvist:
I once did a sketch where I walked on stage with a wooden pizza paddle (thin round thing on a stick that they take out the pizzas from the oven with). I said "kekkoken, kekkoken, kekkoken".  and got a good laugh. It was my first joke in Finnish...

The New York Times - Breaking News, World News & Multimedia

President Bush said today that he was pleased that Attorney General Alberto R. Gonzales had acknowledged mistakes surrounding the dismissals.

I had to clean up the list mark-up on the NYT example (as you said above would probably be necessary). Otherwise, perfect.

What did happen that I don't understand : I had the sidebar open. I copied in the NYT piece. I wasn't sure I had it right, so I copied it a second time (ie chose Copy html etc in the right-click menu, for the second time.) Nothing happened. I supposed Copy 2 had pasted over Copy 1 and moved on to select a piece from a page in The Independent. Clicked the Copy html etc choice in the right-click menu. Got Copy 2 of the NYT in the sidebar. (ie I now had two copies visible of the NYT). Clicked Copy html etc again on the Independent selection. Got four copies from the Independent in the sidebar (above the two from NYT). Got worried about geometric progression and stopped...

I also have a Windows clipboard extension running (Ditto) that stores all clipboard entries in a file. Could there be interference?

by afew (afew(a in a circle)eurotrib_dot_com) on Wed Mar 14th, 2007 at 03:29:28 PM EST
Hmn. I don't know... As I said above, there was a typo that prevents <li> tags from being allowed, but does let </li> tags through. This causes some problems since the html is now broken. (For example, popups don't work for such items.) Try to clear the sidebar. This will restore all the files to default. Do you have a problem copying stuff that doesn't contain lists? I'll fix broken things that popup during the day and put out a new version. I'll install Ditto and see what happens.
by someone (s0me1smail(a)gmail(d)com) on Thu Mar 15th, 2007 at 03:05:46 AM EST
[ Parent ]
Ditto has not yet caused any major problems for me. Though it is clear I need to do some more Html cleanup.
I.e.

Your HTML has the following errors :

  • Attribute CLASS for tag P is not allowed
  • Attribute STYLE for tag UL is not allowed
  • Attribute TYPE for tag UL is not allowed
  • Attribute STYLE="" for tag LI is not allowed
  • Attribute CLASS for tag LI is not allowed
by someone (s0me1smail(a)gmail(d)com) on Thu Mar 15th, 2007 at 03:17:27 AM EST
[ Parent ]
I now have a problem with the search function of the Firefox bookmarks sidebar. It performs the search and brings up the item, but the item is unclickable with either left or right buttons. (Though, if I scroll down to find the item myself, I can click and no problem).

The Firefox version I have installed is 1.5.0.10, not v. 2. Could that have anything to do with it?

by afew (afew(a in a circle)eurotrib_dot_com) on Thu Mar 15th, 2007 at 04:33:08 AM EST
[ Parent ]
Nope, that's a bug on my side. Fixed now.
Fixing problems with lists, allowed attributes, and bookmarks
by someone (s0me1smail(a)gmail(d)com) on Thu Mar 15th, 2007 at 05:13:10 AM EST
[ Parent ]
Yeah, that was what came out of the NYT copy. But I did choose it deliberately because I expected it to have some fancy stuff in there. It wasn't hard to straighten out (take out the CLASS-es and put in the li-s).
by afew (afew(a in a circle)eurotrib_dot_com) on Thu Mar 15th, 2007 at 04:37:54 AM EST
[ Parent ]
I've had no time to play with it yet, but it's very interesting.

I'm not familiar with Firefox extension programming. How do you do that ? (language, IDE, debugger ??) Have you considered open-sourcing your project ?

Pierre

by Pierre on Thu Mar 15th, 2007 at 05:23:21 AM EST
About the Document Object Model - MDC
What is the DOM?

The Document Object Model is an API for HTML and XML documents. It provides a structural representation of the document, enabling you to modify its content and visual presentation. Essentially, it connects web pages to scripts or programming languages.

All of the properties, methods, and events available to the web developer for manipulating and creating web pages are organized into objects (e.g., the document object that represents the document itself, the table object that represents a HTML table elements, and so forth). Those objects are accessible via scripting languages in most recent web browsers.

The DOM is most often used in conjunction with JavaScript. That is, the code is written in JavaScript, but it uses the DOM to access the web page and its elements. However, the DOM was designed to be independent of any particular programming language, making the structural representation of the document available from a single, consistent API. Though we focus on JavaScript throughout this site, implementations of the DOM can be built for any language.

XULPlanet.com

Welcome to XULPlanet

The XML User Interface Language (XUL) is a markup language for describing user interfaces. With XUL you can create rich, sophisticated cross-platform web applications easily.

JavaScript - MDC

JavaScript is a small, lightweight, object-oriented, cross-platform scripting language.

For information about using JavaScript in browsers, please see DOM and DHTML topics. The Gecko DOM Reference describes the host objects available in Gecko-based browsers.

All extensions are open source. They ship as installable xpi's, which is really just a compressed directory structure. Sometimes they contain jar files, which are another type of compressed directory. My extension uses instead directly the source files. (They are interpreted, not compiled.) So, if you install the TribExt you get the source files. Just search for tribext@someone among your files and you'll find the directory with the source files. You will also find that I never comment my code...

by someone (s0me1smail(a)gmail(d)com) on Thu Mar 15th, 2007 at 05:41:44 AM EST
[ Parent ]
OK, I haven't looked into it, but I gather that the .xpi is just a zipped archive of javascript that operates on some sort of syntactic tree for the webpage, with XML describing where to insert action hooks in the general operation of Firefox.

But it must be horrendeously painful to code the scripts in vi, restart firefox to test, etc.. Any thing that gets a little bigger than 30 lines would need hot-swapping of script code, a full blown debugger with step-by-step, variable inspection, test-case replay, etc...

Have you got any of these that you would recommend ?

Pierre

by Pierre on Thu Mar 15th, 2007 at 05:51:18 AM EST
[ Parent ]
Look at this resource first. You really need to setup those prefs!
Setting up extension development environment - MozillaZine Knowledge Base

Then install this:
Ted's Mozilla page - Extension Developer's Extension

The Extension Developer's Extension exists to make life easier for Firefox extension developers. Testing JavaScript code, prototyping XUL layouts, and building XPI packages are all made easier by this extension. Install it and try it out!

I also found it convenient to use a trick to prevent javascript caching to cause a major headache. If one writes a script in a file which is read into a string in another script, and the evaluated with the eval() function there are no caching problems. There is also a convenient javascriptobject.toSource(); For writing evaluatable script strings from object. This comes in handy also because sharing data between different window entities is quite inconvenient. I would say this is also a must read:
Working with windows in chrome code - MDC

Working with windows in chrome code From MDC

This article describes working with multiple windows in Mozilla chrome code (XUL applications and Extensions). It contains tips and example code on opening new windows, finding an already opened window, and passing data between different windows.

It tells you important stuff, like how to get to the top level chrome window, how to access the sidebar, etc. All in all it is a minor nightmare. Not a very logical layout of an object model at all!

by someone (s0me1smail(a)gmail(d)com) on Thu Mar 15th, 2007 at 06:25:53 AM EST
[ Parent ]
Thanx, I'll look into all that someday !

Pierre
by Pierre on Thu Mar 15th, 2007 at 07:35:55 AM EST
[ Parent ]
European Tribune - Falling into a black hole
When text is highlighted the right-click context menu has an option to "Copy Html, URL, title" of the page, a command also available using Ctrl-Shift-C. If the selection is made wholly within one comment on the Eurotrib, we copy instead the selected html, name of the comment author, and link to the comment. These are wrapped up in a blockquote, with the author or title providing the text of the link.

Holy cow.

You're a god.

by Nomad on Thu Mar 15th, 2007 at 06:12:12 AM EST
It is inspiring when someone (and I mean anyone) who enjoys ET, takes the trouble and time to contribute to it in their own way. 'Someone' deserves our real thanks for this.

I'm not a great contributor to political and economic debates, but I love to follow them. For me, it is learning/sharing. But I can be entertaining at times, and even serious, when it gets to art and communications. So that's my contribution. I hope ET continues to be a place where anything can be presented and discussed, and ALL the skills of members can go into the mix - not only content, but management, coding, marketing etc etc - as these are also 'content'.

Great work, someone!

You can't be me, I'm taken

by Sven Triloqvist on Thu Mar 15th, 2007 at 10:08:28 AM EST
[ Parent ]


Display:
Go to: [ European Tribune Homepage : Top of page : Top of comments ]