Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Comparing changes

Choose two branches to see what's changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
base fork: joshua703/wireink
base: 7aed60807b
...
head fork: joshua703/wireink
compare: ba6ac994f1
  • 6 commits
  • 6 files changed
  • 0 commit comments
  • 1 contributor
View
7 Gruntfile.js
@@ -7,15 +7,16 @@ module.exports = function(grunt) {
uglify: {
options: {
banner: '/*! <%= pkg.name %> <%= grunt.template.today("yyyy-mm-dd") %> */\n',
- beautify: DEBUG_MODE
+ beautify: DEBUG_MODE,
+ mangle: !DEBUG_MODE
},
mv_target: {
files: {
'public/built/main.min.js': [
- 'src/bower_components/jquery/dist/jquery.min.js',
'src/bower_components/underscore/underscore.js',
- 'src/bower_components/momentjs/min/moment.min.js',
+ 'src/bower_components/jquery/dist/jquery.min.js',
'src/bower_components/backbone/backbone.js',
+ 'src/bower_components/momentjs/min/moment.min.js',
'src/main.js',
'src/ui.js'
]
View
43 indexer/crawler.js
@@ -79,17 +79,44 @@ function fetchArticle(articleEl, site) {
qs: null,
headers: {}
}, function(error, response, articlePage) {
+ //return early if the request object is undefined
+ if (!response) {
+ return console.error("Response was undefined", error);
+ }
//Parse a single article page
var $articlePage = cheerio.load(articlePage);
var $dateEl = $articlePage(site.pubDate.selector);
+ var body;
+ var title;
+ var articleImage;
+
+ if (site.body.target === 'content') {
+ body = $articlePage(site.body.selector).attr('content');
+ } else if (site.body.target === 'text') {
+ body = $articlePage(site.body.selector).text();
+ }
+
+ if (site.title.target === 'content') {
+ title = $articlePage(site.title.selector).attr('content');
+ } else if (site.title.target === 'text') {
+ title = $articlePage(site.title.selector).text();
+ }
+
+ if (!body || !title) {
+ return console.error("Both title and body must be defined");
+ }
+
+ if ($articlePage(site.articleImage).attr('src')) {
+ articleImage = $articlePage(site.articleImage).attr('src');
+ }
//Generate the article object
var article = {
- body: $articlePage(site.body.selector).attr('content'),
- title: $articlePage(site.title.selector).attr('content'),
+ body: body.trim(),
+ title: title.trim(),
byline: null,
articleUrl: response.request.href,
- articleImage: $articlePage(site.articleImage).attr('src'),
+ articleImage: articleImage,
publicationName: site.publicationName,
clicks: 0,
upvotes: 0
@@ -100,7 +127,6 @@ function fetchArticle(articleEl, site) {
console.error("Article has no body or title. URL: " + article.articleUrl);
return;
}
-
//Set the date to a Date object, if we have it
if ($dateEl.length) {
var date = null;
@@ -108,16 +134,19 @@ function fetchArticle(articleEl, site) {
date = new Date($dateEl.attr('content'));
} else if (site.pubDate.target === "text") {
date = new Date($dateEl.text());
- } else if (site.pubDate === "doubledash") {
+ } else if (site.pubDate.target === "doubledash") {
//A date that looks like "Tue, Mar 25, 2014 -- 9:00 AM" (from KQED as of April 2, 2014)
- console.log($dateEl.text());
date = new Date($dateEl.text().replace('--', ''));
+ } else if (site.pubDate.target === 'dotdash') {
+ date = new Date($dateEl.text().replace(/\./g, '/').replace('-', ''));
}
if(date !== null) {
article.date = date.toISOString();
}
}
-
+if(site.publicationName === "KQED Public Media") {
+ console.log(article)
+}
article.tags = tagArticle(article);
//Persist the article to Parse
View
76 indexer/indexer.json
@@ -4,11 +4,11 @@
"type": "html",
"title": {
"selector": "meta[property=\"og:title\"]",
- "target": "text"
+ "target": "content"
},
"body": {
"selector": "meta[property=\"og:description\"]",
- "target": "text"
+ "target": "content"
},
"byline": {
"selector": "#articleByline",
@@ -29,11 +29,11 @@
"type": "html",
"title": {
"selector": "meta[property=\"og:title\"]",
- "target": "text"
+ "target": "content"
},
"body": {
"selector": "meta[property=\"og:description\"]",
- "target": "text"
+ "target": "content"
},
"byline": {
"selector": "#articleByline",
@@ -54,11 +54,11 @@
"type": "html",
"title": {
"selector": "meta[property=\"og:title\"]",
- "target": "text"
+ "target": "content"
},
"body": {
"selector": "meta[property=\"og:description\"]",
- "target": "text"
+ "target": "content"
},
"byline": {
"selector": "#articleByline",
@@ -79,11 +79,11 @@
"type": "html",
"title": {
"selector": "meta[property=\"og:title\"]",
- "target": "text"
+ "target": "content"
},
"body": {
"selector": "meta[property=\"og:description\"]",
- "target": "text"
+ "target": "content"
},
"byline": {
"selector": "#articleByline",
@@ -104,11 +104,11 @@
"type": "html",
"title": {
"selector": "meta[property=\"og:title\"]",
- "target": "text"
+ "target": "content"
},
"body": {
"selector": "meta[property=\"og:description\"]",
- "target": "text"
+ "target": "content"
},
"byline": {
"selector": "#articleByline",
@@ -129,11 +129,11 @@
"type": "html",
"title": {
"selector": "meta[property=\"og:title\"]",
- "target": "text"
+ "target": "content"
},
"body": {
"selector": "meta[property=\"og:description\"]",
- "target": "text"
+ "target": "content"
},
"byline": {
"selector": "#articleByline",
@@ -149,6 +149,56 @@
"articleImage": ".articleImage img",
"publicationName": "Oakland Local",
"secondaryLocation": "California"
+ },
+ "SanFranciscoBayGuardianPolitics": {
+ "type": "html",
+ "title": {
+ "selector": "h1.title",
+ "target": "text"
+ },
+ "body": {
+ "selector": ".content p",
+ "target": "text"
+ },
+ "byline": {
+ "selector": "#articleByline",
+ "target": "selfText"
+ },
+ "pubDate": {
+ "selector": ".timestamp",
+ "target": "dotdash"
+ },
+ "indexUrl": "http://www.sfbg.com/politics",
+ "articleUrl": "h2.title a",
+ "prependUrl": "http://www.sfbg.com",
+ "articleImage": ".aef-image img",
+ "publicationName": "San Francisco Bay Guardian",
+ "secondaryLocation": "California"
+ },
+ "SanFranciscoBayGuardianNews": {
+ "type": "html",
+ "title": {
+ "selector": "h1.title",
+ "target": "text"
+ },
+ "body": {
+ "selector": ".content p",
+ "target": "text"
+ },
+ "byline": {
+ "selector": "#articleByline",
+ "target": "selfText"
+ },
+ "pubDate": {
+ "selector": ".timestamp",
+ "target": "dotdash"
+ },
+ "indexUrl": "http://www.sfbg.com/topic/news",
+ "articleUrl": "h2.title a",
+ "prependUrl": "http://www.sfbg.com",
+ "articleImage": ".aef-image img",
+ "publicationName": "San Francisco Bay Guardian",
+ "secondaryLocation": "California"
}
- }
+ }
}
View
53 public/index.html
@@ -86,10 +86,10 @@ <h1 id="secondary-heading">
</div>
<script type="text/template" id="article-entry">
<div class="entry">
- <div class="rating"
- ">
- <a href="#" title="<%- upvotes %> others found this useful, <% print(thumbed === true ? " including you." : "did
- you?"); %>" class="<% print(thumbed === true ? "disabled" : "enabled"); %> thumb thumb-up fa fa-thumbs-up"></a>
+ <div class="rating"">
+ <a href="#"
+ title="<%- upvotes %> others found this useful, <% print(thumbed === true ? " including you." : "did you?"); %>"
+ class="<% print(thumbed === true ? "disabled" : "enabled"); %> thumb thumb-up fa fa-thumbs-up"></a>
</div>
<h2>
<a href="#/view/<%- _id %>" class="source-link">
@@ -98,8 +98,7 @@ <h1 id="secondary-heading">
</h2>
<div class="meta">
<time datetime="<%- date %>" title="<% print(moment(date).format('MMMM Do, YYYY h:mma')) %>">
- <% (moment().diff(moment(date), 'days') > 3 ? print(moment(date).format('MMMM Do, YYYY')) :
- print(moment(date).from())) %>
+ <% (moment().diff(moment(date), 'days') > 3 ? print(moment(date).format('MMMM Do, YYYY')) : print(moment(date).from())) %>
</time>
by
<span class="pub-name">
@@ -119,48 +118,6 @@ <h1 id="secondary-heading">
No articles were found, do you want to see the <a href='#'>newest articles</a>?
</li>
</script>
-<!-- start Mixpanel -->
-<script type="text/javascript">(function (e, b) {
- if (!b.__SV) {
- var a, f, i, g;
- window.mixpanel = b;
- b._i = [];
- b.init = function (a, e, d) {
- function f(b, h) {
- var a = h.split(".");
- 2 == a.length && (b = b[a[0]], h = a[1]);
- b[h] = function () {
- b.push([h].concat(Array.prototype.slice.call(arguments, 0)))
- }
- }
-
- var c = b;
- "undefined" !== typeof d ? c = b[d] = [] : d = "mixpanel";
- c.people = c.people || [];
- c.toString = function (b) {
- var a = "mixpanel";
- "mixpanel" !== d && (a += "." + d);
- b || (a += " (stub)");
- return a
- };
- c.people.toString = function () {
- return c.toString(1) + ".people (stub)"
- };
- i = "disable track track_pageview track_links track_forms register register_once alias unregister identify name_tag set_config people.set people.set_once people.increment people.append people.track_charge people.clear_charges people.delete_user".split(" ");
- for (g = 0; g < i.length; g++)f(c, i[g]);
- b._i.push([a, e, d])
- };
- b.__SV = 1.2;
- a = e.createElement("script");
- a.type = "text/javascript";
- a.async = !0;
- a.src = ("https:" === e.location.protocol ? "https:" : "http:") + '//cdn.mxpnl.com/libs/mixpanel-2.2.min.js';
- f = e.getElementsByTagName("script")[0];
- f.parentNode.insertBefore(a, f)
- }
-})(document, window.mixpanel || []);
-mixpanel.init("dca0fb7b70e5176a0c1e97ee7161239d");</script>
-<!-- end Mixpanel -->
<script src="/built/main.min.js" type="text/javascript"></script>
</body>
</html>
View
4 src/main.js
@@ -61,8 +61,6 @@ var ArticleEntryView = Backbone.View.extend({
return this;
},
viewArticle: function(evt) {
- //mixpanel.track('view-article');
-
if ("ontouchstart" in window) {
evt.preventDefault();
@@ -77,7 +75,6 @@ var ArticleEntryView = Backbone.View.extend({
}
},
thumbUp: function (evt) {
- //mixpanel.track('thumb-up');
evt.preventDefault();
console.log(this.model);
var $ratingEl = this.$el.find('.rating a');
@@ -121,7 +118,6 @@ var AppView = Backbone.View.extend({
DEFAULT_LIMIT: 100,
el: $('#main-app'),
initialize: function () {
- //mixpanel.track('app-load');
},
index: function () {
this.popular(0);
View
3  src/ui.js
@@ -3,9 +3,6 @@ $('.submenu').on("click", function(evt) {
//Adds a class that makes the submenu visible
$(this).addClass('show');
- //Tracking menu clicks via Mixpanel
- mixpanel.track('dropdown-click');
-
//Bind an "outsideClick" handler to the menu after one tick
setTimeout(function() {
$(document).one("click", function(evt) {

No commit comments for this range

Something went wrong with that request. Please try again.