# HG changeset patch # User Arne Babenhauserheide # Date 1235829885 -3600 # Node ID 35f8d279bd706d26e7c230433d2aebff670c8aca # Parent cea1ca632c0489a637a99b1b3abd3de1c16eaa27# Parent 15424b1a24a518ca669b9c8b9e20722a790fb3fe merge diff -r cea1ca632c04 -r 35f8d279bd70 hgscm/apps/www/models.py --- a/hgscm/apps/www/models.py Wed Feb 18 11:09:23 2009 +0100 +++ b/hgscm/apps/www/models.py Sat Feb 28 15:04:45 2009 +0100 @@ -1,3 +1,36 @@ from django.db import models +from django.utils import simplejson +from django.conf import settings +import os, re -# Create your models here. +def get_download(platform, version): + '''get the download for the right version''' + f = open(os.path.join(settings.MEDIA_ROOT, "downloads.json")) + list = simplejson.load(f) + f.close() + latest = version == 'latest' or not version + for entry in list: + if (latest and entry['latest'] == 'true') or entry['version'] == version: + for version in entry['versions']: + if version['identifier'] == platform: + return version +def get_download_for_agent(agent, version): + '''get the download for the right version''' + f = open(os.path.join(settings.MEDIA_ROOT, "downloads.json")) + list = simplejson.load(f) + f.close() + latest = version == 'latest' or not version + for entry in list: + if (latest and entry['latest'] == 'true') or entry['version'] == version: + for version in entry['versions']: + if re.search(version['system'], agent): + return version + +def get_latest_version(): + '''return the latest available version''' + f = open(os.path.join(settings.MEDIA_ROOT, "downloads.json")) + list = simplejson.load(f) + f.close() + for entry in list: + if entry['latest'] == 'true': + return entry['version'] diff -r cea1ca632c04 -r 35f8d279bd70 hgscm/apps/www/templatetags/__init__.py diff -r cea1ca632c04 -r 35f8d279bd70 hgscm/apps/www/templatetags/extras.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/hgscm/apps/www/templatetags/extras.py Sat Feb 28 15:04:45 2009 +0100 @@ -0,0 +1,48 @@ +from django import template +from django.conf import settings +from django.template import Context +from hgscm.apps.www.models import get_latest_version, get_download_for_agent, get_download +import random, os, re + +register = template.Library() + +class MercurialTricksNode(template.Node): + def __init__(self): + self._filename = self._random() + + def _random(self): + file = random.choice(os.listdir(settings.MERCURIAL_TRICKS)) + return os.path.join(settings.MERCURIAL_TRICKS, file) + + def render(self, context): + f = open(self._filename) + result = "

Tricks

" + f.read() + "

