Skip to content

onurdemir55/resurrections-rss

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

resurrections - rss

License: MIT

Exactly yes the project name refers The Matrix Resurrections. Oldies but Goldies. Back to the RSS.

Rss is an acronym for Really Simple Syndication. Resurrections-rss is a very easy-peasy Java project for creating RSS-2.0 feeds. This project code contains required mandatory and some optional rss elements. You are free to extend this. One more thing and biggest advantages is that Support CDATA and Plain Text.

Why this project was needed ?

Firstly I have to say that the best project about creating Rss feed is Rome. Literally they did a great job. Congratulations to the whole contributors. Just one more improvement that we needed. Just CDATA. Sorry but Rome not support that :(

If your output content is HTML, CDATA output more readable. (Encoded format is not preferable). Some News Editors, checks the Rss News output manually, selects and decides item. So some customers can expect to see CDATA output.

Features

  • Works on Java version 8 or later.
  • Elements support Plain Text and CDATA format. You can set your encoded data or you can set them as CDATA.
  • jackson XML data format
  • Lombok keeps code clean and easy to use Builder Pattern
  • Easy and Peasy development
  • Simple and easy to extend for optional elements if needed. Just add fields to entity classes.
  • MIT licensed

Basic Setting Before Coding

  • Work with lombok, make this basic setting.
  • Possible errors, check this

Overview Info

Examples

        // creates plaint text holder
        Value plainText=new SimpleValue("simple value")

        // creates cdata holder
        Value cdata=new CDATAValue("cdata value")

Create a feed:

        Set<Value> set = new HashSet<>(Arrays.asList(
                                            new SimpleValue("category-1"),
                                            new SimpleValue("category-2"),
                                            new SimpleValue("category-3"),
                                            new SimpleValue("category-3")));

        Item item = Item.builder()
                        .title(new SimpleValue("sample title"))
                        .category(set)
                        .description(new CDATAValue("sample description"))
                        .link(new CDATAValue("https://www.google.com/"))
                        .pubDate(new SimpleValue(DateParser.format_RFC1123_RFC822(new Date())))
                        .build();

        // items
        List<Item> items = Arrays.asList(item);


        Channel channel = Channel.builder()
                                .items(items)
                                .language(new SimpleValue("en"))
                                .pubDate(new SimpleValue(DateParser.format_RFC1123_RFC822(Instant.now())))
                                .title(new CDATAValue("sample title"))
                                .description(new CDATAValue("sample description"))
                                .link(new SimpleValue("https://www.google.com/"))
                                .build();


        Rss rss = Rss.builder()
                      .version("2.0")
                      .channel(channel)
                      .build();

        String xmlOutput = RssOutput.outputString(rss);
<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0">
  <channel>
    <title><![CDATA[sample title]]></title>
    <link>https://www.google.com/</link>
    <description><![CDATA[sample description]]></description>
    <language>en</language>
    <pubDate>Sat, 9 Oct 2021 20:38:50 GMT</pubDate>
    <item>
      <title>sample title</title>
      <link><![CDATA[https://www.google.com/]]></link>
      <description><![CDATA[sample description]]></description>
      <category>category-3</category>
      <category>category-2</category>
      <category>category-1</category>
      <pubDate>Sat, 9 Oct 2021 20:38:50 GMT</pubDate>
    </item>
    <item>
      <title><![CDATA[sample title]]></title>
      <link><![CDATA[https://www.google.com/]]></link>
      <description><![CDATA[sample description]]></description>
      <category><![CDATA[category-2]]></category>
      <category><![CDATA[category-1]]></category>
      <pubDate><![CDATA[Sat, 9 Oct 2021 20:38:50 GMT]]></pubDate>
    </item>
  </channel>
</rss>

About

Easy Peasy Java Rss Feeder which supports CDATA.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages