Skip to content

Commit

Permalink
Refresh OPA website
Browse files Browse the repository at this point in the history
These changes contain a redesign of the OPA website. The main changes
are (1) new frontpage w/ refreshed messaging and assets and (2) docs
ported to gitbook.
  • Loading branch information
Eva-xiaohui-luo authored and tsandall committed Jul 5, 2017
1 parent 326cb91 commit 25ba04c
Show file tree
Hide file tree
Showing 363 changed files with 10,126 additions and 3,258 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ coverage
opa_*
.Dockerfile_*
_release
site.tar.gz

# runtime artifacts
policies
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ If you have questions, comments, or requests feel free to post on the mailing li
create an issue on GitHub.

If you want to contribute code and you are new to the Go programming language, check out
the [Development](http://openpolicyagent.org/docs/development.html) reference for help getting started.
the [DEVELOPMENT.md](./docs/devel/DEVELOPMENT.md) reference for help getting started.

We currently welcome contributions of all kinds. For example:

Expand Down
15 changes: 6 additions & 9 deletions Dockerfile_release-builder.in
Original file line number Diff line number Diff line change
@@ -1,20 +1,17 @@
FROM golang:GOVERSION

RUN echo 'deb http://deb.nodesource.com/node_6.x jessie main' > /etc/apt/sources.list.d/nodesource.list
RUN echo 'deb-src http://deb.nodesource.com/node_6.x jessie main' >> /etc/apt/sources.list.d/nodesource.list

RUN apt-get update -y \
&& apt-get install -y -q --no-install-recommends \
ruby \
ruby-dev \
&& apt-get install -y -q --force-yes --no-install-recommends \
nodejs \
locales \
&& gem update --system \
&& gem install jekyll \
autoprefixer-rails \
jekyll-assets \
jekyll-contentblocks \
jekyll-minifier \
&& rm -fr /var/lib/apt/lists/* /var/cache/*

RUN echo en_US.UTF-8 UTF-8 > /etc/locale.gen && locale-gen
ENV LANG en_US.UTF-8
ENV LANGUAGE en_US:en
ENV LC_ALL en_US.UTF-8

RUN npm install -g gitbook-cli gulp
19 changes: 15 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ GO15VENDOREXPERIMENT := 1
export GO15VENDOREXPERIMENT

.PHONY: all build check check-fmt check-lint check-vet \
clean cover deps fmt generate install perf perf-regression \
clean cover deps docs fmt generate install perf perf-regression \
push push-latest push-release-builder release release-builder \
release-patch tag-latest test version

Expand Down Expand Up @@ -117,8 +117,17 @@ fmt:
$(GO) fmt $(PACKAGES)

clean:
rm -f opa_*_*
rm -f .Dockerfile_*
rm -f opa_*_*
rm -fr site.tar.gz docs/_site docs/node_modules docs/book/_book docs/book/node_modules

docs:
docker run -it --rm \
-v $(PWD):/go/src/github.com/open-policy-agent/opa \
-w /go/src/github.com/open-policy-agent/opa \
-p 4000:4000 \
$(REPOSITORY)/release-builder:latest \
./build/build-docs.sh --output-dir=/go/src/github.com/open-policy-agent/opa --serve=4000

######################################################
#
Expand Down Expand Up @@ -148,5 +157,7 @@ release-local:
/_src/build/build-release.sh --output-dir=/_release/$(VERSION) --source-url=/_src

release-patch:
@docker run -it --rm -v $(PWD)/build/gen-release-patch.sh:/gen-release-patch.sh \
python:2.7 /gen-release-patch.sh $(VERSION)
@docker run -it --rm \
-v $(PWD):/_src \
python:2.7 \
/_src/build/gen-release-patch.sh --version=$(VERSION) --source-url=/_src
18 changes: 10 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,25 +1,27 @@
# Open Policy Agent
# ![logo](./logo/logo.png) Open Policy Agent

The Open Policy Agent (OPA) is an open source project that helps policy-enable your service. By integrating with OPA, your service's operators will be empowered to manage the size, complexity, and dynamic nature of modern deployments.
The Open Policy Agent (OPA) is an open source, general-purpose policy engine
that enables unified, context-aware policy enforcement across the entire stack.

## Want to learn about OPA?

- See [openpolicyagent.org](http://www.openpolicyagent.org) to get started.
- Join the conversation on [Slack](http://slack.openpolicyagent.org).
- See [openpolicyagent.org](http://www.openpolicyagent.org) to get started.
- See [blog.openpolicyagent.org](https://blog.openpolicyagent.org) for blog posts about OPA and policy.
- Join the conversation on [Slack](http://slack.openpolicyagent.org).

## Want to get OPA?

See [Get OPA](http://www.openpolicyagent.org/get-opa/) for releases.
See [GitHub releases](https://github.com/open-policy-agent/opa/releases) for binary releases.

## Want to build OPA?

See [DEVELOPMENT.md](./docs/DEVELOPMENT.md) for development environment setup and build instructions.
See [DEVELOPMENT.md](./docs/devel/DEVELOPMENT.md) for development environment setup and build instructions.

## Helpful Links

- License: [Apache Version 2.0](https://raw.githubusercontent.com/open-policy-agent/opa/master/LICENSE)
- Bugs: [Github Issues](https://github.com/open-policy-agent/opa/issues)
- Features: [Github Issues](https://github.com/open-policy-agent/opa/issues)
- Discussions: [Google Groups](https://groups.google.com/forum/?hl=en#!forum/open-policy-agent) [![Slack Status](http://slack.openpolicyagent.org/badge.svg)](http://slack.openpolicyagent.org)
- Documentation: [Introduction](http://www.openpolicyagent.org/documentation/what-is-policy-enablement/), [Tutorials](http://www.openpolicyagent.org/tutorials/working-with-the-opa-repl/), [![GoDoc](https://godoc.org/github.com/open-policy-agent/opa?status.svg)](https://godoc.org/github.com/open-policy-agent/opa)
- Discussions: [![Slack Status](http://slack.openpolicyagent.org/badge.svg)](http://slack.openpolicyagent.org)
- Documentation: [Introduction](http://www.openpolicyagent.org/docs/), [Tutorials](http://www.openpolicyagent.org/docs/get-started.html), [![GoDoc](https://godoc.org/github.com/open-policy-agent/opa?status.svg)](https://godoc.org/github.com/open-policy-agent/opa)
- Continuous Integration: [![Build Status](https://travis-ci.org/open-policy-agent/opa.svg?branch=master)](https://travis-ci.org/open-policy-agent/opa) [![Go Report Card](https://goreportcard.com/badge/open-policy-agent/opa)](https://goreportcard.com/report/open-policy-agent/opa)
50 changes: 50 additions & 0 deletions build/build-docs.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
#!/usr/bin/env bash
# Script to build OPA static site. Assumes execution environment is release builder.

set -ex

pushd `dirname $0` >/dev/null
OPA_DIR=$(pwd -P)/..
popd > /dev/null

usage() {
echo "build-docs.sh --output-dir=<path> [--serve=<port>]"
}

for i in "$@"; do
case $i in
--output-dir=*)
OUTPUT_DIR="${i#*=}"
shift
;;
--serve=*)
PORT="${i#*=}"
shift
;;
*)
usage
exit 1
esac
done

if [ -z "$OUTPUT_DIR" ]; then
usage
exit 2
fi

# build docs
cd $OPA_DIR/docs/book
gitbook install
gitbook build

# build front page
cd $OPA_DIR/docs
npm install
gulp build

# save output
tar czvf $OUTPUT_DIR/site.tar.gz -C $OPA_DIR/docs/_site/ .

if [ -n "$PORT" ]; then
cd $OPA_DIR/docs/_site; python -m SimpleHTTPServer $PORT
fi
12 changes: 4 additions & 8 deletions build/build-release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@

set -e

OPA_DIR=/go/src/github.com/open-policy-agent/opa
BUILD_DIR=$OPA_DIR/build

usage() {
echo "build-release.sh --output-dir=<path>"
echo " --source-url=<git-url>"
Expand Down Expand Up @@ -45,13 +48,6 @@ build_binaries() {
mv opa_*_* $OUTPUT_DIR
}

build_site() {
pushd site
jekyll build . && rm _site/assets/.sprockets-manifest-*.json
tar czvf $OUTPUT_DIR/site.tar.gz -C _site .
popd
}

clone_repo() {
git clone $SOURCE_URL /go/src/github.com/open-policy-agent/opa
cd /go/src/github.com/open-policy-agent/opa
Expand All @@ -63,7 +59,7 @@ clone_repo() {
main() {
clone_repo
build_binaries
build_site
$BUILD_DIR/build-docs.sh --output-dir=$OUTPUT_DIR
make test
}

Expand Down
39 changes: 35 additions & 4 deletions build/gen-release-patch.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,42 @@

set -e

git clone --quiet https://github.com/open-policy-agent/opa.git /src >/dev/null
cd /src
OPA_DIR=/go/src/github.com/open-policy-agent/opa

usage() {
echo "gen-release-patch.sh --source-url=<git-url>"
echo " --version=<mj.mn.pt>"
}

for i in "$@"; do
case $i in
--source-url=*)
SOURCE_URL="${i#*=}"
shift
;;
--version=*)
VERSION="${i#*=}"
shift
;;
*)
usage
exit 1
;;
esac
done

if [ -z "$SOURCE_URL" ]; then
usage
exit 1
elif [ -z "$VERSION" ]; then
usage
exit 1
fi

git clone $SOURCE_URL $OPA_DIR
cd $OPA_DIR

LAST_VERSION=$(git describe --abbrev=0 --tags)
VERSION=$1

update_makefile() {
sed -i='' -e "s/^VERSION[ \t]*:=[ \t]*.\+$/VERSION := $VERSION/" Makefile
Expand All @@ -26,7 +57,7 @@ EOF
}

update_docs() {
find ./site/ -name "*.md" -exec sed -i='' s/${LAST_VERSION:1}/$VERSION/g {} \;
find ./docs/ -name "*.md" -exec sed -i='' s/${LAST_VERSION:1}/$VERSION/g {} \;
}

main() {
Expand Down
4 changes: 4 additions & 0 deletions docs/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
node_modules
_book
_site
docs
32 changes: 32 additions & 0 deletions docs/GulpFile.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/**
* Copyright 2015 IBM Corp. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

'use strict';

var gulp = require('gulp');
var wrench = require('wrench');

/**
* This will load all js or coffee files in the gulp directory
* in order to load all gulp tasks
*/
wrench.readdirSyncRecursive('./gulp').filter(function gulFile(file) {
return (/\.(js|coffee)$/i).test(file);
}).map(function requireGulp(file) {
require('./gulp/' + file);
});

gulp.task('default', ['serve']);
67 changes: 67 additions & 0 deletions docs/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
# Docs

This directory contains all of the Markdown, HTML, CSS, and other assets needed
to build the [openpolicyagent.org](http://openpolicyagent.org) site. See the
section below for steps to build the site and test documentation changes
locally.

The raw OPA documentation can be found under the [book](./book) directory.

For development documentation see the [devel](./devel) directory.

## Site Updates

We use GitHub pages to host the website that includes all of the OPA
documentation. In order to update the website, you need to have write permission
on the open-policy-agent/opa repository.

### Prerequisites

If you want to build and serve the site locally, you need the following packages
installed on your system:

- npm
- [gulp](http://gulpjs.com/)
- [gitbook](https://github.com/GitbookIO/gitbook)

### Build and preview the docs locally

```
cd book
gitbook install
gitbook serve
```

> This will build the docs under `./book/_book`.
### Build and preview the entire site (front page and docs) locally

```
cd book; gitbook install; gitbook build; cd ..
npm install
gulp copy-book
gulp serve
```

### Build and preview (only) the front page locally

```
npm install
gulp
```

### Build site for release

From the root directory:

```
make docs
```

This will also serve the site on port 4000. The site will be saved to
`site.tar.gz` in the root directory.

### Update the website

Unzip the `site.tar.gz` file produced by building the site into the `gh-pages`
of this repository, add and commit the changes, and then push.
Loading

0 comments on commit 25ba04c

Please sign in to comment.