Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add clickable diffs to recent changes view #215

Merged
merged 4 commits into from
Mar 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion history/histweb/view_recent_changes.html
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@ <h2 class="recent-changes__heading">
<time class="recent-changes__entry__time">
{{ $time.Format "15:04 UTC" }}
</time>
<span class="recent-changes__entry__message">{{$entry.Hash}}</span>
<span class="recent-changes__entry__message">
{{$entry.HyphaeDiffsHTML}}
</span>
{{ if $entry.Username | ne "anon" }}
<span class="recent-changes__entry__author">
&mdash; <a href="/hypha/{{$userHypha}}/{{$entry.Username}}" rel="author">{{$entry.Username}}</a>
Expand Down
22 changes: 22 additions & 0 deletions history/view.qtpl
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,28 @@ HyphaeLinksHTML returns a comma-separated list of hyphae that were affected by t
{% endstripspace %}
{% endfunc %}


HyphaeDiffsHTML returns a comma-separated list of diffs links of current revision for every affected file as HTML string.
{% func (rev Revision) HyphaeDiffsHTML() %}
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Снимок экрана 2024-03-10 в 22 23 57

Seen this in action. Works as expected, thank you!

However, I don't like this duplication of the hash. Maybe show it one time only? Something like that maybe:

Снимок экрана 2024-03-10 в 22 25 33

Copy link
Contributor Author

@danilax86 danilax86 Mar 10, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This variant without parenthesis looks cleaner. Done!

image

{% code entries := rev.hyphaeAffected() %}
{% stripspace %}
{% if len(entries) == 1 %}
<a href="/primitive-diff/{%s rev.Hash %}/{%s entries[0] %}">{%s rev.Hash %}</a>
{% else %}
{% for i, hyphaName := range entries %}
{% if i > 0 %}
<span aria-hidden="true">, </span>
{% endif %}
<a href="/primitive-diff/{%s rev.Hash %}/{%s hyphaName %}">
{% if i == 0 %}
{%s rev.Hash %}&nbsp;
{% endif %}
{%s hyphaName %}</a>
{% endfor %}
{% endif %}
{% endstripspace %}
{% endfunc %}

descriptionForFeed generates a good enough HTML contents for a web feed.
{% func (rev *Revision) descriptionForFeed() %}
<p><b>{%s rev.Message %}</b> (by {%s rev.Username %} at {%s rev.TimeString() %})</p>
Expand Down
Loading
Loading