From 7dcd8490f0aa50b21ecfdb68613350d8f57bfe9a Mon Sep 17 00:00:00 2001 From: Corey White Date: Tue, 2 Apr 2024 16:39:15 -0400 Subject: [PATCH 1/9] dowload: Upating layout of download pages --- content/learn/download.md | 2 +- themes/grass/assets/js/script.js | 41 ++++++++++++++++ themes/grass/layouts/learn/download.html | 59 ++++++++++++++++++++++++ 3 files changed, 101 insertions(+), 1 deletion(-) create mode 100644 themes/grass/layouts/learn/download.html diff --git a/content/learn/download.md b/content/learn/download.md index 2af086e7..6a434304 100644 --- a/content/learn/download.md +++ b/content/learn/download.md @@ -3,5 +3,5 @@ title: "Download" date: 2022-08-15T11:02:05+02:00 description: "Download GRASS GIS" weight: 1 -layout: "os" +layout: "download" --- \ No newline at end of file diff --git a/themes/grass/assets/js/script.js b/themes/grass/assets/js/script.js index 7069282b..48b070b7 100644 --- a/themes/grass/assets/js/script.js +++ b/themes/grass/assets/js/script.js @@ -61,4 +61,45 @@ $(this).html($(this).html() == 'View more' ? 'View less' : 'View more'); e.preventDefault(); }); + + function detectOSFromUserAgent() { + return new Promise((resolve) => { + const userAgent = window.navigator.userAgent; + + if (userAgent.includes("Win")) resolve("Windows"); + else if (userAgent.includes("Mac")) resolve("macOS"); + else if (userAgent.includes("Linux")) resolve("Linux"); + else if (userAgent.includes("Android")) resolve("Android"); + else if (userAgent.includes("like Mac") && /iPhone|iPad|iPod/.test(userAgent)) resolve("iOS"); + else resolve("Unknown OS"); + }); + } + + $(document).ready(function() { + (async () => { + const os = await detectOSFromUserAgent(); + const button = $(".grass-os-download-button"); + console.log(os); + // Add text and data based on the user's OS + switch (os) { + case "Windows": + button.text("Download for Windows"); + button.data("os", "windows"); + break; + case "macOS": + button.text("Download for macOS"); + button.data("os", "mac"); + break; + case "Linux": + button.text("Download for Linux"); + button.data("os", "linux"); + break; + default: + button.text("Download"); + button.data("os", "unknown"); + break; + } + })(jQuery); + }); + })(jQuery); diff --git a/themes/grass/layouts/learn/download.html b/themes/grass/layouts/learn/download.html new file mode 100644 index 00000000..c018fa75 --- /dev/null +++ b/themes/grass/layouts/learn/download.html @@ -0,0 +1,59 @@ +{{ partial "head.html" . }} + +{{ "" | safeHTML }} +
+
+ {{ partial "banner.html" . }} +
+
+ {{ partial "navigation.html" . }} +
+
+
+
+{{ "" | safeHTML }} + +
+
+
+
+

#Download

+
+
+
+ + +
+ +
+
+
Download
+
+
+ {{ with .Site.GetPage "download" "mac" }}{{ .Content }}{{ end }} +
+
+ {{ with .Site.GetPage "download" "windows" }}{{ .Content }}{{ end }} +
+
+ {{ with .Site.GetPage "download" "docker" }}{{ .Content }}{{ end }} +
+
+
+
+ + +{{ partial "footer.html" . }} \ No newline at end of file From 1a25173dcf805399b37de6bd50dddd88f89cdf4e Mon Sep 17 00:00:00 2001 From: Corey White Date: Wed, 3 Apr 2024 17:22:44 -0400 Subject: [PATCH 2/9] Added download, support, and code copy components --- data/grass.json | 11 ++++- themes/grass/assets/css/style.css | 48 +++++++++++++++++++ themes/grass/layouts/learn/download.html | 12 +++-- themes/grass/layouts/partials/code-copy.html | 23 +++++++++ .../layouts/partials/grass-download.html | 11 +++++ 5 files changed, 100 insertions(+), 5 deletions(-) create mode 100644 themes/grass/layouts/partials/code-copy.html create mode 100644 themes/grass/layouts/partials/grass-download.html diff --git a/data/grass.json b/data/grass.json index 8adc32a2..bffae4e9 100644 --- a/data/grass.json +++ b/data/grass.json @@ -10,5 +10,14 @@ "preview_version":"8.4.0", "preview_version_short":"8.4", "preview_version_underscore": "8_4", - "preview_version_nodots":"84" + "preview_version_nodots":"84", + "install": { + "mac_ports": { + "id": "mac_ports", + "title": "MacPorts", + "code": "sudo port install grass", + "url": "https://ports.macports.org/port/grass/" + } + } + } diff --git a/themes/grass/assets/css/style.css b/themes/grass/assets/css/style.css index 50ecd289..6fe3df07 100644 --- a/themes/grass/assets/css/style.css +++ b/themes/grass/assets/css/style.css @@ -1431,3 +1431,51 @@ code{ object-fit: cover; /* border: 4px solid var(--grass-color-dark); */ } + +.download-card { + max-width: 600px; /* Sets a max-width for the card */ + box-shadow: 0 4px 6px rgba(0,0,0,.1); /* Adds a subtle shadow to the card */ + border: none; /* Removes the default card border */ +} +.download-btn { + background-color: var(--grass-color); + border: none; /* Removes the border */ + padding: .75rem 1.5rem; /* Larger padding for the button */ + font-size: 1rem; /* Larger font size */ + color: var(--white-color); /* White text color */ +} +.download-btn:hover { + color: var(--white-color) !important; + background-color: var(--grass-color-alt); /* Darker blue on hover */ +} + +.support-btn { + background-color: hsl(334, 89%, 59%); + border: none; /* Removes the border */ + padding: .75rem 1.5rem; /* Larger padding for the button */ + font-size: 1rem; /* Larger font size */ + color: var(--white-color); /* White text color */ +} +.support-btn:hover, .support-btn:focus { + color: var(--white-color) !important; + background-color: hsla(334, 89%, 59%, 0.5); /* Darker blue on hover */ +} + +.code-container { + position: relative; + background-color: #777; +} +.btn-clipboard { + position: absolute; + top: .5rem; + right: .5rem; + z-index: 10; + display: block; + padding: .25rem .5rem; + font-size: 75%; + color: #ffffff; + cursor: pointer; + background-color: transparent; + border: 0; + border-radius: .25rem; +} \ No newline at end of file diff --git a/themes/grass/layouts/learn/download.html b/themes/grass/layouts/learn/download.html index c018fa75..e8020a1a 100644 --- a/themes/grass/layouts/learn/download.html +++ b/themes/grass/layouts/learn/download.html @@ -40,16 +40,20 @@

#Download

-
Download
+ {{ with .Site.GetPage "download" "linux" }}{{ .Content }}{{ end }}
- {{ with .Site.GetPage "download" "mac" }}{{ .Content }}{{ end }} + {{ $download_data := dict "os" "Mac" "url" "https://cmbarton.github.io/grass-mac/download/" "version" .Site.Data.grass.current_version }} + {{ partial "grass-download.html" $download_data }} + {{ partial "code-copy.html" .Site.Data.grass.install.mac_ports }}
- {{ with .Site.GetPage "download" "windows" }}{{ .Content }}{{ end }} + {{ $windows_url := printf "/grass%s/binary/mswindows/native/WinGRASS-%s-1-Setup.exe" .Site.Data.grass.current_version_nodots .Site.Data.grass.current_version }} + {{ $download_data := dict "os" "Windows" "url" $windows_url "version" .Site.Data.grass.current_version }} + {{ partial "grass-download.html" $download_data }}
- {{ with .Site.GetPage "download" "docker" }}{{ .Content }}{{ end }} + {{ with .Site.GetPage "download" "docker" }}{{ .Content }}{{ end }}
diff --git a/themes/grass/layouts/partials/code-copy.html b/themes/grass/layouts/partials/code-copy.html new file mode 100644 index 00000000..3b1ab5df --- /dev/null +++ b/themes/grass/layouts/partials/code-copy.html @@ -0,0 +1,23 @@ + + +
+

{{ .title }}

+ +
+
{{ .code }}
+ +
+
+ + \ No newline at end of file diff --git a/themes/grass/layouts/partials/grass-download.html b/themes/grass/layouts/partials/grass-download.html new file mode 100644 index 00000000..cd573898 --- /dev/null +++ b/themes/grass/layouts/partials/grass-download.html @@ -0,0 +1,11 @@ +
+

Download GRASS GIS for {{ .os }}

+

Click the button below to download the latest {{ .os }} version of GRASS GIS.

+ + Download GRASS GIS ( {{ .version }} ) + Support Us +
From 1c08129d51935efc4c97fb5b6ecbd76d6b688340 Mon Sep 17 00:00:00 2001 From: Corey White Date: Thu, 11 Apr 2024 15:25:36 -0400 Subject: [PATCH 3/9] Added code to auto select download option based on os --- themes/grass/assets/js/script.js | 12 ++++++++ themes/grass/layouts/learn/download.html | 37 ++++++++++++++++++++++++ 2 files changed, 49 insertions(+) diff --git a/themes/grass/assets/js/script.js b/themes/grass/assets/js/script.js index 48b070b7..bc9928f0 100644 --- a/themes/grass/assets/js/script.js +++ b/themes/grass/assets/js/script.js @@ -85,14 +85,26 @@ case "Windows": button.text("Download for Windows"); button.data("os", "windows"); + $('#downloadTab a[href="#windows"]').tab('show'); + if (window.location.pathname === "/learn/download/") { + window.location.hash = "windows"; + } break; case "macOS": button.text("Download for macOS"); button.data("os", "mac"); + $('#downloadTab a[href="#mac"]').tab('show'); + if (window.location.pathname === "/learn/download/") { + window.location.hash = "mac"; + } break; case "Linux": button.text("Download for Linux"); button.data("os", "linux"); + $('#downloadTab a[href="#linux"]').tab('show'); + if (window.location.pathname === "/learn/download/") { + window.location.hash = "linux"; + } break; default: button.text("Download"); diff --git a/themes/grass/layouts/learn/download.html b/themes/grass/layouts/learn/download.html index e8020a1a..0d81a33b 100644 --- a/themes/grass/layouts/learn/download.html +++ b/themes/grass/layouts/learn/download.html @@ -39,22 +39,59 @@

#Download

+
{{ with .Site.GetPage "download" "linux" }}{{ .Content }}{{ end }}
+ +
{{ $download_data := dict "os" "Mac" "url" "https://cmbarton.github.io/grass-mac/download/" "version" .Site.Data.grass.current_version }} {{ partial "grass-download.html" $download_data }} {{ partial "code-copy.html" .Site.Data.grass.install.mac_ports }}
+ +
{{ $windows_url := printf "/grass%s/binary/mswindows/native/WinGRASS-%s-1-Setup.exe" .Site.Data.grass.current_version_nodots .Site.Data.grass.current_version }} {{ $download_data := dict "os" "Windows" "url" $windows_url "version" .Site.Data.grass.current_version }} {{ partial "grass-download.html" $download_data }} + + + +
+
+
+

Additional Options

+
+
+

OSGeo4W

+

OSGeo4W is an installer for a broad set of open source geospatial software packages including GRASS GIS as well as many other packages (QGIS, GDAL/OGR, and more).

+ Download OSGeo4W v2 +
+
+
+
+

QGIS users

+

In order to have GRASS GIS support (also in QGIS-Processing) you need to install the “qgis*-grass-plugin” packages.

+
+
+
+
+
+ +
{{ with .Site.GetPage "download" "docker" }}{{ .Content }}{{ end }}
+
From 56be3ce8c1c79fade38e2fdb514efc520d3bc908 Mon Sep 17 00:00:00 2001 From: Corey White Date: Thu, 11 Apr 2024 16:00:38 -0400 Subject: [PATCH 4/9] Fixed issue with page jumping to id location --- themes/grass/assets/js/script.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/themes/grass/assets/js/script.js b/themes/grass/assets/js/script.js index bc9928f0..e5301724 100644 --- a/themes/grass/assets/js/script.js +++ b/themes/grass/assets/js/script.js @@ -76,6 +76,7 @@ } $(document).ready(function() { + // Detect the user's OS and update the download button text (async () => { const os = await detectOSFromUserAgent(); const button = $(".grass-os-download-button"); @@ -87,7 +88,7 @@ button.data("os", "windows"); $('#downloadTab a[href="#windows"]').tab('show'); if (window.location.pathname === "/learn/download/") { - window.location.hash = "windows"; + history.replaceState(null, null, "#windows"); } break; case "macOS": @@ -95,15 +96,14 @@ button.data("os", "mac"); $('#downloadTab a[href="#mac"]').tab('show'); if (window.location.pathname === "/learn/download/") { - window.location.hash = "mac"; + history.replaceState(null, null, "#mac"); } break; case "Linux": button.text("Download for Linux"); button.data("os", "linux"); - $('#downloadTab a[href="#linux"]').tab('show'); if (window.location.pathname === "/learn/download/") { - window.location.hash = "linux"; + history.replaceState(null, null, "#linux"); } break; default: From 56e5f87c99754a21f8a2d2aa4fa52da99bd5683e Mon Sep 17 00:00:00 2001 From: Corey White Date: Fri, 14 Jun 2024 12:39:12 -0400 Subject: [PATCH 5/9] Update content/learn/download.md Co-authored-by: Markus Neteler --- content/learn/download.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/content/learn/download.md b/content/learn/download.md index 6a434304..617df313 100644 --- a/content/learn/download.md +++ b/content/learn/download.md @@ -1,6 +1,6 @@ --- title: "Download" -date: 2022-08-15T11:02:05+02:00 +date: 2024-04-22T11:02:05+02:00 description: "Download GRASS GIS" weight: 1 layout: "download" From e6565a023818da331630efa39b6037526787bb57 Mon Sep 17 00:00:00 2001 From: Corey White Date: Mon, 30 Sep 2024 11:25:15 -0400 Subject: [PATCH 6/9] Updated pagess --- content/download/docker.en.md | 3 +++ content/download/linux.en.md | 5 +++-- themes/grass/assets/js/script.js | 8 ++++++-- 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/content/download/docker.en.md b/content/download/docker.en.md index fa306926..201d34ff 100644 --- a/content/download/docker.en.md +++ b/content/download/docker.en.md @@ -32,6 +32,9 @@ For a list of GRASS GIS versions, see the [docker tag list](https://hub.docker.c * {{< donateDialog isToggle=true isMarkdown=true >}}[ Ubuntu 22.04 based with GUI support](https://hub.docker.com/r/osgeo/grass-gis/tags?page=1&name=ubuntu_wxgui){{< /donateDialog >}} (1.3 GB, with wxPython, Python 3 and PDAL)
docker pull osgeo/grass-gis:releasebranch_{{< currentVersion.inline  >}}{{- .Site.Data.grass.current_version_underscore -}}{{}}-ubuntu_wxgui
+```bash +docker pull osgeo/grass-gis:releasebranch_{{< currentVersion.inline >}}{{- .Site.Data.grass.current_version_underscore -}}{{}}-ubuntu +```
diff --git a/content/download/linux.en.md b/content/download/linux.en.md index bd301c1a..59df3bec 100644 --- a/content/download/linux.en.md +++ b/content/download/linux.en.md @@ -10,11 +10,12 @@ layout: "os" [ [**GRASS GIS {{< grassVersion version="current" type="short">}} (current)**](#GRASS-GIS-current) | [**GRASS {{< grassVersion version="legacy" type="short">}} (legacy)**](#GRASS-GIS-old) | [**GRASS {{< grassVersion version="preview" type="short">}} (preview)**](#GRASS-GIS-devel) ] - Install grass package on your Linux distribution. Have a look at +The packaging status does not work + * {{< donateDialog isToggle=true isMarkdown=true >}}[Arch Linux](https://aur.archlinux.org/packages/grass/){{< /donateDialog >}} * {{< donateDialog isToggle=true isMarkdown=true >}}[Debian](https://packages.debian.org/grass){{< /donateDialog >}} diff --git a/themes/grass/assets/js/script.js b/themes/grass/assets/js/script.js index e5301724..e36a2d00 100644 --- a/themes/grass/assets/js/script.js +++ b/themes/grass/assets/js/script.js @@ -80,13 +80,17 @@ (async () => { const os = await detectOSFromUserAgent(); const button = $(".grass-os-download-button"); - console.log(os); + // Add text and data based on the user's OS switch (os) { case "Windows": button.text("Download for Windows"); button.data("os", "windows"); - $('#downloadTab a[href="#windows"]').tab('show'); + // TODO: This doesn't work + // $('a[data-toggle="tab"]').on("shown.bs.tab", (e) => { + // history.replaceState(null, null, "#windows"); + // window.location.hash = "#windows"; + // }); if (window.location.pathname === "/learn/download/") { history.replaceState(null, null, "#windows"); } From 6ccd20d32038485ca03738d789e98b8e7b2e873e Mon Sep 17 00:00:00 2001 From: Corey White Date: Mon, 30 Sep 2024 12:16:18 -0400 Subject: [PATCH 7/9] Added linux and docker --- data/grass.json | 87 ++++++++++++++++++++++-- themes/grass/layouts/learn/download.html | 82 ++++++++++++++++++++-- 2 files changed, 160 insertions(+), 9 deletions(-) diff --git a/data/grass.json b/data/grass.json index bffae4e9..32901b47 100644 --- a/data/grass.json +++ b/data/grass.json @@ -12,12 +12,89 @@ "preview_version_underscore": "8_4", "preview_version_nodots":"84", "install": { - "mac_ports": { - "id": "mac_ports", - "title": "MacPorts", - "code": "sudo port install grass", - "url": "https://ports.macports.org/port/grass/" + "mac": { + "mac_ports": { + "id": "mac_ports", + "title": "MacPorts", + "code": "sudo port install grass", + "url": "https://ports.macports.org/port/grass/" + } + }, + "linux":{ + "arch_linux": { + "id": "arch_linux", + "title": "Arch Linux", + "code": "sudo pacman -S grass", + "url": "https://aur.archlinux.org/packages/grass" + }, + "debian": { + "id": "debian", + "title": "Debian", + "code": "sudo apt-get install grass", + "url": "https://packages.debian.org/search?keywords=grass" + }, + "generic_64_bit":{ + "id": "generic_64_bit", + "title": "Generic 64-bit", + "code": "add me", + "url": "https://grass.osgeo.org/grass84/binary/linux/snapshot/" + }, + "EPEL": { + "id": "EPEL", + "title": "EPEL", + "code": "sudo yum install grass", + "url": "https://src.fedoraproject.org/rpms/grass" + }, + "fedora":{ + "id": "fedora", + "title": "Fedora", + "code": "sudo dnf install grass", + "url": "https://apps.fedoraproject.org/packages/grass" + }, + "gentoo": { + "id": "gentoo", + "title": "Gentoo", + "code": "sudo emerge grass", + "url": "https://packages.gentoo.org/packages/sci-geosciences/grass" + }, + "openSUSE": { + "id": "openSUSE", + "title": "openSUSE", + "code": "sudo zypper install grass", + "url": "https://build.opensuse.org/package/show/Application:Geo/grass" + }, + "ubuntu": { + "id": "ubuntu", + "title": "Ubuntu", + "code": "sudo apt-get install grass", + "url": "https://launchpad.net/~ubuntugis/+archive/ubuntu/ubuntugis-unstable" + } + }, + "docker": { + "alpine": { + "id": "alpine", + "title": "Alpine based (233 MB, with Python 3 and PDAL)", + "code": "docker pull osgeo/grass-gis:releasebranch_8_4-alpine" + }, + "debian": { + "id": "debian", + "title": "Debian based (1.2 GB, with Python 3 and PDAL)", + "code": "docker pull osgeo/grass-gis:releasebranch_8_4-debian" + }, + "ubuntu": { + "id": "ubuntu", + "title": "Ubuntu based (1.2 GB, with Python 3 and PDAL)", + "code": "docker pull osgeo/grass-gis:releasebranch_8_4-ubuntu" + }, + "wxPython": { + "id": "wxPython", + "title": "Ubuntu based (1.3 GB, with wxPython, Python 3 and PDAL)", + "code": "docker pull osgeo/grass-gis:releasebranch_8_4-ubuntu_wxgui" + } + } + } } + diff --git a/themes/grass/layouts/learn/download.html b/themes/grass/layouts/learn/download.html index 0d81a33b..fd72db94 100644 --- a/themes/grass/layouts/learn/download.html +++ b/themes/grass/layouts/learn/download.html @@ -41,14 +41,20 @@

#Download

- {{ with .Site.GetPage "download" "linux" }}{{ .Content }}{{ end }} + + {{ $download_data := dict "os" "Linux" "url" "https://github.com/OSGeo/grass/releases/tag/8.4.0" "version" .Site.Data.grass.current_version }} + {{ partial "grass-download.html" $download_data }} +

Installation

+ {{ range $key, $value := .Site.Data.grass.install.linux }} + {{ partial "code-copy.html" $value }} + {{ end }}
{{ $download_data := dict "os" "Mac" "url" "https://cmbarton.github.io/grass-mac/download/" "version" .Site.Data.grass.current_version }} {{ partial "grass-download.html" $download_data }} - {{ partial "code-copy.html" .Site.Data.grass.install.mac_ports }} + {{ partial "code-copy.html" .Site.Data.grass.install.mac.mac_ports }}
@@ -89,10 +95,78 @@

QGIS users

- {{ with .Site.GetPage "download" "docker" }}{{ .Content }}{{ end }} + + {{ $download_data := dict "os" "Docker" "url" "https://hub.docker.com/r/osgeo/grass-gis/" "version" .Site.Data.grass.current_version }} + {{ partial "grass-download.html" $download_data }} + +

Installation

+ + {{ range $key, $value := .Site.Data.grass.install.docker }} + {{ partial "code-copy.html" $value }} + {{ end }} + +

Docker

+ +

Build a docker image using the downloaded source code (run this in the directory containing the source code):

+ +

A. Docker image without graphical user interface - wxGUI

+ +
docker build -t grassgis .
+ +

A test run (assuming you have the existing GRASS GIS test location; it can be downloaded from + here)

+ +
# case 1: launching in the grassdata directory in which the location is stored:
+              docker run -it --rm --user=$(id -u):$(id -g) --volume $(pwd):/data \
+                  --env HOME=/data/ grassgis grass --text nc_basic_spm_grass7/user1 \
+                      --exec g.region -p
+              
+              # case 2: launching anywhere
+              docker run -it --rm --user=$(id -u):$(id -g) \
+                  --volume /your/test/grassdata/:/data --env HOME=/data/ grassgis \
+                      grass /data/nc_basic_spm_grass7/PERMANENT --exec g.region -p
+              
+ +

Note that the first grassgis is the name of the image while the second grass is the name of the executable.

+ +

To run the tests (again assuming local location):

+ +
# case 1: launching in the grassdata directory in which the location is stored:
+              docker run -it --rm --user=$(id -u):$(id -g) --volume $(pwd):/data \
+                  --env HOME=/data/ grassgis grass --text nc_basic_spm_grass7/user1 \
+                      --exec g.region -p
+              
+              # case 2: launching anywhere
+              docker run -it --rm --user=$(id -u):$(id -g) \
+                  --volume /your/test/grassdata/:/data --env HOME=/data/ -w /code/grass \
+                      grassgis grass /data/nc_basic_spm_grass7/PERMANENT --exec \
+                          python -m grass.gunittest.main \
+                              --location nc_basic_spm_grass7 --location-type nc
+              
+ +

B. Docker image with graphical user interface - wxGUI

+ +
docker build -t grassgis -f docker/ubuntu_wxgui/Dockerfile .
+ +

Note that the first grassgis is the name of the image while the second grass is the name of the executable.

+ +
xhost local:$(id -u)
+              docker run -it --privileged --user=$(id -u):$(id -g) --rm \
+                  --volume="$(pwd)/:/data" --volume="/tmp/.X11-unix:/tmp/.X11-unix:rw" \
+                  --env HOME=/data/ --env DISPLAY=$DISPLAY \
+                  --device="/dev/dri/card0:/dev/dri/card0" \
+                  grassgis grass --gui
+              
+ +

Note: If you compiled locally before building the Docker image, you may encounter problems as the local configuration and the locally compiled files are copied to and used in the Docker image. To make sure you don't have this issue, clean all the compiled files from the source code:

+ +
make distclean
+ + +
- + From 0fdc4282ca92a243b7def12caa91076088ab012f Mon Sep 17 00:00:00 2001 From: Corey White Date: Fri, 24 Jan 2025 14:48:57 -0500 Subject: [PATCH 8/9] Removed alert when copy button is clicked --- themes/grass/layouts/partials/code-copy.html | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/themes/grass/layouts/partials/code-copy.html b/themes/grass/layouts/partials/code-copy.html index 3b1ab5df..ef65ff71 100644 --- a/themes/grass/layouts/partials/code-copy.html +++ b/themes/grass/layouts/partials/code-copy.html @@ -2,9 +2,7 @@ $(document).ready(function() { $("#{{ .id }}").on('click', function() { const code = $(this).prev().text(); - navigator.clipboard.writeText(code).then(() => { - alert(code); - }).catch(err => { + navigator.clipboard.writeText(code).catch(err => { console.error('Error in copying text: ', err); }); }); From 1d8f972b01e72f6226eb12abe735a49273ae66eb Mon Sep 17 00:00:00 2001 From: Corey White Date: Fri, 24 Jan 2025 16:37:25 -0500 Subject: [PATCH 9/9] Fixed download tabs --- config.toml | 1 + themes/grass/assets/css/style.css | 16 ++- themes/grass/assets/js/script.js | 111 ++++++++++++------- themes/grass/layouts/learn/download.html | 16 +-- themes/grass/layouts/partials/code-copy.html | 2 +- themes/grass/layouts/partials/head.html | 1 + 6 files changed, 95 insertions(+), 52 deletions(-) diff --git a/config.toml b/config.toml index 37c112df..49b55ffc 100644 --- a/config.toml +++ b/config.toml @@ -18,6 +18,7 @@ blackColor = "#000000" greyColor = "#6b6b6b" greyColorLight = "#CCCCCC" greyColorDark = "#A0A0A0" +codeBackgroundColor = "##040404" [sitemap] changefreq = "monthly" diff --git a/themes/grass/assets/css/style.css b/themes/grass/assets/css/style.css index 6fe3df07..32be160c 100644 --- a/themes/grass/assets/css/style.css +++ b/themes/grass/assets/css/style.css @@ -1210,19 +1210,17 @@ li.parent a { } .edt { - font-family: open_sansregular; !important; + font-family: open_sansregular; } nobullets { list-style-type: none; } + /* -.hljs { - background:#c5c8c6; - color: #1d1f21; -} +. .hljs-keyword{ @@ -1463,8 +1461,14 @@ code{ .code-container { position: relative; - background-color: #777; + background: var(--code-background-color); } + +/* .hljs { + background: var(--code-background-color) !important; + color: #1d1f21; +} */ + .btn-clipboard { position: absolute; top: .5rem; diff --git a/themes/grass/assets/js/script.js b/themes/grass/assets/js/script.js index e36a2d00..48d4fa58 100644 --- a/themes/grass/assets/js/script.js +++ b/themes/grass/assets/js/script.js @@ -65,7 +65,6 @@ function detectOSFromUserAgent() { return new Promise((resolve) => { const userAgent = window.navigator.userAgent; - if (userAgent.includes("Win")) resolve("Windows"); else if (userAgent.includes("Mac")) resolve("macOS"); else if (userAgent.includes("Linux")) resolve("Linux"); @@ -75,46 +74,84 @@ }); } + function configureDownloadButton(os, replaceHash = true) { + const button = $(".grass-os-download-button"); + switch (os) { + case "Windows": + console.log("Setting Windows"); + button.text("Download for Windows"); + button.data("os", "windows"); + $('#downloadTab a[href="#windows"]').tab('show'); + if (window.location.pathname === "/learn/download/") { + history.replaceState(null, null, "#windows"); + } + break; + case "macOS": + button.text("Download for macOS"); + button.data("os", "mac"); + $('#downloadTab a[href="#mac"]').tab('show'); + if (window.location.pathname === "/learn/download/") { + history.replaceState(null, null, "#mac"); + } + break; + case "Linux": + button.text("Download for Linux"); + button.data("os", "linux"); + $('#downloadTab a[href="#linux"]').tab('show'); + if (window.location.pathname === "/learn/download/") { + history.replaceState(null, null, "#linux"); + } + break; + case "Docker": + button.text("Docker Container"); + button.data("os", "docker"); + $('#downloadTab a[href="#docker"]').tab('show'); + if (window.location.pathname === "/learn/download/") { + history.replaceState(null, null, "#docker"); + } + break; + default: + button.text("Download"); + button.data("os", "unknown"); + break; + } + } + $(document).ready(function() { + + // Handle download page tab change + $('#downloadTab a').on('click', function(e) { + e.preventDefault(); + console.log("Download button clicked", e, this); + // Activate the clicked tab + $(this).tab('show'); + const hash = e.target.hash; + const os = e.target.innerText; + configureDownloadButton(os); + // history.replaceState(null, null, hash); + }); + // Detect the user's OS and update the download button text (async () => { - const os = await detectOSFromUserAgent(); - const button = $(".grass-os-download-button"); - - // Add text and data based on the user's OS - switch (os) { - case "Windows": - button.text("Download for Windows"); - button.data("os", "windows"); - // TODO: This doesn't work - // $('a[data-toggle="tab"]').on("shown.bs.tab", (e) => { - // history.replaceState(null, null, "#windows"); - // window.location.hash = "#windows"; - // }); - if (window.location.pathname === "/learn/download/") { - history.replaceState(null, null, "#windows"); - } - break; - case "macOS": - button.text("Download for macOS"); - button.data("os", "mac"); - $('#downloadTab a[href="#mac"]').tab('show'); - if (window.location.pathname === "/learn/download/") { - history.replaceState(null, null, "#mac"); - } - break; - case "Linux": - button.text("Download for Linux"); - button.data("os", "linux"); - if (window.location.pathname === "/learn/download/") { - history.replaceState(null, null, "#linux"); - } - break; - default: - button.text("Download"); - button.data("os", "unknown"); - break; + let os = "Unknown OS"; + // If the user has already selected a tab, don't change it + const hash = window.location.hash; + if (hash) { + const tab = $(`#downloadTab a[href="${hash}"]`) + console.log("Open Tab", tab); + os = tab.text(); // Get the OS from the tab text + console.log("Open Tab OS", os); + + } + else { + // No hash, so detect the OS and select the appropriate tab + os = await detectOSFromUserAgent(); + console.log("No Hash", os); } + // Configure the download button + // Add text and data based on the user's OS + configureDownloadButton(os); + })(jQuery); }); diff --git a/themes/grass/layouts/learn/download.html b/themes/grass/layouts/learn/download.html index fd72db94..ed84289d 100644 --- a/themes/grass/layouts/learn/download.html +++ b/themes/grass/layouts/learn/download.html @@ -29,7 +29,7 @@

#Download

Linux