Fossil User Forum

Customize footer with TH1 "unversioned content" not working
Login

Customize footer with TH1 "unversioned content" not working

Customize footer with TH1 "unversioned content" not working

(1) By Joel Dueck (joeld) on 2020-02-08 16:56:23 [source]

Can anyone explain why this might not be working? I’ve customized my footer to include a TH1 directive to include the contents of an unversioned file as shown below:

<div class="footer">
This page was generated in about
<th1>puts [expr {([utime]+[stime]+1000)/1000*0.001}]</th1>s by
Fossil $release_version $manifest_version $manifest_date
</div>
</main>

<th1>unversioned content scribbled/site-footer.html</th1>

<script nonce="$nonce">
<th1>styleScript</th1>
</script>

However when I apply the change and look at the draft1 skin preview, the <th1> tag and its contents are replaced with nothing. No output is visible either in the browser or in the HTML source.

The file scribbled/site-footer.html is present in the unversioned files, and it contains a fragment of HTML inside a <footer> tag.

I can see other changes that I put in the footer. If I change the TH1 command to refer to an erroneous non-existent file, I see a big red error message. But if I change it back to the correct/existing file, nothing.

I can also go to the /admin_th1 page and run the same command unversioned content scribbled/site-footer.html and get the expected output.

Thinking that perhaps Fossil is trying to sanitize or santiy-check the string that appear in the footer, I tried moving the TH1 command inside the first <div> tag, but that also did not help.

(2) By Warren Young (wyoung) on 2020-02-08 23:19:35 in reply to 1 [link] [source]

The call to unversioned content is returning a string containing the content of that file, which you then don't do anything with, so nothing appears. As with CGI scripts, the only thing that appears in the rendered output of a TH1 script in this context is what the script sends to its stdout via puts. Thus:

<th1>puts [unversioned content scribbled/site-footer.html]</th1>

(3) By Warren Young (wyoung) on 2020-02-08 23:22:26 in reply to 2 [link] [source]

By the way, this customization will likely fail on remote clones. Unversioned file content isn't pulled by default in a clone; you have to either give the -u flag to fossil clone or you later have to call fossil uv pull to get the remote UV content. Then if you do either, you have to explicitly update it every time the remote UV content changes with another fossil uv pull call.

Thus, everyone who does fossil ui is highly likely to either not see this customization or to get outdated footer info.

(4) By Joel Dueck (joeld) on 2020-02-09 04:33:56 in reply to 2 [link] [source]

As with CGI scripts, the only thing that appears in the rendered output of a TH1 script in this context is what the script sends to its stdout

Ah I see. I had a rather different mental model of what was happening here, but then, I’m a LISP guy. Thanks for the pointer.

Another minor (?) problem: using your code, the contents of the unversioned file are now inserted, but they are escaped for HTML, so <h1> in the file becomes &lt;h1&gt; in the output, preventing the file’s HTML from being understood as HTML by the browser.

If I use html instead of puts, it works properly. But this is weird, because the docs say puts “outputs the STRING unchanged”, and that html “outputs the STRING escaped for HTML.” Seems backwards!

(5) By Joel Dueck (joeld) on 2020-02-09 04:47:49 in reply to 3 [link] [source]

Thanks for pointing this out. It isn’t much of an issue in my case, though it is something to be aware of.

Do you know whether the uv-sync option affects the autosync that happens during a commit? And whatever that behavior is, does it still apply if autosync is set to pullonly?

I’m thinking I could set uv-sync to true in the repo’s versioned .fossil-settings folder. Ideally this would mean that once someone had cloned the repo, any future pulls or commit-triggered syncing would get them the newest unversioned files. (And I’d be the only one with “write unversioned” permissions so they wouldn’t accidentally overwrite my files with theirs.)

But if not, this aspect of the repo is mostly cosmetic, and nothing will break if it is out of date or even fails to appear altogether.

(6) By Stephan Beal (stephan) on 2020-02-09 06:32:56 in reply to 5 [link] [source]

I’m thinking I could set uv-sync to true in the repo’s versioned .fossil-settings folder.

Alas, that setting, like its files, is not versionable. All versionable settings are marked with a (v) on the setup_settings page.

(7) By Florian Balmer (florian.balmer) on 2020-02-09 13:39:43 in reply to 4 [link] [source]

If I use html instead of puts, it works properly. But this is weird, because the docs say puts “outputs the STRING unchanged”, and that html “outputs the STRING escaped for HTML.” Seems backwards!

See [fossil-forum] TH1: Confusion about HTMLized outputReply No. 2

(8) By Joel Dueck (joeld) on 2020-02-09 16:24:21 in reply to 7 [link] [source]

I see, thank you.

I totally understand that changing the names and behavior of the commands themselves is not feasible at this point. But fixing the documentation seems like an easy win. Just swap the descriptions of the two commands, and they will match drh’s explanation in that thread.