Skip to content

Commit

Permalink
Merge pull request #89 from ivoa/iss88-search-index
Browse files Browse the repository at this point in the history
Add search capability
  • Loading branch information
JeremyMcCormick authored Nov 16, 2024
2 parents 9f38ee1 + f92923e commit 02a2da8
Show file tree
Hide file tree
Showing 273 changed files with 776 additions and 39 deletions.
12 changes: 4 additions & 8 deletions .github/actions/setup-hugo/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,16 @@ inputs:
hugo_version:
description: 'Version of Hugo to download'
required: false
default: '0.123.4'
default: '0.135.0'
runs:
using: 'composite'
steps:
- name: Cache Hugo
uses: actions/cache@v2
uses: actions/cache@v3
with:
path: ~/hugo
path: ./hugo-bin
key: ${{ runner.os }}-hugo-${{ inputs.hugo_version }}
- name: Download and extract Hugo
run: |
if [ ! -f ~/hugo ]; then
wget https://github.com/gohugoio/hugo/releases/download/v${{ inputs.hugo_version }}/hugo_${{ inputs.hugo_version }}_Linux-64bit.tar.gz
tar -zxvf hugo_${{ inputs.hugo_version }}_Linux-64bit.tar.gz
mv hugo ~/hugo
fi
make ./hugo-bin/.v${{ inputs.hugo_version }}
shell: bash
19 changes: 19 additions & 0 deletions .github/actions/setup-pagefind/action.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
name: 'Download and extract PageFind'
description: 'Downloads and extracts a specified version of PageFind'
inputs:
pagefind_version:
description: 'Version of PageFind to download'
required: false
default: '1.1.1'
runs:
using: 'composite'
steps:
- name: Cache PageFind
uses: actions/cache@v3
with:
path: ./pagefind-bin
key: ${{ runner.os }}-pagefind-${{ inputs.pagefind_version }}
- name: Download and extract PageFind
run: |
make ./pagefind-bin/.v${{ inputs.pagefind_version }}
shell: bash
7 changes: 5 additions & 2 deletions .github/workflows/deploy_main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,16 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v2
uses: actions/checkout@v4

- name: Setup Hugo
uses: ./.github/actions/setup-hugo

- name: Setup PageFind
uses: ./.github/actions/setup-pagefind

- name: Build the website
run: ~/hugo
run: make html

- name: Deploy the website
uses: Dylan700/sftp-upload-action@latest
Expand Down
7 changes: 5 additions & 2 deletions .github/workflows/deploy_version.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v2
uses: actions/checkout@v4

- name: Skip workflow for PRs from forks
shell: bash
Expand All @@ -29,8 +29,11 @@ jobs:
- name: Setup Hugo
uses: ./.github/actions/setup-hugo

- name: Setup PageFind
uses: ./.github/actions/setup-pagefind

- name: Build the website
run: ~/hugo -b https://webtest.ivoa.info/v/${{ env.BRANCH_NAME }}
run: BASEURL="https://webtest.ivoa.info/v/${{ env.BRANCH_NAME }}" make html

- name: Upload the branch version of the website
uses: Dylan700/sftp-upload-action@latest
Expand Down
14 changes: 11 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,15 +1,23 @@
# Generated files by hugo
# Generated files by Hugo
/public/
/resources/_gen/
/assets/jsconfig.json
hugo_stats.json

# tmp hugo file
# tmp Hugo file
.hugo_build.lock
/preview/

# ignore hugo in case you have installed it in the project directory
# ignore Hugo in case you have installed it in the project directory
/hugo
/hugo*.tar.gz
/hugo-bin/
/hugo-bin_old/

# Generated files by PageFind
/static/pagefind/

# ignore PageFind in case you have installed it in the project directory
/pagefind-bin/
/pagefind-bin_old/
/pagefind*.tar.gz
152 changes: 139 additions & 13 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,31 +3,72 @@ BOLD=$(shell tput bold)
NORMAL=$(shell tput sgr0)

