]> git.quilime.com - visual-archive.git/commitdiff
Stuff.
authorGabriel Dunne <gdunne@quilime.com>
Sat, 23 Mar 2013 00:37:34 +0000 (17:37 -0700)
committerGabriel Dunne <gdunne@quilime.com>
Sat, 23 Mar 2013 00:37:34 +0000 (17:37 -0700)
README [new file with mode: 0644]
README.md [new file with mode: 0644]
convert_gifs_to_static.py
package.json
public/script.js
public/style.css
server_gifs.js

diff --git a/README b/README
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/README.md b/README.md
new file mode 100644 (file)
index 0000000..e69de29
index 7172b9647e052f53340b154e93d8a7c5f0db24e9..af52297b5a93a113ebce08cd83583add701f8fe1 100644 (file)
@@ -12,7 +12,6 @@
 #     os.system('cd gifs/prelinger/; curl -O ' + thumb)
 
 # json_data.close()
-
 # convert gifs/prelinger/0540_1935_Pontiac_Advertising_R2_13_38_44_00_3mb.gif[3] -coalesce out.gif
 # convert gifs/prelinger/0540_Spain_in_Revolt_R3_13_00_52_20_3mb.gif -format "%[scenes]" info: | tail -n 1
 
@@ -49,7 +48,6 @@ def main():
         #     print 'Oh dear.'
 
 
-
 class GIFError(Exception): pass
 def get_gif_num_frames(filename):
     frames = 0
@@ -82,3 +80,4 @@ def get_gif_num_frames(filename):
 
 if __name__ == "__main__":
     main()
+
index 2e0302921ebe206beb04e9ec25b35aa37a96d3ba..9af02a24ada4ac8f4c70b0358005e91a1e818cb4 100644 (file)
@@ -3,6 +3,8 @@
   "description": "archive-browser",
   "version": "0.0.1",
   "dependencies": {
-    "express": "3.x"
+    "express" : "3.x",
+    "request" : "x.x",
+    "jsdom"   : "x.x"
   }
 }
