Update Makefile for simplified Netlify scheme. (#1525)

This commit is contained in:
Martin Taillefer 2018-06-15 17:02:08 -07:00 committed by GitHub
parent f8a5265efa
commit 857f86abad
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 23 additions and 68 deletions

View File

@ -1,53 +1,21 @@
all: prep build generate lint
prep: prep_build prep_lint prep_generate
##########
prep_generate:
npm install --prefix .tools/node html-minifier
generate:
hugo --baseURL $(URL)
.tools/node/node_modules/html-minifier/cli.js --input-dir public --output-dir public --file-ext html --collapse-whitespace --minify-js --minify-css --sort-attributes --sort-class-name --remove-attribute-quotes --remove-comments
##########
prep_build:
npm install --prefix .tools/node sass
npm install --prefix .tools/node uglify-js
img := gcr.io/istio-testing/website-builder:2018-06-15
docker := docker run -t -i --sig-proxy=true --rm -v $(shell pwd):/site -w /site $(img)
build:
.tools/node/node_modules/sass/sass.js src/sass/light_theme_archive.scss light_theme_archive.css -s compressed
.tools/node/node_modules/sass/sass.js src/sass/light_theme_normal.scss light_theme_normal.css -s compressed
.tools/node/node_modules/sass/sass.js src/sass/light_theme_preliminary.scss light_theme_preliminary.css -s compressed
.tools/node/node_modules/sass/sass.js src/sass/dark_theme_archive.scss dark_theme_archive.css -s compressed
.tools/node/node_modules/sass/sass.js src/sass/dark_theme_normal.scss dark_theme_normal.css -s compressed
.tools/node/node_modules/sass/sass.js src/sass/dark_theme_preliminary.scss dark_theme_preliminary.css -s compressed
mv light_theme* static/css
mv dark_theme* static/css
.tools/node/node_modules/uglify-js/bin/uglifyjs src/js/misc.js src/js/prism.js --mangle --compress -o static/js/all.min.js --source-map
.tools/node/node_modules/uglify-js/bin/uglifyjs src/js/styleSwitcher.js --mangle --compress -o static/js/styleSwitcher.min.js --source-map
$(docker) scripts/build_site.sh
##########
prep_lint:
npm install --prefix .tools/node markdown-spellcheck
gem install mdl
gem install html-proofer
gen:
$(docker) scripts/gen_site.sh ""
lint:
.tools/node/node_modules/markdown-spellcheck/bin/mdspell --en-us --ignore-acronyms --ignore-numbers --no-suggestions --report content/*.md content/*/*.md content/*/*/*.md content/*/*/*/*.md content/*/*/*/*/*.md content/*/*/*/*/*/*.md content/*/*/*/*/*/*/*.md
mdl --ignore-front-matter --style mdl_style.rb .
htmlproofer ./public --check-html --assume-extension --timeframe 2d --storage-dir .htmlproofer --url-ignore "/localhost/,/github.com/istio/istio.github.io/edit/master/,/github.com/istio/istio/issues/new/choose/"
$(docker) scripts/lint_site.sh
prep_lint_local:
npm install --prefix .tools/node markdown-spellcheck
gem install mdl --install-dir .tools
gem install html-proofer --install-dir .tools
serve:
$(docker) scripts/serve_site.sh
lint_local:
.tools/node/node_modules/markdown-spellcheck/bin/mdspell --en-us --ignore-acronyms --ignore-numbers --no-suggestions --report content/*.md content/*/*.md content/*/*/*.md content/*/*/*/*.md content/*/*/*/*/*.md content/*/*/*/*/*/*.md content/*/*/*/*/*/*/*.md
.tools/bin/mdl --ignore-front-matter --style mdl_style.rb .
.tools/bin/htmlproofer ./public --check-html --assume-extension --timeframe 2d --storage-dir .htmlproofer --url-ignore "/localhost/,/github.com/istio/istio.github.io/edit/master/,/github.com/istio/istio/issues/new/choose/"
netlify:
npm install -g html-minifier
scripts/gen_site.sh "$(DEPLOY_PRIME_URL)"
all: netlify

View File

@ -18,31 +18,18 @@ see the Istio [contribution guidelines](https://github.com/istio/community/blob/
## Editing and testing content
We use [Hugo](https://gohugo.io/) to generate our sites. To build and test the site locally,
install Hugo, go to the root of the repo and do:
We use [Hugo](https://gohugo.io/) to generate our sites. To build and test the site locally, we use a docker
image that contains Hugo. To build and serve the site, simply go to the root of the tree and do:
```bash
$ hugo serve
$ make serve
```
This will build the site and start a web server hosting the site. You can then connect to the web server
at `http://localhost:1313`.
All normal content for the site is located in the `content` directory. To
create a new content file, go to the root of the repo and do:
```bash
$ hugo new <path to new file>
```
This will create a fresh content file, ready for editing. The path you specify is relative to the `content` directory. For
example:
```bash
$ hugo new docs/tasks/traffic-management/foo.md
```
Will create the file `content/docs/tasks/traffic-management/foo.md` which you can then add your markdown to.
All normal content for the site is located in the `content` directory, as well as in sibling translated
directories such as content_zh.
## Linting
@ -58,13 +45,10 @@ run 3 linters as a precommit requirement:
You can run these linters locally using:
```bash
$ make prep_lint
$ make build
$ make lint
```
The `prep_lint` step installs a bunch of Ruby and Node.js tools in a local directory. You only need to do
this once. Afterwards, just use the `lint` target to run the linters.
If you get spelling errors, you have three choices to address it:
* It's a real typo, so fix your markdown.
@ -87,7 +71,6 @@ Hugo directly copies to the site without any processing.
`static` directory. You use
```bash
$ make prep_build
$ make build
```

View File

@ -1,4 +1,5 @@
#!/usr/bin/env sh
set -e
sass src/sass/light_theme_archive.scss light_theme_archive.css -s compressed
sass src/sass/light_theme_normal.scss light_theme_normal.css -s compressed

View File

@ -1,4 +1,5 @@
#!/usr/bin/env sh
set -e
hugo --baseURL "$1"
html-minifier --input-dir public --output-dir public --file-ext html --collapse-whitespace --minify-js --minify-css --sort-attributes --sort-class-name --remove-attribute-quotes --remove-comments

View File

@ -1,5 +1,7 @@
#!/usr/bin/env sh
set -e
mdspell --en-us --ignore-acronyms --ignore-numbers --no-suggestions --report content/*.md content/*/*.md content/*/*/*.md content/*/*/*/*.md content/*/*/*/*/*.md content/*/*/*/*/*/*.md content/*/*/*/*/*/*/*.md
#mdspell --zh-cn --ignore-acronyms --ignore-numbers --no-suggestions --report content_zh/*.md content_zh/*/*.md content_zh/*/*/*.md content_zh/*/*/*/*.md content_zh/*/*/*/*/*.md content_zh/*/*/*/*/*/*.md content_zh/*/*/*/*/*/*/*.md
mdl --ignore-front-matter --style mdl_style.rb .
htmlproofer ./public --check-html --assume-extension --timeframe 2d --storage-dir .htmlproofer --url-ignore "/localhost/,/github.com/istio/istio.github.io/edit/master/,/github.com/istio/istio/issues/new/choose/"