Permalink
Browse files

initial commit

  • Loading branch information...
edsu committed Sep 10, 2012
0 parents commit ead31469ba6f04d3cfaf96e8a7aef2773e43d946
Showing with 799 additions and 0 deletions.
  1. +14 −0 README.md
  2. +45 −0 css/style.css
  3. BIN images/lastfm.png
  4. BIN images/social_icons_png/.DS_Store
  5. BIN images/social_icons_png/black_white_16.png
  6. BIN images/social_icons_png/black_white_24.png
  7. BIN images/social_icons_png/black_white_32.png
  8. BIN images/social_icons_png/black_white_40.png
  9. BIN images/social_icons_png/black_white_48.png
  10. BIN images/social_icons_png/black_white_56.png
  11. BIN images/social_icons_png/black_white_64.png
  12. BIN images/social_icons_png/orange_transparent_16.png
  13. BIN images/social_icons_png/orange_transparent_24.png
  14. BIN images/social_icons_png/orange_transparent_32.png
  15. BIN images/social_icons_png/orange_transparent_40.png
  16. BIN images/social_icons_png/orange_transparent_48.png
  17. BIN images/social_icons_png/orange_transparent_56.png
  18. BIN images/social_icons_png/orange_transparent_64.png
  19. BIN images/social_icons_png/orange_white_16.png
  20. BIN images/social_icons_png/orange_white_24.png
  21. BIN images/social_icons_png/orange_white_32.png
  22. BIN images/social_icons_png/orange_white_40.png
  23. BIN images/social_icons_png/orange_white_48.png
  24. BIN images/social_icons_png/orange_white_56.png
  25. BIN images/social_icons_png/orange_white_64.png
  26. BIN images/social_icons_png/white_orange_16.png
  27. BIN images/social_icons_png/white_orange_24.png
  28. BIN images/social_icons_png/white_orange_32.png
  29. BIN images/social_icons_png/white_orange_40.png
  30. BIN images/social_icons_png/white_orange_48.png
  31. BIN images/social_icons_png/white_orange_56.png
  32. BIN images/social_icons_png/white_orange_64.png
  33. BIN images/social_icons_png/white_transparent_16.png
  34. BIN images/social_icons_png/white_transparent_24.png
  35. BIN images/social_icons_png/white_transparent_32.png
  36. BIN images/social_icons_png/white_transparent_40.png
  37. BIN images/social_icons_png/white_transparent_48.png
  38. BIN images/social_icons_png/white_transparent_56.png
  39. BIN images/social_icons_png/white_transparent_64.png
  40. BIN images/soundcloud-large.png
  41. BIN images/soundcloud.png
  42. +82 −0 index.html
  43. +41 −0 js/lastcloud.js
  44. +617 −0 js/mustache.js
