README.md

WebLS

A Gleam library for generating sitemaps and RSS feeds and more. to meet all your common web listing needs.

Package Version Hex Docs

sh
1gleam add webls
gleam
1import gleam/time/timestamp
2import webls/sitemap
3import webls/rss
4import webls/robots
5
6pub fn sitemap() -> String {
7 sitemap.sitemap("https://gleam.run/sitemap.xml")
8 |> sitemap.with_sitemap_last_modified(timestamp.system_time())
9 |> sitemap.with_sitemap_items([
10 sitemap.item("https://gleam.run")
11 |> sitemap.with_item_frequency(sitemap.Monthly)
12 |> sitemap.with_item_priority(1.0),
13 sitemap.item("https://gleam.run/blog")
14 |> sitemap.with_item_frequency(sitemap.Weekly),
15 sitemap.item("https://gleam.run/blog/gleam-1.0"),
16 sitemap.item("https://gleam.run/blog/gleam-1.1"),
17 ]) |> sitemap.to_string()
18}
19
20pub fn rss() -> String {
21 [
22 rss.channel("Gleam RSS", "A test RSS feed", "https://gleam.run")
23 |> rss.with_channel_category("Releases")
24 |> rss.with_channel_language("en")
25 |> rss.with_channel_items([
26 rss.item("Gleam 1.0", "Gleam 1.0 is here!")
27 |> rss.with_item_link("https://gleam.run/blog/gleam-1.0")
28 |> rss.with_item_pub_date(timestamp.system_time())
29 |> rss.with_item_guid(#("gleam 1.0", Some(False))),
30 rss.item("Gleam 0.10", "Gleam 0.10 is here!")
31 |> rss.with_item_link("https://gleam.run/blog/gleam-0.10")
32 |> rss.with_item_author("user@example.com")
33 |> rss.with_item_guid(#("gleam 0.10", Some(True))),
34 ]),
35 ] |> rss.to_string()
36}
37
38pub fn robots() -> String {
39 robots.config("https://example.com/sitemap.xml")
40 |> robots.with_config_robots([
41 robots.robot("googlebot")
42 |> robots.with_robot_allowed_routes(["/posts/", "/contact/"])
43 |> robots.with_robot_disallowed_routes(["/admin/", "/private/"]),
44 robots.robot("bingbot")
45 |> robots.with_robot_allowed_routes(["/posts/", "/contact/", "/private/"])
46 |> robots.with_robot_disallowed_routes(["/"]),
47 ])
48 |> robots.to_string()
49}

Further documentation can be found at https://hexdocs.pm/webls.

Current Standards Compliance

ProtocolVersionStatus
Sitemaps0.9Complete
RSS2.0.1Complete
Robots.txt1997 IDSComplete
Atom1.0Complete

A Note on the RSS 2.0 spec, the PICS field for content ratings is not going to be supported as the PICS standard was discontinued more than a decade ago.

Utility Support

TypeBuilder Functionsto_stringfrom_string
SitemapCompleteCompleteComplete
RSS v2.0CompleteCompleteComplete
Robots.txtCompleteCompleteComplete
AtomCompleteCompleteNone

Development

sh
1gleam test # Run the tests

Yes the name is a reference to the ls command in unix to list files