implementation-guidelines-fr: Difference between revisions
(awaiting cleanup before translation) |
m (Reverted edits by OrliaCcnab (Talk) to last version by ChristopheDucamp) |
||
(3 intermediate revisions by 2 users not shown) | |||
Line 9: | Line 9: | ||
== | ==Editeurs== | ||
* | * L'embarquement dans les documents XHTML est la chose la plus facile à faire avec les microformats. | ||
* | * Les microformats peuvent être embarqués dans les entrées Atom : | ||
<pre> | <pre> | ||
<entry> | <entry> | ||
<title> | <title>Critique de N'importe Quel Objet</title> | ||
<link href="http://microformats.org/wiki/" /> | <link href="http://microformats.org/wiki/" /> | ||
<id>urn:uuid:1225c695-cfb8-4ebb-aaaa-80da344efa6a</id> | <id>urn:uuid:1225c695-cfb8-4ebb-aaaa-80da344efa6a</id> | ||
Line 22: | Line 22: | ||
<div xmlns="http://www.w3.org/1999/xhtml"> | <div xmlns="http://www.w3.org/1999/xhtml"> | ||
<div class="hreview"> | <div class="hreview"> | ||
<h3 class="summary"><span class="item fn"> | <h3 class="summary"><span class="item fn">Un objet</span> en cours de critique</h4> | ||
<p> | <p>Critique : <span class="reviewer fn">nom auteur</span> - | ||
<abbr class="dtreviewed" title="20050730T1900-0700"> | <abbr class="dtreviewed" title="20050730T1900-0700">30 juillet 2005</abbr></p> | ||
<blockquote class="description"><p> | <blockquote class="description"><p>Le contenu de la critique</p></blockquote> | ||
<span><span class="rating">5</span> | <span><span class="rating">5</span> sur 5</span> | ||
</div> | </div> | ||
</div> | </div> | ||
Line 33: | Line 33: | ||
</pre> | </pre> | ||
Questions: | Questions : | ||
* | * Est-ce qu'un profil XMDP devrait être lié à l'entrée Atom ? | ||
* | * Est-ce que la classe hreview apparaît dans la div du conteneur de contenu ? | ||
==Identification== | ==Identification== | ||
Line 64: | Line 64: | ||
</pre> | </pre> | ||
A greasemonkey script that applies this strategy to [http://de.lirio.us de.lirio.us] and an [http://thecommunityengine.com/webcites/ individual linkblog republished from del.icio.us] is available [http://thecommunityengine.com/resources/xfolk-colorize.user.js here] with a tutorial on how the script works and how to modify it for other microformats [http://thecommunityengine.com/home/archives/2005/07/greasemonkey_mi.html here]. Alf Eaton uses this exact XPath strategy in an early [http://hublog.hubmed.org/archives/001149.html script] that he created for [[hreview]]. | A greasemonkey script that applies this strategy to [http://de.lirio.us de.lirio.us] and an [http://thecommunityengine.com/webcites/ individual linkblog republished from del.icio.us] is available [http://thecommunityengine.com/resources/xfolk-colorize.user.js here] with a tutorial on how the script works and how to modify it for other microformats [http://thecommunityengine.com/home/archives/2005/07/greasemonkey_mi.html here]. Alf Eaton uses this exact XPath strategy in an early [http://hublog.hubmed.org/archives/001149.html script] that he created for [[hreview-fr|hreview]]. | ||
However, as Alf Eaton also notes, the XPath-only strategy is subject to potential collisions where the class value that denotes the microformat's container element is contained in another class value. For example 'xfolkentry' is contained in 'mixfolkentry', and the XPath expression would identify both as an [[xfolk]] entry. While the danger of this particular collision occurring are slight, such may not be the case with other microformats. | However, as Alf Eaton also notes, the XPath-only strategy is subject to potential collisions where the class value that denotes the microformat's container element is contained in another class value. For example 'xfolkentry' is contained in 'mixfolkentry', and the XPath expression would identify both as an [[xfolk-fr|xfolk]] entry. While the danger of this particular collision occurring are slight, such may not be the case with other microformats. | ||
To avoid collisions in microformat container values, Alf proposes an amendment to the above strategy that works well for microformats where the container element is identified by a class value. Alf's strategy is contained in the following code pattern (that does not run as is): | To avoid collisions in microformat container values, Alf proposes an amendment to the above strategy that works well for microformats where the container element is identified by a class value. Alf's strategy is contained in the following code pattern (that does not run as is): | ||
Line 116: | Line 116: | ||
=== hCard === | === hCard === | ||
voir : [[hcard-parsing-fr|hCard Parsing] | voir : [[hcard-parsing-fr|hCard Parsing]] | ||
== voir aussi == | == voir aussi == | ||
* [[xmdp-faq-fr|XMDP FAQ]] | * [[xmdp-faq-fr|XMDP FAQ]] |
Latest revision as of 22:34, 5 January 2009
Instructions et Stratégies pour Implémenter les Microformats
Cette page a démarré sur implementation-guidelines. La page originale a besoin de GROS MENAGE et de réorganisation avant de passer en traduction afin d'être utile pour y trouver des "instructions" pour les implémenteurs. A cette heure la page originale ne contient qu'un vague ensemble désordonné d'idées d'implémentations. Si vous êtes un implémenteur francophone, sentez-vous vraiment libre de sauter dans la page mentionnée au-dessus et d'aider au nettoyage. Merci d'avance -- Christophe .
Editeurs
- L'embarquement dans les documents XHTML est la chose la plus facile à faire avec les microformats.
- Les microformats peuvent être embarqués dans les entrées Atom :
<entry> <title>Critique de N'importe Quel Objet</title> <link href="http://microformats.org/wiki/" /> <id>urn:uuid:1225c695-cfb8-4ebb-aaaa-80da344efa6a</id> <updated>20050730T1900-0700</updated> <content type="xhtml"> <div xmlns="http://www.w3.org/1999/xhtml"> <div class="hreview"> <h3 class="summary"><span class="item fn">Un objet</span> en cours de critique</h4> <p>Critique : <span class="reviewer fn">nom auteur</span> - <abbr class="dtreviewed" title="20050730T1900-0700">30 juillet 2005</abbr></p> <blockquote class="description"><p>Le contenu de la critique</p></blockquote> <span><span class="rating">5</span> sur 5</span> </div> </div> </content> </entry>
Questions :
- Est-ce qu'un profil XMDP devrait être lié à l'entrée Atom ?
- Est-ce que la classe hreview apparaît dans la div du conteneur de contenu ?
Identification
There are several user agent identification strategies. Currently, Firefox provides strong support for XPath based discovery methods. Some of these can be adapted to Internet Explorer 6 with a small loss in efficiency and others not at all. The following examples are in extreme summary form. It is suggested that you click through on the links for more explanation.
Stratégies Firefox/Mozilla
The simplest method is just to use an XPath expression to identify the microformat. Here is an example that does just that:
var allDivs, thisDiv; allDivs = document.evaluate( "//*[contains(@class, 'xfolkentry')]", document, null, XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE, null); // Just run through all elements matched by the XPATH expression and change // the background color to an attractive red. for (var i = 0; i < allDivs.snapshotLength; i++) { thisDiv = allDivs.snapshotItem(i); // do something here. For example, change the background color to red. thisDiv.style.backgroundColor = 'red'; }
A greasemonkey script that applies this strategy to de.lirio.us and an individual linkblog republished from del.icio.us is available here with a tutorial on how the script works and how to modify it for other microformats here. Alf Eaton uses this exact XPath strategy in an early script that he created for hreview.
However, as Alf Eaton also notes, the XPath-only strategy is subject to potential collisions where the class value that denotes the microformat's container element is contained in another class value. For example 'xfolkentry' is contained in 'mixfolkentry', and the XPath expression would identify both as an xfolk entry. While the danger of this particular collision occurring are slight, such may not be the case with other microformats.
To avoid collisions in microformat container values, Alf proposes an amendment to the above strategy that works well for microformats where the container element is identified by a class value. Alf's strategy is contained in the following code pattern (that does not run as is):
var mf = 'hreview'; var micropath = "//*[contains(@class,'" + mf + "')]"; var micromatch = new RegExp('\\b' + mf + '\\b'); var mc = document.evaluate(micropath, document, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null); for (var i = 0; i < mc.snapshotLength; i++) { iNode = mc.snapshotItem(i); if (iNode.className.match(micromatch)) doSomething(); }
Note that this solution introduces regular expression checking as a second test on the nodes isolated by the XPath expression. Modifying the first example to use this strategy in a bit of code that is runnable we get:
var allDivs, thisDiv; var mf = 'xfolkentry'; var micropath = "//*[contains(@class,'" + mf + "')]"; var micromatch = new RegExp('\\b' + mf + '\\b'); allDivs = document.evaluate( micropath, document, null, XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE, null); for (var i = 0; i < allDivs.snapshotLength; i++) { thisDiv = allDivs.snapshotItem(i); // do something here. For example, change the background color to red. if (iNode.className.match(micromatch)) // apply the second test thisDiv.style.backgroundColor = 'red'; }
Stratégies Internet Explorer
XPath-based strategies can be made to work sometimes in Internet Explorer with Dimitri Glazkov's javascript library that harnesses IE's built-in XPath support for traversing HTML DOM.
Parsage
Parsing Microformats can be as easy or as hard as you want it to be. Since many of the elementary building blocks are based on anchor tags, its possible possible to implement some fairly effective functionality without needing to mess around with the complexities of tag nesting and unknown class names. Simple rule: ignore anything you don't need.
hCard
voir : hCard Parsing