the repository which powers this website
Add compare button to branches page
RunasSudo 9 months ago
parent 7f5688d · commit 91ce363
-rw-r--r--themed/refs.html23
1 files changed, 16 insertions, 7 deletions
diff --git a/themed/refs.html b/themed/refs.html
index 5da2bd90..0c5e7148 100644
--- a/themed/refs.html
+++ b/themed/refs.html
@@ -29,14 +29,23 @@
{! struct commitinfo *info = ref->commit; !}
{! char *name = (char *)ref->refname; !}
{! if (!info) { continue; } !}
- <div class="px-3 py-2">
- <div><a href="{! cgit_shared_repolink_url(NULL, name, NULL); !}" class="text-blue-500 hover:text-blue-600 hover:underline">{{ name }}</a></div>
- {% if ref->object->type == OBJ_COMMIT %}
- <div class="text-sm text-gray-500 flex gap-x-1">
- {{ info->subject }} &middot; Updated {! cgit_print_age(info->committer_date, info->committer_tz, -1); !} ago
- <img src="{! gravatar_url(info->author_email); !}?s=24" class="mt-[-0.2rem]">
- {{ info->author }}
+ <div class="px-3 py-2 flex">
+ <div>
+ {# Branch info #}
+ <div><a href="{! cgit_shared_repolink_url(NULL, name, NULL); !}" class="text-blue-500 hover:text-blue-600 hover:underline">{{ name }}</a></div>
+ {% if ref->object->type == OBJ_COMMIT %}
+ <div class="text-sm text-gray-500 flex gap-x-1">
+ {{ info->subject }} &middot; Updated {! cgit_print_age(info->committer_date, info->committer_tz, -1); !} ago
+ <img src="{! gravatar_url(info->author_email); !}?s=24" class="mt-[-0.2rem]">
+ {{ info->author }}
+ </div>
+ {% endif %}
</div>
+ {% if strcmp(name, ctx.qry.head) %}{# Only show compare button if not equal to current branch #}
+ <div class="flex-1"></div>
+ <a href="{! cgit_shared_repolink_url_with_delimiter("diff", ctx.qry.head, NULL); !}id={{ name|urlencode }}&id2={{ ctx.qry.head|urlencode }}" class="py-1.5 px-3 self-center text-gray-500 bg-gray-50 border border-gray-300 rounded-md hover:bg-gray-100">
+ Compare
+ </a>
{% endif %}
</div>
{% endfor %}