HUGO_URL=https://github.com/gohugoio/hugo/releases/download
HUGO_VERSION=0.126.1
HUGO_VERSION=0.135.0
HUGO_ARCHIVE=hugo_extended_${HUGO_VERSION}_Linux-64bit.tar.gz
HUGO_DIR=hugo-bin
HUGO_DIR_OLD=hugo-bin_old
HUGO_VERSION_FILE=${HUGO_DIR}/.v${HUGO_VERSION}

PAGEFIND_URL=https://github.com/CloudCannon/pagefind/releases/download
PAGEFIND_VERSION=1.1.1
PAGEFIND_ARCHIVE=pagefind-v${PAGEFIND_VERSION}-x86_64-unknown-linux-musl.tar.gz
PAGEFIND_DIR=pagefind-bin
PAGEFIND_DIR_OLD=pagefind-bin_old
PAGEFIND_VERSION_FILE=${PAGEFIND_DIR}/.v${PAGEFIND_VERSION}
PAGEFIND_INDEX_DIR=static/pagefind
PAGEFIND_CMD=${PAGEFIND_DIR}/pagefind

DIR_PUBLIC=public
DIR_PUBLIC_TMP=.public_tmp

HUGO_CMD=${HUGO_DIR}/hugo

.PHONY: help install list-draft uninstall uninstall-hugo preview
.PHONY: help preview update-search-index clear-search-index list-draft html generate-public-pages clear-generated-public-pages index-public-pages clear-public-pages-index clear install uninstall uninstall-hugo uninstall-pagefind

#: Display this help (i.e. list all available targets). (DEFAULT TARGET)
help:
@echo "Make targets for ivoa-web"
@echo "make help - Display help (default target)."
@echo "make preview - Start the preview service (on port 1313). All required tools are installed/upgraded automatically, when needed."
@echo "make list-draft - List all draft pages (i.e. all pages only visible in preview mode)."
@echo "make install - Install Hugo (or upgrade it if a different version is set in Makefile)."
@echo "make uninstall - Uninstall Hugo."
@echo "\nMake targets for ivoa-web:\n"
@echo "* help Display help (default target).\n"
@echo "* preview Start the preview service (on port 1313). All required tools\n are installed/upgraded automatically, when needed.\n"
@echo "* html Generate the HTML version of the IVOA Website (with search\n index).\n"
@echo "* list-draft List all draft pages (i.e. all pages only visible in preview\n mode).\n"
@echo "* clear Delete local search index and generated public pages.\n"
@echo "* install Install Hugo and PageFind (or upgrade them if a different\n version is set in Makefile).\n"
@echo "* uninstall Uninstall Hugo and PageFind.\n"


#: Start the preview service (on port 1313). All required tools are installed/upgraded automatically, when needed.
preview: install list-draft
./local_preview.bash "${HUGO_DIR}"
preview: install update-search-index list-draft
./local_preview.bash "${HUGO_DIR}" "${PAGEFIND_INDEX_DIR}"

#: Update local search index (only for preview purpose). All pages (event draft) are generated with Hugo and then indexed by PageFind. The generated index is stored in the 'static/' directory in order to be available in preview mode.
update-search-index: clear-search-index ${PAGEFIND_INDEX_DIR}


${PAGEFIND_INDEX_DIR}:
@echo "- Generating search index..."

@if [ -d "${DIR_PUBLIC_TMP}" ]; then \
rm -rf "${DIR_PUBLIC_TMP}"; \
fi

@if [ -d "${PAGEFIND_INDEX_DIR}" ]; then \
rm -rf "${PAGEFIND_INDEX_DIR}"; \
fi

@mkdir "${DIR_PUBLIC_TMP}" \
&& ${HUGO_CMD} -d "${DIR_PUBLIC_TMP}" -DEF \
&& ${PAGEFIND_CMD} --site "${DIR_PUBLIC_TMP}" \
&& cp -r "${DIR_PUBLIC_TMP}/pagefind" "${PAGEFIND_INDEX_DIR}" \
&& rm -rf "${DIR_PUBLIC_TMP}"

#: Delete the local search index.
clear-search-index:
@if [ -d "${PAGEFIND_INDEX_DIR}" ]; then \
echo "- Clearing search index (${PAGEFIND_INDEX_DIR})..."; \
rm -rf "${PAGEFIND_INDEX_DIR}"; \
fi

