Skip to content

Commit

Permalink
Merge pull request #74 from GeoscienceAustralia/benji
Browse files Browse the repository at this point in the history
Merging latest changes into the main branch
  • Loading branch information
benji-glitsos-ga authored Jan 16, 2024
2 parents b0b6813 + 25288e7 commit 42738b3
Show file tree
Hide file tree
Showing 327 changed files with 2,589 additions and 402 deletions.
2 changes: 0 additions & 2 deletions .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,3 @@
Thumbs.db
.DS_Store
_build
content/tags
content/notebooks
1 change: 1 addition & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
BUILD_MODE=local # local / demo / production

LOCAL_ENABLE_REDIRECTS=Yes
LOCAL_ENABLE_TAGS=Yes
LOCAL_ENABLE_USER_GUIDES=Yes
LOCAL_ENABLE_DATA_PRODUCTS=Yes
LOCAL_ENABLE_NOTEBOOKS=Yes
3 changes: 3 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
*.md linguist-detectable
*.rst linguist-detectable
*.ipynb linguist-detectable
2 changes: 1 addition & 1 deletion .github/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Requirements for Pull Request

1. I have previewed my changes on [demo1], [demo2], or [demo3].
1. I have previewed my changes on either [demo1], [demo2], or [demo3].

[demo1]: https://demo1--dea-docs.netlify.app/
[demo2]: https://demo2--dea-docs.netlify.app/
Expand Down
2 changes: 1 addition & 1 deletion .gitmodules
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[submodule "dea-notebooks"]
path = docs/notebooks
url = git@github.com:GeoscienceAustralia/dea-notebooks.git
url = https://github.com/GeoscienceAustralia/dea-notebooks.git
branch = stable
shallow = true
ignore = untracked
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,4 @@ COPY docs /docs
COPY build-local.sh /setup
CMD /bin/bash -c "/setup/build-local.sh"

EXPOSE 8011
EXPOSE 8062
5 changes: 4 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# This is the script for building the site locally on Mac or Linux. In the terminal, enter the command:
# make

run:
make build
make start
Expand All @@ -9,7 +12,7 @@ rebuild:
docker build --no-cache -t dea-docs .

start:
docker run -it --rm --name dea-docs --publish 8011:8011 --volume ./docs/notebooks:/docs/notebooks --volume ./output:/output --env-file .env dea-docs \
docker run -it --rm --name dea-docs --publish 8062:8062 --volume ./docs/notebooks:/docs/notebooks --volume ./output:/output --env-file .env dea-docs \
| grep --invert-match --regexp "WARNING.*Document headings start at" \
| grep --invert-match --regexp "WARNING.*duplicate label" \
| grep --invert-match --regexp "^copying images..." \
Expand Down
45 changes: 1 addition & 44 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,46 +1,3 @@
# DEA Knowledge Hub

