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

0 views
Skip to first unread message

codesite...@google.com

unread,
May 19, 2008, 2:08:52 AM5/19/08
to 16x16-...@googlegroups.com
Author: alexpolvi
Date: Sun May 18 23:08:05 2008
New Revision: 13

Modified:
trunk/app/favicon/helpers.py
trunk/app/favicon/views.py
trunk/app/index.yaml
trunk/app/templates/contrib.html

Log:
more helper moves, updates to contrib page

Modified: trunk/app/favicon/helpers.py
==============================================================================
--- trunk/app/favicon/helpers.py (original)
+++ trunk/app/favicon/helpers.py Sun May 18 23:08:05 2008
@@ -58,3 +58,17 @@
today = datetime.today()
total_updates_today =
DateCountStat.get_by_key_name("updates_%04d%02d%02d" % (today.year,
today.month, today.day))
return total_updates_today.count
+
+# favicon fetch methods
+def most_recently_accessed(num):
+ return Access.all().order('-created_at').fetch(num)
+
+def most_accessed(num):
+ return Favicon.all().filter('active = ', True).order('-accesses').fetch(num)
+
+def most_recently_added(num):
+ return Favicon.all().filter('active = ', True).order('-created_at').fetch(num)
+
+# hack to make key_name begin with a letter
+def md5_key(md5):
+ return 'a' + md5

Modified: trunk/app/favicon/views.py
==============================================================================
--- trunk/app/favicon/views.py (original)
+++ trunk/app/favicon/views.py Sun May 18 23:08:05 2008
@@ -1,4 +1,3 @@
-# Create your views here.
import logging
import sys
from google.appengine.ext import db
@@ -13,19 +12,10 @@
from favicon.models import Favicon, FaviconURI, Client, Access,
CountStat, DateCountStat
from favicon.helpers import *

-def md5_key(md5):
- return 'a' + md5
-
def image(request, id):
favicon = Favicon.get_by_key_name(id)
return http.HttpResponse(favicon.favicon_bytes, mimetype=favicon.mimetype)

-def toggle_active(request, id):
- favicon = Favicon.get_by_key_name(id)
- favicon.active = not favicon.active
- favicon.put()
- return http.HttpResponseRedirect("/toggler/")
-
def receiver(request):
params = {}
# logging.debug("file contents: " + str(request.FILES))
@@ -68,7 +58,7 @@
a = Access(favicon=f, favicon_uri=fu, client=c)
a.put()
except:
- logging.error("Unexpected error:" + str(sys.exc_info()))
+ logging.error("Unexpected error: " + str(sys.exc_info()))
logging.error(request.FILES)

return shortcuts.render_to_response('index.html', params)
@@ -77,6 +67,12 @@
params = {}
return shortcuts.render_to_response('contrib.html', params)

+def toggle_active(request, id):
+ favicon = Favicon.get_by_key_name(id)
+ favicon.active = not favicon.active
+ favicon.put()
+ return http.HttpResponseRedirect("/toggler/")
+
def toggler(request):
params = {}
favicons = Favicon.all().filter('active = ', True)
@@ -87,28 +83,18 @@
bad_keys = [ f.key().id_or_name() for f in favicons ]
params['favicons_disabled'] = bad_keys

-# logging.debug(params)
return shortcuts.render_to_response('toggler.html', params)

-def most_recently_accessed(num):
- return Access.all().order('-created_at').fetch(num)
-
-def most_accessed(num):
- return Favicon.all().filter('active = ', True).order('-accesses').fetch(num)
-
-def most_recently_added(num):
- return Favicon.all().filter('active = ', True).order('-created_at').fetch(num)

# TODO: implement charts for data
def get_sparkline(data):
+ # first stab, not working
max_val = float(max(data))
vals = [ str( (d / max_val)*100 ) for d in data ]
data_string = ",".join(data)
img_string
= "http://chart.apis.google.com/chart?chs=100x20&cht=ls&chco=0077CC&chm=B,E6F2FA,0,0,0&chls=1,0,0&chd=t:%s" % (data_string)
return img_string

-
-
def top_x(request):
params = {}
params['most_recently_created'] = [ f.key().id_or_name() for f in
most_recently_added(10) ]
@@ -121,7 +107,7 @@

def index(request):
favicons = Favicon.all().filter('active = ', True).fetch(1000)
- # \r hack because one of the keys has a \r in it, weird!
+ # \r hack because one of the keys has a \r in it -- probably should
figure out why
a_keys = [ "\'" + f.key().id_or_name().replace('\r', ' ') + "\',"
for f in favicons ]
params = {'favicons_recent':a_keys}
params['favicon_cnt'] = get_total_favicons()

Modified: trunk/app/index.yaml
==============================================================================
--- trunk/app/index.yaml (original)
+++ trunk/app/index.yaml Sun May 18 23:08:05 2008
@@ -22,20 +22,20 @@
# automatically uploaded to the admin console when you next deploy
# your application using appcfg.py.

-# Used once in query history.
+# Unused in query history -- copied from input.
- kind: Access
properties:
- name: created_at
direction: desc

-# Used once in query history.
+# Unused in query history -- copied from input.
- kind: Favicon
properties:
- name: active
- name: accesses
direction: desc

-# Used once in query history.
+# Unused in query history -- copied from input.
- kind: Favicon
properties:
- name: active

Modified: trunk/app/templates/contrib.html
==============================================================================
--- trunk/app/templates/contrib.html (original)
+++ trunk/app/templates/contrib.html Sun May 18 23:08:05 2008
@@ -1,14 +1,18 @@
{% extends "base.html" %}

-{% block title %}Favicons - Contribute{% endblock %}
+{% block title %}favicoop - contribute{% endblock %}

{% block content %}
<div id="wrapper">
<h3>About</h3>
The favicoop is a giant collection of favicons. The repository was
generated by people browsing the web with our Firefox add-on. As you
browse the web, the add-ons send back any favicons you receive. We have
high hopes for the possibilities of large amounts of icons. <a
href="/">View the collection</a>.
<h3>Contribute</h3>
-Contribute the Favicon Collective by installing our Firefox 3 add-on.
+Contribute the favicoop by installing our Firefox 3 add-on.

<h4><a href="/xpi/favicon-collective-1.1.xpi">Drag this URL to the
location bar to install the Firefox add-on</a></h4>
+
+If you're a hacker, you can also contribute to the back-end project --
<a href="http://code.google.com/p/16x16/">16x16</a>. 16x16 is the name
of the tool suite needed to collect favicons (favicoop is this
particular collection). This project consists of the AppEngine web app
and the Firefox 3 add-on.
+
+Learn how to set-up a development environment by <a
href="http://alex.polvi.net/2008/05/18/building-a-personal-favicon-collection-or-running-16x16-locally-or-an-appengine-tutorial/">reading
this article</a>.
</div>
{% endblock %}

Reply all
Reply to author
Forward
0 new messages