Skip to content

Commit

Permalink
Fix TTL, NT and XML links: resolve #59.
Browse files Browse the repository at this point in the history
  • Loading branch information
KonradHoeffner committed Oct 23, 2023
1 parent 716d2fb commit 68ac01f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 13 deletions.
7 changes: 3 additions & 4 deletions data/resource.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width,initial-scale=1">
<title>{title}</title>
<base href="{base}/">
<link rel="stylesheet" href="rickview.css" type="text/css" />
<link rel="stylesheet" href="roboto.css" type="text/css" />
<link rel="shortcut icon" href="favicon.ico" />
Expand Down Expand Up @@ -81,9 +80,9 @@ <h3>inverse relations</h3>
<ul>
<li>
view as:
<a href="{uri | uri_to_suffix}?output=application/rdf%2Bxml">xml, </a>
<a href="{uri | uri_to_suffix}?output=application/n-triples">ntriples, </a>
<a href="{uri | uri_to_suffix}?output=application/turtle">turtle</a>
<a href="?output=application/rdf%2Bxml">xml, </a>
<a href="?output=application/n-triples">ntriples, </a>
<a href="?output=application/turtle">turtle</a>
</li>
{{ if github_issue_url }}
<li>
Expand Down
15 changes: 6 additions & 9 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,15 +67,12 @@ fn template() -> TinyTemplate<'static> {
tt.add_template("index", INDEX).expect("Could not parse index page template");
tt.add_template("about", ABOUT).expect("Could not parse about page template");
tt.add_formatter("uri_to_suffix", |json, output| {
let o = || -> String {
let s = json.as_str().unwrap_or_else(|| panic!("JSON value is not a string: {json}"));
let mut s = s.rsplit_once('/').unwrap_or_else(|| panic!("no '/' in URI '{s}'")).1;
if s.contains('#') {
s = s.rsplit_once('#').unwrap().1;
}
s.to_owned()
};
output.push_str(&o());
let s = json.as_str().unwrap_or_else(|| panic!("JSON value is not a string: {json}"));
let mut s = s.rsplit_once('/').unwrap_or_else(|| panic!("no '/' in URI '{s}'")).1;
if s.contains('#') {
s = s.rsplit_once('#').unwrap().1;
}
output.push_str(s);
Ok(())
});
tt
Expand Down

0 comments on commit 68ac01f

Please sign in to comment.