![]() |
#1 |
Junior Member
![]() Posts: 8
Karma: 10
Join Date: Apr 2022
Device: Onyx Leaf 3
|
[1.9.20] css template issue
I update 1.9.20(from 1.9.10) and test new features.
xhtml template(user-template2.xhtml and user-template3.xhtml) and both of Preview custom css is working perfectly. but user-template*.css(user-template2.css / user-template3.css) is not read when i creat new empty EPUB2 and EPUB3. 1. OS : Windows 11 2. Version : Sigil 1.9.20 3. Add user-template2.css and user-template2.css files to [..\sigil-ebook\sigil\] folder 4. restart sigil(css is not read/xhtml is working) and creat new empty EPUB(also css is not working but xhtnk is working) * xhtml templates are working with epub2 and 3 am I missed something? or an error? |
![]() |
![]() |
![]() |
#2 |
Grand Sorcerer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 28,569
Karma: 204127028
Join Date: Jan 2010
Device: Nexus 7, Kindle Fire HD
|
The template is what appears when you right-click the css folder in Book Browser and select "Add Blank Stylesheet". Unlike the xhtml template, a blank Sigil epub has no css file.
|
![]() |
![]() |
Advert | |
|
![]() |
#3 |
just an egg
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 1,827
Karma: 7943430
Join Date: Mar 2015
Device: Kindle, iOS
|
I must be doing something wrong.
I am on macOS Catalina and Sigil 1.9.20. I have placed user-template2.xhtml and user-template2.css in User > Library > Application Support > sigil-ebook > sigil. Then restart Sigil. Right-clicking in Book Browser to Add Blank HTML file and Add Blank Stylesheet simply create generic blank files, not my templates. Help, please?? ![]() |
![]() |
![]() |
![]() |
#4 |
Grand Sorcerer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 28,569
Karma: 204127028
Join Date: Jan 2010
Device: Nexus 7, Kindle Fire HD
|
Do you see your user-template*.(xhtml|css) files when you click the "Open Preferences Location" button in Sigil's preferences?
|
![]() |
![]() |
![]() |
#5 |
Sigil Developer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 8,760
Karma: 5706256
Join Date: Nov 2009
Device: many
|
on macOS, for me that is:
/Users/kbhend/Library/Application Support/sigil-ebook/sigil You would need to replace "kbhend" with your own userid. |
![]() |
![]() |
Advert | |
|
![]() |
#6 | ||
just an egg
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 1,827
Karma: 7943430
Join Date: Mar 2015
Device: Kindle, iOS
|
Quote:
Quote:
Now this is interesting. I just deleted my entire /sigil-ebook/sigil folder to do a clean install and now it works. So clearly something in my pre-existing folder from 1.9.10 was preventing this from working. I will play with this some more later tonight to see if I can figure out what it is. Will keep you posted. |
||
![]() |
![]() |
![]() |
#7 |
Junior Member
![]() Posts: 8
Karma: 10
Join Date: Apr 2022
Device: Onyx Leaf 3
|
Thank you
|
![]() |
![]() |
![]() |
#8 | |
Sigil Developer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 8,760
Karma: 5706256
Join Date: Nov 2009
Device: many
|
I think Sigil looks for those files when a Main Window is first opened. So if you had Sigil-1.9.20 running with one or more Windows open before you added them, those already open windows would not know to look for any templates. Opening a new Main Window should make them work, as should exiting fully out of Sigil then starting it back up.
Quote:
|
|
![]() |
![]() |
![]() |
#9 | |
just an egg
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 1,827
Karma: 7943430
Join Date: Mar 2015
Device: Kindle, iOS
|
Quote:
I played around with this, and interestingly, for me at least, the problem only occurs when I'm working in EPUB3 (which I do almost exclusively, whether creating new epub or editing existing epub). When I create a new EPUB2, the templates work fine. This is with both a clean install and with my pre-existing Sigil preference folder. (I believe the reason it worked when I initially did a clean install is because clean install defaults to EPUB2.) This seems odd to me, as I figure most testers are working with EPUB3. Am I the only one where the templates only work with EPUB2 and don't work with EPUB3? |
|
![]() |
![]() |
![]() |
#10 |
Grand Sorcerer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 28,569
Karma: 204127028
Join Date: Jan 2010
Device: Nexus 7, Kindle Fire HD
|
I can't see any difference on Windows or Linux. It all works as it should regardless of whether it's an epub2 or epub3--new or existing--and regardless of the default epub version setting.
I can't see anything in the code that would make it behave differently on macOS, but Kevin's the expert there. |
![]() |
![]() |
![]() |
#11 |
Sigil Developer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 8,760
Karma: 5706256
Join Date: Nov 2009
Device: many
|
It is all platform agnostic code. It works in my macOS.
This is strange. Code:
HTMLResource *Book::CreateEmptyHTMLFile(const QString &folderpath) { HTMLResource *html_resource = CreateNewHTMLFile(folderpath); QString version = html_resource->GetEpubVersion(); QString data; QString template_path; if (version.startsWith('2')) { template_path = Utility::DefinePrefsDir() + "/" + "user-template2.xhtml"; data = EMPTY_HTML_FILE; } else { template_path = Utility::DefinePrefsDir() + "/" + "user-template3.xhtml"; data = EMPTY_HTML5_FILE; } if (QFile::exists(template_path)) { data = CleanSource::Mend(Utility::ReadUnicodeTextFile(template_path), version); } html_resource->SetText(data); SetModified(true); return html_resource; } Code:
CSSResource *Book::CreateEmptyCSSFile(const QString &folderpath) { TempFolder tempfolder; QString fullfilepath = tempfolder.GetPath() + "/" + m_Mainfolder->GetUniqueFilenameVersion(FIRST_CSS_NAME); Utility::WriteUnicodeTextFile("", fullfilepath); Resource * resource = m_Mainfolder->AddContentFileToFolder(fullfilepath, true, "text/css", QString(), folderpath); CSSResource *css_resource = qobject_cast<CSSResource *>(resource); QString version = css_resource->GetEpubVersion(); QString data = ""; QString template_path; if (version.startsWith('2')) { template_path = Utility::DefinePrefsDir() + "/" + "user-template2.css"; } else { template_path = Utility::DefinePrefsDir() + "/" + "user-template3.css"; } if (QFile::exists(template_path)) { data = Utility::ReadUnicodeTextFile(template_path); } css_resource->SetText(data); SetModified(true); return css_resource; } So long as you used the correct file names it should work. For epub2: user-template2.xhtml user-template2.css and for epub3: user-template3.xhtml user-template3.css Last edited by KevinH; 09-06-2022 at 11:09 AM. |
![]() |
![]() |
![]() |
#12 | |
Connoisseur
![]() Posts: 52
Karma: 10
Join Date: Sep 2021
Location: Upstate NY, USA
Device: iPad Pro, Kindle basic
|
Quote:
Sigil 1.9.20 I have Sigil set in my preferences to default to EPUB3. I opened the Sigil Preferences directory through the button in the preferences dialog, then closed Sigil. I then created a "user-template3.css" and "user-template3.xhtml" into that same directory, using Notepad++. The CSS has a couple of basic entries, and the XHTML file has a basic framework with a couple paragraphs of "Lorem ipsum" content. When I start Sigil, the user-template3.xhtml is automatically loaded and shown as the "OEBPS/Text/Section0001.xhtml" file in the Book Browser. When I right-click the Styles directory and select Add Blank Stylesheet, the user-template3.css is loaded as the "OEBPS/Styles/Style0001.css" file. [Edit] I just tried the same process for EPUB2 (user-template2.*) with a couple changes so I could easily tell if they were the correct files, and when I had Sigil switch to a new EPUB2 document, the xhtml file was loaded as expected as was the CSS file for a new stylesheet. [/Edit] Last edited by CubGeek; 09-06-2022 at 11:28 AM. |
|
![]() |
![]() |
![]() |
#13 |
Sigil Developer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 8,760
Karma: 5706256
Join Date: Nov 2009
Device: many
|
And fwiw, If you want to add more templates at the same time there is a Template plugin that allows loading an entire template epub at the same time while modding the book id as needed.
|
![]() |
![]() |
![]() |
#14 | |
just an egg
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 1,827
Karma: 7943430
Join Date: Mar 2015
Device: Kindle, iOS
|
Quote:
![]() ![]() ![]() From the ChangeLog ("add ability for a user-template*.xhtml and user-template*.css") I thought the * was a true wildcard and you could append anything to "user-template". I didn't realize you had to use 2 and 3 specifically and exclusively, and 2 and 3 referred to epub2 and epub3. So I was testing with user-template2.css and user-template2.xhtml, so of course it only worked with epub2. Now that I've changed it to user-template3.css/xhtml, it works ![]() ![]() ![]() I'll do a pull request to add this to the User Guide in the next few days. As always, thank you @KevinH and @DiapDealer for the new release. Sigil is awesome ![]() |
|
![]() |
![]() |
![]() |
#15 |
Sigil Developer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 8,760
Karma: 5706256
Join Date: Nov 2009
Device: many
|
Good to know. Yes, user's guide needs to be updated and any help with that is always welcome!
|
![]() |
![]() |
![]() |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
A bit of css help for a Kindle Fixed template | holdit | Kindle Formats | 2 | 03-01-2014 04:06 AM |
Issue with Send to Device template | BookJunkieLI | Library Management | 5 | 02-14-2014 01:16 AM |
Looking for help in developing workflow, css, InDesign template | mcoleman | ePub | 3 | 07-24-2013 05:43 PM |
Kindle newbie needs "template" HTML & CSS | Rich_H | Kindle Developer's Corner | 12 | 09-10-2012 11:16 PM |
CSS template for epub for the mobi conversioin | vogella | Kindle Formats | 5 | 11-02-2011 08:19 AM |