Skip to content

Commit d3d8bb6

Browse files
authored
Merge branch '6-dev' into writing-docs-tips
2 parents 5099f34 + 38be3c7 commit d3d8bb6

File tree

11 files changed

+217
-17
lines changed

11 files changed

+217
-17
lines changed

docs/_static/custom.css

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,11 @@ img.figure,
5858
margin-bottom: 1rem;
5959
}
6060

61+
img.inline {
62+
margin: 0;
63+
height: 1em;
64+
}
65+
6166
span.linenos {
6267
padding-right: 1em;
6368
}
@@ -184,6 +189,25 @@ div.admonition.admonition-todo>.admonition-title::before {
184189
display: block;
185190
}
186191

192+
#search-form:focus-within #shortcut-page,
193+
.bd-search:focus-within #shortcut {
194+
display: none;
195+
}
196+
197+
#shortcut-page.input-group-text {
198+
padding-top: 0;
199+
padding-bottom: 0;
200+
}
201+
202+
input#q {
203+
border-radius: .25rem 0 0 .25rem;
204+
}
205+
206+
.form-control:focus {
207+
box-shadow: none;
208+
border-width: 2px;
209+
}
210+
187211
ul.search {
188212
margin-left: 0;
189213
}
@@ -234,6 +258,45 @@ ul.search li p.context {
234258
margin-left: 0;
235259
}
236260

261+
/* Search form sidebar */
262+
263+
.bd-search {
264+
font-size: .8rem;
265+
}
266+
267+
.bd-search:focus-within #search-input {
268+
border-radius: .25rem;
269+
}
270+
271+
#shortcut.input-group-text {
272+
padding-top: 0;
273+
padding-bottom: 0;
274+
}
275+
276+
.bd-search input,
277+
.bd-search .input-group-text {
278+
font-size: .8rem;
279+
padding-left: .5em;
280+
}
281+
282+
input#search-input {
283+
padding-left: 2.1875rem;
284+
border-radius: .25rem 0 0 .25rem;
285+
}
286+
287+
.search-icon {
288+
position: absolute;
289+
color: #a4a6a7;
290+
left: .625rem;
291+
z-index: 100;
292+
align-self: center;
293+
}
294+
295+
.input-group-text kbd {
296+
padding: 0rem 0.4rem;
297+
font-size: 135%;
298+
}
299+
237300
.pathseparator {
238301
padding: 0 0.7rem;
239302
}

docs/_static/search_shortcut.js

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
/**
2+
* Add shortcut `ctrl+k` to focus on search field
3+
*/
4+
5+
$(document).ready(() => {
6+
if (window.location.pathname === '/search.html') {
7+
$('form.bd-search .input-group').hide(); // Hide Sidebar Search field
8+
9+
$(document).keydown(function(event) {
10+
if ((event.ctrlKey || event.metaKey) && event.key == "k") {
11+
event.preventDefault();
12+
$('#q').focus();
13+
}
14+
});
15+
} else {
16+
$(document).keydown(function(event) {
17+
if ((event.ctrlKey || event.metaKey) && event.key == "k") {
18+
event.preventDefault();
19+
$('#search-input').focus();
20+
}
21+
});
22+
}
23+
24+
// if OS isn't Mac change visual indication of search field
25+
if (navigator.platform.indexOf('Mac') === -1) {
26+
$('#search-shortcut').html("^");
27+
$('#search-page-shortcut').html("^");
28+
}
29+
30+
});
31+
32+
function onReset() {
33+
$('#search-form').trigger('reset');
34+
$('#search-form').trigger('submit');
35+
}

