# HG changeset patch # User Goffi # Date 1343519547 -7200 # Node ID a49aa1b823f60b4d11523b739b04049d16803daa # Parent 9305c6458e2f74c80cfe5d24839447606d3ea92e added SàT archive download link (detect the last version) diff -r 9305c6458e2f -r a49aa1b823f6 README --- 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: diff -r 9305c6458e2f -r a49aa1b823f6 sat_website/utils.py --- /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 . +""" + +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) diff -r 9305c6458e2f -r a49aa1b823f6 sat_website/views.py --- 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": diff -r 9305c6458e2f -r a49aa1b823f6 templates/sat_website/base.html --- 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 %}
  • {{ cat_name }}
  • {% endfor %} - + + {% if latest_dl_path and latest_version %} + + {% endif %}