changeset 1:a49aa1b823f6

added SàT archive download link (detect the last version)
author Goffi <goffi@goffi.org>
date Sun, 29 Jul 2012 01:52:27 +0200
parents 9305c6458e2f
children 0df46e87537d
files README sat_website/utils.py sat_website/views.py templates/sat_website/base.html
diffstat 4 files changed, 61 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/README	Sat Jul 28 20:36:32 2012 +0200
+++ b/README	Sun Jul 29 01:52:27 2012 +0200
@@ -30,6 +30,14 @@
 This is the source code of Salut à Toi's presentation website.
 Salut à Toi is a communication software base on XMPP. You can have more informations on http://sat.goffi.org (the website ran by this code).
 
+** SETTINGS **
+
+The following values can be set in site's settings.py:
+
+	SAT_LINK_PATH = '/path/to/sat_link.tar.bz2' #the link should point to a SàT archive in the form sat-version.tar.bz2
+	SAT_DL_PREFIX = 'ftp://ftp.goffi.org/sat' #this prefix will be joined to the filename pointed by the previous link
+	SAT_DL_PATH = 'ftp://ftp.goffi.org/sat/sat.tar.bz2' #if set, this link will be used instead of the joined dl_prefix + filename
+
 ** CREDIT **
 
 The following third party project are shipped with this source code:
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/sat_website/utils.py	Sun Jul 29 01:52:27 2012 +0200
@@ -0,0 +1,40 @@
+#!/usr/bin/python
+# -*- coding: utf-8 -*-
+"""
+SàT website: Salut à Toi's presentation website
+Copyright (C) 2012  Jérôme Poisson (goffi@goffi.org)
+
+This file is part of SàT website.
+
+SàT website is free software: you can redistribute it and/or modify
+it under the terms of the GNU Affero General Public License as published by
+the Free Software Foundation, either version 3 of the License, or
+(at your option) any later version.
+
+Foobar is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU Affero General Public License for more details.
+
+You should have received a copy of the GNU Affero General Public License
+along with Foobar.  If not, see <http://www.gnu.org/licenses/>.
+"""
+
+from os.path import basename,realpath,join
+from django.conf import settings
+
+def get_latest_sat():
+    """Return a tuple with download path of latest SàT version, and version number"""
+    try:
+        path = settings.SAT_LINK_PATH
+        real_path = realpath(path)
+        filename = basename(real_path)
+        version = filename[4:-8] #filename must be in the form of sat-version.tar.bz2
+        if hasattr(settings, "SAT_DL_PATH"):
+            dl_path = settings.SAT_DL_PATH
+        else:
+            dl_path = join(settings.SAT_DL_PREFIX, filename)
+    except AttributeError:
+        return (None, None)
+    
+    return (dl_path, version)
--- a/sat_website/views.py	Sat Jul 28 20:36:32 2012 +0200
+++ b/sat_website/views.py	Sun Jul 29 01:52:27 2012 +0200
@@ -23,7 +23,7 @@
 from django.http import Http404
 from django.shortcuts import render_to_response
 from collections import OrderedDict
-import screenshots, social_contract
+import screenshots, social_contract, utils
 
 CATEGORIES = OrderedDict([("features", "Features"),
               ("frontends", "Frontends"),
@@ -36,8 +36,12 @@
     return render_to_response('sat_website/overview.html')
 
 def generic_cat(request, category):
+    latest_dl_path, latest_version = utils.get_latest_sat()
     context = {"categories": CATEGORIES,
-               "category": category}
+               "category": category,
+               "latest_dl_path": latest_dl_path,
+               "latest_version": latest_version,
+              }
     for k,v in CATEGORIES.iteritems():
         print "category: %s:%s" % (k,v)
     if not category or category == "overview":
--- a/templates/sat_website/base.html	Sat Jul 28 20:36:32 2012 +0200
+++ b/templates/sat_website/base.html	Sun Jul 29 01:52:27 2012 +0200
@@ -41,7 +41,13 @@
 					{% for cat_url,cat_name in categories.items %}
 						<li><a href="{{ cat_url }}.html">{{ cat_name }}</a></li>  
 					{% endfor %}
-				</ul> 
+				</ul>
+                {% if latest_dl_path and latest_version %}
+                    <ul class="nav pull-right">
+                        <li><a href="{{ latest_dl_path }}"><strong>Download SàT {{ latest_version }}</strong></a> </li>
+                        
+                    </ul>
+                {% endif %}
 			</div>  
 		</div>  
 	</div>