Show More
@@ -1,181 +1,183 b'' | |||
|
1 | 1 | #!/usr/bin/env python |
|
2 | 2 | # encoding: utf-8 |
|
3 | 3 | # changeset controller for pylons |
|
4 | 4 | # Copyright (C) 2009-2010 Marcin Kuzminski <marcin@python-works.com> |
|
5 | 5 | # This program is free software; you can redistribute it and/or |
|
6 | 6 | # modify it under the terms of the GNU General Public License |
|
7 | 7 | # as published by the Free Software Foundation; version 2 |
|
8 | 8 | # of the License or (at your opinion) any later version of the license. |
|
9 | 9 | # |
|
10 | 10 | # This program is distributed in the hope that it will be useful, |
|
11 | 11 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
12 | 12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
13 | 13 | # GNU General Public License for more details. |
|
14 | 14 | # |
|
15 | 15 | # You should have received a copy of the GNU General Public License |
|
16 | 16 | # along with this program; if not, write to the Free Software |
|
17 | 17 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, |
|
18 | 18 | # MA 02110-1301, USA. |
|
19 | 19 | from rhodecode.lib.utils import EmptyChangeset |
|
20 | 20 | """ |
|
21 | 21 | Created on April 25, 2010 |
|
22 | 22 | changeset controller for pylons |
|
23 | 23 | @author: marcink |
|
24 | 24 | """ |
|
25 | 25 | from pylons import tmpl_context as c, url, request, response |
|
26 | 26 | from pylons.i18n.translation import _ |
|
27 | 27 | from pylons.controllers.util import redirect |
|
28 | 28 | from rhodecode.lib.auth import LoginRequired, HasRepoPermissionAnyDecorator |
|
29 | 29 | from rhodecode.lib.base import BaseController, render |
|
30 | import rhodecode.lib.helpers as h | |
|
30 | 31 | from rhodecode.model.hg import HgModel |
|
31 | 32 | from vcs.exceptions import RepositoryError, ChangesetError |
|
32 | 33 | from vcs.nodes import FileNode |
|
33 | 34 | from vcs.utils import diffs as differ |
|
34 | 35 | import logging |
|
35 | 36 | import traceback |
|
36 | 37 | |
|
37 | 38 | log = logging.getLogger(__name__) |
|
38 | 39 | |
|
39 | 40 | class ChangesetController(BaseController): |
|
40 | 41 | |
|
41 | 42 | @LoginRequired() |
|
42 | 43 | @HasRepoPermissionAnyDecorator('repository.read', 'repository.write', |
|
43 | 44 | 'repository.admin') |
|
44 | 45 | def __before__(self): |
|
45 | 46 | super(ChangesetController, self).__before__() |
|
46 | 47 | |
|
47 | 48 | def index(self, revision): |
|
48 | 49 | hg_model = HgModel() |
|
49 | 50 | cut_off_limit = 1024 * 250 |
|
50 | 51 | |
|
51 | 52 | def wrap_to_table(str): |
|
52 | 53 | |
|
53 | 54 | return '''<table class="code-difftable"> |
|
54 | 55 | <tr class="line"> |
|
55 | 56 | <td class="lineno new"></td> |
|
56 | 57 | <td class="code"><pre>%s</pre></td> |
|
57 | 58 | </tr> |
|
58 | 59 | </table>''' % str |
|
59 | 60 | |
|
60 | 61 | try: |
|
61 | 62 | c.changeset = hg_model.get_repo(c.repo_name).get_changeset(revision) |
|
62 | except RepositoryError: | |
|
63 | except RepositoryError, e: | |
|
63 | 64 | log.error(traceback.format_exc()) |
|
65 | h.flash(str(e), category='warning') | |
|
64 | 66 | return redirect(url('home')) |
|
65 | 67 | else: |
|
66 | 68 | try: |
|
67 | 69 | c.changeset_old = c.changeset.parents[0] |
|
68 | 70 | except IndexError: |
|
69 | 71 | c.changeset_old = None |
|
70 | 72 | c.changes = [] |
|
71 | 73 | |
|
72 | 74 | #=================================================================== |
|
73 | 75 | # ADDED FILES |
|
74 | 76 | #=================================================================== |
|
75 | 77 | c.sum_added = 0 |
|
76 | 78 | for node in c.changeset.added: |
|
77 | 79 | |
|
78 | 80 | filenode_old = FileNode(node.path, '', EmptyChangeset()) |
|
79 | 81 | if filenode_old.is_binary or node.is_binary: |
|
80 | 82 | diff = wrap_to_table(_('binary file')) |
|
81 | 83 | else: |
|
82 | 84 | c.sum_added += node.size |
|
83 | 85 | if c.sum_added < cut_off_limit: |
|
84 | 86 | f_udiff = differ.get_udiff(filenode_old, node) |
|
85 | 87 | diff = differ.DiffProcessor(f_udiff).as_html() |
|
86 | 88 | |
|
87 | 89 | else: |
|
88 | 90 | diff = wrap_to_table(_('Changeset is to big and was cut' |
|
89 | 91 | ' off, see raw changeset instead')) |
|
90 | 92 | |
|
91 | 93 | cs1 = None |
|
92 | 94 | cs2 = node.last_changeset.raw_id |
|
93 | 95 | c.changes.append(('added', node, diff, cs1, cs2)) |
|
94 | 96 | |
|
95 | 97 | #=================================================================== |
|
96 | 98 | # CHANGED FILES |
|
97 | 99 | #=================================================================== |
|
98 | 100 | c.sum_removed = 0 |
|
99 | 101 | for node in c.changeset.changed: |
|
100 | 102 | try: |
|
101 | 103 | filenode_old = c.changeset_old.get_node(node.path) |
|
102 | 104 | except ChangesetError: |
|
103 | 105 | filenode_old = FileNode(node.path, '', EmptyChangeset()) |
|
104 | 106 | |
|
105 | 107 | if filenode_old.is_binary or node.is_binary: |
|
106 | 108 | diff = wrap_to_table(_('binary file')) |
|
107 | 109 | else: |
|
108 | 110 | |
|
109 | 111 | if c.sum_removed < cut_off_limit: |
|
110 | 112 | f_udiff = differ.get_udiff(filenode_old, node) |
|
111 | 113 | diff = differ.DiffProcessor(f_udiff).as_html() |
|
112 | 114 | if diff: |
|
113 | 115 | c.sum_removed += len(diff) |
|
114 | 116 | else: |
|
115 | 117 | diff = wrap_to_table(_('Changeset is to big and was cut' |
|
116 | 118 | ' off, see raw changeset instead')) |
|
117 | 119 | |
|
118 | 120 | |
|
119 | 121 | cs1 = filenode_old.last_changeset.raw_id |
|
120 | 122 | cs2 = node.last_changeset.raw_id |
|
121 | 123 | c.changes.append(('changed', node, diff, cs1, cs2)) |
|
122 | 124 | |
|
123 | 125 | #=================================================================== |
|
124 | 126 | # REMOVED FILES |
|
125 | 127 | #=================================================================== |
|
126 | 128 | for node in c.changeset.removed: |
|
127 | 129 | c.changes.append(('removed', node, None, None, None)) |
|
128 | 130 | |
|
129 | 131 | return render('changeset/changeset.html') |
|
130 | 132 | |
|
131 | 133 | def raw_changeset(self, revision): |
|
132 | 134 | |
|
133 | 135 | hg_model = HgModel() |
|
134 | 136 | method = request.GET.get('diff', 'show') |
|
135 | 137 | try: |
|
136 | 138 | c.changeset = hg_model.get_repo(c.repo_name).get_changeset(revision) |
|
137 | 139 | except RepositoryError: |
|
138 | 140 | log.error(traceback.format_exc()) |
|
139 | 141 | return redirect(url('home')) |
|
140 | 142 | else: |
|
141 | 143 | try: |
|
142 | 144 | c.changeset_old = c.changeset.parents[0] |
|
143 | 145 | except IndexError: |
|
144 | 146 | c.changeset_old = None |
|
145 | 147 | c.changes = [] |
|
146 | 148 | |
|
147 | 149 | for node in c.changeset.added: |
|
148 | 150 | filenode_old = FileNode(node.path, '') |
|
149 | 151 | if filenode_old.is_binary or node.is_binary: |
|
150 | 152 | diff = _('binary file') |
|
151 | 153 | else: |
|
152 | 154 | f_udiff = differ.get_udiff(filenode_old, node) |
|
153 | 155 | diff = differ.DiffProcessor(f_udiff).raw_diff() |
|
154 | 156 | |
|
155 | 157 | cs1 = None |
|
156 | 158 | cs2 = node.last_changeset.raw_id |
|
157 | 159 | c.changes.append(('added', node, diff, cs1, cs2)) |
|
158 | 160 | |
|
159 | 161 | for node in c.changeset.changed: |
|
160 | 162 | filenode_old = c.changeset_old.get_node(node.path) |
|
161 | 163 | if filenode_old.is_binary or node.is_binary: |
|
162 | 164 | diff = _('binary file') |
|
163 | 165 | else: |
|
164 | 166 | f_udiff = differ.get_udiff(filenode_old, node) |
|
165 | 167 | diff = differ.DiffProcessor(f_udiff).raw_diff() |
|
166 | 168 | |
|
167 | 169 | cs1 = filenode_old.last_changeset.raw_id |
|
168 | 170 | cs2 = node.last_changeset.raw_id |
|
169 | 171 | c.changes.append(('changed', node, diff, cs1, cs2)) |
|
170 | 172 | |
|
171 | 173 | response.content_type = 'text/plain' |
|
172 | 174 | if method == 'download': |
|
173 | 175 | response.content_disposition = 'attachment; filename=%s.patch' % revision |
|
174 | 176 | parent = True if len(c.changeset.parents) > 0 else False |
|
175 | 177 | c.parent_tmpl = 'Parent %s' % c.changeset.parents[0].raw_id if parent else '' |
|
176 | 178 | |
|
177 | 179 | c.diffs = '' |
|
178 | 180 | for x in c.changes: |
|
179 | 181 | c.diffs += x[2] |
|
180 | 182 | |
|
181 | 183 | return render('changeset/raw_changeset.html') |
@@ -1,212 +1,217 b'' | |||
|
1 | 1 | #!/usr/bin/env python |
|
2 | 2 | # encoding: utf-8 |
|
3 | 3 | # files controller for pylons |
|
4 | 4 | # Copyright (C) 2009-2010 Marcin Kuzminski <marcin@python-works.com> |
|
5 | 5 | |
|
6 | 6 | # This program is free software; you can redistribute it and/or |
|
7 | 7 | # modify it under the terms of the GNU General Public License |
|
8 | 8 | # as published by the Free Software Foundation; version 2 |
|
9 | 9 | # of the License or (at your opinion) any later version of the license. |
|
10 | 10 | # |
|
11 | 11 | # This program is distributed in the hope that it will be useful, |
|
12 | 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
13 | 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
14 | 14 | # GNU General Public License for more details. |
|
15 | 15 | # |
|
16 | 16 | # You should have received a copy of the GNU General Public License |
|
17 | 17 | # along with this program; if not, write to the Free Software |
|
18 | 18 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, |
|
19 | 19 | # MA 02110-1301, USA. |
|
20 | 20 | """ |
|
21 | 21 | Created on April 21, 2010 |
|
22 | 22 | files controller for pylons |
|
23 | 23 | @author: marcink |
|
24 | 24 | """ |
|
25 | 25 | from mercurial import archival |
|
26 | 26 | from pylons import request, response, session, tmpl_context as c, url |
|
27 | 27 | from pylons.i18n.translation import _ |
|
28 | 28 | from pylons.controllers.util import redirect |
|
29 | 29 | from rhodecode.lib.auth import LoginRequired, HasRepoPermissionAnyDecorator |
|
30 | 30 | from rhodecode.lib.base import BaseController, render |
|
31 | 31 | from rhodecode.lib.utils import EmptyChangeset |
|
32 | 32 | from rhodecode.model.hg import HgModel |
|
33 | 33 | from vcs.exceptions import RepositoryError, ChangesetError |
|
34 | 34 | from vcs.nodes import FileNode |
|
35 | 35 | from vcs.utils import diffs as differ |
|
36 | 36 | import logging |
|
37 | 37 | import rhodecode.lib.helpers as h |
|
38 | 38 | import tempfile |
|
39 | 39 | |
|
40 | 40 | log = logging.getLogger(__name__) |
|
41 | 41 | |
|
42 | 42 | class FilesController(BaseController): |
|
43 | 43 | |
|
44 | 44 | @LoginRequired() |
|
45 | 45 | @HasRepoPermissionAnyDecorator('repository.read', 'repository.write', |
|
46 | 46 | 'repository.admin') |
|
47 | 47 | def __before__(self): |
|
48 | 48 | super(FilesController, self).__before__() |
|
49 | 49 | c.file_size_limit = 250 * 1024 #limit of file size to display |
|
50 | 50 | |
|
51 | 51 | def index(self, repo_name, revision, f_path): |
|
52 | 52 | hg_model = HgModel() |
|
53 | 53 | c.repo = repo = hg_model.get_repo(c.repo_name) |
|
54 | 54 | revision = request.POST.get('at_rev', None) or revision |
|
55 | 55 | |
|
56 | 56 | def get_next_rev(cur): |
|
57 | 57 | max_rev = len(c.repo.revisions) - 1 |
|
58 | 58 | r = cur + 1 |
|
59 | 59 | if r > max_rev: |
|
60 | 60 | r = max_rev |
|
61 | 61 | return r |
|
62 | 62 | |
|
63 | 63 | def get_prev_rev(cur): |
|
64 | 64 | r = cur - 1 |
|
65 | 65 | return r |
|
66 | 66 | |
|
67 | 67 | c.f_path = f_path |
|
68 | 68 | |
|
69 | 69 | |
|
70 | 70 | try: |
|
71 |
c |
|
|
71 | c.changeset = repo.get_changeset(revision) | |
|
72 | cur_rev = c.changeset.revision | |
|
72 | 73 | prev_rev = repo.get_changeset(get_prev_rev(cur_rev)).raw_id |
|
73 | 74 | next_rev = repo.get_changeset(get_next_rev(cur_rev)).raw_id |
|
74 | 75 | |
|
75 | 76 | c.url_prev = url('files_home', repo_name=c.repo_name, |
|
76 | 77 | revision=prev_rev, f_path=f_path) |
|
77 | 78 | c.url_next = url('files_home', repo_name=c.repo_name, |
|
78 |
|
|
|
79 | revision=next_rev, f_path=f_path) | |
|
79 | 80 | |
|
80 | c.changeset = repo.get_changeset(revision) | |
|
81 | try: | |
|
82 | c.files_list = c.changeset.get_node(f_path) | |
|
83 | c.file_history = self._get_history(repo, c.files_list, f_path) | |
|
81 | 84 | |
|
82 | c.cur_rev = c.changeset.raw_id | |
|
83 | c.rev_nr = c.changeset.revision | |
|
84 | c.files_list = c.changeset.get_node(f_path) | |
|
85 | c.file_history = self._get_history(repo, c.files_list, f_path) | |
|
85 | except RepositoryError, e: | |
|
86 | h.flash(str(e), category='warning') | |
|
87 | redirect(h.url('files_home', repo_name=repo_name, revision=revision)) | |
|
86 | 88 | |
|
87 |
except |
|
|
88 | c.files_list = None | |
|
89 | except RepositoryError, e: | |
|
90 | h.flash(str(e), category='warning') | |
|
91 | redirect(h.url('files_home', repo_name=repo_name, revision='tip')) | |
|
92 | ||
|
93 | ||
|
89 | 94 | |
|
90 | 95 | return render('files/files.html') |
|
91 | 96 | |
|
92 | 97 | def rawfile(self, repo_name, revision, f_path): |
|
93 | 98 | hg_model = HgModel() |
|
94 | 99 | c.repo = hg_model.get_repo(c.repo_name) |
|
95 | 100 | file_node = c.repo.get_changeset(revision).get_node(f_path) |
|
96 | 101 | response.content_type = file_node.mimetype |
|
97 | 102 | response.content_disposition = 'attachment; filename=%s' \ |
|
98 | 103 | % f_path.split('/')[-1] |
|
99 | 104 | return file_node.content |
|
100 | 105 | |
|
101 | 106 | def raw(self, repo_name, revision, f_path): |
|
102 | 107 | hg_model = HgModel() |
|
103 | 108 | c.repo = hg_model.get_repo(c.repo_name) |
|
104 | 109 | file_node = c.repo.get_changeset(revision).get_node(f_path) |
|
105 | 110 | response.content_type = 'text/plain' |
|
106 | 111 | |
|
107 | 112 | return file_node.content |
|
108 | 113 | |
|
109 | 114 | def annotate(self, repo_name, revision, f_path): |
|
110 | 115 | hg_model = HgModel() |
|
111 | 116 | c.repo = hg_model.get_repo(c.repo_name) |
|
112 | 117 | cs = c.repo.get_changeset(revision) |
|
113 | 118 | c.file = cs.get_node(f_path) |
|
114 | 119 | c.file_msg = cs.get_file_message(f_path) |
|
115 | 120 | c.cur_rev = cs.raw_id |
|
116 | 121 | c.rev_nr = cs.revision |
|
117 | 122 | c.f_path = f_path |
|
118 | 123 | |
|
119 | 124 | return render('files/files_annotate.html') |
|
120 | 125 | |
|
121 | 126 | def archivefile(self, repo_name, revision, fileformat): |
|
122 | 127 | archive_specs = { |
|
123 | 128 | '.tar.bz2': ('application/x-tar', 'tbz2'), |
|
124 | 129 | '.tar.gz': ('application/x-tar', 'tgz'), |
|
125 | 130 | '.zip': ('application/zip', 'zip'), |
|
126 | 131 | } |
|
127 | 132 | if not archive_specs.has_key(fileformat): |
|
128 | 133 | return 'Unknown archive type %s' % fileformat |
|
129 | 134 | |
|
130 | 135 | def read_in_chunks(file_object, chunk_size=1024 * 40): |
|
131 | 136 | """Lazy function (generator) to read a file piece by piece. |
|
132 | 137 | Default chunk size: 40k.""" |
|
133 | 138 | while True: |
|
134 | 139 | data = file_object.read(chunk_size) |
|
135 | 140 | if not data: |
|
136 | 141 | break |
|
137 | 142 | yield data |
|
138 | 143 | |
|
139 | 144 | archive = tempfile.TemporaryFile() |
|
140 | 145 | repo = HgModel().get_repo(repo_name).repo |
|
141 | 146 | fname = '%s-%s%s' % (repo_name, revision, fileformat) |
|
142 | 147 | archival.archive(repo, archive, revision, archive_specs[fileformat][1], |
|
143 | 148 | prefix='%s-%s' % (repo_name, revision)) |
|
144 | 149 | response.content_type = archive_specs[fileformat][0] |
|
145 | 150 | response.content_disposition = 'attachment; filename=%s' % fname |
|
146 | 151 | archive.seek(0) |
|
147 | 152 | return read_in_chunks(archive) |
|
148 | 153 | |
|
149 | 154 | def diff(self, repo_name, f_path): |
|
150 | 155 | hg_model = HgModel() |
|
151 | 156 | diff1 = request.GET.get('diff1') |
|
152 | 157 | diff2 = request.GET.get('diff2') |
|
153 | 158 | c.action = request.GET.get('diff') |
|
154 | 159 | c.no_changes = diff1 == diff2 |
|
155 | 160 | c.f_path = f_path |
|
156 | 161 | c.repo = hg_model.get_repo(c.repo_name) |
|
157 | 162 | |
|
158 | 163 | try: |
|
159 | 164 | if diff1 not in ['', None, 'None', '0' * 12, '0' * 40]: |
|
160 | 165 | c.changeset_1 = c.repo.get_changeset(diff1) |
|
161 | 166 | node1 = c.changeset_1.get_node(f_path) |
|
162 | 167 | else: |
|
163 | 168 | c.changeset_1 = EmptyChangeset() |
|
164 | 169 | node1 = FileNode('.', '', changeset=c.changeset_1) |
|
165 | 170 | |
|
166 | 171 | if diff2 not in ['', None, 'None', '0' * 12, '0' * 40]: |
|
167 | 172 | c.changeset_2 = c.repo.get_changeset(diff2) |
|
168 | 173 | node2 = c.changeset_2.get_node(f_path) |
|
169 | 174 | else: |
|
170 | 175 | c.changeset_2 = EmptyChangeset() |
|
171 | 176 | node2 = FileNode('.', '', changeset=c.changeset_2) |
|
172 | 177 | except RepositoryError: |
|
173 | 178 | return redirect(url('files_home', |
|
174 | 179 | repo_name=c.repo_name, f_path=f_path)) |
|
175 | 180 | |
|
176 | 181 | f_udiff = differ.get_udiff(node1, node2) |
|
177 | 182 | diff = differ.DiffProcessor(f_udiff) |
|
178 | 183 | |
|
179 | 184 | if c.action == 'download': |
|
180 | 185 | diff_name = '%s_vs_%s.diff' % (diff1, diff2) |
|
181 | 186 | response.content_type = 'text/plain' |
|
182 | 187 | response.content_disposition = 'attachment; filename=%s' \ |
|
183 | 188 | % diff_name |
|
184 | 189 | return diff.raw_diff() |
|
185 | 190 | |
|
186 | 191 | elif c.action == 'raw': |
|
187 | 192 | c.cur_diff = '<pre class="raw">%s</pre>' % h.escape(diff.raw_diff()) |
|
188 | 193 | elif c.action == 'diff': |
|
189 | 194 | if node1.size > c.file_size_limit or node2.size > c.file_size_limit: |
|
190 | 195 | c.cur_diff = _('Diff is to big to display') |
|
191 | 196 | else: |
|
192 | 197 | c.cur_diff = diff.as_html() |
|
193 | 198 | else: |
|
194 | 199 | #default option |
|
195 | 200 | if node1.size > c.file_size_limit or node2.size > c.file_size_limit: |
|
196 | 201 | c.cur_diff = _('Diff is to big to display') |
|
197 | 202 | else: |
|
198 | 203 | c.cur_diff = diff.as_html() |
|
199 | 204 | |
|
200 | 205 | if not c.cur_diff: c.no_changes = True |
|
201 | 206 | return render('files/file_diff.html') |
|
202 | 207 | |
|
203 | 208 | def _get_history(self, repo, node, f_path): |
|
204 | 209 | from vcs.nodes import NodeKind |
|
205 | 210 | if not node.kind is NodeKind.FILE: |
|
206 | 211 | return [] |
|
207 | 212 | changesets = node.history |
|
208 | 213 | hist_l = [] |
|
209 | 214 | for chs in changesets: |
|
210 | 215 | n_desc = 'r%s:%s' % (chs.revision, chs.short_id) |
|
211 | 216 | hist_l.append((chs.raw_id, n_desc,)) |
|
212 | 217 | return hist_l |
@@ -1,48 +1,55 b'' | |||
|
1 | 1 | <%inherit file="/base/base.html"/> |
|
2 | 2 | |
|
3 | 3 | <%def name="title()"> |
|
4 | 4 | ${c.repo_name} ${_('Files')} - ${c.rhodecode_name} |
|
5 | 5 | </%def> |
|
6 | 6 | |
|
7 | 7 | <%def name="breadcrumbs_links()"> |
|
8 | 8 | ${h.link_to(u'Home',h.url('/'))} |
|
9 | 9 | » |
|
10 | 10 | ${h.link_to(c.repo_name,h.url('files_home',repo_name=c.repo_name))} |
|
11 | 11 | » |
|
12 | 12 | ${_('files')} |
|
13 | 13 | %if c.files_list: |
|
14 |
@ |
|
|
14 | @ r${c.changeset.revision}:${h.short_id(c.changeset.raw_id)} | |
|
15 | 15 | %endif |
|
16 | 16 | </%def> |
|
17 | 17 | |
|
18 | 18 | <%def name="page_nav()"> |
|
19 | 19 | ${self.menu('files')} |
|
20 | 20 | </%def> |
|
21 | 21 | |
|
22 | 22 | <%def name="main()"> |
|
23 | 23 | <div class="box"> |
|
24 | 24 | <!-- box / title --> |
|
25 | 25 | <div class="title"> |
|
26 |
${self.breadcrumbs()} |
|
|
26 | ${self.breadcrumbs()} | |
|
27 | <ul class="links"> | |
|
28 | <li> | |
|
29 | <span style="text-transform: uppercase;"><a href="#">${_('branch')}: ${c.changeset.branch}</a></span> | |
|
30 | </li> | |
|
31 | </ul> | |
|
27 | 32 | </div> |
|
28 | 33 | <div class="table"> |
|
29 | 34 | <div id="files_data"> |
|
30 | 35 | %if c.files_list: |
|
31 | <h3 class="files_location">${_('Location')}: ${h.files_breadcrumbs(c.repo_name,c.cur_rev,c.files_list.path)}</h3> | |
|
36 | <h3 class="files_location"> | |
|
37 | ${_('Location')}: ${h.files_breadcrumbs(c.repo_name,c.changeset.raw_id,c.files_list.path)} | |
|
38 | </h3> | |
|
32 | 39 | %if c.files_list.is_dir(): |
|
33 | 40 | <%include file='files_browser.html'/> |
|
34 | 41 | %else: |
|
35 | 42 | <%include file='files_source.html'/> |
|
36 | 43 | %endif |
|
37 | 44 | %else: |
|
38 | 45 | <h2> |
|
39 | 46 | <a href="#" onClick="javascript:parent.history.back();" target="main">${_('Go back')}</a> |
|
40 | 47 | ${_('No files at given path')}: "${c.f_path or "/"}" |
|
41 | 48 | </h2> |
|
42 | 49 | %endif |
|
43 | 50 | |
|
44 | 51 | </div> |
|
45 | 52 | </div> |
|
46 | 53 | </div> |
|
47 | 54 | |
|
48 | 55 | </%def> No newline at end of file |
@@ -1,80 +1,80 b'' | |||
|
1 | 1 | <%def name="file_class(node)"> |
|
2 | 2 | %if node.is_file(): |
|
3 | 3 | <%return "browser-file" %> |
|
4 | 4 | %else: |
|
5 | 5 | <%return "browser-dir"%> |
|
6 | 6 | %endif |
|
7 | 7 | </%def> |
|
8 | 8 | <div id="body" class="browserblock"> |
|
9 | 9 | <div class="browser-header"> |
|
10 | 10 | ${h.form(h.url.current())} |
|
11 | 11 | <div class="info_box"> |
|
12 | 12 | <span >${_('view')}@rev</span> |
|
13 | <a href="${c.url_prev}">«</a> | |
|
14 |
${h.text('at_rev',value=c. |
|
|
15 | <a href="${c.url_next}">»</a> | |
|
13 | <a href="${c.url_prev}" title="${_('previous revision')}">«</a> | |
|
14 | ${h.text('at_rev',value=c.changeset.revision,size=3)} | |
|
15 | <a href="${c.url_next}" title="${_('next revision')}">»</a> | |
|
16 | 16 | ${h.submit('view','view')} |
|
17 | 17 | </div> |
|
18 | 18 | ${h.end_form()} |
|
19 | 19 | </div> |
|
20 | 20 | <div class="browser-body"> |
|
21 | 21 | <table class="code-browser"> |
|
22 | 22 | <thead> |
|
23 | 23 | <tr> |
|
24 | 24 | <th>${_('Name')}</th> |
|
25 | 25 | <th>${_('Size')}</th> |
|
26 | 26 | <th>${_('Mimetype')}</th> |
|
27 | 27 | <th>${_('Revision')}</th> |
|
28 | 28 | <th>${_('Last modified')}</th> |
|
29 | 29 | <th>${_('Last commiter')}</th> |
|
30 | 30 | </tr> |
|
31 | 31 | </thead> |
|
32 | 32 | |
|
33 | 33 | %if c.files_list.parent: |
|
34 | 34 | <tr class="parity0"> |
|
35 | 35 | <td> |
|
36 |
${h.link_to('..',h.url('files_home',repo_name=c.repo_name,revision=c.c |
|
|
36 | ${h.link_to('..',h.url('files_home',repo_name=c.repo_name,revision=c.changeset.raw_id,f_path=c.files_list.parent.path),class_="browser-dir")} | |
|
37 | 37 | </td> |
|
38 | 38 | <td></td> |
|
39 | 39 | <td></td> |
|
40 | 40 | <td></td> |
|
41 | 41 | <td></td> |
|
42 | 42 | <td></td> |
|
43 | 43 | </tr> |
|
44 | 44 | %endif |
|
45 | 45 | |
|
46 | 46 | %for cnt,node in enumerate(c.files_list,1): |
|
47 | 47 | <tr class="parity${cnt%2}"> |
|
48 | 48 | <td> |
|
49 |
${h.link_to(node.name,h.url('files_home',repo_name=c.repo_name,revision=c.c |
|
|
49 | ${h.link_to(node.name,h.url('files_home',repo_name=c.repo_name,revision=c.changeset.raw_id,f_path=node.path),class_=file_class(node))} | |
|
50 | 50 | </td> |
|
51 | 51 | <td> |
|
52 | 52 | %if node.is_file(): |
|
53 | 53 | ${h.format_byte_size(node.size,binary=True)} |
|
54 | 54 | %endif |
|
55 | 55 | </td> |
|
56 | 56 | <td> |
|
57 | 57 | %if node.is_file(): |
|
58 | 58 | ${node.mimetype} |
|
59 | 59 | %endif |
|
60 | 60 | </td> |
|
61 | 61 | <td> |
|
62 | 62 | %if node.is_file(): |
|
63 | ${node.last_changeset.revision} | |
|
63 | <span class="tooltip" tooltip_title="${node.last_changeset.raw_id}">${node.last_changeset.revision}</span> | |
|
64 | 64 | %endif |
|
65 | 65 | </td> |
|
66 | 66 | <td> |
|
67 | 67 | %if node.is_file(): |
|
68 |
${h.age(node.last_changeset.date)} |
|
|
68 | ${node.last_changeset.date} - ${h.age(node.last_changeset.date)} ${_('ago')} | |
|
69 | 69 | %endif |
|
70 | 70 | </td> |
|
71 | 71 | <td> |
|
72 | 72 | %if node.is_file(): |
|
73 | 73 | ${node.last_changeset.author} |
|
74 | 74 | %endif |
|
75 | 75 | </td> |
|
76 | 76 | </tr> |
|
77 | 77 | %endfor |
|
78 | 78 | </table> |
|
79 | 79 | </div> |
|
80 | 80 | </div> No newline at end of file |
@@ -1,57 +1,57 b'' | |||
|
1 | 1 | <dl> |
|
2 | 2 | <dt>${_('Last revision')}</dt> |
|
3 | 3 | <dd> |
|
4 | 4 | ${h.link_to("r%s:%s" % (c.files_list.last_changeset.revision,h.short_id(c.files_list.last_changeset.raw_id)), |
|
5 | 5 | h.url('files_home',repo_name=c.repo_name,revision=c.files_list.last_changeset.raw_id,f_path=c.f_path))} |
|
6 | 6 | </dd> |
|
7 | 7 | <dt>${_('Size')}</dt> |
|
8 | 8 | <dd>${h.format_byte_size(c.files_list.size,binary=True)}</dd> |
|
9 | 9 | <dt>${_('Mimetype')}</dt> |
|
10 | 10 | <dd>${c.files_list.mimetype}</dd> |
|
11 | 11 | <dt>${_('Options')}</dt> |
|
12 | 12 | <dd>${h.link_to(_('show annotation'), |
|
13 |
h.url('files_annotate_home',repo_name=c.repo_name,revision=c.c |
|
|
13 | h.url('files_annotate_home',repo_name=c.repo_name,revision=c.changeset.raw_id,f_path=c.f_path))} | |
|
14 | 14 | / ${h.link_to(_('show as raw'), |
|
15 |
h.url('files_raw_home',repo_name=c.repo_name,revision=c.c |
|
|
15 | h.url('files_raw_home',repo_name=c.repo_name,revision=c.changeset.raw_id,f_path=c.f_path))} | |
|
16 | 16 | / ${h.link_to(_('download as raw'), |
|
17 |
h.url('files_rawfile_home',repo_name=c.repo_name,revision=c.c |
|
|
17 | h.url('files_rawfile_home',repo_name=c.repo_name,revision=c.changeset.raw_id,f_path=c.f_path))} | |
|
18 | 18 | </dd> |
|
19 | 19 | <dt>${_('History')}</dt> |
|
20 | 20 | <dd> |
|
21 | 21 | <div> |
|
22 | 22 | ${h.form(h.url('files_diff_home',repo_name=c.repo_name,f_path=c.f_path),method='get')} |
|
23 | 23 | ${h.hidden('diff2',c.files_list.last_changeset.raw_id)} |
|
24 | 24 | ${h.select('diff1',c.files_list.last_changeset.raw_id,c.file_history)} |
|
25 | 25 | ${h.submit('diff','diff to revision',class_="ui-button ui-widget ui-state-default ui-corner-all")} |
|
26 | 26 | ${h.submit('show_rev','show at revision',class_="ui-button ui-widget ui-state-default ui-corner-all")} |
|
27 | 27 | ${h.end_form()} |
|
28 | 28 | </div> |
|
29 | 29 | </dd> |
|
30 | 30 | </dl> |
|
31 | 31 | |
|
32 | 32 | |
|
33 | 33 | <div id="body" class="codeblock"> |
|
34 | 34 | <div class="code-header"> |
|
35 | 35 | <div class="revision">${c.files_list.name}@r${c.files_list.last_changeset.revision}:${h.short_id(c.files_list.last_changeset.raw_id)}</div> |
|
36 | 36 | <div class="commit">"${c.files_list.last_changeset.message}"</div> |
|
37 | 37 | </div> |
|
38 | 38 | <div class="code-body"> |
|
39 | 39 | % if c.files_list.size < c.file_size_limit: |
|
40 | 40 | ${h.pygmentize(c.files_list,linenos=True,anchorlinenos=True,lineanchors='S',cssclass="code-highlight")} |
|
41 | 41 | %else: |
|
42 | 42 | ${_('File is to big to display')} ${h.link_to(_('show as raw'), |
|
43 |
h.url('files_raw_home',repo_name=c.repo_name,revision=c.c |
|
|
43 | h.url('files_raw_home',repo_name=c.repo_name,revision=c.changeset.raw_id,f_path=c.f_path))} | |
|
44 | 44 | %endif |
|
45 | 45 | </div> |
|
46 | 46 | </div> |
|
47 | 47 | |
|
48 | 48 | <script type="text/javascript"> |
|
49 | 49 | YAHOO.util.Event.onDOMReady(function(){ |
|
50 | 50 | YAHOO.util.Event.addListener('show_rev','click',function(e){ |
|
51 | 51 | YAHOO.util.Event.preventDefault(e); |
|
52 | 52 | var cs = YAHOO.util.Dom.get('diff1').value; |
|
53 | 53 | var url = "${h.url('files_home',repo_name=c.repo_name,revision='__CS__',f_path=c.f_path)}".replace('__CS__',cs); |
|
54 | 54 | window.location = url; |
|
55 | 55 | }); |
|
56 | 56 | }); |
|
57 | 57 | </script> No newline at end of file |
General Comments 0
You need to be logged in to leave comments.
Login now