#: List all draft pages (i.e. all pages only visible in preview mode).
list-draft: install
@echo
Expand All @@ -39,9 +80,41 @@ list-draft: install
@echo "################################################################################"
@echo

#: Generate the HTML version of the IVOA Website (with search index).
html: install generate-public-pages index-public-pages

generate-public-pages: clear-generated-public-pages
@echo "- Generating the HTML pages..."
@echo "######################################################################"
@if [ -z "${BASEURL}" ]; then \
${HUGO_CMD} -d "${DIR_PUBLIC}" --ignoreCache; \
else \
echo "(with base URL: ${BASEURL})"; \
${HUGO_CMD} -b "${BASEURL}" -d "${DIR_PUBLIC}" --ignoreCache; \
fi
@echo "######################################################################\n"

clear-generated-public-pages:
@echo "- Deleting all generated public pages..."
@rm -rf "${DIR_PUBLIC}"


index-public-pages: clear-public-pages-index
@echo "- Indexing the generated public pages..."
@echo "######################################################################"
@${PAGEFIND_CMD} --site "${DIR_PUBLIC}"
@echo "######################################################################\n"


#: Install Hugo (or upgrade it if a different version is set in Makefile).
install: ${HUGO_VERSION_FILE}
clear-public-pages-index:
@rm -rf "${DIR_PUBLIC}/pagefind"


#: Delete local search index and generated public pages.
clear: clear-search-index clear-generated-public-pages

#: Install Hugo and PageFind (or upgrade them if a different version is set in Makefile).
install: ${HUGO_VERSION_FILE} ${PAGEFIND_VERSION_FILE}


${HUGO_VERSION_FILE}:
Expand Down Expand Up @@ -77,8 +150,44 @@ ${HUGO_VERSION_FILE}:
@touch ${HUGO_VERSION_FILE}


${PAGEFIND_VERSION_FILE}:
@if [ -d "${PAGEFIND_DIR}" ]; then \
echo "- Upgrading PageFind to v${PAGEFIND_VERSION}..."; \
else \
echo "- Installing PageFind..."; \
fi

@echo " - 1/6 - Downloading PageFind (version: ${PAGEFIND_VERSION})..."
@wget -q "${PAGEFIND_URL}/v${PAGEFIND_VERSION}/${PAGEFIND_ARCHIVE}"

@echo " - 2/6 - Deprecating existing PageFind version..."
@if [ -d "${PAGEFIND_DIR}" ]; then \
rm -rf "${PAGEFIND_DIR_OLD}"; \
mv "${PAGEFIND_DIR}" "${PAGEFIND_DIR_OLD}"; \
fi

@echo " - 3/6 - Installing PageFind in this directory (inside ${PAGEFIND_DIR})..."
@mkdir ${PAGEFIND_DIR} && tar -xzf ${PAGEFIND_ARCHIVE} -C ${PAGEFIND_DIR}/ && rm -f ${PAGEFIND_ARCHIVE}

@echo " - 4/6 - Giving execute permission..."
@chmod 775 ${PAGEFIND_CMD}

@echo " - 5/6 - Testing installation (and give version)...."
@${PAGEFIND_CMD} --version

@echo " - 6/6 - Removing deprecated Pagefind version..."
@if [ -d "${PAGEFIND_DIR_OLD}" ]; then \
rm -rf "${PAGEFIND_DIR_OLD}"; \
fi

@touch ${PAGEFIND_VERSION_FILE}


#: Uninstall everything (Hugo and PageFind).
uninstall: uninstall-hugo uninstall-pagefind

#: Uninstall Hugo.
uninstall:
uninstall-hugo:
@if [ -d "${HUGO_DIR}" ]; then \
if read -p "Uninstall Hugo? [Y/n] " confirm ; then \
if [ $${confirm:-'Y'} = 'n' ]; then \
Expand All @@ -92,3 +201,20 @@ uninstall:
else \
echo "INFO: Hugo is not installed. Nothing to do."; \
fi


