[gnomeweb-wml] privacy ruler: Generate data for display based on a single value
- From: Tobias Mueller <tobiasmue src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnomeweb-wml] privacy ruler: Generate data for display based on a single value
- Date: Thu, 10 Jan 2013 16:04:55 +0000 (UTC)
commit 6f0bffc90bd6a38f2df865a942fbd360f677bfcb
Author: Tobias Mueller (ideabox) <tobiasmue gnome org>
Date: Thu Jan 10 16:56:04 2013 +0100
privacy ruler: Generate data for display based on a single value
For now, percentage and remaining money were calculated by hand. Now the
goal is to have a single text file containing the information and
then generate the missing data out of that. The target money could also
be defined by file, but for now we don't.
Now it should be possible to update the text file every so often and
have the website reflect that. Another effect is that once that text
file is generated (semi) automatically, the update should be less pain
free and bind less people time.
My preliminary tests suggest that this change works. I don't know,
however, how the build system will take it. Let's hope it won't break.
www.gnome.org/friends/ruler/Makefile.am | 17 +++++++++++++++++
.../friends/ruler/ruler-privacy-amount.txt | 1 +
...{ruler-privacy.js => ruler-privacy.js.template} | 4 ++--
3 files changed, 20 insertions(+), 2 deletions(-)
---
diff --git a/www.gnome.org/friends/ruler/Makefile.am b/www.gnome.org/friends/ruler/Makefile.am
index 1808ed1..faf3392 100644
--- a/www.gnome.org/friends/ruler/Makefile.am
+++ b/www.gnome.org/friends/ruler/Makefile.am
@@ -12,4 +12,21 @@ page_DATA = \
ruler-privacy.js \
lock.png
+
+# You may adapt this value if the amount of money you want to raise differs
+FOG_GOAL = 20000
+# We expect ruler-privacy-amount.txt to contain the amount of money that has
+# so far been raised.
+ruler-privacy-percent.txt: ruler-privacy-amount.txt
+ awk '{t=$$0/$(FOG_GOAL); printf "%.2f", t*100}' < $< > $@
+ruler-privacy-remain.txt: ruler-privacy-amount.txt
+ awk '{t=$(FOG_GOAL)-$$0; printf "%d", t}' < $< > $@
+
+
+ruler-privacy.js: ruler-privacy.js.template ruler-privacy-amount.txt ruler-privacy-remain.txt ruler-privacy-percent.txt
+ sed -e "s/{{{FOG_AMOUNT}}}/$$(tr -d '\n' <ruler-privacy-amount.txt)/g" \
+ -e "s/{{{FOG_PERCENT}}}/$$(tr -d '\n' <ruler-privacy-percent.txt)/g" \
+ -e "s/{{{FOG_REMAIN}}}/$$(tr -d '\n' <ruler-privacy-remain.txt)/g" \
+ $< > $@
+
EXTRA_DIST=$(page_DATA)
diff --git a/www.gnome.org/friends/ruler/ruler-privacy-amount.txt b/www.gnome.org/friends/ruler/ruler-privacy-amount.txt
new file mode 100644
index 0000000..0356192
--- /dev/null
+++ b/www.gnome.org/friends/ruler/ruler-privacy-amount.txt
@@ -0,0 +1 @@
+5782
diff --git a/www.gnome.org/friends/ruler/ruler-privacy.js b/www.gnome.org/friends/ruler/ruler-privacy.js.template
similarity index 95%
rename from www.gnome.org/friends/ruler/ruler-privacy.js
rename to www.gnome.org/friends/ruler/ruler-privacy.js.template
index 185f27a..387eaf4 100644
--- a/www.gnome.org/friends/ruler/ruler-privacy.js
+++ b/www.gnome.org/friends/ruler/ruler-privacy.js.template
@@ -32,7 +32,7 @@ document.write( '<div id="gnome-fog-ruler">' +
'<p>Donate today to help make GNOME <a href="http://www.gnome.org/friends">safer than ever!</a></p>' +
'</div><div class="fog-data">' +
'<div class="fog-ruler">' +
- '<span style="width: 17.58%;" class="fog-bar orange"> </span>' +
+ '<span style="width: {{{FOG_PERCENT}}}%;" class="fog-bar orange"> </span>' +
'</div>' +
'<div class="fog-donate">' +
'<a href="http://www.gnome.org/friends/">Donate now!</a>' +
@@ -41,7 +41,7 @@ document.write( '<div id="gnome-fog-ruler">' +
'<div class="fog-item">' +
'<span class="fog-box orange"> </span>' +
'<strong>Friends of GNOME donations</strong>' +
- '<span class="fog-details">$3516. $16,804 to go!</span>' +
+ '<span class="fog-details">${{{FOG_AMOUNT}}}. ${{{FOG_REMAIN}}} to go!</span>' +
'</div>' +
'</div>' +
'</div>' +
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]