Skip to content

Commit

Permalink
Change Link to use the Atom type instead
Browse files Browse the repository at this point in the history
The code duplication didn't seem to be worth it
  • Loading branch information
porglezomp committed Jun 14, 2016
1 parent a5e112a commit 1012a5b
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 26 deletions.
9 changes: 4 additions & 5 deletions src/entry.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
extern crate atom_syndication;
extern crate rss;
extern crate chrono;
use atom_syndication;
use rss;

use chrono::{DateTime, UTC};
use category::Category;
use link::Link;
use atom_syndication::Link;

enum EntryData {
Atom(atom_syndication::Entry),
Expand Down Expand Up @@ -59,7 +58,7 @@ impl From<atom_syndication::Entry> for Entry {
content: entry.content,
links: entry.links
.into_iter()
.map(|link| Link { href: link.href })
.map(|link| link.into())
.collect::<Vec<_>>(),
// TODO: Implement the Category type for converting this
categories: vec![],
Expand Down
23 changes: 7 additions & 16 deletions src/feed.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
extern crate atom_syndication;
extern crate rss;
extern crate chrono;
use atom_syndication;
use rss;

use std::str::FromStr;
use chrono::{DateTime, UTC};
use atom_syndication::{Link, Person};

use category::Category;
use link::Link;
use entry::Entry;

enum FeedData {
Expand Down Expand Up @@ -45,12 +44,11 @@ pub struct Feed {
pub links: Vec<Link>,
// `categories` in both Atom and RSS
pub categories: Vec<Category>,
// TODO: Define our own Person type for API stability reasons
// TODO: Should the `web_master` be in `contributors`, `authors`, or at all?
// `authors` in Atom, `managing_editor` in RSS (produces 1 item Vec)
pub authors: Vec<atom_syndication::Person>,
pub authors: Vec<Person>,
// `contributors` in Atom, `web_master` in RSS (produces a 1 item Vec)
pub contributors: Vec<atom_syndication::Person>,
pub contributors: Vec<Person>,
// `entries` in Atom, and `items` in RSS
// TODO: Add more fields that are necessary for RSS
// TODO: Fancy translation, e.g. Atom <link rel="via"> = RSS `source`
Expand All @@ -71,11 +69,7 @@ impl From<atom_syndication::Feed> for Feed {
icon: feed.icon,
image: feed.logo,
// NOTE: We throw away the generator field
// TODO: Add more fields to the link type
links: feed.links
.into_iter()
.map(|link| Link { href: link.href })
.collect::<Vec<_>>(),
links: feed.links,
// TODO: Handle this once the Category type is defined
categories: vec![],
authors: feed.authors,
Expand Down Expand Up @@ -106,10 +100,7 @@ impl From<Feed> for atom_syndication::Feed {
icon: feed.icon,
logo: feed.image,
generator: None,
links: feed.links
.into_iter()
.map(|link| atom_syndication::Link { href: link.href, ..Default::default() })
.collect::<Vec<_>>(),
links: feed.links,
// TODO: Convert from our Category type instead of throwing them away
categories: vec![],
authors: feed.authors,
Expand Down
4 changes: 2 additions & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@ extern crate rss;
extern crate chrono;

mod category;
mod link;
mod person;
mod entry;
mod feed;

pub use ::atom_syndication::Link;

pub use ::category::Category;
pub use ::link::Link;
pub use ::person::Person;
pub use ::entry::Entry;
pub use ::feed::Feed;
3 changes: 0 additions & 3 deletions src/link.rs

This file was deleted.

0 comments on commit 1012a5b

Please sign in to comment.