Skip to content

Commit c5f599e

Browse files
committed
show tabs for boilerplate
1 parent f24d414 commit c5f599e

File tree

2 files changed

+36
-10
lines changed

2 files changed

+36
-10
lines changed

fmriprep/viz/report.tpl

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,10 +120,21 @@ div.boiler-text {
120120

121121
<div id="boilerplate">
122122
<h1 class="sub-report-title">Methods</h1>
123+
{% if boilerplate %}
123124
<p>We kindly ask to report results preprocessed with fMRIPrep using the following
124125
boilerplate</p>
125-
{% if boilerplate %}
126-
{{ boilerplate }}
126+
<ul class="nav nav-tabs" id="myTab" role="tablist">
127+
{% for b in boilerplate %}
128+
<li class="nav-item">
129+
<a class="nav-link {% if b[0] == 0 %}active{% endif %}" id="{{ b[1] }}-tab" data-toggle="tab" href="#{{ b[1] }}" role="tab" aria-controls="{{ b[1] }}" aria-selected="true">{{ b[1] }}</a>
130+
</li>
131+
{% endfor %}
132+
</ul>
133+
<div class="tab-content" id="myTabContent">
134+
{% for b in boilerplate %}
135+
<div class="tab-pane fade {% if b[0] == 0 %}show active{% endif %}" id="{{ b[1] }}" role="tabpanel" aria-labelledby="{{ b[1] }}-tab">{{ b[2] }}</div>
136+
{% endfor %}
137+
</div>
127138
{% else %}
128139
<p class="text-danger">Failed to generate the boilerplate</p>
129140
{% endif %}

fmriprep/viz/reports.py

Lines changed: 23 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -164,17 +164,32 @@ def _read_txt(path):
164164
return data
165165

166166
def generate_report(self):
167-
boilerplate = None
168167
logs_path = self.out_dir / 'fmriprep' / 'logs'
168+
169+
boilerplate = []
170+
boiler_idx = 0
171+
169172
if (logs_path / 'CITATION.html').exists():
170-
boilerplate = (logs_path / 'CITATION.html').read_text()
171-
boilerplate = re.compile(
173+
text = (logs_path / 'CITATION.html').read_text()
174+
text = re.compile(
172175
'<body>(.*?)</body>',
173-
re.DOTALL | re.IGNORECASE).findall(boilerplate)[0].strip()
174-
boilerplate = '<div class="boiler-text">%s</div>' % boilerplate
175-
176-
elif (logs_path / 'CITATION.md').exists():
177-
boilerplate = '<pre>%s</pre>' % (logs_path / 'CITATION.md').read_text()
176+
re.DOTALL | re.IGNORECASE).findall(text)[0].strip()
177+
text = '<div class="boiler-text">%s</div>' % text
178+
boilerplate.append((boiler_idx, 'HTML', text))
179+
boiler_idx += 1
180+
181+
if (logs_path / 'CITATION.md').exists():
182+
text = '<pre>%s</pre>' % (logs_path / 'CITATION.md').read_text()
183+
boilerplate.append((boiler_idx, 'Markdown', text))
184+
boiler_idx += 1
185+
186+
if (logs_path / 'CITATION.tex').exists():
187+
text = '<pre>%s</pre>\n' % (logs_path / 'CITATION.tex').read_text()
188+
text += '<h3>Bibliography</h3>\n'
189+
text += '<pre>%s</pre>' % Path(
190+
pkgrf('fmriprep', 'data/boilerplate.bib')).read_text()
191+
boilerplate.append((boiler_idx, 'LaTeX', text))
192+
boiler_idx += 1
178193

179194
searchpath = pkgrf('fmriprep', '/')
180195
env = jinja2.Environment(

0 commit comments

Comments
 (0)