Keyvan Minoukadeh http://www.keyvan.net Mon, 23 Aug 2010 22:45:46 +0000 en hourly 1 Jeff Schmidt on Academic Freedom http://www.keyvan.net/2010/08/jeff-schmidt-on-academic-freedom/ http://www.keyvan.net/2010/08/jeff-schmidt-on-academic-freedom/#comments Mon, 23 Aug 2010 00:25:32 +0000 Keyvan http://www.keyvan.net/?p=1277 Jeff Schmidt, author of one of my favourite books (Disciplined Minds):

“Intellectual workers don’t need academic freedom to service the status quo, which is what they’ve been hired to do, but they do need academic freedom to do what they should be doing, which is questioning what they’ve been hired to do and working instead in the public interest. If salaried intellectual workers want to make a difference in the world, if they want to make the world a better place, then they have to do things beyond the service work that they’ve been hired to do. That’s what activists do: things that they weren’t hired to do.”

The clip below is from his talk at the Frederic Ewen Academic Freedom Center’s 2nd Annual Conference at New York University on April 3, 2009.

]]>
http://www.keyvan.net/2010/08/jeff-schmidt-on-academic-freedom/feed/ 0
PHP Port of Arc90′s Readability http://www.keyvan.net/2010/08/php-readability/ http://www.keyvan.net/2010/08/php-readability/#comments Mon, 09 Aug 2010 23:41:07 +0000 Keyvan http://www.keyvan.net/?p=1199 Last year I ported Arc90′s Readability to use in the Five Filters project. It’s been over a year now and Readability has improved a lot — thanks to Chris Dary and the rest of the team at Arc90.

As part of an update to the Full-Text RSS service I started porting a more recent version (1.6.2) to PHP and the code is now online:

For anyone not familiar, Readability was created for use as a browser addon (a bookmarklet). With one click it transforms web pages for easy reading and strips away clutter. Apple recently incorporated it into Safari Reader.

It’s also very handy for content extraction, which is why I wanted to port it to PHP in the first place. Here’s an example of how to use the PHP port:

require_once 'Readability.php';
header('Content-Type: text/plain; charset=utf-8');

// get latest Medialens alert
// (change this URL to whatever you'd like to test)
$url = 'http://medialens.org/alerts/index.php';
$html = file_get_contents($url);

// PHP Readability works with UTF-8 encoded content.
// If $html is not UTF-8 encoded, use iconv() or
// mb_convert_encoding() to convert to UTF-8.

// give it to Readability
$readability = new Readability($html, $url);

// print debug output?
// useful to compare against Arc90's original JS version -
// simply click the bookmarklet with FireBug's
// console window open
$readability->debug = false;

// convert links to footnotes?
$readability->convertLinksToFootnotes = true;

// process it
$result = $readability->init();

// does it look like we found what we wanted?
if ($result) {
	echo "== Title ===============================\n";
	echo $readability->getTitle()->textContent, "\n\n";

	echo "== Body ===============================\n";
	$content = $readability->getContent()->innerHTML;

	// if we've got Tidy, let's clean it up for output
	if (function_exists('tidy_parse_string')) {
		$tidy = tidy_parse_string($content,
			array('indent'=>true, 'show-body-only'=>true),
			'UTF8');
		$tidy->cleanRepair();
		$content = $tidy->value;
	}
	echo $content;
} else {
	echo 'Looks like we couldn\'t find the content.';
}

Differences between the PHP port and the original

Arc90′s Readability is designed to run in the browser. It works on the DOM tree (the parsed HTML) after the page’s CSS styles have been applied and Javascript code executed. This PHP port does not run inside a browser. We use PHP’s ability to parse HTML to build our DOM tree, but we cannot rely on CSS or Javascript support. As such, the results will not always match Arc90′s Readability. (For example, if a web page contains CSS style rules or Javascript code which hide certain HTML elements from display, Arc90′s Readability will dismiss those from consideration but our PHP port, unable to understand CSS or Javascript, will not know any better.)

Another significant difference is that the aim of Arc90′s Readability is to re-present the main content block of a given web page so users can read it more easily in their browsers. Correct identification, clean up, and separation of the content block is only a part of this process. This PHP port is only concerned with this part, it does not include code that relates to presentation in the browser — Arc90 already do that extremely well, and for PDF output there’s FiveFilters.org’s PDF Newspaper.

Finally, this class contains methods that might be useful for developers working on HTML document fragments. So without deviating too much from the original code (which I don’t want to do because it makes debugging and updating more difficult), I’ve tried to make it a little more developer friendly. You should be able to use the methods here on existing DOMElement objects without passing an entire HTML document to be parsed.

]]>
http://www.keyvan.net/2010/08/php-readability/feed/ 7
JavaScript-like innerHTML access in PHP http://www.keyvan.net/2010/07/javascript-like-innerhtml-access-in-php/ http://www.keyvan.net/2010/07/javascript-like-innerhtml-access-in-php/#comments Mon, 26 Jul 2010 00:40:23 +0000 Keyvan http://www.keyvan.net/?p=1175 As part of an update to the Five Filters Full-Text RSS service, I’ve been porting some JavaScript code (Arc90′s current version of Readability) to PHP. It contains a lot of DOM manipulation which translates very easily – thanks to PHP5′s DOM support. But one thing I wasn’t able to do was manipulate the DOM tree through the innerHTML property.

