Make number of nodes listed on index configurable
This commit is contained in:
parent
d51b9a135e
commit
ab38e5ebde
3 changed files with 25 additions and 7 deletions
|
|
@ -82,6 +82,10 @@ pub struct Config {
|
||||||
pub index_search: bool,
|
pub index_search: bool,
|
||||||
#[serde(default = "mktrue")]
|
#[serde(default = "mktrue")]
|
||||||
pub index_node_list: bool,
|
pub index_node_list: bool,
|
||||||
|
#[serde(default = "mk8")]
|
||||||
|
pub index_node_count: u16,
|
||||||
|
#[serde(default = "mktrue")]
|
||||||
|
pub index_root_node: bool,
|
||||||
#[serde(default = "mktrue")]
|
#[serde(default = "mktrue")]
|
||||||
pub tree_node_text: bool,
|
pub tree_node_text: bool,
|
||||||
}
|
}
|
||||||
|
|
@ -90,6 +94,9 @@ pub struct Config {
|
||||||
fn mktrue() -> bool {
|
fn mktrue() -> bool {
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
|
fn mk8() -> u16 {
|
||||||
|
8
|
||||||
|
}
|
||||||
|
|
||||||
impl Graph {
|
impl Graph {
|
||||||
pub fn new(message: Option<String>) -> Graph {
|
pub fn new(message: Option<String>) -> Graph {
|
||||||
|
|
@ -113,6 +120,8 @@ impl Graph {
|
||||||
raw_json: true,
|
raw_json: true,
|
||||||
index_search: true,
|
index_search: true,
|
||||||
index_node_list: true,
|
index_node_list: true,
|
||||||
|
index_node_count: 8,
|
||||||
|
index_root_node: true,
|
||||||
tree_node_text: true,
|
tree_node_text: true,
|
||||||
},
|
},
|
||||||
version: (0, 1, 0),
|
version: (0, 1, 0),
|
||||||
|
|
|
||||||
|
|
@ -140,5 +140,3 @@ footer_credits = false
|
||||||
footer_text = """
|
footer_text = """
|
||||||
made by jutty • acknowledgements • source code
|
made by jutty • acknowledgements • source code
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -20,25 +20,36 @@
|
||||||
<input type="submit" value="Submit"/>
|
<input type="submit" value="Submit"/>
|
||||||
</form>
|
</form>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% if config.index_node_list %}
|
{% if config.index_node_list or config.index_root_node %}
|
||||||
<hr>
|
<hr>
|
||||||
|
{% if config.index_node_list %}
|
||||||
<h2>Nodes</h2>
|
<h2>Nodes</h2>
|
||||||
|
{% endif %}
|
||||||
<nav>
|
<nav>
|
||||||
{% if root_node %}
|
{% if root_node and config.index_root_node %}
|
||||||
<p>
|
<p>
|
||||||
<strong>Root</strong>:
|
<strong>Root</strong>:
|
||||||
<a href="/node/{{root_node.id}}">{{root_node.title}}</a>
|
<a href="/node/{{root_node.id}}">{{root_node.title}}</a>
|
||||||
</p>
|
</p>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% if nodes %}
|
{% if nodes and config.index_node_list %}
|
||||||
<ul>
|
<ul>
|
||||||
{% for node in nodes %}
|
{% for node in nodes | slice(end=config.index_node_count) %}
|
||||||
{% if node.id != root_node.id %}
|
{% if node.id != root_node.id %}
|
||||||
<li><a href="/node/{{node.id}}">{{node.title}}</a></li>
|
<li><a href="/node/{{node.id}}">{{node.title}}</a></li>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
{% endif %}
|
|
||||||
</ul>
|
</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>
|
</nav>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% else %}
|
{% else %}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue