Skip to content

Commit b7e35b7

Browse files
sritasnghavinal
andcommitted
Add test for sample HTML template and update changelog
Signed-off-by: Sarita Singh <[email protected]> Co-authored-by: Avinal Kumar <[email protected]>
1 parent 75a744f commit b7e35b7

File tree

5 files changed

+927
-6
lines changed

5 files changed

+927
-6
lines changed

CHANGELOG.rst

+3
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,9 @@ Important API changes:
2727
that contains each package instance that can be aggregating data from
2828
multiple manifests for a single package instance.
2929

30+
- The data structure for HTML output has been changed to include emails and urls under the
31+
"infos" object. Now HTML template will output holders, authors, emails, and
32+
urls into separate tables like "licenses" and "copyrights".
3033

3134
Copyright detection:
3235
~~~~~~~~~~~~~~~~~~~~

tests/formattedcode/data/templated/sample-template.html

+101-3
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@
6262
</style>
6363
</head>
6464
<body>
65-
<p> Scanned with ScanCode version {{ version }} </p>
65+
<p> Scanned with ScanCode </p>
6666
{% if files.license_copyright %}
6767
<table>
6868
<caption>Copyrights and Licenses Information</caption>
@@ -104,7 +104,6 @@
104104
<th>type</th>
105105
<th>name</th>
106106
<th>extension</th>
107-
<th>date</th>
108107
<th>size</th>
109108
<th>sha1</th>
110109
<th>md5</th>
@@ -127,7 +126,6 @@
127126
<td>{{ row.type }}</td>
128127
<td>{{ row.name }}</td>
129128
<td>{{ row.extension }}</td>
130-
<td>{{ row.date }}</td>
131129
<td>{{ row.size }}</td>
132130
<td>{{ row.sha1 }}</td>
133131
<td>{{ row.md5 }}</td>
@@ -145,6 +143,106 @@
145143
{% endfor %}
146144
</tbody>
147145
</table>
146+
<table>
147+
<caption>Holders</caption>
148+
<thead>
149+
<tr>
150+
<th>path</th>
151+
<th>holder</th>
152+
<th>start</th>
153+
<th>end</th>
154+
</tr>
155+
</thead>
156+
<tbody>
157+
{% for path, row in files.infos.items() %}
158+
{% if row.holders %}
159+
{% for data in row.holders %}
160+
<tr>
161+
<td>{{ path }}</td>
162+
<td>{{ data.value }}</td>
163+
<td>{{ data.start_line }}</td>
164+
<td>{{ data.end_line }}</td>
165+
</tr>
166+
{% endfor %}
167+
{% endif %}
168+
{% endfor %}
169+
</tbody>
170+
</table>
171+
<table>
172+
<caption>Authors</caption>
173+
<thead>
174+
<tr>
175+
<th>path</th>
176+
<th>Author</th>
177+
<th>start</th>
178+
<th>end</th>
179+
</tr>
180+
</thead>
181+
<tbody>
182+
{% for path, row in files.infos.items() %}
183+
{% if row.authors %}
184+
{% for data in row.authors %}
185+
<tr>
186+
<td>{{ path }}</td>
187+
<td>{{ data.value }}</td>
188+
<td>{{ data.start_line }}</td>
189+
<td>{{ data.end_line }}</td>
190+
</tr>
191+
{% endfor %}
192+
{% endif %}
193+
{% endfor %}
194+
</tbody>
195+
</table>
196+
<table>
197+
<caption>Emails</caption>
198+
<thead>
199+
<tr>
200+
<th>path</th>
201+
<th>email</th>
202+
<th>start</th>
203+
<th>end</th>
204+
</tr>
205+
</thead>
206+
<tbody>
207+
{% for path, row in files.infos.items() %}
208+
{% if row.emails %}
209+
{% for data in row.emails %}
210+
<tr>
211+
<td>{{ path }}</td>
212+
<td>{{ data.email |urlize(target='_blank') }}</td>
213+
<td>{{ data.start_line }}</td>
214+
<td>{{ data.end_line }}</td>
215+
</tr>
216+
{% endfor %}
217+
{% endif %}
218+
{% endfor %}
219+
</tbody>
220+
</table>
221+
<table>
222+
<caption>Urls</caption>
223+
<thead>
224+
<tr>
225+
<th>path</th>
226+
<th>url</th>
227+
<th>start</th>
228+
<th>end</th>
229+
</tr>
230+
</thead>
231+
<tbody>
232+
{% for path, row in files.infos.items() %}
233+
{% if row.urls %}
234+
{% for data in row.urls %}
235+
<tr>
236+
<td>{{ path }}</td>
237+
<td>{{ data.url |urlize(target='_blank') }}</td>
238+
<td>{{ data.start_line }}</td>
239+
<td>{{ data.end_line }}</td>
240+
</tr>
241+
{% endfor %}
242+
{% endif %}
243+
{% endfor %}
244+
</tbody>
245+
</table>
148246
{% endif %}
149247

