~sircmpwn/lists.sr.ht

ref: b0a92975f11afb7487f6af43b364ce44647ed7d1 lists.sr.ht/listssrht/templates/patchset.html -rw-r--r-- 5.8 KiB View raw
b0a92975Drew DeVault Add contrib/reclassify-patches 7 months ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
{% extends "list.html" %}
{% block title %}
<title>
  {{ patchset.subject }} &mdash; {{ cfg("sr.ht", "site-name") }} lists
</title>
{% endblock %}
{% macro msg_header(msg, showfrom=True) %}
<div class="message-header">
  {% if showfrom %}
  <div class="from">
    {% set from_hdr = msg.parsed()['From'] %}
    {% set from = parseaddr(from_hdr) %}
    {% if msg.sender != None %}
    <a href="/{{ msg.sender.canonical_name }}">{{from[0]}}</a>
    {% else %}
    {{from[0]}}
    {% endif %}
    {% if current_user %}
    <a href="{{reply_to(msg)}}">&lt;{{ from[1] }}&gt;</a>
    {% endif %}
  </div>
  {% endif %}
  <div class="date">
    <a
      id="{{ msg.message_id }}"
      href="#{{ msg.message_id }}"
      class="text-muted"
    >{{ msg.created | date }}</a>
  </div>
</div>
{% endmacro %}

{% macro display_msg(msg, body=None, index=0, standalone=True) %}
{{ msg_header(msg) }}
{% set feedback = feedback[msg.id] %}
{% if feedback.feedback_by_line.keys() %}
{% set last_line = max(feedback.feedback_by_line.keys()) %}
{% endif %}
<pre class="message-body">
  {%- for line in (body if body else format_body(msg)).splitlines() -%}
  {{- line + "\n" -}}
  {%- set line = loop.index + index - 1 -%}
  {%- if line in feedback.feedback_by_line -%}
</pre>
  {% for sub in feedback.feedback_by_line[line] %}
  <blockquote class="feedback">
    {% set msg = sub.source_msg._email %}
    {{ display_msg(msg, body="\n".join(sub.lines),
      index=sub.index, standalone=(line == last_line)) }}
  </blockquote>
  {% endfor %}
<pre class="message-body">
  {%- endif -%}
{%- endfor -%}
</pre>
{% if any(feedback.standalone_feedback) and standalone %}
{% for feedback in feedback.standalone_feedback %}
{% if feedback.source_msg._email not in patches %}
<blockquote>
  {% set msg = feedback.source_msg._email %}
  {{ msg_header(msg) }}
  <pre class="message-body">{{"\n".join(feedback.lines)}}</pre>
</blockquote>
{% endif %}
{% endfor %}
{% endif %}
{% endmacro %}

{% block content %}
<div class="container">
  <div class="row">
    <div class="col-md-12">
      {% if patchset.cover_letter %}
      {% set msg = patchset.cover_letter %}
      {% else %}
      {% set msg = patchset.patches[0] %}
      {% endif %}
      <h3>
        {% if patchset.prefix %}
        {{patchset.prefix}}:
        {% endif %}
        {{patchset.subject}}
        <small>v{{patchset.version}}</small>
        <span class="pull-right {{status_to_color[patchset.status]}}">
          {{patchset.status.value.replace("_", " ").upper()}}
        </span>
      </h3>
      {% if patchset.cover_letter %}
      {{ msg_header(msg) }}
      {% endif %}
    </div>
  </div>
  <div class="row">
    <div class="col-md-8">
      {% if patchset.cover_letter %}
      <pre class="message-body">{{ format_body(msg) }}</pre>
      {% endif %}
      {% for feedback in feedback[msg.id].standalone_feedback %}
      {% set msg = feedback.source_msg._email %}
      {% if not msg.is_patch %}
      {{ display_msg(msg, body="\n".join(feedback.lines)) }}
      {% endif %}
      {% endfor %}
    </div>
    <div class="col-md-4">
      <a class="btn btn-primary btn-block" href="{{ url_for('patches.mbox',
        owner_name=owner.canonical_name, list_name=ml.name,
        patchset_id=patchset.id) }}"
      >Export patchset (mbox) {{icon('caret-right')}}</a>
      <div class="event-list">
        <details class="event">
          <summary>How do I use this?</summary>
          <p>
            Copy &amp; paste the following snippet into your terminal to
            import this patchset into git:
          </p>
          <pre>curl -s {{root}}{{ url_for('archives.mbox',
            owner_name=owner.canonical_name, list_name=ml.name,
            message_id=thread.message_id) }} | git am -3</pre>
          <a
            href="https://git-send-email.io/"
            target="_blank"
            class="btn btn-link btn-block"
          >Learn more about email &amp; git {{icon('caret-right')}}</a>
        </details>
      </div>
      {% if current_user and current_user.id == ml.owner_id %}
      {# TODO: Better ACLs so non-owners can do this too #}
      <div class="event-list" style="margin-top: 1rem">
        <form
          class="event"
          method="POST"
          action="{{url_for('patches.patchset_update',
            owner_name=owner.canonical_name, list_name=ml.name,
            patchset_id=patchset.id)}}"
        >
          {{csrf_token()}}
          <div class="form-group">
            <select
              name="status"
              id="status"
              class="form-control"
            >
              {% for opt in PatchsetStatus %}
              <option
                value="{{opt.value}}"
                {% if patchset.status == opt %}
                selected
                {% endif %}
              >{{opt.value.replace("_", " ").upper()}}</option>
              {% endfor %}
            </select>
          </div>
          <button
            type="submit"
            class="btn btn-success pull-right"
          >Update {{icon('caret-right')}}</button>
          <div class="clearfix"></div>
        </form>
      </div>
      {% endif %}
    </div>
  </div>
  <div class="row">
    <div class="col-md-12">
      {% for msg in patches %}
      <h3>
        {{msg.subject}}
        <a href="{{ url_for("archives.raw",
                  owner_name=ml.owner.canonical_name,
                  list_name=ml.name,
                  message_id=msg.message_id
        ) }}" class="btn btn-link pull-right">
          Export this patch {{icon('caret-right')}}
        </a>
      </h3>
      {{ display_msg(msg) }}
      {% endfor %}
      <a class="btn btn-link btn-block" href="{{ url_for('archives.thread',
        owner_name=owner.canonical_name, list_name=ml.name,
        message_id=thread.message_id) }}"
      >View this thread in the archives {{icon('caret-right')}}</a>
    </div>
  </div>
</div>
{% endblock %}