[uf-discuss] Any bettter way to do an include in hreview?
Elli Albek
elli at sustainlane.com
Wed Jun 3 20:05:36 PDT 2009
Hi Tantek.
Link to a page with reviews:
http://www.sustainlane.com/reviews/aziza/TVLWN4ZKQLKTOIKFLWKBWFQ17DN8
You can also look at Yelp. Similar page content.
Notice hidden blocks with class="microformat_detail"
<div class="microformat_detail">
<span class="type">business</span>
review of
<span class="item">
<a class="include" href="#review_item">Aziza</a>
</span>:
<span class="rating">4</span> stars
</div>
Two things we want:
1. Remove repetition
2. Add review aggregates without more repetition
Generally I would like to stop using microformat_detail, and not restructure the HTML.
The microformats spec can makes it easier to support variety of page structures without includes/hidden blocks by having other association rules. Toby's RDF example is 1:1 match to our pages, but that may be a special case.
A few suggestions that will make implementation simpler for different HTML trees:
1. hcard can contain associated information like reviews and aggregates. hreviews inside an hcard to not need to specify item.
<div class="hcard">
<!-- hcard as a container -->
<h1 class="fn">name</h1>
<span class="average-rating">5</span> stars
based on <span class="hreview-count">1313</span> reviews
<div class="hreview">...</div>
<div class="hreview"> ...</div>
</div>
2. Make a container, in which things are associated by default, so you can have a few of them on a page.
<div class="item-container">
<h1 class="item hcard fn url"><a href="...">name</a></h1>
<span class="average-rating">5</span> stars
based on <span class="hreview-count">1313</span> reviews
<div class="hreview">...</div>
<div class="hreview"> ...</div>
</div>
3. Item can contain, instead of be part of other blocks.
<div class="item">
<!-- item as a container -->
<h1 class="hcard fn"><a class="url" href="...">name</a></h1>
<span class="average-rating">5</span> stars
based on <span class="hreview-count">1313</span> reviews
<div class="hreview">...</div>
<div class="hreview"> ...</div>
</div>
4. Aggregates have distinct names that are not used in hreview, so a block with an aggregate can be included in hreview without collisions with the hreview rating.
<div class="hcard item" id="review_item">
<h1 class="fn">name</h1>
<span class="average-rating">5</span> stars
based on <span class="review-count">1313</span> reviews
<span class="type microformat_detail">business</span>
</div>
<div class="hreview">...
<a class="item microformat_detail" href="#review_item">Aziza</a>
</div>
5. This HTML structure may currently be the solution to the puzzle (hack?). Still requires includes.
<div class="hreview-aggregate">
<div class="item hcard" id="review_item">
<span class="fn">L'Amourita Pizza</span>
</div>
<span class="average-rating">4.4</span>
<span class="review-count">1313</span>
</div>
<div class="hreview">...
<a class="item microformat_detail" href="#review_item">Aziza</a>
</div>
The key in this trick is that aggregate block contains the hcard block and separately than the actual aggregate numbers. They are siblings. It is now possible to include the item in hreview, without importing a second rating from the aggregate. In this case aggregates can have names already used in hreview.
This dictates a certain markup tree, which will require web developers to rewrite pages to match it, as we do now (unless they are lucky enough to already have it this way). A better solution will not require you to reorganize your page blocks if they are already semantically readable. Something like example 3 is more flexible, it allows things to be in a flat structure without includes, all you need is one class outside.
If the spec does not offer something like 3 (no includes, no forced tree structures, etc) than reviews and aggregates need distinct names for the elements, to make including easier. Otherwise developers have to go to something like 5, which dictates a rigid page. There should be more than only one possible way to add microformats to a reviews page without hidden blocks, repeating text, etc.
I also think it is a goal to make the work of the parser as easy as possible without big decision trees to resolve includes.
Another suggestion: Collapse trees. If microformats are already flexible in what they allow as parent child, you might as well consider a rule that allows you to collapse an entire tree of microformats:
<a class="item hcard fn url" href="...">name</a>
-------------------------------------------------
Suggested solution using TODAYS spec:
<div class="hreview-aggregate">
<div class="item hcard" id="review_item">
<span class="fn">L'Amourita Pizza</span>
</div>
<div class="rating">
<span class="average">4.4</span>
</div>
<span class="count">1313</span>
</div>
<div class="hreview">...
<a class=" microformat_detail" href="#review_item">Aziza</a>
</div>
E
More information about the microformats-discuss
mailing list