Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion ui/dev_server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ func main() {
http.Handle("/", fs) // Serve static files
http.Handle("/geonetheader", http.HandlerFunc(testUIhandler))
http.Handle("/geonetfooter", http.HandlerFunc(testUIhandler))
http.Handle(footer.ReturnFooterAssetPattern(), footer.ReturnFooterAssetServer())
http.Handle("/geonetheaderbasic", http.HandlerFunc(testUIhandler))

log.Println("starting server")
Expand Down Expand Up @@ -63,6 +62,7 @@ func testUIhandler(w http.ResponseWriter, req *http.Request) {
{
URL: "https://www.rcet.science",
LogoURL: "/example_extra_logo.png",
Alt: "RCET logo",
},
},
}
Expand Down
12 changes: 2 additions & 10 deletions ui/geonet_footer/footer.css
Original file line number Diff line number Diff line change
@@ -1,15 +1,7 @@
/* Projects that import the GeoNet header must contain the following CSS in
the HTML files that use it. These are CSS for some image/s, and extra styles on top of the standard
the HTML files that use it. These are extra styles on top of the standard
GeoNet Bootstrap.css file (which also needs to be present) */

.esi-logo {
object-fit: contain;
max-width: 180px;
max-height: 68.7px;
width: 100%;
height: 100%
}

/* Bootstrap overrides - this should be changed in the main Bootstrap file at some point*/
#footer .row {
width: auto !important;
Expand All @@ -18,4 +10,4 @@ GeoNet Bootstrap.css file (which also needs to be present) */
margin-top: 20px;
padding: 20px 0 20px;
border-top: 1px solid #e5e5e5;
}
}
37 changes: 15 additions & 22 deletions ui/geonet_footer/footer.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,8 @@ package geonet_footer

import (
"bytes"
"embed"
_ "embed"
"html/template"
"net/http"
"path"
)

//go:embed footer.html
Expand All @@ -21,22 +19,24 @@ var nhcLogo template.HTML
//go:embed images/toka_tu_ake_nhc_logo_stacked.svg
var nhcLogoStacked template.HTML

//go:embed images/footer_pngs/*
var FooterAssetServer embed.FS
//go:embed images/esnz_logo.svg
var esnzLogo template.HTML

const FOOTER_ASSET_DIR = "/images/footer_pngs/"
//go:embed images/esnz_logo_stacked.svg
var esnzLogoStacked template.HTML

type FooterConfig struct {
// Whether to use relative links in footer. If false, uses www.geonet.org.nz.
UseRelativeLinks bool
// The origin to be used at the beginning of GeoNet links in the footer.
// Cannot be changed.
Origin string
// The GeoNet, ESI, and NHC logos are fixed and cannot be changed.
GeoNetLogo template.HTML
EsiLogo string
NhcLogo template.HTML
NhcLogoStacked template.HTML
// The GeoNet, ESNZ, and NHC logos are fixed and cannot be changed.
GeoNetLogo template.HTML
EsnzLogo template.HTML
EsnzLogoStacked template.HTML
NhcLogo template.HTML
NhcLogoStacked template.HTML
// URLs for extra logos to be added to the footer can be passed in.
ExtraLogos []FooterLogo
// Set whether footer is a stripped down, basic version.
Expand All @@ -49,6 +49,8 @@ type FooterLogo struct {
URL string
// The URL to the logo image.
LogoURL string
// The alt text to add to the logo image.
Alt string
}

// ReturnGeoNetFooter returns HTML for the main GeoNet footer that
Expand All @@ -58,7 +60,8 @@ func ReturnGeoNetFooter(config FooterConfig) (template.HTML, error) {
var contents template.HTML

config.GeoNetLogo = geonetLogo
config.EsiLogo = path.Join(FOOTER_ASSET_DIR, "esi_logo_cropped_downsized.png")
config.EsnzLogo = esnzLogo
config.EsnzLogoStacked = esnzLogoStacked
config.NhcLogo = nhcLogo
config.NhcLogoStacked = nhcLogoStacked

Expand All @@ -72,13 +75,3 @@ func ReturnGeoNetFooter(config FooterConfig) (template.HTML, error) {
}
return template.HTML(b.String()), nil // nolint: gosec // The source is our HTML file.
}

// ReturnFooterAssetServer returns a handler for serving embedded PNGs for the footer.
func ReturnFooterAssetServer() http.Handler {
return http.FileServer(http.FS(FooterAssetServer))
}

// ReturnFooterAssetPattern returns the path pattern for the footer asset server.
func ReturnFooterAssetPattern() string {
return FOOTER_ASSET_DIR
}
13 changes: 8 additions & 5 deletions ui/geonet_footer/footer.html
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
<div class="row">
<div class="col-12 d-md-none pb-4">
<a target="_blank" href="https://earthsciences.nz" rel="external noopener noreferrer">
<img class="esi-logo" src={{.EsiLogo}} alt="Earth Sciences New Zealand logo">
{{.EsnzLogo}}
</a>
</div>
</div>
Expand All @@ -45,7 +45,7 @@
<div class="row">
<div class="col-12 d-md-none pb-4">
<a target="_blank" href="{{$logo.URL}}" rel="external noopener noreferrer">
<img src="{{$logo.LogoURL}}" width="150px">
<img src="{{$logo.LogoURL}}" width="150px" alt="{{$logo.Alt}}">
</a>
</div>
</div>
Expand All @@ -67,8 +67,11 @@
<div class="col-md-3 d-none d-md-block">
<div class="row d-flex align-items-center">
<div class="col-xl-6 col-12">
<a target="_blank" href="https://earthsciences.nz" rel="external noopener noreferrer">
<img class="esi-logo" src={{.EsiLogo}} alt="Earth Sciences New Zealand logo">
<a class="d-none d-xl-block pt-1" target="_blank" href="https://earthsciences.nz" rel="external noopener noreferrer">
{{.EsnzLogoStacked}}
</a>
<a class="d-block d-xl-none" target="_blank" href="https://earthsciences.nz" rel="external noopener noreferrer">
{{.EsnzLogo}}
</a>
</div>
<div class="col-xl-6 col-12">
Expand All @@ -84,7 +87,7 @@
<div class="row">
<div class="col-12">
<a target="_blank" href="{{$logo.URL}}" rel="external noopener noreferrer">
<img src="{{$logo.LogoURL}}" class="pt-3" width="100%">
<img src="{{$logo.LogoURL}}" class="pt-3" width="100%" alt="{{$logo.Alt}}">
</a>
</div>
</div>
Expand Down
Loading
Loading