Initial commit

This commit is contained in:
Ana Custura 2025-06-07 17:01:43 +01:00
commit 65f1591c05
6 changed files with 2074 additions and 0 deletions

10
Cargo.toml Normal file
View file

@ -0,0 +1,10 @@
[package]
name = "readme"
version = "0.1.0"
edition = "2024"
[dependencies]
tera = "1.20"
serde = { version = "1.0.219", features = ["derive"] }
toml = "0.8.23"
serde_json = "1.0.140"

26
README.toml Normal file
View file

@ -0,0 +1,26 @@
[header]
src = "https://guardianproject.dev/jasima/lukin/raw/branch/main/pngs/logomark-colour-w1024.png"
alt = "jasima.app"
href = "https://guardianproject.dev/jasima/lipu-pali"
[project]
name = "Example Project"
summary = "An example project for example use"
description = """
This is an extended description of the example project.
Look how much longer it is than the summary.
The summary is just one line, but the description is many.
"""
language = "Rust"
licence = "BSD-2-Clause"
lifecycle = "experimental"
[[project.badges]]
alt = "Language: Markdown"
href = "https://daringfireball.net/projects/markdown/"
src = "https://img.shields.io/badge/language-markdown-083fa1?style=flat-square"
[[project.badges]]
alt = "Licence: BSD 2-clause"
href = "https://opensource.org/license/bsd-2-clause"
src = "https://img.shields.io/badge/license-bsd%202--clause-orange?style=flat-square"

1904
src/languages.toml Normal file

File diff suppressed because it is too large Load diff

24
src/licences.toml Normal file
View file

@ -0,0 +1,24 @@
[BSD-2-Clause]
class = "permissive"
grant = """
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
"""

57
src/main.rs Normal file
View file

@ -0,0 +1,57 @@
use std::collections::HashMap;
use std::fs;
use tera::Tera;
use serde::Deserialize;
#[derive(Deserialize, serde::Serialize)]
struct ReadmeConfig {
header: Image,
project: Project
}
#[derive(Deserialize, serde::Serialize)]
struct Project {
name: String,
summary: String,
description: String,
language: String,
licence: String,
lifecycle: String,
badges: Vec<Image>,
}
#[derive(Deserialize, serde::Serialize)]
struct Image {
alt: String,
href: String,
src: String,
}
#[derive(Deserialize)]
struct Language {
color: String
}
fn main() {
let mut readme_template = Tera::new("templates/**/*").unwrap();
readme_template.add_template_file("templates/readme_templ.j2", Option::from("readme")).unwrap();
let mut context = tera::Context::new();
let language_colours = include_str!("languages.toml");
let language_colours_config: HashMap<String, Language> = toml::from_str(language_colours).unwrap();
// println!("{:?}", colours_config);
let toml_filename = "README.toml";
let contents: String = fs::read_to_string(toml_filename).unwrap();
let readme_config: ReadmeConfig = toml::from_str(&contents).expect("Failed to parse readme.toml");
let project_language = &readme_config.project.language;
let project_language_colour = language_colours_config.get(project_language).unwrap();
context.insert("config", &readme_config);
let rendered = readme_template.render("readme", &context).unwrap();
//println!("{}", rendered);
}

53
templates/readme_templ.j2 Normal file
View file

@ -0,0 +1,53 @@
<h1 align="center">
<br>
<a href="{{ config.header.href }}"> <img src="{{ config.header.src }}" alt="{{ config.header.alt }}"> </a>
<br>
</h1>
<p align="center">
{% for badge in config.project.badges %}
{% if badge.href %}
<a href="{{ badge.href }}"><img alt="{{ badge.alt }}" src="{{ badge.src }}"></a>
{% else %}
<img alt="{{badge.alt}}" src="{{badge.src}}">
{% endif %}
{% endfor %}
</p>
## {{ config.project.name }}
{{ config.project.summary }}
{{ config.project.description }}
### Usage
Use these as examples, but I would strongly recommend you do not include these directly in your IaC.
If something here fits your needs really well, maybe [get in touch](https://irl.xyz/contact/) with me and check if I'm
planning to maintain that role or playbook.
Sometimes a bit of external motivation is the push I need to get something finished, otherwise you can always
[hire me to do it](https://www.sr2.uk/).
### Licence
Copyright © 2022-2025 irl.
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the
following conditions are met:
Redistributions of source code must retain the above copyright notice, this list of conditions and the following
disclaimer.
Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following
disclaimer in the documentation and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS “AS IS” AND ANY EXPRESS OR IMPLIED WARRANTIES,
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.