To contribute content to this site, please [follow the publication process](https://geoscienceau.sharepoint.com/:w:/r/sites/DEA/_layouts/15/Doc.aspx?sourcedoc=%7BE75F31A8-1648-4DA3-9E36-9BB8135921B2%7D&file=DEA%20Publication%20Process.docx&action=default&mobileredirect=true).

## Git workflow

You should do your work on the `develop` branch or, ideally, branch off into your own branch (e.g. `alex` branch or `feature/something` branch). Then, preview your changes by pushing to one of the demo branches (`demo1`, `demo2`, or `demo3`) before merging into `develop` and then creating a pull request into the `main` branch.

![Git workflow diagram](https://mermaid.ink/svg/pako:eNqNkT9PAzEMxb9KZOl0SxmgW0aoxMIGYxY3cS8Rl-SUOlTVKd-d9C_t6RBsz88_20_yCDoaAglNM7rgWIpRtJ3j14SDbWvVbm3cvUTvHb_hmvrqbbDfUimiNI0KKlxo8fEsVRBCH-GDWicM2gpDX9TH4dizpD9j5jtvyu9jTg8n_evMxZuy110zKXx8nDAzmz2ljv4VYe7A098HbujlHePRhZ8E5wlYQK1ry9QfjYe2ArbkSYGs0tAGc88KVCgVxczxfR80SE6ZFpAHg0wrh11CfzLLN_hJsJw)

<!-- ```mermaid -->
<!-- %%{init: { 'gitGraph': {'showCommitLabel': false}} }%% -->
<!-- -->
<!-- gitGraph TB: -->
<!-- commit -->
<!-- branch develop -->
<!-- checkout develop -->
<!-- commit -->
<!-- branch your-branch -->
<!-- checkout develop -->
<!-- checkout your-branch -->
<!-- commit -->
<!-- commit -->
<!-- branch demo1 -->
<!-- commit -->
<!-- checkout develop -->
<!-- merge your-branch -->
<!-- checkout develop -->
<!-- commit -->
<!-- branch demo2 -->
<!-- commit -->
<!-- checkout develop -->
<!-- branch demo3 -->
<!-- checkout main -->
<!-- merge develop -->
<!-- ``` -->

# Overwriting demo branches

Instead of merging into the demo branches, it's easier to overwrite them with the exact contents of your branch.

```bash
git checkout demo1
git reset --hard your-branch
git push origin demo1 --force
```
To contribute content to this site, please [follow the publication process and git workflow](https://geoscienceau.sharepoint.com/:w:/r/sites/DEA/_layouts/15/Doc.aspx?sourcedoc=%7BE75F31A8-1648-4DA3-9E36-9BB8135921B2%7D&file=DEA%20Publication%20Process.docx&action=default&mobileredirect=true).
33 changes: 0 additions & 33 deletions aws/cloudfront/functions/redirect-filetype-extensions.js

This file was deleted.

58 changes: 58 additions & 0 deletions aws/cloudfront/functions/redirects.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
// This function handles redirect logic

async function handler(event) {
const request = event.request;
const uri = event.request.uri;
const deaToolsSourceCodePattern = /dea_tools\/(.*)\.py$/g;
const indexHtmlPattern = /\/index\.html$/g;
const filetypeExtensionsPattern = /\.(html|rst|md|ipynb|py)$/g;

const status301MovedPermanently = {
statusCode: 301,
statusDescription: "Moved Permanently"
};

// Redirect DEA Tools source code URLs to the relevant 'automodule' page generated from the source code.
// E.g. "../Tools/dea_tools/coastal.py" => "/notebooks/Tools/gen/dea_tools.coastal/"
// E.g. "../Tools/dea_tools/app/animations.py" => "/notebooks/Tools/gen/dea_tools.app.animations/"

if (deaToolsSourceCodePattern.test(uri)) {
const sourceCodePath = uri.match(deaToolsSourceCodePattern)[1];
const automoduleName = sourceCodePath.replaceAll("/", ".");
const automoduleUri = `/notebooks/Tools/gen/dea_tools.${deaToolsName}/`;

return Object.assign(status301MovedPermanently, {
headers: {
location: {
value: automoduleUri
}
}
});
}

// Redirect URLs ending in "index.html" to end in "/" instead. E.g. /page/index.html => /page/

if (indexHtmlPattern.test(uri)) {
return Object.assign(status301MovedPermanently, {
headers: {
location: {
value: uri.replace(indexHtmlPattern, "/")
}
}
});
}

// Redirect URLs ending in certain extensions (".html", ".rst", and others) to end in "/" instead. E.g. /example.html => /example/

if (filetypeExtensionsPattern.test(uri)) {
return Object.assign(status301MovedPermanently, {
headers: {
location: {
value: uri.replace(filetypeExtensionsPattern, "/")
}
}
});
}

return request;
}
2 changes: 1 addition & 1 deletion build-demo.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@ sass --style=compressed ./docs/_static/styles/index.scss ./docs/_static/styles/s

cp ./docs/_robots/robots-demo.txt ./docs/robots.txt

sphinx-build -b dirhtml -j auto ./docs ./output
sphinx-build -b dirhtml -j auto -a ./docs ./output
4 changes: 2 additions & 2 deletions build-local.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ sass --style=expanded /docs/_static/styles/index.scss /docs/_static/styles/style

cp /docs/_robots/robots-local.txt /docs/robots.txt

sphinx-build -b dirhtml -j auto /docs /output
sphinx-build -b dirhtml -j auto -a /docs /output

cd /output
python -m http.server 8011
python -m http.server 8062
2 changes: 1 addition & 1 deletion build-production.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ sass --style=compressed ./docs/_static/styles/index.scss ./docs/_static/styles/s

cp ./docs/_robots/robots-production.txt ./docs/robots.txt

sphinx-build -b dirhtml -j auto ./docs ./output
sphinx-build -b dirhtml -j auto -a ./docs ./output
Loading

0 comments on commit 42738b3

Please sign in to comment.