#: Uninstall PageFind.
uninstall-pagefind:
@if [ -d "${PAGEFIND_DIR}" ]; then \
if read -p "Uninstall PageFind? [Y/n] " confirm ; then \
if [ $${confirm:-'Y'} = 'n' ]; then \
echo "=> Aborted"; \
else \
rm -rf ${PAGEFIND_DIR} \
&& echo "=> OK. PageFind successfully uninstalled." \
|| echo "=> ERROR: Failed to delete the directory '${PAGEFIND_DIR}'!"; \
fi \
fi \
else \
echo "INFO: PageFind is not installed. Nothing to do."; \
fi
1 change: 0 additions & 1 deletion content/deployers/intro_to_vo_concepts.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
---
title: "Introduction to VO concepts"
date:
draft: false
tags:
- about
Expand Down
4 changes: 2 additions & 2 deletions content/newsletter/005.md
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ collections of theoretical models.

{{</ side-image >}}

{{< side-image image="websampconnector_arch_big.png" thumbnail="websampconnector_arch.png" >}}
{{< side-image image="websampconnector_arch.png" thumbnail="websampconnector_arch.png" >}}

### WebSampConnector - Stay tuned in to the VO!

Expand Down Expand Up @@ -253,4 +253,4 @@ Research Initiative [Fathi et al., MNRAS, 406, 1595, (2010)].

[Subscribe to email notifications of the IVOA Newsletter](http://www.eso.org/lists/listinfo/ivoa-news)

[newsletter archives](http://www.ivoa.net/newsletter/archives.html)
[newsletter archives](http://www.ivoa.net/newsletter/archives.html)
4 changes: 2 additions & 2 deletions content/newsletter/019.md
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ easily discoverable and explorable.

{{</ side-image >}}

{{< side-image image="Gaia-DR2-flux-map.png.1" thumbnail="Gaia-DR2-flux-map.png" position="right" floating="true" >}}
{{< side-image image="Gaia-DR2-flux-map.png" thumbnail="Gaia-DR2-flux-map.png" position="right" floating="true" >}}

### Gaia DR2 in CDS Services

Expand Down Expand Up @@ -495,4 +495,4 @@ All [refereed publications](https://ui.adsabs.harvard.edu/#search/fq=%7B!type%3D
dedicated to hands-on exercises, which will allow participants to become fully
familiar with the VO capabilities on their own laptops.

{{< newsletter-social-links >}}
{{< newsletter-social-links >}}
7 changes: 7 additions & 0 deletions content/search.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
title: "Search IVOA pages"
---

Write keywords matching the IVOA website pages you are searching for.

{{< search-pages >}}
7 changes: 4 additions & 3 deletions layouts/_default/baseof.html
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
<!DOCTYPE html>
<html>
<html lang="en">
{{- partial "head.html" . -}}
<body>
{{- .Scratch.Set "canBeIndexed" (or (or (eq .BundleType "branch") (hasPrefix .Type "_")) (or (eq .Kind "term") (eq .Kind "taxonomy"))) }}
<body{{- if (.Scratch.Get "canBeIndexed") }} data-pagefind-ignore{{- end }}>
{{- partial "header.html" . -}}
<main>
<main {{- if not (.Scratch.Get "canBeIndexed") }} data-pagefind-body data-pagefind-meta="date:{{- .Date.Format "2006-01-02" }}"{{- end }}>
{{- block "main" . }}{{- end }}
</main>
{{- partial "sitemap.html" . -}}
Expand Down
2 changes: 1 addition & 1 deletion layouts/index.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{{ define "main" }}

<section class="with-only-right-aside">
<section class="with-only-right-aside" data-pagefind-ignore>
<main class="carrousel">
{{ range $elem_index, $elem_val := where .Site.Pages "Params.tags" "intersect" (slice "banner") }}
{{ if (eq $elem_index 0)}}
Expand Down
1 change: 1 addition & 0 deletions layouts/partials/header.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,6 @@
<a href="{{ .Site.Home.Permalink}}/deployers/">Deployers</a>
<a href="{{ .Site.Home.Permalink}}/members/">Members</a>
<a href="{{ .Site.Home.Permalink}}/about/">About</a>
<a class="search" href="{{ .Site.Home.Permalink}}/search/">Search</a>
</nav>
</header>
Loading

0 comments on commit 02a2da8

Please sign in to comment.