nautilebleu / django_hg

django_hg allows managing (create, authenticate, clone/push/pull…) Mercurial repositories throught django.

Clone this repository (size: 144.8 KB): HTTPS / SSH
$ hg clone http://bitbucket.org/nautilebleu/django_hg/
commit 29: 445f4d878d8a
parent 28: 8c38784a85a3
branch: default
Replace breadcrumb by path to be able to reuse the breadcrubm elsewere
Goulwen Reboux / nautilebleu
9 months ago

Changed (Δ8.3 KB):

raw changeset »

VERSION (1 lines added, 1 lines removed)

models.py (20 lines added, 20 lines removed)

site_media/css/django_hg.css (146 lines added, 0 lines removed)

templates/django_hg/base_file.html (27 lines added, 0 lines removed)

templates/django_hg/base_repository.html (32 lines added, 0 lines removed)

templates/django_hg/breadcrumb.html

templates/django_hg/changeset.html (15 lines added, 20 lines removed)

templates/django_hg/changeset_info.html (4 lines added, 5 lines removed)

templates/django_hg/changesets.html (47 lines added, 42 lines removed)

templates/django_hg/detail.html (36 lines added, 28 lines removed)

templates/django_hg/file.html

templates/django_hg/filediff.html (28 lines added, 0 lines removed)

templates/django_hg/filedisplay.html (2 lines added, 0 lines removed)

templates/django_hg/filelog.html (8 lines added, 13 lines removed)

templates/django_hg/filerev.html (7 lines added, 23 lines removed)

templates/django_hg/list.html (65 lines added, 50 lines removed)

templates/django_hg/path.html (6 lines added, 0 lines removed)

templates/django_hg/repo_info.html (1 lines added, 12 lines removed)

templatetags/django_hg_tags.py (13 lines added, 13 lines removed)

urls.py (3 lines added, 0 lines removed)

views.py (34 lines added, 2 lines removed)

Up to file-list VERSION:

1
0.0.1dev
1
0.4.0dev

Up to file-list models.py:

@@ -65,7 +65,6 @@ class HgContext():
65
65
    def __unicode__(self):
66
66
        return self.name
67
67
68
    # should rename to directory_listing
69
68
    def get_directory(self, path) :
70
69
        names = []
71
70
        dirs = []
@@ -156,7 +155,6 @@ class HgRepository(models.Model):
156
155
        """
157
156
        return ("hg-detail", {}, {'name': self.name })
158
157
159
160
158
    def owners(self):
161
159
        """
162
160
        Get the project owners
@@ -269,6 +267,9 @@ class HgRepository(models.Model):
269
267
        if not os.path.isdir(self.repo_path):#new:
270
268
            self.create_repository()
271
269
270
    def get_hash(self):
271
        print self.get_context().ctx
272
        return self.get_context().ctx
272
273
273
274
    def get_context(self):
274
275
        return self.context
@@ -281,24 +282,23 @@ class HgRepository(models.Model):
281
282
        shutil.rmtree(self.repo_path)
282
283
        super(HgRepository, self).delete()
283
284
284
285
    def list(self, path="/"):
286
        """
287
        Return a directory listing from the given repository path
288
        """
289
        import time
290
        results = []
291
        for item, locked in dirlist:
292
            if item.repos_path == path:
293
                continue
294
            results.append({
295
                'filename': os.path.basename(item.path),
296
                'dir_flag': 'brap',  #(item.kind == pysvn.node_kind.dir),
297
                'size': item.size,
298
                'date': time.ctime(item.time),
299
                'author': item.last_author
300
            })
301
        return results
285
    #def list(self, path="/"):
286
    #    """
287
    #    Return a directory listing from the given repository path
288
    #    """
289
    #    import time
290
    #    results = []
291
    #    for item, locked in dirlist:
292
    #        if item.repos_path == path:
293
    #            continue
294
    #        results.append({
295
    #            'filename': os.path.basename(item.path),
296
    #            'dir_flag': 'brap',  #(item.kind == pysvn.node_kind.dir),
297
    #            'size': item.size,
298
    #            'date': time.ctime(item.time),
299
    #            'author': item.last_author
300
    #        })
301
    #    return results
302
302
303
303
304
304
class RepositoryUser(models.Model):

Up to file-list site_media/css/django_hg.css:

