View Single Post
Old 01-17-2010, 10:46 AM   #60
Jellby
frumious Bandersnatch
Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.
 
Jellby's Avatar
 
Posts: 7,516
Karma: 18512745
Join Date: Jan 2008
Location: Spaniard in Sweden
Device: Cybook Orizon, Kobo Aura
One sometimes wants to have a way to detect which reader is being used, so that some feature can be disabled or some workaround activated. There is no standard way to detect the reader, but something can be done to detect the Adobe engine, and activate or deactivate CSS stuff depending on whether the book is being rendered by Adobe or not.

The "trick" is just using Adobe's conditional CSS in the page template file (xpgt). Since at the moment only Adobe understands and uses the xpgt, whatever you put in this file will only be read by Adobe. So you could have, in your standard CSS file:

Code:
.ade { display: none; }
to hide ADE-only stuff from other renderers. And, in the xpgt file:

Code:
<ade:style>
  <ade:styling-rule selector=".noade" display="none"/>
  <ade:styling-rule selector="div.ade" display="block"/>
  <ade:styling-rule selector="span.ade" display="inline"/>
</ade:style>
to hide "non-ADE"-only stuff and show ADE-only stuff. This is demonstrated in the attached test ePUB, which will tell you whether you are using the Adobe engine (Sony, Cybook, etc.) or not (Calibre, for instance). The file also shows a couple of Adobe bugs which don't matter in this thread.
Attached Files
File Type: epub test.epub (39.1 KB, 1340 views)
Jellby is offline   Reply With Quote