Register Guidelines E-Books Search Today's Posts Mark Forums Read

Go Back   MobileRead Forums > E-Book Software > Sigil

Notices

Reply
 
Thread Tools Search this Thread
Old 08-10-2013, 12:19 PM   #1
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: 9,129
Karma: 40942904
Join Date: Jan 2010
Device: Nexus 7, Kindle Fire HD
Sigil Plugins!

Ok, not officially anyway, but still ... sorta ... kinda.

I've been using the "Open with" feature of Sigil to launch Python scripts from *.bat files and bash scripts... with varying levels of success.

I thought I'd share in case anyone was interested in creating their own "plugins."

I'm using Python because that's what I know, but there's really nothing preventing someone from using their own preferred scripting/programming language if they so desired.

Having said that, however; if you want to try my attached samples (working on Windows and Linux), you'll need to have Python installed (and the interpreter on your PATH).

I've got three simple plugins that perform various things:
1) Smarten Punctuation (using SmartyPants)
2) Generate a new UUID in the OPF file (useful for those who use templates)
3) Add the Apple XML file to the ePub (so embedded fonts work in iBooks)

After ensuring you have a working Python installation, unzip the attached file to a folder/directory on your system. Then from within Sigil, right-click on a file and select "Open With." Then browse to the folder where you unzipped the files and select the plugin you want to use (*.bat on windows ... *.sh on linux). Optionally change the name of the "editor" to something relevant, and that's really it.

*Please* don't use these on something you've spent hours getting just right without having proper backups. They're working fairly well for me, but still... caution would definitely be in order.


Details:

Smarten Punctuation: smarten_punc.(bat|sh). Edit smarten_punc.py to tweak how things work (converting entities to characters, which entities, etc). I associate this plugin with (x)html files (and yes, it only works on one file at a time). This script is not discriminating in what kind of file it will work on, so please don't attempt to use it on anything other than your (x)html files. I don't know what the results would be!

Generate New UUID: new_uuid.(bat|sh) Edit new_uuid.py to tweak how things work. I associate this plugin with the OPF file.

Add Apple XML: apple_xml.(bat|sh) Edit apple_xml.py to tweak how things work. I associate this plugin with font files (even though it doesn't modify them). NOTE: you won't see the XML file in Sigil after running the plugin, but you will get an indication that the epub is in an unsaved state. If you save the ePub, rest assured the xml file will show up in Sigil 'Misc' folder next time you open the ePub.

Anyway, I hope someone can have fun with this. It's really meant as a "proof of concept" sort of thing. I'm more than willing to help people get things working in a general way, but just know that I'm not volunteering for a "make it do X!, or make it do Y!" sort of free-for-all.

Also, although SmartyPants does an admirable job, it's not perfect (and I didn't write it). So I'm not responsible for it behaving in a way you don't think it should.

For myself, I eventually foresee me creating a Tk graphical front-end that will allow me to choose from several common utilities to be performed for that file type. But I'm in no hurry.

