From b4831a3e59b93ef7b92e47a84460e708ec47c0d3 Mon Sep 17 00:00:00 2001 From: Matthias Kretschmann Date: Thu, 7 Sep 2017 12:13:50 +0200 Subject: [PATCH] move over code examples, add syntax highlighting --- _src/_assets/scss/_code.scss | 33 ++++++++++++++++++++++-- _src/_assets/scss/_syntax.scss | 35 +++++++++++++++++++++++++ _src/_assets/scss/ipdb.scss | 1 + _src/docs.md | 47 +++++++++++++++++++++++++++++----- 4 files changed, 108 insertions(+), 8 deletions(-) create mode 100644 _src/_assets/scss/_syntax.scss diff --git a/_src/_assets/scss/_code.scss b/_src/_assets/scss/_code.scss index 0741e4e..e9c359c 100644 --- a/_src/_assets/scss/_code.scss +++ b/_src/_assets/scss/_code.scss @@ -8,12 +8,41 @@ kbd, pre, samp { font-family: $font-family-monospace; - font-size: $font-size-small; + font-size: $font-size-mini; hyphens: none; } // Inline code code { color: $brand-04; - opacity: .85; +} + +// Blocks of code +pre { + display: block; + padding: $spacer; + line-height: 1.5; + word-break: break-all; + word-wrap: break-word; + background-color: rgba($brand-05, .6); + border-radius: $border-radius; + + // make 'em scrollable + overflow: scroll; + -webkit-overflow-scrolling: touch; + max-height: 20rem; + + // Account for some code outputs that place code tags in pre tags + code { + padding: 0; + font-size: inherit; + color: inherit; + white-space: pre; + overflow-wrap: normal; + word-wrap: normal; + word-break: normal; + overflow: auto; + background-color: transparent; + border-radius: 0; + } } diff --git a/_src/_assets/scss/_syntax.scss b/_src/_assets/scss/_syntax.scss new file mode 100644 index 0000000..bbdd360 --- /dev/null +++ b/_src/_assets/scss/_syntax.scss @@ -0,0 +1,35 @@ +/* stylelint-disable */ + +.highlight .hll { background-color: #ffffcc } +.highlight .c { color: #008000 } /* Comment */ +.highlight .err { border: 1px solid #FF0000 } /* Error */ +.highlight .k { color: #0000ff } /* Keyword */ +.highlight .cm { color: #008000 } /* Comment.Multiline */ +.highlight .cp { color: #0000ff } /* Comment.Preproc */ +.highlight .c1 { color: #008000 } /* Comment.Single */ +.highlight .cs { color: #008000 } /* Comment.Special */ +.highlight .ge { font-style: italic } /* Generic.Emph */ +.highlight .gh { font-weight: bold } /* Generic.Heading */ +.highlight .gp { font-weight: bold } /* Generic.Prompt */ +.highlight .gs { font-weight: bold } /* Generic.Strong */ +.highlight .gu { font-weight: bold } /* Generic.Subheading */ +.highlight .kc { color: #0000ff } /* Keyword.Constant */ +.highlight .kd { color: #0000ff } /* Keyword.Declaration */ +.highlight .kn { color: #0000ff } /* Keyword.Namespace */ +.highlight .kp { color: #0000ff } /* Keyword.Pseudo */ +.highlight .kr { color: #0000ff } /* Keyword.Reserved */ +.highlight .kt { color: #2b91af } /* Keyword.Type */ +.highlight .s { color: #a31515 } /* Literal.String */ +.highlight .nc { color: #2b91af } /* Name.Class */ +.highlight .ow { color: #0000ff } /* Operator.Word */ +.highlight .sb { color: #a31515 } /* Literal.String.Backtick */ +.highlight .sc { color: #a31515 } /* Literal.String.Char */ +.highlight .sd { color: #a31515 } /* Literal.String.Doc */ +.highlight .s2 { color: #a31515 } /* Literal.String.Double */ +.highlight .se { color: #a31515 } /* Literal.String.Escape */ +.highlight .sh { color: #a31515 } /* Literal.String.Heredoc */ +.highlight .si { color: #a31515 } /* Literal.String.Interpol */ +.highlight .sx { color: #a31515 } /* Literal.String.Other */ +.highlight .sr { color: #a31515 } /* Literal.String.Regex */ +.highlight .s1 { color: #a31515 } /* Literal.String.Single */ +.highlight .ss { color: #a31515 } /* Literal.String.Symbol */ diff --git a/_src/_assets/scss/ipdb.scss b/_src/_assets/scss/ipdb.scss index fd54979..aa4c2f1 100644 --- a/_src/_assets/scss/ipdb.scss +++ b/_src/_assets/scss/ipdb.scss @@ -18,6 +18,7 @@ @import 'board'; @import 'alerts'; @import 'cookiebanner'; +@import 'syntax'; .content--page--markdown { padding-top: $spacer * 2; diff --git a/_src/docs.md b/_src/docs.md index 758a940..a008eef 100644 --- a/_src/docs.md +++ b/_src/docs.md @@ -27,7 +27,46 @@ If you, as a developer, want to allow users to send HTTP requests directly to th ## How to Make HTTP Requests -The IPDB Test Network is an instance of a BigchainDB cluster. The API is the [BigchainDB HTTP API](https://docs.bigchaindb.com/projects/server/en/latest/drivers-clients/http-client-server-api.html). Sign in and visit the home page for specific instructions about how to send requests to the IPDB Test Network. +The IPDB Test Network is an instance of a BigchainDB cluster. The API is documented under [BigchainDB HTTP API](https://docs.bigchaindb.com/projects/server/en/latest/drivers-clients/http-client-server-api.html). + +### API root endpoint + +``` +https://test.ipdb.io/api/v1/ +``` + +### Examples + +#### Connect using Python + +```python +from bigchaindb_driver import BigchainDB +tokens = {} +tokens['app_id'] = 'bcdc4699' +tokens['app_key'] = '0ab98d2ca2e8ca6f37518b9d0eb5ac50' +bdb = BigchainDB('https://test.ipdb.io', headers=tokens) +``` +[BigchainDB Python driver on GitHub](https://github.com/bigchaindb/bigchaindb-driver) | [Python driver usage documentation](https://docs.bigchaindb.com/projects/py-driver/en/master/usage.html) + +#### Connect using Node.js + +```js +const driver = require('bigchaindb-driver') +let bdb = new driver.Connection('https://test.ipdb.io/api/v1/', { + app_id: 'bcdc4699', + app_key: '0ab98d2ca2e8ca6f37518b9d0eb5ac50' +}) +``` +[BigchainDB JavaScript driver on GitHub](https://github.com/bigchaindb/js-bigchaindb-driver) + +#### Connect using curl + +```bash +curl -X "POST" "https://test.ipdb.io/api/v1/transactions/" \ + -H "app_id: bcdc4699" \ + -H "app_key: 0ab98d2ca2e8ca6f37518b9d0eb5ac50" \ + -d "@tx.json" +``` ### Limits @@ -41,8 +80,7 @@ The IPDB Test Network is an instance of a BigchainDB cluster. The API is the [Bi There are two ways for a developer to create a new application. -1. One way is to sign in on the developer portal, click APPLICATIONS in the top menu, and then click the button labelled "Create new application". - +1. One way is to sign in on the developer portal, click APPLICATIONS in the top menu, and then click the button labelled *Create new application*. 2. A second way is to make an HTTP request to the IPDB-Agent, an online microservice that can create new applications on behalf of IPDB. If you'd like to do this, please contact us using the IPDB Foundation's [contact page](/contact/). ## Billing @@ -54,11 +92,8 @@ Right now, the IPDB Test Network only has one plan: a free plan, but it has a li The IPDB Production Network is not currently available, but we intend to offer the following plans once it is available: 1. Free: 10 MB data transfer (IN) per month (about 10k transactions`*`) - 2. $20 per month: 200 MB data transfer (IN) per month (about 200k transactions*) - 3. $50 per month: 500 MB data transfer (IN) per month (about 500k transactions*) - 4. $100 per month: 1000 MB data transfer (IN) per month (about 1M transactions*) `*`assuming an average transaction size of 1 kb (typical).