1
span.access {
2
  float: right ;
3
  font-size: .8em ;
4
  font-weight: normal ;
5
}
6
7
.changeset {
8
  list-style-type: none ;
9
  margin: 0 ;
10
  padding: 0 ;
11
}
12
13
  .changeset pre {
14
    padding: 0 15px 0 15px ;
15
    white-space: normal ;
16
  }
17
18
.clone_url {
19
  float: right ;
20
  font-family: monospace ;
21
  font-size: .9em ;
22
  position: relative ;
23
  top: -15px ;
24
}
25
26
.description {
27
  color: grey ;
28
  float: none;
29
  margin: 5px 0 ;
30
}
31
32
.diff {
33
  font-family: monospace ;
34
  /*font-size: 1.1em;*/
35
  white-space: pre;
36
  width: 80em ;
37
}
38
39
  .diff td {
40
    height: 14px !important ;
41
  }
42
43
  .diff .diff_chg {
44
    background: silver ;/*rgb(221, 255, 221);*/
45
  }
46
47
  .diff .add {
48
    background: rgb(221, 255, 221);
49
  }
50
51
  .diff .remove {
52
    background: #FFDDDD;
53
  }
54
55
.django_hg_toolbar {
56
  float: right ;
57
  padding: 0px 5px ;
58
  width: 360px ;
59
}
60
61
  .django_hg_toolbar dl dd {
62
    margin: 0px
63
  }
64
65
.file {
66
  display: inline-block ;
67
}
68
69
.filelinks
70
{
71
  display: inline ;
72
  /*float: right ;*/
73
}
74
75
.pager {
76
  list-style-type: none ;
77
  margin: 0px 370px 0 15px ;
78
  padding: 0 ;
79
}
80
81
  .pager > li {
82
    border-bottom : 1px solid silver ;
83
    padding: 10px 0 ;
84
  }
85
86
.pre {
87
  font-family: monospace ;
88
}
89
90
.file_wrapper {
91
  overflow: auto ;
92
  margin: 0 5px 0 0 ;
93
}
94
95
.tools {
96
  list-style-type: none ;
97
  margin: 0 ;
98
  padding: 0 ;
99
}
100
101
  .tools li {
102
    display: inline-block ;
103
    padding: 0 15px 0 0 ;
104
  }
105
106
#breadcrumb {
107
  display: block ;
108
  list-style-type: none ;
109
  margin: 0 ;
110
  padding: 0 ;
111
}
112
113
  #breadcrumb li {
114
    display: inline-block ;
115
  }
116
117
    #breadcrumb li a {
118
      /*padding: 0 5px ;*/
119
    }
120
121
#django_hg_container {
122
  padding: 0 0 0 5px ;
123
}
124
125
#django_hg_container:after {
126
    content: ".";
127
    display: block;
128
    height: 0;
129
    clear: both;
130
    visibility: hidden;
131
}
132
133
#path {
134
  display: block ;
135
  list-style-type: none ;
136
  margin: 0 ;
137
  padding: 0 ;
138
}
139
140
  #path li {
141
    display: inline-block ;
142
  }
143
144
    #path li a {
145
      /*padding: 0 5px ;*/
146
    }

Up to file-list templates/django_hg/base_file.html:

1
{% extends "base.html" %}
2
{% load i18n %}
3
{% load django_hg_tags %}
4
5
6
{% block content %}
7
    <div id="django_hg_wrapper">
8
        <ul id="breadcrumb">
9
          <li><a href="{% url hg-list %}">«{%  trans 'Repositories' %}</a></li>
10
          <li><a href="{% url hg-detail repo %}">{{repo}}@{{rev}}:{{repo.get_hash}}</a></li>
11
          <li>{{ file|strip_path }}</li>
12
        </ul>
13
14
        <h2>{% block title %}{% endblock %}</h2>
15
16
        <div class="clone_url">{% trans 'Clone url' %}: {{ repo.absolute_url }} </div>
17
18
        <div id="django_hg_container">
19
            <div id="django_hg_container">
20
                <p>{% path %}</p>
21
22
                {% block file_content %}
23
                {% endblock %}
24
            </div>
25
        </div>
26
    </div>
27
{% endblock  %}

Up to file-list templates/django_hg/base_repository.html:

1
{% extends "base.html" %}
2
{% load i18n %}
3
{% load django_hg_tags %}
4
5
{% block content %}
6
    <div id="django_hg_wrapper">
7
        <a href="{% url hg-list %}">«{%  trans 'Repositories' %}</a> • {{repo}}
