Skip to content

Commit

Permalink
Finish basic page output
Browse files Browse the repository at this point in the history
  • Loading branch information
CodeDoctorDE committed Jan 26, 2024
1 parent 8baac09 commit 16df83b
Show file tree
Hide file tree
Showing 8 changed files with 45 additions and 14 deletions.
4 changes: 2 additions & 2 deletions cli/assets/layouts/asset.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
<div class="container">
<h1>{{asset.name}}</h1>
<li>
<ul><a href="{{info.root}}/assets/{{asset.name}}/changes">Home</a></ul>
<ul><a href="{{info.root}}/assets/{{asset.name}}/changes">Changes</a></ul>
<ul><a href="{{info.root}}/{{asset.author}}/{{asset.name}}">Home</a></ul>
<ul><a href="{{info.root}}/{{asset.author}}/{{asset.name}}/changes.html">Changes</a></ul>
</li>
</div>
{{> @partial-block }}
Expand Down
5 changes: 3 additions & 2 deletions cli/assets/layouts/base.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,11 @@
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>{{> title}}</title>
<link rel="stylesheet" href="{{info.root}}/assets/css/style.css">
<link rel="stylesheet" href="{{info.root}}/style.css">
<link rel="stylesheet" href="{{info.root}}/custom.css">
</head>
<body>
{{> layouts/navbar}}
{{> layouts/navbar.hbs}}
{{> @partial-block }}
</body>
</html>
2 changes: 1 addition & 1 deletion cli/assets/layouts/navbar.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
</button>
<ul class="navbar-items">
<li class="navbar-search">
<form action="{{info.root}}/search" method="GET">
<form action="{{info.root}}/search.html" method="GET">
<input type="text" name="q" placeholder="Search">
</form>
</li>
Expand Down
16 changes: 15 additions & 1 deletion cli/assets/public/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,23 @@ html, body {
.item-list {
display: flex;
flex-direction: column;
gap: 1rem;
gap: 1em;
}

.item-list-entry {
list-style-type: none;
}

.button {
background-color: var(--primary-color);
color: var(--primary-color-text);
border: 0;
padding: 1em 0.5em;
border-radius: 1em;
text-decoration: none;
}

.header {
display: flex;
justify-content: space-between;
}
10 changes: 6 additions & 4 deletions cli/assets/templates/asset/changes.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,14 @@
<div class="container">
<ul class="item-list">
{{#each asset.versions}}
<li clas="item-list-entry">
<h2>{{this.name}}</h2>
<a href="{{this.download_url}}">Download</a>
<li class="item-list-entry">
<div class="header">
<h2>{{this.name}}</h2>
<a class="button" href="{{this.download_url}}">Download</a>
</div>
<p>{{this.changes}}</p>
</li>
{{/each}}
</ul>
</div>
{{/layouts/base.hbs}}
{{/layouts/asset.hbs}}
2 changes: 1 addition & 1 deletion cli/assets/templates/asset/index.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@
<p>{{asset.description}}</p>
<p>{{asset.current_version.changes}}</p>
</div>
{{/layouts/base.hbs}}
{{/layouts/asset.hbs}}
7 changes: 6 additions & 1 deletion cli/src/docs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ struct Templates;
#[folder = "assets/public"]
struct Public;

const ASSET_PAGES: [&str; 2] = ["index", "changes"];

pub fn generate_docs(data: &RepositoryData, output : String) -> Result<(), DocsError> {
let mut hb = Handlebars::new();
hb.register_embed_templates::<Templates>()?;
Expand All @@ -40,7 +42,10 @@ pub fn generate_docs(data: &RepositoryData, output : String) -> Result<(), DocsE
"asset": asset,
"info": data.info
});
render_dynamic("asset", &format!("{}/{}", asset.author, asset.name), &hb, &output, context)?;
fs::create_dir_all(format!("{}/{}/{}", output, &asset.author, &asset.name))?;
for page in ASSET_PAGES {
render_dynamic(&format!("asset/{}", &page), &format!("{}/{}/{}", &asset.author, &asset.name, &page), &hb, &output, context)?;
}
}

for file in Public::iter() {
Expand Down
13 changes: 11 additions & 2 deletions example/content/codedoctor/assets/testasset/config.toml
Original file line number Diff line number Diff line change
@@ -1,4 +1,13 @@
name = "testasset"
author = "obiwan"
author = "codedoctor"
id = "LEL"
tags = ["test", "asset"]
tags = ["test", "asset"]

previous_versions = []

[current_version]
name = "1.0"
changes = "Nothing"
download_url = "https://example.com"
sha256 = "test"

0 comments on commit 16df83b

Please sign in to comment.