** (If you want to use these in conjunction with Calibre's 'Open with' plugin to launch Sigil, you'll probably need to edit the bat/sh files and hardcode the path to your Python interpreter. Something about the Calibre environment prevents Sigil from finding the interpreter even when it's on the system path. I hard code them anyway, simply because I have multiple versions of Python installed.) **
Attached Files
File Type: zip sigil_plugins.zip (16.1 KB, 127 views)

Last edited by DiapDealer; 08-10-2013 at 01:06 PM.
DiapDealer is online now   Reply With Quote
Old 08-10-2013, 01:06 PM   #2
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: 9,129
Karma: 40942904
Join Date: Jan 2010
Device: Nexus 7, Kindle Fire HD
Did I forget to attach the zip file, or was it removed for some reason?
Oh well, I'll just attach it again. If there's some sort of issue with doing so, I assume someone will let me know.
DiapDealer is online now   Reply With Quote
 
Enthusiast
Old 08-10-2013, 01:12 PM   #3
theducks
Grand Sorcerer
theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.
 
theducks's Avatar
 
Posts: 14,707
Karma: 5643657
Join Date: Aug 2009
Location: (The original) Silicon Valley, USA
Device: Galaxy Tab 2, Astak Pocket Pro, K4NT
Quote:
Originally Posted by DiapDealer View Post
Did I forget to attach the zip file, or was it removed for some reason?
Oh well, I'll just attach it again. If there's some sort of issue with doing so, I assume someone will let me know.
I don't see any MOD action. Maybe you rushed the upload process
theducks is offline   Reply With Quote
Old 08-10-2013, 01:23 PM   #4
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: 9,129
Karma: 40942904
Join Date: Jan 2010
Device: Nexus 7, Kindle Fire HD
Quote:
Originally Posted by theducks View Post
I don't see any MOD action. Maybe you rushed the upload process
Quite likely the case.
DiapDealer is online now   Reply With Quote
Old 08-10-2013, 03:01 PM   #5
Jellby
frumious Bandersnatch
Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.
 
Jellby's Avatar
 
Posts: 6,166
Karma: 4792399
Join Date: Jan 2008
Location: Spaniard in Sweden
Device: Cybook Orizon, Kobo Aura
Quote:
Originally Posted by DiapDealer View Post
For myself, I eventually foresee me creating a Tk graphical front-end that will allow me to choose from several common utilities to be performed for that file type. But I'm in no hurry.
Why not QT? When I created the GUI for the epub2pdf script I was only a novice in python (I still am) and had never done any GUI programming, let alone QT.
Jellby is offline   Reply With Quote
Old 08-10-2013, 03:16 PM   #6
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: 9,129
Karma: 40942904
Join Date: Jan 2010
Device: Nexus 7, Kindle Fire HD
Quote:
Originally Posted by Jellby View Post
Why not QT? When I created the GUI for the epub2pdf script I was only a novice in python (I still am) and had never done any GUI programming, let alone QT.
Even though I said "for myself," I'll more than likely share whatever I come up with. So even though I prefer the look of QT (and agree that it's fairly painless), I usually try to confine my scripts to modules that will work with "standard" Python installs. TKinter is standard in most Linux flavors (as well as OS X), and comes with Activestate's Python for Windows as well. PyQt is usually an addon. I enjoy sharing python scripts that other users won't need to install extra modules to get up and running. I guess you could say it was a slightly obsessive hobby of mine.
DiapDealer is online now   Reply With Quote
Old 08-13-2013, 01:05 AM   #7
GrannyGrump
Persnickity Nitpicker
GrannyGrump ought to be getting tired of karma fortunes by now.GrannyGrump ought to be getting tired of karma fortunes by now.GrannyGrump ought to be getting tired of karma fortunes by now.GrannyGrump ought to be getting tired of karma fortunes by now.GrannyGrump ought to be getting tired of karma fortunes by now.GrannyGrump ought to be getting tired of karma fortunes by now.GrannyGrump ought to be getting tired of karma fortunes by now.GrannyGrump ought to be getting tired of karma fortunes by now.GrannyGrump ought to be getting tired of karma fortunes by now.GrannyGrump ought to be getting tired of karma fortunes by now.GrannyGrump ought to be getting tired of karma fortunes by now.
 
GrannyGrump's Avatar
 
