Make number of nodes listed on index configurable

This commit is contained in:
Juno Takano 2025-12-17 02:21:31 -03:00
commit ab38e5ebde
3 changed files with 25 additions and 7 deletions

View file

@ -82,6 +82,10 @@ pub struct Config {
pub index_search: bool,
#[serde(default = "mktrue")]
pub index_node_list: bool,
#[serde(default = "mk8")]
pub index_node_count: u16,
#[serde(default = "mktrue")]
pub index_root_node: bool,
#[serde(default = "mktrue")]
pub tree_node_text: bool,
}
@ -90,6 +94,9 @@ pub struct Config {
fn mktrue() -> bool {
true
}
fn mk8() -> u16 {
8
}
impl Graph {
pub fn new(message: Option<String>) -> Graph {
@ -113,6 +120,8 @@ impl Graph {
raw_json: true,
index_search: true,
index_node_list: true,
index_node_count: 8,
index_root_node: true,
tree_node_text: true,
},
version: (0, 1, 0),

View file

@ -140,5 +140,3 @@ footer_credits = false
footer_text = """
made by jutty acknowledgements source code
"""

View file

@ -20,25 +20,36 @@
<input type="submit" value="Submit"/>
</form>
{% endif %}
{% if config.index_node_list %}
{% if config.index_node_list or config.index_root_node %}
<hr>
{% if config.index_node_list %}
<h2>Nodes</h2>
{% endif %}
<nav>
{% if root_node %}
{% if root_node and config.index_root_node %}
<p>
<strong>Root</strong>:
<a href="/node/{{root_node.id}}">{{root_node.title}}</a>
</p>
{% endif %}
{% if nodes %}
{% if nodes and config.index_node_list %}
<ul>
{% for node in nodes %}
{% for node in nodes | slice(end=config.index_node_count) %}
{% if node.id != root_node.id %}
<li><a href="/node/{{node.id}}">{{node.title}}</a></li>
{% endif %}
{% endfor %}
{% endif %}
</ul>
{% if config.index_node_count < nodes | length %}
<br/>
<em style="font-size:0.9em"">
Listing {{ config.index_node_count }} of {{ nodes | length }} nodes, {{ nodes | length - config.index_node_count }} not shown in this sample.
{% if config.tree %}
See the <a href="/tree">tree</a> for a full list.
{% endif %}
</em>
{% endif %}
{% endif %}
</nav>
{% endif %}
{% else %}