[Scummvm-git-logs] scummvm-sites director-buildbot -> 101d77f38873fca67fdfdfdebdf60a04e3cd7c23

sev- noreply at scummvm.org
Mon Jun 15 17:35:25 UTC 2026


This automated email contains information about 1 new commit which have been
pushed to the 'scummvm-sites' repo located at https://api.github.com/repos/scummvm/scummvm-sites .

Summary:
101d77f388 IMAGEDIFF: Add pagination and default to last page


Commit: 101d77f38873fca67fdfdfdebdf60a04e3cd7c23
    https://github.com/scummvm/scummvm-sites/commit/101d77f38873fca67fdfdfdebdf60a04e3cd7c23
Author: ramyak-sharma (ramyaksharma1 at gmail.com)
Date: 2026-06-15T19:35:22+02:00

Commit Message:
IMAGEDIFF: Add pagination and default to last page

Changed paths:
    imagediff/main.py
    imagediff/static/css/style.css
    imagediff/templates/target.html


diff --git a/imagediff/main.py b/imagediff/main.py
index 5ab58f4..7e7f8ab 100644
--- a/imagediff/main.py
+++ b/imagediff/main.py
@@ -108,6 +108,21 @@ def get_frame_number(filename):
         
 
 
+def get_pagination_pages(page, total_pages, window=2):
+    """Return list of page numbers with None for ellipsis gaps."""
+    pages = set([1, total_pages])
+    for i in range(max(1, page - window), min(total_pages, page + window) + 1):
+        pages.add(i)
+    result = []
+    prev = None
+    for p in sorted(pages):
+        if prev is not None and p - prev > 1:
+            result.append(None)
+        result.append(p)
+        prev = p
+    return result
+
+
 def get_sorted_builds(target_path, reverse=True):
     """Get sorted list of builds for a target."""
     builds = [b for b in os.listdir(target_path)
@@ -218,18 +233,17 @@ def target_detail(target):
     if not os.path.exists(target_path) or not os.path.isdir(target_path):
         return "Target not found", 404
 
-    # Only get the build list, other time-consuming operations moved to API
-    builds = get_sorted_builds(target_path,reverse=False)
-
-    # Only return the page framework with build list but without table data
-    page = int(request.args.get('page', 1))
+    builds = get_sorted_builds(target_path, reverse=False)
     page_size = 20
+    total_pages = max(1, (len(builds) + page_size - 1) // page_size)
+    page_param = request.args.get('page')
+    page = int(page_param) if page_param is not None else total_pages
+    page = max(1, min(page, total_pages))
     start = (page - 1) * page_size
     end = start + page_size
     paginated_builds = builds[start:end]
-    total_pages = (len(builds) + page_size - 1) // page_size
+    pagination_pages = get_pagination_pages(page, total_pages)
 
-    # Load cache for this target and page
     cache_data = load_target_cache(target, page)
 
     return render_template('target.html',
@@ -238,6 +252,7 @@ def target_detail(target):
         builds=paginated_builds,
         page=page,
         total_pages=total_pages,
+        pagination_pages=pagination_pages,
         cache_data=cache_data)
 
 
diff --git a/imagediff/static/css/style.css b/imagediff/static/css/style.css
index 410eea8..99119a1 100644
--- a/imagediff/static/css/style.css
+++ b/imagediff/static/css/style.css
@@ -128,4 +128,67 @@ a:hover {
         max-width: 300px;
         max-height: 300px;
     }
+}
+
+.pagination-container {
+    margin-top: 12px;
+}
+
+.pagination {
+    display: flex;
+    align-items: center;
+    gap: 4px;
+    flex-wrap: wrap;
+}
+
+.page-btn {
+    display: inline-block;
+    padding: 4px 8px;
+    border: 1px solid #ccc;
+    border-radius: 4px;
+    color: #337ab7;
+    background: #fff;
+    cursor: pointer;
+    text-decoration: none;
+    font-size: 14px;
+    line-height: 1.4;
+}
+
+.page-btn:hover {
+    background: #e8f0fe;
+    text-decoration: none;
+}
+
+.page-btn.current {
+    background: #337ab7;
+    color: #fff;
+    border-color: #337ab7;
+    font-weight: bold;
+}
+
+.page-btn.disabled {
+    color: #aaa;
+    border-color: #eee;
+    cursor: default;
+    pointer-events: none;
+}
+
+.page-ellipsis {
+    padding: 4px 4px;
+    color: #666;
+}
+
+.page-jump-form {
+    display: inline-flex;
+    align-items: center;
+    gap: 4px;
+    margin-left: 8px;
+}
+
+.page-jump-input {
+    width: 60px;
+    padding: 4px 6px;
+    border: 1px solid #ccc;
+    border-radius: 4px;
+    font-size: 14px;
 }
\ No newline at end of file
diff --git a/imagediff/templates/target.html b/imagediff/templates/target.html
index 841d13e..e9c4438 100644
--- a/imagediff/templates/target.html
+++ b/imagediff/templates/target.html
@@ -104,25 +104,37 @@
         <div class="pagination-container">
     {% if total_pages > 1 %}
         <div class="pagination">
-
             {% if page > 1 %}
-                <a class="page-btn"
-                   href="{{ url_for('target_detail', target=target) }}?page={{ page - 1 }}">
-                    ⬅ Previous
-                </a>
+                <a class="page-btn" href="{{ url_for('target_detail', target=target) }}?page=1">|<</a>
+                <a class="page-btn" href="{{ url_for('target_detail', target=target) }}?page={{ page - 1 }}"><</a>
+            {% else %}
+                <span class="page-btn disabled">|<</span>
+                <span class="page-btn disabled"><</span>
             {% endif %}
 
-            <span class="page-info">
-                Page {{ page }} of {{ total_pages }}
-            </span>
+            {% for p in pagination_pages %}
+                {% if p is none %}
+                    <span class="page-ellipsis">…</span>
+                {% elif p == page %}
+                    <span class="page-btn current">{{ p }}</span>
+                {% else %}
+                    <a class="page-btn" href="{{ url_for('target_detail', target=target) }}?page={{ p }}">{{ p }}</a>
+                {% endif %}
+            {% endfor %}
 
             {% if page < total_pages %}
-                <a class="page-btn"
-                   href="{{ url_for('target_detail', target=target) }}?page={{ page + 1 }}">
-                    Next âž¡
-                </a>
+                <a class="page-btn" href="{{ url_for('target_detail', target=target) }}?page={{ page + 1 }}">></a>
+                <a class="page-btn" href="{{ url_for('target_detail', target=target) }}?page={{ total_pages }}">>|</a>
+            {% else %}
+                <span class="page-btn disabled">></span>
+                <span class="page-btn disabled">>|</span>
             {% endif %}
 
+            <form method="get" class="page-jump-form">
+                <input type="number" name="page" min="1" max="{{ total_pages }}"
+                       placeholder="{{ page }}" class="page-jump-input">
+                <button type="submit" class="page-btn">Go</button>
+            </form>
         </div>
     {% endif %}
 </div>




More information about the Scummvm-git-logs mailing list