Skip to content

Commit

Permalink
Merge pull request #292 from sentinel-hub/fix/structure
Browse files Browse the repository at this point in the history
Fix/structure
  • Loading branch information
jonasViehweger authored Dec 18, 2023
2 parents 27b2cab + 94462dd commit 6a8a5f6
Show file tree
Hide file tree
Showing 29 changed files with 301 additions and 140 deletions.
113 changes: 113 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
# Sentinel Hub Custom Script Repository

![Examples of visualizations](assets/images/custom-scripts-examples.jpg)

This repository contains a collection of custom scripts for [Sentinel Hub](https://www.sentinel-hub.com/), which can be fed to the services via the URL.

Custom scripts are a piece of Javascript code, used to visualize satellite imagery and to control what values the Sentinel Hub services will return. Any visualization of any constellation (e.g. Sentinel-2 satellite), even a simple true color composite, is dictated by a custom script.

See [here](https://docs.sentinel-hub.com/api/latest/evalscript/v3/) for more information on how to write your own evalscript.

## Contribute to Custom Scripts

Have a look at the [template](/contribute/example) for an example of how a script page can be structured.

You can also have a look at other scripts to see how they are structured.

For instructions on how custom scripts are structured have a look at this [tutorial](https://www.sentinel-hub.com/explore/education/custom-scripts-tutorial/), or at the [official documenation](https://docs.sentinel-hub.com/api/latest/evalscript/).

---

### How to publish your own product

- Fork the repository to get your own copy of the custom-scripts
_It is easiest to fork the repository on GitHub, but as some of you might not have GitHub account, or don't want to bother with all this versioning and collaboration tools, you can also just download the whole repository as Zip file and work from there._
- Create a new directory entry for your custom script
_Copy the `example` directory to proper directory, based on which datasource (satellite) you are publishing the product for, to something that describes what the product is about, say `my_algorithm`._
_Preferably use ["snake_case"](https://simple.wikipedia.org/wiki/Snake_case) (underscores instead of spaces) if more than one word is used._
- Fill in the details about the project in the `README.md` file.
_Obviously, you'll want to remove this chapter, but use the rest of the file as a template._
_Have a look around at other `README.md` files to see how to include images, format the text and generally use the GitHub [markdown](https://help.github.com/categories/writing-on-github/) (e.g. [here](../sentinel-2/cby_cloud_detection/README.md) for mathematical formulas or [here](../sentinel-2/ndvi_uncertainty/README.md) for adding images)._
- Implement the product in the `script.js` file.
_The most work is of course the JavaScript implementation of the product. The `example` folder includes an empty custom script with comments that will hopefully help you build your own custom script. Of course the easiest is to do the custom script building/testing on [Sentinel Playground](https://apps.sentinel-hub.com/sentinel-playground/)._
- Add an entry pointing to your script to the top level markdown file (i.e. if adding a script for Sentinel 2 add the link to `sentinel-2.md` in the folder `sentinel-2`).
_A link and a short description will do._
- And create a pull request :).
_There is extensive help on creating pull requests on GitHub [help](https://help.github.com/categories/collaborating-with-issues-and-pull-requests/), but if you feel overwhelmed by this step and would still like to contribute, send us the folder you've created and we will take care of it for you._

Publishing your product should be easy, nevertheless, any feedback and ideas how to improve or make the process simpler is very appreciated.

#### Test your changes locally

This is optional but makes Pull Requests quicker to handle since they should have less mistakes.
Before you create the PR you can check if everything looks right on the website. To do this follow these steps which are based on [Testing your GitHub Pages site locally with Jekyll](https://docs.github.com/en/pages/setting-up-a-github-pages-site-with-jekyll/testing-your-github-pages-site-locally-with-jekyll) page:

##### Linux

- In the root directory of your fork open a terminal
- Install ruby
- Ubuntu: `sudo apt install ruby ruby-dev`
- Install bundler
- `gem install bundler`
- On Ubuntu you might have to add `sudo`
- Create a Gemfile
- In the root folder of the repository (where the `_config.yml` file is) create a new file `Gemfile`.
- i.e `touch Gemfile`
- and add the following content:

```
source 'https://rubygems.org'
gem "github-pages", "~> GH_VERSION", group: :jekyll_plugins
gem "just-the-docs"
```

Replace `GH_VERSION` with the version number that is displayed next to github-pages [here](https://pages.github.com/versions/).

- Serve the page
- First install all necessary gems with `bundle install`
- then the site can be built with `bundle exec jekyll serve`
- The site should then be visible on `127.0.0.1:4000`

##### macOS

- In the root directory of your fork open a terminal
- Install ruby

- `brew install chruby ruby-install xz`

- If homebrew hasn't been installed yet, intall homebrew

```
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
```
- `ruby-install ruby 3.1.3`
- After installation run the following codes:
```
echo "source $(brew --prefix)/opt/chruby/share/chruby/chruby.sh" >> ~/.zshrc
echo "source $(brew --prefix)/opt/chruby/share/chruby/auto.sh" >> ~/.zshrc
echo "chruby ruby-3.1.3" >> ~/.zshrc # run 'chruby' to see actual version
```
- Quit and relaunch Terminal, then check that everything with `ruby -v`
- It should show ruby 3.1.3p185 (2022-11-24 revision 1a6b16756e) or a newer version
- Install Jekyll
- `gem install jekyll`
- Install bundler
- `gem install bundler`
- Following the **Create a Gemfile** step in the Linux section
- Serve the page
- First install all necessary gems with `bundle install`
- Add the missing webrick package with `bundle add webrick`
- Run this command again when the following error message pops out:
```
bundler: failed to load command: jekyll
```
- then the site can be built with `bundle exec jekyll serve`
- The site should then be visible on `127.0.0.1:4000`
2 changes: 2 additions & 0 deletions _config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ url: https://custom-scripts.sentinel-hub.com
math: mathjax
enable_copy_code_button: true

exclude: ["README.md"]

logo: "/assets/images/sentinel_hub_logo_with_custom_scripts.png"
favicon_ico: "/assets/images/public_favicon.ico"

Expand Down
18 changes: 0 additions & 18 deletions contribute/example/README.md

This file was deleted.

19 changes: 19 additions & 0 deletions contribute/example/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
---
title: Example product
parent: Contribute

layout: script
nav_exclude: true
---

The layout `script` automatically adds the title defined in the front matter and adds buttons to visualize the script. For the buttons to work the evalscript has to be named `script.js` and must be in the same directory as the `README.md` file.

## Evaluate and visualize

- [EO Browser](https://apps.sentinel-hub.com/eo-browser/#lat=41.9&lng=12.5&zoom=10&datasource=Sentinel-2%20L1C&time=2017-10-08&preset=CUSTOM&layers=B01,B02,B03&evalscripturl=https://raw.githubusercontent.com/sentinel-hub/customScripts/master/example/script.js){:target="\_blank"}

## General description of the script

## References

- possible references (scientific articles, wiki/web references, ...)
22 changes: 0 additions & 22 deletions contribute/example_multiple_scripts/README.md

This file was deleted.

22 changes: 22 additions & 0 deletions contribute/example_multiple_scripts/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
---
title: Example product
parent: Contribute
layout: script
nav_exclude: true
scripts:
- [Visualization, script.js]
- [EO Browser, eob.js]
- [Raw Values, raw.js]
---

The layout `script` automatically adds the title defined in the front matter and adds buttons to visualize the script. For the buttons to work the evalscript has to be named `script.js` and must be in the same directory as the `README.md` file.

## Evaluate and visualize

- [EO Browser](https://apps.sentinel-hub.com/eo-browser/#lat=41.9&lng=12.5&zoom=10&datasource=Sentinel-2%20L1C&time=2017-10-08&preset=CUSTOM&layers=B01,B02,B03&evalscripturl=https://raw.githubusercontent.com/sentinel-hub/customScripts/master/example/script.js){:target="\_blank"}

## General description of the script

## References

- possible references (scientific articles, wiki/web references, ...)
48 changes: 26 additions & 22 deletions contribute/contribute.md → contribute/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ layout: default
title: Contribute
nav_order: 99
has_children: false
permalink: /contribute/
---

# Contribute to Custom Scripts
Expand All @@ -18,25 +17,20 @@ For instructions on how custom scripts are structured have a look at this [tutor

## How to publish your own product

* Fork the repository to get your own copy of the custom-scripts
- Fork the repository to get your own copy of the custom-scripts
_It is easiest to fork the repository on GitHub, but as some of you might not have GitHub account, or don't want to bother with all this versioning and collaboration tools, you can also just download the whole repository as Zip file and work from there._

* Create a new directory entry for your custom script
*Copy the `example` directory to proper directory, based on which datasource (satellite) you are publishing the product for, to something that describes what the product is about, say `my_algorithm`.*
*Preferably use ["snake_case"](https://simple.wikipedia.org/wiki/Snake_case) (underscores instead of spaces) if more than one word is used.*

* Fill in the details about the project in the `README.md` file.
*Obviously, you'll want to remove this chapter, but use the rest of the file as a template.*
*Have a look around at other `README.md` files to see how to include images, format the text and generally use the GitHub [markdown](https://help.github.com/categories/writing-on-github/) (e.g. [here](../sentinel-2/cby_cloud_detection/README.md) for mathematical formulas or [here](../sentinel-2/ndvi_uncertainty/README.md) for adding images).*

* Implement the product in the `script.js` file.
*The most work is of course the JavaScript implementation of the product. The `example` folder includes an empty custom script with comments that will hopefully help you build your own custom script. Of course the easiest is to do the custom script building/testing on [Sentinel Playground](https://apps.sentinel-hub.com/sentinel-playground/).*

* Add an entry pointing to your script to the top level markdown file (i.e. if adding a script for Sentinel 2 add the link to `sentinel-2.md` in the folder `sentinel-2`).
*A link and a short description will do.*

* And create a pull request :).
*There is extensive help on creating pull requests on GitHub [help](https://help.github.com/categories/collaborating-with-issues-and-pull-requests/), but if you feel overwhelmed by this step and would still like to contribute, send us the folder you've created and we will take care of it for you.*
- Create a new directory entry for your custom script
_Copy the `example` directory to proper directory, based on which datasource (satellite) you are publishing the product for, to something that describes what the product is about, say `my_algorithm`._
_Preferably use ["snake_case"](https://simple.wikipedia.org/wiki/Snake_case) (underscores instead of spaces) if more than one word is used._
- Fill in the details about the project in the `README.md` file.
_Obviously, you'll want to remove this chapter, but use the rest of the file as a template._
_Have a look around at other `README.md` files to see how to include images, format the text and generally use the GitHub [markdown](https://help.github.com/categories/writing-on-github/) (e.g. [here](../sentinel-2/cby_cloud_detection/README.md) for mathematical formulas or [here](../sentinel-2/ndvi_uncertainty/README.md) for adding images)._
- Implement the product in the `script.js` file.
_The most work is of course the JavaScript implementation of the product. The `example` folder includes an empty custom script with comments that will hopefully help you build your own custom script. Of course the easiest is to do the custom script building/testing on [Sentinel Playground](https://apps.sentinel-hub.com/sentinel-playground/)._
- Add an entry pointing to your script to the top level markdown file (i.e. if adding a script for Sentinel 2 add the link to `sentinel-2.md` in the folder `sentinel-2`).
_A link and a short description will do._
- And create a pull request :).
_There is extensive help on creating pull requests on GitHub [help](https://help.github.com/categories/collaborating-with-issues-and-pull-requests/), but if you feel overwhelmed by this step and would still like to contribute, send us the folder you've created and we will take care of it for you._

Publishing your product should be easy, nevertheless, any feedback and ideas how to improve or make the process simpler is very appreciated.

Expand All @@ -46,6 +40,7 @@ This is optional but makes Pull Requests quicker to handle since they should hav
Before you create the PR you can check if everything looks right on the website. To do this follow these steps which are based on [Testing your GitHub Pages site locally with Jekyll](https://docs.github.com/en/pages/setting-up-a-github-pages-site-with-jekyll/testing-your-github-pages-site-locally-with-jekyll) page:

#### Linux

- In the root directory of your fork open a terminal
- Install ruby
- Ubuntu: `sudo apt install ruby ruby-dev`
Expand All @@ -54,7 +49,7 @@ Before you create the PR you can check if everything looks right on the website.
- On Ubuntu you might have to add `sudo`
- Create a Gemfile
- In the root folder of the repository (where the `_config.yml` file is) create a new file `Gemfile`.
- i.e `touch Gemfile`
- i.e `touch Gemfile`
- and add the following content:

```
Expand All @@ -63,22 +58,26 @@ gem "github-pages", "~> GH_VERSION", group: :jekyll_plugins
gem "just-the-docs"
```

Replace `GH_VERSION` with the version number that is displayed next to github-pages [here](https://pages.github.com/versions/).
Replace `GH_VERSION` with the version number that is displayed next to github-pages [here](https://pages.github.com/versions/).

- Serve the page
- First install all necessary gems with `bundle install`
- then the site can be built with `bundle exec jekyll serve`
- The site should then be visible on `127.0.0.1:4000`

#### macOS

- In the root directory of your fork open a terminal
- Install ruby

- `brew install chruby ruby-install xz`
- If homebrew hasn't been installed yet, intall homebrew

- If homebrew hasn't been installed yet, intall homebrew

```
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
```
- `ruby-install ruby 3.1.3`
- After installation run the following codes:
Expand All @@ -87,20 +86,25 @@ Replace `GH_VERSION` with the version number that is displayed next to github-pa
echo "source $(brew --prefix)/opt/chruby/share/chruby/auto.sh" >> ~/.zshrc
echo "chruby ruby-3.1.3" >> ~/.zshrc # run 'chruby' to see actual version
```
- Quit and relaunch Terminal, then check that everything with `ruby -v`
- It should show ruby 3.1.3p185 (2022-11-24 revision 1a6b16756e) or a newer version
- Install Jekyll
- `gem install jekyll`
- Install bundler
- `gem install bundler`
- Following the **Create a Gemfile** step in the Linux section
- Serve the page
- First install all necessary gems with `bundle install`
- Add the missing webrick package with `bundle add webrick`
- Run this command again when the following error message pops out:
```
bundler: failed to load command: jekyll
```
- then the site can be built with `bundle exec jekyll serve`
- The site should then be visible on `127.0.0.1:4000`
Loading

0 comments on commit 6a8a5f6

Please sign in to comment.