8
9
        <h2>{% block title %}{% endblock %}</h2>
10
        
11
        <div class="clone_url">{% trans 'Clone url' %}: {{ repo.absolute_url }} </div>
12
13
        <div id="django_hg_container">
14
            <div class="django_hg_toolbar">
15
                {% include 'django_hg/repo_info.html' %}
16
                <p>{% trans 'Informations about changeset' %}</p>
17
                <ul>
18
                    {% with repo.get_context as ctx %}
19
                      {% include 'django_hg/changeset_info.html' %}
20
                    {% endwith %}
21
                </ul>
22
            </div>
23
24
            <div id="django_hg_container">
25
                {% block repository_content %}
26
                {% endblock %}
27
            </div>
28
29
        </div>
30
31
    </div>
32
{% endblock  %}

Up to file-list templates/django_hg/changeset.html:

1
{% extends "base.html" %}
1
{% extends "django_hg/base_repository.html" %}
2
2
{% load i18n %}
3
3
{% load django_hg_tags %}
4
4
9
9
    {% endblocktrans %}
10
10
{% endblock %}
11
11
12
{% block content %}
13
{% include 'django_hg/repo_info.html' %}
12
{% block title %}
13
    {% blocktrans %}
14
      Changesets
15
    {% endblocktrans %}
16
{% endblock %}
14
17
15
<p>{% trans 'Informations about changeset' %}</p>
16
<ul>
17
  {% with repo.get_context as ctx %}
18
    {% include 'django_hg/changeset_info.html' %}
19
  {% endwith %}
20
</ul>
21
22
<h3>{% trans 'Files' %}</h3>
23
<ul>
24
    {% for f in files %}
25
        <li>{{ f.name }} ({{ f.size|filesizeformat }})
26
          <a href="{% url hg-filelog repo rev f.name %}">{% trans "Filelog" %}</a>
27
          <a href="{% url hg-filerev repo rev f.name %}">{% trans "View" %}</a>
28
        </li>
29
    {% endfor %}
30
</ul>
31
18
{% block repository_content %}
19
    <ul>
20
        {% for f in files %}
21
            <li>{{ f.name }} ({{ f.size|filesizeformat }})
22
              <a href="{% url hg-filelog repo rev f.name %}">{% trans "Filelog" %}</a>
23
              <a href="{% url hg-filerev repo rev f.name %}">{% trans "View" %}</a>
24
            </li>
25
        {% endfor %}
26
    </ul>
32
27
{% endblock  %}

Up to file-list templates/django_hg/changeset_info.html:

1
1
{% load i18n %}
2
2
{% load django_hg_tags %}
3
3
4
<li>{% trans 'Hash' %} : {{ ctx.hash }}</li>
5
<li>{% trans 'Date' %} : {% format_hg_date ctx.date %}</li>
6
<li>{% trans 'Last change by' %} : {{ ctx.user }}</li>
7
<li>{% trans 'Description' %} : <pre>{{ ctx.description }}</pre></li>
8
<li>{% trans 'Files changed' %} : {{ ctx.files_count }}</li>
4
{% blocktrans with ctx.user as user and ctx.date as date and ctx.description|linebreaks as description and ctx.files_count as files_count %}
5
  On {{ date }}, {{ user }} has committed {{ files_count }} file(s):
6
  <div class="pre">{{ description }}</div>
7
{% endblocktrans %}

Up to file-list templates/django_hg/changesets.html:

1
{% extends "base.html" %}
1
{% extends "django_hg/base_repository.html" %}
2
2
{% load i18n %}
3
3
{% load django_hg_tags %}
4
4
7
7
    {% trans 'Changesets of repository' %} {{ repo }}
8
8
{% endblock %}
9
9
10
{% block content %}
11
{% include 'django_hg/repo_info.html' %}
10
{% block title %}
11
    {% blocktrans %}
12
      Changesets
13
    {% endblocktrans %}
14
{% endblock %}
12
15
13
<p>
14
    {% ifequal max 0 %}
15
        {% blocktrans  %}
16
            There's currently no revisions in this repository:
17
        {% endblocktrans %}
18
    {% else %}
19
        {% ifequal max 1 %}
16
{% block repository_content %}
17
    <p>
18
        {% ifequal max 0 %}
20
19
            {% blocktrans  %}
21
                There's currently one revision in this repository:
20
                There's currently no revisions in this repository:
