[ Launch: user page ] 5216418 by ptvans
[ Launch: testing params ] 5088240 by enjalot
[ Launch: testing params ] 5088156 by enjalot
-
-
Save ptvans/5216418 to your computer and use it in GitHub Desktop.
user page
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{"description":"user page","endpoint":"","display":"div","public":true,"require":[],"fileconfigs":{"inlet.js":{"default":true,"vim":false,"emacs":false,"fontSize":12},"_.md":{"default":true,"vim":false,"emacs":false,"fontSize":12},"config.json":{"default":true,"vim":false,"emacs":false,"fontSize":12},"style.css":{"default":true,"vim":false,"emacs":false,"fontSize":12}},"fullscreen":false,"play":false,"loop":false,"restart":false,"autoinit":true,"pause":true,"loop_type":"period","bv":false,"nclones":15,"clone_opacity":0.4,"duration":3000,"ease":"linear","dt":0.01,"thumbnail":"http://i.imgur.com/2GWKmwv.png"} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var query = tributary.query; | |
var username = query.user || "ptvans"; | |
var imgWidth = 32; | |
var imgHeight = 32; | |
var urlBase = "http://tributary.io" | |
var url = urlBase + "/api/user/" + username + "/latest?limit=200"; | |
d3.json(url, function(err, inlets) { | |
render(inlets); | |
}); | |
var dateFormat = d3.time.format("%m.%d.%Y") | |
var display = d3.select("#display"); | |
display.append("div") | |
.classed("name", true) | |
.text(username); | |
function render(inlets) { | |
display.append("div") | |
.classed("count", true) | |
.text(inlets.length + " inlets") | |
//console.log(inlets); | |
var divs = display.selectAll("div.inlet") | |
.data(inlets) | |
var enter = divs | |
.enter() | |
.append("div") | |
.classed("inlet", true); | |
//TODO: default image for when no thumbnail exists | |
enter.append("img") | |
.attr({ | |
src: function(d) { return d.thumbnail }, | |
width: imgWidth, | |
height: imgHeight | |
}) | |
enter.append("a") | |
.classed("description", true) | |
.attr({ | |
href: function(d) { return urlBase + "/inlet/" + d.gistid }, | |
target: "blank" | |
}) | |
.text(function(d) { return d.description }); | |
enter.append("span") | |
.classed("date", true) | |
.text(function(d) { | |
var date = new Date(d.createdAt); | |
return " " + dateFormat(date) | |
}) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#display { | |
overflow: scroll | |
} | |
.name { | |
font-weight: 700; | |
font-size: 24px; | |
} | |
.inlet { | |
} | |
.inlet .description { | |
} | |
.inlet .date { | |
font-size: 10px; | |
} | |
.inlet img { | |
margin: 5px; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment