Klaus Demo ~jonashaag/klaus / 08e8d19
Refactoring Jonas Haag 9 years ago
2 changed file(s) with 25 addition(s) and 11 deletion(s). Raw diff Collapse all Expand all
99
1010 {% include 'tree.inc.html' %}
1111
12 {# TODO: move logic into view #}
13 {% set history = repo.history(commit_id, path, history_length+1, skip) %}
14 {% set has_more_commits = history|length == history_length+1 %}
15
1612 {% macro pagination() %}
1713 <div class=pagination>
1814 {% if page %}
2420 {% endif %}
2521 {% endfor %}
2622 {% endif %}
27 {% if has_more_commits %}
23 {% if more_commits %}
2824 <a href="?page={{page+1}}">»»</a>
2925 {% else %}
3026 <span>»»</span>
5955
6056 <ul>
6157 {% for commit in history %}
62 {% if not loop.last or history|length < history_length %}
6358 <li>
6459 <a class=commit href="{{ url_for('commit', repo=repo.name, commit_id=commit.id) }}">
6560 <span class=line1>
7671 <span class=clearfloat></span>
7772 </a>
7873 </li>
79 {% endif %}
8074 {% endfor %}
8175 </ul>
8276 </div>
77 from werkzeug.exceptions import NotFound
88
99 from dulwich.objects import Blob
10 from dulwich.diff_tree import RenameDetector
1011
1112 from klaus import markup
1213 from klaus.utils import parent_directory, subpaths, get_mimetype_and_encoding, \
132133 self.context['page'] = page
133134
134135 if page:
135 self.context['history_length'] = 30
136 self.context['skip'] = (self.context['page']-1) * 30 + 10
136 history_length = 30
137 skip = (self.context['page']-1) * 30 + 10
137138 if page > 7:
138139 self.context['previous_pages'] = [0, 1, 2, None] + range(page)[-3:]
139140 else:
140141 self.context['previous_pages'] = xrange(page)
141142 else:
142 self.context['history_length'] = 10
143 self.context['skip'] = 0
143 history_length = 10
144 skip = 0
145
146 history = self.context['repo'].history(
147 self.context['commit_id'],
148 self.context['path'],
149 history_length + 1,
150 skip
151 )
152 if len(history) == history_length + 1:
153 # At least one more commit for next page left
154 more_commits = True
155 # We don't want show the additional commit on this page
156 history.pop()
157 else:
158 more_commits = False
159
160 self.context.update({
161 'history': history,
162 'more_commits': more_commits,
163 })
144164
145165
146166 class BlobViewMixin(object):