Register Guidelines E-Books Today's Posts Search

Go Back   MobileRead Forums > E-Book Software > Sigil > Plugins

Notices

Reply
 
Thread Tools Search this Thread
Old 11-01-2019, 06:46 AM   #436
Vroni
Banned
Vroni knows the difference between 'who' and 'whom'Vroni knows the difference between 'who' and 'whom'Vroni knows the difference between 'who' and 'whom'Vroni knows the difference between 'who' and 'whom'Vroni knows the difference between 'who' and 'whom'Vroni knows the difference between 'who' and 'whom'Vroni knows the difference between 'who' and 'whom'Vroni knows the difference between 'who' and 'whom'Vroni knows the difference between 'who' and 'whom'Vroni knows the difference between 'who' and 'whom'Vroni knows the difference between 'who' and 'whom'
 
Posts: 168
Karma: 10010
Join Date: Oct 2018
Device: Tolino/PRS 650/Tablet
Quote:
Originally Posted by KevinH View Post
A book path (...) is a unique relative path from the ebook root to a specific file.
If its from the root isnt it then an absolute path?
Vroni is offline   Reply With Quote
Old 11-01-2019, 08:44 AM   #437
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,793
Karma: 6000000
Join Date: Nov 2009
Device: many
In a way, as it is a partial path. So it is relative to the ebook folder path itself. The path to the ebook root folder is not part of it. Just the path within the ebook.

Last edited by KevinH; 11-01-2019 at 08:55 AM.
KevinH is offline   Reply With Quote
Old 11-08-2019, 02:55 PM   #438
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,793
Karma: 6000000
Join Date: Nov 2009
Device: many
FYI,
Updated the Sigil Plugin Framework epub to rev12 and it now includes and documents the extensions for the upcomig Sigil-0.9.991 (pre 1.0) alpha release.

Plugin developers should be able to use Sigil-0.9.991 to test and debug their plugins under the new interface, especially with non-standard epub layouts.
KevinH is offline   Reply With Quote
Old 11-13-2019, 03:29 PM   #439
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,793
Karma: 6000000
Join Date: Nov 2009
Device: many
Hi All,

For what it is worth, my plugins (FolderIn, FolderOut, ePub3-itizer, Access-Aide) all should now support the new Sigil-1.0 plugin interface.

I would be happy to help anyone else convert their plugins.

Just ask here.
KevinH is offline   Reply With Quote
Old 11-15-2019, 06:12 AM   #440
CalibUser
Addict
CalibUser goes to eleven.CalibUser goes to eleven.CalibUser goes to eleven.CalibUser goes to eleven.CalibUser goes to eleven.CalibUser goes to eleven.CalibUser goes to eleven.CalibUser goes to eleven.CalibUser goes to eleven.CalibUser goes to eleven.CalibUser goes to eleven.
 
Posts: 203
Karma: 62362
Join Date: Jul 2015
Device: Sony
Quote:
Originally Posted by KevinH View Post
Under Sigil 1.0 and later, the original epub structure will be preserved meaning that file names like "content.opf" could be named "package.opf", and be placed almost anyplace inside the epub. This is true for almost all files.
Would it be possible for somebody to provide a 'non-standard' Sigil-structured epub with at least two xhtml sections so that I can test my plugins on it? I have always used the standard structure that Sigil sets up so I am not familiar with the other types of structures that Sigil 0.9.991 can handle.

Under Sigil version 0.9.991 I renamed content.opf to package.opf and toc.ncx to toc1.ncx to make a non-standard epub but my pluging - FootnoteManipulator plugin for epub 2.0 publications - that was built for previous versions of Sigil still runs on this structure with Sigil 0.9.991. I do not know what else to change in the structure to fully test my plugin.

