Mixin Classes in Odoo 17 How to Extend Models Using Mixin Classes
How to make an e book in an afternoon
1. Make an eBook in an Afternoon
How to make eBooks in the ePub and MOBI (KF8
compatible) formats using free software.
These instructions are intended as a how-to guide for making eBooks using
free and widely available software. If you devote a couple of hours to following
them, you should have a properly formatted, glitch-free eBook ready for
publication.
This lesson will show you how to make eBooks in the most widely used eBook
format (ePub) and then convert this to the Amazon Kindle format (MOBI).
We’ll be looking at the example of making an eBook version of a novel, but
the same principles apply for books of short stories, poetry, non-fiction, etc.
Before you start, you’ll need to have the following things ready:
• The text of your book in rft (rich text) format. You can choose to save a
document in rtf format from MS Word.
• Another rtf document containing the text of the jacket blurb and any
review quotes.
• A high-res jpeg image of the book’s cover (minimum 600x800 pixels).
And you’ll need to download and install these two software applications:
Sigil. This is an open-source ‘WYSIWYG’ (What You See Is What You
Get) ePub editing application. It's basically a split-screen xhtml editor
that lets you see what your book's pages will look like as you make
changes to the xhtml code. Download it
from http://code.google.com/p/sigil/.
Get the latest stable version you can run on your machine, as the later
versions have more time-saving functionality.
Kindle Previewer. This converts ePub files to the newest version of
MOBI (which is compatible with Kindle eInk readers, the Kindle Fire
and the iPad) and allows you to view them more or less as they will
appear on a Kindle device. Download it at
http://www.amazon.com/kindleformat/KindlePreviewer
2. Part One.
Open the Sigil application. This will automatically open a new ePub file. Save
the file as the title of your book, e.g. ‘Novel’.
Open the .rtf file of your book in either Text Editor (on a Mac) or Wordpad (on
a PC). Copy the text of your book, excluding the title page, prelims and table
of contents.
and paste it into the Sigil page (which will automatically have been named
‘Section 1’). It should now look like this:
3. Now highlight the name of the first chapter, and from the drop-down menu at
the top left of the menu bar, select ‘Heading 2’.
The text should now look like this:
Then go through the text, highlighting each chapter title and formatting it as
Heading 2.
You’ll see the following 3 buttons at the top of the Sigil window:
= Book view. This lets you see what the formatting will look like in
the finished book
= Split view. Click this button to see both the finished page and the
xhtml code behind it.
= Code view. Click this button to view the xhtml only.
If you toggle to code view, and look closely a the xhtml, you’ll see that tags
have been attached to the text ‘Chapter One’, so it reads <h2>Chapter
One</h2>. This is because you formatted it as Heading 2.
4. It’s worth noting at this stage that Sigil automatically generates a table of
contents (TOC) for your book using the header tags you apply. The table of
contents allows someone viewing an ePub file on a reading device to navigate
through the text.
Sigil will look for the <h> </h> tags in the xhtml code, and add whatever text is
between them to the table of contents. It does this on a hierarchical basis,
with Header 1 being the top level, and Header 6 being the bottom level. E.g.:
Chapter One (set in Header 2)
Chapter Two (set in Header 2)
Chapter Three (set in Header 2)
Chapter Four (set in Header 2)
Sub-chapter 1 (set in Header 3)
Sub-chapter 2 (set in Header 3)
Chapter Five (set in Header 2)
…and so on.
Now toggle back to ‘book view’, using this button.
At the moment, the chapter titles are aligned to the left, but you’ll want to
centre them. To do this, highlight your first chapter heading (e.g. ‘Chapter
One’) and click the ‘centre text’ button on the menu bar:
Now your book should look like this:
If you toggle to ‘code view’, you’ll see that some new code has appeared, as if
by magic. The first bit to pay attention to is near the top of the page. It’ll
appear in khaki.
<style type="text/css">
h2.sgc-3 {text-align: center;}
</style>
5. This is CSS code. CSS stands for ‘Cascading Style Sheets’, and it’s
essentially a labour-saving way of implementing complex formatting
throughout a document, by setting out some rules at the start. The CSS rule
that has just been written is, as you might expect, about centring.
The buttons on the menu at the top of your Sigil window will each implement
different CSS rules. But to make a really nice looking eBook, it’s useful to
understand enough about CSS to be able to write it yourself.
CSS rules have 3 components. The ‘selector’, the ‘property’ and the ‘value’. In
the rule: h2.sgc-3 {text-align: center;}
h2.sgc-3 is the selector, text-align is the property, and center is the value.
These rules are then imposed on the text itself using tags, like this:
<h2 class="sgc-3">Chapter One</h2>
Because the text ‘Chapter One’ is tagged with the selector <h2
class="sgc-3"> the corresponding CSS rule at the top of the document is
applied, and the text is centred.
Why use CSS? Well, you might want to implement formatting changes on
multiple sections of text. It would take forever to write out all the different
styles in tags around each bit of text you want to change. Instead, you can
compile them as one CSS rule.
The next section will require you to write some actual code. But don’t be
daunted! Yes, it looks like squiggles at first, but soon it will start to make
sense, and once you’ve learned a bit, you’ll be in command of the formatting
of your book.
Now we’re going to amend the CSS rule so that it centres not just the first
chapter heading, but all text tagged in the Heading 2 style.
To do this, go into ‘code view’ and change the CSS rule:
h2.sgc-3 {text-align: center;}
to this:
h2{text-align: center;}
(all you’re doing is deleting the code: .sgc-3)
Now toggle back to ‘book view’ and look at the page. All the chapter headings
should now be centred. If it hasn’t worked, go back into code view and check
you’ve got the CSS exactly right.
In page view, you’ll notice the body text is all left-justified, each paragraph is
separated by a line break, and there are no indents. Yuk!
6. Let’s fix that in the CSS.
Copy these CSS rules (you should be able to copy and paste them from this
pdf document):
h2 {text-align: center;}
p.sgc-2 {text-align: center;}
h1.sgc-1 {text-align: center;}
p.sgc-4 {text-align: center;}
h4.sgc-2 {text-align: center;}
h2.drop {margin 0 0 0 1em 0;}
p {text-indent: 2em; margin:0 0 .2em 0;}
p.noindent {text-indent: 0; }
…and paste them over the line of CSS in the code view of your Sigil book.
so it looks
like this:
Now toggle to ‘book view’. The text should look like this:
Great! We have indents! However, the first line of body text is still indented
and we don’t want it to be (according to most publishers’ house-styles, there
should be no indentation after a line-break).
7. There’s a quick fix for this. Toggle to ‘code view’. Find this bit of code, which
appears right at the start of the first line of body text, and copy it from the
code view page (not from this document):
<p><br /></p>
<p>
Now open the find & replace tool, using this button on the menu bar:
Paste the code into the ‘find’ field. Then paste in the following code into the
‘replace’ field.
<p><br /></p> <p class=noindent>
And click ‘replace all.’ This should locate all line breaks and ensure that the
proceeding paragraph is not indented.
Tip – Sigil sometimes reverts find-and-replace changes when you switch back
to ‘book view’. If this happens, click your cursor onto the page of code before
you switch to ‘book view’.
We also want to justify the body text. Highlighting all the sections of text that
need to be justified and hitting the justify button is time consuming, especially
if it’s a long book. Using CSS will save time. So, toggle to ‘code view’ and find
this CSS rule:
p {text-indent: 2em; margin:0 0 .2em 0;}
and add this code, before the closing brace:
text-align: justify;
So the whole rule now reads:
p {text-indent: 2em; margin:0 0 .2em 0; text-align: justify;}
If you toggle to ‘book view’, the body text should now be justified throughout
the book, so it looks like this:
8. That’s Part One finished! Save what you’ve done so far before continuing to
Part Two.
Part Two
The chapters of your book will be listed in the Table of Contents (TOC)
because of the way you’ve formatted the chapter titles with h2 tags. If you’re
using a recent version of the Sigil software, there’ll be a pane on the right
hand side of your window displaying all the items in the TOC. If you have an
earlier version of Sigil, you’ll need to go to Menu/Tools/TOC Editor to view it.
Here you can see the TOC items and uncheck any you don’t want to include.
Now we’re going to divide up the book, so that each chapter begins on a
dedicated page. Here’s how:
In ‘book view’, click your cursor just after the body text at the end of the first
chapter. Then on the menu, select Insert/Chapter Break.
This will split the book into 2 distinct sections, which you’ll see listed in the left
hand pane as Section0001.xhtml and Section0002.xhtml. Continue through
the text, adding new Chapter Breaks for each chapter (but with care – you
can’t undo this!).
Tip – It doesn’t really matter what the pages within an eBook are called, i.e.
Section0001.xhtml, Section0001.xhtml, etc. These page names are for the
book’s internal reference only – the reader will never see them.
So far, so good. You’ve laid out and formatted the novel, and separated it into
chapters, which have automatically been added to the TOC. Unfortunately,
this is the point where ePub and MOBI (the Kindle format) compatibility issues
raise their heads. For eBook readers using the ePub file format, the TOC you
9. already have should make the eBook perfectly navigable. But for Kindle
devices, you need to build a dedicated Contents page. Here’s how:
1) First of all, in the left hand pane, right click on one of the existing pages
(e.g. Section0001.xhtml) and select ‘Add New Item.’ A new page will be
created. Rename this page ‘Contents.xhtml’ (by right clicking on it and
selecting ‘rename’). Then right click on it again and select ‘Add Semantics’;
then ‘Table of Contents.’ You can drag and drop this page in the left hand
pane so it’s at the top of the list, and will appear as the first page in the book.
2) Now go back to the original rtf document of the book, copy the text from the
contents page. Paste it into the eBook page you just created.
3) Write ‘Contents’ at the top of the page, format it as Heading 2, and centre
it.
4) As eBooks don’t use page numbers, the next thing you need to do is delete
the page numbers listed on the page.
By now, your contents page should look something like this:
5) Now you need to make it navigable. Toggle to ‘code view’.
To link the text ‘Chapter One’ to that page within the eBook, you’ll need to
insert some code. Pasting in the following code will link the text ‘Chapter One’
with the xhtml page called ‘Section0001.xhtml’.
<a href="../Text/Section0001.xhtml">Chapter One</a>
If you now toggle to ‘book view’, and click on the text ‘Chapter One’ (which will
appear in blue), you should navigate to the xhtml page ‘Section001.’
To build the table of contents, repeat this step for each chapter.
When you’ve finished, check that the hyperlinks are correct by clicking on
each chapter name on the Contents Page to see if it links to the right chapter.
10. Tip – the old Kindle eInk devices will sometimes arbitrarily indent some items
on a contents page. To avoid this, highlight your all chapter headings on the
contents page and left justify them using the button on the menu.
Prelims
Some publishers don’t consider it necessary to add a prelims page to an
eBook, as copyright and publisher information will be included in the metadata
(more about this later). However, if you want to add a prelims page, here’s
how to do it.
1) First, right click on one of the existing pages (e.g. Section0001.xhtml) and
select ‘Add New Item.’ A new page will be created. Rename this page
‘Prelims.xhtml’ (by right clicking on it and selecting ‘rename’). Then right click
on it again and select ‘Add Semantics’; then select ‘Copyright Page’.
2) Paste in your prelims text and centre it.
3) You may well want the prelims text to appear smaller than normal-sized
text. There are two ways of achieving this.
a) In ‘code view’, paste this CSS over the existing CSS code in the
Prelims page:
p.sgc-1 {font-size: 50%; text-align: center}
That should make the text 50% smaller.
Tip – Kindle devices, particularly the eInk Kindle readers, have limited support
for different sized text within an eBook. This was essentially because the
‘vision’ of these devices was to give the user control over this aspect of the
reading experience – setting the text size themselves. Amazon have revised
this with the Kindle Fire, which allows publishers to have more control over
font sizes.
The upshot is, before publication of your eBook, you must road-test your
eBook on a range of devices, old and new (not just the Kindle Previewer
software), to see whether your prelims text appears in the size you want.
Cover Image
Here’s how to insert a cover image.
1) Make sure you have the cover image saved somewhere on your computer.
It should be a jpeg of at least 600 x 800 pixels resolution.
11. 2) Right click on the folder ‘Images’ in the left hand pane. Select ‘Add Existing
Item’. This will prompt you to import an image file.
3) Once imported, right click on the image file and select ‘Add Semantics’;
then select ‘Cover Image’.
Metadata
Metadata is information about the book, including the title, the author’s name,
copyright information, a description of the contents, a blurb, press quotes, a
list of territories in which the eBook will be available (which will depend on the
rights specified in your contract with the book’s author), and in some cases,
an ISBN*. You can find much of this information on the jacket of a book, or on
the prelims pages.
Metadata doesn’t appear within the pages of an eBook, but is included as part
of the ePub file.
Metadata is important when it comes to having your book sold by eBook
retailers. Crucially, it’s what allows customers find your book when they
search online (and remember, they might not search for the book’s title or the
author’s name, but by topic, theme or genre). Without the right metadata, a
retailer may not accept your eBook, or it might not be very visible when
people search for your book.
*Technically, there’s no requirement for an eBook to carry an ISBN. EBooks
sold on Amazon, for example, don’t need one. However, some eBook retailers
demand it, so allocating it one now could save you hassle in the future. It
should not be the same ISBN as the hard-copy edition, as this leads to
confusion when customers search for the book using the ISBN.
How to add metadata
1) In the top menu, select ‘Tools/Meta Editor’.
2) Add the book’s name and the author’s name.
3) Click ‘Add Basic’. As a bare minimum, I’d recommend adding a Description
(use your blurb text for this), the Publisher, the Publication Date, the ISBN if
you’re allocating it one, and ‘Rights’. In ‘Rights’, list the territories in which you
have the right or license to sell the eBook.
4) Click ‘Add Advanced’. Here, as a minimum, I’d add Copyright Holder,
Designer, Editor (if an anthology), and Translator (if applicable).
12. Checking – the first round
First of all, have a quick scroll through each chapter of the book in Sigil.
Obvious things to check are:
• Are the chapter headings centered and correctly formatted as h2?
• If the body text uses numbers, asterixes or other symbols to divide sub-
sections of a chapter, are these centered?
• Is the body text correctly indented on the first line of each new
paragraph?
• When there’s a line break, is the proceeding paragraph unindented? If
not, replace the opening <p> tag of the proceeding paragraph with <p
class=”noindent”>
• Do the chapter titles on the Contents Page hyperlink to the
corresponding chapter in the book?
• Are the prelims the correct size?
• And obviously, look for any miscellaneous typos that may have crept
in. Pay particular attention to any text you have added or altered ‘by
hand’ while making the ePub (as opposed to text imported from the rtf).
Conversion to MOBI format.
1) Save the Sigil ePub file.
2) Then open the Kindle Previewer application.
3) From the main menu, select ‘Open’ and then choose your ePub file
from the dialogue box.
At this point, you’ll see a message box telling you the file is being converted.
After a moment, you should get the message ‘Kindle Previewer has
Successfully Compiled the Book. The Output File has been generated
here.’ If this is what you see, click OK and carry on to stage 4 below.
If you see a message that says ‘Kindle Previewer has Successfully
Compiled the Book. But there are warnings !’ this, as you might expect,
means something isn’t quite right.
Click on ‘Compilation Details’, and scroll down to see what the warning is for.
It’s most likely to be one of 2 things, which you’ll need to fix in Sigil before you
proceed:
a) The cover image is too small.
b) There’s a navigation problem in the Table of Contents, which usually
means a hyperlink on the contents page directs to a page that doesn’t exist in
the book, or visa versa.
13. 4) The Kindle Previewer will automatically open in Kindle Fire mode. But
as the older Kindle eInk reader is the device most prone to formatting
problems, it makes sense to start with that. So on the top menu, select
Devices/Kindle.
5) Now navigate from chapter to chapter, using this button:
…to check that the formatting and alignment of the chapter titles looks
okay.
6) Click this button to see the contents page. Check that all the links
to chapters on the contents page work.
7) From the first Chapter, use this button to scroll back through the
pages to the prelims. Check they look okay.
8) Now scroll forward through every page of the book. It’s probably not
necessary (or a good use of your time) to proof read it. But do at least
scan the formatting and alignment of the text on every page.
9) Now repeat the process in ‘Kindle Fire’ and ‘iPad’ modes.
Once you’re satisfied it’s all looking good (and, if you’ve gone back to make
any changes in Sigil, you’ve re-checked it in the Kindle Previewer) you’re
ready to check it on the Kindle itself.
1) Kindle Previewer will have automatically created a new folder in the
same location as your ePub was saved. The MOBI file of your eBook
will be saved in here.
2) If you’ve opened your eBook in Previewer more than once, you’ll have
several MOBI files in here. Make sure you select the latest version.
3) Plug your kindle device into your computer.
4) Drag and drop this MOBI file into the ‘documents’ folder of your Kindle.
5) Disconnect (by safely ejecting it!), then check how the eBook looks on
the Kindle, using the same checklist as above.
Kindle eInk and Kindle Fire compatibility.
As noted above, the older Kindle eInk devices do not support some formatting
commonly used in ePub files. Many of these glitches have been ironed out
with the introduction of the Kindle Fire device and the new, KF8-compatible
updated MOBI file format.
But it’s worth bearing in mind that many of your customers will have older
Kindle eInk reading devices, so it makes sense to check how your book looks
in the Kindle Previewer in ‘Kindle’ mode, and on an actual Kindle eInk
device prior to publishing it.
To learn more about compatibility issues, you can find a full list of the xhtml
tags supported by different Kindle devices on page 52 of this document:
http://kindlegen.s3.amazonaws.com/AmazonKindlePublishingGuidelines.pdf.
14. If you don’t have a Kindle, you can drop into the Literature Northwest office to
test your eBook files on our Kindle. Please email ra.page@commapress.co.uk
to arrange this in advance.
Now you’re ready to publish!
It’s really straightforward to sell a book on Amazon. You can set-up an
account on the Amazon Kindle Direct Publishing website:
https://kdp.amazon.com/self-publishing/signin