docs/_static/searchtools.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -342,7 +342,10 @@ var Search = {
342342
else {
343343
Search.stopPulse();
344344
Search.title.text(_('Search Results'));
345-
if (!resultCount)
345+
if (query === '') {
346+
Search.status.text(_('No query, no results.'));
347+
}
348+
else if (!resultCount)
346349
Search.status.text(_('Your search did not match any documents. Please make sure that all words are spelled correctly. Searching for multiple words only shows matches that contain all words.'));
347350
else
348351
Search.status.text(_('Found %s page(s) matching the search query.').replace('%s', resultCount));

docs/_templates/search-field.html

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<form class="bd-search d-flex align-items-center" action="{{ pathto('search') }}" method="get">
2+
<div class="input-group">
3+
<label for="q" class="sr-only">Search string
4+
</label>
5+
<i class="fa fa-search fa-lg search-icon" aria-hidden="true"></i>
6+
<input
7+
type="search" name="q" id="search-input"
8+
class="form-control"
9+
placeholder="{{ _(theme_search_bar_text) }}"
10+
aria-labelledby="{{ _(theme_search_bar_text) }}"
11+
value="" autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false"
12+
/>
13+
<div class="input-group-append">
14+
<span class="input-group-text" id="shortcut">
15+
<kbd id="search-shortcut"></kbd>&nbsp;<kbd>K</kbd>
16+
</span>
17+
</div>
18+
</div>
19+
</form>

docs/_templates/search.html

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -48,20 +48,29 @@ <h1 id="search-documentation">{{ _('Search') }}</h1>
4848
>
4949
<div class="row">
5050
<div class="input-group col-xl-8 mb-2">
51+
<label for="q" class="sr-only">Search string
52+
</label>
5153
<input
52-
type="text" name="q" id="q"
53-
class="form-control"
54-
placeholder="Search the docs…"
55-
aria-labelledby="search-documentation" value="" autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false"/>
56-
<label for="q" class="sr-only">Search string</label>
54+
type="search" name="q" id="q"
55+
class="form-control"
56+
placeholder="{{ _(theme_search_bar_text) }}"
57+
aria-labelledby="{{ _(theme_search_bar_text) }}"
58+
value="" autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false"
59+
/>
5760
<div class="input-group-append">
58-
<button type="submit" class="btn btn-primary">{{ _('search') }}</button>
61+
<span class="input-group-text" id="shortcut-page">
62+
<kbd id="search-page-shortcut"></kbd>&nbsp;<kbd>K</kbd>
63+
</span>
5964
</div>
6065
<div class="input-group-append">
6166
<button
62-
type="button"
63-
class="clear_search btn btn-secondary"
64-
>{{ _('reset') }}</button>
67+
type="button"
68+
onclick="onReset()"
69+
class="btn btn-danger"
70+
><i class="fas fa-times"></i></button>
71+
</div>
72+
<div class="input-group-append">
73+
<button type="submit" class="btn btn-primary"><i class="fas fa-search fa-lg" aria-hidden="true"></i></button>
6574
</div>
6675
</div>
6776
</div>
@@ -70,7 +79,7 @@ <h1 id="search-documentation">{{ _('Search') }}</h1>
7079
<label for="doc_section" class="col sr-only">Filter by section</label>
7180
<div class="col">
7281
<div class="form-check">
73-
<input class="form-check-input" type="radio" name="doc_section" id="doc_section_all" value="all">
82+
<input class="form-check-input" type="radio" name="doc_section" id="doc_section_all" value="all" checked>
7483
<label class="form-check-label" for="doc_section_all">
7584
All Documentation
7685
</label>

docs/classic-ui/static-resources.md

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,80 @@ We often want to ship a website with a static resource, such as an image, icon,
1515
For this, we need to register static resources.
1616

1717

18+
(classic-ui-static-resources-registering-label)=
19+
## Registering javascript and css
20+
21+
To register a static resource in Plone 6, we need to use the `plone.base.interfaces.resources.IBundleRegistry` interface.
22+
23+
The following example registers a Javascript resource in `browser/profiles/default/registry` of your Plone 6 project.
24+
The js files have to be in the `browser/static` folder of your Plone 6 project.
25+
26+
```xml
27+
<registry>
28+
<records interface="plone.base.interfaces.resources.IBundleRegistry" prefix="plone.bundles/jscript">
29+
<value key="enabled">True</value>
30+
<value key="jscompilation">++plone++myproject.site/javascript.min.js</value>
31+
<value key="load_async">False</value>
32+
<value key="load_defer">False</value>
33+
<value key="depends">plone</value>
34+
</records>
35+
</registry>
36+
```
37+
38+
You can register a CSS resource in the same way.
39+
40+
```xml
41+
<registry>
42+
<records interface="plone.base.interfaces.resources.IBundleRegistry" prefix="plone.bundles/css">
43+
<value key="enabled">True</value>
44+
<value key="csscompilation">++plone++myproject.site/style.min.css</value>
45+
<value key="depends">plone</value>
46+
</records>
47+
</registry>
48+
```
49+
50+
Registering a js file and a css file in the same bundle is also possible.
51+
52+
```xml
53+
<registry>
54+
<records interface="plone.base.interfaces.resources.IBundleRegistry" prefix="plone.bundles/css">
55+
<value key="enabled">True</value>
56+
<value key="csscompilation">++plone++myproject.site/style.min.css</value>
57+
<value key="jscompilation">++plone++myproject.site/javascript.min.js</value>
58+
<value key="load_async">False</value>
59+
<value key="load_defer">False</value>
60+
<value key="depends">plone</value>
61+
</records>
62+
</registry>
63+
```
64+
1865
(classic-ui-static-resources-available-attributeslabel)=
1966

2067
## Available attributes
2168

69+
The following attributes are available for registering a static resource:
70+
71+
`enabled`
72+
: Whether the bundle is enabled or not. If it is disabled, the bundle will not be loaded.
73+
74+
`jscompilation`
75+
: The path to the compiled js file.
76+
77+
`csscompilation`
78+
: The path to the compiled css file.
79+
80+
`depends`
81+
: A list of bundles that this bundle depends on.
82+
83+
`load_async`
84+
: Whether the bundle should be loaded asynchronously or not. *Only JS*
85+
86+
`load_defer`
87+
: Whether the bundle should be loaded deferred or not. *Only JS*
88+
2289

2390
(classic-ui-static-resources-loading-order-label)=
2491

2592
## Loading order of resources
2693

94+
`depends` is used to define the loading order of resources, by specifying the name of the depending bundle.

docs/conf.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@
5757
"sphinx.ext.autosummary", # plone.api
5858
"sphinx.ext.graphviz",
5959
"notfound.extension",
60+
"sphinxcontrib.video",
6061
]
6162

6263
graphviz_output_format = "svg"
@@ -131,16 +132,15 @@
131132
"volto/developer-guidelines/branch-policy.md",
132133
]
133134

