[16x16 commit] r17 - in trunk/app: . favicon files templates

1 view
Skip to first unread message

codesite...@google.com

unread,
Jun 5, 2008, 12:49:22 PM6/5/08
to 16x16-...@googlegroups.com
Author: alexpolvi
Date: Thu Jun 5 09:49:13 2008
New Revision: 17

Added:
trunk/app/files/favicon.ico (contents, props changed)
Modified:
trunk/app/app.yaml
trunk/app/favicon/views.py
trunk/app/index.yaml
trunk/app/templates/gears.html
trunk/app/templates/index.html

Log:
thanks for the favicon, scott

Modified: trunk/app/app.yaml
==============================================================================
--- trunk/app/app.yaml (original)
+++ trunk/app/app.yaml Thu Jun 5 09:49:13 2008
@@ -27,6 +27,11 @@
login: admin
script: main.py

+- url: /favicon.ico
+ static_files: files/favicon.ico
+ upload: files/favicon.ico
+
+
- url: .*
script: main.py


Modified: trunk/app/favicon/views.py
==============================================================================
--- trunk/app/favicon/views.py (original)
+++ trunk/app/favicon/views.py Thu Jun 5 09:49:13 2008
@@ -14,8 +14,10 @@
from favicon.helpers import *

def image(request, id):
+ mimetype = "image/png"
favicon = Favicon.get_by_key_name(id)
- return http.HttpResponse(favicon.favicon_bytes, mimetype=favicon.mimetype)
+ if favicon.mimetype: mimetype = favicon.mimetype
+ return http.HttpResponse(favicon.favicon_bytes, mimetype=mimetype)

def receiver(request):
params = {}
@@ -112,7 +114,7 @@
params['accesses_cnt'] = get_total_accesses()
params['favicon_today_cnt'] = get_today_favicons()
params['accesses_today_cnt'] = get_today_accesses()
- return shortcuts.render_to_response('index.html', params)
+ return shortcuts.render_to_response('gears.html', params)

def update(request):
inc_today_updates()

Added: trunk/app/files/favicon.ico
==============================================================================
Binary file. No diff available.

Modified: trunk/app/index.yaml
==============================================================================
--- trunk/app/index.yaml (original)
+++ trunk/app/index.yaml Thu Jun 5 09:49:13 2008
@@ -35,7 +35,7 @@
- name: accesses
direction: desc

-# Used 1562 times in query history.
+# Used 3 times in query history.
- kind: Favicon
properties:
- name: active

Modified: trunk/app/templates/gears.html
==============================================================================
--- trunk/app/templates/gears.html (original)
+++ trunk/app/templates/gears.html Thu Jun 5 09:49:13 2008
@@ -8,7 +8,7 @@

var images = [];

-var url = "/api/2008/01/01/01/01/01/0/";
+var api_url = "/api/2008/01/01/01/01/01/0/";

// for gears
// i am horrible at js, please bare with me.
@@ -24,6 +24,7 @@
function gearsLoad(images) {
for(var i=0; i<images.length;i++){
url = 'http://favicoop.com/image/' + images[i];
+ //url = 'http://localhost:8080/image/' + images[i];
if(!resourceStore.isCaptured(url)){
resourceStore.capture(url, gearsCallBack);
} else {
@@ -48,14 +49,14 @@
}

function getImages() {
- var the_object;
+ var the_object = {};
var http_request = new XMLHttpRequest();
- http_request.open( "GET", url, true );
+ http_request.open( "GET", api_url, true );
http_request.onreadystatechange = function () {
if ( http_request.readyState == 4 ) {
if ( http_request.status == 200 ) {
the_object = eval( "(" + http_request.responseText + ")" );
- url = the_object.next_url;
+ api_url = the_object.next_url;
if (typeof google != "undefined") {
gearsLoad(the_object.favicons);
} else {
@@ -71,12 +72,12 @@
}
http_request = null;
}
- }
+ };
http_request.send(null);
}

-getImages(url);
-window.setInterval(function(){ getImages(url); }, 1000 * 30);
+getImages();
+window.setInterval(function(){ getImages(api_url); }, 1000 * 30);

var i = 0;
var j = 0;
@@ -93,18 +94,14 @@
newImage.src = 'http://' + domains[j++ % domains.length] +'/image/'
+ images[i];
newImage.width = '16'
newImage.height = '16'
- var retry = window.setTimeout(function(){
- loadImage(i);
- }, 5000)
- newImage.onload = onLoadClosure(newImage, retry);
+ newImage.onload = onLoadClosure(newImage);
}


-function onLoadClosure(newImage, retry) {
+function onLoadClosure(newImage) {
return function(){
i++;
images_loaded++;
- window.clearTimeout(retry);
document.getElementById('accesses_block').appendChild(this);
document.getElementById('count').innerHTML = images_loaded;
document.getElementById('gears_count').innerHTML = gears_images_loaded;
@@ -116,7 +113,7 @@

<div id="favicon_wrapper">
<div id="stats">
- favicoop, a favicon collection | {{ favicon_cnt }} total | {{
favicon_today_cnt }} new today | {{ accesses_cnt }} accesses | {{
accesses_today_cnt }} accessed today | <a id="count">0</a> displayed |
<a id="gears_count">0</a> <a
href="http://gears.google.com/?action=install&message=favicoop uses
google gears for ultra fast image loading. Give it a go if you want to
refresh favicoop a lot!&return=http://favicoop.com/">from gears</a>
+ favicoop, a favicon collection | {{ favicon_cnt }} total | {{
favicon_today_cnt }} new today | {{ accesses_cnt }} accesses | {{
accesses_today_cnt }} accessed today | <a id="count">0</a> displayed |
<a id="gears_count">0</a> <a
href="http://gears.google.com/?action=install&message=favicoop uses
google gears for ultra fast image loading. Give it a go if you want to
refresh favicoop a lot!&return=http://favicoop.com/">from gears</a>
</div>
<div id="accesses_block">
</div>

Modified: trunk/app/templates/index.html
==============================================================================
--- trunk/app/templates/index.html (original)
+++ trunk/app/templates/index.html Thu Jun 5 09:49:13 2008
@@ -11,6 +11,7 @@
var url = "/api/2008/01/01/01/01/01/0/";

function getImages() {
+ document.getElementById('status').innerHTML = "fetching some more...";
var the_object;
var http_request = new XMLHttpRequest();
http_request.open( "GET", url, true );
@@ -20,6 +21,11 @@
the_object = eval( "(" + http_request.responseText + ")" );
url = the_object.next_url;
images = images.concat(the_object.favicons);
+ if (images.length > 0) {
+ document.getElementById('status').innerHTML = "loading favicons!";
+ } else {
+ document.getElementById('status').innerHTML = "no new ones...";
+ }
loadImage();
loadImage(++i);
loadImage(++i);
@@ -73,7 +79,7 @@

<div id="favicon_wrapper">
<div id="stats">
- favicoop, a favicon collection | {{ favicon_cnt }} total | {{
favicon_today_cnt }} new today | {{ accesses_cnt }} accesses | {{
accesses_today_cnt }} accessed today | <a id="count">0</a> displayed
+ favicoop, a favicon collection | {{ favicon_cnt }} total | {{
favicon_today_cnt }} new today | {{ accesses_cnt }} accesses | {{
accesses_today_cnt }} accessed today | <a id="count">0</a> displayed |
<a id"status"></a>
</div>
<div id="accesses_block">
</div>

Reply all
Reply to author
Forward
0 new messages