Fossil

Check-in [02db05e6]
Login

Check-in [02db05e6]

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Added the nonce="$NONCE" embedded documentation substitution feature and documented that and the other pre-existing text substitution features.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | server-docs
Files: files | file ages | folders
SHA3-256: 02db05e60057a0060246a3d142ede3a83a6c599acb4ae30966f1ea12ffedad0b
User & Date: wyoung 2019-08-18 06:06:01
Context
2019-08-18
06:20
URL fix in previous ... (check-in: a7610e42 user: wyoung tags: server-docs)
06:06
Added the nonce="$NONCE" embedded documentation substitution feature and documented that and the other pre-existing text substitution features. ... (check-in: 02db05e6 user: wyoung tags: server-docs)
05:20
Further refinement of the server setup tutorial matrix CSS ... (check-in: a6fee589 user: wyoung tags: server-docs)
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to src/doc.c.

521
522
523
524
525
526
527
528
529
530


531
532
533
534
535
536






537
538
539
540
541
542
543
*/
void convert_href_and_output(Blob *pIn){
  int i, base;
  int n = blob_size(pIn);
  char *z = blob_buffer(pIn);
  for(base=0, i=7; i<n; i++){
    if( z[i]=='$'
     && strncmp(&z[i],"$ROOT/", 6)==0
     && (z[i-1]=='\'' || z[i-1]=='"')
     && i-base>=9


     && (fossil_strnicmp(&z[i-7]," href=", 6)==0 ||
           fossil_strnicmp(&z[i-9]," action=", 8)==0)
    ){
      blob_append(cgi_output_blob(), &z[base], i-base);
      blob_appendf(cgi_output_blob(), "%R");
      base = i+5;






    }
  }
  blob_append(cgi_output_blob(), &z[base], i-base);
}

/*
** Render a document as the reply to the HTTP request.  The body







<

|
>
>
|
|
|
<
|
|
>
>
>
>
>
>







521
522
523
524
525
526
527

528
529
530
531
532
533
534

535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
*/
void convert_href_and_output(Blob *pIn){
  int i, base;
  int n = blob_size(pIn);
  char *z = blob_buffer(pIn);
  for(base=0, i=7; i<n; i++){
    if( z[i]=='$'

     && (z[i-1]=='\'' || z[i-1]=='"')
     && i-base>=9 ) {
      blob_append(cgi_output_blob(), &z[base], i-base);
      if( strncmp(&z[i],"$ROOT/", 6)==0
       && (fossil_strnicmp(&z[i-7]," href=", 6)==0 ||
             fossil_strnicmp(&z[i-9]," action=", 8)==0)
      ){

        blob_appendf(cgi_output_blob(), "%R");
        base = i+5;
      } else if( strncmp(&z[i],"$NONCE", 6)==0
       && (fossil_strnicmp(&z[i-8]," nonce=", 6)==0)
       && (z[i+6]=='\'' || z[i+6]=='"') ) { 
        blob_append(cgi_output_blob(), style_nonce(), 48);
        base = i+6;
      }
    }
  }
  blob_append(cgi_output_blob(), &z[base], i-base);
}

/*
** Render a document as the reply to the HTTP request.  The body

Changes to www/embeddeddoc.wiki.

91
92
93
94
95
96
97















































98
99
100
101
102
103
104
Then the standard Fossil header and footer are added to the document
prior to being displayed.  The "class='fossil-doc'" attribute is
required for this to occur.  The "data-title='...'" attribute is
optional, but if it is present the text will become the title displayed
in the Fossil header.  An example of this can be seen in the text
of the [/artifact/84b4b3d041d93a?txt=1 | Index Of Fossil Documentation]
document.
















































<h2>Examples</h2>

This file that you are currently reading is an example of
embedded documentation.  The name of this file in the fossil
source tree is "<b>www/embeddeddoc.wiki</b>".
You are perhaps looking at this







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
Then the standard Fossil header and footer are added to the document
prior to being displayed.  The "class='fossil-doc'" attribute is
required for this to occur.  The "data-title='...'" attribute is
optional, but if it is present the text will become the title displayed
in the Fossil header.  An example of this can be seen in the text
of the [/artifact/84b4b3d041d93a?txt=1 | Index Of Fossil Documentation]
document.


<h2>Server-Side Text Substitution</h2>

Fossil can do a few types of substitution of server-side information
into the embedded document.

<h3>1. $ROOT</h3>

To allow for repositories [server/ | served deeper than the root of the
URL hierarchy], Fossil can substitute the repository's root in the URL
scheme into HTML <tt>href</tt> and <tt>action</tt> attributes. For
example:

<nowiki><pre>
        [$ROOT/doc.wiki | doc at project root]
</pre></nowiki>

might become this in the rendered HTML:

<nowiki><pre>
        &lt;a href="/project/root/doc.wiki"&gt;doc at project root&lt;/a&gt;
</pre></nowiki>

As you can see, this happens for all source document types that end up
rendering as HTML, not just source documents in the HTML
<tt>fossil-doc</tt> format described at the end of the prior section.


<h3>2. $NONCE</h3>

If you put the string <tt>nonce="$NONCE"</tt> or <tt>nonce='$NONCE'</tt>
anywhere in your document, the server's per-page CSP nonce value is
substituted into the document at that point. This is most useful in
combination with the HTML embedded doc type when using
<tt>&lt;script&gt;</tt> and <tt>&lt;style&gt;</tt> tags to allow that
tag to be accepted by Fossil's default
[https://developer.mozilla.org/en-US/docs/Web/HTTP/CSP | CSP settings].


<h3>3. TH1 Documents</h3>

Fossil will substitute the value of [./th1.md | TH1 expressions] within
<tt>{</tt> curly braces <tt>}</tt> into the output HTML if you have
configured it with the <tt>--with-th1-docs</tt> option, which is
disabled by default.


<h2>Examples</h2>

This file that you are currently reading is an example of
embedded documentation.  The name of this file in the fossil
source tree is "<b>www/embeddeddoc.wiki</b>".
You are perhaps looking at this