Batchpages

From MegaZine3
Revision as of 22:16, 1 May 2010 by Hnuecke (talk | contribs) (corrected example for print with localization; language code was missing in print line)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search
{{#if: | }} {{#if: | }}{{#if: * batchpages.swf | }}{{#if: * Gallery}}
Plugin: Batchpages
[[File:{{{image}}}]]
Name Batchpages
Since version

{{{version}}}

Files
  • batchpages.swf
Related plugins

This plugins allows to define multiple pages in a chapter using a single attribute, making it easier to create books which only use one image per page, which fills out the entire page.

Attributes

Chapter

=== pages ==={{#if: String or Definition |

  • Type: String or Definition}}{{#if: |
  • Valid values: {{{valid}}}}}{{#if: |
  • Default: {{{default}}}}}{{#if: |
  • Overrides: {{{overrides}}}}}{{#if: |
  • Aliases: {{{alias}}}}}{{#if: |
  • Version: {{{version}}}}}

May be used to automatically generate multiple pages. The pages created this way will be appended behind page nodes defined in the XML. This attribute was extended in version 2.0.6 of the engine, to allow more detailed customization, e.g. localized pages. The old method of defining batch pages still works, though.{{#if: |

  • See also: {{{see}}}}}

Detailed Configuration

Available as of version 2.0.6

{{#switch:left | left =

{{#switch:{{#if: | {{{smallimage}}} | }} | none =

| #default =

}} {{#if:{{#if: | {{{smallimageright}}} | }} | {{#ifeq:{{#if: | {{{smallimageright}}} | }}|none | | }} }}

| #default =

{{#switch: | none =

| #default =

}}

{{#if: | {{#ifeq:|none

 | 
| }} }}

}}

The detailed configuration uses the definition format.

Generally, in paths, the string {{num}} is replaced with the number of the generated page. Note that this number does not represent the actual page number, but the number of the page in the currently defined batch (for the current chapter). So the only case when this value represents the page number in the book is if this is defined for the first chapter in the book, and the chapter contains no other pages.

The following "commands" are available:

scale

This allows defining an image for a page, optionally to be used with a given scaling level (see Adaptive Zoom), as well as for defining images for different languages. The basic format is:

scale(path, scale, language)

Where

  • path is the path to the image to use. Uses {{num}} to insert number.
  • scale is optional, and the scaling at which to use this image. Accepts numbers. Defaults to 0, i.e. used for all scalings. Can be left blank, if you just want to define the language.
  • language defines the language for which this image should be used. Use one of the codes you provided in book@lang here, or none to make it the default.

Usage examples:

Code Result / XML equivalent for {{num}} = 0.
scale(path/normal{{num}}.jpg)
<page>
    <img src="path/normal0.jpg"/>
</page>
scale(path/hires{{num}}.swf, 2)
<page>
    <img>
         <src scale="2">path/hires0.swf</src>
    </img>
</page>
scale(en/normal{{num}}.jpg,,en)
<page>
    <img>
         <src lang="en">en/normal0.jpg</src>
    </img>
</page>
scale(en/hires{{num}}.swf, 2, en)
<page>
    <img>
         <src scale="2" lang="en">en/hires0.swf</src>
    </img>
</page>
hires

Allows defining high resolution alternatives to be used by the Gallery plugin. The basic format is:

hires(path)

Usage example:

hires(big/image{{num}}.png) results in <img hires="big/image0.png"/>
print

Allows defining print alternatives to be used by the Print or PrintPDF plugin. The basic format is:

print(path, language)

Where language is optional, and determines the language for which to use the alternative path given in path.

Usage examples:

Code Result / XML equivalent for {{num}} = 0.
print(pages/print{{num}}.swf)
<page print="pages/print0.swf"/>
print(de/print{{num}}.swf, de); print(en/print{{num}}.swf, en)
<page print="de(de/print0.swf);en(en/print0.swf)"/>
count

This one is used solely for the purpose of defining which number range to use for replacing the {{num}} variable, and thus how many pages to generate. The basic format is:

count(end) or count(start, end)

If only one argument is given, the pages generated will use the interval [0, end], thus generating end + 1 pages. If two arguments are given, the pages generated will use the interval [start, end].

Usage examples:

count(5) will generate 6 pages, with {{num}} being 0, 1, 2, 3, 4 and 5.
count(2,6) will generate 5 pages, with {{num}} being 2, 3, 4, 5 and 6.
settings

Allows defining addition settings, which are basically values to apply to attributes of the generated pages or images. This is a list with a fixed order. To skip a setting, just leave it blank. The basic format is:

settings(page@buffer, img@aa/page@buffer_aa, img@rasterize, img@cache, img@gallerybutton)

Usage examples:

settings(true) sets page@buffer to true for all generated pages.
settings(,,,false) disables caching for all generated images.
Full example
<nowiki><book lang="en,de" plugins="print" zoomminscale="0.5">
    <chapter pages="count(10);
                    settings(true);
                    scale(pages/de/normal{{num}}.jpg,,de);
                    scale(pages/en/normal{{num}}.jpg,,en);
                    scale(pages/de/hires{{num}}.swf,1,de);
                    scale(pages/en/hires{{num}}.swf,1,en);
                    print(print/de/page{{num}}.swf,de);
                    print(print/en/page{{num}}.swf,en)"/>
</book></nowiki>
Note: the whole attribute should go in one line. It is just wrapped for readability, here.

Simple Configuration

The string is basically be an URL but can contain variables describing numeric intervals. Intervals are defined like this: [XX-YY], where XX is the lower end of the interval and YY the upper one.

Alternatively it can be defined by using [XX] where XX is the upper bound and the lower bound is 1.

The loaded graphics will be scaled to exactly fit the page.

An example:

pages/page[0-10].jpg

This loads all files of the names "pages/page0.jpg", "pages/page1.jpg", ..., "pages/page10.jpg" as image elements and puts them into 11 automatically generated page element. It is also possible to define multiple intervals, e.g. pages[2]/page[0-10].jpg would load the images "pages1/page0.jpg", ..., "pages1/page10.jpg", "pages2/page0.jpg", ..., "pages2/page10.jpg".

It is also possible to use high resolution variants (for the gallery plugin). Those will have to follow a certain naming, though. To declare high resolution variants, add the following to the end of the String:
|_postfix, where _postfix is the end of the file name of the high resolution files, and the beginning of the file names has to be the same as for the actual images. If _postfix is empty, the same URL that is used for the page image will be used for the zoom mode (i.e. hires == src).

An example:

pages/page[0-10].jpg|_big

would not only load the images as img elements and put them into pages, it would additionally define a hires attribute for each image, accordingly to its name. Also, the so created images/pages will be put into one gallery. The equivalent XML would look like so (one page only):

<page>
    <img src="pages/page5.jpg" hires="pages/page5_big.jpg"
         gallery="Automatically generated Value"/>
</page>

Note that when the print plugin is loaded, this will also generate a page@print attribute, using the same path as the hires image.

Additional settings are possible when adding "?", allowing a few of the boolean settings for all images. The possible settings are set to their non-default value by adding the letter they correspond to after the "?". The corresponding pairs are:

  • a → img@aa="true" and page@buffer_aa="true"
  • b → img@gallerybutton="true"
  • n → img@nocache="true"
  • r → img@rasterize="true"
  • s → page@buffer="true"

So, to make all images loaded use rasterize="true" and gallerybutton="false" use something like this:

pages/page[0-10].jpg|_hires?br

Or, without using hires:

pages/page[0-10].jpg?br

Or, using hires with the same image as the original one:

pages/page[0-10].jpg|?br

The settings must follow after hires settings (i.e. after the optional "|").


MegaZine3 Plugin-related articles
Plugins Anchors · Background Sounds · Batchpages · Bookmarks · Console · ElementIDs · Gallery · Google Analytics · Help · JavaScript · Keyboard Navigation · Links · NavigationBar · Options · Overlays · Password · PDFLinks · Print · PrintPDF · SWFAddress· Search · Sidebar · Slideshow · Titles
Plugin Articles Writing a plugin · Writing a plugin II · Plugin development

{{#if: | |}}