Skip to content

Commit d926bb4

Browse files
committed
Added button to view source of every page
1 parent 52adc00 commit d926bb4

File tree

7 files changed

+110
-11
lines changed

7 files changed

+110
-11
lines changed

Diff for: material/overrides/main.html

+3
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@
1414
<strong>Twitter</strong>
1515
</a>
1616
{% endblock %}
17+
{% block content %}
18+
{% include "overrides/partials/content.html" %}
19+
{% endblock %}
1720
{% block scripts %}
1821
{{ super() }}
1922
<script src="{{ 'overrides/assets/javascripts/bundle.641d98f2.min.js' | url }}"></script>

Diff for: material/overrides/partials/content.html

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
{#-
2+
This file was automatically generated - do not edit
3+
-#}
4+
{% if page.edit_url %}
5+
{% set edit = "https://github.com/squidfunk/mkdocs-material/edit" %}
6+
{% set view = "https://raw.githubusercontent.com/squidfunk/mkdocs-material" %}
7+
<a href="{{ page.edit_url }}" title="{{ lang.t('edit.link.title') }}" class="md-content__button md-icon">
8+
{% include ".icons/material/file-edit-outline.svg" %}
9+
</a>
10+
<a href="{{ page.edit_url | replace(edit, view) }}" title="View source of this page" class="md-content__button md-icon">
11+
{% include ".icons/material/file-eye-outline.svg" %}
12+
</a>
13+
{% endif %}
14+
{% if "tags" in config.plugins %}
15+
{% include "partials/tags.html" %}
16+
{% endif %}
17+
{% if not "\x3ch1" in page.content %}
18+
<h1>{{ page.title | d(config.site_name, true)}}</h1>
19+
{% endif %}
20+
{{ page.content }}
21+
{% if page and page.meta and (
22+
page.meta.git_revision_date_localized or
23+
page.meta.revision_date
24+
) %}
25+
{% include "partials/source-file.html" %}
26+
{% endif %}

Diff for: material/partials/content.html

+3-3
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22
This file was automatically generated - do not edit
33
-#}
44
{% if page.edit_url %}
5-
<a href="{{ page.edit_url }}" title="{{ lang.t('edit.link.title') }}" class="md-content__button md-icon">
6-
{% include ".icons/material/pencil.svg" %}
7-
</a>
5+
<a href="{{ page.edit_url }}" title="{{ lang.t('edit.link.title') }}" class="md-content__button md-icon">
6+
{% include ".icons/material/pencil.svg" %}
7+
</a>
88
{% endif %}
99
{% if "tags" in config.plugins %}
1010
{% include "partials/tags.html" %}

Diff for: mkdocs.yml

-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ site_description: >-
2929
# Repository
3030
repo_name: squidfunk/mkdocs-material
3131
repo_url: https://github.com/squidfunk/mkdocs-material
32-
edit_uri: ""
3332

3433
# Copyright
3534
copyright: Copyright &copy; 2016 - 2022 Martin Donath

Diff for: src/overrides/main.html

+5
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,11 @@
4343
</a>
4444
{% endblock %}
4545

46+
<!-- Content -->
47+
{% block content %}
48+
{% include "overrides/partials/content.html" %}
49+
{% endblock %}
50+
4651
<!-- Theme-related JavaScript -->
4752
{% block scripts %}
4853
{{ super() }}

Diff for: src/overrides/partials/content.html

+66
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
<!--
2+
Copyright (c) 2016-2022 Martin Donath <[email protected]>
3+
4+
Permission is hereby granted, free of charge, to any person obtaining a copy
5+
of this software and associated documentation files (the "Software"), to
6+
deal in the Software without restriction, including without limitation the
7+
rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
8+
sell copies of the Software, and to permit persons to whom the Software is
9+
furnished to do so, subject to the following conditions:
10+
11+
The above copyright notice and this permission notice shall be included in
12+
all copies or substantial portions of the Software.
13+
14+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16+
FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE
17+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
19+
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
20+
IN THE SOFTWARE.
21+
-->
22+
23+
<!-- Edit and view button -->
24+
{% if page.edit_url %}
25+
{% set edit = "https://github.com/squidfunk/mkdocs-material/edit" %}
26+
{% set view = "https://raw.githubusercontent.com/squidfunk/mkdocs-material" %}
27+
<a
28+
href="{{ page.edit_url }}"
29+
title="{{ lang.t('edit.link.title') }}"
30+
class="md-content__button md-icon"
31+
>
32+
{% include ".icons/material/file-edit-outline.svg" %}
33+
</a>
34+
<a
35+
href="{{ page.edit_url | replace(edit, view) }}"
36+
title="View source of this page"
37+
class="md-content__button md-icon"
38+
>
39+
{% include ".icons/material/file-eye-outline.svg" %}
40+
</a>
41+
{% endif %}
42+
43+
<!-- Tags -->
44+
{% if "tags" in config.plugins %}
45+
{% include "partials/tags.html" %}
46+
{% endif %}
47+
48+
<!--
49+
Hack: check whether the content contains a h1 headline. If it
50+
doesn't, the page title (or respectively site name) is used
51+
as the main headline.
52+
-->
53+
{% if not "\x3ch1" in page.content %}
54+
<h1>{{ page.title | d(config.site_name, true)}}</h1>
55+
{% endif %}
56+
57+
<!-- Markdown content -->
58+
{{ page.content }}
59+
60+
<!-- Source file information -->
61+
{% if page and page.meta and (
62+
page.meta.git_revision_date_localized or
63+
page.meta.revision_date
64+
) %}
65+
{% include "partials/source-file.html" %}
66+
{% endif %}

Diff for: src/partials/content.html

+7-7
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,13 @@
2222

2323
<!-- Edit button -->
2424
{% if page.edit_url %}
25-
<a
26-
href="{{ page.edit_url }}"
27-
title="{{ lang.t('edit.link.title') }}"
28-
class="md-content__button md-icon"
29-
>
30-
{% include ".icons/material/pencil.svg" %}
31-
</a>
25+
<a
26+
href="{{ page.edit_url }}"
27+
title="{{ lang.t('edit.link.title') }}"
28+
class="md-content__button md-icon"
29+
>
30+
{% include ".icons/material/pencil.svg" %}
31+
</a>
3232
{% endif %}
3333

3434
<!-- Tags -->

0 commit comments

Comments
 (0)