150248
{% if files.packages %}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,251 @@
1+
<!DOCTYPE html>
2+
3+
<html lang="en">
4+
5+
<head>
6+
<meta charset="utf-8">
7+
<title>Custom Template</title>
8+
<style type="text/css">
9+
table {
10+
border-collapse:collapse;
11+
border: 1px solid gray;
12+
margin-bottom: 20px;
13+
}
14+
td{
15+
padding: 5px 5px;
16+
border-style: solid;
17+
border-width: 1px;
18+
overflow: hidden;
19+
}
20+
th{
21+
padding:10px 5px;
22+
border-style: solid;
23+
border-width: 1px;
24+
overflow: hidden;
25+
border-color: gray;
26+
color: #fff;
27+
background-color: #5E81B7;
28+
}
29+
tr:nth-child(even) { background-color:#FFFFFF; }
30+
tr:nth-child(odd) { background-color:#F9F9F9; }
31+
tr:hover {background-color: #EEEEEE;}
32+
* {
33+
font-family: Helvetica, Arial, sans-serif;
34+
font-weight: normal;
35+
font-size: 12px;
36+
}
37+
</style>
38+
</head>
39+
<body>
40+
<p> Scanned with ScanCode </p>
41+
42+
<table>
43+
<caption>Copyrights and Licenses Information</caption>
44+
<thead>
45+
<tr>
46+
<th>path</th>
47+
<th>start</th>
48+
<th>end</th>
49+
<th>what</th>
50+
<th>value</th>
51+
</tr>
52+
</thead>
53+
<tbody>
54+
55+
56+
<tr>
57+
<td>simple/copyright_acme_c-c.c</td>
58+
<td>1</td>
59+
<td>1</td>
60+
<td>copyright</td>
61+
62+
<td>Copyright (c) 2000 ACME, Inc.</td>
63+
64+
</tr>
65+
66+
67+
</tbody>
68+
</table>
69+
70+
71+
72+
<table>
73+
<caption>File Information</caption>
74+
<thead>
75+
<tr>
76+
<th>path</th>
77+
<th>type</th>
78+
<th>name</th>
79+
<th>extension</th>
80+
<th>size</th>
81+
<th>sha1</th>
82+
<th>md5</th>
83+
<th>files_count</th>
84+
<th>mime_type</th>
85+
<th>file_type</th>
86+
<th>programming_language</th>
87+
<th>is_binary</th>
88+
<th>is_text</th>
89+
<th>is_archive</th>
90+
<th>is_media</th>
91+
<th>is_source</th>
92+
<th>is_script</th>
93+
</tr>
94+
</thead>
95+
<tbody>
96+
97+
<tr>
98+
<td>simple</td>
99+
<td>directory</td>
100+
<td>simple</td>
101+
<td></td>
102+
<td>0</td>
103+
<td>None</td>
104+
<td>None</td>
105+
<td></td>
106+
<td>None</td>
107+
<td>None</td>
108+
<td>None</td>
109+
<td>False</td>
110+
<td>False</td>
111+
<td>False</td>
112+
<td>False</td>
113+
<td>False</td>
114+
<td>False</td>
115+
</tr>
116+
117+
<tr>
118+
<td>simple/copyright_acme_c-c.c</td>
119+
<td>file</td>
120+
<td>copyright_acme_c-c.c</td>
121+
<td>.c</td>
122+
<td>55</td>
123+
<td>e2466d5b764d27fb301ceb439ffb5da22e43ab1d</td>
124+
<td>bdf7c572beb4094c2059508fa73c05a4</td>
125+
<td></td>
126+
<td>text/plain</td>
127+
<td>UTF-8 Unicode text, with no line terminators</td>
128+
<td>C</td>
129+
<td>False</td>
130+
<td>True</td>
131+
<td>False</td>
132+
<td>False</td>
133+
<td>True</td>
134+
<td>False</td>
135+
</tr>
136+
137+
</tbody>
138+
</table>
139+
<table>
140+
<caption>Holders</caption>
141+
<thead>
142+
<tr>
143+
<th>path</th>
144+
<th>holder</th>
145+
<th>start</th>
146+
<th>end</th>
147+
</tr>
148+
</thead>
149+
<tbody>
150+
151+
152+
153+
154+
155+
<tr>
156+
<td>simple/copyright_acme_c-c.c</td>
157+
<td>ACME, Inc.</td>
158+
<td>1</td>
159+
<td>1</td>
160+
</tr>
161+
162+
163+
164+
</tbody>
165+
</table>
166+
<table>
167+
<caption>Authors</caption>
168+
<thead>
169+
<tr>
170+
<th>path</th>
171+
<th>Author</th>
172+
<th>start</th>
173+
<th>end</th>
174+
</tr>
175+
</thead>
176+
<tbody>
177+
178+
179+
180+
181+
182+
</tbody>
183+
</table>
184+
<table>
185+
<caption>Emails</caption>
186+
<thead>
187+
<tr>
188+
<th>path</th>
189+
<th>email</th>
190+
<th>start</th>
191+
<th>end</th>
192+
</tr>
193+
</thead>
194+
<tbody>
195+
196+
197+
198+
199+
200+
</tbody>
201+
</table>
202+
<table>
203+
<caption>Urls</caption>
204+
<thead>
205+
<tr>
206+
<th>path</th>
207+
<th>url</th>
208+
<th>start</th>
209+
<th>end</th>
210+
</tr>
211+
</thead>
212+
<tbody>
213+
214+
215+
216+
217+
218+
</tbody>
219+
</table>
220+
221+
222+
223+
<table>
224+
<caption>Package Information</caption>
225+
<thead>
226+
<tr>
227+
<th>path</th>
228+
<th>type</th>
229+
<th>packaging</th>
230+
<th>primary_language</th>
231+
</tr>
232+
</thead>
233+
<tbody>
234+
235+
236+
237+
238+
239+
</tbody>
240+
</table>
241+
242+
243+
244+
</body>
245+
<footer>
246+
<p>Generated with ScanCode and provided on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
247+
No content created from ScanCode should be considered or used as legal advice. Consult an Attorney for any legal advice.
248+
ScanCode is a free software code scanning tool from nexB Inc. and others.
249+
Visit <a href="http://www.nexb.com/">http://www.nexb.com</a> and <a href="https://github.com/nexB/scancode-toolkit/">https://github.com/nexB/scancode-toolkit/</a> for support and download.
250+
</footer>
251+
</html>

0 commit comments

Comments
 (0)