[papert commit] r126 - trunk

2 views
Skip to first unread message

codesite...@google.com

unread,
Feb 14, 2009, 5:15:09 PM2/14/09
to paper...@googlegroups.com
Author: thomas.figg
Date: Sat Feb 14 14:01:10 2009
New Revision: 126

Modified:
trunk/index.html.tmpl
trunk/index.py
trunk/index.yaml

Log:
adding browsing

Modified: trunk/index.html.tmpl
==============================================================================
--- trunk/index.html.tmpl (original)
+++ trunk/index.html.tmpl Sat Feb 14 14:01:10 2009
@@ -86,11 +86,11 @@

<div id="main">
<form id="input" action="/" method="post" onSubmit="this.img.value =
canvas.toDataURL().replace('data:image/png;base64,','')">
-<div id="top"><div class="inner"><h1>papert &#8213; logo in your
browser</h1>
+<div id="top"><div class="inner"><h1>papert&#8213;logo in your browser</h1>
<h2>
examples:
-<a href="/_REo_2F2">koch snowflake</a> |
-<a href="/dZ1f62XY">hilbert curve</a> |
+<a href="/_REo_2F2">koch snowflake</a>,
+<a href="/dZ1f62XY">hilbert curve</a>,
<a href="/8kpcBaQu">spiral</a>
</h2>
{% if hash %}
@@ -140,11 +140,12 @@
</form>

<div id="footer">
-<span style="float: left; margin-left: 20px; margin-right: auto;">
+<span style="float: left; margin-left: 20px; margin-right: auto; color:
white;">
Recent Programs
</span>
-<span style="float: right;margin-left: auto; margin-right: 20px;">
-<a href="http://code.google.com/p/papert">papert on google code</a>
+<span style="float: right;margin-left: auto; margin-right: 20px; color:
white;">
+this is free software, and
+<a href="http://code.google.com/p/papert">papert is hosted on google
code</a>
</span>
&nbsp;
</div>
@@ -153,6 +154,9 @@
{% for item in recent %}
<li><a href="/{{item|escape}}"><img src="/{{item|escape}}.png" alt=""
/></a></li>
{% endfor %}
+{% if last_date %}
+<li><a href="?older={{last_date|escape}}">older</li>
+{% endif %}
</ul>
</div>
<div id="notes">

Modified: trunk/index.py
==============================================================================
--- trunk/index.py (original)
+++ trunk/index.py Sat Feb 14 14:01:10 2009
@@ -29,6 +29,8 @@
self.redirect('/')
return

+ browse_date = self.request.get("older")
+
program = None

if hash:
@@ -58,13 +60,30 @@
values['code'] = program.code
values['hash'] = hash

- recent = memcache.get("recent")
- if recent is None:
- recent = [program.hash for program in
- LogoProgram.all().order('-date').fetch(5)]
- memcache.set("recent", recent)
-
- values['recent'] = recent
+
+ if browse_date:
+ recent = LogoProgram.all().filter('date =',
browse_date).order('-date').fetch(5)
+ if recent:
+ last_date = recent[-1].date
+ else:
+ last_date = None
+ recent = [program.hash for program in recent]
+ else:
+ recent = memcache.get("recent")
+ last_date = memcache.get("last_date")
+ if recent is None or last_date is None:
+ recent = LogoProgram.all().order('-date').fetch(5)
+ if recent:
+ last_date = recent[-1].date
+ else:
+ last_date = None
+ recent = [program.hash for program in recent]
+ memcache.set("recent", recent)
+ memcache.set("last_date", last_date)
+ if recent:
+ values['recent'] = recent
+ if last_date:
+ values['last_date'] = last_date

page =
os.path.join(os.path.dirname(__file__), 'index.html.tmpl')
self.response.out.write(template.render(page, values))

Modified: trunk/index.yaml
==============================================================================
--- trunk/index.yaml (original)
+++ trunk/index.yaml Sat Feb 14 14:01:10 2009
@@ -10,7 +10,7 @@
# automatically uploaded to the admin console when you next deploy
# your application using appcfg.py.

-# Used once in query history.
+# Used 5 times in query history.
- kind: LogoProgram
properties:
- name: date

Reply all
Reply to author
Forward
0 new messages