@@ -0,0 +1,14 @@
+lastcloud
+=========
+
+This is a little HTML/JavaScript hack that uses the
+[LastFM](http://last.fm) and [Soundcloud][http://soundcloud.com] APIs
+APIs to look for musicians you listen to, who might be active
+on Soundcloud.
+
+Thanks to Mustache and jQuery for making this doable in an hour or two.
+
+Licsense
+--------
+
+* CC0
@@ -0,0 +1,45 @@
+body {
+ font-size: 14pt;
+ width: 30%;
+ margin-left: auto;
+ margin-right: auto;
+}
+
+header {
+ text-align: center;
+ font-size: 40pt;
+ font-weight: bold;
+}
+
+header img {
+ vertical-align: top;
+}
+
+#summary {
+ font-size: 10pt;
+ padding: 5px;
+ font-style: italic;
+}
+
+#search {
+ margin-top: 10px;
+ text-align: center;
+}
+
+#search input {
+ height: 40px;
+ font-size: 14pt;
+ padding-left: 10px;
+}
+
+#results li {
+ padding-top: 20px;
+ border-top: thin solid #eeeeee;
+ text-align: center;
+ list-style: none;
+}
+
+#results .artist a {
+ text-decoration: none;
+}
+
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
@@ -0,0 +1,82 @@
+<html>
+ <head>
+ <link rel="stylesheet" href="css/style.css"></link>
+
+ <script type="text/javascript">
+ var _gaq = _gaq || [];
+ _gaq.push(['_setAccount', 'UA-16871278-7']);
+ _gaq.push(['_trackPageview']);
+ (function() {
+ var ga = document.createElement('script');
+ ga.type = 'text/javascript';
+ ga.async = true;
+ ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
+ var s = document.getElementsByTagName('script')[0];
+ s.parentNode.insertBefore(ga, s);
+ })();
+ </script>
+ </head>
+ <body>
+
+ <header>lastcloud</header>
+
+ <section id="summary">
+
+ <p>
+ Enter your <a href="http://last.fm">LastFM</a> username below
+ and I'll try to find the top 100 artists you listen to who look
+ like they might upload tracks to
+ <a href="http://soundcloud.com">Soundcloud</a>.
+ </p>
+
+ <p>
+ I'm not perfect, since there are some Soundcloud users who have
+ taken musician names as their own. But you might be pleasantly
+ surprised to find some Soundcloud users you didn't know about
+ already.
+ </p>
+
+ <p>
+ Oh, this is a pure HTML and JavaScript
+ app, and you won't need to login to anything, or bring oAuth
+ to the dance. Code is also on
+ <a href="http://github.com/edsu/lastcloud">Github</a>
+ if you have ideas for fixing/improving it.
+ </p>
+ </section>
+
+ <section id="search">
+ <input placeholder="your lastfm username" name="username" type="text">
+ <input type="submit" value="oh why not"></input>
+ </section>
+
+ <section id="results">
+ <ul id="results"></ul>
+ </section>
+
+ <!-- javascript -->
+ <script src="http://connect.soundcloud.com/sdk.js"></script>
+ <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.1/jquery.min.js"></script>
+ <script src="js/mustache.js"></script>
+ <script src="js/lastcloud.js"></script>
+ <script>
+ $(document).ready(init);
+ </script>
+
+ <!-- templates -->
+ <script id="artist-template" type="text/x-mustache-template">
+ <li class="artist" id="{{ id }}">
+ <img src="{{ image }}">
+ <br>
+ <a target="_new" href="{{ url }}">{{ name }}</a>
+ <br>
+ </li>
+ </script>
+
+ <script id="soundcloud-template" type="test/x-mustache-template">
+ <a target="_new" href="{{ permalink_url }}">
+ <img title="{{ full_name }} [{{ username }}]"src="images/soundcloud-large.png"></img>
+ </a>
+ </script>
+ </body>
+</html>
@@ -0,0 +1,41 @@
+function init() {
+ $('input[type="submit"]').click(lastfmArtists);
+}
+
+function lastfmArtists() {
+ var key = "0d5ffce4d06bffa87a0415eddf078cde";
+ var username = $('input[name="username"]').val();
+ var url = "http://ws.audioscrobbler.com/2.0/?method=library.getartists&format=json&limit=100&api_key=" + key + "&user=" + username;
+ $.ajax({url: url, dataType: "jsonp", success: soundcloudUsers});
+}
+
+function soundcloudUsers(lastfmResponse) {
+ var artists = lastfmResponse.artists.artist;
+ var template = $("#artist-template").html();
+ $("ul").empty();
+ for (var i in artists) {
+ var artist = artists[i];
+ artist.id = normalize(artist.name);
+ artist.image = artist.image[2]["#text"];
+ $("#results").append(Mustache.render(template, artist));
+ SC.initialize({'client_id': '000d9ae8898f80c0fe2ace5bd9e8f58e'});
+ SC.get('/users', {q: artist.name}, addSoundcloud);
+ }
+}
+
+function addSoundcloud(response) {
+ for (var j in response) {
+ var user = response[j];
+ var username = normalize(user.username);
+ console.log("looking for id=" + username);
+ var li = $("#" + username)[0];
+ var template = $("#soundcloud-template").html();
+ if (li) {
+ $(li).append(Mustache.render(template, user));
+ }
+ }
+}
+
+function normalize(s) {
+ return s.toLowerCase().replace(/[^\w]/g, "");
+}
Oops, something went wrong.

0 comments on commit ead3146

Please sign in to comment.