View Single Post
Old 10-02-2015, 01:50 PM   #95
KevinH
Sigil Developer
KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.
 
Posts: 8,859
Karma: 6120478
Join Date: Nov 2009
Device: many
New Plugin Interface Routines to support Manipulating epub3

Hi All,

This is just a head's up. In the upcoming release of Sigil 0.8.901, we have added in some new plugin interface routines that are needed to work with ePub3's via plugin.

These new routines provide support for adding/manipulating properties on manifest items and for adding/manipulating properties on spine itemrefs.

The new ("edit" plugin) bookcontainer.py routines are:

Code:
    # New for epub3
    def getspine_epub3(self):
        # spine is an ordered list of tuples (id, linear, properties)
        return self._w.getspine_epub3()

    # New for epub3
    def setspine_epub3(self, new_spine):
        # new_spine must be an ordered list of tuples (id, linear, properties (or None))
        self._w.setspine_epub3(new_spine)

    # Modified for epub3
    def spine_insert_before(self, pos, spid, linear, properties=None):
        self._w.spine_insert_before(pos, spid, linear, properties)

    # New for epub3
    def setspine_idref_epub3_attributes(idref, linear, properties):
        self._w.setspine_idref_attributes(idref, linear, properties)


    # Modified for epub3
    def addfile(self, uniqueid, basename, data, mime=None, properties=None):
        # creates a new file in the manifest with unique manifest id, basename, data, and mimetype
        self._w.addfile(uniqueid, basename, data, mime, properties)

    # New for epub3
    def set_manifest_epub3_properties(self, id, properties):
        # sets the epub3 manifest property for this manifest id
        self._w.set_manifest_epub3_property(id, properties)

    # New for epub3
    def manifest_epub3_iter(self):
        # yields manifest id, href, mimetype, and properties
        for id in sorted(self._w.id_to_mime):
            mime = self._w.id_to_mime[id]
            href = self._w.id_to_href[id]
            properties = self._w.id_to_props[id]
            yield id, href, mime, properties

    # New for epub3
    def spine_epub3_iter(self):
        # yields spine idref, linear(yes,no,None), properties, href in spine order
        for (id , linear, properties) in self._w.spine:
            href = self._w.id_to_href[id]
            yield id, linear, properties, href

    # New for epub3
    def id_to_properties(self, id, ow=None):
        return self._w.map_id_to_props(id, ow)

The new launcher version will report 20151001.

Note that these changes are versioned with "epub3", and the older interface routines are still there and still work. There should be no breakage of current plugins.

Also note, with these latest changes, it should now be possible for plugin developers to add epub3 features via python plugins even before we get a chance to add them to Sigil. I am thinking here of epub3 metadata editing or conversion, and autogeneration of a nav as some thigns that would certainly be doable with plugins.

Hope this helps,

KevinH

Last edited by KevinH; 10-04-2015 at 04:08 PM. Reason: Update docs with info for new release
KevinH is offline   Reply With Quote