134-
html_js_files = [
135-
"patch_scrollToActive.js",
136-
]
135+
html_js_files = ["patch_scrollToActive.js", "search_shortcut.js"]
137136

138137
html_extra_path = [
139138
"robots.txt",
140139
]
141140

142141
html_static_path = [
143142
"_static",
143+
"volto/_static",
144144
]
145145

146146
# -- Options for myST markdown conversion to html -----------------------------
@@ -155,6 +155,7 @@
155155
# instead of ```.
156156
"substitution", # plone.restapi \
157157
# https://myst-parser.readthedocs.io/en/latest/syntax/optional.html#substitutions-with-jinja2
158+
"html_image",
158159
]
159160

160161
myst_substitutions = {
@@ -251,6 +252,7 @@
251252
"use_repository_button": True,
252253
"use_issues_button": True,
253254
"use_edit_page_button": True,
255+
"search_bar_text": "Search",
254256
"switcher": {
255257
"json_url": "/_static/switcher.json",
256258
"version_match": version,

docs/install/manage-add-ons-packages.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ make start-backend
147147
```
148148

149149
```{seealso}
150-
See the [documentation of `mxdev` in its README.rst](https://github.com/mxstack/mxdev/blob/main/README.rst) for complete information.
150+
See the [documentation of `mxdev` in its README.md](https://github.com/mxstack/mxdev/blob/main/README.md) for complete information.
151151
```
152152

153153

requirements.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,3 +17,4 @@ sphinxcontrib.httpdomain # plone.restapi
1717
sphinxcontrib.httpexample # plone.restapi
1818
sphinxext-opengraph
1919
sphinx-design
20+
sphinxcontrib-video

submodules/plone.restapi

Submodule plone.restapi updated 38 files

0 commit comments

Comments
 (0)