diff --git a/README b/README index e69de29..c0ddba6 100644 --- a/README +++ b/README @@ -0,0 +1,17 @@ +Changelog: +---------- + +- Moved initial comment below the Doctype +- Created separate script "nose.js" file to clear the HTML +- Moved script to the end of the file -- just before the closing tag +- Modified the log() function to work and added some styling to it + +ToDoS : +------- + +- Implementation for a simple use case -- the one described in the chapter, i.e: + Fetching from Freebase for a movie entity > Searching for the Soundtrack > requesting MusicBrainz to retrieve the Soundtrack info +- Explore different nose-following paths... +- Find a good & reliable source of information. + It seems it's kind of a unicorn at the moment. Solution: use YQL to aggregate several sources of information? + + idea: use the YQL Jquery plugin? () \ No newline at end of file diff --git a/css/woo.css b/css/woo.css new file mode 100644 index 0000000..8e2dd7a --- /dev/null +++ b/css/woo.css @@ -0,0 +1,41 @@ + +/* ---------------------------- */ +/* Styling, just a bit, for fun */ +/* ---------------------------- */ + +body{ + width: 960px; + margin: 50px auto; + color: #444; + position: relative; +} +h1{ text-align: center; font-family: Arial, sans-serif; padding-bottom: 0.2em; border-bottom: 1px #999 solid;} +label{ display: block;} +input{ width: 390px; margin-top: 5px;} +form{ + width: 400px; + margin: 50px auto; + background-color: #dedede; + border-radius: 5px; + box-shadow: 0px 0px 7px #333; + -webkit-box-shadow: 0px 0px 7px #333; + -moz-box-shadow: 0px 0px 7px #333; + border: 1px #999 solid; + padding: 15px; +} + +#log{ + background-color: #000; color: #fff; font-family: Courier, mono; + padding: 5px; + width: 100%; + max-height: 220px; + overflow-y:scroll; + position: fixed; + bottom: 0; + left:0; + border-top: 2px #999 solid; + opacity: 0.7; + +} +#log h2 {margin-bottom: 0.5em; font-size: 14px; text-align: center;} +#log div{padding: 4px 10px; border-bottom: 1px #fff solid; font-size: 11px;} diff --git a/index.html b/index.html index 08e0791..6a0c795 100644 --- a/index.html +++ b/index.html @@ -1,100 +1,24 @@ + - Linked Data For the Web Developer - Movie Soundtrack Explorer - - - + + - -
+ +

Nose follower with Linked data

+
- -
-
+ + +
+

Nose follower console

+

+ + + \ No newline at end of file diff --git a/js/nose.js b/js/nose.js new file mode 100644 index 0000000..a6b4fc3 --- /dev/null +++ b/js/nose.js @@ -0,0 +1,90 @@ +/* + Script to implement the "Follow your nose" behaviour +*/ + +$(function() { + function log( message ) { + var ourMessage = $('
').html(message); + $('#log').prepend(ourMessage); + } + + function getRelease(url) { + $.ajax({ + url: url, + dataType: 'jsonp', + success: function(data) { + if (data.result.url) { + var id = data.result.url; + log(id); + + } + } + }); + } + + function getSoundtrack(url) { + $.ajax({ + url: url, + dataType: 'jsonp', + success: function(data) { + if (data.result.webpage) { + var text = data.result.webpage[0].text; + var soundtrackUrl = data.result.webpage[0].url; + log("soundtrack found @"+ text +": " + soundtrackUrl); + alert("getSoundtrack finished"); + //getRelease('http://www.freebase.com/experimental/topic/standard' + id); + } + } + }); + } + + function getSoundtrackUrl(url) { + $.ajax({ + url: url, + dataType: 'jsonp', + success: function(data) { + if (data.result.properties['/film/film/soundtrack'].values[0]) { + var id = data.result.properties['/film/film/soundtrack'].values[0].id; + log("performing getSoundTrack('http://www.freebase.com/experimental/topic/standard" + id + "')") + getSoundtrack('http://www.freebase.com/experimental/topic/standard' + id); + } + } + }); + } + $('#movie').autocomplete({ + //Thanks to the JQuery UI, let's implement autocompletion + source: function(request, response) { + $.ajax({ + //base URL for the Freebase API + url: 'http://freebase.com/api/service/search?', + //We want JSON data returned + dataType: 'jsonp', + //We force a request stricly restricted to films + data: { query: request.term, type: '/film/film', type_strict: 'all', limit: 3 }, + success: function(data) { + response($.map(data.result, function(item) { + return { + label: item.name + ' http://freebase.com' + item.id, + value: 'http://www.freebase.com/experimental/topic/standard' + item.id + } + })); + } + }); + }, + minLength: 2, + select: function(event, ui) { + //When a option of the list is selected + if (ui.item) { + var url = ui.item.value; + var name = ui.item.label; + log("You selected" + name); + log("Will now try to fetch data about" + url); + getSoundtrackUrl(url); + } + }, + }); + + //functions are defined. DOM is loaded. Let's go. + log("hello, it seems I'm ready to use. Welcome folks!"); + +}); \ No newline at end of file