Skip to content

Commit

Permalink
Use feedly for feeds now instead of direct url, Element for feedly items
Browse files Browse the repository at this point in the history
  • Loading branch information
jariz committed May 6, 2015
1 parent 294a884 commit 5cee6a1
Show file tree
Hide file tree
Showing 7 changed files with 169 additions and 37 deletions.
3 changes: 2 additions & 1 deletion bower.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
"google-signin": "~0.2.1",
"pleasejs": "~0.4.2",
"pushbullet-js": "https://github.com/alexschneider/pushbullet-js.git",
"URIjs": "~1.15.0"
"URIjs": "~1.15.0",
"underscore": "~1.8.3"
}
}
3 changes: 2 additions & 1 deletion gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@ gulp.task('libs', function() {
'bower_components/momentjs/moment.js',
'bower_components/pleasejs/src/Please.js',
'bower_components/pushbullet-js/pushbullet.js',
'bower_components/URIjs/src/URI.min.js'
'bower_components/URIjs/src/URI.min.js',
'bower_components/underscore/underscore-min.js'
])
.pipe(concat('libs.js'))
.pipe(gulp.dest('dist/js'))
Expand Down
7 changes: 3 additions & 4 deletions src/coffee/Tabbie.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,7 @@ class Tabbie
if timeout then clearTimeout timeout

timeout = setTimeout =>
fetch "http://feedly.com/v3/search/auto-complete?query="+query+"&sites=7&topics=0&libraries=0&locale=en-US"
fetch "https://feedly.com/v3/search/auto-complete?query="+query+"&sites=7&topics=0&libraries=0&locale=en-US"
.then (response) ->
if response.status is 200 then Promise.resolve response
else Promise.reject new Error response.statusText
Expand All @@ -349,7 +349,7 @@ class Tabbie

adddialog.addButton 'add', ->
chrome.permissions.request
origins: ["http://feedly.com/"]
origins: ["https://feedly.com/"]
, (granted) =>
if granted
search.toggle()
Expand Down Expand Up @@ -486,7 +486,6 @@ class Tabbie
@columnNames.push columnName

createColumnFromFeedly: (feedly) =>
console.log feedly

#todo download and convert thumb to data url
if feedly.visualUrl then thumb = "http://proxy.boxresizer.com/convert?resize=150x150&source=" + encodeURIComponent(feedly.visualUrl)
Expand All @@ -495,7 +494,7 @@ class Tabbie
column = new Columns.CustomColumn
name: feedly.title
link: feedly.website
url: feedly.feedId.substring 5
url: "https://feedly.com/v3/streams/contents?streamId=" + encodeURIComponent(feedly.feedId)
thumb: thumb

@customColumns.push column
Expand Down
18 changes: 6 additions & 12 deletions src/columns/customcolumn/CustomColumn.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,13 @@
#blabla

class Columns.CustomColumn extends Columns.FeedColumn
element: "custom-item"
xmlTag: "item"
responseType: "xml"
width: 2

# name, link, name, etc all get set by Tabbie core
element: "feedly-item"
responseType: "json"
dataPath: "items"

attemptAdd: (successCallback) =>
uri = new URI @url
uri.path("")
console.log "[attemptAdd]", "full", @url, "formatted", uri.toString()

chrome.permissions.request
origins: [uri.toString()]
origins: ["https://feedly.com/"]
, (granted) =>
if granted and typeof successCallback is 'function' then successCallback()
if granted
if typeof successCallback is "function" then successCallback();
17 changes: 0 additions & 17 deletions src/columns/customcolumn/custom-item.html

This file was deleted.

148 changes: 148 additions & 0 deletions src/columns/customcolumn/feedly-item.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,148 @@
<link rel="import" href="../../../bower_components/polymer/polymer.html">
<link rel="import" href="../../time-ago.html">

<polymer-element name="feedly-item" attributes="item">
<template>
<style>
:host {
/*padding:10px;*/
padding-right:10px;
}

.media {
position:relative;
}

.media img {
width:100%;
}

h1 {
font-size:16px;
font-family: 'Roboto Slab', 'Roboto', sans-serif;
font-weight:normal;
}

.media h1 {
color:#fff;
position:absolute;
bottom:0;
background:rgba(0,0,0,.5);
width:100%;
left:0;
padding:5px 10px;
margin:0;
box-sizing: border-box;
}

.media h1 a {
color:#fff;
}

a {
color:#2c2c2c;
text-decoration: none;
}

.info {
color: #616161;
font-size:10px;
padding: 10px;
font-weight: lighter;
border-bottom:1px solid #d2d2d2;
}

footer {
margin-top:10px;
}

.info p {
margin:0;
}

footer p {
width:50%;
white-space: nowrap;
text-overflow: ellipsis;
overflow:hidden;
}

footer p:last-child {
text-align:right;
}
</style>

<template if="{{item.visual.url | isValidUrl}}">
<div class="media">
<img src="{{item.visual.url}}">
<h1><a target="_blank" href="{{item.alternate.href}}">{{item.title}}</a></h1>
</div>
</template>

<div class="info">

<template if="{{item.visual.url | isInvalidUrl}}">
<h1><a target="_blank" href="{{item.alternate.href}}">{{item.title}}</a></h1>
</template>

<p>{{item.article | filterHtml | summarize}}</p>

<footer layout horizontal>
<p>
<template if="{{item.author}}">
by {{item.author}}
</template>
</p>
<p>
<time-ago datetime="{{item.published}}" epoch="false"></time-ago>
</p>
</footer>

</div>

</template>
<script>
Polymer({
isValidUrl: function(url) {
return typeof url === "string" && url.substring(0, 4) === "http"
},

isInvalidUrl: function(url) {
//not very pretty, but polymer doesn't have an else statement
return !this.isValidUrl(url);
},

summarize: function(content) {
if(typeof content !== 'string') return content;

var words = content.split(" ")
if(words.length > 50) {
//more than 50 words, let's make it a bit shorter
words = words.filter(function(word, i) {
return i < 50;
})
content = words.join(' ') + '...';
}

return content;
},

filterHtml: function(string) {
//if it's not a string, we don't want it
if(typeof string !== 'string') return string;

//pretty mediocre way, but it's the only way to do this without *shivers* executing the html.
string = _.unescape(string)

//don't worry. this is just to make the summaries with html look a bit more nice.
//we're never actually inserting any html into the dom. because that's dangerous af. chrome runtime access, son. i don't think so.
return string.replace(/<[^>]*>?/g, '');
},

attached:function() {
if('summary' in this.item) this.item.article = this.item.summary.content;
else if('content' in this.item) this.item.article = this.item.content.content;
}
});
</script>
</polymer-element>
10 changes: 8 additions & 2 deletions src/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,19 @@
},
"permissions": [
"identity",
"http://*/*",
"https://*/*"
"https://lobste.rs/*",
"https://api.behance.net/*"
],
"optional_permissions": [
"http://*/",
"https://*/",

"https://www.reddit.com/",
"https://oauth.reddit.com/",
"https://api.producthunt.com/",
"https://feedly.com/",
"https://www.theverge.com/",

"management",
"bookmarks",
"chrome://favicon/*",
Expand Down

0 comments on commit 5cee6a1

Please sign in to comment.