-module(webls@atom). -compile([no_auto_import, nowarn_unused_vars, nowarn_unused_function, nowarn_nomatch]). -export([to_string/1, plain_text/1, html/1, xhtml/1, link/1, with_link_rel/2, with_link_content_type/2, with_link_hreflang/2, with_link_title/2, with_link_length/2, category/1, with_category_scheme/2, with_category_label/2, person/1, with_person_email/2, with_person_uri/2, feed/3, entry/3, with_entry_id/2, with_entry_title/2, with_entry_updated/2, with_entry_authors/2, with_entry_content/2, with_entry_link/2, with_entry_summary/2, with_entry_categories/2, with_entry_contributors/2, with_entry_published/2, with_entry_rights/2, with_entry_source/2, with_feed_author/2, with_feed_authors/2, with_feed_link/2, with_feed_category/2, with_feed_categories/2, with_feed_contributor/2, with_feed_contributors/2, with_feed_generator/2, with_feed_icon/2, with_feed_logo/2, with_feed_rights/2, with_feed_subtitle/2, with_feed_entry/2, with_feed_entries/2]). -export_type([atom_feed/0, person/0, generator/0, link/0, category/0, atom_entry/0, text/0, source/0]). -type atom_feed() :: {atom_feed, binary(), text(), birl:time(), list(person()), gleam@option:option(link()), list(category()), list(person()), gleam@option:option(generator()), gleam@option:option(binary()), gleam@option:option(binary()), gleam@option:option(text()), gleam@option:option(binary()), list(atom_entry())}. -type person() :: {person, binary(), gleam@option:option(binary()), gleam@option:option(binary())}. -type generator() :: {generator, gleam@option:option(binary()), gleam@option:option(binary())}. -type link() :: {link, binary(), gleam@option:option(binary()), gleam@option:option(binary()), gleam@option:option(binary()), gleam@option:option(binary()), gleam@option:option(integer())}. -type category() :: {category, binary(), gleam@option:option(binary()), gleam@option:option(binary())}. -type atom_entry() :: {atom_entry, binary(), text(), birl:time(), list(person()), gleam@option:option(text()), gleam@option:option(link()), gleam@option:option(text()), list(category()), list(person()), gleam@option:option(birl:time()), gleam@option:option(text()), gleam@option:option(source())}. -type text() :: {plain_text, binary()} | {html, binary()} | {x_html, binary()}. -type source() :: {source, binary(), binary(), birl:time()}. -spec person_to_string(person()) -> binary(). person_to_string(Person) -> <<<<<<<<<<<<"\n"/utf8, ""/utf8>>/binary, (erlang:element(2, Person))/binary>>/binary, "\n"/utf8>>/binary, (case erlang:element(3, Person) of {some, Email} -> <<<<""/utf8, Email/binary>>/binary, "\n"/utf8>>; none -> <<""/utf8>> end)/binary>>/binary, (case erlang:element(4, Person) of {some, Uri} -> <<<<""/utf8, Uri/binary>>/binary, "\n"/utf8>>; none -> <<""/utf8>> end)/binary>>/binary, "\n"/utf8>>. -spec link_to_string(link()) -> binary(). link_to_string(Link) -> <<<<<<<<<<<<<<<<">/binary, "\""/utf8>>/binary, (case erlang:element(3, Link) of {some, Rel} -> <<<<" rel=\""/utf8, Rel/binary>>/binary, "\""/utf8>>; none -> <<""/utf8>> end)/binary>>/binary, (case erlang:element(4, Link) of {some, Content_type} -> <<<<" type=\""/utf8, Content_type/binary>>/binary, "\""/utf8>>; none -> <<""/utf8>> end)/binary>>/binary, (case erlang:element(5, Link) of {some, Hreflang} -> <<<<" hreflang=\""/utf8, Hreflang/binary>>/binary, "\""/utf8>>; none -> <<""/utf8>> end)/binary>>/binary, (case erlang:element(6, Link) of {some, Title} -> <<<<" title=\""/utf8, Title/binary>>/binary, "\""/utf8>>; none -> <<""/utf8>> end)/binary>>/binary, (case erlang:element(7, Link) of {some, Length} -> <<<<" length=\""/utf8, (gleam@int:to_string(Length))/binary>>/binary, "\""/utf8>>; none -> <<""/utf8>> end)/binary>>/binary, "/>\n"/utf8>>. -spec category_to_string(category()) -> binary(). category_to_string(Category) -> <<<<<<<<<<">/binary, "\""/utf8>>/binary, (case erlang:element(3, Category) of {some, Scheme} -> <<<<" scheme=\""/utf8, Scheme/binary>>/binary, "\""/utf8>>; none -> <<""/utf8>> end)/binary>>/binary, (case erlang:element(4, Category) of {some, Label} -> <<<<" label=\""/utf8, Label/binary>>/binary, "\""/utf8>>; none -> <<""/utf8>> end)/binary>>/binary, "/>\n"/utf8>>. -spec generator_to_string(generator()) -> binary(). generator_to_string(Generator) -> <<<<<<" <<<<" uri=\""/utf8, Uri/binary>>/binary, "\""/utf8>>; none -> <<""/utf8>> end)/binary>>/binary, (case erlang:element(3, Generator) of {some, Version} -> <<<<" version=\""/utf8, Version/binary>>/binary, "\""/utf8>>; none -> <<""/utf8>> end)/binary>>/binary, ">webls\n"/utf8>>. -spec source_to_string(source()) -> binary(). source_to_string(Source) -> <<<<<<<<<<<<<<<<<<<<"\n"/utf8, ""/utf8>>/binary, (erlang:element(2, Source))/binary>>/binary, "\n"/utf8>>/binary, ""/utf8>>/binary, (erlang:element(3, Source))/binary>>/binary, "\n"/utf8>>/binary, ""/utf8>>/binary, (birl:to_iso8601(erlang:element(4, Source)))/binary>>/binary, "\n"/utf8>>/binary, "\n"/utf8>>. -spec text_to_string(text()) -> binary(). text_to_string(Text) -> case Text of {plain_text, Value} -> Value; {html, Value@1} -> <<<<""/utf8, Value@1/binary>>/binary, ""/utf8>>; {x_html, Value@2} -> <<<<""/utf8, Value@2/binary>>/binary, ""/utf8>> end. -spec atom_entry_to_string(atom_entry()) -> binary(). atom_entry_to_string(Entry) -> <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<"\n"/utf8, ""/utf8>>/binary, (erlang:element( 2, Entry ))/binary>>/binary, "\n"/utf8>>/binary, ""/utf8>>/binary, (text_to_string( erlang:element( 3, Entry ) ))/binary>>/binary, "\n"/utf8>>/binary, ""/utf8>>/binary, (birl:to_iso8601( erlang:element(4, Entry) ))/binary>>/binary, "\n"/utf8>>/binary, (begin _pipe = gleam@list:map( erlang:element(5, Entry), fun person_to_string/1 ), _pipe@1 = gleam@list:reduce( _pipe, fun(Acc, Author) -> <> end ), gleam@result:unwrap( _pipe@1, <<""/utf8>> ) end)/binary>>/binary, (case erlang:element(6, Entry) of {some, Content} -> <<<<""/utf8, (text_to_string(Content))/binary>>/binary, "\n"/utf8>>; none -> <<""/utf8>> end)/binary>>/binary, (case erlang:element(7, Entry) of {some, Link} -> link_to_string(Link); none -> <<""/utf8>> end)/binary>>/binary, (case erlang:element(8, Entry) of {some, Summary} -> <<<<""/utf8, (text_to_string(Summary))/binary>>/binary, "\n"/utf8>>; none -> <<""/utf8>> end)/binary>>/binary, (begin _pipe@2 = gleam@list:map( erlang:element(9, Entry), fun category_to_string/1 ), _pipe@3 = gleam@list:reduce( _pipe@2, fun(Acc@1, Category) -> <> end ), gleam@result:unwrap(_pipe@3, <<""/utf8>>) end)/binary>>/binary, (begin _pipe@4 = gleam@list:map( erlang:element(10, Entry), fun person_to_string/1 ), _pipe@5 = gleam@list:reduce( _pipe@4, fun(Acc@2, Contributor) -> <> end ), gleam@result:unwrap(_pipe@5, <<""/utf8>>) end)/binary>>/binary, (case erlang:element(11, Entry) of {some, Published} -> <<<<""/utf8, (birl:to_iso8601(Published))/binary>>/binary, "\n"/utf8>>; none -> <<""/utf8>> end)/binary>>/binary, (case erlang:element(12, Entry) of {some, Rights} -> <<<<""/utf8, (text_to_string(Rights))/binary>>/binary, "\n"/utf8>>; none -> <<""/utf8>> end)/binary>>/binary, (case erlang:element(13, Entry) of {some, Source} -> source_to_string(Source); none -> <<""/utf8>> end)/binary>>/binary, "\n"/utf8>>. -spec atom_feed_to_string(atom_feed()) -> binary(). atom_feed_to_string(Feed) -> <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<"\n"/utf8, (erlang:element( 2, Feed ))/binary>>/binary, "\n"/utf8>>/binary, ""/utf8>>/binary, (text_to_string( erlang:element( 3, Feed ) ))/binary>>/binary, "\n"/utf8>>/binary, ""/utf8>>/binary, (birl:to_iso8601( erlang:element(4, Feed) ))/binary>>/binary, "\n"/utf8>>/binary, (begin _pipe = gleam@list:map( erlang:element(5, Feed), fun person_to_string/1 ), _pipe@1 = gleam@list:reduce( _pipe, fun(Acc, Author) -> <> end ), gleam@result:unwrap( _pipe@1, <<""/utf8>> ) end)/binary>>/binary, (case erlang:element(6, Feed) of {some, Link} -> link_to_string(Link); none -> <<""/utf8>> end)/binary>>/binary, (begin _pipe@2 = gleam@list:map( erlang:element(7, Feed), fun category_to_string/1 ), _pipe@3 = gleam@list:reduce( _pipe@2, fun(Acc@1, Category) -> <> end ), gleam@result:unwrap( _pipe@3, <<""/utf8>> ) end)/binary>>/binary, (begin _pipe@4 = gleam@list:map( erlang:element(8, Feed), fun person_to_string/1 ), _pipe@5 = gleam@list:reduce( _pipe@4, fun(Acc@2, Contributor) -> <> end ), gleam@result:unwrap(_pipe@5, <<""/utf8>>) end)/binary>>/binary, (case erlang:element(9, Feed) of {some, Generator} -> generator_to_string(Generator); none -> <<""/utf8>> end)/binary>>/binary, (case erlang:element(10, Feed) of {some, Icon} -> <<<<""/utf8, Icon/binary>>/binary, "\n"/utf8>>; none -> <<""/utf8>> end)/binary>>/binary, (case erlang:element(11, Feed) of {some, Logo} -> <<<<""/utf8, Logo/binary>>/binary, "\n"/utf8>>; none -> <<""/utf8>> end)/binary>>/binary, (case erlang:element(12, Feed) of {some, Rights} -> <<<<""/utf8, (text_to_string(Rights))/binary>>/binary, "\n"/utf8>>; none -> <<""/utf8>> end)/binary>>/binary, (case erlang:element(13, Feed) of {some, Subtitle} -> <<<<""/utf8, Subtitle/binary>>/binary, "\n"/utf8>>; none -> <<""/utf8>> end)/binary>>/binary, (begin _pipe@6 = gleam@list:map( erlang:element(14, Feed), fun atom_entry_to_string/1 ), _pipe@7 = gleam@list:reduce( _pipe@6, fun(Acc@3, Entry) -> <> end ), gleam@result:unwrap(_pipe@7, <<""/utf8>>) end)/binary>>. -spec to_string(atom_feed()) -> binary(). to_string(Feed) -> <<<<"\n"/utf8, (atom_feed_to_string(Feed))/binary>>/binary, ""/utf8>>. -spec plain_text(binary()) -> text(). plain_text(Input) -> {plain_text, Input}. -spec html(binary()) -> text(). html(Input) -> {html, Input}. -spec xhtml(binary()) -> text(). xhtml(Input) -> {x_html, Input}. -spec link(binary()) -> link(). link(Href) -> {link, Href, none, none, none, none, none}. -spec with_link_rel(link(), binary()) -> link(). with_link_rel(Link, Rel) -> erlang:setelement(3, Link, {some, Rel}). -spec with_link_content_type(link(), binary()) -> link(). with_link_content_type(Link, Content_type) -> erlang:setelement(4, Link, {some, Content_type}). -spec with_link_hreflang(link(), binary()) -> link(). with_link_hreflang(Link, Hreflang) -> erlang:setelement(5, Link, {some, Hreflang}). -spec with_link_title(link(), binary()) -> link(). with_link_title(Link, Title) -> erlang:setelement(6, Link, {some, Title}). -spec with_link_length(link(), integer()) -> link(). with_link_length(Link, Length) -> erlang:setelement(7, Link, {some, Length}). -spec category(binary()) -> category(). category(Term) -> {category, Term, none, none}. -spec with_category_scheme(category(), binary()) -> category(). with_category_scheme(Category, Scheme) -> erlang:setelement(3, Category, {some, Scheme}). -spec with_category_label(category(), binary()) -> category(). with_category_label(Category, Label) -> erlang:setelement(4, Category, {some, Label}). -spec person(binary()) -> person(). person(Name) -> {person, Name, none, none}. -spec with_person_email(person(), binary()) -> person(). with_person_email(Person, Email) -> erlang:setelement(3, Person, {some, Email}). -spec with_person_uri(person(), binary()) -> person(). with_person_uri(Person, Uri) -> erlang:setelement(4, Person, {some, Uri}). -spec feed(binary(), text(), birl:time()) -> atom_feed(). feed(Id, Title, Updated) -> {atom_feed, Id, Title, Updated, [], none, [], [], none, none, none, none, none, []}. -spec entry(binary(), text(), birl:time()) -> atom_entry(). entry(Id, Title, Updated) -> {atom_entry, Id, Title, Updated, [], none, none, none, [], [], none, none, none}. -spec with_entry_id(atom_entry(), binary()) -> atom_entry(). with_entry_id(Entry, Id) -> erlang:setelement(2, Entry, Id). -spec with_entry_title(atom_entry(), text()) -> atom_entry(). with_entry_title(Entry, Title) -> erlang:setelement(3, Entry, Title). -spec with_entry_updated(atom_entry(), birl:time()) -> atom_entry(). with_entry_updated(Entry, Updated) -> erlang:setelement(4, Entry, Updated). -spec with_entry_authors(atom_entry(), list(person())) -> atom_entry(). with_entry_authors(Entry, Authors) -> erlang:setelement( 5, Entry, gleam@list:concat([erlang:element(5, Entry), Authors]) ). -spec with_entry_content(atom_entry(), text()) -> atom_entry(). with_entry_content(Entry, Content) -> erlang:setelement(6, Entry, {some, Content}). -spec with_entry_link(atom_entry(), link()) -> atom_entry(). with_entry_link(Entry, Link) -> erlang:setelement(7, Entry, {some, Link}). -spec with_entry_summary(atom_entry(), text()) -> atom_entry(). with_entry_summary(Entry, Summary) -> erlang:setelement(8, Entry, {some, Summary}). -spec with_entry_categories(atom_entry(), list(category())) -> atom_entry(). with_entry_categories(Entry, Categories) -> erlang:setelement( 9, Entry, gleam@list:concat([erlang:element(9, Entry), Categories]) ). -spec with_entry_contributors(atom_entry(), list(person())) -> atom_entry(). with_entry_contributors(Entry, Contributors) -> erlang:setelement( 10, Entry, gleam@list:concat([erlang:element(10, Entry), Contributors]) ). -spec with_entry_published(atom_entry(), birl:time()) -> atom_entry(). with_entry_published(Entry, Published) -> erlang:setelement(11, Entry, {some, Published}). -spec with_entry_rights(atom_entry(), text()) -> atom_entry(). with_entry_rights(Entry, Rights) -> erlang:setelement(12, Entry, {some, Rights}). -spec with_entry_source(atom_entry(), source()) -> atom_entry(). with_entry_source(Entry, Source) -> erlang:setelement(13, Entry, {some, Source}). -spec with_feed_author(atom_feed(), person()) -> atom_feed(). with_feed_author(Feed, Author) -> erlang:setelement(5, Feed, [Author | erlang:element(5, Feed)]). -spec with_feed_authors(atom_feed(), list(person())) -> atom_feed(). with_feed_authors(Feed, Authors) -> erlang:setelement( 5, Feed, gleam@list:concat([erlang:element(5, Feed), Authors]) ). -spec with_feed_link(atom_feed(), link()) -> atom_feed(). with_feed_link(Feed, Link) -> erlang:setelement(6, Feed, {some, Link}). -spec with_feed_category(atom_feed(), category()) -> atom_feed(). with_feed_category(Feed, Category) -> erlang:setelement(7, Feed, [Category | erlang:element(7, Feed)]). -spec with_feed_categories(atom_feed(), list(category())) -> atom_feed(). with_feed_categories(Feed, Categories) -> erlang:setelement( 7, Feed, gleam@list:concat([erlang:element(7, Feed), Categories]) ). -spec with_feed_contributor(atom_feed(), person()) -> atom_feed(). with_feed_contributor(Feed, Contributor) -> erlang:setelement(8, Feed, [Contributor | erlang:element(8, Feed)]). -spec with_feed_contributors(atom_feed(), list(person())) -> atom_feed(). with_feed_contributors(Feed, Contributors) -> erlang:setelement( 8, Feed, gleam@list:concat([erlang:element(8, Feed), Contributors]) ). -spec with_feed_generator(atom_feed(), generator()) -> atom_feed(). with_feed_generator(Feed, Generator) -> erlang:setelement(9, Feed, {some, Generator}). -spec with_feed_icon(atom_feed(), binary()) -> atom_feed(). with_feed_icon(Feed, Icon) -> erlang:setelement(10, Feed, {some, Icon}). -spec with_feed_logo(atom_feed(), binary()) -> atom_feed(). with_feed_logo(Feed, Logo) -> erlang:setelement(11, Feed, {some, Logo}). -spec with_feed_rights(atom_feed(), text()) -> atom_feed(). with_feed_rights(Feed, Rights) -> erlang:setelement(12, Feed, {some, Rights}). -spec with_feed_subtitle(atom_feed(), binary()) -> atom_feed(). with_feed_subtitle(Feed, Subtitle) -> erlang:setelement(13, Feed, {some, Subtitle}). -spec with_feed_entry(atom_feed(), atom_entry()) -> atom_feed(). with_feed_entry(Feed, Entry) -> erlang:setelement(14, Feed, [Entry | erlang:element(14, Feed)]). -spec with_feed_entries(atom_feed(), list(atom_entry())) -> atom_feed(). with_feed_entries(Feed, Entries) -> erlang:setelement( 14, Feed, gleam@list:concat([erlang:element(14, Feed), Entries]) ).