Thanks
CalibUser is offline   Reply With Quote
Old 11-15-2019, 06:17 AM   #441
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,793
Karma: 6000000
Join Date: Nov 2009
Device: many
I will dig one up and post it for you today. In the meantime, you can select any file or group of files in the BookBrowser and use the context menu to run Move on them and set a new destination. So move one of your *.xhtml files into a new lication, then move a second someplace else.
KevinH is offline   Reply With Quote
Old 11-15-2019, 12:51 PM   #442
CalibUser
Addict
CalibUser goes to eleven.CalibUser goes to eleven.CalibUser goes to eleven.CalibUser goes to eleven.CalibUser goes to eleven.CalibUser goes to eleven.CalibUser goes to eleven.CalibUser goes to eleven.CalibUser goes to eleven.CalibUser goes to eleven.CalibUser goes to eleven.
 
Posts: 203
Karma: 62362
Join Date: Jul 2015
Device: Sony
@KevinH:
Quote:
Originally Posted by KevinH View Post
..In the meantime, you can select any file or group of files in the BookBrowser and use the context menu to run Move on them and set a new destination. So move one of your *.xhtml files into a new location, then move a second someplace else.
Thanks for this. I experimented with your suggestion and now see that other folders can be created in the epub file by moving them; I moved a file to TestFolder and found

Code:
print(bk.group_to_folders("Text"))
returns

Code:
['OEBPS/Text', 'TestFolder']
With the older version of Sigil I could iterate through all the xhtml files using:

Code:
for (id, href) in bk.text_iter()
so I tried running the following code in Sigil 0.9.991

Code:
 	for (id, href) in bk.text_iter():
		print("id= ", id)
		print("href= ", href)
and this returned:

Code:
id=  sec_01.xhtml
href=  Text/sec_01.xhtml
id=  Section0001.xhtml
href=  ../TestFolder/Section0001.xhtml
id=  Section0002.xhtml
href=  Text/Section0002.xhtml
showing that the same code can still be used to iterate through all the xhtml files.

I hope this information may be of some use to other plugin developers.
CalibUser is offline   Reply With Quote
Old 11-15-2019, 02:06 PM   #443
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,793
Karma: 6000000
Join Date: Nov 2009
Device: many
Yes and the href in that case is the relative path from the OPF. If you want the path from the root folder of the epub, you can now use bk.id_to_bookpath(id) on the id that iterator provides to get the bookpath as well.

KevinH
KevinH is offline   Reply With Quote
Old 11-15-2019, 02:13 PM   #444
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,793
Karma: 6000000
Join Date: Nov 2009
Device: many
Here is a simple non-standard test epub that DiapDealer gave to me to test things with.

It is laid out as a simple compendium style epub might be but the files are pretty much empty.

Hope this helps,

KevinH
Attached Files
File Type: epub simple_test.epub (79.2 KB, 1144 views)
KevinH is offline   Reply With Quote
Old 11-15-2019, 02:59 PM   #445
DiapDealer
Grand Sorcerer
DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.
 
DiapDealer's Avatar
 
Posts: 28,588
Karma: 204624552
Join Date: Jan 2010
Device: Nexus 7, Kindle Fire HD
Is there any kind of simple algorithm that could be used to calculate a relative href between two files?

If one is creating a new xhtml file, I'm trying to think of a consistent way to come up with the proper src to a particular image file (already in the epub) based on the known factors.

Say I've created an xhtml file with my plugin whose href (relative to the opf file) is something like:

"book1/xhtml/newfile.xhtml"

and I have an image file with an href (relative to the opf file) of:

book1/images/myimage,jpg

I'm looking for some sort of reusable, failsafe function that could take two hrefs (from the various iter functions) as parameters (source and target) and give me a relative href from the first parameter's file to the second parameter's file.

Consider the two previously mentioned sample hrefs:

getRelativeHref('book1/xhtml/newfile.xhtml', 'book1/images/myimage,jpg')

needs to be able to return a value of '../images/myimage.jpg' so it can be used in an img tag in newfile.xhtml. Is that possible to do with any two files' hrefs in any epub structured in any way? Or will I need to build a relative href from the root of the epub up to be able to make it work under any conditions?

Or am I overthinking this?--which is entirely possible!

Last edited by DiapDealer; 11-15-2019 at 03:02 PM.
DiapDealer is offline   Reply With Quote
Old 11-15-2019, 03:45 PM   #446
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,793
Karma: 6000000
Join Date: Nov 2009
Device: many
Yes, the new interface offers just such a function:


