[gnomeweb-wml] [friends] Add script to update Friends of GNOME ruler



commit 042b06aebd1e1907a5716c04dea8717e1ebd1b3b
Author: Lucas Rocha <lucasr litl com>
Date:   Thu Feb 11 22:57:46 2010 +0000

    [friends] Add script to update Friends of GNOME ruler

 www.gnome.org/friends/ruler/update-ruler |  223 ++++++++++++++++++++++++++++++
 1 files changed, 223 insertions(+), 0 deletions(-)
---
diff --git a/www.gnome.org/friends/ruler/update-ruler b/www.gnome.org/friends/ruler/update-ruler
new file mode 100755
index 0000000..4804508
--- /dev/null
+++ b/www.gnome.org/friends/ruler/update-ruler
@@ -0,0 +1,223 @@
+#!/usr/bin/env python
+
+##############################################################
+# Script to update Friends of GNOME ruler.                   #
+#                                                            #
+# Simply update the values below and run this script. A new  #
+# ruler.js #will be generated. After careful testing, just   #
+# commit/push the new ruler.js file. Something like this:    #
+#                                                            #
+#     update-ruler > ruler.js                                #
+#                                                            #
+##############################################################
+
+def split_thousands(s):
+    if s.rfind('.') > 0:
+        rhs=s[s.rfind('.')+1:]
+        s=s[:s.rfind('.')-1]
+        if len(s) <= 3: return s + '.' + rhs
+        return split_thousands(s[:-3]) + ',' + s[-3:] + '.' + rhs
+    else:
+        if len(s) <= 3: return s
+        return split_thousands(s[:-3]) + ',' + s[-3:]
+
+TARGET_AMOUNT = 57000.00;
+
+# Colors should have a matching CSS style
+
+DONORS = [
+{ 'name': 'Canonical',
+  'color': 'orange',
+  'donation': 10000.00 },
+
+{ 'name': 'Google',
+  'color': 'blue',
+  'donation': 5000.00 },
+
+{ 'name': 'Nokia',
+  'color': 'yellow',
+  'donation': 5000.00 },
+
+{ 'name': 'Friends of GNOME',
+  'color': 'green',
+  'donation': 21165.00,
+  'show-still-needed': 1 }]
+
+TOTAL_DONATIONS = 0
+
+for donor in DONORS:
+    TOTAL_DONATIONS += donor['donation']
+
+STILL_NEED = TARGET_AMOUNT - TOTAL_DONATIONS
+
+##############################################################
+# Only change the code from now on if you want to change the #
+# generated CSS and HTML                                     #
+##############################################################
+
+CSS = ' \
+<style type="text/css"> \
+    #gnome-fog-ruler {\
+        background: #237100 url(http://www.gnome.org/friends/ruler/ruler-bg.jpg) center no-repeat;\
+        padding: 16px 0px 16px 0px;\
+        color: #fff;\
+        font-family: "Lucida Grande", "DejaVu Sans", "Bitstream Vera Sans", Verdana, sans-serif;\
+        font-size: 12px;\
+        z-index: 200;\
+        float: left;\
+        width: 100%;\
+        position: relative;\
+    }\
+    #gnome-fog-ruler * {\
+        margin: 0;\
+        padding: 0;\
+    }\
+    #gnome-fog-ruler .fog-center {\
+        width: 960px;\
+        margin: 0 auto;\
+        text-align: left;\
+    }\
+    #gnome-fog-ruler a {\
+        color: #fff;\
+    }\
+    #gnome-fog-ruler .fog-intro {\
+        width: 380px;\
+        float: left;\
+        margin-right: 12px;\
+    }\
+    #gnome-fog-ruler .fog-intro h4 {\
+        margin-bottom: 6px;\
+        color: #fff;\
+        font-size: 13px;\
+        text-shadow: 0 1px 2px #346704;\
+    }\
+    #gnome-fog-ruler .fog-ruler {\
+        background: #fff;\
+        overflow: hidden;\
+        -moz-border-radius: 4px;\
+        -webkit-border-radius: 4px;\
+        padding: 2px;\
+        -moz-box-shadow: 0 1px 2px #346704;\
+        -webkit-box-shadow: 0 1px 2px #346704;\
+    }\
+    #gnome-fog-ruler .fog-ruler .fog-bar {\
+        display: block;\
+        float: left;\
+        font-size: 5px;\
+        height: 14px;\
+        line-height: 12px;\
+    }\
+    #gnome-fog-ruler .green {\
+        background: #66bb14;\
+    }\
+    #gnome-fog-ruler .orange {\
+        background: #f57900;\
+    }\
+    #gnome-fog-ruler .blue {\
+        background: #729fcf;\
+    }\
+    #gnome-fog-ruler .yellow {\
+        background: #fce94f;\
+    }\
+    #gnome-fog-ruler .white {\
+        background: #fff;\
+    }\
+    #gnome-fog-ruler .green {\
+        background: #8ae234;\
+    }\
+    #gnome-fog-ruler .fog-description {\
+        margin-top: 8px;\
+        overflow: hidden;\
+        text-align: center;\
+    }\
+    #gnome-fog-ruler .fog-description .fog-item {\
+        margin-right: 12px;\
+        display: block;\
+        float: left;\
+        overflow: hidden;\
+        text-align: left;\
+    }\
+    #gnome-fog-ruler .fog-description .fog-item .fog-box {\
+        display: block;\
+        float: left;\
+        width: 12px;\
+        height: 12px;\
+        border: 1px solid #fff;\
+        margin: 0 6px 6px 0;\
+        -moz-border-radius: 3px;\
+        -webkit-border-radius: 3px;\
+        border-radius: 3px;\
+        -moz-box-shadow: 0 1px 2px #346704;\
+        -webkit-box-shadow: 0 1px 2px #346704;\
+    }\
+    #gnome-fog-ruler .fog-description .fog-item .fog-details {\
+        font-style: italic;\
+        display: block;\
+        margin-left: 20px;\
+    }\
+    #gnome-fog-ruler .fog-donate {\
+        float: right;\
+        margin-top: 11px;\
+    }\
+    #gnome-fog-ruler .fog-donate a {\
+        display: block;\
+        padding: 6px 8px;\
+        background: #fff;\
+        color: #333;\
+        font-weight: bold;\
+        text-decoration: none;\
+        font-size: 14px;\
+        -moz-box-shadow: 0 1px 2px #346704, inset 0 -3px 10px #ccc;\
+        -webkit-box-shadow: 0 1px 2px #346704, inset 0 -3px 10px #ccc;\
+        -moz-border-radius: 4px;\
+        -webkit-border-radius: 4px;\
+    }\
+    #gnome-fog-ruler .fog-donate a:hover {\
+        color: #204a87;\
+        text-decoration: underline;\
+    }\
+</style>'
+
+HTML = '\
+<div id="gnome-fog-ruler">\
+    <div class="fog-center">\
+        <div class="fog-intro">\
+            <h4>The GNOME Project needs your help!</h4>\
+            <p>GNOME Foundation wants to hire a sysadmin so that GNOME developers can focus on GNOME. Help us doing that!</p>\
+        </div>\
+        <div class="fog-data">\
+            <div class="fog-ruler">'
+
+for donor in DONORS:
+    percentage = (donor['donation'] / TARGET_AMOUNT) * 100
+    color = donor['color']
+    HTML += '<span style="width: %.2f%%;" class="fog-bar %s">&nbsp;</span>' % (percentage, color)
+
+HTML += '\
+            </div>\
+            <div class="fog-donate">\
+                <a href="http://www.gnome.org/friends/";>Donate now!</a>\
+            </div>\
+            <div class="fog-description">'
+
+for donor in DONORS:
+    donor_name = donor['name']
+    donation_str = "%.0f" % donor['donation']
+    donation = split_thousands(donation_str)
+    color = donor['color']
+
+    if 'show-still-needed' in donor:
+        still_needed_str = "%.0f" % STILL_NEED
+        still_needed = split_thousands(still_needed_str)
+        HTML += '<div class="fog-item"><span class="fog-box %s">&nbsp;</span><strong>%s</strong><span class="fog-details">$%s. $%s to go!</span></div>' % (color, donor_name, donation, still_needed)
+    else:
+        HTML += '<div class="fog-item"><span class="fog-box %s">&nbsp;</span><strong>%s</strong><span class="fog-details">$%s</span></div>' % (color, donor_name, donation)
+
+HTML += '\
+            </div>\
+        </div>\
+        <div style="clear: both;"></div>\
+    </div>\
+</div>'
+
+print 'document.write(\'%s\')' % (CSS + HTML)



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]