Last active
January 4, 2016 07:48
-
-
Save josephpconley/8590722 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
package com.josephpconley.rss | |
import scala.xml.Elem | |
/** | |
* User: jconley | |
* Date: 1/16/14 | |
*/ | |
case class Item(title: String, description: String, link: String, guid: String){ | |
def xml = { | |
<item> | |
<title>{title}</title> | |
<description>{ | |
//wrap in PCData in case we want to use HTML in our description | |
scala.xml.PCData(description) | |
} | |
</description> | |
<link>{link}</link> | |
<guid>{guid}</guid> | |
</item> | |
} | |
} | |
abstract trait Feed{ | |
val name: String | |
val title: String | |
val description: String | |
val link: String | |
val atomLink: String | |
def items: Seq[Item] | |
def xml: Elem = { | |
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"> | |
<channel> | |
<title>{title}</title> | |
<description>{description}</description> | |
<link>{link}</link> | |
<atom:link href={atomLink} rel="self" type="application/rss+xml" />{ | |
items.map(_.xml) | |
} | |
</channel> | |
</rss> | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment