Skip to content

Commit

Permalink
Merge pull request #18 from NBISweden/search-function
Browse files Browse the repository at this point in the history
Search function
  • Loading branch information
darthvader2 authored Jun 14, 2024
2 parents fed24f7 + 4162db6 commit 052039b
Show file tree
Hide file tree
Showing 15 changed files with 148 additions and 5,303 deletions.
22 changes: 15 additions & 7 deletions header_extractor.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,22 +24,30 @@ type StringAttribute struct {
Value string `xml:"VALUE"`
}

// Function to extract header value from XML content
func getHeaderValueFromXMLContent(xmlContent []byte) (string, error) {
func getHeaderValueFromXMLContent(xmlContent []byte) (string, string, error) {
var landingPageSet LandingPageSet
err := xml.Unmarshal(xmlContent, &landingPageSet)
if err != nil {
log.Fatal("Unmarshalling XML file for header failed", err)
log.Fatal("Unmarshalling XML file failed", err)
}

// Iterate over the string attributes to find the header value
var header, doi string

// Iterate over the string attributes to find the header and doi values
for _, attr := range landingPageSet.LandingPage.Attributes.StringAttributes {
if attr.Tag == "header" {
return attr.Value, nil
switch attr.Tag {
case "header":
header = attr.Value
case "doi":
doi = attr.Value
}
}
return "sf", err

if header == "" {
return "", "", err
}

return header, doi, nil
}

// Function to read the XML file and return its content
Expand Down
5 changes: 3 additions & 2 deletions markdown_writer.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ func markDownCreator() {
if err != nil {
log.Fatalf("Error reading the XML file %V", err)
}
headerValue, err := getHeaderValueFromXMLContent(xmlContent)
headerValue, doiValue, err := getHeaderValueFromXMLContent(xmlContent)
if err != nil {
log.Fatal("Error while getting header value from XML file", err)
}
Expand All @@ -52,13 +52,14 @@ func markDownCreator() {
// Markdown content
markdownContent := fmt.Sprintf(`---
title: "%s"
doi: "%s"
---
{{< datafetch variable="%s" >}}
Filename of the associated XML file: %s
`, headerValue, fileNameWithoutExt, xmlFileName)
`, headerValue, doiValue, fileNameWithoutExt, xmlFileName)

// Create Markdown file
mdFileName := filepath.Join(markdownDir, fileNameWithoutExt+".md")
Expand Down
6 changes: 6 additions & 0 deletions static_files_uploader.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,12 @@ func staticSiteUploader(DeploymenClient *DeploymentBackend) {
if ext == ".svg" {
contentType = "image/svg+xml;"
}
if ext == ".js" {
contentType = "application/javascript;"
}
if ext == ".xml" {
contentType = "application/xml;"
}

if err != nil {
log.Fatalln("File bytes empty", path, err)
Expand Down
9 changes: 8 additions & 1 deletion web/README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,9 @@
# hugo.bp.datasets.nbis.se
# Bigpicture landing pages web components

Bigpicture landing pages and data description pages using HUGO

## Start Development server
```
hugo server --disableFastRender
```

2 changes: 1 addition & 1 deletion web/content/datasets/_index.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
title: "Search"
title: "Dataset search"
date: 2024-03-20T10:31:33+01:00
layout: test
---
7 changes: 2 additions & 5 deletions web/layouts/_default/baseof.html
Original file line number Diff line number Diff line change
@@ -1,21 +1,18 @@
<!DOCTYPE html>
<html lang="{{ .Site.LanguageCode }}">
<html lang="{{ .Site.LanguageCode }}">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
{{ partial "head.html" . }}

<body>
{{ partial "nav.html" . }}
<!-- Page Header -->

<header class="page-header" ,role="banner" >
<h1 class="project-name" >{{ .Site.Title}} </h1>
<h2 class="project-tagline">{{ .Site.Params.slogan }}</h2>
</header>
<main id="content" class="main-content" role="main">
{{ block "main" . }}

{{ end }}

</main>
{{ partial "footer.html" . }}
</body>
</html>
29 changes: 16 additions & 13 deletions web/layouts/datasets/list.html
Original file line number Diff line number Diff line change
@@ -1,17 +1,20 @@
{{ define "main" }}
<h2> Bigpicture Datasets</h2>
<div class="datasets-cards-parent-container">
{{ range .Pages }}
<div class="dataset-card">
<div class="dataset-card-top-section">
<div class="dataset-card-image"><img src="{{.Site.BaseURL}}/img/bigpicture_logo.svg" alt="sdf"></div>
<div class="dataset-card-title"><h4>{{ .Params.title }}</h4></div>
</div>
<div class="dataset-card-bottom-section">
<div class="dataset-card-doi"><p>DOI: {{.Params.doi}}</p></div>
<div class="dataset-card-descrition"></div>
</div>
</div>
{{end}}
</div>

<div id="search">
<script>
window.addEventListener('DOMContentLoaded', (event) => {
new PagefindUI({ element: "#search", showSubResults: true });
});
</script>
<ul data-pagefind-ignore >
{{ range .Pages }}
<a href="{{ .RelPermalink }}"><p>{{ .Params.title }}</p></a>

{{ end }}
</ul>
{{ .Content }}

{{ .Content }}
{{ end }}
40 changes: 29 additions & 11 deletions web/layouts/index.html
Original file line number Diff line number Diff line change
@@ -1,17 +1,35 @@
{{ define "main" }}
<div data-pagefind-ignore="all" class="container">
<main id="content" class="main-content" role="main" >
<h2>NOTICE (Please read the following notice carefully)</h2>
<br/>
This website is openly accessible to Everyone on the Internet, because the purpose of Dataset description pages / DOI landing pages is to be accessible to anyone on the Internet.
<br/>
The reason for Dataset description pages / DOI landing pages to be openly accessible to anyone on the Internet, is so that a potential user can learn<br/>
1) that a dataset exists,<br/>
2) how it can be used, <br/>
3) why they should bother applying for access, and how to apply for access.
<br/>



<script>
window.addEventListener('DOMContentLoaded', (event) => {
new PagefindUI({ element: "#search", showSubResults: true });
});

</script>
<h2>Bigpicture Dataset search</h2>
<div style="max-height: 1%;">
<div id="search" style="overflow-x: auto;">
</div>
</div>
<h2 style="margin-top: 5rem;">Explore Bigpicture datasets</h2>
<div class="datasets-cards-parent-container">
{{ range where .Site.RegularPages "Section" "datasets" }}
<div class="dataset-card">
<div class="dataset-card-top-section">
<div class="dataset-card-image"><img src="{{.Site.BaseURL}}/img/bigpicture_logo.svg" alt="sdf"></div>
<div class="dataset-card-title"><a href="{{ .RelPermalink }}"><h4>{{ .Params.title }}</h4></a></div>
</div>
<div class="dataset-card-bottom-section">
<div class="dataset-card-doi"><p>DOI: {{.Params.doi}}</p></div>
<div class="dataset-card-descrition"></div>
</div>
</div>
{{end}}
</div>


</main>

</div>
Expand Down
16 changes: 6 additions & 10 deletions web/layouts/partials/footer.html
Original file line number Diff line number Diff line change
@@ -1,13 +1,9 @@
<footer class="site-footer">
<div class="columns">

<div class="column text-center">
<a href="https://bigpicture.eu/">About</a>
</div>
<div class="column text-right">
<a href="/datasets/">Datasets</a>
</div>
</div>

<div class = "footer-columns">
<div class="footer-container" >
<img style="height: 100px;" src="{{.Site.BaseURL}}/img/bigpicture_logo.svg">
</div>
<div class="footer-container" >© 2024 BIGPICTURE</div>
</div>
</footer>

2 changes: 1 addition & 1 deletion web/layouts/partials/head.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
<meta name="keyword" content="{{ .Site.Params.keyword }}">
<link rel="shortcut icon" href="{{ "img/favicon.ico" | relURL }}">

<title>{{ if .Title }}{{ .Title }} | {{ .Site.Params.SEOTitle }}{{ else }}{{ .Site.Params.SEOTitle }}{{ end }}</title>
<title data-pagefind-meta="title" >{{ if .Title }}{{ .Title }} | {{ .Site.Params.SEOTitle }}{{ else }}{{ .Site.Params.SEOTitle }}{{ end }}</title>

<link rel="canonical" href="{{ .RelPermalink }}">

Expand Down
17 changes: 1 addition & 16 deletions web/layouts/partials/nav.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,7 @@

<div class="topnav" id="navbar">

<script>
var navbar = document.getElementById('navbar');
var navbarHeight = navbar.offsetHeight;
window.addEventListener('scroll', function() {
if (window.scrollY > 0) {
navbar.classList.add('shrink');
} else {
navbar.classList.remove('shrink');
navbar.style.position = 'initial';
}
if (window.scrollY >= navbarHeight) {
navbar.style.position = 'fixed';
navbar.style.top = '0';
}
});
</script>


<div class="logo-nav-container">
<img id = "nav-logo" src="{{.Site.BaseURL}}/img/bigpicture_logo.svg">
Expand Down
Loading

0 comments on commit 052039b

Please sign in to comment.