# returns the href relative path from source bookpath to the target bookpath
#
def get_relativepath(self, from_bookpath, to_bookpath)

So bk.get_relativepath(from_bookpath, to_bookpath)

will nicely create for you the href to reference the to_bookpath file from the "from_bookpath" file. You still need to deal with any fragments afterwards and of course url encode it before writing it to a file.

There are examples of this and routines to help in hrefutils.py as well as that is what the plugin wrapper itself uses.

If you want sample code that builds links to an image file from an html file that is backwards compatible with older versions of Sigil check out ePub3-itizer, and Access-Aide for many examples.
KevinH is offline   Reply With Quote
Old 11-15-2019, 03:49 PM   #447
DiapDealer
Grand Sorcerer
DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.
 
DiapDealer's Avatar
 
Posts: 28,588
Karma: 204624552
Join Date: Jan 2010
Device: Nexus 7, Kindle Fire HD
Well looky there. If only I knew how to read, I could have answered my own question, huh?

Thanks!
DiapDealer is offline   Reply With Quote
Old 11-16-2019, 07:52 AM   #448
CalibUser
Addict
CalibUser goes to eleven.CalibUser goes to eleven.CalibUser goes to eleven.CalibUser goes to eleven.CalibUser goes to eleven.CalibUser goes to eleven.CalibUser goes to eleven.CalibUser goes to eleven.CalibUser goes to eleven.CalibUser goes to eleven.CalibUser goes to eleven.
 
Posts: 203
Karma: 62362
Join Date: Jul 2015
Device: Sony
Quote:
Originally Posted by KevinH View Post
Here is a simple non-standard test epub that DiapDealer gave to me to test things with.

It is laid out as a simple compendium style epub might be but the files are pretty much empty.

Hope this helps,

KevinH
Thanks for this.
CalibUser is offline   Reply With Quote
Old 11-17-2019, 06:04 AM   #449
Vroni
Banned
Vroni knows the difference between 'who' and 'whom'Vroni knows the difference between 'who' and 'whom'Vroni knows the difference between 'who' and 'whom'Vroni knows the difference between 'who' and 'whom'Vroni knows the difference between 'who' and 'whom'Vroni knows the difference between 'who' and 'whom'Vroni knows the difference between 'who' and 'whom'Vroni knows the difference between 'who' and 'whom'Vroni knows the difference between 'who' and 'whom'Vroni knows the difference between 'who' and 'whom'Vroni knows the difference between 'who' and 'whom'
 
Posts: 168
Karma: 10010
Join Date: Oct 2018
Device: Tolino/PRS 650/Tablet
If i understand this correct to save a file to the epub you need something like a complete "file selection" browser as the only folder you can trust to be present by default is the root folder of the epub.

Any best practices or is something availöable in the API to make use of?
Vroni is offline   Reply With Quote
Old 11-17-2019, 07:33 AM   #450
Doitsu
Grand Sorcerer
Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.
 
Doitsu's Avatar
 
Posts: 5,731
Karma: 24031401
Join Date: Dec 2010
Device: Kindle PW2
Quote:
Originally Posted by Vroni View Post
If i understand this correct to save a file to the epub you need something like a complete "file selection" browser as the only folder you can trust to be present by default is the root folder of the epub.
AFAIK, bk.addfile() will work with both standard and non-standard epub files. You'll only need to worry about the actual folder structure, if you want to create a plugin that allows the user to save a file to an arbitrary folder.

What kind of functionality are you trying to implement?
Doitsu is offline   Reply With Quote
Reply


Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Loading Plugin in development Sladd Development 6 06-17-2014 06:57 PM
Question for plugin development gurus DiapDealer Plugins 2 02-04-2012 11:33 PM
DR800 Plugin development for DR800/DR1000 yuri_b iRex Developer's Corner 0 09-18-2010 09:46 AM
Device plugin development reader42 Plugins 10 03-29-2010 12:39 PM
Calibre plugin development - Newbie problems minstrel Plugins 5 04-12-2009 12:44 PM


All times are GMT -4. The time now is 12:25 PM.


MobileRead.com is a privately owned, operated and funded community.