In JavaScript, it’s very easy to do. The Mozilla Developer Network’s page on innerHTML gives the following example:

var content = element.innerHTML;
// Returns a string containing the HTML syntax describing all
// of the element's descendants
element.innerHTML = content;
// Removes all of element's descendants, parses the content
// string and assigns  the resulting nodes as descendants of
// the element.

Using PHP’s magic getter and setter methods, it’s possible to extend DOMElement to achieve this type of access and manipulation. My attempt at doing it is JSLikeHTMLElement. Here’s an example of how to use it (with relevant lines highlighted):

require_once 'JSLikeHTMLElement.php';
$doc = new DOMDocument();
$doc->registerNodeClass('DOMElement', 'JSLikeHTMLElement');
$doc->loadHTML('<div><p>Para 1</p><p>Para 2</p></div>');
$elem = $doc->getElementsByTagName('div')->item(0);

// print innerHTML
echo $elem->innerHTML; // prints '<p>Para 1</p><p>Para 2</p>'

// set innerHTML
$elem->innerHTML = 'FF';

// print document (with our changes)
echo $doc->saveXML();

Download: JSLikeHTMLElement.php. Feedback appreciated.

]]>
http://www.keyvan.net/2010/07/javascript-like-innerhtml-access-in-php/feed/ 2
Propaganda, State Religion and the Attack on the Gaza Peace Flotilla http://www.keyvan.net/2010/06/propaganda-state-religion-and-the-attack-on-the-gaza-peace-flotilla/ http://www.keyvan.net/2010/06/propaganda-state-religion-and-the-attack-on-the-gaza-peace-flotilla/#comments Sun, 13 Jun 2010 14:51:58 +0000 Keyvan http://www.keyvan.net/?p=1164 Another excellent alert from Medialens: Headshot – Propaganda, State Religion and the Attack on the Gaza Peace Flotilla. It compares the media reaction to the Israeli killing of activists with the reaction towards the 2007 incident involving British sailors being detained by Iranian forces.

…media coverage of the non-violent Iranian capture of 15 British sailors (in Iranian waters) focused on the humiliating failure of the sailors to open fire in self-defence. Journalists took a very different view of the May 31 Israeli attack on the ship Mavi Marmara carrying human rights activists and supplies to the besieged population of Gaza.

In this case, the key question was not why the activists failed to open fire (they had no guns) on their approaching kidnappers, but whether they used lesser violence – hitting with sticks and poles – before the commandos opened fire killing nine people and wounding several dozen more.

]]>
http://www.keyvan.net/2010/06/propaganda-state-religion-and-the-attack-on-the-gaza-peace-flotilla/feed/ 1
WordPress Blog to PDF http://www.keyvan.net/2010/06/wordpress-blog-to-pdf/ http://www.keyvan.net/2010/06/wordpress-blog-to-pdf/#comments Thu, 10 Jun 2010 23:30:06 +0000 Keyvan http://www.keyvan.net/?p=1143 If you’d like to turn your WordPress blog content into a printable PDF in newspaper format, there’s now a solution for you: Make PDF Newspaper by Martin Hawksey. It makes use of the FiveFilters.org PDF Newspaper source code.

Developing a plugin like this has been on my todo list for the FiveFilters.org project for a while now. To give a little background, one goal of the project is to encourage users to explore the world of non-corporate media, and to do that we’re developing tools and services to make content on the web a little more accessible. One area of development has been the PDF Newspaper project which can take feed or HTML input and turn it into a printable PDF in newspaper format. But while the service at FiveFilters.org has been up and running for over a year now, bloggers have not had a convenient way to generate and offer their content in PDF format directly from their blogs.

I’m happy to say that a few days ago Martin Hawksey got in touch to say he had integrated the FiveFilters.org source code into a WordPress plugin. Martin had previously released the Make Tabbloid plugin which did something similar using HP’s Tabbloid service (in fact, my own plan for the plugin was to build on Martin’s work). HP, however, pulled API access to the service earlier in the year without warning – breaking any application that depended on it (one risk of relying on closed, cloud-based services, but more on that in another post). The Newspaper PDF project was started to offer users a free software (open source) alternative to HP’s service, so I’m very happy that the work has now been extended to the WordPress platform. Thanks Martin!

For a full list of features and an example of the PDF output, please visit Make PDF Newspaper.

I tested the plugin on this site a little earlier, following the installation steps, and it worked without any problems. To see the output, you can view the generated PDF for this blog.

]]>
http://www.keyvan.net/2010/06/wordpress-blog-to-pdf/feed/ 2
John Thackara on Design Schools http://www.keyvan.net/2010/06/john-thackara-on-design-schools/ http://www.keyvan.net/2010/06/john-thackara-on-design-schools/#comments Tue, 08 Jun 2010 21:52:55 +0000 Keyvan http://www.keyvan.net/?p=1139 From an interview with John Thackara on Wodcast (via Guilhem):

