copy readme files to their real name in addition to the file hash
local_bytes = self.write_rendered(&out_path, &rendered);
atomic_repo_bytes.fetch_add(local_bytes, Ordering::SeqCst);
atomic_bytes.fetch_add(local_bytes, Ordering::SeqCst);
+
+ // Copy readme files to their real filename, so links to readme files remain valid
+ // across file changes.
+ if let Some(readmes) = &repo_desc.readme_files {
+ for readme in readmes {
+ if &file.path == readme {
+ let mut pretty_path = PathBuf::from(out_path);
+ pretty_path.pop();
+ pretty_path.push(&file.path);
+ match std::fs::copy(&out_path, &pretty_path) {
+ Ok(_) => louder!(" - wrote readme file: {}", pretty_path.to_string_lossy()),
+ Err(e) => error!("ERROR: {:?}", e),
+ }
+ }
+ }
+ };
+
}
Err(x) => match x.kind {
_ => error!("ERROR: {:?}", x),
<tr class="readme">
<td class="field website">Documentation:</td>
{% if readme and readme.id in file_ids -%}
- <td class="value website"><a href="{{repo_url | safe}}/{{readme.kind}}/{{readme.id}}.html">{{readme.name | default(value="[none]")}}</a></td>
+ <td class="value website"><a href="{{repo_url | safe}}/{{readme.kind}}/{{readme.name}}.html">{{readme.name | default(value="[none]")}}</a></td>
{% else -%}
<td class="value website">{{readme.name | default(value="[none]")}}</td>
{% endif -%}
<tr class="website">
<td class="field website">Website:</td>
{% if metadata.website -%}
- <td class="value website"><a href="{{ metadata.website }}">{{metadata.website | default(value="[none]")}}</a></td>
+ <td class="value website"><a href="{{ metadata.website | safe }}">{{metadata.website | default(value="[none]")}}</a></td>
{% else -%}
<td class="value website">{{metadata.website | default(value="[none]")}}</td>
{% endif-%}
<tr class="readme">
<td class="field website">Documentation:</td>
{% if readme and readme.id in file_ids -%}
- <td class="value website"><a href="{{repo_url | safe}}/{{readme.kind}}/{{readme.id}}.html">{{readme.name | default(value="[none]")}}</a></td>
+ <td class="value website"><a href="{{repo_url | safe}}/{{readme.kind}}/{{readme.name}}">{{readme.name | default(value="[none]")}}</a></td>
{% else -%}
<td class="value website">{{readme.name | default(value="[none]")}}</td>
{% endif -%}
<tr class="website">
<td class="field website">Website:</td>
{% if metadata.website -%}
- <td class="value website"><a href="{{ metadata.website }}">{{metadata.website | default(value="[none]")}}</a></td>
+ <td class="value website"><a href="{{ metadata.website | safe }}">{{metadata.website | default(value="[none]")}}</a></td>
{% else -%}
<td class="value website">{{metadata.website | default(value="[none]")}}</td>
{% endif-%}