Register Guidelines E-Books Today's Posts Search

Go Back   MobileRead Forums > E-Book Software > Sigil

Notices

Reply
 
Thread Tools Search this Thread
Old 09-05-2022, 04:51 AM   #1
byword
Junior Member
byword began at the beginning.
 
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?
byword is offline   Reply With Quote
Old 09-05-2022, 07:19 AM   #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: 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.
DiapDealer is offline   Reply With Quote
Advert
Old 09-05-2022, 04:30 PM   #3
odamizu
just an egg
odamizu ought to be getting tired of karma fortunes by now.odamizu ought to be getting tired of karma fortunes by now.odamizu ought to be getting tired of karma fortunes by now.odamizu ought to be getting tired of karma fortunes by now.odamizu ought to be getting tired of karma fortunes by now.odamizu ought to be getting tired of karma fortunes by now.odamizu ought to be getting tired of karma fortunes by now.odamizu ought to be getting tired of karma fortunes by now.odamizu ought to be getting tired of karma fortunes by now.odamizu ought to be getting tired of karma fortunes by now.odamizu ought to be getting tired of karma fortunes by now.
 
odamizu's Avatar
 
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??
odamizu is offline   Reply With Quote
Old 09-05-2022, 04:56 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: 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?
DiapDealer is offline   Reply With Quote
Old 09-05-2022, 05:23 PM   #5
KevinH
Sigil Developer
KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.
 
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.
KevinH is online now   Reply With Quote
Advert
Old 09-05-2022, 08:36 PM   #6
odamizu
just an egg
odamizu ought to be getting tired of karma fortunes by now.odamizu ought to be getting tired of karma fortunes by now.odamizu ought to be getting tired of karma fortunes by now.odamizu ought to be getting tired of karma fortunes by now.odamizu ought to be getting tired of karma fortunes by now.odamizu ought to be getting tired of karma fortunes by now.odamizu ought to be getting tired of karma fortunes by now.odamizu ought to be getting tired of karma fortunes by now.odamizu ought to be getting tired of karma fortunes by now.odamizu ought to be getting tired of karma fortunes by now.odamizu ought to be getting tired of karma fortunes by now.
 
odamizu's Avatar
 
Posts: 1,827
Karma: 7943430
Join Date: Mar 2015
Device: Kindle, iOS
Quote:
Originally Posted by DiapDealer View Post
Do you see your user-template*.(xhtml|css) files when you click the "Open Preferences Location" button in Sigil's preferences?
Yes

Quote:
Originally Posted by KevinH View Post
on macOS, for me that is:

/Users/kbhend/Library/Application Support/sigil-ebook/sigil

You would need to replace "kbhend" with your own userid.
Yes, sorry, when I write "User > Library" I do mean "Users > username > Library".

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.
odamizu is offline   Reply With Quote
Old 09-05-2022, 09:05 PM   #7
byword
Junior Member
byword began at the beginning.
 
Posts: 8
Karma: 10
Join Date: Apr 2022
Device: Onyx Leaf 3
Thank you

Quote:
Originally Posted by DiapDealer View Post
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.
I understand and it is working!
Thank you!
byword is offline   Reply With Quote
Old 09-05-2022, 10:01 PM   #8
KevinH
Sigil Developer
KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.
 
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:
Originally Posted by odamizu View Post
Yes



Yes, sorry, when I write "User > Library" I do mean "Users > username > Library".

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.
KevinH is online now   Reply With Quote
Old 09-05-2022, 10:34 PM   #9
odamizu
just an egg
odamizu ought to be getting tired of karma fortunes by now.odamizu ought to be getting tired of karma fortunes by now.odamizu ought to be getting tired of karma fortunes by now.odamizu ought to be getting tired of karma fortunes by now.odamizu ought to be getting tired of karma fortunes by now.odamizu ought to be getting tired of karma fortunes by now.odamizu ought to be getting tired of karma fortunes by now.odamizu ought to be getting tired of karma fortunes by now.odamizu ought to be getting tired of karma fortunes by now.odamizu ought to be getting tired of karma fortunes by now.odamizu ought to be getting tired of karma fortunes by now.
 
odamizu's Avatar
 
Posts: 1,827
Karma: 7943430
Join Date: Mar 2015
Device: Kindle, iOS
Quote:
Originally Posted by KevinH View Post
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.
After adding the template files, I exited fully out of Sigil then started it back up. I tried this multiple times, so that's not it.

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?
odamizu is offline   Reply With Quote
Old 09-06-2022, 07:25 AM   #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: 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.
DiapDealer is offline   Reply With Quote
Old 09-06-2022, 09:47 AM   #11
KevinH
Sigil Developer
KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.
 
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;
}
and

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.
KevinH is online now   Reply With Quote
Old 09-06-2022, 11:14 AM   #12
CubGeek
Connoisseur
CubGeek began at the beginning.
 
Posts: 52
Karma: 10
Join Date: Sep 2021
Location: Upstate NY, USA
Device: iPad Pro, Kindle basic
Quote:
Originally Posted by odamizu View Post
Am I the only one where the templates only work with EPUB2 and don't work with EPUB3?
Windows 10 (21H2)
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.
CubGeek is offline   Reply With Quote
Old 09-06-2022, 11:17 AM   #13
KevinH
Sigil Developer
KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.
 
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.
KevinH is online now   Reply With Quote
Old 09-06-2022, 12:47 PM   #14
odamizu
just an egg
odamizu ought to be getting tired of karma fortunes by now.odamizu ought to be getting tired of karma fortunes by now.odamizu ought to be getting tired of karma fortunes by now.odamizu ought to be getting tired of karma fortunes by now.odamizu ought to be getting tired of karma fortunes by now.odamizu ought to be getting tired of karma fortunes by now.odamizu ought to be getting tired of karma fortunes by now.odamizu ought to be getting tired of karma fortunes by now.odamizu ought to be getting tired of karma fortunes by now.odamizu ought to be getting tired of karma fortunes by now.odamizu ought to be getting tired of karma fortunes by now.
 
odamizu's Avatar
 
Posts: 1,827
Karma: 7943430
Join Date: Mar 2015
Device: Kindle, iOS
Quote:
Originally Posted by KevinH View Post
... 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
Ha! I knew I was doing something stupid.

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
odamizu is offline   Reply With Quote
Old 09-06-2022, 01:16 PM   #15
KevinH
Sigil Developer
KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.
 
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!
KevinH is online now   Reply With Quote
Reply


Forum Jump

Similar Threads
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


All times are GMT -4. The time now is 12:03 PM.


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