-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
webls 1.4 spec compliant RSS + standard builder patterns for all
- Loading branch information
Showing
9 changed files
with
678 additions
and
213 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,22 +11,53 @@ gleam add webls | |
``` | ||
|
||
```gleam | ||
import gleam/option.{None} | ||
import webls/sitemap.{Sitemap} | ||
import webls/sitemap | ||
import webls/rss | ||
import webls/robots | ||
pub fn sitemap() -> String { | ||
let sitemap = | ||
Sitemap(url: "https://gleam.run/sitemap.xml", last_modified: None, items: [ | ||
sitemap.item("https://gleam.run") | ||
|> sitemap.with_frequency(sitemap.Monthly) | ||
|> sitemap.with_priority(1.0), | ||
sitemap.item("https://gleam.run/blog") | ||
|> sitemap.with_frequency(sitemap.Weekly), | ||
sitemap.item("https://gleam.run/blog/gleam-1.0"), | ||
sitemap.item("https://gleam.run/blog/gleam-1.1"), | ||
]) | ||
sitemap |> sitemap.to_string() | ||
sitemap.sitemap("https://gleam.run/sitemap.xml") | ||
|> sitemap.with_sitemap_last_modified(birl.now()) | ||
|> sitemap.with_sitemap_items([ | ||
sitemap.item("https://gleam.run") | ||
|> sitemap.with_item_frequency(sitemap.Monthly) | ||
|> sitemap.with_item_priority(1.0), | ||
sitemap.item("https://gleam.run/blog") | ||
|> sitemap.with_item_frequency(sitemap.Weekly), | ||
sitemap.item("https://gleam.run/blog/gleam-1.0"), | ||
sitemap.item("https://gleam.run/blog/gleam-1.1"), | ||
]) |> sitemap.to_string() | ||
} | ||
pub fn rss() -> String { | ||
[ | ||
rss.channel("Gleam RSS", "A test RSS feed", "https://gleam.run") | ||
|> rss.with_channel_category("Releases") | ||
|> rss.with_channel_language("en") | ||
|> rss.with_channel_items([ | ||
rss.item("Gleam 1.0", "Gleam 1.0 is here!") | ||
|> rss.with_item_link("https://gleam.run/blog/gleam-1.0") | ||
|> rss.with_item_pub_date(birl.now()) | ||
|> rss.with_item_guid(#("gleam 1.0", Some(False))), | ||
rss.item("Gleam 0.10", "Gleam 0.10 is here!") | ||
|> rss.with_item_link("https://gleam.run/blog/gleam-0.10") | ||
|> rss.with_item_author("[email protected]") | ||
|> rss.with_item_guid(#("gleam 0.10", Some(True))), | ||
]), | ||
] |> rss.to_string() | ||
} | ||
pub fn robots() -> String { | ||
robots.config("https://example.com/sitemap.xml") | ||
|> robots.with_config_robots([ | ||
robots.robot("googlebot") | ||
|> robots.with_robot_allowed_routes(["/posts/", "/contact/"]) | ||
|> robots.with_robot_disallowed_routes(["/admin/", "/private/"]), | ||
robots.robot("bingbot") | ||
|> robots.with_robot_allowed_routes(["/posts/", "/contact/", "/private/"]) | ||
|> robots.with_robot_disallowed_routes(["/"]), | ||
]) | ||
|> robots.to_string() | ||
} | ||
``` | ||
|
||
|
@@ -37,15 +68,18 @@ Further documentation can be found at <https://hexdocs.pm/webls>. | |
| Protocol | Version | Status | | ||
| ---------- | -------- | -------- | | ||
| Sitemaps | 0.9 | Complete | | ||
| RSS v2.0 | 2.0.1 | Partial | | ||
| RSS | 2.0.1 | Complete | | ||
| Robots.txt | 1997 IDS | Complete | | ||
|
||
> 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 | ||
|
||
| Type | to_string | Builder Functions | Validators | | ||
| ---------- | --------- | ----------------- | ---------- | | ||
| Sitemap | Complete | Complete | None | | ||
| RSS v2.0 | Complete | None | None | | ||
| RSS v2.0 | Complete | Complete | None | | ||
| Robots.txt | Complete | Complete | None | | ||
|
||
## Development | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.