forked from googleforgames/agones
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Due to googleforgames#1668, saw that Hugo can fall over with: `fatal error: concurrent map read and map write` When there are lots of CPUs, so decided it was time to take the opportunity to update Hugo. Only big difference was to enable "unsafe" in the markdown engine, so that it would allow HTML in markdown.
- Loading branch information
1 parent
a34f001
commit ed5e42c
Showing
40 changed files
with
657 additions
and
70 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,188 @@ | ||
// Adapted from code by Matt Walters https://www.mattwalters.net/posts/hugo-and-lunr/ | ||
|
||
(function ($) { | ||
'use strict'; | ||
|
||
$(document).ready(function () { | ||
const $searchInput = $('.td-search-input'); | ||
|
||
// | ||
// Options for popover | ||
// | ||
|
||
$searchInput.data('html', true); | ||
$searchInput.data('placement', 'bottom'); | ||
$searchInput.data( | ||
'template', | ||
'<div class="popover offline-search-result" role="tooltip"><div class="arrow"></div><h3 class="popover-header"></h3><div class="popover-body"></div></div>' | ||
); | ||
|
||
// | ||
// Register handler | ||
// | ||
|
||
$searchInput.on('change', (event) => { | ||
render($(event.target)); | ||
|
||
// Hide keyboard on mobile browser | ||
$searchInput.blur(); | ||
}); | ||
|
||
// Prevent reloading page by enter key on sidebar search. | ||
$searchInput.closest('form').on('submit', () => { | ||
return false; | ||
}); | ||
|
||
// | ||
// Lunr | ||
// | ||
|
||
let idx = null; // Lunr index | ||
const resultDetails = new Map(); // Will hold the data for the search results (titles and summaries) | ||
|
||
// Set up for an Ajax call to request the JSON data file that is created by Hugo's build process | ||
$.ajax($searchInput.data('offline-search-index-json-src')).then( | ||
(data) => { | ||
idx = lunr(function () { | ||
this.ref('ref'); | ||
this.field('title', { boost: 2 }); | ||
this.field('body'); | ||
|
||
data.forEach((doc) => { | ||
this.add(doc); | ||
|
||
resultDetails.set(doc.ref, { | ||
title: doc.title, | ||
excerpt: doc.excerpt, | ||
}); | ||
}); | ||
}); | ||
|
||
$searchInput.trigger('change'); | ||
} | ||
); | ||
|
||
const render = ($targetSearchInput) => { | ||
// Dispose the previous result | ||
$targetSearchInput.popover('dispose'); | ||
|
||
// | ||
// Search | ||
// | ||
|
||
if (idx === null) { | ||
return; | ||
} | ||
|
||
const searchQuery = $targetSearchInput.val(); | ||
if (searchQuery === '') { | ||
return; | ||
} | ||
|
||
const results = idx | ||
.query((q) => { | ||
const tokens = lunr.tokenizer(searchQuery.toLowerCase()); | ||
tokens.forEach((token) => { | ||
const queryString = token.toString(); | ||
q.term(queryString, { | ||
boost: 100, | ||
}); | ||
q.term(queryString, { | ||
wildcard: | ||
lunr.Query.wildcard.LEADING | | ||
lunr.Query.wildcard.TRAILING, | ||
boost: 10, | ||
}); | ||
q.term(queryString, { | ||
editDistance: 2, | ||
}); | ||
}); | ||
}) | ||
.slice( | ||
0, | ||
$targetSearchInput.data('offlnie-search-max-results') | ||
); | ||
|
||
// | ||
// Make result html | ||
// | ||
|
||
const $html = $('<div>'); | ||
|
||
$html.append( | ||
$('<div>') | ||
.css({ | ||
display: 'flex', | ||
justifyContent: 'space-between', | ||
marginBottom: '1em', | ||
}) | ||
.append( | ||
$('<span>') | ||
.text('Search results') | ||
.css({ fontWeight: 'bold' }) | ||
) | ||
.append( | ||
$('<i>') | ||
.addClass('fas fa-times search-result-close-button') | ||
.css({ | ||
cursor: 'pointer', | ||
}) | ||
) | ||
); | ||
|
||
const $searchResultBody = $('<div>').css({ | ||
maxHeight: `calc(100vh - ${ | ||
$targetSearchInput.offset().top - | ||
$(window).scrollTop() + | ||
180 | ||
}px)`, | ||
overflowY: 'auto', | ||
}); | ||
$html.append($searchResultBody); | ||
|
||
if (results.length === 0) { | ||
$searchResultBody.append( | ||
$('<p>').text(`No results found for query "${searchQuery}"`) | ||
); | ||
} else { | ||
results.forEach((r) => { | ||
const doc = resultDetails.get(r.ref); | ||
const href = | ||
$searchInput.data('offline-search-base-href') + | ||
r.ref.replace(/^\//, ''); | ||
|
||
const $entry = $('<div>').addClass('mt-4'); | ||
|
||
$entry.append( | ||
$('<small>').addClass('d-block text-muted').text(r.ref) | ||
); | ||
|
||
$entry.append( | ||
$('<a>') | ||
.addClass('d-block') | ||
.css({ | ||
fontSize: '1.2rem', | ||
}) | ||
.attr('href', href) | ||
.text(doc.title) | ||
); | ||
|
||
$entry.append($('<p>').text(doc.excerpt)); | ||
|
||
$searchResultBody.append($entry); | ||
}); | ||
} | ||
|
||
$targetSearchInput.on('shown.bs.popover', () => { | ||
$('.search-result-close-button').on('click', () => { | ||
$targetSearchInput.val(''); | ||
$targetSearchInput.trigger('change'); | ||
}); | ||
}); | ||
|
||
$targetSearchInput | ||
.data('content', $html[0].outerHTML) | ||
.popover('show'); | ||
}; | ||
}); | ||
})(jQuery); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,4 +16,9 @@ | |
size: cover; | ||
}; | ||
|
||
} | ||
& > .byline { | ||
position: absolute; | ||
bottom: 2px; | ||
right: 4px; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
|
||
|
||
# UI strings. Botones y similares. | ||
|
||
[ui_pager_prev] | ||
other = "Previo" | ||
|
||
[ui_pager_next] | ||
other = "Siguiente" | ||
|
||
[ui_read_more] | ||
other = "Contiuar leyendo" | ||
|
||
[ui_search] | ||
other = "Buscar" | ||
|
||
# Used in sentences such as "Posted in News" | ||
[ui_in] | ||
other = "en" | ||
|
||
# Footer text | ||
[footer_all_rights_reserved] | ||
other = "Derechos reservados" | ||
|
||
[footer_privacy_policy] | ||
other = "Política de privacidad" | ||
|
||
|
||
# Post (blog, articles etc.) | ||
[post_byline_by] | ||
other = "Por" | ||
[post_created] | ||
other = "Creado" | ||
[post_last_mod] | ||
other = "Última modificación" | ||
[post_edit_this] | ||
other = "Editar esta página" | ||
[post_create_issue] | ||
other = "Notificar una incidencia con la documentanción" | ||
[post_create_project_issue] | ||
other = "Notificar una incidencia en un proyecto" | ||
[post_posts_in] | ||
other = "Añadir entrada" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
|
||
|
||
# UI strings. Buttons and similar. | ||
|
||
[ui_pager_prev] | ||
other = "Précédent" | ||
|
||
[ui_pager_next] | ||
other = "Suivant" | ||
|
||
[ui_read_more] | ||
other = "Lire plus" | ||
|
||
[ui_search] | ||
other = "Rechercher ce site…" | ||
|
||
# Used in sentences such as "Posted in News" | ||
[ui_in] | ||
other = "dans" | ||
|
||
# Footer text | ||
[footer_all_rights_reserved] | ||
other = "Tous droits résérvés" | ||
|
||
[footer_privacy_policy] | ||
other = "Politique de confidentialité" | ||
|
||
|
||
# Post (blog, articles etc.) | ||
[post_byline_by] | ||
other = "Par" | ||
[post_created] | ||
other = "Crée" | ||
[post_last_mod] | ||
other = "Dernière modification" | ||
[post_edit_this] | ||
other = "Modifier cette page" | ||
[post_create_issue] | ||
other = "Créer un problème dans la documentation" | ||
[post_create_project_issue] | ||
other = "Créer un problème dans le projet" | ||
[post_posts_in] | ||
other = "Messages dans" |
Oops, something went wrong.