MobileRead Forums

MobileRead Forums (https://www.mobileread.com/forums/index.php)
-   Sigil (https://www.mobileread.com/forums/forumdisplay.php?f=203)
-   -   UUID basics & template (https://www.mobileread.com/forums/showthread.php?t=294905)

Evil Overlord 02-17-2018 08:19 PM

UUID basics & template
 
I have a stable EPUB that I tend to use as a template. It works fine, but it's only just occurred to me that perhaps it's reusing the same UUID over and over. It hasn't caused me any trouble, but is there a way to use a file as a template, and avoid this problem?

Tex2002ans 02-18-2018 01:02 AM

1 Attachment(s)
Quote:

Originally Posted by Evil Overlord (Post 3658730)
I have a stable EPUB that I tend to use as a template. It works fine, but it's only just occurred to me that perhaps it's reusing the same UUID over and over. It hasn't caused me any trouble, but is there a way to use a file as a template, and avoid this problem?

You could just create a folder with all the common template files you use.

Create a new EPUB, Right-Click in the Book Browser + "Add Existing Files":

Attachment 162367

I have a folder of common CSS + Front/Backmatter that gets used in every book that I just import in every time. Then I do whatever tweaks are needed.

Maui 02-18-2018 04:11 AM

Another way is to copy & paste a new UUID from here

https://www.uuidgenerator.net/

or to write a plugin which is modifying the content.opf.

KevinH 02-18-2018 10:43 AM

Or remove the uuid dc:identifier and the content.opf will create a new one before saving it

Updated: whoops! This only works when the epub in question has obfuscated fonts!

So you would have to edit/add the bookid dc:identifier metadata and make sure it matches what is used in the ncx..

DiapDealer 02-18-2018 11:07 AM

I've always meant to knock together an input plugin that would allow a user to select from different predefined template epubs. Just never found the time.

Evil Overlord 02-18-2018 08:40 PM

Thanks, all.

@DiapDealer - I'd love to have that plugin (but have no idea how to make my own).

I think I'll try the UUID-generator site. In the case where this came up, I did try a bunch of things to make Sigil generate a new UUID, but they didn't work (perhaps because I don't have obfuscated fonts). I messed with the opf, but that seemed to make things worse. I finally just transferred all the files to a new EPUB, but reordering a bunch of files is tedious.

Hitch 02-19-2018 02:49 AM

Quote:

Originally Posted by KevinH (Post 3658968)
Or remove the uuid dc:identifier and the content.opf will create a new one before saving it

Updated: whoops! This only works when the epub in question has obfuscated fonts!

May inquiring minds ask why that is?

Quote:

So you would have to edit/add the bookid dc:identifier metadata and make sure it matches what is used in the ncx..
Hitch

KevinH 02-19-2018 09:08 AM

It is because both official font obfuscation algorithms use the main book uuid identifier value in their obfuscation/deobfuscation process. So saving an epub and obfuscating fonts, will simply destroy the font files without a main book uuid dc:identifier.

Hitch 02-19-2018 01:42 PM

Quote:

Originally Posted by KevinH (Post 3659394)
It is because both official font obfuscation algorithms use the main book uuid identifier value in their obfuscation/deobfuscation process. So saving an epub and obfuscating fonts, will simply destroy the font files without a main book uuid dc:identifier.

Duh, of course. I forget, as we never use font obfuscation; we subset.

Thanks for taking the time to respond.

Hitch

Tex2002ans 02-19-2018 03:51 PM

Quote:

Originally Posted by Evil Overlord (Post 3659220)
I think I'll try the UUID-generator site. In the case where this came up, I did try a bunch of things to make Sigil generate a new UUID, but they didn't work (perhaps because I don't have obfuscated fonts). I messed with the opf, but that seemed to make things worse.

Or another method: Create a new EPUB and just copy over the UUID into the template EPUB's content.opf + toc.ncx.

Then you could keep your template EPUB as a base, and don't have to do all that file reordering.

Quote:

Originally Posted by Evil Overlord (Post 3659220)
I finally just transferred all the files to a new EPUB, but reordering a bunch of files is tedious.

If you do this so often, you could also number your template files to keep them in sorted order when you "Add Existing Files":

Code:

00-cover.xhtml
01-titlepage.xhtml
02-copyright.xhtml
99-backmatter.xhtml

How many template files are we talking here?

Turtle91 02-19-2018 06:55 PM

Instead of using the "Add Existing Files" technique, I simply saved a template epub (with all of my default files) as "template.epub" and set my desktop shortcut to open that file. When it opens I "Save As" with the new name then add any other content.

Turtle91 02-19-2018 06:59 PM

It would be nice to have Sigil add a UUID if it is missing from the opf automagically...then I would just save my template without a UUID to force generation.

While I'm wishing... Is it possible to force a "Save As" when opening a specific file...such as one named "Template.epub" or "*.tmp" or somesuch??

slowsmile 02-20-2018 05:09 AM

@Evil Overlord...Try the following if you want a new OPF uuid:

* Load your epub template file into Sigil
* Go to the OPF file and delete the "urn:uuid" part from the the uuid value.
* Then run the IDErrorCheck plugin from the Sigil Plugin Index.

The IDErrorCheck plugin will automatically fix and regenerate many incorrect ID errors in your epub -- including the uuids in the OPF and NCX files if they are incorrectly formatted. If you follow the above advice then this plugin should automatically give you a newly generated OPF uuid in the correct format.

And if the OPF uuid is incorrect then the OPF uuid will be replaced and the NCX uuid will also be replaced with the same uuid as the OPF(and vice versa) -- even though this is no longer an IDPF requirement(If the OPF uuid is different from the NCX uuid, Epupcheck no longer gives an error). I learned this from the Epubcheck developer blog after I requested that they fix the "colon" error msg problem some while ago.

Doitsu 02-21-2018 08:50 AM

1 Attachment(s)
I've recycled code from the ODT import plugin to create a simple epub template plugin and attached a beta version.

What the plugin does is add all files in its resources subfolder to the current epub. (It won't overwrite existing files with the same name, though.)
Simply install the plugin, display its resources folder in the file manager and copy all files that you want to add to the resources folder. (You can't use subfolders.)

To display the resources folder:
  1. Press Windows+R (Run)
  2. Copy and paste %USERPROFILE%\AppData\Local\sigil-ebook\sigil\plugins\EpubTemplate\resources and press Enter. (I've already added a dummy cover page for demonstration purposes.)

To run the plugin select Plugins > Edit > EpubTemplate.

bravosx 02-21-2018 03:37 PM

@Doitsu thank you for the ingenious plugin.

So far, I've been uploading my own templates each one by one. I inserted my xhtml file templates (cover, titlepage, chapters, endnotes) into the plugin as well as a style file and font. Now with one move I can put it all into Sigil.

I'm very happy.
bravosx


All times are GMT -4. The time now is 09:18 PM.

Powered by: vBulletin
Copyright ©2000 - 3.8.5, Jelsoft Enterprises Ltd.
MobileRead.com is a privately owned, operated and funded community.