index dd58657d8e9e3917240c6dbf350e3a30fdae1905..e177204d4f5154f08a1d6125670b961df8c523f1 100644 (file)
@@ -1,20 +1,72 @@
+
 $(document).ready(function() {
+
+  $(document.body).append('<div id="scrim" />');
+  $(document.body).append('<div id="subcontent"><div class="container"></div></div>');
+  $('#scrim').click(function() {
+    $('#subcontent').fadeOut(100, function() {
+      scrim(0);
+    });
+  });
+
   $.each( $('.thumbs li'), function( key, elem ) {
 
     var id = $(elem).attr('id')
     var thumb_static = $(elem).find('img').attr('src');
     var thumb_name = thumb_static.split("/");
     thumb_name = thumb_name[thumb_name.length-1];
-    var img = $(elem).find('img');
 
-    $(elem).find('a').hover(function() {
+    var link = $(elem).find('a');
+    var img = $(link).find('img');
+    var thumbs_url = $(elem).attr('data-thumbs-url');
+
+    link.click(function() {
+      scrim(1, function() {
+        $('#subcontent .container').empty();
+        $('#subcontent').fadeIn(100);
+
+        //console.log(thumbs_url);
+
+        $.getJSON('/proxy/?url=' + thumbs_url, function(data) {
+
+          console.log(data);
+          // var items = [];
+
+          // $.each(data, function(key, val) {
+          //   items.push('<li id="' + key + '">' + val + '</li>');
+          // });
+
+          // $('<ul/>', {
+          //   'class': 'my-new-list',
+          //   html: items.join('')
+          // }).appendTo('body');
+        });
+
+        // $.load("/proxy/?url=" + thumbs_url + ' div.box div ', function(response, status, xhr) {
+        //   // alert('Load was performed.');
+        //   console.log(response);
+        // });
+
+      });
+      return false;
+    });
+    link.hover(function() {
       img.attr('src', 'prelinger_anim/' + thumb_name);
     });
-    $(elem).find('a').mouseout(function() {
+    link.mouseout(function() {
       img.attr('src', 'prelinger_static/' + thumb_name);
     });
+
   });
 });
 
+var scrim = function(visible, callback) {
+  var s = $('#scrim');
+  if (visible == 1)
+    s.fadeIn(150, callback);
+  else
+    s.fadeOut(150, callback);
+}
+
 
 //onmouseout="this.src=\'prelinger_static/'+t+'\'" onmouseover="this.src=\'prelinger/'+t+'\'"
index bd59bd4314c09f689b9dd6f817b895c8d783012f..f77e85a0c60e47de13f89c4d20e12fa77da48c90 100644 (file)
@@ -20,3 +20,28 @@ ul.thumbs li img {
     width:160px;
     height:110px;
 }
+
+#scrim {
+    background:rgba(0,0,0,0.5);
+    width:100%;
+    height:100%;
+    position:absolute;
+    top:0;
+    left:0;
+    z-index: 100;
+    display: none;
+}
+
+#subcontent {
+    position:absolute;
+    z-index:200;
+    display:none;
+    left: 50%;
+}
+#subcontent .container {
+    position: relative;
+    left: -50%;
+    background:#f0f;
+    width:500px;
+    height:500px;
+}
index 482fbcf9b75f849cd6718caedb566a8ed1af2409..c0e4895e2b663b3f9aa1f57cd56de74619cf67e7 100644 (file)
@@ -1,33 +1,38 @@
 var express = require("express"),
+    request = require('request'),
+    jsdom   = require("jsdom"),
     app     = express(),
+    fs      = require("fs"),
     port    = 3000;
 
+var jquery = fs.readFileSync("./public/jquery-1.9.1.min.js").toString();
+
 var prelinger = require('./prelinger.json');
 
-app.get("/", function(req, res) {
 
+app.get("/", function(req, res) {
   var out = [];
-
   out.push('<ul class="thumbs">');
   // prelinger.clips.length
-  var count = 50;
+  var count = 10;
   for( var i = 0; i < prelinger.clips.length; i++) {
 
-    // count--;
-    // if (count == 0)
-    //   break;
+    count--;
+    if (count == 0)
+      break;
 
     var clip = prelinger.clips[i];
     var t = clip.thumbnail_filename;
-    var ts = clip.thumbnails_url;
+    var turl = clip.thumbnails_url;
     var url = clip.url;
     out.push([
-      '<li id="'+ clip.id +'">',
-      '<a href="' + ts + '">',
+      '<li id="'+ clip.id +'" data-thumbs-url="' + turl + '">',
+      '<a href="#">',
       '<img src="prelinger_static/' + t + '">',
       '</a>',
       '</li>'].join("")
       );
+
   }
   out.push('</ul>');
   out.push('<link rel="stylesheet" type="text/css" href="style.css">');
@@ -38,11 +43,65 @@ app.get("/", function(req, res) {
   res.setHeader('Content-Type', 'text/html');
   res.setHeader('Content-Length', body.length);
   res.end(body);
-
 });
 
 
 
+// url proxy
+app.get("/proxy/", function(req, res) {
+  jsdom.env({
+    html : req.query["url"],
+    src : [jquery],
+    done: function (errors, window) {
+      var $ = window.$;
+      var thumbs = [];
+      var as =$("div.box div a");
+      for (var i = 0; i < as.length; i++) {
+        thumbs.push({
+          "url" : "http://archive.org" + $(as[i]).attr('href'),
+          "img" : $(as[i]).find('img').attr('src')
+        });
+      }
+      res.end(JSON.stringify({
+        "url" : req.query["url"],
+        "links" : thumbs
+      }));
+    }
+    // function (errors, window) {
+
+    //   //console.log();
+
+    //   //var $ = window.$;
+
+    //   window.$.each("div.box div a", function(key, val) {
+    //     console.log(val);
+    //   })
+
+    //   var thumbs = window.$("div.box div a img").attr('src');
+
+    //   // console.log(thumbs);
+
+    //   res.end(JSON.stringify({
+    //     "test" : "test",
+    //     "thumbs" : ""
+    //   }));
+    //   //console.log("there have been", window.$("a").length, "nodejs releases!");
+    // }
+  });
+
+  // request(req.query["url"], function (error, response, body) {
+  // if (!error && response.statusCode == 200) {
+  //   jsdom
+  //   res.end(body);
+  // }
+  // })
+})
+
+
+
+
+
+
 app.configure(function(){
   app.use(express.methodOverride());
   app.use(express.bodyParser());
@@ -56,39 +115,3 @@ app.configure(function(){
 });
 app.listen(port);
 console.log('Listening on port ' + port);
-
-
-
-/*var express = require('express');
-var app = express();
-
-app.use(express.static(__dirname + '/css'));
-
-//app.use("/css", express.static(__dirname + '/css'));
-
-var prelinger = require('./prelinger.json');
-
-app.get('/gifs', function(req, res){
-
-  var out = [];
-  out.push('<ul>');
-  // prelinger.clips.length
-  for( var i = 0; i < 2; i++) {
-    var c = prelinger.clips[i];
-    //out.push('<li><img src="' + c.thumbnail + '" /></li>');
-    var t = c.thumbnail.split('/');
-    t = t[t.length-1].split('?')[0];
-    out.push('<li>' + t + '</li>');
-  }
-  out.push('</ul>');
-  var body = out.join("");
-
-  res.setHeader('Content-Type', 'text/html');
-  res.setHeader('Content-Length', body.length);
-  res.end(body);
-});
-
-app.listen(3000);
-console.log('Listening on port 3000');
-
-*/