Skip to content

Commit 4b3d3a7

Browse files
Merge pull request #1120 from USDA-SCINet/newsletter-components
Add newsletter components
2 parents 60bd808 + 208c034 commit 4b3d3a7

File tree

5 files changed

+133
-43
lines changed

5 files changed

+133
-43
lines changed

_includes/components/tables/md-table

Lines changed: 35 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -15,40 +15,40 @@
1515

1616
<div class="usa-table-container {{ tablediv }}">
1717
<table class="{{ tableclass }}">
18-
{%- if datas.caption %}
19-
<caption>
20-
{{ datas.caption }}
21-
</caption>
22-
{%- endif %}
23-
<thead>
24-
<tr>
25-
{% for _title in titles %}
26-
<th scope="col"{{ sortable }}>{{_title | strip }}</th>
27-
{% endfor %}
28-
</tr>
29-
</thead>
30-
<tbody>
31-
{% for _node in nodes %}
32-
{% unless rowcount < 2 %}
33-
{% assign colcount = 0 %}
34-
{% assign rowdata = _node | split: "|" %}
35-
<tr>
36-
{% for _col in rowdata %}
37-
{% if forloop.first %}
38-
<th data-label="{{ titles[colcount] | strip }}" scope="row"{% if datas.sortable %} role="rowheader"{% endif %} >
39-
{{ _col | strip | markdownify }}
40-
</th>
41-
{% else %}
42-
<td data-label="{{ titles[colcount] | strip }}">
43-
{{ _col | strip | markdownify }}
44-
</td>
45-
{% endif %}
46-
{% assign colcount = colcount | plus: 1 %}
47-
{% endfor %}
48-
</tr>
49-
{% endunless %}
50-
{% assign rowcount = rowcount | plus: 1 %}
51-
{% endfor %}
52-
</tbody>
18+
{%- if datas.caption %}
19+
<caption>
20+
{{ datas.caption }}
21+
</caption>
22+
{%- endif %}
23+
<thead>
24+
<tr>
25+
{% for _title in titles %}
26+
<th scope="col"{{ sortable }}>{{_title | strip }}</th>
27+
{% endfor %}
28+
</tr>
29+
</thead>
30+
<tbody>
31+
{% for _node in nodes %}
32+
{% unless rowcount < 2 %}
33+
{% assign colcount = 0 %}
34+
{% assign rowdata = _node | split: "|" %}
35+
<tr>
36+
{% for _col in rowdata %}
37+
{% if forloop.first %}
38+
<th data-label="{{ titles[colcount] | strip }}" scope="row"{% if datas.sortable %} role="rowheader"{% endif %} >
39+
{{ _col | strip | markdownify }}
40+
</th>
41+
{% else %}
42+
<td data-label="{{ titles[colcount] | strip }}">
43+
{{ _col | strip | markdownify }}
44+
</td>
45+
{% endif %}
46+
{% assign colcount = colcount | plus: 1 %}
47+
{% endfor %}
48+
</tr>
49+
{% endunless %}
50+
{% assign rowcount = rowcount | plus: 1 %}
51+
{% endfor %}
52+
</tbody>
5353
</table>
5454
</div>

_includes/fellows

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
{%- assign fellows = include.fellows | default: page.fellows -%}
2+
{%- include layout/newsletter/fellows fellows=fellows -%}

_includes/layout/newsletter/emailcontent

Lines changed: 73 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
{%- assign emailcontent = emailcontent | replace: '<!--excerpt-->', '' %}
33
{% assign blankarray = "" | split: "" %}
44
{% assign emailarray = blankarray %}
5+
{% capture linebreak %}
6+
{% endcapture %}
57

68
{% assign uljoined = 0 %}
79
{% assign licount = 0 %}
@@ -10,6 +12,12 @@
1012
{% assign rownum = 0 %}
1113
{% assign colnum = 0 %}
1214
{% assign narrowcol = 0 %}
15+
{% assign currenttable = 0 %}
16+
{% assign currenttablediv = 0 %}
17+
{% assign codeblockend = 0 %}
18+
{% assign codeblockstart = 0 %}
19+
{% assign fellowimg = 0 %}
20+
{% assign tablebody = 0 %}
1321

1422
{%- assign emailnodes = emailcontent | split: '<' %}
1523
{% for _node in emailnodes %}
@@ -19,6 +27,8 @@
1927
{% assign nodedesc = subnode[0] | split: ' ' %}
2028
{% assign nodename = nodedesc | first %}
2129

