feat(search): replace gitlab search with duckduckgo

todo: algolia
This commit is contained in:
curben 2019-06-07 18:39:51 +09:30
parent 105de8515c
commit a5d1791b14
3 changed files with 33 additions and 14 deletions

View File

@ -3,7 +3,7 @@
X-XSS-Protection: 1; mode=block X-XSS-Protection: 1; mode=block
X-Content-Type-Options: nosniff X-Content-Type-Options: nosniff
Content-Language: en Content-Language: en
Content-Security-Policy: default-src 'self'; child-src 'none'; connect-src 'none'; font-src 'none'; frame-src 'none'; img-src https: 'self'; manifest-src 'none'; media-src 'none'; object-src 'none'; prefetch-src 'none'; script-src https://cdnjs.cloudflare.com 'self'; style-src https://cdnjs.cloudflare.com 'self'; worker-src 'none'; base-uri 'none'; form-action 'none'; block-all-mixed-content; frame-ancestors 'none' Content-Security-Policy: default-src 'self'; child-src 'none'; connect-src 'none'; font-src 'none'; frame-src 'none'; img-src https: 'self'; manifest-src 'none'; media-src 'none'; object-src 'none'; prefetch-src 'none'; script-src https://cdnjs.cloudflare.com 'self'; style-src https://cdnjs.cloudflare.com 'self'; worker-src 'none'; base-uri 'none'; form-action https://duckduckgo.com; frame-ancestors 'none'; block-all-mixed-content
Referrer-Policy: no-referrer Referrer-Policy: no-referrer
Strict-Transport-Security: max-age=31536000 Strict-Transport-Security: max-age=31536000
Feature-Policy: accelerometer 'none'; autoplay 'none'; camera 'none'; document.domain 'none'; display-capture 'none'; encrypted-media 'none'; geolocation 'none'; gyroscope 'none'; magnetometer 'none'; microphone 'none'; midi 'none'; payment 'none'; sync-xhr 'none'; usb 'none' Feature-Policy: accelerometer 'none'; autoplay 'none'; camera 'none'; document.domain 'none'; display-capture 'none'; encrypted-media 'none'; geolocation 'none'; gyroscope 'none'; magnetometer 'none'; microphone 'none'; midi 'none'; payment 'none'; sync-xhr 'none'; usb 'none'

View File

@ -6,14 +6,19 @@
<% } %> <% } %>
<div class="searchContainer"> <div class="searchContainer">
<input class="searchBox" type="text" id="searchTxt" placeholder="Search..."> <form id="searchForm" method="post" action="https://duckduckgo.com/" target="_blank">
<a class="searchBtn no-underline" id="searchClick" href="#"> <input type="text" name="q" class="searchBox" id="searchTxt" placeholder="Search..." title="Search using DuckDuckGo">
<input type="hidden" name="kd" value="-1">
<input type="hidden" name="kg" value="p">
<input type="hidden" name="kae" value="#000">
<a class="searchBtn no-underline" id="searchClick">
<svg viewBox="0 0 512 512"> <svg viewBox="0 0 512 512">
<title>Search</title> <title>Search using DuckDuckGo</title>
<desc>Search icon</desc> <desc>Search icon</desc>
<use href="/svg/search.svg#search"/> <use href="/svg/search.svg#search"/>
</svg> </svg>
</a> </a>
</form>
</div> </div>
</nav> </nav>
<%/* Nav menu for mobile */%> <%/* Nav menu for mobile */%>
@ -24,14 +29,19 @@
<input id="mobile-menu-toggle" type="checkbox"/> <input id="mobile-menu-toggle" type="checkbox"/>
<ul class="mobile-nav-link"> <ul class="mobile-nav-link">
<div class="searchContainer"> <div class="searchContainer">
<input class="searchBox" type="text" id="searchTxtMob" placeholder="Search..."> <form id="searchFormMob" method="post" action="https://duckduckgo.com/" target="_blank">
<a class="searchBtn no-underline" id="searchClickMob" href="#"> <input type="text" name="q" class="searchBox" id="searchTxtMob" placeholder="Search..." title="Search using DuckDuckGo">
<input type="hidden" name="kd" value="-1">
<input type="hidden" name="kg" value="p">
<input type="hidden" name="kae" value="#000">
<a class="searchBtn no-underline" id="searchClickMob">
<svg viewBox="0 0 512 512"> <svg viewBox="0 0 512 512">
<title>Search</title> <title>Search using DuckDuckGo</title>
<desc>Search icon</desc> <desc>Search icon</desc>
<use href="/svg/search.svg#search"/> <use href="/svg/search.svg#search"/>
</svg> </svg>
</a> </a>
</form>
</div> </div>
<p><br></p> <p><br></p>
<% for (let i in theme.menu) { %> <% for (let i in theme.menu) { %>

View File

@ -1,16 +1,24 @@
// Search button function // Search button function
const searchClick = document.getElementById('searchClick') const searchClick = document.getElementById('searchClick')
searchClick.addEventListener('click', () => { searchClick.addEventListener('click', () => {
window.open('https://gitlab.com/search?utf8=%E2%9C%93&search=' + const searchTxt = document.getElementById('searchTxt')
document.getElementById('searchTxt').value + const searchForm = document.getElementById('searchForm')
'&group_id=&project_id=8306723&search_code=true&repository_ref=master')
}, false); searchTxt.value = searchTxt.value + ' site:curben.netlify.com'
searchForm.submit()
searchTxt.value = searchTxt.value.replace(' site:curben.netlify.com', '')
}, false)
const searchClickMob = document.getElementById('searchClickMob') const searchClickMob = document.getElementById('searchClickMob')
searchClickMob.addEventListener('click', () => { searchClickMob.addEventListener('click', () => {
window.open('https://gitlab.com/search?utf8=%E2%9C%93&search=' + const searchTxt = document.getElementById('searchTxtMob')
document.getElementById('searchTxtMob').value + const searchForm = document.getElementById('searchFormMob')
'&group_id=&project_id=8306723&search_code=true&repository_ref=master')
searchTxt.value = searchTxt.value + ' site:curben.netlify.com'
searchForm.submit()
searchTxt.value = searchTxt.value.replace(' site:curben.netlify.com', '')
}, false) }, false)
/* /*
@ -20,6 +28,7 @@ searchClickMob.addEventListener('click', () => {
* <script src> is executed. * <script src> is executed.
*/ */
document.addEventListener('DOMContentLoaded', () => { document.addEventListener('DOMContentLoaded', () => {
// Copy button // Copy button
const copyCode = new ClipboardJS('.copy-button', { const copyCode = new ClipboardJS('.copy-button', {
target: (trigger) => { target: (trigger) => {