Register Guidelines E-Books Today's Posts Search

Go Back   MobileRead Forums > E-Book Software > Calibre > Recipes

Notices

Reply
 
Thread Tools Search this Thread
Old 01-04-2012, 06:52 AM   #1
Olger
Member
Olger began at the beginning.
 
Posts: 11
Karma: 10
Join Date: Nov 2011
Device: Kobo Touch
Modding Calibre CSS styles

Hi Folks,

I'm customizing a few recipes for news sites I download, which I'll be reading on a Kobo Touch. The problem I have with Calibre's default templates for news feeds is that the navigation links (next/previous sections, etc) are too small and more often than not result in going forward or backwards a page. Very annoying. There's also a few other CSS styles things I'd like to customize.
I have the CSS styles that I want, and which work a lot better, but I can't find where Calibre keeps its templates. I'm working mostly on a Windows 7 machine with Calibre, and have been searching the C:\Program Files\Calibre for the files but no joy.
I've tried using the extra_css option in the recipe but that appears to be ignored. For that matter, the author and publisher field is also ignored.
Anybody able to point me to where those darn templates are stored? Driving me nuts...
Cheers! Olger.
Olger is offline   Reply With Quote
Old 01-04-2012, 08:01 AM   #2
kovidgoyal
creator of calibre
kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.
 
kovidgoyal's Avatar
 
Posts: 45,195
Karma: 27110894
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
The templates are not stored anywhere, they're hardcoded.
kovidgoyal is offline   Reply With Quote
Old 01-04-2012, 04:47 PM   #3
Olger
Member
Olger began at the beginning.
 
Posts: 11
Karma: 10
Join Date: Nov 2011
Device: Kobo Touch
Thanks Kovid,
Any idea why extra_css doesn't work? Here's the recipe I've got:
from calibre.web.feeds.recipes import BasicNewsRecipe

class ABCNewsRecipe(BasicNewsRecipe):
feeds = [
(u'News: Top Stories', u'http://www.abc.net.au/news/feed/45910/rss.xml'),
(u'News: World', u'http://www.abc.net.au/news/feed/52278/rss.xml'),
(u'News: Australia', u'http://www.abc.net.au/news/feed/46182/rss.xml'),
(u'News: Queensland', u'http://www.abc.net.au/news/feed/50990/rss.xml'),
(u'News: Business', u'http://www.abc.net.au/news/feed/51892/rss.xml'),
(u'Science', u'http://www.abc.net.au/science/news/topic/latest/latest.xml')
]

title = u'ABC News'
oldest_article = 1
max_articles_per_feed = 100
auto_cleanup = True
cover_url = 'file:///d:/ebooks/covers/abcnewscover.jpg'
publication_type = 'newspaper'
author = 'ABC News'
publisher = 'ABC News'
extra_css = ':link:hover { background-color:blue; color: white;}'

Cheers!
Olger is offline   Reply With Quote
Old 01-04-2012, 10:15 PM   #4
kovidgoyal
creator of calibre
kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.
 
kovidgoyal's Avatar
 
Posts: 45,195
Karma: 27110894
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
CSS has complex specificity rules. The rules you specify may not have high enough specificity to override the builtin ones.
kovidgoyal is offline   Reply With Quote
Old 01-05-2012, 02:36 AM   #5
Olger
Member
Olger began at the beginning.
 
Posts: 11
Karma: 10
Join Date: Nov 2011
Device: Kobo Touch
I've used Sigil to place the below CSS rules at the end of the stylesheet.css file created by Calibre in the epub file. That overrides all the styles with the same names earlier in the stylesheet.css, which works fine.
My problem is that extra_css (which is supposed to place an entry in the Styles section in each html file) doesn't add those styles. Calibre seems to ignore my extra_css or there's something not right with how I'm specifying the option. It follows pretty much what the manual says.
The same problem occurs with the author and publisher option. So I'm thinking there's something else not right? Everything is indented (with spaces) as required by python.
If I can get extra_css to work, I'm sure I'll get the styles working the way I want too.
Any ideas? Cheers!

.calibrenavbar {
display: block;
font-family: monospace;
font-size: 1.0em;
text-align: center;
padding: 4px;
}
.article {
color: blue;
cursor: pointer;
font-size: 1.2em;
font-weight: bold;
line-height: 1.2;
text-align: left;
text-decoration: underline;
}
.articledate {
color: gray;
font-family: monospace;
font-size: 0.9em;
}
.articledescription {
display: block;
font-size: 0.8em;
text-indent: 0;
}
:link:active { background-color:blue; color: white;}
:link:hover { background-color:blue; color: white;}
.calibrenavbar.a {
color: blue;
cursor: pointer;
text-decoration: none;
}
a {padding: 4px; }
Olger is offline   Reply With Quote
Old 01-05-2012, 03:09 AM   #6
kovidgoyal
creator of calibre
kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.
 
kovidgoyal's Avatar
 
Posts: 45,195
Karma: 27110894
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
I looked at the code, the font sizes for the navbars are not overridable via extra css (they are specified to be 70% of whatever calibre calculates the base font size for the document to be).
kovidgoyal is offline   Reply With Quote
Old 01-05-2012, 04:50 AM   #7
Olger
Member
Olger began at the beginning.
 
Posts: 11
Karma: 10
Join Date: Nov 2011
Device: Kobo Touch
Sigh. Maybe something to consider as a new feature for a future release? Allow custom CSS into the default stylesheet.css? Could easily be done through an option in the recipe? Add_CSS = '/home/user/blabla' and simply append it to the stylesheet.css?
Anyway, thanks for commenting!
Cheers! Olger.
Olger is offline   Reply With Quote
Old 01-25-2012, 05:08 AM   #8
Olger
Member
Olger began at the beginning.
 
Posts: 11
Karma: 10
Join Date: Nov 2011
Device: Kobo Touch
Finally managed to find a work around for at least part of it. Increasing the size of the navigation bar in recipes can be done, but only on a global (as in entire ebook) scale.
Adding the following:
extra_css = """
a { font-size: 1em; padding: 6px;}
"""
worked a treat for me. It basically increases the size and padding for every anchor in the ebook. Not an issue for me.
Hope someone else find this usefull.
Cheers!
Olger is offline   Reply With Quote
Reply


Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
CSS Table Styles: Does it work? Alan Newson ePub 3 12-12-2011 03:54 PM
CSS Styles From InDesign 5.5 Export Problem SamL ePub 4 11-10-2011 01:46 PM
Tool to centralise css styles? snarkophilus ePub 7 07-01-2011 04:08 AM
CSS styles not displaying in some eReader apps?? jttraverse Sigil 12 05-23-2011 05:31 AM
Sigil styles and CSS View[+]Finder Sigil 4 05-27-2010 05:39 PM


All times are GMT -4. The time now is 07:48 PM.


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