Posts: 565
Karma: 2634426
Join Date: May 2011
Location: JAPAN (US expatriate)
Device: Sony PRS-T2, ADE on PC
Thank you for the plugins. I am really looking forward to using "Smarten Punctuation", seems like it will be simpler to work from within Sigil rather than having to use Calibre and its plugin.
GrannyGrump is offline   Reply With Quote
Old 08-13-2013, 06:49 AM   #8
mrmikel
Book Twiddler
mrmikel ought to be getting tired of karma fortunes by now.mrmikel ought to be getting tired of karma fortunes by now.mrmikel ought to be getting tired of karma fortunes by now.mrmikel ought to be getting tired of karma fortunes by now.mrmikel ought to be getting tired of karma fortunes by now.mrmikel ought to be getting tired of karma fortunes by now.mrmikel ought to be getting tired of karma fortunes by now.mrmikel ought to be getting tired of karma fortunes by now.mrmikel ought to be getting tired of karma fortunes by now.mrmikel ought to be getting tired of karma fortunes by now.mrmikel ought to be getting tired of karma fortunes by now.
 
Posts: 2,058
Karma: 1444487
Join Date: Apr 2008
Location: Central Oregon Coast
Device: PRS-300
I don't need a wood burning computer....I fume all by myself. LOL
mrmikel is offline   Reply With Quote
Old 08-13-2013, 05:45 PM   #9
varlog
just member
varlog has not lost his or her sense of wonder.varlog has not lost his or her sense of wonder.varlog has not lost his or her sense of wonder.varlog has not lost his or her sense of wonder.varlog has not lost his or her sense of wonder.varlog has not lost his or her sense of wonder.varlog has not lost his or her sense of wonder.varlog has not lost his or her sense of wonder.varlog has not lost his or her sense of wonder.varlog has not lost his or her sense of wonder.varlog has not lost his or her sense of wonder.
 
varlog's Avatar
 
Posts: 100
Karma: 86836
Join Date: Sep 2012
Location: Europa
Device: prs t1
On my Ubuntu 12.04 32 I had to make *.sh files executable to make it work - which is obvious but perhaps not to all.
Undo function function doesn't know anything about plugins (ditto) - but you don't have to save (save before ).
toc.ncx shows the old data (uuid) - you have to save and open again to see changes - which only shows that I don't know my Sigil yet .

And when speaking about not knowing: at the moment Sigil monitors the tmp files and reacts immediately to any changes - is it reliable feature?

Nice.
varlog is offline   Reply With Quote
Old 08-13-2013, 06:35 PM   #10
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: 9,129
Karma: 40942904
Join Date: Jan 2010
Device: Nexus 7, Kindle Fire HD
Yes, the Generate UUID script doesn't currently change the matching uuid in the toc.ncx file. Mainly because I forgot about there BEING an id entry in the ncx!

Quote:
And when speaking about not knowing: at the moment Sigil monitors the tmp files and reacts immediately to any changes - is it reliable feature?
It can be a bit flaky, actually. If you look at the bash scripts, you'll see some commented out lines I was experimenting with. If the Sigil UI doesn't seem to react to your changes to the tmp files (visually), you may have to experiment with those commented out commands and see if one works better than the other for you.

Launching a terminal (gnome-terminal in my case) from the bash script and executing the commands seems to have pretty reliable results, though. Seems Sigil likes the "editor" to actually take the focus away from it. It's not a problem on Windows since it always opens a terminal window when launching the scripts.

Something for the TODO list is to modify the Smarten Punctuation script so that if no punctuation is altered, it doesn't save the file. The way it works currently, the file is ALWAYS modified. It works for what I want to do with it, but that may be sticking point for other users.

Last edited by DiapDealer; 08-13-2013 at 07:55 PM.
DiapDealer is online now   Reply With Quote
Old 08-13-2013, 07:09 PM   #11
varlog
just member
varlog has not lost his or her sense of wonder.varlog has not lost his or her sense of wonder.varlog has not lost his or her sense of wonder.varlog has not lost his or her sense of wonder.varlog has not lost his or her sense of wonder.varlog has not lost his or her sense of wonder.varlog has not lost his or her sense of wonder.varlog has not lost his or her sense of wonder.varlog has not lost his or her sense of wonder.varlog has not lost his or her sense of wonder.varlog has not lost his or her sense of wonder.
 
varlog's Avatar
 
