This commit is contained in:
Athou
2013-04-09 13:37:00 +02:00
parent e718586e22
commit 7d982a440a
5 changed files with 57 additions and 0 deletions

View File

@@ -17,7 +17,9 @@ import com.commafeed.backend.model.Feed;
import com.commafeed.backend.model.FeedEntry;
import com.google.common.base.Function;
import com.google.common.collect.Collections2;
import com.google.common.collect.Iterables;
import com.sun.syndication.feed.synd.SyndContent;
import com.sun.syndication.feed.synd.SyndEnclosure;
import com.sun.syndication.feed.synd.SyndEntry;
import com.sun.syndication.feed.synd.SyndFeed;
import com.sun.syndication.io.FeedException;
@@ -51,6 +53,13 @@ public class FeedParser {
entry.setUrl(item.getLink());
entry.setUpdated(getUpdateDate(item));
SyndEnclosure enclosure = (SyndEnclosure) Iterables.getFirst(
item.getEnclosures(), null);
if (enclosure != null) {
entry.setEnclosureUrl(enclosure.getUrl());
entry.setEnclosureType(enclosure.getType());
}
feed.getEntries().add(entry);
}
} catch (Exception e) {

View File

@@ -37,6 +37,12 @@ public class FeedEntry extends AbstractModel {
@Column(length = Integer.MAX_VALUE)
private String content;
@Column(length = 2048)
private String enclosureUrl;
@Column(length = 255)
private String enclosureType;
@Column(length = 2048)
private String url;
@@ -115,4 +121,20 @@ public class FeedEntry extends AbstractModel {
this.inserted = inserted;
}
public String getEnclosureUrl() {
return enclosureUrl;
}
public void setEnclosureUrl(String enclosureUrl) {
this.enclosureUrl = enclosureUrl;
}
public String getEnclosureType() {
return enclosureType;
}
public void setEnclosureType(String enclosureType) {
this.enclosureType = enclosureType;
}
}

View File

@@ -9,6 +9,8 @@ public class Entry implements Serializable {
private String id;
private String title;
private String content;
private String enclosureUrl;
private String enclosureType;
private Date date;
private String feedId;
private String feedName;
@@ -97,4 +99,20 @@ public class Entry implements Serializable {
this.feedUrl = feedUrl;
}
public String getEnclosureUrl() {
return enclosureUrl;
}
public void setEnclosureUrl(String enclosureUrl) {
this.enclosureUrl = enclosureUrl;
}
public String getEnclosureType() {
return enclosureType;
}
public void setEnclosureType(String enclosureType) {
this.enclosureType = enclosureType;
}
}

View File

@@ -105,6 +105,8 @@ public class EntriesREST extends AbstractREST {
entry.setId(String.valueOf(status.getId()));
entry.setTitle(feedEntry.getTitle());
entry.setContent(feedEntry.getContent());
entry.setEnclosureUrl(status.getEntry().getEnclosureUrl());
entry.setEnclosureType(status.getEntry().getEnclosureType());
entry.setDate(feedEntry.getUpdated());
entry.setUrl(feedEntry.getUrl());

View File

@@ -24,6 +24,12 @@
</h4>
</div>
<div ng-bind-html-unsafe="entry.content"></div>
<video controls ui-if="entry.enclosureType && entry.enclosureType.indexOf('video') == 0">
<source src="{{entry.enclosureUrl}}" type="{{entry.enclosureType}}" />
</video>
<audio controls ui-if="entry.enclosureType && entry.enclosureType.indexOf('audio') == 0">
<source src="{{entry.enclosureUrl}}" type="{{entry.enclosureType}}" />
</audio>
<div class="entry-buttons form-horizontal">
<label class="checkbox">
<input type="checkbox" ng-checked="!entry.read" ng-click="mark(entry, !entry.read)"></input>