[gnomeweb-wml] [www.gnome.org] add Friends of GNOME drive page
- From: Lucas Almeida Rocha <lucasr src gnome org>
- To: svn-commits-list gnome org
- Subject: [gnomeweb-wml] [www.gnome.org] add Friends of GNOME drive page
- Date: Thu, 11 Jun 2009 06:10:47 -0400 (EDT)
commit 5e122fd46ce393a12dce55bd0cb027d07cf28e02
Author: Lucas Rocha <lucasr litl com>
Date: Thu Jun 11 11:08:49 2009 +0100
[www.gnome.org] add Friends of GNOME drive page
---
configure.in | 2 +
www.gnome.org/friends/Makefile.am | 2 +-
www.gnome.org/friends/drive/Makefile.am | 10 ++
www.gnome.org/friends/drive/admin/Makefile.am | 24 ++++
www.gnome.org/friends/drive/admin/admin.wml | 149 +++++++++++++++++++++++++
www.gnome.org/friends/drive/admin/htaccess | 4 +
www.gnome.org/friends/drive/admin/htpasswd | 1 +
www.gnome.org/friends/drive/admin/index.wml | 21 ++++
www.gnome.org/friends/drive/index.wml | 33 ++++++
9 files changed, 245 insertions(+), 1 deletions(-)
diff --git a/configure.in b/configure.in
index b3f8bb9..aaa56e8 100644
--- a/configure.in
+++ b/configure.in
@@ -22,6 +22,8 @@ www.gnome.org/friends/banners/Makefile
www.gnome.org/friends/css/Makefile
www.gnome.org/friends/images/Makefile
www.gnome.org/friends/js/Makefile
+www.gnome.org/friends/drive/Makefile
+www.gnome.org/friends/drive/admin/Makefile
www.gnome.org/fonts/Makefile
www.gnome.org/i18n/Makefile
www.gnome.org/img/Makefile
diff --git a/www.gnome.org/friends/Makefile.am b/www.gnome.org/friends/Makefile.am
index 70ffc05..e53fab2 100644
--- a/www.gnome.org/friends/Makefile.am
+++ b/www.gnome.org/friends/Makefile.am
@@ -1,4 +1,4 @@
-SUBDIRS = banners css images js
+SUBDIRS = banners css drive images js
urlpath = /friends
diff --git a/www.gnome.org/friends/drive/Makefile.am b/www.gnome.org/friends/drive/Makefile.am
new file mode 100644
index 0000000..38dd1c5
--- /dev/null
+++ b/www.gnome.org/friends/drive/Makefile.am
@@ -0,0 +1,10 @@
+SUBDIRS = admin
+
+urlpath = /friends/ruler
+
+include $(top_srcdir)/rules.common
+
+page_DATA = \
+ index.html
+
+EXTRA_DIST=$(page_DATA)
diff --git a/www.gnome.org/friends/drive/admin/Makefile.am b/www.gnome.org/friends/drive/admin/Makefile.am
new file mode 100644
index 0000000..60970ef
--- /dev/null
+++ b/www.gnome.org/friends/drive/admin/Makefile.am
@@ -0,0 +1,24 @@
+SUBDIRS =
+
+urlpath = /friends/drive/admin
+
+page_SCRIPTS = \
+ .htpasswd \
+ .htaccess
+
+include $(top_srcdir)/rules.common
+
+DRIVE_PATH = $(prefix)/$(SITE)/friends/drive
+DRIVE_WEBROOT = http://$(SITE)/friends/drive
+
+.htpasswd: htpasswd
+ cp $< $@
+
+%.cgi: %.wml
+ @sed -e "s,@DRIVE_WEBROOT@,$(DRIVE_WEBROOT),g;s,@DRIVE_PATH@,$(DRIVE_PATH),g" $< > $@
+
+page_DATA = \
+ admin.cgi \
+ index.html
+
+EXTRA_DIST=$(page_DATA)
diff --git a/www.gnome.org/friends/drive/admin/admin.wml b/www.gnome.org/friends/drive/admin/admin.wml
new file mode 100644
index 0000000..6ef9b25
--- /dev/null
+++ b/www.gnome.org/friends/drive/admin/admin.wml
@@ -0,0 +1,149 @@
+#!/usr/bin/env python
+
+from math import pi
+import cairo
+import cgi
+import os
+import re
+import shutil
+import cgitb
+cgitb.enable()
+
+path = '@DRIVE_PATH@'
+webroot = '@DRIVE_WEBROOT@'
+
+class Graph:
+ def __init__ (self, amount):
+ self.amount = amount
+ self.height = 20
+ self.width = 400
+ self.end = int(2 * self.width * min(self.amount / 50000, 1.0)) / 2.0
+
+ self.border1 = (0.703125, 0.703125, 0.703125)
+ self.border2 = (0.43359375, 0.43359375, 0.43359375)
+ self.inactive_bg1 = (0.94140625, 0.94140625, 0.94140625)
+ self.inactive_bg2 = (0.60546875, 0.60546875, 0.60546875)
+ self.active_bg1 = (0.5390625, 0.8828125, 0.203125)
+ self.active_bg2 = (0.3046875, 0.6015625, 0.0234375)
+
+ self.border_grad = cairo.LinearGradient (0, 0, 0, self.height)
+ self.border_grad.add_color_stop_rgb (0, *self.border1)
+ self.border_grad.add_color_stop_rgb (1, *self.border2)
+
+ self.surface = cairo.ImageSurface (cairo.FORMAT_ARGB32, self.width, self.height)
+ self.context = cairo.Context (self.surface)
+
+ def fill_active (self):
+ grad = cairo.LinearGradient (0, 0, 0, self.height)
+ grad.add_color_stop_rgb (0.3, *self.active_bg1)
+ grad.add_color_stop_rgb (1.0, *self.active_bg2)
+ self.context.set_source (grad)
+ self.context.fill_preserve ()
+
+ grad = cairo.LinearGradient (0, 0, 0, self.height)
+ grad.add_color_stop_rgb (0, 0.3515625, 0.7109375, 0)
+ grad.add_color_stop_rgb (1, 0.24609375, 0.48046875, 0.0078125)
+ self.context.set_source (grad)
+ self.context.stroke ()
+
+ def draw (self):
+ # Fill with white background
+ self.context.new_path ()
+ self.context.move_to (0, 0)
+ self.context.line_to (self.width, 0)
+ self.context.line_to (self.width, self.height)
+ self.context.line_to (0, self.height)
+ self.context.set_source_rgb (1.0, 1.0, 1.0)
+ self.context.fill ()
+
+ # Construct the main ruler frame
+ self.context.new_path ()
+ self.context.set_line_width (1)
+ self.context.move_to (6.5, 2.5)
+ self.context.arc_negative (6.5, 6.5, 4, -pi/2, -pi)
+ self.context.line_to (2.5, self.height - 6.5)
+ self.context.arc_negative (6.5, self.height - 6.5, 4, -pi, -3*pi/2)
+ self.context.line_to (self.width - 6.5, self.height - 2.5)
+ self.context.arc_negative (self.width - 6.5, self.height - 6.5, 4, pi/2, 0)
+ self.context.line_to (self.width - 2.5, 6.5)
+ self.context.arc_negative (self.width - 6.5, 6.5, 4, 0, -pi/2)
+ self.context.line_to (6.5, 2.5)
+
+ if self.end >= self.width - 6.5:
+ # It's as full as we can draw it, so just fill with active color
+ self.fill_active ()
+ else:
+ # Otherwise fill with inactive...
+ grad = cairo.LinearGradient (0, 0, 0, self.height)
+ grad.add_color_stop_rgb (0.3, *self.inactive_bg1)
+ grad.add_color_stop_rgb (1.0, *self.inactive_bg2)
+ self.context.set_source (grad)
+ self.context.fill_preserve ()
+
+ self.context.set_source (self.border_grad)
+ self.context.stroke ()
+
+ # Then construct the active frame, but only if it's full enough
+ # for us to be able to draw it
+ if self.end > 6.5:
+ self.context.new_path ()
+ self.context.set_line_width (1)
+
+ self.context.move_to (self.end, 2.5)
+ self.context.line_to (6.5, 2.5)
+ self.context.arc_negative (6.5, 6.5, 4, -pi/2, -pi)
+ self.context.line_to (2.5, self.height - 6.5)
+ self.context.arc_negative (6.5, self.height - 6.5, 4, -pi, -3*pi/2)
+ self.context.line_to (self.end, self.height - 2.5)
+
+ self.fill_active ()
+
+ # Then make some tick marks
+ for i in range (1, 10):
+ self.context.new_path ()
+ self.context.move_to (i * (self.width / 10) - .5, 4.5)
+ self.context.line_to (i * (self.width / 10) - .5, self.height - 4.5)
+ self.context.set_source_rgba (1, 1, 1, 0.25)
+ self.context.stroke ()
+ self.context.new_path ()
+ self.context.move_to (i * (self.width / 10) + .5, 4.5)
+ self.context.line_to (i * (self.width / 10) + .5, self.height - 4.5)
+ if i * (self.width / 10) > self.end:
+ self.context.set_source (self.border_grad)
+ else:
+ self.context.set_source_rgba (0.24609375, 0.48046875, 0.0078125, 0.333)
+ self.context.stroke ()
+
+ def save (self):
+ self.surface.write_to_png (os.path.join (path, 'drive.png.tmp'))
+
+ jsfile = open (os.path.join (path, 'drive.js.tmp'), 'w')
+ jsfile.write (
+ 'document.write(\'<div style="' +
+ ('background-color:white;color:#2e3436;width:%ipx;' % self.width) +
+ 'text-align:center;' +
+ '">' +
+ ('<img src="%sdrive.png" width="%i" height="%i">'
+ % (webroot, self.width, self.height)) +
+ ('<div style="font-size:1.2em;font-weight:bold;">$%i of $50000 raised</div>'
+ % self.amount) +
+ '<div>Become a <a href="http://www.gnome.org/friends/">Friend of Gnome</a> today.</div>'
+ '</div>\')\n')
+ jsfile.close ()
+
+ shutil.move (os.path.join (path, 'drive.png.tmp'),
+ os.path.join (path, 'drive.png'))
+ shutil.move (os.path.join (path, 'drive.js.tmp'),
+ os.path.join (path, 'drive.js'))
+
+query = cgi.parse ()
+amount = query['amount'][0]
+if amount.startswith ('$'):
+ amount = amount[1:]
+amount = re.sub (',', '', amount)
+amount = float (amount)
+graph = Graph (amount)
+graph.draw ()
+graph.save ()
+print 'Content-type: text/html\n'
+print '<html><body>Thanks!</body></html>'
diff --git a/www.gnome.org/friends/drive/admin/htaccess b/www.gnome.org/friends/drive/admin/htaccess
new file mode 100644
index 0000000..4994281
--- /dev/null
+++ b/www.gnome.org/friends/drive/admin/htaccess
@@ -0,0 +1,4 @@
+AuthName "Friends of GNOME - Ruler Admin"
+AuthType Basic
+AuthUserFile @pagedir@/.htpasswd
+Require valid-user
diff --git a/www.gnome.org/friends/drive/admin/htpasswd b/www.gnome.org/friends/drive/admin/htpasswd
new file mode 100644
index 0000000..a70fa4e
--- /dev/null
+++ b/www.gnome.org/friends/drive/admin/htpasswd
@@ -0,0 +1 @@
+fogdrive:V1yKlP8m9Csk.
diff --git a/www.gnome.org/friends/drive/admin/index.wml b/www.gnome.org/friends/drive/admin/index.wml
new file mode 100644
index 0000000..8809317
--- /dev/null
+++ b/www.gnome.org/friends/drive/admin/index.wml
@@ -0,0 +1,21 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd";>
+<html>
+
+<head>
+ <title>Friends of GNOME - Fundraising Drive</title>
+
+ <link media="all" type="text/css" rel="stylesheet" href="../../css/friends.css"/>
+</head>
+
+<body>
+ <h1>Friends of GNOME - Fundraising Drive</h1>
+
+ <form method="POST" action="admin.cgi">
+ <p>We've raised $<input type="text" name="amount" size="8"> of $50000.</p>
+ <p><input type="submit"></p>
+</form>
+
+</body>
+
+</html>
diff --git a/www.gnome.org/friends/drive/index.wml b/www.gnome.org/friends/drive/index.wml
new file mode 100644
index 0000000..91c03e2
--- /dev/null
+++ b/www.gnome.org/friends/drive/index.wml
@@ -0,0 +1,33 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd";>
+<html>
+
+<head>
+ <title>Friends of GNOME - Fundraising Drive</title>
+
+ <link media="all" type="text/css" rel="stylesheet" href="../css/friends.css"/>
+</head>
+
+<body>
+
+ <h1>Friends of GNOME - Fundraising Drive</h1>
+
+ <p>This page has details on how we could do a progress bar for fundraising
+ drives in Friends of Gnome. I've written a Python script that reads in some
+ data about contributions and generates a progress meter and some JavaScript.
+ You can then embed a progress widget into web sites with the following:</p>
+
+ <pre><script type="text/javascript" src="http://www.gnome.org/friends/drive/drive.js"></script></pre>
+
+ <p>Here's how my prototype looks when I do that:</p>
+
+ <script type="text/javascript" src="http://www.gnome.org/friends/drive/drive.js"></script>
+
+ <p>Note that this was fed with completely bogus data. To make this happen,
+ we'd need access to real data. We should also tweak the design and the
+ language.</p>
+</form>
+
+</body>
+
+</html>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]