" + f.close() + return result + +class DownloadButtonNode(template.Node): + def __init__(self, extended): + self._extended = extended + def render(self, context): + agent = context['request'].META['HTTP_USER_AGENT'] + t = template.loader.get_template('fragments/downloadbutton.html') + c = Context() + + version = get_download_for_agent(agent, 'latest') + if not version: + version = get_download('source', 'latest') + c['download_system'] = version['system'] + c['download_url'] = version['url'] + c['latest_version'] = get_latest_version() + c['extended'] = self._extended + return t.render(c) + +def do_mercurial_tricks (parser, token): + return MercurialTricksNode() + +def do_download_button(parser, token): + extended = len(token.split_contents()) > 1 + return DownloadButtonNode(extended) + +register.tag('mercurial_tricks', do_mercurial_tricks) +register.tag('download_button', do_download_button) diff -r cea1ca632c04 -r 35f8d279bd70 hgscm/apps/www/urls.py --- a/hgscm/apps/www/urls.py Wed Feb 18 11:09:23 2009 +0100 +++ b/hgscm/apps/www/urls.py Sat Feb 28 15:04:45 2009 +0100 @@ -4,4 +4,6 @@ url(r'^$', 'frontpage', name='frontpage'), url(r'^about$', 'about', name='about'), url(r'^thepage$', 'thepage', name='thepage'), + url(r'^downloads$', 'downloads', name='downloads'), + url(r'^download/(?P.*?)/(?P.*?)$', 'download', name='download'), ) diff -r cea1ca632c04 -r 35f8d279bd70 hgscm/apps/www/views.py --- a/hgscm/apps/www/views.py Wed Feb 18 11:09:23 2009 +0100 +++ b/hgscm/apps/www/views.py Sat Feb 28 15:04:45 2009 +0100 @@ -1,5 +1,10 @@ from django.shortcuts import render_to_response from django.template import RequestContext +from django.http import HttpResponseRedirect +from django.utils import simplejson +from django.conf import settings +from hgscm.apps.www.models import get_download, get_latest_version +import os def frontpage(request): return render_to_response("frontpage.html", { }, @@ -10,3 +15,11 @@ def thepage(request): return render_to_response("thepage.html", { }, RequestContext(request)) +def download(request, platform, version): + return HttpResponseRedirect(get_download(platform, version)['url']) +def downloads(request): + f = open(os.path.join(settings.MEDIA_ROOT, "downloads.json")) + list = simplejson.load(f) + f.close() + return render_to_response("downloads.html", {'downloads': list}, + RequestContext(request)) diff -r cea1ca632c04 -r 35f8d279bd70 hgscm/media/css/styles.css --- a/hgscm/media/css/styles.css Wed Feb 18 11:09:23 2009 +0100 +++ b/hgscm/media/css/styles.css Sat Feb 28 15:04:45 2009 +0100 @@ -19,7 +19,7 @@ /* * General Document Settings */ -body { font: .875em/1.4285em "Times New Roman", Times, Georgia, serif; color: #666; width: 900px; margin: 0 auto; position: relative; } +body { font: .925em/1.4285em "Times New Roman", Times, Georgia, serif; color: #111; width: 900px; margin: 0 auto; position: relative; } /* * Headings @@ -31,6 +31,11 @@ h3 { font-size: 1.3em; } /* + * WIP warning, can be removed once the site is 'finished' + */ +.wip-warning { font-size: 1em; font-family: Optimer, Helvetica, Arial, sans-serif; border: 1px solid #330; background-color: #fafa33; padding: 2px; text-align: center} + +/* * Lists */ ul { margin-left: 2.2em; line-height: 1.5em; } @@ -62,7 +67,8 @@ table { border-collapse: separate; border-spacing: 0; font-family: Verdana, Helvetica, Arial, sans-serif; font-size: .7875em; } caption, th, td { text-align: left; font-weight: normal; } td, th { padding: 6px 8px; } -thead td, thead th { background: #00B5F1; color: #fff; font-weight: bold; } +.latest thead td, .latest thead th { background: #00B5F1; color: #fff; font-weight: bold; } +thead td, thead th { background: #999; color: #fff; font-weight: bold; } tbody td { border-bottom: 1px solid #ccc; } /* @@ -90,7 +96,7 @@ /* * Nav */ -#nav { position: absolute; top: 17px; right: 0; background: #999; height: 42px; margin: 0; width: 665px; font-size: 1.1428em; *font-size: 16px; line-height: 42px; font-family: Optimer, Helvetica, Arial, sans-serif; overflow: hidden; } +#nav { position: absolute; top: 41px; right: 0; background: #999; height: 42px; margin: 0; width: 665px; font-size: 1.1428em; *font-size: 16px; line-height: 42px; font-family: Optimer, Helvetica, Arial, sans-serif; overflow: hidden; } #nav li { float: left; margin: 0; padding: 0; list-style: none; } #nav a { float: left; color: #fff; text-decoration: none; padding: 0 16px; *padding: 0 14px; } #nav a:hover, #nav a:focus, #nav .active a { background: #00b5f1; } @@ -98,7 +104,7 @@ /* * Search */ -#search { position: absolute; right: 15px; top: 26px; color: #fff; width: 183px; height: 23px; background: url(../images/search.png) no-repeat 0 0; } +#search { position: absolute; right: 15px; top: 50px; color: #fff; width: 183px; height: 23px; background: url(../images/search.png) no-repeat 0 0; } #search legend { display: none; } #search label { position: absolute; left: -9999px; } #search .text { width: 150px; background: none; border: none; margin: 0 0 0 5px; position: relative; top: 5px; color: #666; } diff -r cea1ca632c04 -r 35f8d279bd70 hgscm/media/downloads.json --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/hgscm/media/downloads.json Sat Feb 28 15:04:45 2009 +0100 @@ -0,0 +1,26 @@ +[{ + "latest": "true", + "version": "1.1.1", + "versions": [{ + "system": "FreeBSD", + "identifier": "freebsd", + "url": "ftp://ftp.freebsd.org/pub/FreeBSD/ports/i386/packages-stable/devel/mercurial-1.1.2.tbz" + },{ + "system": "MacOS X 10.5", + "identifier": "macosx", + "url": "http://mercurial.berkwood.com/binaries/Mercurial-1.1.1-py2.5-macosx10.5.zip" + },{ + "system": "MacOS X 10.4", + "identifier": "macosx104", + "url": "http://mercurial.berkwood.com/binaries/Mercurial-1.1.1-py2.5-macosx10.4.zip" + },{ + "system": "Windows", + "identifier": "windows", + "url": "http://mercurial.berkwood.com/binaries/Mercurial-1.1.1.exe" + },{ + "system": "Source", + "identifier": "source", + "url": "http://www.selenic.com/mercurial/release/mercurial-1.1.1.tar.gz" + }] + } +] diff -r cea1ca632c04 -r 35f8d279bd70 hgscm/media/images/favicon.ico Binary file hgscm/media/images/favicon.ico has changed diff -r cea1ca632c04 -r 35f8d279bd70 hgscm/settings.py --- a/hgscm/settings.py Wed Feb 18 11:09:23 2009 +0100 +++ b/hgscm/settings.py Sat Feb 28 15:04:45 2009 +0100 @@ -67,10 +67,17 @@ ROOT_URLCONF = 'hgscm.urls' +MERCURIAL_TRICKS = os.path.join(BASE_DIR, "templates/tricks") + TEMPLATE_DIRS = ( os.path.join(BASE_DIR, "templates"), ) +TEMPLATE_CONTEXT_PROCESSORS = ( + 'django.core.context_processors.request', + 'django.core.context_processors.media', +) + INSTALLED_APPS = ( 'django.contrib.auth', 'django.contrib.contenttypes', diff -r cea1ca632c04 -r 35f8d279bd70 hgscm/templates/about.html --- a/hgscm/templates/about.html Wed Feb 18 11:09:23 2009 +0100 +++ b/hgscm/templates/about.html Sat Feb 28 15:04:45 2009 +0100 @@ -1,5 +1,6 @@ {% extends "base.html" %} +{% load extras %} {% block content %}
@@ -30,15 +31,11 @@

Similar projects

-

Mercurial is used for version control of files. Similar projects include git, Bazaar, Subversion and CVS. +

Mercurial is used for version control of files. Similar projects include Git and Bazaar, and other version control systems without a distributed architecture include Subversion and CVS.

-

Download Mercurial

- - Download now - Mercurial 2.42 - Windows XP | Vista | 7 - + {% download_button %} + {% mercurial_tricks %}
diff -r cea1ca632c04 -r 35f8d279bd70 hgscm/templates/base.html --- a/hgscm/templates/base.html Wed Feb 18 11:09:23 2009 +0100 +++ b/hgscm/templates/base.html Sat Feb 28 15:04:45 2009 +0100 @@ -5,19 +5,22 @@ - + + + Mercurial SCM +
Please note that this site is work in progress and incomplete! You probably want to visit the official mercurial homepage instead.

mercurial