22
21
            {% endblocktrans %}
23
22
        {% else %}
24
            {% blocktrans  %}
25
                There's {{ max }} revisions in this repository, showing {{ start }} to {{ end }}:
26
            {% endblocktrans %}
23
            {% ifequal max 1 %}
24
                {% blocktrans  %}
25
                    There's currently one revision in this repository:
26
                {% endblocktrans %}
27
            {% else %}
28
                {% blocktrans  %}
29
                    There's {{ max }} revisions in this repository, showing {{ start }} to {{ end }}:
30
                {% endblocktrans %}
31
            {% endifequal %}
27
32
        {% endifequal %}
28
    {% endifequal %}
29
</p>
33
    </p>
30
34
31
<ul>
32
    {% for c in changelog %}
35
    <div id="django_hg_main">
36
        <ul class="pager">
37
        {% for c in changelog %}
38
            <ul>
39
              <li>
40
                {% with repo as name %}
41
                    <a href="{% url hg-changeset name, c.rev %}">{{c.rev }}:{{c.hash}}</a>
42
                {% endwith %}
43
                <ul>
44
                {% with c as ctx %}
45
                    {% include 'django_hg/changeset_info.html' %}
46
                {% endwith %}
47
                <li>
48
                {% with repo as name %}
49
                  <a href="{% url hg-detail-rev name c.rev %}">{% trans 'Browse' %}</a>
50
                {% endwith %}
51
              </li>
52
                </ul>
53
              </li>
54
            </ul>
55
        {% endfor %}
56
        </ul>
57
58
33
59
        <ul>
34
          <li>
35
            {% with repo as name %}
36
                <a href="{% url hg-changeset name, c.hash %}">{{c.rev }}</a>
37
            {% endwith %}
38
            <ul>
39
            {% with c as ctx %}
40
                {% include 'django_hg/changeset_info.html' %}
41
            {% endwith %}
42
            <li>
43
            {% with repo as name %}
44
              <a href="{% url hg-detail-rev name c.hash %}">{% trans 'Browse' %}</a>
45
            {% endwith %}
46
          </li>
47
            </ul>
48
          </li>
60
            {% paginate %}
49
61
        </ul>
50
    {% endfor %}
51
</ul>
52
53
54
<ul>
55
    {% paginate %}
56
</ul>
57
58
{% endblock  %}
62
    </div>
63
{% endblock %}

Up to file-list templates/django_hg/detail.html:

1
{% extends "base.html" %}
1
{% extends "django_hg/base_repository.html" %}
2
2
{% load i18n %}
3
3
{% load django_hg_tags %}
4
4
5
5
{% block head_title %}
6
    {% trans 'Repository' %}  {{ repo }}
6
    {% trans 'Repository' %} {{ repo }}
7
7
{% endblock %}
8
8
9
{% block content %}
10
{% include 'django_hg/repo_info.html' %}
9
{% block title %}
10
    {% blocktrans %}
11
      Browse@{{ rev }}
12
    {% endblocktrans %}
13
{% endblock %}
11
14
12
<p>{% trans 'Informations about changeset' %}</p>
13
<ul>
14
  {% with repo.get_context as ctx %}
15
    {% include 'django_hg/changeset_info.html' %}
16
  {% endwith %}
17
</ul>
18
19
<p>{% breadcrumb %}</p>
20
<p>Nombre d'éléments {{ files|length }}</p>
21
<ul>
22
{% for f in files %}
23
  <li>
24
    {% if f.is_dir %}
25
      <a href="{% url hg-detail-rev-browse repo rev f.path %}">{{ f }}</a>
26
    {% else %}
27
      {{ f }} ({{ f.size|filesizeformat }})
28
      <a href="{% url hg-filelog repo rev f.path %}">{% trans "Log" %}</a>
29
      <a href="{% url hg-filerev repo rev f.path %}">{% trans "View" %}</a>
30
    {% endif %}
31
  </li>
32
{% endfor %}
33
</ul>
34
35
{% endblock  %}
15
{% block repository_content%}
16
    <p>{% path %}</p>
17
    <p>{% trans 'Items count' %}: {{ files|length }}</p>
18
    <ul>
19
    {% for f in files %}
20
      <li>
21
        {% if f.is_dir %}
22
            <div class="file">
23
                <a href="{% url hg-detail-rev-browse repo rev f.path %}">
24
                    {{ f }}
25
                </a>
