Permalink
Browse files

Persist the original URL for an article image to storage

  • Loading branch information...
1 parent 8e34df3 commit f86c7e1a1e4441cbc206dfdf9f536b7df80a4f7b Joshua Davis committed Apr 17, 2014
Showing with 11 additions and 6 deletions.
  1. +6 −5 indexer/crawler.js
  2. +5 −1 server/schemas/article.js
View
@@ -134,7 +134,7 @@ function fetchArticle(articleEl, site) {
var body;
var title;
var articleImage;
- var articleImageUrl;
+ var articleImageUrl = $articlePage(site.articleImage).attr('src');
if (site.body.target === 'content') {
body = $articlePage(site.body.selector).attr('content');
@@ -152,10 +152,6 @@ function fetchArticle(articleEl, site) {
return console.error("Both title and body must be defined");
}
- articleImageUrl = $articlePage(site.articleImage).attr('src');
- if (articleImageUrl) {
- saveImage(articleImageUrl);
- }
//Generate the article object
var article = {
@@ -169,6 +165,11 @@ function fetchArticle(articleEl, site) {
upvotes: 0
};
+ if (articleImageUrl) {
+ article.articleOriginalImageUrl = articleImageUrl;
+ saveImage(articleImageUrl);
+ }
+
//Return early if there's no tile or body
if (!article.title || !article.body) {
console.error("Article has no body or title. URL: " + article.articleUrl);
@@ -28,7 +28,11 @@ module.exports = mongoose.Schema({
},
articleImage: {
type: String,
- required: false,
+ required: false
+ },
+ articleOriginalImageUrl: {
+ type: String,
+ required: false
},
clicks: {
type: Number,

0 comments on commit f86c7e1

Please sign in to comment.