I don’t think that one should abolish design education, I think one needs skills, we definitely need places and times to reflect and to stand back from reality. It’s just that the way that schools have evolved in the last period is that they tend to be a silo rather than a cauldron of interesting activity.

]]>
http://www.keyvan.net/2010/06/john-thackara-on-design-schools/feed/ 0
UID Design Talks http://www.keyvan.net/2010/06/uid-design-talks/ http://www.keyvan.net/2010/06/uid-design-talks/#comments Tue, 08 Jun 2010 00:42:14 +0000 Keyvan http://www.keyvan.net/?p=1127 I spent most of last week in Umeå listening to the design talks and seeing the student exhibition at the Umeå Institute of Design. The students presenting and showcasing their work were from four different programmes: Industrial Design (BA), Advanced Product Design (MA), Transportation Design (MA) and Interaction Design (MA). The invited speakers, Chris Bangle and Alex Padwa, were from the car world and not very interesting.

The Interaction Design students presenting were:

  • Tae-yeol Lim with a tangible device and medical doll to help patients overcome the language barrier when communicating with doctors.
  • Chao Wang with a system to help the local Red Cross group get its events publicised and encourage more volunteering.
  • Linda Bresäter with an interactive tree to help large organisations share their ideas and gather feedback.
  • Ruedee Sarawutpaiboon with a playful system to allow people to share their feelings and emotions anonymously.
  • Sisirnath Sangireddy with a digital toolkit for teachers.

The Interaction Design students at UID also maintain a blog at interactiondesign.se.

]]>
http://www.keyvan.net/2010/06/uid-design-talks/feed/ 0
Vanunu to Face Jail http://www.keyvan.net/2010/05/vanunu-to-face-jail/ http://www.keyvan.net/2010/05/vanunu-to-face-jail/#comments Sat, 15 May 2010 01:19:53 +0000 Keyvan http://www.keyvan.net/?p=1122 Amnesty (via Craig Murray):

Amnesty International is urging the Israeli government not to imprison nuclear whistleblower Mordechai Vanunu, who is facing a return to jail within days.

The Israeli Supreme Court ruled on 11 May that Vanunu, who served 18 years in prison for revealing information about Israel’s nuclear programme, must serve a further three months for meeting a foreign national, a violation of the restrictions imposed on him by the military since his release.

Vanunu, a former technician at Israel’s nuclear plant near the southern town of Dimona, revealed details of the country’s nuclear arsenal to the Sunday Times in 1986.

Philip Luther, Amnesty International’s Deputy Director for the Middle East, said: “If Mordechai Vanunu is imprisoned again, Amnesty International will declare him to be a prisoner of conscience and call for his immediate and unconditional release.”

]]>
http://www.keyvan.net/2010/05/vanunu-to-face-jail/feed/ 0
David Cameron: The New Prime Minister http://www.keyvan.net/2010/05/david-cameron-common-people/ http://www.keyvan.net/2010/05/david-cameron-common-people/#comments Wed, 12 May 2010 19:12:37 +0000 Keyvan http://www.keyvan.net/?p=1106

From The Tory press and “democracy”:

That Labour is widely detested is beyond question. It deservedly received its worst vote share since 1983… What stands out above all from the results is the alienation of the majority of the population from the official parties.

From Voting in Britain for war. Take your pick by John Pilger:

All three party leaders are warmongers. Nick Clegg, the Liberal Democrats leader and darling of former Blair lovers, says that as prime minister he will “participate” in another invasion of a “failed state” provided there is “the right equipment, the right resources”. His one condition is the standard genuflection towards a military now scandalised by a colonial cruelty of which the Baha Mousa case is but one of many.

From Culture and Nationalism by Rudolf Rocker (quoted by Medialens):

We speak of national interests, national capital, national spheres of interest, national honour, and national spirit; but we forget that behind all this there are hidden merely the selfish interests of powerloving politicians and money loving business men for whom the nation is a convenient cover to hide their personal greed and their schemes for political power from the eyes of the world.

From The Art of Looking Prime Ministerial – The 2010 UK General Election:

Why +do+ voters consistently have no option in choosing parties opposed to waging war on “failed states” at the behest of the United States? Why are we restricted to such an obviously pre-filtered set of choices despite the equally obvious dissatisfaction of the overwhelming majority of the population? How do powerful elites manage to ensure that they retain control no matter who wins? What is the role of the corporate media in preventing the public from interfering with corporate control of society?

]]>
http://www.keyvan.net/2010/05/david-cameron-common-people/feed/ 0
Five Filters Service Featured on Tekzilla http://www.keyvan.net/2010/05/five-filters-on-tekzilla/ http://www.keyvan.net/2010/05/five-filters-on-tekzilla/#comments Wed, 12 May 2010 18:35:45 +0000 Keyvan http://www.keyvan.net/?p=1085 The Full-Text RSS service developed for the Five Filters project was featured on Tekzilla in February. Clip below…

]]>
http://www.keyvan.net/2010/05/five-filters-on-tekzilla/feed/ 0