Skip to content

Commit bc8b227

Browse files
committed
Merge branch 'feature/#190-add-versioning' into feature/#191-add-versioning-to-tour
2 parents 06d2cba + bc66c8f commit bc8b227

File tree

6 files changed

+60
-32
lines changed

6 files changed

+60
-32
lines changed

CHANGELOG.md

+4
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,10 @@
3131
<!-- addition of notable features. When PATCH is 0 it can -->
3232
<!-- be omitted -->
3333

34+
## ATT&CK Website version 2.1.1
35+
### Improvements
36+
- Improved matrix page header layout with versioning feature. See issue [#190](https://github.com/mitre-attack/attack-website/issues/190).
37+
3438
# Sub-techniques Beta
3539
## ATT&CK Website version 2.1
3640
### New Features

attack-theme/static/style/_matrix.scss

+7
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,11 @@
88
margin-top: to-rem(16);
99
}
1010

11+
.matrix-border {
12+
border-left: 1px solid border-color(body);
13+
padding-left: 0.5rem;
14+
}
15+
1116
.matrix-title {
1217
border-bottom: 1px solid border-color(body);
1318
margin-bottom: 1rem;
@@ -275,6 +280,8 @@ $sizeunit: 14px;
275280

276281

277282
.matrix-controls {
283+
margin: auto;
284+
width: 50%;
278285
padding: 1rem;
279286

280287
button {

attack-theme/templates/macros/matrix.html

+5-8
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,7 @@
66
tour_technique: the technique to use in the sub-techniques tour
77
isIndex: boolean, true if this matrix is going on the index page
88
-->
9-
{% import 'macros/versioning.html' as versioning %}
10-
11-
{% macro matrices(matrices, has_subtechniques, tour_technique, isIndex, output_file) %}
9+
{% macro matrices(matrices, has_subtechniques, tour_technique, isIndex) %}
1210
<div id="tour-matrix-container">
1311
{% if has_subtechniques %}
1412
<div class="matrix-controls">
@@ -41,18 +39,18 @@
4139
<div id="layouts-content">
4240
<div class="matrix-type side">
4341
{% for matrix in matrices %}
44-
{{ matrix_box('side', matrix, matrices | length, tour_technique, isIndex, output_file) }}
42+
{{ matrix_box('side', matrix, matrices | length, tour_technique, isIndex) }}
4543
{% endfor %}
4644
</div>
4745
<div class="matrix-type flat d-none">
4846
{% for matrix in matrices %}
49-
{{ matrix_box('flat', matrix, matrices | length, tour_technique, isIndex, output_file) }}
47+
{{ matrix_box('flat', matrix, matrices | length, tour_technique, isIndex) }}
5048
{% endfor %}
5149
</div>
5250
</div>
5351
{% else %}
5452
{% for matrix in matrices %}
55-
{{ matrix_box('side', matrix, matrices | length, tour_technique, isIndex, output_file) }}
53+
{{ matrix_box('side', matrix, matrices | length, tour_technique, isIndex) }}
5654
{% endfor %}
5755
{% endif %}
5856
</div>
@@ -68,7 +66,7 @@
6866
tour_technique: the technique to use in the matrix tour
6967
isIndex: boolean, is this matrix being displayed on the index page?
7068
-->
71-
{% macro matrix_box(whichmatrix, matrix, num_matrices, tour_technique, isIndex, output_file) %}
69+
{% macro matrix_box(whichmatrix, matrix, num_matrices, tour_technique, isIndex) %}
7270
<div class="matrix-container p-3">
7371
{% if num_matrices >1 %}
7472
<h3 class="text-center matrix-title">{{matrix.name}}</h3>
@@ -91,7 +89,6 @@ <h3 class="text-center matrix-title">{{matrix.name}}</h3>
9189
{% if not isIndex %}
9290
<div class="timestamp deemphasis text-center pt-3">Last modified: {{matrix.timestamp}}</div>
9391
{% set permalink_title = "the matrices" if matrix.tactics | length > 1 else "the matrix" %}
94-
{{ versioning.permalink_button(output_file, permalink_title, False)}}
9592
{% endif %}
9693
</div>
9794
{% endmacro %}

attack-theme/templates/macros/versioning.html

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,13 @@
55
<a data-toggle="tooltip"
66
data-placement="bottom"
77
title="permalink to this version of {{object_name}}"
8-
href="{{ output_file | permalink }}">version permalink</a>
8+
href="{{ output_file | permalink }}">Version Permalink</a>
99
</div>
1010
<div class="permalink">
1111
<a data-toggle="tooltip"
1212
data-placement="bottom"
1313
title="go to the live version of {{object_name}}"
14-
href="{{ output_file | permalink }}">live version</a><!--do not change this line without also changing versions.py-->
14+
href="{{ output_file | permalink }}">Live Version</a><!--do not change this line without also changing versions.py-->
1515
</div>
1616
</div>
1717
{% endmacro %}

attack-theme/templates/matrices/matrix.html

+41-21
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
{% set parsed = page.data | from_json %}
33
{% import 'macros/navigation.html' as navigation %}
44
{% import 'macros/matrix.html' as matrix_macros %}
5+
{% import 'macros/versioning.html' as versioning %}
56

67
{% if parsed.domain == "pre" %}
78
{% set title = "Matrix - PRE-ATT&CK | MITRE ATT&CK&reg;" -%}
@@ -37,33 +38,52 @@
3738
{% endif %}
3839
</ol>
3940
</div>
40-
<!-- only show navigator link if it's defined in the config -->
41-
{% if (parsed.navigator_link_enterprise and parsed.domain == 'enterprise') or (parsed.navigator_link_mobile and parsed.domain == 'mobile') %}
42-
<div class="col">
43-
<span class="h3 mt-3 float-right">
44-
<a href="{{ parsed.navigator_link_mobile if parsed.domain == 'mobile' else parsed.navigator_link_enterprise }}" class="btn btn-navy" target="_blank">Launch the ATT&amp;CK<sup>&reg;</sup> Navigator <img src="/theme/images/external-link.svg" width="10"></a>
45-
</span>
46-
</div>
47-
{% endif %}
4841
</div>
4942
<div class="tab-pane fade show active" id="v-attckmatrix" role="tabpanel" aria-labelledby="v-attckmatrix-tab">
50-
<div class="container-fluid">
51-
{% set matrix_plural = "Matrices" if (parsed.matrices | length > 1) else "Matrix" %}
5243

53-
<h1>{{parsed.name}} {{matrix_plural}}</h1>
44+
<div class="matrix-container p-3">
45+
{% set matrix_plural = "Matrices" if (parsed.matrices | length > 1) else "Matrix" %}
46+
<div class="row">
47+
<div class="col-md-9">
48+
<h1>{{parsed.name}} {{matrix_plural}}</h1>
5449

55-
<p>
56-
{{parsed.descr}}
57-
{% if parsed.platforms | length > 1 %}
58-
The {{matrix_plural}} contains information for the following platforms: {% for platform in parsed.platforms %}{%if loop.index != 1 %}, {% endif %}<a href="/matrices/{{platform.path}}">{{platform.name}}</a>{% endfor %}.
59-
{% elif parsed.platforms | length == 1 %}
60-
The {{matrix_plural}} contains information for the {{parsed.platforms[0].name}} platform.
61-
{% endif %}
62-
</p>
63-
<div class="pb-3">
64-
{{matrix_macros.matrices(parsed.matrices, parsed.has_subtechniques, parsed.tour_technique, False, output_file)}}
50+
<p>
51+
{{parsed.descr}}
52+
{% if parsed.platforms | length > 1 %}
53+
The {{matrix_plural}} contains information for the following platforms: {% for platform in parsed.platforms %}{%if loop.index != 1 %}, {% endif %}<a href="/matrices/{{platform.path}}">{{platform.name}}</a>{% endfor %}.
54+
{% elif parsed.platforms | length == 1 %}
55+
The {{matrix_plural}} contains information for the {{parsed.platforms[0].name}} platform.
56+
{% endif %}
57+
</p>
58+
</div>
59+
<div class="matrix-border col-md-3">
60+
<div class="col py-2">
61+
<!-- only show navigator link if it's defined in the config -->
62+
{% if (parsed.navigator_link_enterprise and parsed.domain == 'enterprise') or (parsed.navigator_link_mobile and parsed.domain == 'mobile') %}
63+
<div class="row p-2">
64+
<a href="{{ parsed.navigator_link_mobile if parsed.domain == 'mobile' else parsed.navigator_link_enterprise }}" target="_blank">View on the ATT&amp;CK<sup>&reg;</sup> Navigator <img src="/theme/images/external-site-dark.jpeg" width="10"></a>
65+
</div>
66+
{% endif %}
67+
<div class="row p-2">
68+
{% if parsed.domain == "pre" %}
69+
<a href="/resources/pre-introduction/">About the PRE-ATT&CK domain</a>
70+
{% elif parsed.domain == "enterprise" %}
71+
<a href="/resources/enterprise-introduction/">About the Enterprise domain</a>
72+
{% elif parsed.domain == "mobile" %}
73+
<a href="/resources/mobile-introduction/">About the Mobile domain</a>
74+
{% endif %}
75+
</div>
76+
<div class="row p-2">
77+
{% set permalink_title = "the matrices" if parsed.matrices | length > 1 else "the matrix" %}
78+
{{ versioning.permalink_button(output_file, permalink_title, False)}}
79+
</div>
80+
</div>
81+
</div>
6582
</div>
6683
</div>
84+
<div class="pb-3">
85+
{{matrix_macros.matrices(parsed.matrices, parsed.has_subtechniques, parsed.tour_technique, False)}}
86+
</div>
6787
</div>
6888
{% endblock %}
6989

modules/versions.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ def substitute_redirection(prefix, html_str):
185185
# update versioning button to show the permalink site version, aka "back to main site"
186186
html_str = html_str.replace("version-button live", "version-button permalink")
187187
# update live version links on the versioning button
188-
from_str = f"href=[\"']\/versions\/v\d+([{allowed_in_link}]+[\"']>live version<\/a>)"
188+
from_str = f"href=[\"']\/versions\/v\d+([{allowed_in_link}]+[\"']>Live Version<\/a>)"
189189
to_str = f'href="\g<1>'
190190
html_str = re.sub(from_str, to_str, html_str)
191191

0 commit comments

Comments
 (0)