diff --git a/README.md b/README.md index 00add15..b7d7385 100644 --- a/README.md +++ b/README.md @@ -112,17 +112,14 @@ Templates are located in the `./data/templates` folder by default; this path can Templates contain tags which will be replaced with generated content. You can customize generated files by adding content before/after the tags. The repo includes basic template examples to get you started. -In the templates folder, `redirect.html` is used to generate each of the `next.html`/`previous.html` pages, containing the redirects for each website. The tag `{{ url }}` is inserted by the generator in each page, and that powers the webring. +In the templates folder, `redirect.html` is used to generate each of the `next.html`/`previous.html` pages, containing the redirects for each website. The tag `{{ url }}` is inserted by the generator in each page, and that powers the webring. Right now, `{{ url }}` is a unique tag that only works in `redirect.html` for the next/previous links. Besides `redirect.html`, the templates folder can contain any other templates you want. -For instance, it's a good idea for a webring to have a central hub page listing all of the sites. You can put this on `index.html`, or create a dedicated page such as `list.html`, `table.html`, etc. ~~Simply use the tag `{{ table_of_sites }}` in the template, and `ringfairy` will generate a formatted list of the sites in the webring.~~ - ### Template Tags The following tags are currently usable in templates: -- *`{{ sites }}`* provides access to information about the sites in the webring. - *`{{ number_of_sites }}`* shows the current size of the webring. - *`{{ current_time }}`* displays the time of generating, showing when the page was last updated. - *`{{ opml }}`* inserts the relative path of the ring's OPML file. @@ -134,8 +131,23 @@ The following tags are currently usable in templates: - *`{{ featured_site_name }}`* prints the name of the "featured site", which is random. - *`{{ featured_site_description }}`* prints the description of the random featured site. - *`{{ featured_site_url }}`* prints the URL of the random featured site. +- *`{{ sites }}`* provides access to information about the sites in the webring for creating a listing of all the sites. + +### Ring List + +It's a good idea for a webring to have a central hub page listing all of the sites. You can put this on `index.html`, or create a dedicated page such as `list.html`, `table.html`, etc. This can be done by looping over the `{{ sites }}` tag and pulling out the individual properties from website.json/toml file. Here's a very basic exmaple to create an `article` : +```html +
+ {% for site in sites %} +
+ {{ site.website.slug }} at {{ site.website.url }} +
+ {% endfor %} +
+``` +Refer to `data/templates/index.html` for the default layout for a fuller example. -Right now, `{{ url }}` is a unique tag that only works in `redirect.html` for the next/previous links. +The approach above provides a lot of layout flexibility. There are a couple of old approaches that can be used to generate an entire table or a CSS grid compatible layout easily by simply using the tag `{{ table_of_sites | safe }}` or `{{ grid_of_sites | safe }}` in the template, and `ringfairy` will generate a formatted list of the sites in the webring. Refer to `data/templates/table.html` and `data/templates/grid.html` for these old layouts. ---------------------------- diff --git a/data/templates/table.html b/data/templates/table.html new file mode 100644 index 0000000..ae0db0e --- /dev/null +++ b/data/templates/table.html @@ -0,0 +1,22 @@ + + + + + + + {{ ring_name }} List + + +

{{ ring_name }} List

+

{{ ring_description }}

+

Add all sites with declared RSS feeds to your feed reader with this OPML link.

+ + {{ table_of_sites | safe }} + +
+ + + diff --git a/src/gen/html.rs b/src/gen/html.rs index eff3e12..10c7e23 100644 --- a/src/gen/html.rs +++ b/src/gen/html.rs @@ -277,22 +277,18 @@ pub async fn build_sites_grid_html(websites: &[WebringSite]) -> String { for (_index, website) in websites.iter().enumerate() { grid_html.push_str("
\n"); grid_html.push_str(&format!( - "
{} ({})
\n", - website - .website - .owner - .as_deref() - .map(format_owner) - .unwrap_or(String::new()), - website.website.slug - )); + "
{} ({})
\n", + website.website.url, + website.website.name.as_deref().map(format_owner).unwrap_or(String::new()), + website.website.slug)); grid_html.push_str("
\n"); grid_html.push_str(&format!( - "
{} {}
\n", + "
{} {} {}
\n", + website.website.owner.as_deref().unwrap_or(""), website.website.url, website.website.url, if let Some(rss_url) = &website.website.rss { - format!(" [rss]", rss_url) + format!(" [rss]", rss_url) } else { String::new() }