Posts: 100
Karma: 86836
Join Date: Sep 2012
Location: Europa
Device: prs t1
I think at the moment that ncx is build (rebuild?) on the fly when you open a book (Devs please?).
And of course I've seen yours commented out... I've partly uncommented - and added my own to verify.
And of course (Google is the saviour!) I don't speak python .

tk (and SmartyPants!) was not included in my standard python installation - so it is quite ok to use qt I guess.
varlog is offline   Reply With Quote
Old 08-19-2013, 04:06 PM   #12
Perkin
Guru
Perkin calls his or her ebook reader Vera.Perkin calls his or her ebook reader Vera.Perkin calls his or her ebook reader Vera.Perkin calls his or her ebook reader Vera.Perkin calls his or her ebook reader Vera.Perkin calls his or her ebook reader Vera.Perkin calls his or her ebook reader Vera.Perkin calls his or her ebook reader Vera.Perkin calls his or her ebook reader Vera.Perkin calls his or her ebook reader Vera.Perkin calls his or her ebook reader Vera.
 
Perkin's Avatar
 
Posts: 644
Karma: 64171
Join Date: Sep 2010
Location: Kent, England, Sol 3, ZZ9 plural Z Alpha
Device: Sony PRS-300, Kobo Aura HD
I've created one to add to these, it strips all the empty <span> elements
(and their corresponding (and correct) closing </span>'s)
Attached Files
File Type: zip strip_empty_spans_plugin.zip (1.4 KB, 98 views)
Perkin is offline   Reply With Quote
Old 08-19-2013, 07:41 PM   #13
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: 9,129
Karma: 40942904
Join Date: Jan 2010
Device: Nexus 7, Kindle Fire HD
It's a plugin revolution!
DiapDealer is online now   Reply With Quote
Old 08-20-2013, 02:01 AM   #14
roger64
Wizard
roger64 ought to be getting tired of karma fortunes by now.roger64 ought to be getting tired of karma fortunes by now.roger64 ought to be getting tired of karma fortunes by now.roger64 ought to be getting tired of karma fortunes by now.roger64 ought to be getting tired of karma fortunes by now.roger64 ought to be getting tired of karma fortunes by now.roger64 ought to be getting tired of karma fortunes by now.roger64 ought to be getting tired of karma fortunes by now.roger64 ought to be getting tired of karma fortunes by now.roger64 ought to be getting tired of karma fortunes by now.roger64 ought to be getting tired of karma fortunes by now.
 
Posts: 1,436
Karma: 846401
Join Date: Jan 2009
Device: KoboGlo
Hi

A good idea.

Even after making the scripts executable, I fail to launch them. Maybe my python version is too old?
roger64 is offline   Reply With Quote
Old 08-20-2013, 06:50 AM   #15
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: 9,129
Karma: 40942904
Join Date: Jan 2010
Device: Nexus 7, Kindle Fire HD
Or too new. They probably won't work if your default python is 3.0 or higher. They need to be run with python 2.x (or you may need to hardcode the location of your python interpreter in the bash script). Also, make sure it is the bash script you are making executable, and pointing to with Sigil's Open With feature -- and not the python script. It won't matter if the python script is executable as you won't be launching it directly. Also keep all the files together in one directory -- don't move the bash scripts in relation to the python scripts.

If none of that gets you going, I'd suggest taking Sigil out of the equation. Launch one of the bash scripts from a terminal and see what's happening.
DiapDealer is online now   Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Sigil 0.3.4 / Sigil 0.4.0 RC1 / Cover in Nook Color Bertrand Sigil 13 08-06-2011 04:06 AM
Sigil 0.3.4 / Problème CSS entre Sigil et iPad Grivels Software 10 07-03-2011 09:06 AM
Plugins junkml Plugins 32 06-19-2009 06:43 AM
Plugins? Mitchll Plugins 0 12-27-2008 02:36 PM


All times are GMT -4. The time now is 08:43 AM.


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