1

I would like to be able to include th1 code in a Fossil wiki page. Specifically, I want a particular page to display different information depending on the user. It is easy to do that in the header or footer, but I haven't found any way to insert th1 code directly into a wiki document.

Edit:

A hack that I found is to generate Javascript in the header to generate the variables using th1, like this:

<th1>
html "<script>var foo = \"$login\";</script>"
</th1>

I can then insert a Javascript call directly in the Markdown file, like this:

<script>document.write(foo);</script

Since this is a hack, and requires generating those variables in the header of every page, I would prefer to use th1 directly in the wiki page itself.

user2225804
  • 761
  • 8
  • 22

1 Answers1

2

I don't think this is possible, for security reasons: if TH1 were enabled for wikis, anyone with wiki permissions would be able to execute code... Even the use of HTML in wiki has to be enabled explicitly.

Your workaround (or hack) using Javascript works fine; to prevent that Javascript from being included in each and every page, you can use the TH1 statement enable_output followed by 0 to disable the output to the page. Put that after an if condition on the page name, and you're good to go. Don't forget to re-enable output with enable_output 1 after your bit of Javascript!

Edit: here's an example that I use to include syntax highlighting on the /artifact page. You would replace the link tag with a script element. Also note that I use ne (not equal) to omit the syntax highlighting from every page but the artifact page.

<th1>
  if { "$current_page" ne "artifact" } {
    enable_output 0
  }
</th1>
    <link rel="stylesheet" href="$highlighterpath/styles/shCoreDefault.css" type="text/css" media="screen" />
<th1>
  enable_output 1
</th1>
Martijn
  • 13,225
  • 3
  • 48
  • 58