26
            </div>
27
        {% else %}
28
            <div class="file">{{ f }} ({{ f.size|filesizeformat }})</div>
29
            <div class="filelinks">
30
                <a href="{% url hg-filelog repo rev f.path %}">
31
                    {% trans "Log" %}
32
                </a>
33
                <a href="{% url hg-filerev repo rev f.path %}">
34
                    {% trans "View" %}
35
                </a>
36
                <a href="{% url hg-filediff repo rev f.path %}">
37
                    {% trans "Diff" %}
38
                </a>
39
        {% endif %}
40
      </li>
41
    {% endfor %}
42
    </ul>
43
{% endblock %}

Up to file-list templates/django_hg/filediff.html:

1
{% extends "django_hg/base_file.html" %}
2
{% load i18n %}
3
{% load django_hg_tags %}
4
5
{% block head_title %}
6
    {% blocktrans %}
7
        Diff of {{ file }} in repository {{ repo }} at rev {{ rev}}
8
    {% endblocktrans %}
9
{% endblock %}
10
11
12
{% block title %}
13
    {% trans 'Diff' %}
14
{% endblock %}
15
16
{% block file_content %}
17
    <div class="diff">
18
        <table>
19
        {% for line in diff %}
20
            <tr class="{% ifequal line.added 1 %} add {% endifequal %}
21
                       {% ifequal line.removed 1 %} remove {% endifequal %}">
22
                <td>
23
                {{ line.content }}</td>
24
            </tr>
25
        {% endfor %}
26
        </table>
27
    </div>
28
{% endblock %}

Up to file-list templates/django_hg/filedisplay.html:

1
1
{% load i18n %}
2
2
<p>{{ mimetype.0 }} ({{ size|filesizeformat }})</p>
3
3
4
<div class="file_wrapper">
4
5
{% if lexer %}
5
6
    <div class="syntax">
6
7
        {{ content|safe }}
28
29
    {% endifequal %}
29
30
30
31
{% endif %}
32
</div>

Up to file-list templates/django_hg/filelog.html:

1
{% extends "base.html" %}
1
{% extends "django_hg/base_file.html" %}
2
2
{% load i18n %}
3
3
{% load django_hg_tags %}
4
4
9
9
    {% endblocktrans %}
10
10
{% endblock %}
11
11
12
{% block content %}
13
{% include 'django_hg/repo_info.html' %}
12
{% block title %}
13
    {% trans 'Filelog' %}
14
{% endblock %}
14
15
15
<h3>
16
    {% blocktrans %}
17
        Filelog of {{ file }}
18
    {% endblocktrans %}
19
</h3>
20
<p>{% breadcrumb %}</p>
21
<ul>
16
{% block file_content %}
17
  <ul class="pager">
22
18
    {% for log in filelog %}
23
19
        <li><strong>
24
20
          {% trans 'On' %} {% format_hg_date log.date %} {% trans 'by' %}
25
21
          {{ log.user }} {% trans 'in branch' %} <em>{{ log.branch }}</em></strong>
26
          <pre style="white-space: normal">{{ log.description }}</pre>
22
          <div class="pre">{{ log.description }}</div>
27
23
          ({{ log.filesize|filesizeformat }})
28
24
          <a href="{% url hg-filerev repo log.rev file %}">{% trans "View" %}</a>
29
25
        </li>
30
26
    {% endfor %}
31
27
</ul>
32
33
{% endblock  %}
28
{% endblock %}

Up to file-list templates/django_hg/filerev.html:

1
{% extends "base.html" %}
1
{% extends "django_hg/base_file.html" %}
2
2
{% load i18n %}
3
3
{% load django_hg_tags %}
4
4
12
12
    {% endblocktrans %}
13
13
{% endblock %}
14
14
15
{% block content %}
16
<div id="django_hg_wrapper">
17
    <h2><a href="{% url hg-list %}">«{%  trans 'Repositories' %}</a> • {{repo}}@{{rev}} • {{ file|strip_path }}</h2>
15
{% block title %}
16
    {% trans 'File view' %}
17
{% endblock %}
18
18
19
    <div id="django_hg_container">
20
        <div class="django_hg_toolbar">
21
            {% include 'django_hg/repo_info.html' %}
22
            <p>{% trans 'Informations about changeset' %}</p>
23
            <ul>
24
                {% with repo.get_context as ctx %}
25
                  {% include 'django_hg/changeset_info.html' %}