30+
{% if subnode[1] %}{% assign nodecontent = subnode[1] %}{% endif %}
31+
2232
{% case nodename %}
2333
{% when 'p' %}
2434
{% assign emailarray = emailarray | push: '<p align="left" style="font-family: Helvetica, sans-serif; font-size: 10.5pt; color: rgb(0, 0, 0); margin-top: 0px; margin-bottom: 8pt; line-height: 130%; -ms-word-break: break-all; word-break: break-word;">' %}
@@ -53,8 +63,10 @@
5363
{% assign imgct = 1 %}
5464
{% if narrowcol == 1 %}
5565
{% capture htmlconts %}<{{ subnode[0] | replace: 'alt=', 'width="200" align="center" class="newsletter_template_image" style="max-width: 100%; width: 200px; height: auto !important;" alt=' | replace: 'src="/', 'src="https://scinet.usda.gov/' }}>{% endcapture %}
66+
{% elsif fellowimg == 1 %}
67+
{% capture htmlconts %}<{{ subnode[0] | replace: 'padding: 5px;', 'padding: 5px; height: auto !important;' | replace: 'src="/', 'src="https://scinet.usda.gov/' }}>{% endcapture %}
5668
{% else %}
57-
{% capture htmlconts %}<{{ subnode[0] | replace: 'alt="Figure', 'width="500" align="center" class="newsletter_template_image" style="max-width: 100%; width: 500px; height: auto !important;" alt="Figure' | replace: 'src="/', 'src="https://scinet.usda.gov/' }}></p>{% endcapture %}
69+
{% capture htmlconts %}<{{ subnode[0] | replace: 'alt="Figure', 'width="500" align="center" class="newsletter_template_image" style="max-width: 100%; width: 500px; height: auto !important; align: center;" alt="Figure' | replace: 'src="/', 'src="https://scinet.usda.gov/' }}></p>{% endcapture %}
5870
{% endif %}
5971
{% assign emailarray = emailarray | push: htmlconts %}
6072
{% when 'ul' %}
@@ -81,8 +93,31 @@
8193
{% assign uljoined = 0 %}
8294
{% endif %}
8395
{% assign emailarray = emailarray | push: '</ul>' %}
96+
{% when 'table' %}
97+
{% if currenttablediv > currenttable %}
98+
{% assign emailarray = emailarray | push:'<table cellspacing="0" cellpadding="10" style="border: 1px solid #000000; border-collapse: collapse;">' %}
99+
{% assign currenttable = currenttable | plus: 1 %}
100+
{% endif %}
101+
{% when '/table' %}
102+
{% if currenttablediv > 0 and currenttablediv == currenttable %}
103+
{% assign emailarray = emailarray | push:'</table>' %}
104+
{% assign currenttable = currenttable | minus: 1 %}
105+
{% endif %}
106+
{% when 'tbody' %}
107+
{% assign emailarray = emailarray | push: '<tbody>' %}
108+
{% assign tablebody = 1 %}
109+
{% when '/tbody' %}
110+
{% assign emailarray = emailarray | push: '</tbody>' %}
111+
{% assign tablebody = 0 %}
112+
{% when 'td' %}
113+
{% assign emailarray = emailarray | push: '<td style="border: 1px solid #000000; padding: 10px;" >' %}
114+
{% when 'th' %}
115+
{% capture thconts %}<th style="border: 1px solid #000000; padding: 10px; {%- if tablebody == 0 %}background-color: #f1f3f6;" bgcolor="#f1f3f6"{% else %}"{%- endif %} >{% endcapture %}
116+
{% assign emailarray = emailarray | push: thconts %}
84117
{% when 'div' %}
85-
{% if subnode[0] == 'div class="grid-row"' %}
118+
{% if subnode[0] == 'div class="fellows"' %}
119+
{% assign fellowimg = 1 %}
120+
{% elsif subnode[0] == 'div class="grid-row"' %}
86121
{% assign rownum = rownum | plus: 1 %}
87122
{% assign emailarray = emailarray | push:'<table cellspacing="10"><tbody><tr>' %}
88123
{% elsif subnode[0] == 'div class="grid-col-4"' %}
@@ -92,19 +127,35 @@
92127
{% elsif subnode[0] == 'div class="grid-col"' %}
93128
{% assign colnum = colnum | plus: 1 %}
94129
{% assign emailarray = emailarray | push:'<td>' %}
130+
{% elsif subnode[0] == 'div class="language-plaintext highlighter-rouge"' %}
131+
{% assign rownum = rownum | plus: 1 %}
132+
{% assign emailarray = emailarray | push:'<table cellspacing="10"><tbody><tr>' %}
133+
{% elsif subnode[0] == 'div class="highlight"' %}
134+
{% assign emailarray = emailarray | push:'<td bgcolor="#f1f3f6" style="padding: 10px; background-color: #f1f3f6; border: 2px solid #e6e6e6; font-family: monospace, serif; font-size: 10pt; color: rgb(0, 0, 0); line-height: 130%; -ms-word-break: break-all; word-break: break-word;">' %}
135+
{% assign codeblockstart = 1 %}
136+
{% elsif subnode[0] == 'div class="usa-table-container flex-scroll"' %}
137+
{% assign currenttable = 0 %}
138+
{% assign currenttablediv = currenttablediv | plus: 1 %}
95139
{% else %}
96-
<p><b>ALARM</b></p>
140+
<p><b>ALARM</b></p><code>{{ subnode }}</code>
97141
{% endif %}
98142
{% when '/div' %}
99-
{% if colnum == rownum %}
143+
{% if fellowimg == 1 %}
144+
{% assign fellowimg = 0 %}
145+
{% elsif codeblockend == 1 %}
146+
{% assign emailarray = emailarray | push: '</td>' %}
147+
{% assign codeblockend = 0 %}
148+
{% elsif currenttable < currenttablediv %}
149+
{% assign currenttablediv = 0 %}
150+
{% elsif colnum == rownum %}
100151
{% assign narrowcol = 0 %}
101152
{% assign emailarray = emailarray | push: '</td>' %}
102153
{% assign colnum = colnum | minus: 1 %}
103154
{% elsif rownum > colnum %}
104155
{% assign rownum = rownum | minus: 1 %}
105156
{% assign emailarray = emailarray | push: '</tr></tbody></table>' %}
106157
{% else %}
107-
<p><b>ALARM</b></p>
158+
<p><b>ALARM</b></p><code>{{ subnode }}</code>
108159
{% endif %}
109160
{% when 'ol' %}
110161
{% if licount == 1 %}
@@ -119,15 +170,31 @@
119170
{% assign uljoined = 0 %}
120171
{% endif %}
121172
{% assign emailarray = emailarray | push: '</ol>' %}
173+
{% when 'code' %}
174+
{% assign nodecontent = blankarray %}
175+
{% assign splitcode = subnode[1] | split: linebreak %}
176+
{% for _sc in splitcode %}
177+
{% assign nodecontent = nodecontent | push: _sc %}
178+
{% unless forloop.last %}
179+
{% assign nodecontent = nodecontent | push: '<br>' %}
180+
{% endunless %}
181+
{% endfor %}
182+
{% when '/code' %}
122183
{% when 'br' %}
123184
{% unless imgct == 1 %}
124185
{% assign emailarray = emailarray | push: '<br>' %}
125186
{% endunless %}
187+
{% when 'pre' %}
188+
{% when '/pre' %}
189+
{% if codeblockstart == 1 %}
190+
{% assign codeblockstart = 0 %}
191+
{% assign codeblockend = 1 %}
192+
{% endif %}
126193
{% else %}
127194
{% capture thistag %}<{{ nodename }}>{% endcapture %}
128195
{% assign emailarray = emailarray | push: thistag %}
129196
{% endcase %}
130-
{% if subnode[1] %}{% assign emailarray = emailarray | push: subnode[1] %}{% endif %}
197+
{% if subnode[1] %}{% assign emailarray = emailarray | push: nodecontent %}{% endif %}
131198
{% endif %}
132199
{% endfor %}
133200

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
{% capture linebreak %}
22
{% endcapture %}
3-
{% for fellow in page.fellows %}
4-
<img class="fellow_img margin-right-2" style="width: 200px; padding: 5px" align="left" src="/news/newsletter/{{ fellow.img }}" />
3+
{% for fellow in include.fellows %}
4+
<div class="fellows">
5+
<img class="fellow_img margin-right-2" style="width: 200px; padding: 5px;" align="left" alt="{{ fellow.name }}" src="/news/newsletter/{{ fellow.img }}" />
56
{% assign bfellow = fellow.bio | split: linebreak %}
67
{% for _b in bfellow %}
78
<p>{% if forloop.first %}<strong>{{ fellow.name }} </strong>{% endif %}{{ _b }}</p>
89
{% endfor %}
10+
</div>
911
{% endfor %}

_includes/layout/newsletter/nav

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,25 @@
2020
{%- endfor %}
2121
</td>
2222
</tr>
23+
{%- if page.alerts %}
24+
{%- for _alert in page.alerts %}
25+
<tr>
26+
<td>
27+
<table align="center" class="nl_table" style="width: 90%; border-collapse: collapse; background-color: #f0f0f0;" cellpadding="20" bgcolor="#f0f0f0" id="Alert">
28+
<tbody>
29+
<tr>
30+
<td style="width: 90%; text-align:left; padding: 10px; margin: 10px; font-style: italic; line-height: 130%; color: #131313;" align="left">
31+
{{ _alert.text }}
32+
</td>
33+
</tr>
34+
</tbody>
35+
</table>
36+
</td>
37+
</tr>
38+
{%- endfor %}
39+
<tr><td style="padding: 5px 20px 30px;">
40+
</td></tr>
41+
{%- endif %}
2342
<tr>
2443
<td>
2544
<table align="center" class="nl_table" style="width: 90%; border-collapse: collapse; background-color: #f0f0f0;" cellpadding="20" bgcolor="#f0f0f0" id="Table of Contents">

0 commit comments

Comments
 (0)