First of all, thanks for being one of the first to write to the
developer's list. This is an excellent question.
Some answers:
1. The web export plugin's core is a Java application that reads the
XML from the Books export process to generate HTML pages. Since this
is Java, you'll need to recompile the main JAR file containing the
code to get things to work. In the plugin, this is the web-export.jar
file. I do my Java work in Eclipse (http://www.eclipse.org). You
should have no problem taking the Java source files from within the
plugin and working with them in Eclipse and having Eclipse spit out
an appropriate JAR file.
2. Since this is all Java, you'll need a Java library for generating
the barcode graphic files. Barbeque (http://
barbecue.sourceforge.net/) looks like a promising library. The BBQ
jar file will need to be added to the Resources folder of the plugin.
The run.sh file will need to be modified to point to the new jar file
in its classpath:
-cp web-export.jar
becomes
-cp web-export.jar:bbq.jar
3. Within the Java source, in WebExporter.java, you'll most likely
want to add the code to generate the barcode in the chunk that does
stuff with ISBN numbers (assuming you're generating based on ISBN):
String isbn = fields.get ("isbn");
if (isbn != null && !isbn.equals (""))
{
isbn = isbn.replaceAll ("-", "").replaceAll (" ", "");
htmlString += "<div class=\"buy\">Buy online: <a href=\"http://
www.amazon.com/exec/obidos/ASIN/" + isbn + "/aetherialnu-20\">Amazon</
a>, " +
"<a href=\"http://service.bfast.com/bfast/click?
bfmid=2181&sourceid=41590896&bfpid=" + isbn + "&bfmtype=book\">Barnes
& Noble</a></div>";
}
Within that if block, you'll want to add the code that generates the
graphic file and saves it to a file. Somewhere within that method,
you'll want to add the HTML code that points to the new image.
4. The reason that you can't use PHP in this setup is because the Web
Export plugin can't make any assumptions about the server
technologies on the server that it's living, so everything's plain
static HTML. If you are running on a server that does use PHP and
you'd be fine pointing to that instead of adding the code to the Java
portions, you may be able to get away with doing some creative
searching and replacing within a text editor (TextMate works great
for this) that can search and replace across multiple files. In
particular, you could set up a search and replace task that replaces
the Amazon buy code with the barcode
Find: <div class="buy">Buy online: <a href="http://www.amazon.com/
exec/obidos/ASIN/"
Replace: <div clas="img-barcode"><img src="barcode.php?code=
and
Find: /aetherialnu-20">Amazon</a>,
Replace: " /></div><div class="buy">Buy online:
This would replace the Amazon buy link with a pointer to the
generated barcode image file. You'd want to play with the CSS to
style it and position the code where you wanted, but it's a simple
non-programming way to accomplish the same thing. You could do the
same thing with the ISBN text field:
<tr><td class="key">ISBN:</td><td class="value">0201514257</td></tr>
I hope that this gets you started on the right path. If you need more
pointers, please let me know.
-Chris
On Mar 4, 2006, at 2:57 AM, mxmlitvinov wrote:
> Hello and sorry to barge in...
>
> I am but a humble tinkerer who wants to customise the Web Export
> plugin a bit before
> outputting his library.
>
> Specifically, I'm wanting to add a barcode into each book's page on
> export, something that
> will probably be of little use eventually, but might give me some
> limited personal
> satisfaction (and I do have a barcode scanner, so it isn't just for
> aesthetic reasons). I can
> generate ISBN barcodes in a standard web page easily enough by
> calling a PHP page to
> generate an image on the fly, (eg: "<img src=barcode.php?
> code=1583671021>"), but am
> stumped as to how I can actually modify Web Exporter.app in the
> first place to place the
> relevant code on each book's page.
>
> I've opened up the package, gone to src/resources/Java/net/
> aetherial/books/
> webexporter/WebExporter.java and played around with that file in a
> way that my enfeebled
> mind considered would output what I wanted, but this hasn't made
> any difference to the
> output of the Web Exporter.
>
> Could someone just point me on the right track? Do I need to *do*
> something (other than
> save) with the modified Java file before the modifications will
> take effect? I feel just
> providing the ability for people with limited understanding of css
> and html to customise
> some elements of the Web Exporter would lend enormous flexibility
> to the software, but at
> the moment it all seems just a bit over my head.
>
> Kind Regards,
> James.