26
                {% endwith %}
27
            </ul>
28
        </div>
29
30
        <div id="django_hg_container">
31
            <p>{% breadcrumb %}</p>
32
33
            {% filedisplay %}
34
        </div>
35
    </div>
36
</div>
37
{% endblock  %}
19
{% block file_content %}
20
  {% filedisplay %}
21
{% endblock %}

Up to file-list templates/django_hg/list.html:

3
3
{% load django_hg_tags %}
4
4
5
5
{% block head_title %}
6
    {% trans 'List of repositories' %}
6
    {% trans 'Repositories' %}
7
7
{% endblock %}
8
8
9
9
{% block content %}
10
<h2>{% trans 'List of repositories' %}</h2>
10
<div id="django_hg_wrapper">
11
    {%  trans 'Repositories' %}
11
12
12
<p>
13
    {% ifequal max 0 %}
14
        {% blocktrans  %}
15
            There's currently no repositories available:
16
        {% endblocktrans %}
17
    {% else %}
18
        {% ifequal max 1 %}
13
    <h2>
14
        {% ifequal max 0 %}
19
15
            {% blocktrans  %}
20
                There's currently one repository available:
16
                There's currently no repositories available:
21
17
            {% endblocktrans %}
22
18
        {% else %}
23
            {% blocktrans  %}
24
                There's {{ max }} repositories, showing {{ start }} to {{ end }}:
25
            {% endblocktrans %}
19
            {% ifequal max 1 %}
20
                {% blocktrans  %}
21
                    There's currently one repository available:
22
                {% endblocktrans %}
23
            {% else %}
24
                {% blocktrans  %}
25
                    There's {{ max }} repositories, showing {{ start }} to {{ end }}:
26
                {% endblocktrans %}
27
            {% endifequal %}
26
28
        {% endifequal %}
27
    {% endifequal %}
28
</p>
29
<!--
30
<div class="toolbar">
31
  <ul>
32
    <li>
33
      <dl>
34
        <dt>Access</dt>
35
        <dd>
36
          <select>
37
            <option value="">{% trans 'Public or private' %}</option>
38
            <option value="0">{% trans 'Public' %}</option>
39
            <option value="0">{% trans 'Private' %}</option>
40
          </select>
41
        </dd>
42
      </dl>
43
    </li>
44
  </ul>
29
    </h2>
30
31
    <div id="django_hg_container">
32
        <div class="django_hg_toolbar">
33
            <ul>
34
                <li>
35
                    <dl>
36
                        <dt>Access</dt>
37
                        <dd>
38
                            <select>
39
                                <option value="">{% trans 'Public or private' %}</option>
40
                                <option value="0">{% trans 'Public' %}</option>
41
                                <option value="0">{% trans 'Private' %}</option>
42
                            </select>
43
                        </dd>
44
                    </dl>
45
                </li>
46
            </ul>
47
        </div>
48
49
        <div id="django_hg_main">
50
            <ul class="pager">
51
                {% for repo in repositories %}
52
                <li>
53
                    <h3>
54
                        <a href="{% url hg-detail repo %}">{{repo}}</a>
55
                        <span class="access">
56
                        {% ifequal repo.anonymous_access 1 %}
57
                          {% trans '!Public!' %}
58
                        {% else %}
59
                          {% trans '[Private]' %}
60
                        {% endifequal %}
61
                        </span>
62
                    </h3>
63
                    <p class="description">{{ repo.summary }}</p>
64
                    {% include 'django_hg/repo_info.html' %}
65
                    <ul class="changeset">
66
                    {% with repo.get_context as ctx %}
67
                      {% include 'django_hg/changeset_info.html' %}
68
                    {% endwith %}
69
                    </ul>
70
                </li>
71
                {% endfor %}
72
            </ul>
73
        </div>
74
75
        <ul>
76
            {% paginate %}
77
        </ul>
78
    </div>
45
79
</div>
46
-->
47
<ul id="pager">
48
  {% for repo in repositories %}
49
    <li>
50
      {% include 'django_hg/repo_info.html' %}
51
      <p>{% trans 'Informations about latest changeset' %}</p>
52
      <ul>
53
      {% with repo.get_context as ctx %}
54
        {% include 'django_hg/changeset_info.html' %}
55
      {% endwith %}
56
      </ul>
57
    </li>
58
  {% endfor %}
59
</ul>
60
61
<ul>
62
    {% paginate %}
