mirror of
https://github.com/zaphar/ucg.git
synced 2025-07-23 18:29:50 -04:00
Add our documentation site using gutenberg and ucg.
* gutenberg generates the documentation site * ucg configures the Google cloud storage bucket.
This commit is contained in:
parent
eebe0bbe67
commit
c20190e8e2
3
.gitignore
vendored
3
.gitignore
vendored
@ -1,2 +1,5 @@
|
||||
target
|
||||
.libtarget
|
||||
.vscode/settings.json
|
||||
docsite/site/generated
|
||||
docsite/site/public
|
||||
|
32
docsite/Makefile
Normal file
32
docsite/Makefile
Normal file
@ -0,0 +1,32 @@
|
||||
allyamls := $(shell find . -type f -name '*.yaml')
|
||||
|
||||
shared := $(wildcard ucglib/*.ucg)
|
||||
bucketucgs := $(wildcard buckets/*.ucg)
|
||||
|
||||
%.yaml: %.ucg .libtarget
|
||||
ucg build $<
|
||||
|
||||
# This ensures that we rebuild if the dependent ucglibs
|
||||
# change.
|
||||
.libtarget: $(shared)
|
||||
touch .libtarget
|
||||
|
||||
build: bucketconfs gensite
|
||||
|
||||
bucketconfs: .libtarget $(patsubst %.ucg,%.yaml,$(bucketucgs))
|
||||
|
||||
all: build test
|
||||
|
||||
test:
|
||||
ucg test -r
|
||||
|
||||
gensite:
|
||||
cd site; \
|
||||
gutenberg build -o generated
|
||||
|
||||
deploysite: gensite
|
||||
cd site/; \
|
||||
gsutil -m rsync -d -r generated gs://ucg.marzhillstudios.com/
|
||||
|
||||
clean:
|
||||
rm -f $(allyamls)
|
27
docsite/buckets/ucg-docs.ucg
Normal file
27
docsite/buckets/ucg-docs.ucg
Normal file
@ -0,0 +1,27 @@
|
||||
import "../ucglib/globals.ucg" as globals;
|
||||
import "../ucglib/macros.ucg" as mks;
|
||||
|
||||
let doc_bucket_name = "ucg.marzhillstudios.com";
|
||||
|
||||
let doc_site_bucket = mks.bucketbase(doc_bucket_name, globals.project, globals.location);
|
||||
|
||||
let resources = [
|
||||
doc_site_bucket{
|
||||
properties = self.properties{
|
||||
website = {
|
||||
notFoundPage = "404.html",
|
||||
mainPageSuffix = "index.html",
|
||||
},
|
||||
},
|
||||
},
|
||||
];
|
||||
|
||||
let deployment = {
|
||||
resources = resources,
|
||||
outputs = [
|
||||
mks.bucketSelfLink(doc_bucket_name),
|
||||
mks.bucketGsLink(doc_bucket_name),
|
||||
],
|
||||
};
|
||||
|
||||
out yaml deployment;
|
26
docsite/buckets/ucg-docs.yaml
Normal file
26
docsite/buckets/ucg-docs.yaml
Normal file
@ -0,0 +1,26 @@
|
||||
---
|
||||
resources:
|
||||
- name: ucg.marzhillstudios.com
|
||||
type: storage.v1.bucket
|
||||
properties:
|
||||
bucket: ucg.marzhillstudios.com
|
||||
project: "ucg-configuration-project"
|
||||
location: "us-east1"
|
||||
acl:
|
||||
- entity: "project-owners-ucg-configuration-project"
|
||||
role: OWNER
|
||||
- entity: "project-editors-ucg-configuration-project"
|
||||
role: WRITER
|
||||
- entity: "project-viewers-ucg-configuration-project"
|
||||
role: READER
|
||||
defaultObjectAcl:
|
||||
- entity: allUsers
|
||||
role: READER
|
||||
website:
|
||||
notFoundPage: 404.html
|
||||
mainPageSuffix: index.html
|
||||
outputs:
|
||||
- name: ucg.marzhillstudios.comselfLink
|
||||
value: "https://console.cloud.google.com/storage/browser/ucg.marzhillstudios.com"
|
||||
- name: ucg.marzhillstudios.comgsLink
|
||||
value: "gs://ucg.marzhillstudios.com"
|
19
docsite/site/config.toml
Normal file
19
docsite/site/config.toml
Normal file
@ -0,0 +1,19 @@
|
||||
# The URL the site will be built for
|
||||
base_url = "https://ucg.marzhillstudios.com"
|
||||
|
||||
# Whether to automatically compile all Sass files in the sass directory
|
||||
compile_sass = true
|
||||
|
||||
# Whether to do syntax highlighting
|
||||
# Theme can be customised by setting the `highlight_theme` variable to a theme supported by Gutenberg
|
||||
highlight_code = true
|
||||
|
||||
# Whether to build a search index to be used later on by a JavaScript library
|
||||
build_search_index = true
|
||||
|
||||
# Use the book theme
|
||||
theme = "book"
|
||||
|
||||
[extra]
|
||||
# Put all your custom variables here
|
||||
book_number_chapters = false
|
23
docsite/site/content/_index.md
Normal file
23
docsite/site/content/_index.md
Normal file
@ -0,0 +1,23 @@
|
||||
+++
|
||||
title = "Introduction to UCG"
|
||||
in_seach_index = true
|
||||
+++
|
||||
[UCG](https://crates.io/crates/ucg) is a universal grammar for configuration. It's goal is not to define a configuration format
|
||||
like JSON, YAML, or TOML. It is not intended to replace the other configuration formats. Instead
|
||||
it is intended to provide a common grammar for generating those formats. Currently UCG is able to
|
||||
generate conversions for the following formats.
|
||||
|
||||
* Environment Variables
|
||||
* Command Line Flags
|
||||
* An executable shell launch script combining the two above
|
||||
* JSON
|
||||
* YAML
|
||||
* TOML
|
||||
|
||||
UCG allows you to use one common grammar to generate configuation values for any applications that
|
||||
use one of provided conversion outputs while also allowing you to easily share common configuration
|
||||
values like hostnames, jvm settings, and database settings.
|
||||
|
||||
UCG can build an entire directory of files or a single file.
|
||||
|
||||
Next: <a href="/getting-started">Getting Started</a>
|
102
docsite/site/content/getting-started/_index.md
Normal file
102
docsite/site/content/getting-started/_index.md
Normal file
@ -0,0 +1,102 @@
|
||||
+++
|
||||
title = "Getting Started"
|
||||
slug = "getting-started"
|
||||
weight = 1
|
||||
sort_by = "weight"
|
||||
in_search_index = true
|
||||
+++
|
||||
Installing
|
||||
----------
|
||||
|
||||
### Cargo
|
||||
|
||||
You can install ucg using Rust's Cargo package manager.
|
||||
|
||||
```sh
|
||||
cargo install ucg
|
||||
```
|
||||
|
||||
### Compiling
|
||||
|
||||
You can also install from source yourself. First ensure that you have the latest
|
||||
version of Rust installed. You can find install instructions for Rust
|
||||
[here](https://www.rust-lang.org/en-US/install.html). Then you can get the source
|
||||
from github and use cargo to build.
|
||||
|
||||
```sh
|
||||
# Get the source code from github
|
||||
git clone https://github.com/zaphar/ucg
|
||||
cd ucg
|
||||
# optionally checkout the current version
|
||||
git checkout v0.2.3
|
||||
# use cargo to build and install
|
||||
cargo install --path .
|
||||
```
|
||||
|
||||
A simple configuration
|
||||
----------------------
|
||||
|
||||
To create a configuration and build it in ucg you must first create a ucg file. Copy the below contents into a file called `sample.ucg`. All ucg files must end in the ucg
|
||||
extension.
|
||||
|
||||
```
|
||||
let hostname = "www.example.com";
|
||||
let mysql_host = "localhost";
|
||||
let mysql_port = 3306;
|
||||
|
||||
let config = {
|
||||
// This uses a format string to put the hostname into
|
||||
// the baseUrl.
|
||||
baseUrl = "http://@" % (hostname),
|
||||
db = {
|
||||
host = mysql_host,
|
||||
port = myssql_port,
|
||||
},
|
||||
}
|
||||
|
||||
// Generate a yaml file from that config.
|
||||
out yaml config;
|
||||
```
|
||||
|
||||
The above binds 3 values to names and then creates a config tuple using those values.
|
||||
We'll look in more detail at ucg's syntax later.
|
||||
|
||||
To generate a yaml file from the above run the ucg build command.
|
||||
|
||||
```sh
|
||||
ucg build sample.ucg
|
||||
cat sample.yaml
|
||||
```
|
||||
|
||||
Ucg will generate the yaml file with the same name as the file containing the out statement.
|
||||
|
||||
The ucg command line
|
||||
-----------
|
||||
|
||||
Ucg has builtin help on the command line. You can
|
||||
|
||||
$> ucg help
|
||||
ucg 0.2.2
|
||||
Jeremy Wall <jeremy@marzhillstudios.com>
|
||||
Universal Configuration Grammar compiler.
|
||||
|
||||
USAGE:
|
||||
ucg [SUBCOMMAND]
|
||||
|
||||
FLAGS:
|
||||
-h, --help Prints help information
|
||||
-V, --version Prints version information
|
||||
|
||||
SUBCOMMANDS:
|
||||
build Build a list of ucg files.
|
||||
converters list the available converters
|
||||
help Prints this message or the help of the given subcommand(s)
|
||||
inspect Inspect a specific symbol in a ucg file.
|
||||
test Check a list of ucg files for errors and run test assertions.
|
||||
|
||||
* build will build a list of files or directories of files.
|
||||
* inspect will allow you to print out the contents of a specific named binding in a ucg file.
|
||||
* test compiles and runs any test assertions in the provided files or directories of files.
|
||||
* converters will list the available conversion formats that this ucg tool supports.
|
||||
|
||||
You can get more information about the options for each command by running `ucg help $command`
|
35
docsite/site/content/reference/_index.md
Normal file
35
docsite/site/content/reference/_index.md
Normal file
@ -0,0 +1,35 @@
|
||||
+++
|
||||
title = "The UCG Language Reference"
|
||||
slug = "reference"
|
||||
weight = 2
|
||||
sort_by = "weight"
|
||||
in_search_index = true
|
||||
+++
|
||||
An Overview
|
||||
-----------
|
||||
|
||||
UCG is a language specialized for generating configurations. It does not have classes,
|
||||
inheritance, closures, or a full type system. All values are immutable once bound to
|
||||
a name. A valid UCG file is composed of a series of statements. Statements can be
|
||||
an expression, introduce named bindings, or create different outputs. All statements
|
||||
must be terminiated by a semicolon.
|
||||
|
||||
Some words are reserved in ucg and can not be used as a named binding.
|
||||
|
||||
|
||||
* self
|
||||
* assert
|
||||
* true
|
||||
* false
|
||||
* let
|
||||
* import
|
||||
* as
|
||||
* select
|
||||
* macro
|
||||
* env
|
||||
* map
|
||||
* filter
|
||||
* NULL
|
||||
* out
|
||||
|
||||
Next: <a href="types">Types</a>
|
243
docsite/site/content/reference/expressions.md
Normal file
243
docsite/site/content/reference/expressions.md
Normal file
@ -0,0 +1,243 @@
|
||||
+++
|
||||
title = "UCG Expressions"
|
||||
weight = 3
|
||||
sort_by = "weight"
|
||||
in_search_index = true
|
||||
+++
|
||||
Ucg expressions can reference a bound name, do math, concatenate lists or strings,
|
||||
copy and modify a struct, or format a string.
|
||||
|
||||
Symbols
|
||||
-------
|
||||
|
||||
Many ucg expressions or statements use a symbol. A symbol might be used for either
|
||||
name for a binding or a name for a field. Symbols must start with an ascii letter and can contain any ascii letter, number, `_`, or `-` characters.
|
||||
|
||||
Selectors
|
||||
------
|
||||
|
||||
A UCG selector references a bound value by name. They can descend into tuples or lists
|
||||
or refer to symbols in imported files. They are symbol followed optionally by a list
|
||||
of other symbols or numbers separated by a `.` to reference subfields or indexes in a list.
|
||||
|
||||
You can reference a field in a tuple by putting the field name after a dot. Lists are always 0 indexed. You can index into a list by referencing the index after
|
||||
a `.`.
|
||||
|
||||
```
|
||||
let tuple = {
|
||||
inner = {
|
||||
field = "value",
|
||||
},
|
||||
list = [1, 2, 3],
|
||||
};
|
||||
|
||||
// reference the field in the inner tuple in our tuple defined above.
|
||||
tuple.inner.field;
|
||||
|
||||
// reference the field in the list contained in our tuple defined above.
|
||||
tuple.list.0;
|
||||
```
|
||||
|
||||
### The environment Selector
|
||||
|
||||
There is a special selector in ucg for obtaining a value from the environment. The
|
||||
`env` selector references the environment variables in environment at the time of
|
||||
the build. You reference environment variables just like it was a tuple. Attempting
|
||||
to reference a variable that doesn't exist will be a compile error.
|
||||
|
||||
```
|
||||
let env_name = env.DEPLOY_ENV;
|
||||
```
|
||||
|
||||
Binary Operators
|
||||
----------
|
||||
|
||||
UCG has a numver of binary infix operators. Some work only on numeric values and others
|
||||
work on more than one type.
|
||||
|
||||
### Numeric Operators
|
||||
|
||||
ucg supports the following numeric operators, `+`, `-`, `*`, `/` Each one is type safe
|
||||
and infers the types from the values they operate on. The operators expect both the
|
||||
left and right operands to be of the same type.
|
||||
|
||||
```
|
||||
1 + 1;
|
||||
1.0 - 1.0;
|
||||
```
|
||||
|
||||
### Concatenation
|
||||
|
||||
The `+` operator can also do concatenation on strings and lists. As with the numeric
|
||||
version both sides must be the same type, either string or list.
|
||||
|
||||
```
|
||||
"Hello " + "World"; // "Hello World"
|
||||
[1, 2] + [3]; // [1, 2, 3]
|
||||
```
|
||||
|
||||
### Comparison Operators
|
||||
|
||||
UCG supports the comparison operators `==`, `!=`, `>=`, `<=`, `<`, and `>`. The all
|
||||
expect both sides to be of the same type.
|
||||
|
||||
The `>`, `<`, `>=`, and `>=` operators are only supported on numeric types (i.e. int,
|
||||
and float).
|
||||
|
||||
```
|
||||
1 > 2; // result is false
|
||||
2 < 3; // result is true
|
||||
10 > "9"; // This is a compile error.
|
||||
(1+2) == 3;
|
||||
```
|
||||
|
||||
The equality operators `==` and `!=` are supported for all types and will perform deep
|
||||
equal comparisons on complex types.
|
||||
|
||||
```
|
||||
let tpl1 = {
|
||||
foo = "bar",
|
||||
one = 1
|
||||
};
|
||||
let tpl2 = {
|
||||
foo = "bar",
|
||||
one = 1
|
||||
};
|
||||
tpl1 == tpl2; // returns true
|
||||
let tpl2 = {
|
||||
foo = "bar",
|
||||
one = 1
|
||||
duck = "quack",
|
||||
};
|
||||
tpl1 == tpl3; // returns false
|
||||
```
|
||||
|
||||
Because tuples are an ordered set both tuples in a comparison must have their fields in
|
||||
the same order to compare as equal.
|
||||
|
||||
#### Operator Precedence
|
||||
|
||||
UCG binary operators follow the typical operator precedence for math. `*` and `/` are
|
||||
higher precendence than `+` and `-` which are higher precedence than any of the
|
||||
comparison operators.
|
||||
|
||||
Copy Expressions
|
||||
----------------
|
||||
|
||||
UCG expressions have a special copy expression for tuples. These faciliate a form of
|
||||
data reuse as well as a way to get a modified version of a tuple. Copy expressions
|
||||
start with a selector referencing a tuple followed by braces `{}` with `name = value`
|
||||
pairs separated by commas. Trailing commas are allowed.
|
||||
|
||||
Copied expressions can change base fields in the copied tuple or add new fields. If
|
||||
you are changing the value of a base field in the copy then the new value must be of
|
||||
the same type as the base field's value. This allows you to define a base "type" of
|
||||
sorts and ensure that any modified fields stay the same.
|
||||
|
||||
```
|
||||
let base = {
|
||||
field1 = "value1",
|
||||
field2 = 100,
|
||||
field3 = 5.6,
|
||||
};
|
||||
|
||||
let overridden = base{
|
||||
field1 = "new value"
|
||||
};
|
||||
|
||||
let expanded = base{
|
||||
field2 = 200,
|
||||
field3 = "look ma a new field",
|
||||
};
|
||||
|
||||
let bad = base{
|
||||
field1 = 300, // Error!!! must be a string.
|
||||
};
|
||||
|
||||
```
|
||||
|
||||
There is a special selector that can be used in a copy expression to refer to the base
|
||||
tuple in a copy called `self`. `self` can only be used in the body of the copy.
|
||||
|
||||
```
|
||||
let nestedtpl = {
|
||||
field1 = "value1",
|
||||
inner = {
|
||||
field2 = 2
|
||||
inner = {
|
||||
field3 = "three",
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
let copiedtpl = nestedtpl{
|
||||
inner = self.inner{
|
||||
inner = self.inner{
|
||||
field4 = 4,
|
||||
},
|
||||
},
|
||||
};
|
||||
```
|
||||
|
||||
Format Expressions
|
||||
----------
|
||||
|
||||
UCG has a format expression that has a limited form of string templating. A format
|
||||
expression starts with a string followed by the `%` operator and a list of arguments
|
||||
in parentheses separated by commas. Trailing commas are allowed. The format string
|
||||
should have `@` in each location where a value should be placed. Any primitive value
|
||||
can be used as an argument.
|
||||
|
||||
```
|
||||
"https://@:@/" % (host, port)
|
||||
```
|
||||
|
||||
Conditionals
|
||||
----------
|
||||
|
||||
UCG supports a limited conditional expression called a select. A select expression
|
||||
starts with the `select` keyword and is followed by a an expression resolving to a
|
||||
string naming the field to select, an expression resolving to the default value, and
|
||||
finally a tuple literal to select the field from. If the field selected is not in the
|
||||
tuple then the default value will be used.
|
||||
|
||||
```
|
||||
let want = "baz";
|
||||
|
||||
// field default
|
||||
select want, "quux", {
|
||||
baz = "foo",
|
||||
fuzz = "bang",
|
||||
}; // result will be "foo"
|
||||
|
||||
// field default
|
||||
select "quack", "quux", {
|
||||
baz = "foo",
|
||||
fuzz = "bang",
|
||||
}; // result will be "quux"
|
||||
```
|
||||
|
||||
Macros
|
||||
-----
|
||||
|
||||
Macros look like functions but they are resolved at compile time and configurations
|
||||
don't execute so they never appear in output. Macros do not close over their
|
||||
environment so they can only reference values defined in their arguments. They can't
|
||||
refer to bindings or other macros defined elsewhere. They are useful for constructing
|
||||
tuples of a certain shape or otherwise promoting data reuse. You define a macro with
|
||||
the `macro` keyword followed by the arguments in parentheses, a `=>`, and then a tuple
|
||||
literal.
|
||||
|
||||
```
|
||||
let mymacro = macro (arg1, arg2) => {
|
||||
host = arg1,
|
||||
port = arg2,
|
||||
connstr = "couchdb://@:@" % (arg1, arg2),
|
||||
}
|
||||
|
||||
let my_dbconf = mymacro("couchdb.example.org", "9090");
|
||||
|
||||
let my_dbhost = dbconf.host;
|
||||
```
|
||||
|
||||
Next: <a href="statements">Statements</a>
|
97
docsite/site/content/reference/statements.md
Normal file
97
docsite/site/content/reference/statements.md
Normal file
@ -0,0 +1,97 @@
|
||||
+++
|
||||
title = "UCG Statements"
|
||||
weight = 4
|
||||
sort_by = "weight"
|
||||
in_search_index = true
|
||||
+++
|
||||
Expression Statements
|
||||
-------
|
||||
|
||||
The simplest and least useful is the expression statement. It is any valid expression
|
||||
followed by a semicolon.
|
||||
|
||||
```
|
||||
1;
|
||||
4 / 2;
|
||||
"foo";
|
||||
"foo" + "bar";
|
||||
```
|
||||
|
||||
Despite the fact that these are valid the results are thrown away and can essentially
|
||||
be considered a noop. If we ever create a repl for ucg statements they may prove more
|
||||
useful.
|
||||
|
||||
Named Value Statements
|
||||
--------
|
||||
|
||||
### Let statements
|
||||
|
||||
There are two statements that can introduce a named value for a given ucg file. Let
|
||||
statnements and import statements. Any collisions in binding names inside a file are
|
||||
treated as compile errors. Bindings are immutable and once bound they can't be
|
||||
modified.
|
||||
|
||||
```
|
||||
let name = "foo";
|
||||
```
|
||||
|
||||
### Import Statement
|
||||
|
||||
The import statement imports the contents of another ucg file into the current file
|
||||
with a name. The imported files named values are exposed as a tuple in the referencing
|
||||
file. It starts with the `import` keyword and is followed by a quoted path to the ucg
|
||||
file, the keyword `as`, and a name for the imported values.
|
||||
|
||||
```
|
||||
import "dbconfigs.ucg" as dbconfigs;
|
||||
let mysqlconf = dbconfigs.mysql;
|
||||
```
|
||||
|
||||
Output Statements
|
||||
-----------
|
||||
|
||||
Some statements in ucg exist to generate an output. Either a compiled configuration or the results of test assertions.
|
||||
|
||||
### Assert Statements
|
||||
|
||||
The assert statement defines an expression that must evaluate to either true or false.
|
||||
Assert statements are noops except during a validation compile. They give you a way to
|
||||
assert certains properties about your data and can be used as a form of unit testing
|
||||
for your configurations. It starts with the `assert` keyword followed by a valid block
|
||||
of ucg statements delimited by `|` characters. The final statement in the in the block
|
||||
must evaluate to a boolean expression.
|
||||
|
||||
```
|
||||
assert |
|
||||
host == "www.example.com";
|
||||
|;
|
||||
|
||||
assert |
|
||||
select qa, 443, {
|
||||
qa = 80,
|
||||
prod = 443,
|
||||
} == 443;
|
||||
|;
|
||||
```
|
||||
|
||||
When _test.ucg files are run in a test run then ucg will output a log of all the assertions to stdout. Giving you a simple test harness for your ucg configs.
|
||||
|
||||
### Out Statements
|
||||
|
||||
The Out statement defines the output for a UCG file. It identifies the output
|
||||
converter type and an expression that will be output. The output converter type is
|
||||
expected to be one of the registered converters (e.g. json, exec) and the artifact
|
||||
file will take the same name as the ucg file with the extension replaced by the
|
||||
defined extension for that converter.
|
||||
|
||||
For a file named api_config.ucg with the following contents:
|
||||
|
||||
```
|
||||
let myconf = {
|
||||
api_url = "https://example.org/api/v1/",
|
||||
api_token = env.API_TOKEN,
|
||||
};
|
||||
out json myconf;
|
||||
```
|
||||
|
||||
ucg will output the myconf tuple as json to a file called api_config.json
|
87
docsite/site/content/reference/types.md
Normal file
87
docsite/site/content/reference/types.md
Normal file
@ -0,0 +1,87 @@
|
||||
+++
|
||||
title = "UCG types"
|
||||
weight = 2
|
||||
sort_by = "weight"
|
||||
in_search_index = true
|
||||
+++
|
||||
Primitive Values
|
||||
-------------
|
||||
|
||||
UCG has a few primitive types.
|
||||
|
||||
### Boolean
|
||||
|
||||
Boolean types can be either `true` or `false`. They are represented by symbols of the
|
||||
same name.
|
||||
|
||||
```
|
||||
true;
|
||||
false;
|
||||
```
|
||||
|
||||
### Integer
|
||||
|
||||
An Integer is any 64 bit integer number.
|
||||
|
||||
```
|
||||
1;
|
||||
```
|
||||
|
||||
### Float
|
||||
|
||||
A Float is any 64 bit floating point numer. You indicate a number is a Float by
|
||||
including a decimal point. Any number with a decimal point is a float.
|
||||
|
||||
```
|
||||
1.0;
|
||||
.0;
|
||||
1.;
|
||||
```
|
||||
|
||||
### String
|
||||
|
||||
Strings are any double quoted text.
|
||||
|
||||
```
|
||||
"This is a string";
|
||||
```
|
||||
|
||||
### NULL or the Empty type
|
||||
|
||||
NULL is the empty type. It represents the absence of a value. It is represented by the
|
||||
symbol `NULL`.
|
||||
|
||||
```
|
||||
let empty = NULL;
|
||||
```
|
||||
|
||||
Complex types
|
||||
-----------
|
||||
|
||||
UCG also has two complex types.
|
||||
|
||||
### Tuples
|
||||
|
||||
Tuples are an ordered set of name value pairs. They are delimited by braces and should
|
||||
contain 1 or more `name = expression` pairs separated by commas. Trailing commas are allowed.
|
||||
|
||||
```
|
||||
let tuple = {
|
||||
field = "value",
|
||||
inner = {
|
||||
number = 1,
|
||||
},
|
||||
};
|
||||
```
|
||||
|
||||
### Lists
|
||||
|
||||
Lists are a 0 indexed heterogenous list of expressions. The are delimited by square
|
||||
brackets and should contain 1 or more expressions separated by commas. Trailing commas
|
||||
are allowed.
|
||||
|
||||
```
|
||||
let list = [1, "two", {three = 3},];
|
||||
```
|
||||
|
||||
Next: <a href="expressions">Expressions</a>
|
2
docsite/site/themes/book/.gitignore
vendored
Normal file
2
docsite/site/themes/book/.gitignore
vendored
Normal file
@ -0,0 +1,2 @@
|
||||
.idea/
|
||||
public
|
21
docsite/site/themes/book/LICENSE
Normal file
21
docsite/site/themes/book/LICENSE
Normal file
@ -0,0 +1,21 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2017 Vincent Prouillet
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
54
docsite/site/themes/book/README.md
Normal file
54
docsite/site/themes/book/README.md
Normal file
@ -0,0 +1,54 @@
|
||||
# book
|
||||
|
||||
A theme based on [Gitbook](https://www.gitbook.com), to write documentation
|
||||
or books.
|
||||
|
||||

|
||||
|
||||
|
||||
## Contents
|
||||
|
||||
- [Installation](#installation)
|
||||
- [Options](#options)
|
||||
- [Numbered chapters](#numbered-chapters)
|
||||
|
||||
## Installation
|
||||
First download this theme to your `themes` directory:
|
||||
|
||||
```bash
|
||||
$ cd themes
|
||||
$ git clone https://github.com/Keats/book.git
|
||||
```
|
||||
and then enable it in your `config.toml`:
|
||||
|
||||
```toml
|
||||
theme = "book"
|
||||
# Optional, if you want search
|
||||
build_search_index = true
|
||||
```
|
||||
|
||||
## Usage
|
||||
Book will generate a book from the files you place in the `content` directory. Your book
|
||||
can have two levels of hierarchy: chapters and subchapters.
|
||||
|
||||
Each chapter should be a `section` within the Gutenberg site and should have an `_index.md`
|
||||
file that sets its `weight` front-matter variable to its chapter number. For example,
|
||||
chapter 2 should have `weight = 2`. Additionally, each chapter should also set the
|
||||
`sort_by = "weight"` in its front matter.
|
||||
|
||||
Each subchapter should be a `page` and should have its `weight` variable set to the subchapter
|
||||
number. For example, subchapter 3.4 should have `weight = 4`.
|
||||
|
||||
Finally, you should create an `_index.md` file and set the `redirect_to` front-matter variable
|
||||
to redirect to the first section of your content. For example, if your first section has the
|
||||
slug `introduction`, then you would set `redirect_to = "introduction"`.
|
||||
|
||||
## Options
|
||||
|
||||
### Numbered chapters
|
||||
By default, the `book` theme will number the chapters and pages in the left menu.
|
||||
You can disable that by setting the `book_numbered_chapters` in `extra`:
|
||||
|
||||
```toml
|
||||
book_numbered_chapters = false
|
||||
```
|
9
docsite/site/themes/book/config.toml
Normal file
9
docsite/site/themes/book/config.toml
Normal file
@ -0,0 +1,9 @@
|
||||
base_url = "https://gutenberg-book.netlify.com"
|
||||
compile_sass = true
|
||||
title = "book theme"
|
||||
description = "A book theme"
|
||||
highlight_code = true
|
||||
build_search_index = true
|
||||
|
||||
[extra]
|
||||
book_number_chapters = true
|
3
docsite/site/themes/book/content/_index.md
Normal file
3
docsite/site/themes/book/content/_index.md
Normal file
@ -0,0 +1,3 @@
|
||||
+++
|
||||
redirect_to = "chapter1"
|
||||
+++
|
66
docsite/site/themes/book/content/chapter1/_index.md
Normal file
66
docsite/site/themes/book/content/chapter1/_index.md
Normal file
@ -0,0 +1,66 @@
|
||||
+++
|
||||
title = "Introduction"
|
||||
weight = 1
|
||||
sort_by = "weight"
|
||||
insert_anchor_links = "right"
|
||||
+++
|
||||
|
||||
Testing every `elements` you can find in [CommonMark](http://commonmark.org).
|
||||
<!-- more -->
|
||||
|
||||
Quisque viverra a eros id auctor. Proin id nibh ut nisl dignissim pellentesque et ac mi. Nullam mattis urna quis consequat bibendum. Donec pretium dui elit, a semper purus tristique et. Mauris euismod nisl eu vehicula facilisis. Maecenas facilisis non massa non scelerisque. Integer malesuada cursus erat eu viverra. Duis ligula mi, eleifend vel justo id, laoreet porttitor ex. Etiam ultricies lacus lorem, sed aliquam nulla blandit in. Maecenas vel facilisis neque, vitae fringilla eros. In justo nibh, pellentesque sed faucibus nec, varius sit amet risus.
|
||||
|
||||
> This is a quote
|
||||
|
||||
- a
|
||||
- bullet
|
||||
- point
|
||||
|
||||
## Some code
|
||||
|
||||
```rust
|
||||
fn main() {
|
||||
let greetings = ["Hello", "Hola", "Bonjour",
|
||||
"Ciao", "こんにちは", "안녕하세요",
|
||||
"Cześć", "Olá", "Здравствуйте",
|
||||
"Chào bạn", "您好", "Hallo",
|
||||
"Hej", "Ahoj", "سلام"];
|
||||
|
||||
for (num, greeting) in greetings.iter().enumerate() {
|
||||
print!("{} : ", greeting);
|
||||
match num {
|
||||
0 => println!("This code is editable and runnable!"),
|
||||
1 => println!("¡Este código es editable y ejecutable!"),
|
||||
2 => println!("Ce code est modifiable et exécutable !"),
|
||||
3 => println!("Questo codice è modificabile ed eseguibile!"),
|
||||
4 => println!("このコードは編集して実行出来ます!"),
|
||||
5 => println!("여기에서 코드를 수정하고 실행할 수 있습니다!"),
|
||||
6 => println!("Ten kod można edytować oraz uruchomić!"),
|
||||
7 => println!("Este código é editável e executável!"),
|
||||
8 => println!("Этот код можно отредактировать и запустить!"),
|
||||
9 => println!("Bạn có thể edit và run code trực tiếp!"),
|
||||
10 => println!("这段代码是可以编辑并且能够运行的!"),
|
||||
11 => println!("Dieser Code kann bearbeitet und ausgeführt werden!"),
|
||||
12 => println!("Den här koden kan redigeras och köras!"),
|
||||
13 => println!("Tento kód můžete upravit a spustit"),
|
||||
14 => println!("این کد قابلیت ویرایش و اجرا دارد!"),
|
||||
_ => {},
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## A table
|
||||
|
||||
| a | table | in | markdown | !! |
|
||||
|----|-------|----|----------|---------------------------------|
|
||||
| 1 | 2 | 3 | 4 | 5 |
|
||||
| 1 | we | ew | we | with a longish column inside it |
|
||||
|
||||
## An image
|
||||
|
||||

|
||||
|
||||
## An iframe
|
||||
|
||||
{{ youtube(id="dQw4w9WgXcQ") }}
|
84
docsite/site/themes/book/content/chapter1/page1.md
Normal file
84
docsite/site/themes/book/content/chapter1/page1.md
Normal file
@ -0,0 +1,84 @@
|
||||
+++
|
||||
title = "Page 1"
|
||||
weight = 1
|
||||
+++
|
||||
|
||||
Pages and sections are actually very similar.
|
||||
|
||||
## Page variables
|
||||
Gutenberg will try to load the `templates/page.html` template, the `page.html` template of the theme if one is used
|
||||
or will render the built-in template: a blank page.
|
||||
|
||||
Whichever template you decide to render, you will get a `page` variable in your template
|
||||
with the following fields:
|
||||
|
||||
|
||||
```ts
|
||||
content: String;
|
||||
title: String?;
|
||||
description: String?;
|
||||
date: String?;
|
||||
slug: String;
|
||||
path: String;
|
||||
permalink: String;
|
||||
summary: String?;
|
||||
tags: Array<String>;
|
||||
category: String?;
|
||||
extra: HashMap<String, Any>;
|
||||
// Naive word count, will not work for languages without whitespace
|
||||
word_count: Number;
|
||||
// Based on https://help.medium.com/hc/en-us/articles/214991667-Read-time
|
||||
reading_time: Number;
|
||||
// `previous` and `next` are only filled if the content can be sorted
|
||||
previous: Page?;
|
||||
next: Page?;
|
||||
// See the Table of contents section below for more details
|
||||
toc: Array<Header>;
|
||||
```
|
||||
|
||||
## Section variables
|
||||
By default, Gutenberg will try to load `templates/section.html`. If there isn't
|
||||
one, it will render the built-in template: a blank page.
|
||||
|
||||
Whichever template you decide to render, you will get a `section` variable in your template
|
||||
with the following fields:
|
||||
|
||||
|
||||
```ts
|
||||
content: String;
|
||||
title: String?;
|
||||
description: String?;
|
||||
date: String?;
|
||||
slug: String;
|
||||
path: String;
|
||||
permalink: String;
|
||||
extra: HashMap<String, Any>;
|
||||
// Pages directly in this section, sorted if asked
|
||||
pages: Array<Pages>;
|
||||
// Direct subsections to this section, sorted by subsections weight
|
||||
subsections: Array<Section>;
|
||||
// Naive word count, will not work for languages without whitespace
|
||||
word_count: Number;
|
||||
// Based on https://help.medium.com/hc/en-us/articles/214991667-Read-time
|
||||
reading_time: Number;
|
||||
// See the Table of contents section below for more details
|
||||
toc: Array<Header>;
|
||||
```
|
||||
|
||||
## Table of contents
|
||||
|
||||
Both page and section have a `toc` field which corresponds to an array of `Header`.
|
||||
A `Header` has the following fields:
|
||||
|
||||
```ts
|
||||
// The hX level
|
||||
level: 1 | 2 | 3 | 4 | 5 | 6;
|
||||
// The generated slug id
|
||||
id: String;
|
||||
// The text of the header
|
||||
title: String;
|
||||
// A link pointing directly to the header, using the inserted anchor
|
||||
permalink: String;
|
||||
// All lower level headers below this header
|
||||
children: Array<Header>;
|
||||
```
|
6
docsite/site/themes/book/content/chapter2/_index.md
Normal file
6
docsite/site/themes/book/content/chapter2/_index.md
Normal file
@ -0,0 +1,6 @@
|
||||
+++
|
||||
title = "What is Gutenberg"
|
||||
weight = 2
|
||||
sort_by = "weight"
|
||||
insert_anchor_links = "right"
|
||||
+++
|
14
docsite/site/themes/book/content/chapter2/page1.md
Normal file
14
docsite/site/themes/book/content/chapter2/page1.md
Normal file
@ -0,0 +1,14 @@
|
||||
+++
|
||||
title = "Page 1"
|
||||
weight = 1
|
||||
+++
|
||||
|
||||
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Proin pulvinar, sem id fermentum sollicitudin, velit sem elementum nisl, at tempus odio lectus eu sapien. Quisque ligula diam, cursus sed nisi et, ultricies rhoncus diam. Integer nec tellus a ante dapibus tincidunt nec id lacus. Quisque eu aliquet dui. Etiam placerat, ex in luctus lobortis, sem augue pellentesque nulla, in gravida lacus dui id arcu. Nam vel metus a ipsum condimentum porta non quis purus. Nullam feugiat vitae felis eu imperdiet. Sed et faucibus ligula.
|
||||
|
||||
Morbi tempus semper tellus eget luctus. Morbi eu dui leo. Aliquam vel neque id risus laoreet pellentesque. In mattis tincidunt nulla, sit amet pharetra tellus facilisis vel. Nulla facilisi. Nunc blandit massa a ante interdum pulvinar. Suspendisse bibendum efficitur gravida. Praesent gravida urna a luctus molestie. Fusce accumsan ipsum elit, quis gravida urna condimentum sed. Aliquam erat volutpat. Quisque eget mollis lorem, sit amet ultricies mauris. Fusce vulputate sollicitudin magna eget facilisis. Nunc id dignissim sapien.
|
||||
|
||||
Nulla pharetra eget ligula vitae auctor. Praesent consectetur consectetur nunc, quis commodo arcu posuere tincidunt. Praesent auctor, augue ut tincidunt semper, dolor ex malesuada justo, sit amet feugiat velit leo a lectus. Curabitur et velit ut magna vulputate vehicula nec sed lorem. Ut rutrum, odio sit amet mollis scelerisque, enim arcu euismod odio, vel faucibus libero ex sit amet nisl. Proin nec orci nec elit vehicula sodales id eget ex. Etiam et aliquet lacus. Cras tortor orci, blandit nec eleifend nec, venenatis at nibh. Vivamus eu feugiat purus. Nam viverra lobortis dui, non eleifend mauris commodo eget. Vestibulum quis erat et turpis maximus pretium. Aenean ac placerat quam. Nulla elit tortor, ornare a libero non, eleifend vestibulum nulla. Donec justo lorem, accumsan a feugiat ullamcorper, fringilla vel augue. Sed convallis et odio rhoncus vestibulum. Vivamus finibus lacinia dui, volutpat tincidunt felis condimentum et.
|
||||
|
||||
Cras accumsan libero sed nulla facilisis varius. Nulla auctor nibh quis mauris tincidunt fermentum. Nulla sed consectetur odio, a fringilla libero. Curabitur tincidunt varius mollis. Cras ornare nec enim in vestibulum. Quisque tempor nunc arcu, eu accumsan tellus pulvinar nec. Donec venenatis cursus est sed gravida. Ut non nisi sit amet ligula facilisis volutpat. Praesent lorem quam, euismod sit amet consequat eu, aliquam at justo. Nunc vel condimentum velit. Duis pharetra laoreet nulla sed consectetur. Pellentesque malesuada mauris id nunc ultricies, quis viverra tellus porttitor.
|
||||
|
||||
Aliquam vitae lectus tortor. Etiam auctor tortor elit, vel scelerisque metus tempor et. Quisque condimentum, massa vel condimentum sagittis, justo risus convallis eros, ac accumsan dolor ante in justo. Quisque et lacus at lectus semper commodo. Cras id viverra sem. Aliquam venenatis, tortor at fringilla semper, metus libero dictum libero, consequat facilisis nunc dolor sed sem. Nulla blandit, justo a condimentum malesuada, mauris mi lacinia orci, at finibus odio mi quis velit. Maecenas vel justo in lorem tristique sodales.
|
6
docsite/site/themes/book/content/chapter3/_index.md
Normal file
6
docsite/site/themes/book/content/chapter3/_index.md
Normal file
@ -0,0 +1,6 @@
|
||||
+++
|
||||
title = "Chapter 3"
|
||||
weight = 3
|
||||
sort_by = "weight"
|
||||
insert_anchor_links = "right"
|
||||
+++
|
20
docsite/site/themes/book/content/chapter3/page1.md
Normal file
20
docsite/site/themes/book/content/chapter3/page1.md
Normal file
@ -0,0 +1,20 @@
|
||||
+++
|
||||
title = "Page 1"
|
||||
weight = 1
|
||||
+++
|
||||
|
||||
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Proin pulvinar, sem id fermentum sollicitudin, velit sem elementum nisl, at tempus odio lectus eu sapien. Quisque ligula diam, cursus sed nisi et, ultricies rhoncus diam. Integer nec tellus a ante dapibus tincidunt nec id lacus. Quisque eu aliquet dui. Etiam placerat, ex in luctus lobortis, sem augue pellentesque nulla, in gravida lacus dui id arcu. Nam vel metus a ipsum condimentum porta non quis purus. Nullam feugiat vitae felis eu imperdiet. Sed et faucibus ligula.
|
||||
|
||||
```js
|
||||
function isAllowed(user) {
|
||||
return user.admin || user.staff;
|
||||
}
|
||||
```
|
||||
|
||||
Morbi tempus semper tellus eget luctus. Morbi eu dui leo. Aliquam vel neque id risus laoreet pellentesque. In mattis tincidunt nulla, sit amet pharetra tellus facilisis vel. Nulla facilisi. Nunc blandit massa a ante interdum pulvinar. Suspendisse bibendum efficitur gravida. Praesent gravida urna a luctus molestie. Fusce accumsan ipsum elit, quis gravida urna condimentum sed. Aliquam erat volutpat. Quisque eget mollis lorem, sit amet ultricies mauris. Fusce vulputate sollicitudin magna eget facilisis. Nunc id dignissim sapien.
|
||||
|
||||
Nulla pharetra eget ligula vitae auctor. Praesent consectetur consectetur nunc, quis commodo arcu posuere tincidunt. Praesent auctor, augue ut tincidunt semper, dolor ex malesuada justo, sit amet feugiat velit leo a lectus. Curabitur et velit ut magna vulputate vehicula nec sed lorem. Ut rutrum, odio sit amet mollis scelerisque, enim arcu euismod odio, vel faucibus libero ex sit amet nisl. Proin nec orci nec elit vehicula sodales id eget ex. Etiam et aliquet lacus. Cras tortor orci, blandit nec eleifend nec, venenatis at nibh. Vivamus eu feugiat purus. Nam viverra lobortis dui, non eleifend mauris commodo eget. Vestibulum quis erat et turpis maximus pretium. Aenean ac placerat quam. Nulla elit tortor, ornare a libero non, eleifend vestibulum nulla. Donec justo lorem, accumsan a feugiat ullamcorper, fringilla vel augue. Sed convallis et odio rhoncus vestibulum. Vivamus finibus lacinia dui, volutpat tincidunt felis condimentum et.
|
||||
|
||||
Cras accumsan libero sed nulla facilisis varius. Nulla auctor nibh quis mauris tincidunt fermentum. Nulla sed consectetur odio, a fringilla libero. Curabitur tincidunt varius mollis. Cras ornare nec enim in vestibulum. Quisque tempor nunc arcu, eu accumsan tellus pulvinar nec. Donec venenatis cursus est sed gravida. Ut non nisi sit amet ligula facilisis volutpat. Praesent lorem quam, euismod sit amet consequat eu, aliquam at justo. Nunc vel condimentum velit. Duis pharetra laoreet nulla sed consectetur. Pellentesque malesuada mauris id nunc ultricies, quis viverra tellus porttitor.
|
||||
|
||||
Aliquam vitae lectus tortor. Etiam auctor tortor elit, vel scelerisque metus tempor et. Quisque condimentum, massa vel condimentum sagittis, justo risus convallis eros, ac accumsan dolor ante in justo. Quisque et lacus at lectus semper commodo. Cras id viverra sem. Aliquam venenatis, tortor at fringilla semper, metus libero dictum libero, consequat facilisis nunc dolor sed sem. Nulla blandit, justo a condimentum malesuada, mauris mi lacinia orci, at finibus odio mi quis velit. Maecenas vel justo in lorem tristique sodales.
|
20
docsite/site/themes/book/content/chapter3/page2.md
Normal file
20
docsite/site/themes/book/content/chapter3/page2.md
Normal file
@ -0,0 +1,20 @@
|
||||
+++
|
||||
title = "Page 2"
|
||||
weight = 2
|
||||
+++
|
||||
|
||||
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Proin pulvinar, sem id fermentum sollicitudin, velit sem elementum nisl, at tempus odio lectus eu sapien. Quisque ligula diam, cursus sed nisi et, ultricies rhoncus diam. Integer nec tellus a ante dapibus tincidunt nec id lacus. Quisque eu aliquet dui. Etiam placerat, ex in luctus lobortis, sem augue pellentesque nulla, in gravida lacus dui id arcu. Nam vel metus a ipsum condimentum porta non quis purus. Nullam feugiat vitae felis eu imperdiet. Sed et faucibus ligula.
|
||||
|
||||
```js
|
||||
function isAllowed(user) {
|
||||
return user.admin || user.staff;
|
||||
}
|
||||
```
|
||||
|
||||
Morbi tempus semper tellus eget luctus. Morbi eu dui leo. Aliquam vel neque id risus laoreet pellentesque. In mattis tincidunt nulla, sit amet pharetra tellus facilisis vel. Nulla facilisi. Nunc blandit massa a ante interdum pulvinar. Suspendisse bibendum efficitur gravida. Praesent gravida urna a luctus molestie. Fusce accumsan ipsum elit, quis gravida urna condimentum sed. Aliquam erat volutpat. Quisque eget mollis lorem, sit amet ultricies mauris. Fusce vulputate sollicitudin magna eget facilisis. Nunc id dignissim sapien.
|
||||
|
||||
Nulla pharetra eget ligula vitae auctor. Praesent consectetur consectetur nunc, quis commodo arcu posuere tincidunt. Praesent auctor, augue ut tincidunt semper, dolor ex malesuada justo, sit amet feugiat velit leo a lectus. Curabitur et velit ut magna vulputate vehicula nec sed lorem. Ut rutrum, odio sit amet mollis scelerisque, enim arcu euismod odio, vel faucibus libero ex sit amet nisl. Proin nec orci nec elit vehicula sodales id eget ex. Etiam et aliquet lacus. Cras tortor orci, blandit nec eleifend nec, venenatis at nibh. Vivamus eu feugiat purus. Nam viverra lobortis dui, non eleifend mauris commodo eget. Vestibulum quis erat et turpis maximus pretium. Aenean ac placerat quam. Nulla elit tortor, ornare a libero non, eleifend vestibulum nulla. Donec justo lorem, accumsan a feugiat ullamcorper, fringilla vel augue. Sed convallis et odio rhoncus vestibulum. Vivamus finibus lacinia dui, volutpat tincidunt felis condimentum et.
|
||||
|
||||
Cras accumsan libero sed nulla facilisis varius. Nulla auctor nibh quis mauris tincidunt fermentum. Nulla sed consectetur odio, a fringilla libero. Curabitur tincidunt varius mollis. Cras ornare nec enim in vestibulum. Quisque tempor nunc arcu, eu accumsan tellus pulvinar nec. Donec venenatis cursus est sed gravida. Ut non nisi sit amet ligula facilisis volutpat. Praesent lorem quam, euismod sit amet consequat eu, aliquam at justo. Nunc vel condimentum velit. Duis pharetra laoreet nulla sed consectetur. Pellentesque malesuada mauris id nunc ultricies, quis viverra tellus porttitor.
|
||||
|
||||
Aliquam vitae lectus tortor. Etiam auctor tortor elit, vel scelerisque metus tempor et. Quisque condimentum, massa vel condimentum sagittis, justo risus convallis eros, ac accumsan dolor ante in justo. Quisque et lacus at lectus semper commodo. Cras id viverra sem. Aliquam venenatis, tortor at fringilla semper, metus libero dictum libero, consequat facilisis nunc dolor sed sem. Nulla blandit, justo a condimentum malesuada, mauris mi lacinia orci, at finibus odio mi quis velit. Maecenas vel justo in lorem tristique sodales.
|
6
docsite/site/themes/book/content/chapter4/_index.md
Normal file
6
docsite/site/themes/book/content/chapter4/_index.md
Normal file
@ -0,0 +1,6 @@
|
||||
+++
|
||||
title = "A chapter without sub-parts"
|
||||
weight = 4
|
||||
sort_by = "weight"
|
||||
insert_anchor_links = "right"
|
||||
+++
|
6
docsite/site/themes/book/content/chapter5/_index.md
Normal file
6
docsite/site/themes/book/content/chapter5/_index.md
Normal file
@ -0,0 +1,6 @@
|
||||
+++
|
||||
title = "Another chapter without sub-parts"
|
||||
weight = 5
|
||||
sort_by = "weight"
|
||||
insert_anchor_links = "right"
|
||||
+++
|
222
docsite/site/themes/book/sass/_content.scss
Normal file
222
docsite/site/themes/book/sass/_content.scss
Normal file
@ -0,0 +1,222 @@
|
||||
.page {
|
||||
position: absolute;
|
||||
width: calc(100% - #{$sidebar-width});
|
||||
height: 100%;
|
||||
overflow-y: auto;
|
||||
color: #000;
|
||||
background: #fff;
|
||||
padding-bottom: 20px;
|
||||
transition: 0.5s;
|
||||
|
||||
.gutenberg-anchor {
|
||||
color: #4183c4;
|
||||
padding-left: 10px;
|
||||
text-decoration: none;
|
||||
font-weight: initial;
|
||||
|
||||
&:hover {
|
||||
text-decoration: underline;
|
||||
}
|
||||
}
|
||||
|
||||
img {
|
||||
max-width: 100%;
|
||||
}
|
||||
|
||||
&__content {
|
||||
a {
|
||||
color: #4183c4;
|
||||
text-decoration: none;
|
||||
|
||||
&:hover {
|
||||
text-decoration: underline;
|
||||
}
|
||||
}
|
||||
|
||||
hr {
|
||||
height: 4px;
|
||||
padding: 0;
|
||||
margin: 1.7em 0;
|
||||
overflow: hidden;
|
||||
background-color: #e7e7e7;
|
||||
border: none;
|
||||
}
|
||||
|
||||
pre {
|
||||
padding: 1rem;
|
||||
|
||||
span {
|
||||
white-space: pre-wrap;
|
||||
}
|
||||
}
|
||||
|
||||
blockquote {
|
||||
margin: 0;
|
||||
margin-bottom: .85em;
|
||||
padding: 0 15px;
|
||||
color: #858585;
|
||||
border-left: 4px solid #e5e5e5;
|
||||
}
|
||||
|
||||
code {
|
||||
display: inline-block;
|
||||
vertical-align: middle;
|
||||
padding: 0.1em 0.3em;
|
||||
border-radius: 3px;
|
||||
color: #6e6b5e;
|
||||
background: #f1f1f1;
|
||||
font-size: 0.875em;
|
||||
font-family: "Source Code Pro", Consolas, "Ubuntu Mono", Menlo, "DejaVu Sans Mono", monospace, monospace;
|
||||
}
|
||||
|
||||
iframe {
|
||||
border: 0;
|
||||
}
|
||||
|
||||
table {
|
||||
margin: 0 auto;
|
||||
border-collapse: collapse;
|
||||
border-color: #cccccc;
|
||||
|
||||
td {
|
||||
padding: 3px 20px;
|
||||
border: 1px solid #ccc;
|
||||
}
|
||||
|
||||
thead {
|
||||
th {
|
||||
padding: 6px 13px;
|
||||
font-weight: bold;
|
||||
border: 1px solid #ccc;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
font-size: 1.6rem;
|
||||
word-wrap: break-word;
|
||||
line-height: 1.7;
|
||||
position: relative;
|
||||
left: 0;
|
||||
max-width: 800px;
|
||||
margin: 0 auto;
|
||||
padding: 0 15px 40px;
|
||||
|
||||
p {
|
||||
margin-top: 0;
|
||||
margin-bottom: 0.85em;
|
||||
}
|
||||
}
|
||||
|
||||
.previous, .next {
|
||||
position: fixed;
|
||||
display: flex;
|
||||
top: 50px;
|
||||
bottom: 0;
|
||||
font-size: 2.5em;
|
||||
color: #ccc;
|
||||
text-decoration: none;
|
||||
text-align: center;
|
||||
margin: 0;
|
||||
max-width: 150px;
|
||||
min-width: 90px;
|
||||
justify-content: center;
|
||||
align-content: center;
|
||||
flex-direction: column;
|
||||
|
||||
&:hover {
|
||||
color: #333;
|
||||
}
|
||||
}
|
||||
|
||||
.previous {
|
||||
left: $sidebar-width;
|
||||
float: left;
|
||||
transition: left 0.5s;
|
||||
}
|
||||
|
||||
.next {
|
||||
// not 0 as it goes over the sidebar otherwise
|
||||
right: 15px;
|
||||
float: right;
|
||||
}
|
||||
|
||||
@include max-screen(1250px) {
|
||||
.previous, .next {
|
||||
position: static;
|
||||
top: auto;
|
||||
display: inline-block;
|
||||
max-width: 49%;
|
||||
width: 49%;
|
||||
|
||||
&:hover {
|
||||
text-decoration: none;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@include min-screen(600px) {
|
||||
.page {
|
||||
left: $sidebar-width;
|
||||
}
|
||||
}
|
||||
|
||||
.page-without-menu {
|
||||
width: 100%;
|
||||
left: 0;
|
||||
|
||||
.previous {
|
||||
left: 15px;
|
||||
}
|
||||
}
|
||||
|
||||
@include max-screen(600px) {
|
||||
.page {
|
||||
width: 100%;
|
||||
left: 0;
|
||||
}
|
||||
}
|
||||
|
||||
.search-container {
|
||||
display: none;
|
||||
|
||||
&--is-visible {
|
||||
display: block;
|
||||
}
|
||||
|
||||
#search {
|
||||
width: 100%;
|
||||
padding: 1rem;
|
||||
border: 1px solid #aaa;
|
||||
border-radius: 3px;
|
||||
background-color: #fafafa;
|
||||
color: #000;
|
||||
}
|
||||
|
||||
.search-results {
|
||||
&__header {
|
||||
font-weight: bold;
|
||||
padding: 1rem 0rem;
|
||||
}
|
||||
|
||||
&__items {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
list-style: none;
|
||||
}
|
||||
|
||||
&__item {
|
||||
margin-bottom: 1rem;
|
||||
}
|
||||
|
||||
&__teaser {
|
||||
font-size: 90%;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.search-mode {
|
||||
.prev-link, .next-link {
|
||||
display: none;
|
||||
}
|
||||
}
|
160
docsite/site/themes/book/sass/_header.scss
Normal file
160
docsite/site/themes/book/sass/_header.scss
Normal file
@ -0,0 +1,160 @@
|
||||
@mixin menu-icon() {
|
||||
@keyframes clickfirst {
|
||||
0% {
|
||||
transform: translateY(6px) rotate(0deg);
|
||||
|
||||
}
|
||||
|
||||
100% {
|
||||
transform: translateY(0) rotate(45deg);
|
||||
}
|
||||
}
|
||||
|
||||
@keyframes clickmid {
|
||||
0% {
|
||||
opacity: 1;
|
||||
}
|
||||
|
||||
100% {
|
||||
opacity: 0;
|
||||
}
|
||||
}
|
||||
|
||||
@keyframes clicklast {
|
||||
0% {
|
||||
transform: translateY(-6px) rotate(0deg);
|
||||
}
|
||||
|
||||
100% {
|
||||
transform: translateY(0) rotate(-45deg);
|
||||
}
|
||||
}
|
||||
|
||||
@keyframes outfirst {
|
||||
0% {
|
||||
transform: translateY(0) rotate(-45deg);
|
||||
}
|
||||
|
||||
100% {
|
||||
transform: translateY(-6px) rotate(0deg);
|
||||
}
|
||||
}
|
||||
|
||||
@keyframes outmid {
|
||||
0% {
|
||||
opacity: 0;
|
||||
}
|
||||
|
||||
100% {
|
||||
opacity: 1;
|
||||
}
|
||||
}
|
||||
|
||||
@keyframes outlast {
|
||||
0% {
|
||||
transform: translateY(0) rotate(45deg);
|
||||
}
|
||||
|
||||
100% {
|
||||
transform: translateY(6px) rotate(0deg);
|
||||
}
|
||||
}
|
||||
|
||||
span {
|
||||
position: absolute;
|
||||
/* fallback for browsers which still doesn't support for `calc()` */
|
||||
left: 15px;
|
||||
top: 25px;
|
||||
left: calc((100% - 20px) / 2);
|
||||
top: calc((100% - 1px) / 2);
|
||||
width: 20px;
|
||||
height: 2px;
|
||||
background-color: rgba(0, 0, 0, 0.5);
|
||||
|
||||
&:nth-child(1) {
|
||||
transform: translateY(6px) rotate(0deg);
|
||||
}
|
||||
|
||||
&:nth-child(3) {
|
||||
transform: translateY(-6px) rotate(0deg);
|
||||
}
|
||||
}
|
||||
|
||||
&.icon-click {
|
||||
span:nth-child(1) {
|
||||
animation-duration: 0.5s;
|
||||
animation-fill-mode: both;
|
||||
animation-name: clickfirst;
|
||||
}
|
||||
|
||||
span:nth-child(2) {
|
||||
animation-duration: 0.2s;
|
||||
animation-fill-mode: both;
|
||||
animation-name: clickmid;
|
||||
}
|
||||
|
||||
span:nth-child(3) {
|
||||
animation-duration: 0.5s;
|
||||
animation-fill-mode: both;
|
||||
animation-name: clicklast;
|
||||
}
|
||||
}
|
||||
|
||||
&.icon-out {
|
||||
span:nth-child(1) {
|
||||
animation-duration: 0.5s;
|
||||
animation-fill-mode: both;
|
||||
animation-name: outfirst;
|
||||
}
|
||||
|
||||
span:nth-child(2) {
|
||||
animation-duration: 0.2s;
|
||||
animation-fill-mode: both;
|
||||
animation-name: outmid;
|
||||
}
|
||||
|
||||
span:nth-child(3) {
|
||||
animation-duration: 0.5s;
|
||||
animation-fill-mode: both;
|
||||
animation-name: outlast;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.page__header {
|
||||
height: 50px;
|
||||
|
||||
.menu-icon {
|
||||
height: 50px;
|
||||
width: 50px;
|
||||
font-size: 24px;
|
||||
text-align: center;
|
||||
float: left;
|
||||
position: relative;
|
||||
transition: background .5s;
|
||||
cursor: pointer;
|
||||
|
||||
@include menu-icon();
|
||||
|
||||
&:hover {
|
||||
span {
|
||||
background-color: black;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.search-icon {
|
||||
height: 50px;
|
||||
width: 50px;
|
||||
display: inline-block;
|
||||
text-align: center;
|
||||
line-height: 50px;
|
||||
color: rgba(0, 0, 0, 0.5);
|
||||
cursor: pointer;
|
||||
font-size: 2rem;
|
||||
|
||||
&:hover {
|
||||
color: black
|
||||
}
|
||||
}
|
||||
}
|
50
docsite/site/themes/book/sass/_navigation.scss
Normal file
50
docsite/site/themes/book/sass/_navigation.scss
Normal file
@ -0,0 +1,50 @@
|
||||
.menu {
|
||||
height: 100%;
|
||||
position: absolute;
|
||||
left: 0;
|
||||
overflow-y: auto;
|
||||
width: 300px;
|
||||
color: #364149;
|
||||
background: #fafafa;
|
||||
border-right: 1px solid rgba(0, 0, 0, 0.07);
|
||||
transition: 0.5s;
|
||||
|
||||
ul {
|
||||
list-style: none;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
|
||||
a {
|
||||
display: block;
|
||||
color: #364149;
|
||||
text-overflow: ellipsis;
|
||||
overflow: hidden;
|
||||
white-space: nowrap;
|
||||
text-decoration: none;
|
||||
padding: 10px 15px;
|
||||
|
||||
&:hover {
|
||||
text-decoration: underline;
|
||||
}
|
||||
}
|
||||
|
||||
li.active > a {
|
||||
color: #008cff;
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
ul {
|
||||
padding-left: 20px;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.menu-hidden {
|
||||
width: 0;
|
||||
}
|
||||
|
||||
@include max-screen(600px) {
|
||||
.menu {
|
||||
width: 0;
|
||||
}
|
||||
}
|
447
docsite/site/themes/book/sass/_normalize.scss
Normal file
447
docsite/site/themes/book/sass/_normalize.scss
Normal file
@ -0,0 +1,447 @@
|
||||
/*! normalize.css v7.0.0 | MIT License | github.com/necolas/normalize.css */
|
||||
|
||||
/* Document
|
||||
========================================================================== */
|
||||
|
||||
/**
|
||||
* 1. Correct the line height in all browsers.
|
||||
* 2. Prevent adjustments of font size after orientation changes in
|
||||
* IE on Windows Phone and in iOS.
|
||||
*/
|
||||
|
||||
html {
|
||||
line-height: 1.15; /* 1 */
|
||||
-ms-text-size-adjust: 100%; /* 2 */
|
||||
-webkit-text-size-adjust: 100%; /* 2 */
|
||||
}
|
||||
|
||||
/* Sections
|
||||
========================================================================== */
|
||||
|
||||
/**
|
||||
* Remove the margin in all browsers (opinionated).
|
||||
*/
|
||||
|
||||
body {
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add the correct display in IE 9-.
|
||||
*/
|
||||
|
||||
article,
|
||||
aside,
|
||||
footer,
|
||||
header,
|
||||
nav,
|
||||
section {
|
||||
display: block;
|
||||
}
|
||||
|
||||
/**
|
||||
* Correct the font size and margin on `h1` elements within `section` and
|
||||
* `article` contexts in Chrome, Firefox, and Safari.
|
||||
*/
|
||||
|
||||
h1 {
|
||||
font-size: 2em;
|
||||
margin: 0.67em 0;
|
||||
}
|
||||
|
||||
/* Grouping content
|
||||
========================================================================== */
|
||||
|
||||
/**
|
||||
* Add the correct display in IE 9-.
|
||||
* 1. Add the correct display in IE.
|
||||
*/
|
||||
|
||||
figcaption,
|
||||
figure,
|
||||
main { /* 1 */
|
||||
display: block;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add the correct margin in IE 8.
|
||||
*/
|
||||
|
||||
figure {
|
||||
margin: 1em 40px;
|
||||
}
|
||||
|
||||
/**
|
||||
* 1. Add the correct box sizing in Firefox.
|
||||
* 2. Show the overflow in Edge and IE.
|
||||
*/
|
||||
|
||||
hr {
|
||||
box-sizing: content-box; /* 1 */
|
||||
height: 0; /* 1 */
|
||||
overflow: visible; /* 2 */
|
||||
}
|
||||
|
||||
/**
|
||||
* 1. Correct the inheritance and scaling of font size in all browsers.
|
||||
* 2. Correct the odd `em` font sizing in all browsers.
|
||||
*/
|
||||
|
||||
pre {
|
||||
font-family: monospace, monospace; /* 1 */
|
||||
font-size: 1em; /* 2 */
|
||||
}
|
||||
|
||||
/* Text-level semantics
|
||||
========================================================================== */
|
||||
|
||||
/**
|
||||
* 1. Remove the gray background on active links in IE 10.
|
||||
* 2. Remove gaps in links underline in iOS 8+ and Safari 8+.
|
||||
*/
|
||||
|
||||
a {
|
||||
background-color: transparent; /* 1 */
|
||||
-webkit-text-decoration-skip: objects; /* 2 */
|
||||
}
|
||||
|
||||
/**
|
||||
* 1. Remove the bottom border in Chrome 57- and Firefox 39-.
|
||||
* 2. Add the correct text decoration in Chrome, Edge, IE, Opera, and Safari.
|
||||
*/
|
||||
|
||||
abbr[title] {
|
||||
border-bottom: none; /* 1 */
|
||||
text-decoration: underline; /* 2 */
|
||||
text-decoration: underline dotted; /* 2 */
|
||||
}
|
||||
|
||||
/**
|
||||
* Prevent the duplicate application of `bolder` by the next rule in Safari 6.
|
||||
*/
|
||||
|
||||
b,
|
||||
strong {
|
||||
font-weight: inherit;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add the correct font weight in Chrome, Edge, and Safari.
|
||||
*/
|
||||
|
||||
b,
|
||||
strong {
|
||||
font-weight: bolder;
|
||||
}
|
||||
|
||||
/**
|
||||
* 1. Correct the inheritance and scaling of font size in all browsers.
|
||||
* 2. Correct the odd `em` font sizing in all browsers.
|
||||
*/
|
||||
|
||||
code,
|
||||
kbd,
|
||||
samp {
|
||||
font-family: monospace, monospace; /* 1 */
|
||||
font-size: 1em; /* 2 */
|
||||
}
|
||||
|
||||
/**
|
||||
* Add the correct font style in Android 4.3-.
|
||||
*/
|
||||
|
||||
dfn {
|
||||
font-style: italic;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add the correct background and color in IE 9-.
|
||||
*/
|
||||
|
||||
mark {
|
||||
background-color: #ff0;
|
||||
color: #000;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add the correct font size in all browsers.
|
||||
*/
|
||||
|
||||
small {
|
||||
font-size: 80%;
|
||||
}
|
||||
|
||||
/**
|
||||
* Prevent `sub` and `sup` elements from affecting the line height in
|
||||
* all browsers.
|
||||
*/
|
||||
|
||||
sub,
|
||||
sup {
|
||||
font-size: 75%;
|
||||
line-height: 0;
|
||||
position: relative;
|
||||
vertical-align: baseline;
|
||||
}
|
||||
|
||||
sub {
|
||||
bottom: -0.25em;
|
||||
}
|
||||
|
||||
sup {
|
||||
top: -0.5em;
|
||||
}
|
||||
|
||||
/* Embedded content
|
||||
========================================================================== */
|
||||
|
||||
/**
|
||||
* Add the correct display in IE 9-.
|
||||
*/
|
||||
|
||||
audio,
|
||||
video {
|
||||
display: inline-block;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add the correct display in iOS 4-7.
|
||||
*/
|
||||
|
||||
audio:not([controls]) {
|
||||
display: none;
|
||||
height: 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the border on images inside links in IE 10-.
|
||||
*/
|
||||
|
||||
img {
|
||||
border-style: none;
|
||||
}
|
||||
|
||||
/**
|
||||
* Hide the overflow in IE.
|
||||
*/
|
||||
|
||||
svg:not(:root) {
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
/* Forms
|
||||
========================================================================== */
|
||||
|
||||
/**
|
||||
* 1. Change the font styles in all browsers (opinionated).
|
||||
* 2. Remove the margin in Firefox and Safari.
|
||||
*/
|
||||
|
||||
button,
|
||||
input,
|
||||
optgroup,
|
||||
select,
|
||||
textarea {
|
||||
font-family: sans-serif; /* 1 */
|
||||
font-size: 100%; /* 1 */
|
||||
line-height: 1.15; /* 1 */
|
||||
margin: 0; /* 2 */
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the overflow in IE.
|
||||
* 1. Show the overflow in Edge.
|
||||
*/
|
||||
|
||||
button,
|
||||
input { /* 1 */
|
||||
overflow: visible;
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the inheritance of text transform in Edge, Firefox, and IE.
|
||||
* 1. Remove the inheritance of text transform in Firefox.
|
||||
*/
|
||||
|
||||
button,
|
||||
select { /* 1 */
|
||||
text-transform: none;
|
||||
}
|
||||
|
||||
/**
|
||||
* 1. Prevent a WebKit bug where (2) destroys native `audio` and `video`
|
||||
* controls in Android 4.
|
||||
* 2. Correct the inability to style clickable types in iOS and Safari.
|
||||
*/
|
||||
|
||||
button,
|
||||
html [type="button"], /* 1 */
|
||||
[type="reset"],
|
||||
[type="submit"] {
|
||||
-webkit-appearance: button; /* 2 */
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the inner border and padding in Firefox.
|
||||
*/
|
||||
|
||||
button::-moz-focus-inner,
|
||||
[type="button"]::-moz-focus-inner,
|
||||
[type="reset"]::-moz-focus-inner,
|
||||
[type="submit"]::-moz-focus-inner {
|
||||
border-style: none;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Restore the focus styles unset by the previous rule.
|
||||
*/
|
||||
|
||||
button:-moz-focusring,
|
||||
[type="button"]:-moz-focusring,
|
||||
[type="reset"]:-moz-focusring,
|
||||
[type="submit"]:-moz-focusring {
|
||||
outline: 1px dotted ButtonText;
|
||||
}
|
||||
|
||||
/**
|
||||
* Correct the padding in Firefox.
|
||||
*/
|
||||
|
||||
fieldset {
|
||||
padding: 0.35em 0.75em 0.625em;
|
||||
}
|
||||
|
||||
/**
|
||||
* 1. Correct the text wrapping in Edge and IE.
|
||||
* 2. Correct the color inheritance from `fieldset` elements in IE.
|
||||
* 3. Remove the padding so developers are not caught out when they zero out
|
||||
* `fieldset` elements in all browsers.
|
||||
*/
|
||||
|
||||
legend {
|
||||
box-sizing: border-box; /* 1 */
|
||||
color: inherit; /* 2 */
|
||||
display: table; /* 1 */
|
||||
max-width: 100%; /* 1 */
|
||||
padding: 0; /* 3 */
|
||||
white-space: normal; /* 1 */
|
||||
}
|
||||
|
||||
/**
|
||||
* 1. Add the correct display in IE 9-.
|
||||
* 2. Add the correct vertical alignment in Chrome, Firefox, and Opera.
|
||||
*/
|
||||
|
||||
progress {
|
||||
display: inline-block; /* 1 */
|
||||
vertical-align: baseline; /* 2 */
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the default vertical scrollbar in IE.
|
||||
*/
|
||||
|
||||
textarea {
|
||||
overflow: auto;
|
||||
}
|
||||
|
||||
/**
|
||||
* 1. Add the correct box sizing in IE 10-.
|
||||
* 2. Remove the padding in IE 10-.
|
||||
*/
|
||||
|
||||
[type="checkbox"],
|
||||
[type="radio"] {
|
||||
box-sizing: border-box; /* 1 */
|
||||
padding: 0; /* 2 */
|
||||
}
|
||||
|
||||
/**
|
||||
* Correct the cursor style of increment and decrement buttons in Chrome.
|
||||
*/
|
||||
|
||||
[type="number"]::-webkit-inner-spin-button,
|
||||
[type="number"]::-webkit-outer-spin-button {
|
||||
height: auto;
|
||||
}
|
||||
|
||||
/**
|
||||
* 1. Correct the odd appearance in Chrome and Safari.
|
||||
* 2. Correct the outline style in Safari.
|
||||
*/
|
||||
|
||||
[type="search"] {
|
||||
-webkit-appearance: textfield; /* 1 */
|
||||
outline-offset: -2px; /* 2 */
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the inner padding and cancel buttons in Chrome and Safari on macOS.
|
||||
*/
|
||||
|
||||
[type="search"]::-webkit-search-cancel-button,
|
||||
[type="search"]::-webkit-search-decoration {
|
||||
-webkit-appearance: none;
|
||||
}
|
||||
|
||||
/**
|
||||
* 1. Correct the inability to style clickable types in iOS and Safari.
|
||||
* 2. Change font properties to `inherit` in Safari.
|
||||
*/
|
||||
|
||||
::-webkit-file-upload-button {
|
||||
-webkit-appearance: button; /* 1 */
|
||||
font: inherit; /* 2 */
|
||||
}
|
||||
|
||||
/* Interactive
|
||||
========================================================================== */
|
||||
|
||||
/*
|
||||
* Add the correct display in IE 9-.
|
||||
* 1. Add the correct display in Edge, IE, and Firefox.
|
||||
*/
|
||||
|
||||
details, /* 1 */
|
||||
menu {
|
||||
display: block;
|
||||
}
|
||||
|
||||
/*
|
||||
* Add the correct display in all browsers.
|
||||
*/
|
||||
|
||||
summary {
|
||||
display: list-item;
|
||||
}
|
||||
|
||||
/* Scripting
|
||||
========================================================================== */
|
||||
|
||||
/**
|
||||
* Add the correct display in IE 9-.
|
||||
*/
|
||||
|
||||
canvas {
|
||||
display: inline-block;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add the correct display in IE.
|
||||
*/
|
||||
|
||||
template {
|
||||
display: none;
|
||||
}
|
||||
|
||||
/* Hidden
|
||||
========================================================================== */
|
||||
|
||||
/**
|
||||
* Add the correct display in IE 10-.
|
||||
*/
|
||||
|
||||
[hidden] {
|
||||
display: none;
|
||||
}
|
49
docsite/site/themes/book/sass/book.scss
Normal file
49
docsite/site/themes/book/sass/book.scss
Normal file
@ -0,0 +1,49 @@
|
||||
@charset "utf-8";
|
||||
|
||||
@import "normalize";
|
||||
|
||||
* {
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
html {
|
||||
font-size: 62.5%;
|
||||
}
|
||||
|
||||
body, html {
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
body {
|
||||
text-rendering: optimizeLegibility;
|
||||
font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
|
||||
font-size: 14px;
|
||||
letter-spacing: 0.2px;
|
||||
}
|
||||
|
||||
.footnote {
|
||||
text-decoration: underline;
|
||||
}
|
||||
|
||||
sup {
|
||||
font-weight: bold;
|
||||
font-size: 85%;
|
||||
}
|
||||
|
||||
@mixin min-screen($min-width: $body-width) {
|
||||
@media screen and (min-width: $min-width) {
|
||||
@content;
|
||||
}
|
||||
}
|
||||
|
||||
@mixin max-screen($max-width: $body-width) {
|
||||
@media screen and (max-width: $max-width) {
|
||||
@content;
|
||||
}
|
||||
}
|
||||
|
||||
$sidebar-width: 300px;
|
||||
|
||||
@import "navigation";
|
||||
@import "content";
|
||||
@import "header";
|
BIN
docsite/site/themes/book/screenshot.png
Normal file
BIN
docsite/site/themes/book/screenshot.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 142 KiB |
223
docsite/site/themes/book/static/book.js
Normal file
223
docsite/site/themes/book/static/book.js
Normal file
@ -0,0 +1,223 @@
|
||||
function initToggleMenu() {
|
||||
var $menu = document.querySelector(".menu");
|
||||
var $menuIcon = document.querySelector(".menu-icon");
|
||||
var $page = document.querySelector(".page");
|
||||
$menuIcon.addEventListener("click", function() {
|
||||
$menu.classList.toggle("menu-hidden");
|
||||
$page.classList.toggle("page-without-menu");
|
||||
});
|
||||
}
|
||||
|
||||
function debounce(func, wait) {
|
||||
var timeout;
|
||||
|
||||
return function () {
|
||||
var context = this;
|
||||
var args = arguments;
|
||||
clearTimeout(timeout);
|
||||
|
||||
timeout = setTimeout(function () {
|
||||
timeout = null;
|
||||
func.apply(context, args);
|
||||
}, wait);
|
||||
};
|
||||
}
|
||||
|
||||
// Taken from mdbook
|
||||
// The strategy is as follows:
|
||||
// First, assign a value to each word in the document:
|
||||
// Words that correspond to search terms (stemmer aware): 40
|
||||
// Normal words: 2
|
||||
// First word in a sentence: 8
|
||||
// Then use a sliding window with a constant number of words and count the
|
||||
// sum of the values of the words within the window. Then use the window that got the
|
||||
// maximum sum. If there are multiple maximas, then get the last one.
|
||||
// Enclose the terms in <b>.
|
||||
function makeTeaser(body, terms) {
|
||||
var TERM_WEIGHT = 40;
|
||||
var NORMAL_WORD_WEIGHT = 2;
|
||||
var FIRST_WORD_WEIGHT = 8;
|
||||
var TEASER_MAX_WORDS = 30;
|
||||
|
||||
var stemmedTerms = terms.map(function (w) {
|
||||
return elasticlunr.stemmer(w.toLowerCase());
|
||||
});
|
||||
var termFound = false;
|
||||
var index = 0;
|
||||
var weighted = []; // contains elements of ["word", weight, index_in_document]
|
||||
|
||||
// split in sentences, then words
|
||||
var sentences = body.toLowerCase().split(". ");
|
||||
|
||||
for (var i in sentences) {
|
||||
var words = sentences[i].split(" ");
|
||||
var value = FIRST_WORD_WEIGHT;
|
||||
|
||||
for (var j in words) {
|
||||
var word = words[j];
|
||||
|
||||
if (word.length > 0) {
|
||||
for (var k in stemmedTerms) {
|
||||
if (elasticlunr.stemmer(word).startsWith(stemmedTerms[k])) {
|
||||
value = TERM_WEIGHT;
|
||||
termFound = true;
|
||||
}
|
||||
}
|
||||
weighted.push([word, value, index]);
|
||||
value = NORMAL_WORD_WEIGHT;
|
||||
}
|
||||
|
||||
index += word.length;
|
||||
index += 1; // ' ' or '.' if last word in sentence
|
||||
}
|
||||
|
||||
index += 1; // because we split at a two-char boundary '. '
|
||||
}
|
||||
|
||||
if (weighted.length === 0) {
|
||||
return body;
|
||||
}
|
||||
|
||||
var windowWeights = [];
|
||||
var windowSize = Math.min(weighted.length, TEASER_MAX_WORDS);
|
||||
// We add a window with all the weights first
|
||||
var curSum = 0;
|
||||
for (var i = 0; i < windowSize; i++) {
|
||||
curSum += weighted[i][1];
|
||||
}
|
||||
windowWeights.push(curSum);
|
||||
|
||||
for (var i = 0; i < weighted.length - windowSize; i++) {
|
||||
curSum -= weighted[i][1];
|
||||
curSum += weighted[i + windowSize][1];
|
||||
windowWeights.push(curSum);
|
||||
}
|
||||
|
||||
// If we didn't find the term, just pick the first window
|
||||
var maxSumIndex = 0;
|
||||
if (termFound) {
|
||||
var maxFound = 0;
|
||||
// backwards
|
||||
for (var i = windowWeights.length - 1; i >= 0; i--) {
|
||||
if (windowWeights[i] > maxFound) {
|
||||
maxFound = windowWeights[i];
|
||||
maxSumIndex = i;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var teaser = [];
|
||||
var startIndex = weighted[maxSumIndex][2];
|
||||
for (var i = maxSumIndex; i < maxSumIndex + windowSize; i++) {
|
||||
var word = weighted[i];
|
||||
if (startIndex < word[2]) {
|
||||
// missing text from index to start of `word`
|
||||
teaser.push(body.substring(startIndex, word[2]));
|
||||
startIndex = word[2];
|
||||
}
|
||||
|
||||
// add <em/> around search terms
|
||||
if (word[1] === TERM_WEIGHT) {
|
||||
teaser.push("<b>");
|
||||
}
|
||||
startIndex = word[2] + word[0].length;
|
||||
teaser.push(body.substring(word[2], startIndex));
|
||||
|
||||
if (word[1] === TERM_WEIGHT) {
|
||||
teaser.push("</b>");
|
||||
}
|
||||
}
|
||||
teaser.push("…");
|
||||
return teaser.join("");
|
||||
}
|
||||
|
||||
function formatSearchResultItem(item, terms) {
|
||||
var li = document.createElement("li");
|
||||
li.classList.add("search-results__item");
|
||||
li.innerHTML = `<a href="${item.ref}">${item.doc.title}</a>`;
|
||||
li.innerHTML += `<div class="search-results__teaser">${makeTeaser(item.doc.body, terms)}</div>`;
|
||||
return li;
|
||||
}
|
||||
|
||||
// Go from the book view to the search view
|
||||
function toggleSearchMode() {
|
||||
var $bookContent = document.querySelector(".book-content");
|
||||
var $searchContainer = document.querySelector(".search-container");
|
||||
if ($searchContainer.classList.contains("search-container--is-visible")) {
|
||||
$searchContainer.classList.remove("search-container--is-visible");
|
||||
document.body.classList.remove("search-mode");
|
||||
$bookContent.style.display = "block";
|
||||
} else {
|
||||
$searchContainer.classList.add("search-container--is-visible");
|
||||
document.body.classList.add("search-mode");
|
||||
$bookContent.style.display = "none";
|
||||
document.getElementById("search").focus();
|
||||
}
|
||||
}
|
||||
|
||||
function initSearch() {
|
||||
var $searchInput = document.getElementById("search");
|
||||
if (!$searchInput) {
|
||||
return;
|
||||
}
|
||||
var $searchIcon = document.querySelector(".search-icon");
|
||||
$searchIcon.addEventListener("click", toggleSearchMode);
|
||||
|
||||
var $searchResults = document.querySelector(".search-results");
|
||||
var $searchResultsHeader = document.querySelector(".search-results__header");
|
||||
var $searchResultsItems = document.querySelector(".search-results__items");
|
||||
var MAX_ITEMS = 10;
|
||||
|
||||
var options = {
|
||||
bool: "AND",
|
||||
fields: {
|
||||
title: {boost: 2},
|
||||
body: {boost: 1},
|
||||
}
|
||||
};
|
||||
var currentTerm = "";
|
||||
var index = elasticlunr.Index.load(window.searchIndex);
|
||||
|
||||
$searchInput.addEventListener("keyup", debounce(function() {
|
||||
var term = $searchInput.value.trim();
|
||||
if (term === currentTerm || !index) {
|
||||
return;
|
||||
}
|
||||
$searchResults.style.display = term === "" ? "none" : "block";
|
||||
$searchResultsItems.innerHTML = "";
|
||||
if (term === "") {
|
||||
return;
|
||||
}
|
||||
|
||||
var results = index.search(term, options).filter(function (r) {
|
||||
return r.doc.body !== "";
|
||||
});
|
||||
if (results.length === 0) {
|
||||
$searchResultsHeader.innerText = `No search results for '${term}'.`;
|
||||
return;
|
||||
}
|
||||
|
||||
currentTerm = term;
|
||||
$searchResultsHeader.innerText = `${results.length} search results for '${term}':`;
|
||||
for (var i = 0; i < Math.min(results.length, MAX_ITEMS); i++) {
|
||||
if (!results[i].doc.body) {
|
||||
continue;
|
||||
}
|
||||
// var item = document.createElement("li");
|
||||
// item.innerHTML = formatSearchResultItem(results[i], term.split(" "));
|
||||
console.log(results[i]);
|
||||
$searchResultsItems.appendChild(formatSearchResultItem(results[i], term.split(" ")));
|
||||
}
|
||||
}, 150));
|
||||
}
|
||||
|
||||
if (document.readyState === "complete" ||
|
||||
(document.readyState !== "loading" && !document.documentElement.doScroll)
|
||||
) {
|
||||
initToggleMenu();
|
||||
} else {
|
||||
document.addEventListener("DOMContentLoaded", function () {
|
||||
initToggleMenu();
|
||||
initSearch();
|
||||
});
|
||||
}
|
111
docsite/site/themes/book/templates/index.html
Normal file
111
docsite/site/themes/book/templates/index.html
Normal file
@ -0,0 +1,111 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||
<meta http-equiv="content-type" content="text/html; charset=utf-8">
|
||||
|
||||
<!-- Enable responsiveness on mobile devices-->
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1">
|
||||
|
||||
<title>{% block title %}{{ config.title }}{% endblock title %}</title>
|
||||
|
||||
{% block js %}
|
||||
{% endblock js %}
|
||||
|
||||
<!-- CSS -->
|
||||
{% block css %}
|
||||
<link rel="stylesheet" href="{{ get_url(path="book.css", trailing_slash=false) | safe }}">
|
||||
{% endblock css %}
|
||||
|
||||
{% block extra_head %}
|
||||
{% endblock extra_head %}
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div class="menu">
|
||||
{% block before_menu %}
|
||||
{% endblock before_menu %}
|
||||
<nav role="navigation">
|
||||
<ul>
|
||||
<li><a href="/">Introduction</a></li>
|
||||
{% block menu %}
|
||||
{% set index = get_section(path="_index.md") %}
|
||||
{% for subsection in index.subsections %}
|
||||
<li {% if current_path == subsection.path %}class="active"{% endif %}>
|
||||
{% set chapter_num = loop.index %}
|
||||
<a href="{{ subsection.permalink }}">
|
||||
{% if config.extra.book_number_chapters %}<strong>{{ chapter_num }}.</strong>{% endif %}
|
||||
{{ subsection.title }}
|
||||
</a>
|
||||
{% if subsection.pages %}
|
||||
<ul>
|
||||
{% for page in subsection.pages %}
|
||||
<li {% if current_path == page.path %}class="active"{% endif %}>
|
||||
<a href="{{ page.permalink }}">
|
||||
{% if config.extra.book_number_chapters %}<strong>{{ chapter_num }}.{{ loop.index }}.</strong>{% endif %}
|
||||
{{ page.title }}
|
||||
</a>
|
||||
</li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
{% endif %}
|
||||
</li>
|
||||
{% endfor %}
|
||||
{% endblock menu %}
|
||||
</ul>
|
||||
</nav>
|
||||
{% block after_menu %}
|
||||
{% endblock after_menu %}
|
||||
</div>
|
||||
|
||||
<div class="page">
|
||||
<div class="page__header">
|
||||
<div class="menu-icon">
|
||||
<span></span>
|
||||
<span></span>
|
||||
<span></span>
|
||||
</div>
|
||||
{% if config.build_search_index %}
|
||||
<span class="search-icon">🔎</span>
|
||||
{% endif %}
|
||||
</div>
|
||||
|
||||
<div class="page__content">
|
||||
{% if config.build_search_index %}
|
||||
<div class="search-container">
|
||||
<input id="search" type="search" placeholder="Search..">
|
||||
<div class="search-results">
|
||||
<div class="search-results__header"></div>
|
||||
<ul class="search-results__items"></ul>
|
||||
</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
<div class="book-content">
|
||||
{% block content %}
|
||||
<h1>{{ section.title }}</h1>
|
||||
{{ section.content | safe }}
|
||||
{% endblock content %}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="prev-link">
|
||||
{% block prev_link %}
|
||||
{% endblock prev_link %}
|
||||
</div>
|
||||
|
||||
<div class="next-link">
|
||||
{% block next_link %}
|
||||
{% endblock next_link %}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{% block js_body %}
|
||||
{% if config.build_search_index %}
|
||||
<script type="text/javascript" src="{{ get_url(path="elasticlunr.min.js", trailing_slash=false) | safe }}"></script>
|
||||
<script type="text/javascript" src="{{ get_url(path="search_index.en.js", trailing_slash=false) | safe }}"></script>
|
||||
{% endif %}
|
||||
<script type="text/javascript" src="{{ get_url(path="book.js", trailing_slash=false) | safe }}"></script>
|
||||
{% endblock js_body %}
|
||||
</body>
|
||||
|
||||
</html>
|
45
docsite/site/themes/book/templates/page.html
Normal file
45
docsite/site/themes/book/templates/page.html
Normal file
@ -0,0 +1,45 @@
|
||||
{% extends "index.html" %}
|
||||
|
||||
|
||||
{% block content %}
|
||||
<h1>{{ page.title }}</h1>
|
||||
{{ page.content | safe }}
|
||||
{% endblock content %}
|
||||
|
||||
{% block prev_link %}
|
||||
{% if page.lighter %}
|
||||
<a class="previous" href="{{ page.lighter.permalink }}"><</a>
|
||||
{% else %}
|
||||
{# No page before, find the link for the section it's in if there is one #}
|
||||
{% set index = get_section(path="_index.md") %}
|
||||
{% for subsection in index.subsections %}
|
||||
{% for p in subsection.pages %}
|
||||
{% if p.permalink == page.permalink %}
|
||||
<a class="previous" href="{{ subsection.permalink }}"><</a>
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
{% endblock prev_link %}
|
||||
|
||||
{% block next_link %}
|
||||
{% if page.heavier %}
|
||||
<a class="next" href="{{ page.heavier.permalink }}">></a>
|
||||
{% else %}
|
||||
{# No page after, find the link for the following section #}
|
||||
{% set index = get_section(path="_index.md") %}
|
||||
{% set found_current = false %}
|
||||
{% for subsection in index.subsections %}
|
||||
{% if found_current %}
|
||||
<a class="next" href="{{ subsection.permalink }}">></a>
|
||||
{# no break #}
|
||||
{% set_global found_current = false %}
|
||||
{% endif %}
|
||||
{% for p in subsection.pages %}
|
||||
{% if p.permalink == page.permalink %}
|
||||
{% set_global found_current = true %}
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
{% endblock next_link %}
|
50
docsite/site/themes/book/templates/section.html
Normal file
50
docsite/site/themes/book/templates/section.html
Normal file
@ -0,0 +1,50 @@
|
||||
{% extends "index.html" %}
|
||||
|
||||
{% block content %}
|
||||
<h1>{{ section.title }}</h1>
|
||||
{{ section.content | safe }}
|
||||
{% endblock content %}
|
||||
|
||||
{% block prev_link %}
|
||||
{# need to find the last page of the previous section or the previous section directly
|
||||
if there isn't any pages in it #}
|
||||
{% set index = get_section(path="_index.md") %}
|
||||
{% set found_current = false %}
|
||||
{% for subsection in index.subsections | reverse %}
|
||||
{% if subsection.permalink == section.permalink %}
|
||||
{% set_global found_current = true %}
|
||||
{% else %}
|
||||
{% if found_current %}
|
||||
{% if subsection.pages %}
|
||||
{% set last_page = subsection.pages | last %}
|
||||
<a class="previous" href="{{ last_page.permalink }}"><</a>
|
||||
{% else %}
|
||||
<a class="previous" href="{{ subsection.permalink }}"><</a>
|
||||
{% endif %}
|
||||
{# no break #}
|
||||
{% set_global found_current = false %}
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
{% endblock prev_link %}
|
||||
|
||||
{% block next_link %}
|
||||
{% if section.pages %}
|
||||
{% set next_page = section.pages | first %}
|
||||
<a class="next" href="{{ next_page.permalink }}">></a>
|
||||
{% else %}
|
||||
{# No page in the section, find the link for the following section #}
|
||||
{% set index = get_section(path="_index.md") %}
|
||||
{% set found_current = false %}
|
||||
{% for subsection in index.subsections %}
|
||||
{% if found_current %}
|
||||
<a class="next" href="{{ subsection.permalink }}">></a>
|
||||
{# no break #}
|
||||
{% set_global found_current = false %}
|
||||
{% endif %}
|
||||
{% if subsection.permalink == section.permalink %}
|
||||
{% set_global found_current = true %}
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
{% endblock next_link %}
|
13
docsite/site/themes/book/theme.toml
Normal file
13
docsite/site/themes/book/theme.toml
Normal file
@ -0,0 +1,13 @@
|
||||
name = "book"
|
||||
description = "A book theme inspired from GitBook/mdBook"
|
||||
license = "MIT"
|
||||
homepage = "https://github.com/Keats/book"
|
||||
min_version = "0.4.0"
|
||||
demo = "https://gutenberg-book.netlify.com"
|
||||
|
||||
[extra]
|
||||
book_number_chapters = true
|
||||
|
||||
[author]
|
||||
name = "Vincent Prouillet"
|
||||
homepage = "https://vincent.is"
|
2
docsite/ucglib/globals.ucg
Normal file
2
docsite/ucglib/globals.ucg
Normal file
@ -0,0 +1,2 @@
|
||||
let location = "us-east1";
|
||||
let project = "ucg-configuration-project";
|
40
docsite/ucglib/macros.ucg
Normal file
40
docsite/ucglib/macros.ucg
Normal file
@ -0,0 +1,40 @@
|
||||
let bucketbase = macro(name, project, location) => {
|
||||
name = name,
|
||||
type = "storage.v1.bucket",
|
||||
properties = {
|
||||
bucket = name,
|
||||
project = project,
|
||||
location = location,
|
||||
acl = [
|
||||
{
|
||||
entity = "project-owners-ucg-configuration-project",
|
||||
role = "OWNER",
|
||||
},
|
||||
{
|
||||
entity = "project-editors-ucg-configuration-project",
|
||||
role = "WRITER",
|
||||
},
|
||||
{
|
||||
entity = "project-viewers-ucg-configuration-project",
|
||||
role = "READER",
|
||||
},
|
||||
],
|
||||
defaultObjectAcl = [
|
||||
{
|
||||
entity = "allUsers",
|
||||
role = "READER",
|
||||
},
|
||||
],
|
||||
|
||||
},
|
||||
};
|
||||
|
||||
let bucketSelfLink = macro(bucket) => {
|
||||
name = "@selfLink" % (bucket),
|
||||
value = "https://console.cloud.google.com/storage/browser/@" % (bucket),
|
||||
};
|
||||
|
||||
let bucketGsLink = macro(bucket) => {
|
||||
name = "@gsLink" % (bucket),
|
||||
value = "gs://@" % (bucket),
|
||||
};
|
Loading…
x
Reference in New Issue
Block a user