Author
|
zPlus <zplus@peers.community>
2022-08-03 18:38:24
|
Committer
|
zPlus <zplus@peers.community>
2022-08-03 18:38:24
|
Commit
|
58e8483
(patch)
|
Tree
|
b730647
|
Parent(s)
|
|
Add pagination to Log page.
commits diff:
6b84231..58e8483
2 files changed,
29 insertions,
3 deletions
—
download
Diffstat
Diff options
+11/-0
M templates/repository/log.html
74
|
74
|
|
</tbody>
|
75
|
75
|
|
</table>
|
76
|
76
|
|
|
|
77
|
+ |
<br />
|
|
78
|
+ |
|
|
79
|
+ |
{% if offset > 0 %}
|
|
80
|
+ |
{% set prev_offset = offset - log_pagination %}
|
|
81
|
+ |
<a href="{{ url('log', repository=repository[:-4], revision=revision, offset=prev_offset) }}">« Prev</a>
|
|
82
|
+ |
{% endif %}
|
|
83
|
+ |
|
|
84
|
+ |
{% if commits|length == log_pagination %}
|
|
85
|
+ |
{% set next_offset = offset + log_pagination %}
|
|
86
|
+ |
<a href="{{ url('log', repository=repository[:-4], revision=revision, offset=next_offset) }}">Next »</a>
|
|
87
|
+ |
{% endif %}
|
77
|
88
|
|
</div>
|
78
|
89
|
|
|
79
|
90
|
|
{% endblock %}
|
+18/-3
M web.py
40
|
40
|
|
# or when the domain needs to be displayed on some pages.
|
41
|
41
|
|
INSTANCE_DOMAIN = 'domain.local'
|
42
|
42
|
|
|
|
43
|
+ |
# How many commits to show in the log page
|
|
44
|
+ |
LOG_PAGINATION = 100
|
|
45
|
+ |
|
43
|
46
|
|
|
44
|
47
|
|
|
45
|
48
|
|
|
461
|
464
|
|
|
462
|
465
|
|
# At this point git_object should be a valid pygit2.GIT_OBJ_COMMIT
|
463
|
466
|
|
|
464
|
|
- |
# Read 50 commits
|
|
467
|
+ |
# Read commits
|
|
468
|
+ |
try: commits_offset = int(request.query.get('offset', 0))
|
|
469
|
+ |
except: commits_offset = 0
|
|
470
|
+ |
|
465
|
471
|
|
commits = []
|
|
472
|
+ |
commit_ith = 0
|
466
|
473
|
|
for commit in repo.walk(git_object.id):
|
467
|
|
- |
commits.append(commit)
|
468
|
|
- |
if len(commits) >= 50:
|
|
474
|
+ |
# Skip the first one (offset)
|
|
475
|
+ |
if commit_ith < commits_offset:
|
|
476
|
+ |
commit_ith += 1
|
|
477
|
+ |
continue
|
|
478
|
+ |
|
|
479
|
+ |
# Stop if we have reached pagination size
|
|
480
|
+ |
if len(commits) >= LOG_PAGINATION:
|
469
|
481
|
|
break
|
|
482
|
+ |
|
|
483
|
+ |
commits.append(commit)
|
470
|
484
|
|
|
471
|
485
|
|
return template(
|
472
|
486
|
|
'repository/log.html',
|
473
|
487
|
|
heads=heads, head_ref=HEAD, tags=tags,
|
474
|
488
|
|
commits=commits,
|
|
489
|
+ |
log_pagination=LOG_PAGINATION, offset=commits_offset,
|
475
|
490
|
|
repository=repository, revision=revision)
|
476
|
491
|
|
|
477
|
492
|
|
@bottle.post('/<repository:path>.git/log', name='log_change')
|