63
</ul>
64
65
80
{% endblock  %}

Up to file-list templates/django_hg/path.html:

1
<ul id="path">
2
  {% for item in path %}
3
    <li><a href="{{ item.url }}">{{ item.name }}</a>
4
      {% if not forloop.last %}•{% endif %}</li>
5
  {% endfor %}
6
</ul>

Up to file-list templates/django_hg/repo_info.html:

1
1
{% load i18n %}
2
<h2>
3
    <a href="{% url hg-detail repo %}">{{repo}}</a>
4
    <em>{{ repo.summary }}
5
        {% ifequal repo.anonymous_access 1 %}
6
          {% trans '!Public!' %}
7
        {% else %}
8
          {% trans '[Private]' %}
9
        {% endifequal %}
10
    </em>
11
</h2>
12
<ul>
13
    <li>{% trans 'Clone url' %}: {{ repo.absolute_url }} </li>
2
<ul class="tools">
14
3
    <li><a href="{% url hg-detail repo%}">{% trans 'Browse' %}</a></li>
15
4
    <li><a href="{% url hg-changesets repo %}">{% trans 'Changesets' %}</a></li>
16
5
</ul>

Up to file-list templatetags/django_hg_tags.py:

@@ -7,10 +7,10 @@ from django.template import Library
7
7
8
8
register = Library()
9
9
10
@register.inclusion_tag('django_hg/breadcrumb.html', takes_context=True)
11
def breadcrumb(context):
10
@register.inclusion_tag('django_hg/path.html', takes_context=True)
11
def path(context):
12
12
    """
13
    Build a breadcrumb for the navigation into the repository.
13
    Build a path for the navigation into the repository.
14
14
15
15
    >>> class Foo():
16
16
    ...     def __init__(self, name):
@@ -18,14 +18,14 @@ def breadcrumb(context):
18
18
    ...
19
19
    ...     def __str__(self):
20
20
    ...         return self.name
21
    >>> breadcrumb({'repo': Foo('foo'), 'rev': 'bar'})
22
    {'breadcrumb': [{'url': '/hg/foo/rev/bar', 'name': 'foo'}]}
21
    >>> path({'repo': Foo('foo'), 'rev': 'bar'})
22
    {'path': [{'url': '/hg/foo/rev/bar', 'name': 'foo'}]}
23
23
24
    >>> breadcrumb({'repo': Foo('foo'), 'rev': 'bar', 'path': 'baz/'})
25
    {'breadcrumb': [{'url': '/hg/foo/rev/bar', 'name': 'foo'}, {'url': '/hg/foo/rev/bar/baz/', 'name': 'baz'}]}
24
    >>> path({'repo': Foo('foo'), 'rev': 'bar', 'path': 'baz/'})
25
    {'path': [{'url': '/hg/foo/rev/bar', 'name': 'foo'}, {'url': '/hg/foo/rev/bar/baz/', 'name': 'baz'}]}
26
26
27
    >>> breadcrumb({'repo': Foo('foo'), 'rev': 'bar', 'path': 'baz/foo/'})
28
    {'breadcrumb': [{'url': '/hg/foo/rev/bar', 'name': 'foo'}, {'url': '/hg/foo/rev/bar/baz/', 'name': 'baz'}, {'url': '/hg/foo/rev/bar/baz/foo/', 'name': 'foo'}]}
27
    >>> path({'repo': Foo('foo'), 'rev': 'bar', 'path': 'baz/foo/'})
28
    {'path': [{'url': '/hg/foo/rev/bar', 'name': 'foo'}, {'url': '/hg/foo/rev/bar/baz/', 'name': 'baz'}, {'url': '/hg/foo/rev/bar/baz/foo/', 'name': 'foo'}]}
29
29
    """
30
30
31
31
    name = context['repo'].name
@@ -39,7 +39,7 @@ def breadcrumb(context):
39
39
        elements = path.split('/')
40
40
    else:
41
41
        elements = []
42
    breadcrumb = []
42
    breadcrumb_path = []
43
43
    count = len(elements)
44
44
    for i in range(count-1):
45
45
        previous = '/'.join([elements[elt] for elt in xrange(i+1)])
@@ -51,11 +51,11 @@ def breadcrumb(context):
51
51
            url = reverse('hg-detail-rev-browse', kwargs={'name': name,
52
52
                                                              'rev': rev,
53
53
                                                              'path': previous + '/'})
