diff options
-rw-r--r-- | etc/README.md | 13 | ||||
-rw-r--r-- | etc/compare.html | 45 | ||||
-rw-r--r-- | etc/problems.html | 28 | ||||
-rw-r--r-- | etc/project.html | 36 | ||||
-rw-r--r-- | src/frontend/json.rs | 30 |
5 files changed, 140 insertions, 12 deletions
diff --git a/etc/README.md b/etc/README.md new file mode 100644 index 0000000..c93152b --- /dev/null +++ b/etc/README.md @@ -0,0 +1,13 @@ +# HTML templates + +This directory contains HTML templates which can be used with the "json" output +format and a tool that can fill templates with data. +For example, this can be used with [hdlbr](https://github.com/quitoque/hdlbr) +to generate nice websites for the reported data. + +## Usage with hdlbr + +```bash +repolocli -o json ... > data.json +hdlbr data.json template.html > output.html +``` diff --git a/etc/compare.html b/etc/compare.html new file mode 100644 index 0000000..38e150e --- /dev/null +++ b/etc/compare.html @@ -0,0 +1,45 @@ +<html> + <head> + <link rel="stylesheet" href="https://unpkg.com/purecss@1.0.0/build/pure-min.css" integrity="sha384-nn4HPE8lTHyVtfCBi5yW9d20FjT8BJwUXyWZT9InLYax14RDjBj46LmSztkmNP9w" crossorigin="anonymous"> + </head> + <body> + <center> + <table class="pure-table pure-table-horizontal pure-table-striped"> + <thead> + <tr> + <th>Package</th> + <th>Local Version</th> + <th>External Versions</th> + </tr> + </thead> + + <tbody> + {{~#each . as |t|}} + <tr> + <td>{{t.package_name}}</td> + <td>{{t.local_version}}</td> + <td> + <table class="pure-table pure-table-horizontal pure-table-striped"> + <thead> + <tr> + <th>Repo</th> + <th>Version</th> + </tr> + </thead> + <tbody> + {{~#each t.comparisons as |c|}} + <tr> + <td>{{c.repo}}</td> + <td>{{c.version}}</td> + </tr> + {{~/each}} + </tbody> + </table> + </td> + </tr> + {{~/each}} + </tbody> + </table> + </center> + </body> +</html> diff --git a/etc/problems.html b/etc/problems.html new file mode 100644 index 0000000..bbb66ef --- /dev/null +++ b/etc/problems.html @@ -0,0 +1,28 @@ +<html> + <head> + <link rel="stylesheet" href="https://unpkg.com/purecss@1.0.0/build/pure-min.css" integrity="sha384-nn4HPE8lTHyVtfCBi5yW9d20FjT8BJwUXyWZT9InLYax14RDjBj46LmSztkmNP9w" crossorigin="anonymous"> + </head> + <body> + <table class="pure-table pure-table-horizontal pure-table-striped"> + <thead> + <tr> + <th>Repo</th> + <th>Package</th> + <th>Maintainer</th> + <th>Problem</th> + </tr> + </thead> + + <tbody> + {{~#each . as |t|}} + <tr> + <td>{{t.repo}}</td> + <td>{{t.name}}</td> + <td>{{t.maintainer}}</td> + <td>{{t.problem}}</td> + </tr> + {{~/each}} + </tbody> + </table> + </body> +</html> diff --git a/etc/project.html b/etc/project.html new file mode 100644 index 0000000..74242e7 --- /dev/null +++ b/etc/project.html @@ -0,0 +1,36 @@ +<html> + <head> + <link rel="stylesheet" href="https://unpkg.com/purecss@1.0.0/build/pure-min.css" integrity="sha384-nn4HPE8lTHyVtfCBi5yW9d20FjT8BJwUXyWZT9InLYax14RDjBj46LmSztkmNP9w" crossorigin="anonymous"> + </head> + <body> + <center> + <h1> + {{#if .}} + {{#with . as |t|}} + {{t.[0].name}} + {{/with}} + {{/if}} + </h1> + <hr /> + <table class="pure-table pure-table-horizontal pure-table-striped"> + <thead> + <tr> + <th>Repo</th> + <th>Version</th> + <th>Status</th> + </tr> + </thead> + + <tbody> + {{~#each . as |t|}} + <tr> + <td>{{t.repo}}</td> + <td>{{t.version}}</td> + <td>{{t.status}}</td> + </tr> + {{~/each}} + </tbody> + </table> + </center> + </body> +</html> diff --git a/src/frontend/json.rs b/src/frontend/json.rs index b6a34e5..cd7e651 100644 --- a/src/frontend/json.rs +++ b/src/frontend/json.rs @@ -41,28 +41,34 @@ impl Frontend for JsonFrontend { // but using references is too complicated right now package_name: String, local_version: String, - upstream_repo: String, - upstream_version: String, + comparisons: Vec<CompareTarget>, + } + + #[derive(Serialize)] + struct CompareTarget { + version: String, + repo: String, } let mut output: Vec<PackageComp> = vec![]; for package in packages.iter() { - let mut list = backend + + let comparisons = backend .project(package.name().deref())? .into_iter() .filter(|p| filter_repos.contains(p.repo())) - .map(|upstream_package| { - PackageComp { - package_name: package.name().clone(), - local_version: package.version().clone(), - upstream_repo: upstream_package.repo().deref().clone(), - upstream_version: upstream_package.version().deref().clone(), - } + .map(|upstream_package| CompareTarget { + version: upstream_package.version().deref().clone(), + repo: upstream_package.repo().deref().clone(), }) - .collect::<Vec<_>>(); + .collect(); - output.append(&mut list); + output.push(PackageComp { + package_name: package.name().clone(), + local_version: package.version().clone(), + comparisons, + }); } let output = serde_json::ser::to_string_pretty(&output)?; |