Skip to content
Browse files

show images from the xml in spotify

  • Loading branch information...
1 parent 48105fe commit d4bc1f84650c812c00df2c2f776e35eebcf7037d Roald de Vries committed Apr 25, 2012
Showing with 218 additions and 6 deletions.
  1. +6 −1 .gitignore
  2. +11 −5 index.html
  3. +201 −0 js/index.js
View
7 .gitignore
@@ -1 +1,6 @@
-*.DS_Store
+*.DS_Store
+*.swp
+*.coffee
+/nave
+/Makefile
+/.vimproject
View
16 index.html
@@ -5,11 +5,11 @@
<title>Rijksmuseum App</title>
<link href="css/fotorama.css" rel="stylesheet">
<script type="text/javascript" src="js/jquery-1.7.2.min.js"></script>
- <script type="text/javascript" src="coffee-script.js" charset="utf-8"></script>
- <script type="text/javascript" src="underscore.js" charset="utf-8"></script>
- <script type="text/javascript" src="backbone.js" charset="utf-8"></script>
- <script type="text/javascript" src="jath/jath.js" charset="utf-8"></script>
- <script type="text/javascript" src="jade/jade.js" charset="utf-8"></script>
+ <script type="text/javascript" src="js/coffee-script.js"></script>
+ <script type="text/javascript" src="js/underscore.js"></script>
+ <script type="text/javascript" src="js/backbone.js"></script>
+ <script type="text/javascript" src="js/jath.js"></script>
+ <script type="text/javascript" src="js/jade.js"></script>
<script src="js/fotorama.js"></script>
<script>
function startMusicByYearRange(startYear, endYear) {
@@ -56,6 +56,12 @@
});
});
</script>
+ <script type="text/javascript" src="js/index.js"></script>
+ <script id="record" type="text/template">
+.record
+ a(href=model.get('url'))
+ img(src=model.get('url100'))
+ </script>
</head>
<body>
<div id="my-fotorama"></div>
View
201 js/index.js
@@ -0,0 +1,201 @@
+// Generated by CoffeeScript 1.3.1
+(function() {
+ var originalSync,
+ __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; },
+ __hasProp = {}.hasOwnProperty,
+ __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor; child.__super__ = parent.prototype; return child; };
+
+ Jath.resolver = function(prefix) {
+ switch (prefix) {
+ case 'xsi':
+ return 'http://www.w3.org/2001/XMLSchema-instance';
+ case 'rm':
+ return 'http://rijksmuseum.nl/collection';
+ case 'xsd':
+ return 'http://www.w3.org/2001/XMLSchema';
+ case 'oai_dc':
+ return 'http://www.openarchives.org/OAI/2.0/oai_dc/';
+ case 'dc':
+ return 'http://purl.org/dc/elements/1.1/';
+ case 'dcterms':
+ return 'http://purl.org/dc/terms/';
+ case 'europeana':
+ return 'http://www.europeana.eu/schemas/ese/';
+ case 'oai_dc':
+ return 'http://www.openarchives.org/OAI/2.0/oai_dc/';
+ case 'dc':
+ return 'http://purl.org/dc/elements/1.1/';
+ case 'dcterms':
+ return 'http://purl.org/dc/terms/';
+ case 'europeana':
+ return 'http://www.europeana.eu/schemas/ese/';
+ }
+ };
+
+ originalSync = Backbone.sync;
+
+ Backbone.sync = function(method, model, options) {
+ options = _.extend(options, {
+ dataType: 'xml',
+ contentType: 'application/xml',
+ processData: false
+ });
+ return originalSync.apply(Backbone, [method, model, options]);
+ };
+
+ window.Record = (function(_super) {
+
+ __extends(Record, _super);
+
+ Record.name = 'Record';
+
+ function Record() {
+ this.get = __bind(this.get, this);
+ return Record.__super__.constructor.apply(this, arguments);
+ }
+
+ Record.schema = [
+ '//record', {
+ description: 'metadata/oai_dc:dc/dc:description',
+ title: 'metadata/oai_dc:dc/dc:title',
+ url: 'metadata/oai_dc:dc/dc:format'
+ }
+ ];
+
+ Record.prototype.get = function(attribute) {
+ switch (attribute) {
+ case 'url100':
+ return "" + (this.get('url')) + "&100x100";
+ case 'url200':
+ return "" + (this.get('url')) + "&200x200";
+ default:
+ return Record.__super__.get.call(this, attribute);
+ }
+ };
+
+ return Record;
+
+ })(Backbone.Model);
+
+ window.Records = (function(_super) {
+
+ __extends(Records, _super);
+
+ Records.name = 'Records';
+
+ function Records() {
+ return Records.__super__.constructor.apply(this, arguments);
+ }
+
+ Records.prototype.model = Record;
+
+ Records.prototype.url = 'index.xml';
+
+ Records.prototype.parse = function(response) {
+ return Jath.parse(Record.schema, response);
+ };
+
+ return Records;
+
+ })(Backbone.Collection);
+
+ window.RecordView = (function(_super) {
+
+ __extends(RecordView, _super);
+
+ RecordView.name = 'RecordView';
+
+ function RecordView() {
+ this.render = __bind(this.render, this);
+ return RecordView.__super__.constructor.apply(this, arguments);
+ }
+
+ RecordView.prototype.render = function() {
+ return this.$el.html((jade.compile($('#record').html()))({
+ model: this.model
+ }));
+ };
+
+ return RecordView;
+
+ })(Backbone.View);
+
+ window.BodyView = (function(_super) {
+
+ __extends(BodyView, _super);
+
+ BodyView.name = 'BodyView';
+
+ function BodyView() {
+ this.render = __bind(this.render, this);
+
+ this.resetCollection = __bind(this.resetCollection, this);
+
+ this.initialize = __bind(this.initialize, this);
+ return BodyView.__super__.constructor.apply(this, arguments);
+ }
+
+ BodyView.prototype.el = 'body';
+
+ BodyView.prototype.initialize = function() {
+ return this.collection.on('reset', this.resetCollection);
+ };
+
+ BodyView.prototype.resetCollection = function() {
+ var model, view, _i, _len, _ref, _results;
+ this.subviews = (function() {
+ var _i, _len, _ref, _results;
+ _ref = this.collection.models;
+ _results = [];
+ for (_i = 0, _len = _ref.length; _i < _len; _i++) {
+ model = _ref[_i];
+ _results.push(new RecordView({
+ model: model
+ }));
+ }
+ return _results;
+ }).call(this);
+ this.render();
+ _ref = this.subviews;
+ _results = [];
+ for (_i = 0, _len = _ref.length; _i < _len; _i++) {
+ view = _ref[_i];
+ _results.push(view.render());
+ }
+ return _results;
+ };
+
+ BodyView.prototype.render = function() {
+ var view, _i, _len, _ref, _results;
+ this.$el.html('');
+ _ref = this.subviews;
+ _results = [];
+ for (_i = 0, _len = _ref.length; _i < _len; _i++) {
+ view = _ref[_i];
+ _results.push(this.$el.append(view.$el));
+ }
+ return _results;
+ };
+
+ return BodyView;
+
+ })(Backbone.View);
+
+ window.xmlDoc = (function(filename) {
+ var xhr;
+ xhr = new window.XMLHttpRequest;
+ xhr.open("GET", filename, false);
+ xhr.send(null);
+ return xhr.responseXML;
+ })('index.xml');
+
+ window.data = Jath.parse(Record.schema, xmlDoc);
+
+ $(function() {
+ window.bodyView = new BodyView({
+ collection: new Records
+ });
+ return bodyView.collection.reset(data);
+ });
+
+}).call(this);

0 comments on commit d4bc1f8

Please sign in to comment.
Something went wrong with that request. Please try again.