54
        breadcrumb.append({'name': elements[i], 'url': url})
54
        breadcrumb_path.append({'name': elements[i], 'url': url})
55
55
    url = reverse('hg-detail-rev', kwargs={'name': name, 'rev': rev})
56
    breadcrumb.insert(0, {'name': name, 'url': url})
56
    breadcrumb_path.insert(0, {'name': name, 'url': url})
57
57
58
    return {'breadcrumb': breadcrumb}
58
    return {'path': breadcrumb_path}
59
59
60
60
61
61
@register.inclusion_tag('django_hg/filedisplay.html', takes_context=True)

Up to file-list urls.py:

@@ -13,6 +13,9 @@ urlpatterns = patterns('django_hg.views'
13
13
    url(r'^(?P<name>(\w|\d|\.|\-|\_)+)/rev/(?P<rev>(\w|\d)+)/file/log/(?P<file>(\w|\d|\.|\-|\_|\/)+)/$',
14
14
        'filelog',
15
15
        name="hg-filelog"),
16
    url(r'^(?P<name>(\w|\d|\.|\-|\_)+)/rev/(?P<rev>(\w|\d)+)/file/diff/(?P<file>(\w|\d|\.|\-|\_|\/)+)/$',
17
        'filediff',
18
        name="hg-filediff"),
16
19
    url(r'^(?P<name>(\w|\d|\.|\-|\_)+)/rev/(?P<rev>(\w|\d)+)/file/display/(?P<file>(\w|\d|\.|\-|\_|\/)+)/$',
17
20
        'filedisplay',
18
21
        name="hg-filedisplay"),

Up to file-list views.py:

@@ -91,7 +91,7 @@ def changesets(request, name):
91
91
        c = start
92
92
        while c > end:
93
93
            ctx = repo.get_context().repository[c]
94
            # we pass a tuple instead of the object because it's really, really
94
            # we pass a dict instead of the object because it's really, really
95
95
            # faster (from 12500 to 48 ms with the django repository ! )
96
96
            changelog.append({"user": ctx.user(),
97
97
                             "description": ctx.description(),
@@ -160,6 +160,7 @@ def detail(request, name, rev, path=''):
160
160
            #redirect to an unauthorized page
161
161
            return HttpResponseRedirect(global_settings.LOGIN_URL)
162
162
163
        print repo.get_hash()
163
164
164
165
        return render_to_response('django_hg/detail.html', {
165
166
            'files': files,
@@ -169,6 +170,37 @@ def detail(request, name, rev, path=''):
169
170
        }, context_instance=RequestContext(request))
170
171
171
172
173
174
def filediff(request, name, rev, file):
175
    """
176
    display a diff of a file
177
    ``name``
178
        the name of the repository
179
    ``rev``
180
        the revision in the changesets history
181
    ``file``
182
        the file for which we want the log
183
    """
184
    repo = __get_repo(request, name, rev)
185
    # Check that the user is allowed to view it
186
    if repo.user_can_read(request.user):
187
        ctx = repo.get_context().repository[rev]
188
        fctx = ctx.filectx(file)
189
190
    else:
191
        #redirect to an unauthorized page
192
        return HttpResponseRedirect(global_settings.LOGIN_URL)
193
194
    return render_to_response('django_hg/filediff.html', {
195
        'file': file,
196
        'diff': 'tagada',
197
        'path': file,
198
        'repo': repo,
199
        'rev': rev,
200
    }, context_instance=RequestContext(request))
201
202
203
172
204
def filedisplay(request, name, rev, file):
173
205
    """
174
206
    display the file itself at the given rev
@@ -241,7 +273,6 @@ def filelog(request, name, rev, file):
241
273
        'file': file,
242
274
        'filelog': filelog,
243
275
        'path': file,
244
        'referer': 'changesets',
245
276
        'repo': repo,
246
277
        'rev': rev,
247
278
    }, context_instance=RequestContext(request))
@@ -268,6 +299,7 @@ def filerev(request, name, rev, file):
268
299
        return HttpResponseRedirect(global_settings.LOGIN_URL)
269
300
270
301
    return render_to_response('django_hg/filerev.html', {
302
        'DJANGO_HG_PYGMENT_STYLE': global_settings.DJANGO_HG_PYGMENT_STYLE,
271
303
        'fctx': fctx,
272
304
        'file': file,
273
305
        'host': request.META['HTTP_HOST'],