Commits

Anonymous committed 35f8d27 Merge

merge

  • Participants
  • Parent commits cea1ca6, 15424b1

Comments (0)

Files changed (18)

File hgscm/apps/www/models.py

 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']

File hgscm/apps/www/templatetags/__init__.py

Empty file added.

File hgscm/apps/www/templatetags/extras.py

+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 = "<p><h3>Tricks</h3>" + f.read() + "</p>"
+        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)

File hgscm/apps/www/urls.py

     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<version>.*?)/(?P<platform>.*?)$', 'download', name='download'),
 )

File hgscm/apps/www/views.py

 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", { },
 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))

File hgscm/media/css/styles.css

 /*
  * 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
 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; }
 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; }
 
 /*
 /*
  * 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; }
 /*
  * 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; }

File hgscm/media/downloads.json

+[{
+        "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"
+        }]
+    }
+]

File hgscm/media/images/favicon.ico

Added
New image

File hgscm/settings.py

 
 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',

File hgscm/templates/about.html

 {% extends "base.html" %}
 
+{% load extras %}
 {% block content %}
 
 <div class="row">
 
 		<h3>Similar projects</h3>
 
-		<p>Mercurial is used for version control of files. Similar projects include <a href="http://www.git-scm.org">git</a>, <a href="http://bazaar-vcs.org">Bazaar</a>, <a href="http://subversion.tigris.org/">Subversion</a> and <a href="http://www.nongnu.org/cvs/">CVS</a>.
+		<p>Mercurial is used for version control of files. Similar projects include <a href="http://git-scm.org">Git</a> and <a href="http://bazaar-vcs.org">Bazaar</a>, and other version control systems without a distributed architecture include <a href="http://subversion.tigris.org/">Subversion</a> and <a href="http://www.nongnu.org/cvs/">CVS</a>.
 		</div>
 		<div class="col">
-			<h2>Download Mercurial</h2>
-			<a class="download typeface-js" href="javascript:void(0);">
-			<strong>Download now</strong>
-			Mercurial <em>2.42</em>
-			<span>Windows XP | Vista | 7</span>
-			</a>
+                {% download_button %}
+	            {% mercurial_tricks %}
 		</div>
 	</div>
 

File hgscm/templates/base.html

 		<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
 		<link href="{{ MEDIA_URL }}css/styles.css" type="text/css" rel="stylesheet">
 		<script type="text/javascript" src="{{ MEDIA_URL }}javascript/typeface.js"></script>
-		<script type="text/javascript" src="{{ MEDIA_URL }}javascript/optimer_regular.typeface.js"></script>					
+		<script type="text/javascript" src="{{ MEDIA_URL }}javascript/optimer_regular.typeface.js"></script>
+		<link rel="shortcut icon" type="image/x-icon" href="{{ MEDIA_URL }}images/favicon.ico">
+
 		<title>Mercurial SCM</title>
 	</head>
 	<body id="home">
+	        <div class="wip-warning">Please note that this site is <em>work in progress and incomplete</em>! You probably want to <a href="http://www.selenic.com/mercurial" style="color: #3d3dfa">visit the official mercurial homepage</a> instead.</div>
 				
 		<h1 id="logo"><a href="/">mercurial</a></h1>
 			
 		<ul id="nav" class="typeface-js">
 			<li><a href="{% url about %}">about</a></li>
-			<li><a href="javascript:void(0);">download</a></li>
+			<li><a href="{% url downloads %}">download</a></li>
 			<li><a href="javascript:void(0);">extensions</a></li>
 			<li><a href="javascript:void(0);">docs</a></li>
-			<li><a href="javascript:void(0);">community</a></li>
+			<li><a href="http://www.selenic.com/mercurial">wiki</a></li>
 		</ul>
 		
 		<form id="search" method="post" action="search/">

File hgscm/templates/downloads.html

+{% extends "base.html" %}
+
+{% block content %}
+
+<div class="row">
+    <div class="big col">
+    <h1>Mercurial downloads</h1>
+    {% for d in downloads %}
+    {% ifequal d.latest "true" %}
+    <table border="0" cellspacing="0" cellpadding="0" class="latest" width="100%">
+    {% else %}
+    <table border="0" cellspacing="0" cellpadding="0" width="100%">
+    {% endifequal %}
+        <thead>
+            <tr>
+                <th>Mercurial {{ d.version }}</th>
+                <th></th>
+                <th></th>
+            </tr>
+        </thead>
+        <tbody>
+            {% for v in d.versions %}
+            <tr>
+                <td>{{ v.system }}</td>
+                <td>{{ v.language }}</td>
+                <td><a href="download/{{d.version}}/{{v.identifier}}">download</a></td>
+            </tr>
+            {% endfor %}
+        </tbody>
+    </table>
+    {% endfor %}
+    </div>
+<div class="col">
+    <h3>Get started</h3>
+    <p>Mercurial is written in python with platform independence in mind.
+    As a result, Mercurial is available on
+    <a href="http://www.microsoft.com/windows">Microsoft Windows</a>,
+    <a href="http://kernel.org">GNU/Linux</a>,
+    <a href="http://www.apple.com">MacOS X</a>,
+    <a href="http://www.opensolaris.org">OpenSolaris</a> and others.
+    You can either download a binary package for the system of your choice or
+    build if from sources.</p>
+
+    <p>Packages for common Linux, BSD and Solaris distributions can be
+    installed from the system specific repositories</p>
+    <p>
+<pre>
+# Debian/ubuntu
+$ apt-get install mercurial
+
+# Fedora
+$ yum install mercurial
+
+# Gentoo
+$ emerge mercurial
+
+# OpenSolaris
+$ pkg install SUNWmercurial
+    </p>
+</div>
+</div>
+
+{% endblock %}

File hgscm/templates/fragments/downloadbutton.html

+<a class="download typeface-js" href="{{download_url}}">
+			<strong>Download now</strong>
+			Mercurial <em>{{ latest_version }}</em>
+			<span>{{ download_system }}</span>
+</a>
+{% if extended %}
+<dl>
+    <dt class="typeface-js">Requirements</dt>
+    <dd>Python 2.4 (<a href="http://www.python.org">get python</a>)</dd>
+    <!--2.4 is necessary for TortoiseHG, Mercurial only needs 2.3-->
+
+    <dt>Another OS?<br><em>Get mercurial for:</em></dt>
+    <dd><a href="{% url download "latest" "macosx" %}">Mac OS X</a></dd>
+    <dd><a href="{% url download "latest" "windows" %}">Windows</a></dd>
+    <dd><a href="{% url downloads %}">other</a></dd>
+</dl>
+{% endif %}

File hgscm/templates/frontpage.html

 {% extends "base.html" %}
 
+{% load extras %}
 {% block content %}
 
 <div class="row">
 	<div class="col big">
 		<h1>Work easier <br> Work faster</h1>
-		<h2>Mercurial is a free, distributed source control management tool. It efficiently handles projects of any size and offers an easy and intuitive interface. <strong>Please notice, this page is currently under development and based on a mockup.</strong></h2>
+		<h2>Mercurial is a free, distributed source control management tool. It efficiently handles projects of any size and offers an easy and intuitive interface.</h2>
 	</div>
 	<div class="col">					
-		<a class="download typeface-js" href="javascript:void(0);">
-			<strong>Download now</strong>
-			Mercurial <em>2.42</em>
-			<span>Windows XP | Vista | 7</span>
-		</a>
-		<dl>
-			<dt class="typeface-js">Requirements</dt>
-			<dd>Python 2.4 (<a href="http://www.python.org">get python</a>)</dd>
-			<!--2.4 is necessary for TortoiseHG, Mercurial only needs 2.3-->
-			
-			<dt>Another OS?<br><em>Get mercurial for:</em></dt>
-			<dd><a href="javascript:void(0);">Mac OS X</a></dd>
-			<dd><a href="javascript:void(0);">Linux</a></dd>
-			<dd><a href="javascript:void(0);">other</a></dd>
-		</dl>				
+        {% download_button 'true' %}
 	</div>
 </div>
 

File hgscm/templates/tricks/01

+<strong>Reedit last commit message</strong>
+<pre>
+$ hg qimport -r tip
+$ hg qrefresh -e
+.. edit ..
+$ hg qfinish -a
+</pre>

File hgscm/templates/tricks/02

+<strong>Fold commits</strong>
+<pre>
+$ hg qimport -r tip -n 'tofold.patch'
+$ hg qpop
+$ hg qimport -r tip
+$ hg qfold 'tofold.patch'
+$ hg qfinish -a
+</pre>

File hgscm/urls.py

     (r'^media/(?P<path>.*)$', 'django.views.static.serve', 
         { 'document_root': os.path.join(settings.MEDIA_ROOT) }),
 
+    (r'^favicon\.ico$', 'django.views.static.serve', {'document_root': os.path.join(settings.MEDIA_ROOT), 'path': 'images/favicon.ico'}),
     # Uncomment the next line to enable the admin:
     # (r'^admin/(.*)', admin.site.root),
 )

File text/about.txt

 Mercurial is free software licensed under the terms of the GNU General Public License Version 2.
 
 Similar projects
-Mercurial is used for version control of files. Similar projects include [Git](http://git-scm.org), [Bazaar](http://bazaar-vcs.org), [Subversion](http://subversion.tigris.org/) and [CVS](http://www.nongnu.org/cvs/). 
+Mercurial is used for version control of files. Similar projects include [Git](http://git-scm.org) and [Bazaar](http://bazaar-vcs.org), and other version control systems without a distributed architecture include [Subversion](http://subversion.tigris.org/) and [CVS](http://www.nongnu.org/cvs/).