diff --git a/.gitignore b/.gitignore new file mode 100644 index 00000000..0c3e5abb --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +_site/ +.sass-cache/ diff --git a/_api/1_1_books_list.md b/_api/1_1_books_list.md new file mode 100644 index 00000000..1a551cbe --- /dev/null +++ b/_api/1_1_books_list.md @@ -0,0 +1,55 @@ +--- +title: /books +type: get +description: List all books +parameters: + title: List Book Format + data: + - offset: + - integer + - Offset the results by this amount + - limit: + - integer + - Limit the number of books returned +right_code: + return: | + [ + { + "id": 1, + "title": "The Hunger Games", + "score": 4.5, + "date_added": "12/12/2013" + }, + { + "id": 1, + "title": "The Hunger Games", + "score": 4.7, + "date_added": "15/12/2013" + }, + ] +--- + +

Lists all the photos you have access to. You can paginate by using the parameters listed above.

+ +
+
+  $.get('http://api.myapp.com/books/', { token: 'YOUR_APP_KEY'}, function(data) {
+    alert(data);
+  });
+ +
+  r = requests.get('http://api.myapp.com/books/', token="YOUR_APP_KEY")
+  print r.text
+ +
+  var request = require('request');
+  request('http://api.myapp.com/books?token=YOUR_APP_KEY', function (error, response, body) {
+    if (!error && response.statusCode == 200) {
+      console.log(body);
+    }
+  })
+ +
+  curl http://sampleapi.readme.com/orders?key=YOUR_APP_KEY
+ +
diff --git a/_api/1_2_books_add.md b/_api/1_2_books_add.md new file mode 100644 index 00000000..ff5fa13f --- /dev/null +++ b/_api/1_2_books_add.md @@ -0,0 +1,35 @@ +--- +title: /books +type: post +description: Create Book +parameters: + title: Create Book Format + data: + - title: + - string + - The title for the book + - score: + - float + - The book's score between 0 and 5 +right_code: + response: | + { + "id": 3, + "title": "The Book Thief", + "score": 4.3, + "date_added": "5/1/2015" + } +--- + +Adds a book to your collection. + +
+
+  $.post('http://api.myapp.com/books/', {
+    token: 'YOUR_APP_KEY',
+    title: "The Book Thief",
+    score: 4.3
+  }, function(data) {
+    alert(data);
+  });
+
diff --git a/_api/1_3_books_get.md b/_api/1_3_books_get.md new file mode 100644 index 00000000..aedc771c --- /dev/null +++ b/_api/1_3_books_get.md @@ -0,0 +1,24 @@ +--- +title: /books/:id +type: get +description: Get Book +right_code: + response: | + { + "id": 3, + "title": "The Book Thief", + "score": 4.3, + "date_added": "5/1/2015" + } +--- + +Returns a specific book from your collection + +
+
+  $.get('http://api.myapp.com/books/3', {
+    token: 'YOUR_APP_KEY',
+  }, function(data) {
+    alert(data);
+  });
+
diff --git a/_api/1_4_books_update.md b/_api/1_4_books_update.md new file mode 100644 index 00000000..66412292 --- /dev/null +++ b/_api/1_4_books_update.md @@ -0,0 +1,39 @@ +--- +title: /books/:id +type: put +description: Update Book +parameters: + title: Update Book Format + data: + - title: + - string + - The title for the book + - score: + - float + - The book's score between 0 and 5 +right_code: + response: | + { + "id": 3, + "title": "The Book Stealer", + "score": 5, + "date_added": "5/1/2015" + } +--- + +Update an existing book in your collection. + +
+
+  $.ajax({
+    url: 'http://api.myapp.com/books/3'
+    type: 'PUT',
+    data: {
+      token: 'YOUR_APP_KEY',
+      score: 5.0,
+      title: "The Book Stealer"
+    },
+    success: function(data) {
+      alert(data);
+  });
+
diff --git a/_api/1_5_books_delete.md b/_api/1_5_books_delete.md new file mode 100644 index 00000000..1a8365a8 --- /dev/null +++ b/_api/1_5_books_delete.md @@ -0,0 +1,25 @@ +--- +title: /books/:id +type: delete +description: Deletes a book +right_code: + response: | + { + "id": 3, + "status": "deleted" + } +--- +Deletes a book in your collection. + +
+
+  $.ajax({
+    url: 'http://api.myapp.com/books/3'
+    type: 'DELETE',
+    data: {
+      token: 'YOUR_APP_KEY'
+    },
+    success: function(data) {
+      alert(data);
+  });
+
diff --git a/_config.yml b/_config.yml new file mode 100644 index 00000000..17b00361 --- /dev/null +++ b/_config.yml @@ -0,0 +1,7 @@ +collections: + documentation: + title: Documentation + render: true + api: + title: APIs + render: true diff --git a/_documentation/1_getting_started.html b/_documentation/1_getting_started.html new file mode 100644 index 00000000..33fbb8c4 --- /dev/null +++ b/_documentation/1_getting_started.html @@ -0,0 +1,18 @@ +--- +title: Getting Started +description: An intro to our API +right_code: +--- + + +

Welcome to our API!

+ +

This API document is designed for those interested in developing for our platform.

+ +
+
Warning
+ +

Something terrible will happen if you try and do this.

+
+ +

This API is still under development and will evolve.

diff --git a/_documentation/2_authentication.html b/_documentation/2_authentication.html new file mode 100644 index 00000000..8684f3b8 --- /dev/null +++ b/_documentation/2_authentication.html @@ -0,0 +1,20 @@ +--- +title: Authentication +right_code: + jQuery: | + $.get('http://api.myapp.com/books/', { token: 'YOUR_APP_KEY'}, function(data) { + alert(data); + }); + cURL: | + curl http://api.myapp.com/books?token=YOUR_APP_KEY +--- + +

You need to be authenticated for all API requests. You can generate an API key in your developer dashboard.

+ +

Add the API key to all requests as a GET parameter.

+ +
+
Uh ohhh
+ +

Nothing will work unless you include this API key.

+
diff --git a/_documentation/3_errors.html b/_documentation/3_errors.html new file mode 100644 index 00000000..f9448352 --- /dev/null +++ b/_documentation/3_errors.html @@ -0,0 +1,46 @@ +--- +title: Errors +description: These are all the errors the API could return + +--- + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
CodeNameDescription
200OKSuccess
201CreatedCreation successful
400Bad RequestWe could not process that action
403ForbiddenWe couldn't authenticate you
+ +

All errors will return JSON in the following format:

+ +
+{
+  error: true,
+  message: "error message here"
+}
diff --git a/_includes/sidebar.html b/_includes/sidebar.html new file mode 100644 index 00000000..79762afd --- /dev/null +++ b/_includes/sidebar.html @@ -0,0 +1,17 @@ + diff --git a/_layouts/default.html b/_layouts/default.html new file mode 100644 index 00000000..2956a8be --- /dev/null +++ b/_layouts/default.html @@ -0,0 +1,48 @@ + + + + + {{page.title}} + + + + + + + + + + + + + + + + {% if page.sidebar %} + {% include sidebar.html %} + {% endif %} +
+ {{content}} +
+ + diff --git a/_more/1_twitter.md b/_more/1_twitter.md new file mode 100644 index 00000000..6c33ab98 --- /dev/null +++ b/_more/1_twitter.md @@ -0,0 +1,4 @@ +--- +name: Twitter (@orderapi) +link: '#' +--- diff --git a/_more/2_email.md b/_more/2_email.md new file mode 100644 index 00000000..17a1d0fd --- /dev/null +++ b/_more/2_email.md @@ -0,0 +1,4 @@ +--- +name: Email (help@orderapi.com) +link: '#' +--- diff --git a/css/normalize.css b/css/normalize.css new file mode 100644 index 00000000..81c6f31e --- /dev/null +++ b/css/normalize.css @@ -0,0 +1,427 @@ +/*! normalize.css v3.0.2 | MIT License | git.io/normalize */ + +/** + * 1. Set default font family to sans-serif. + * 2. Prevent iOS text size adjust after orientation change, without disabling + * user zoom. + */ + +html { + font-family: sans-serif; /* 1 */ + -ms-text-size-adjust: 100%; /* 2 */ + -webkit-text-size-adjust: 100%; /* 2 */ +} + +/** + * Remove default margin. + */ + +body { + margin: 0; +} + +/* HTML5 display definitions + ========================================================================== */ + +/** + * Correct `block` display not defined for any HTML5 element in IE 8/9. + * Correct `block` display not defined for `details` or `summary` in IE 10/11 + * and Firefox. + * Correct `block` display not defined for `main` in IE 11. + */ + +article, +aside, +details, +figcaption, +figure, +footer, +header, +hgroup, +main, +menu, +nav, +section, +summary { + display: block; +} + +/** + * 1. Correct `inline-block` display not defined in IE 8/9. + * 2. Normalize vertical alignment of `progress` in Chrome, Firefox, and Opera. + */ + +audio, +canvas, +progress, +video { + display: inline-block; /* 1 */ + vertical-align: baseline; /* 2 */ +} + +/** + * Prevent modern browsers from displaying `audio` without controls. + * Remove excess height in iOS 5 devices. + */ + +audio:not([controls]) { + display: none; + height: 0; +} + +/** + * Address `[hidden]` styling not present in IE 8/9/10. + * Hide the `template` element in IE 8/9/11, Safari, and Firefox < 22. + */ + +[hidden], +template { + display: none; +} + +/* Links + ========================================================================== */ + +/** + * Remove the gray background color from active links in IE 10. + */ + +a { + background-color: transparent; +} + +/** + * Improve readability when focused and also mouse hovered in all browsers. + */ + +a:active, +a:hover { + outline: 0; +} + +/* Text-level semantics + ========================================================================== */ + +/** + * Address styling not present in IE 8/9/10/11, Safari, and Chrome. + */ + +abbr[title] { + border-bottom: 1px dotted; +} + +/** + * Address style set to `bolder` in Firefox 4+, Safari, and Chrome. + */ + +b, +strong { + font-weight: bold; +} + +/** + * Address styling not present in Safari and Chrome. + */ + +dfn { + font-style: italic; +} + +/** + * Address variable `h1` font-size and margin within `section` and `article` + * contexts in Firefox 4+, Safari, and Chrome. + */ + +h1 { + font-size: 2em; + margin: 0.67em 0; +} + +/** + * Address styling not present in IE 8/9. + */ + +mark { + background: #ff0; + color: #000; +} + +/** + * Address inconsistent and variable font size in all browsers. + */ + +small { + font-size: 80%; +} + +/** + * Prevent `sub` and `sup` affecting `line-height` in all browsers. + */ + +sub, +sup { + font-size: 75%; + line-height: 0; + position: relative; + vertical-align: baseline; +} + +sup { + top: -0.5em; +} + +sub { + bottom: -0.25em; +} + +/* Embedded content + ========================================================================== */ + +/** + * Remove border when inside `a` element in IE 8/9/10. + */ + +img { + border: 0; +} + +/** + * Correct overflow not hidden in IE 9/10/11. + */ + +svg:not(:root) { + overflow: hidden; +} + +/* Grouping content + ========================================================================== */ + +/** + * Address margin not present in IE 8/9 and Safari. + */ + +figure { + margin: 1em 40px; +} + +/** + * Address differences between Firefox and other browsers. + */ + +hr { + -moz-box-sizing: content-box; + box-sizing: content-box; + height: 0; +} + +/** + * Contain overflow in all browsers. + */ + +pre { + overflow: auto; +} + +/** + * Address odd `em`-unit font size rendering in all browsers. + */ + +code, +kbd, +pre, +samp { + font-family: monospace, monospace; + font-size: 1em; +} + +/* Forms + ========================================================================== */ + +/** + * Known limitation: by default, Chrome and Safari on OS X allow very limited + * styling of `select`, unless a `border` property is set. + */ + +/** + * 1. Correct color not being inherited. + * Known issue: affects color of disabled elements. + * 2. Correct font properties not being inherited. + * 3. Address margins set differently in Firefox 4+, Safari, and Chrome. + */ + +button, +input, +optgroup, +select, +textarea { + color: inherit; /* 1 */ + font: inherit; /* 2 */ + margin: 0; /* 3 */ +} + +/** + * Address `overflow` set to `hidden` in IE 8/9/10/11. + */ + +button { + overflow: visible; +} + +/** + * Address inconsistent `text-transform` inheritance for `button` and `select`. + * All other form control elements do not inherit `text-transform` values. + * Correct `button` style inheritance in Firefox, IE 8/9/10/11, and Opera. + * Correct `select` style inheritance in Firefox. + */ + +button, +select { + text-transform: none; +} + +/** + * 1. Avoid the WebKit bug in Android 4.0.* where (2) destroys native `audio` + * and `video` controls. + * 2. Correct inability to style clickable `input` types in iOS. + * 3. Improve usability and consistency of cursor style between image-type + * `input` and others. + */ + +button, +html input[type="button"], /* 1 */ +input[type="reset"], +input[type="submit"] { + -webkit-appearance: button; /* 2 */ + cursor: pointer; /* 3 */ +} + +/** + * Re-set default cursor for disabled elements. + */ + +button[disabled], +html input[disabled] { + cursor: default; +} + +/** + * Remove inner padding and border in Firefox 4+. + */ + +button::-moz-focus-inner, +input::-moz-focus-inner { + border: 0; + padding: 0; +} + +/** + * Address Firefox 4+ setting `line-height` on `input` using `!important` in + * the UA stylesheet. + */ + +input { + line-height: normal; +} + +/** + * It's recommended that you don't attempt to style these elements. + * Firefox's implementation doesn't respect box-sizing, padding, or width. + * + * 1. Address box sizing set to `content-box` in IE 8/9/10. + * 2. Remove excess padding in IE 8/9/10. + */ + +input[type="checkbox"], +input[type="radio"] { + box-sizing: border-box; /* 1 */ + padding: 0; /* 2 */ +} + +/** + * Fix the cursor style for Chrome's increment/decrement buttons. For certain + * `font-size` values of the `input`, it causes the cursor style of the + * decrement button to change from `default` to `text`. + */ + +input[type="number"]::-webkit-inner-spin-button, +input[type="number"]::-webkit-outer-spin-button { + height: auto; +} + +/** + * 1. Address `appearance` set to `searchfield` in Safari and Chrome. + * 2. Address `box-sizing` set to `border-box` in Safari and Chrome + * (include `-moz` to future-proof). + */ + +input[type="search"] { + -webkit-appearance: textfield; /* 1 */ + -moz-box-sizing: content-box; + -webkit-box-sizing: content-box; /* 2 */ + box-sizing: content-box; +} + +/** + * Remove inner padding and search cancel button in Safari and Chrome on OS X. + * Safari (but not Chrome) clips the cancel button when the search input has + * padding (and `textfield` appearance). + */ + +input[type="search"]::-webkit-search-cancel-button, +input[type="search"]::-webkit-search-decoration { + -webkit-appearance: none; +} + +/** + * Define consistent border, margin, and padding. + */ + +fieldset { + border: 1px solid #c0c0c0; + margin: 0 2px; + padding: 0.35em 0.625em 0.75em; +} + +/** + * 1. Correct `color` not being inherited in IE 8/9/10/11. + * 2. Remove padding so people aren't caught out if they zero out fieldsets. + */ + +legend { + border: 0; /* 1 */ + padding: 0; /* 2 */ +} + +/** + * Remove default vertical scrollbar in IE 8/9/10/11. + */ + +textarea { + overflow: auto; +} + +/** + * Don't inherit the `font-weight` (applied by a rule above). + * NOTE: the default cannot safely be changed in Chrome and Safari on OS X. + */ + +optgroup { + font-weight: bold; +} + +/* Tables + ========================================================================== */ + +/** + * Remove most spacing between table cells. + */ + +table { + border-collapse: collapse; + border-spacing: 0; +} + +td, +th { + padding: 0; +} \ No newline at end of file diff --git a/css/railscasts.css b/css/railscasts.css new file mode 100755 index 00000000..a0154b55 --- /dev/null +++ b/css/railscasts.css @@ -0,0 +1,187 @@ +/* + +Railscasts-like style (c) Visoft, Inc. (Damien White) + +*/ + +.right-code .hljs { + display: block; + overflow-x: auto; + padding: 0.5em; + background: #232323; + color: #e6e1dc; + -webkit-text-size-adjust: none; +} + +.right-code .hljs-comment, +.right-code .hljs-javadoc, +.right-code .hljs-shebang { + color: #bc9458; + font-style: italic; +} + +.right-code .hljs-keyword, +.right-code .ruby .hljs-function .hljs-keyword, +.right-code .hljs-request, +.right-code .hljs-status, +.right-code .nginx .hljs-title, +.right-code .method, +.right-code .hljs-list .hljs-title { + color: #c26230; +} + +.right-code .hljs-string, +.right-code .hljs-number, +.right-code .hljs-regexp, +.right-code .hljs-tag .hljs-value, +.right-code .hljs-cdata, +.right-code .hljs-filter .hljs-argument, +.right-code .hljs-attr_selector, +.right-code .apache .hljs-cbracket, +.right-code .hljs-date, +.right-code .tex .hljs-command, +.right-code .asciidoc .hljs-link_label, +.right-code .markdown .hljs-link_label { + color: #a5c261; +} + +.right-code .hljs-subst { + color: #519f50; +} + +.right-code .hljs-tag, +.right-code .hljs-tag .hljs-keyword, +.right-code .hljs-tag .hljs-title, +.right-code .hljs-doctype, +.right-code .hljs-sub .hljs-identifier, +.right-code .hljs-pi, +.right-code .input_number { + color: #e8bf6a; +} + +.right-code .hljs-identifier { + color: #d0d0ff; +} + +.right-code .hljs-class .hljs-title, +.right-code .hljs-type, +.right-code .smalltalk .hljs-class, +.right-code .hljs-javadoctag, +.right-code .hljs-yardoctag, +.right-code .hljs-phpdoc, +.right-code .hljs-dartdoc { + text-decoration: none; +} + +.right-code .hljs-constant { + color: #da4939; +} + + +.right-code .hljs-symbol, +.right-code .hljs-built_in, +.right-code .ruby .hljs-symbol .hljs-string, +.right-code .ruby .hljs-symbol .hljs-identifier, +.right-code .asciidoc .hljs-link_url, +.right-code .markdown .hljs-link_url, +.right-code .hljs-attribute { + color: #6d9cbe; +} + +.right-code .asciidoc .hljs-link_url, +.right-code .markdown .hljs-link_url { + text-decoration: underline; +} + + + +.right-code .hljs-params, +.right-code .hljs-variable, +.right-code .clojure .hljs-attribute { + color: #d0d0ff; +} + +.right-code .css .hljs-tag, +.right-code .hljs-rules .hljs-property, +.right-code .hljs-pseudo, +.right-code .tex .hljs-special { + color: #cda869; +} + +.right-code .css .hljs-class { + color: #9b703f; +} + +.right-code .hljs-rules .hljs-keyword { + color: #c5af75; +} + +.right-code .hljs-rules .hljs-value { + color: #cf6a4c; +} + +.right-code .css .hljs-id { + color: #8b98ab; +} + +.right-code .hljs-annotation, +.right-code .apache .hljs-sqbracket, +.right-code .nginx .hljs-built_in { + color: #9b859d; +} + +.right-code .hljs-preprocessor, +.right-code .hljs-preprocessor *, +.right-code .hljs-pragma { + color: #8996a8 !important; +} + +.right-code .hljs-hexcolor, +.right-code .css .hljs-value .hljs-number { + color: #a5c261; +} + +.right-code .hljs-title, +.right-code .hljs-decorator, +.right-code .css .hljs-function { + color: #ffc66d; +} + +.right-code .diff .hljs-header, +.right-code .hljs-chunk { + background-color: #2f33ab; + color: #e6e1dc; + display: inline-block; + width: 100%; +} + +.right-code .diff .hljs-change { + background-color: #4a410d; + color: #f8f8f8; + display: inline-block; + width: 100%; +} + +.right-code .hljs-addition { + background-color: #144212; + color: #e6e1dc; + display: inline-block; + width: 100%; +} + +.right-code .hljs-deletion { + background-color: #600; + color: #e6e1dc; + display: inline-block; + width: 100%; +} + +.right-code .coffeescript .javascript, +.right-code .javascript .xml, +.right-code .tex .hljs-formula, +.right-code .xml .javascript, +.right-code .xml .vbscript, +.right-code .xml .css, +.right-code .xml .hljs-cdata { + opacity: 0.7; +} diff --git a/css/skeleton.css b/css/skeleton.css new file mode 100644 index 00000000..f28bf6c5 --- /dev/null +++ b/css/skeleton.css @@ -0,0 +1,418 @@ +/* +* Skeleton V2.0.4 +* Copyright 2014, Dave Gamache +* www.getskeleton.com +* Free to use under the MIT license. +* http://www.opensource.org/licenses/mit-license.php +* 12/29/2014 +*/ + + +/* Table of contents +–––––––––––––––––––––––––––––––––––––––––––––––––– +- Grid +- Base Styles +- Typography +- Links +- Buttons +- Forms +- Lists +- Code +- Tables +- Spacing +- Utilities +- Clearing +- Media Queries +*/ + + +/* Grid +–––––––––––––––––––––––––––––––––––––––––––––––––– */ +.container { + position: relative; + width: 100%; + max-width: 960px; + margin: 0 auto; + padding: 0 20px; + box-sizing: border-box; } +.column, +.columns { + width: 100%; + float: left; + box-sizing: border-box; } + +/* For devices larger than 400px */ +@media (min-width: 400px) { + .container { + width: 85%; + padding: 0; } +} + +/* For devices larger than 550px */ +@media (min-width: 550px) { + .container { + width: 80%; } + .column, + .columns { + margin-left: 4%; } + .column:first-child, + .columns:first-child { + margin-left: 0; } + + .one.column, + .one.columns { width: 4.66666666667%; } + .two.columns { width: 13.3333333333%; } + .three.columns { width: 22%; } + .four.columns { width: 30.6666666667%; } + .five.columns { width: 39.3333333333%; } + .six.columns { width: 48%; } + .seven.columns { width: 56.6666666667%; } + .eight.columns { width: 65.3333333333%; } + .nine.columns { width: 74.0%; } + .ten.columns { width: 82.6666666667%; } + .eleven.columns { width: 91.3333333333%; } + .twelve.columns { width: 100%; margin-left: 0; } + + .one-third.column { width: 30.6666666667%; } + .two-thirds.column { width: 65.3333333333%; } + + .one-half.column { width: 48%; } + + /* Offsets */ + .offset-by-one.column, + .offset-by-one.columns { margin-left: 8.66666666667%; } + .offset-by-two.column, + .offset-by-two.columns { margin-left: 17.3333333333%; } + .offset-by-three.column, + .offset-by-three.columns { margin-left: 26%; } + .offset-by-four.column, + .offset-by-four.columns { margin-left: 34.6666666667%; } + .offset-by-five.column, + .offset-by-five.columns { margin-left: 43.3333333333%; } + .offset-by-six.column, + .offset-by-six.columns { margin-left: 52%; } + .offset-by-seven.column, + .offset-by-seven.columns { margin-left: 60.6666666667%; } + .offset-by-eight.column, + .offset-by-eight.columns { margin-left: 69.3333333333%; } + .offset-by-nine.column, + .offset-by-nine.columns { margin-left: 78.0%; } + .offset-by-ten.column, + .offset-by-ten.columns { margin-left: 86.6666666667%; } + .offset-by-eleven.column, + .offset-by-eleven.columns { margin-left: 95.3333333333%; } + + .offset-by-one-third.column, + .offset-by-one-third.columns { margin-left: 34.6666666667%; } + .offset-by-two-thirds.column, + .offset-by-two-thirds.columns { margin-left: 69.3333333333%; } + + .offset-by-one-half.column, + .offset-by-one-half.columns { margin-left: 52%; } + +} + + +/* Base Styles +–––––––––––––––––––––––––––––––––––––––––––––––––– */ +/* NOTE +html is set to 62.5% so that all the REM measurements throughout Skeleton +are based on 10px sizing. So basically 1.5rem = 15px :) */ +html { + font-size: 62.5%; } +body { + font-size: 1.5em; /* currently ems cause chrome bug misinterpreting rems on body element */ + line-height: 1.6; + font-weight: 400; + font-family: "Raleway", "HelveticaNeue", "Helvetica Neue", Helvetica, Arial, sans-serif; + color: #222; } + + +/* Typography +–––––––––––––––––––––––––––––––––––––––––––––––––– */ +h1, h2, h3, h4, h5, h6 { + margin-top: 0; + margin-bottom: 2rem; + font-weight: 300; } +h1 { font-size: 4.0rem; line-height: 1.2; letter-spacing: -.1rem;} +h2 { font-size: 3.6rem; line-height: 1.25; letter-spacing: -.1rem; } +h3 { font-size: 3.0rem; line-height: 1.3; letter-spacing: -.1rem; } +h4 { font-size: 2.4rem; line-height: 1.35; letter-spacing: -.08rem; } +h5 { font-size: 1.8rem; line-height: 1.5; letter-spacing: -.05rem; } +h6 { font-size: 1.5rem; line-height: 1.6; letter-spacing: 0; } + +/* Larger than phablet */ +@media (min-width: 550px) { + h1 { font-size: 5.0rem; } + h2 { font-size: 4.2rem; } + h3 { font-size: 3.6rem; } + h4 { font-size: 3.0rem; } + h5 { font-size: 2.4rem; } + h6 { font-size: 1.5rem; } +} + +p { + margin-top: 0; } + + +/* Links +–––––––––––––––––––––––––––––––––––––––––––––––––– */ +a { + color: #1EAEDB; } +a:hover { + color: #0FA0CE; } + + +/* Buttons +–––––––––––––––––––––––––––––––––––––––––––––––––– */ +.button, +button, +input[type="submit"], +input[type="reset"], +input[type="button"] { + display: inline-block; + height: 38px; + padding: 0 30px; + color: #555; + text-align: center; + font-size: 11px; + font-weight: 600; + line-height: 38px; + letter-spacing: .1rem; + text-transform: uppercase; + text-decoration: none; + white-space: nowrap; + background-color: transparent; + border-radius: 4px; + border: 1px solid #bbb; + cursor: pointer; + box-sizing: border-box; } +.button:hover, +button:hover, +input[type="submit"]:hover, +input[type="reset"]:hover, +input[type="button"]:hover, +.button:focus, +button:focus, +input[type="submit"]:focus, +input[type="reset"]:focus, +input[type="button"]:focus { + color: #333; + border-color: #888; + outline: 0; } +.button.button-primary, +button.button-primary, +input[type="submit"].button-primary, +input[type="reset"].button-primary, +input[type="button"].button-primary { + color: #FFF; + background-color: #33C3F0; + border-color: #33C3F0; } +.button.button-primary:hover, +button.button-primary:hover, +input[type="submit"].button-primary:hover, +input[type="reset"].button-primary:hover, +input[type="button"].button-primary:hover, +.button.button-primary:focus, +button.button-primary:focus, +input[type="submit"].button-primary:focus, +input[type="reset"].button-primary:focus, +input[type="button"].button-primary:focus { + color: #FFF; + background-color: #1EAEDB; + border-color: #1EAEDB; } + + +/* Forms +–––––––––––––––––––––––––––––––––––––––––––––––––– */ +input[type="email"], +input[type="number"], +input[type="search"], +input[type="text"], +input[type="tel"], +input[type="url"], +input[type="password"], +textarea, +select { + height: 38px; + padding: 6px 10px; /* The 6px vertically centers text on FF, ignored by Webkit */ + background-color: #fff; + border: 1px solid #D1D1D1; + border-radius: 4px; + box-shadow: none; + box-sizing: border-box; } +/* Removes awkward default styles on some inputs for iOS */ +input[type="email"], +input[type="number"], +input[type="search"], +input[type="text"], +input[type="tel"], +input[type="url"], +input[type="password"], +textarea { + -webkit-appearance: none; + -moz-appearance: none; + appearance: none; } +textarea { + min-height: 65px; + padding-top: 6px; + padding-bottom: 6px; } +input[type="email"]:focus, +input[type="number"]:focus, +input[type="search"]:focus, +input[type="text"]:focus, +input[type="tel"]:focus, +input[type="url"]:focus, +input[type="password"]:focus, +textarea:focus, +select:focus { + border: 1px solid #33C3F0; + outline: 0; } +label, +legend { + display: block; + margin-bottom: .5rem; + font-weight: 600; } +fieldset { + padding: 0; + border-width: 0; } +input[type="checkbox"], +input[type="radio"] { + display: inline; } +label > .label-body { + display: inline-block; + margin-left: .5rem; + font-weight: normal; } + + +/* Lists +–––––––––––––––––––––––––––––––––––––––––––––––––– */ +ul { + list-style: circle inside; } +ol { + list-style: decimal inside; } +ol, ul { + padding-left: 0; + margin-top: 0; } +ul ul, +ul ol, +ol ol, +ol ul { + margin: 1.5rem 0 1.5rem 3rem; + font-size: 90%; } +li { + margin-bottom: 1rem; } + + +/* Code +–––––––––––––––––––––––––––––––––––––––––––––––––– */ +code { + padding: .2rem .5rem; + margin: 0 .2rem; + font-size: 90%; + white-space: nowrap; + background: #F1F1F1; + border: 1px solid #E1E1E1; + border-radius: 4px; } +pre > code { + display: block; + padding: 1rem 1.5rem; + white-space: pre; } + + +/* Tables +–––––––––––––––––––––––––––––––––––––––––––––––––– */ +th, +td { + padding: 12px 15px; + text-align: left; + border-bottom: 1px solid #E1E1E1; } +th:first-child, +td:first-child { + padding-left: 0; } +th:last-child, +td:last-child { + padding-right: 0; } + + +/* Spacing +–––––––––––––––––––––––––––––––––––––––––––––––––– */ +button, +.button { + margin-bottom: 1rem; } +input, +textarea, +select, +fieldset { + margin-bottom: 1.5rem; } +pre, +blockquote, +dl, +figure, +table, +p, +ul, +ol, +form { + margin-bottom: 2.5rem; } + + +/* Utilities +–––––––––––––––––––––––––––––––––––––––––––––––––– */ +.u-full-width { + width: 100%; + box-sizing: border-box; } +.u-max-full-width { + max-width: 100%; + box-sizing: border-box; } +.u-pull-right { + float: right; } +.u-pull-left { + float: left; } + + +/* Misc +–––––––––––––––––––––––––––––––––––––––––––––––––– */ +hr { + margin-top: 3rem; + margin-bottom: 3.5rem; + border-width: 0; + border-top: 1px solid #E1E1E1; } + + +/* Clearing +–––––––––––––––––––––––––––––––––––––––––––––––––– */ + +/* Self Clearing Goodness */ +.container:after, +.row:after, +.u-cf { + content: ""; + display: table; + clear: both; } + + +/* Media Queries +–––––––––––––––––––––––––––––––––––––––––––––––––– */ +/* +Note: The best way to structure the use of media queries is to create the queries +near the relevant code. For example, if you wanted to change the styles for buttons +on small devices, paste the mobile query code up in the buttons section and style it +there. +*/ + + +/* Larger than mobile */ +@media (min-width: 400px) {} + +/* Larger than phablet (also point when grid becomes active) */ +@media (min-width: 550px) {} + +/* Larger than tablet */ +@media (min-width: 750px) {} + +/* Larger than desktop */ +@media (min-width: 1000px) {} + +/* Larger than Desktop HD */ +@media (min-width: 1200px) {} diff --git a/css/style.css b/css/style.css new file mode 100644 index 00000000..d5a77c9e --- /dev/null +++ b/css/style.css @@ -0,0 +1,525 @@ +/* Typography +–––––––––––––––––––––––––––––––––––––––––––––––––– */ +h1, h2, h3, h4, h5, h6 { + margin-top: 0; + margin-bottom: 2rem; + font-weight: 300; +} + +h1 { font-size: 4.0rem; line-height: 1.2; letter-spacing: -.1rem;} +h2 { font-size: 3.6rem; line-height: 1.25; letter-spacing: -.1rem; } +h3 { font-size: 3.0rem; line-height: 1.3; letter-spacing: -.1rem; } + +h4 { + font-size: 2.4rem; + line-height: 1.35; + letter-spacing: -.08rem; + margin: 0 0 5px 0; +} + +h5 { + font-size: 1.8rem; + line-height: 1.5; + letter-spacing: -.05rem; +} + +.sidebar h6 { + line-height: 1em; + font-size: 1.5rem; + letter-spacing: 1px; + color: #888; + font-weight: bold; +} + +.main h6 { + font-size: 1.01em; + padding: 0 0 6px 0; + margin: 0; +} + +p { + margin-top: 0; } + +figure { + text-align: center; +} + +figcaption { + color: #999; + font-size: 0.9em; +} + + +h3 a { + text-decoration: none; + color: #474a54; +} + +h3 a:hover { + text-decoration: none; + color: #474a54; +} +a { + color: #1EAEDB; text-decoration: none; +} + +a:hover { + color: #0FA0CE; text-decoration: underline; +} + +html { + font-size: 62.5%; + color: #474a54; +} + +body { + font-size: 1.5em; /* currently ems cause chrome bug misinterpreting rems on body element */ + line-height: 1.6; + font-weight: 400; + font-family: "Raleway", "HelveticaNeue", "Helvetica Neue", Helvetica, Arial, sans-serif; +} + +.nav-bar { + background: #2196F3; + padding: 12px 0; + height: 40px; + box-shadow: 0 0 5px #333; + z-index: 1000; + position: relative; +} + +.nav-bar .right { + position: absolute; + right: 36px; + top: 17px; + width: 200px; +} + +.nav-bar ul{ + list-style: none; + margin: 0; + padding: 0; +} + +.nav-bar .hor > li { + padding: 0; + margin: 0 10px; + float: left; + position: relative; + height: 40px; +} + +.nav-bar .hor a.current { + font-weight: bold; +} + +.nav-bar .hor > li > a { + display: block; + height: 100%; + vertical-align: text-bottom; + line-height: 3em; + color: #fff; + text-decoration: none; + letter-spacing: 1px; +} + +.logo { + height: 100%; + display: block; + margin: 0 0 0 9px; +} + +.logo img { + max-height: 100%; + position: relative; + top: 4px; +} + +.clearfix:after { + content: " "; /* Older browser do not support empty content */ + visibility: hidden; + display: block; + height: 0; + clear: both; +} + +.sidebar { + width: 170px; + position: absolute; + padding: 20px 20px 0 20px; + white-space:nowrap; + top: 80px; + overflow-y: auto; + height: 100%; +} + +.sidebar section { + padding: 10px 0; +} + +.sidebar ul { + padding: 0 0 0 10px; + margin: 0; + list-style: none; +} + +.sidebar h6 { + padding: 0; + margin: 0 0 5px 0; +} + +.sidebar a { + color: #777; + text-decoration: none; + font-size: .90em; + display: block; + width: 100%; + text-overflow: ellipsis; + overflow: hidden; +} + +.sidebar a.active { + color: #2196F3; + text-decoration: none; + font-weight: bold; +} + +.endpoint { + font-size: 10px; + padding: 0 2px; + position: relative; +} + +h3 .endpoint { + padding: 4px 6px; + font-size: 19px; +} + +.endpoint.put { + color: #7E57C2; +} + +.endpoint.put:after { + content: "PUT"; +} + +.endpoint.delete { + color: #FF7043; +} + +.endpoint.delete:after { + content: "DELETE"; +} + +.endpoint.get { + color: #66BB6A; +} +.endpoint.get:after { + content: "GET"; +} + +.endpoint.post { + color: #42A5F5; +} + +.endpoint.post:after { + content: "POST"; +} + +.docs .main { + border-left: #bbb 1px solid; + margin: 0 0 0 210px; +} + +hr { + border: 0; + border-top: 1px solid #ddd; + margin: 20px 0; +} + +.message-box { + background: #F0F5FF; + border: 3px solid #4EB9F0; + padding: 10px; + margin: 20px 0; +} + +.message-box h5 { + color: #4EB9F0; + margin: 0 0 10px 0; +} + +.message-box p { + margin: 0 0 8px 0; +} + +.alert { + background: #FFEBEE; + border-color: #F44336; +} + +.alert h5 { + color: #F44336; +} + +.warning { + background: #FFF8E1; + border-color: #FFC107; +} + +.warning h5:before { + content: "!"; + font-weight: bold; + color: #fff; + background: #f0ad4e; + font-size: 10px; + width: 15px; + height: 15px; + display: inline-block; + text-align: center; + border-radius: 10px; + position: relative; + top: -3px; + margin: 0 5px 0 0; + +} + +.warning h5 { + color: #FFC107; +} + + +.doc-content { + border-bottom: 1px solid #ddd; + padding: 30px 0; +background: #ffffff; /* Old browsers */ +background: -moz-linear-gradient(left, #ffffff 0%, #ffffff 60%, #232323 60%); /* FF3.6+ */ +background: -webkit-gradient(linear, left top, right top, color-stop(0%,#ffffff), color-stop(60%,#ffffff), color-stop(60%,#232323)); /* Chrome,Safari4+ */ +background: -webkit-linear-gradient(left, #ffffff 0%,#ffffff 60%,#232323 60%); /* Chrome10+,Safari5.1+ */ +background: -o-linear-gradient(left, #ffffff 0%,#ffffff 60%,#232323 60%); /* Opera 11.10+ */ +background: -ms-linear-gradient(left, #ffffff 0%,#ffffff 60%,#232323 60%); /* IE10+ */ +background: linear-gradient(to right, #ffffff 0%,#ffffff 60%,#232323 60%); /* W3C */ +filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#ffffff', endColorstr='#232323',GradientType=1 ); /* IE6-9 */ + +} + +.doc-content.full { + background: #fff; +} + +.doc-content.full .left-docs { + width: 100%; +} + +.doc-content:after { + visibility: hidden; + display: block; + content: ""; + clear: both; + height: 0; +} + +.left-docs { + width: 60%; + float: left; + padding: 0 50px; + -webkit-box-sizing: border-box; /* Safari/Chrome, other WebKit */ + -moz-box-sizing: border-box; /* Firefox, other Gecko */ + box-sizing: border-box; /* Opera/IE 8+ */ +} + +.right-code { + width: 40%; + float: left; + padding: 0 50px; + -webkit-box-sizing: border-box; /* Safari/Chrome, other WebKit */ + -moz-box-sizing: border-box; /* Firefox, other Gecko */ + box-sizing: border-box; /* Opera/IE 8+ */ +} + +.code-viewer .languages { + padding: 0; + margin: 0; + list-style: none; +} + +.code-viewer .languages li { + display: inline-block; +} + +.code-viewer .languages li a { + display: block; + padding: 0 5px; + z-index: 100; +} + +.code-viewer a { + text-decoration: none; + color: #aaa; +} + +.code-viewer pre { + margin: 0 0 20px 0; +} + +.code-viewer a:hover { + color: #222; +} + +.right-code .code-viewer a:hover { + color: #fff; +} + +.code-viewer a.active{ + font-weight: bold; + color: #1EAEDB; +} + +.return_codes tbody td:first-child { + font-family: courier; + font-size: .9em; + text-align: center; +} + +table { + border: 1px solid #E1E1E1; + margin: 0 0 20px 0; +} + +th, td { + border: 1px solid #ccc; + padding: 10px; + font-size: .9em; + text-align: left; +} + +th { + background: #f7f7f7; +} + +.main .description { + color: #aaa; + margin-top: -11px; +} + +.left-docs pre { + border: 1px solid #aaa; + box-shadow: 0 0 0 3px #eee; + border-radius: 3px; +} + +pre { + white-space: pre-wrap; + font-size: .8em; + margin: 22px 0; + word-wrap: break-word; +} + +.parameters { + border-top: 1px solid #eee; + border-bottom: 1px solid #eee; + padding: 0 0 20px 0; + margin: 0 0 20px 0; +} + +.parameters dt { + width: 30%; + float: left; + font-weight: bold; + text-align: right; + position: relative; + top: 20px; +} + +.parameters dd { + margin-left: 30%; + padding-left: 15px; + margin-top: 20px; +} + +.parameters dd:after { + visibility: hidden; + display: block; + content: ""; + clear: both; + height: 0; +} + +.search-box { + color: #fff; + border: 0; + border-radius: 5px; + padding: 6px; + width: 200px; + background: #1976D2 url(/img/search.png) no-repeat 190px center; + background-size: 15px 19px; +} + +.search-box::-webkit-input-placeholder { /* WebKit browsers */ + color: #ccc; +} +.search-box:-moz-placeholder { /* Mozilla Firefox 4 to 18 */ + color: #ccc; + opacity: 1; +} +.search-box::-moz-placeholder { /* Mozilla Firefox 19+ */ + color: #ccc; + opacity: 1; +} +.search-box:-ms-input-placeholder { /* Internet Explorer 10+ */ + color: #ccc; +} + +.nav-bar .search-results { + background: #fff; + margin-top: 5px; + border-radius: 5px; + padding: 5px 0; + display: none; +} + +.nav-bar .search-results a { + color: #666; + display: block; + padding: 10px; +} + +.nav-bar .search-results a:hover { + background: #efefef; + text-decoration: none; +} + +.nav-bar .search-results a span.description { + display: block; + font-size: .7em; + color: #999; +} + +#search_bg { + width:100%; + height:100%; + position:fixed; + z-index:1000; + display:none; + top: 0; +} + +@media (max-width: 1000px) { + .right-code { + float: none; + width: 100%; + background: #232323; + padding-top: 20px; + padding-bottom: 20px; + } + + .left-docs { + float: none; + width: 100%; + } + + .doc-content { + background: #fff; + padding-bottom: 0; + } +} diff --git a/css/tomorrow.css b/css/tomorrow.css new file mode 100755 index 00000000..a71610dd --- /dev/null +++ b/css/tomorrow.css @@ -0,0 +1,92 @@ +/* http://jmblog.github.com/color-themes-for-google-code-highlightjs */ + +/* Tomorrow Comment */ +.left-docs .hljs-comment { + color: #8e908c; +} + +/* Tomorrow Red */ +.left-docs .hljs-variable, +.left-docs .hljs-attribute, +.left-docs .hljs-tag, +.left-docs .hljs-regexp, +.left-docs .ruby .hljs-constant, +.left-docs .xml .hljs-tag .hljs-title, +.left-docs .xml .hljs-pi, +.left-docs .xml .hljs-doctype, +.left-docs .html .hljs-doctype, +.left-docs .css .hljs-id, +.left-docs .css .hljs-class, +.left-docs .css .hljs-pseudo { + color: #c82829; +} + +/* Tomorrow Orange */ +.left-docs .hljs-number, +.left-docs .hljs-preprocessor, +.left-docs .hljs-pragma, +.left-docs .hljs-built_in, +.left-docs .hljs-literal, +.left-docs .hljs-params, +.left-docs .hljs-constant { + color: #f5871f; +} + +/* Tomorrow Yellow */ +.left-docs .ruby .hljs-class .hljs-title, +.left-docs .css .hljs-rules .hljs-attribute { + color: #eab700; +} + +/* Tomorrow Green */ +.left-docs .hljs-string, +.left-docs .hljs-value, +.left-docs .hljs-inheritance, +.left-docs .hljs-header, +.left-docs .ruby .hljs-symbol, +.left-docs .xml .hljs-cdata { + color: #718c00; +} + +/* Tomorrow Aqua */ +.left-docs .hljs-title, +.left-docs .css .hljs-hexcolor { + color: #3e999f; +} + +/* Tomorrow Blue */ +.left-docs .hljs-function, +.left-docs .python .hljs-decorator, +.left-docs .python .hljs-title, +.left-docs .ruby .hljs-function .hljs-title, +.left-docs .ruby .hljs-title .hljs-keyword, +.left-docs .perl .hljs-sub, +.left-docs .javascript .hljs-title, +.left-docs .coffeescript .hljs-title { + color: #4271ae; +} + +/* Tomorrow Purple */ +.left-docs .hljs-keyword, +.left-docs .javascript .hljs-function { + color: #8959a8; +} + +.left-docs .hljs { + display: block; + overflow-x: auto; + background: white; + color: #4d4d4c; + padding: 0.5em; + -webkit-text-size-adjust: none; +} + +.left-docs .coffeescript .javascript, +.left-docs .javascript .xml, +.left-docs .tex .hljs-formula, +.left-docs .xml .javascript, +.left-docs .xml .vbscript, +.left-docs .xml .css, +.left-docs .xml .hljs-cdata { + opacity: 0.5; +} diff --git a/img/logo.png b/img/logo.png new file mode 100644 index 00000000..22d0f1ff Binary files /dev/null and b/img/logo.png differ diff --git a/img/search.png b/img/search.png new file mode 100644 index 00000000..b9c5c26d Binary files /dev/null and b/img/search.png differ diff --git a/img/search.svg b/img/search.svg new file mode 100644 index 00000000..d00ef004 --- /dev/null +++ b/img/search.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/index.html b/index.html new file mode 100644 index 00000000..7d80788d --- /dev/null +++ b/index.html @@ -0,0 +1,54 @@ +--- +layout: default +sidebar: true +body_class: docs +title: My App Docs +--- + + + +{% for collection in site.collections %} + {% if collection[1].render %} + {% for doc in collection[1].docs %} +
+
+

+ {% if doc.type %} {% endif %} + {{doc.title}}

+ {% if doc.description %} +

{{doc.description}}

+ {% endif %} + + {% if doc.parameters %} +
{{ doc.parameters.title }}
+
+ {% for parameter in doc.parameters.data %} + {% for k in parameter %} +
{{k[0]}}
+
+ {{k[1][0]}} +
+ {{k[1][1]}} +
+ {% endfor %} + {% endfor %} +
+ {% endif %} + + {{doc.content}} +
+ + {% if doc.right_code %} +
+ +
+ {% for code in doc.right_code %} +
{{code[1]}}
+ {% endfor %} +
+
+ {% endif %} +
+ {% endfor %} + {% endif %} +{% endfor %} diff --git a/index2.html b/index2.html new file mode 100644 index 00000000..32bed279 --- /dev/null +++ b/index2.html @@ -0,0 +1,43 @@ +--- +layout: default +sidebar: true +body_class: docs +title: My App Docs +--- + + + +{% for collection in site.collections %} + {% if collection[1].render %} + {% for doc in collection[1].docs %} +
+
+

+ {% if doc.type %} {% endif %} + {{doc.title}}

+ {% if doc.description %} +

{{doc.description}}

+ {% endif %} + + {% if doc.parameters %} +
{{ doc.parameters.title }}
+
+ {% for parameter in doc.parameters.data %} + {% for k in parameter %} +
{{k[0]}}
+
+ {{k[1][0]}} +
+ {{k[1][1]}} +
+ {% endfor %} + {% endfor %} +
+ {% endif %} + + {{doc.content}} +
+
+ {% endfor %} + {% endif %} +{% endfor %} diff --git a/js/.gitignore b/js/.gitignore new file mode 100644 index 00000000..e69de29b diff --git a/js/lunr.min.js b/js/lunr.min.js new file mode 100644 index 00000000..2fa414e1 --- /dev/null +++ b/js/lunr.min.js @@ -0,0 +1,7 @@ +/** + * lunr - http://lunrjs.com - A bit like Solr, but much smaller and not as bright - 0.5.7 + * Copyright (C) 2014 Oliver Nightingale + * MIT Licensed + * @license + */ +!function(){var t=function(e){var n=new t.Index;return n.pipeline.add(t.trimmer,t.stopWordFilter,t.stemmer),e&&e.call(n,n),n};t.version="0.5.7",t.utils={},t.utils.warn=function(t){return function(e){t.console&&console.warn&&console.warn(e)}}(this),t.EventEmitter=function(){this.events={}},t.EventEmitter.prototype.addListener=function(){var t=Array.prototype.slice.call(arguments),e=t.pop(),n=t;if("function"!=typeof e)throw new TypeError("last argument must be a function");n.forEach(function(t){this.hasHandler(t)||(this.events[t]=[]),this.events[t].push(e)},this)},t.EventEmitter.prototype.removeListener=function(t,e){if(this.hasHandler(t)){var n=this.events[t].indexOf(e);this.events[t].splice(n,1),this.events[t].length||delete this.events[t]}},t.EventEmitter.prototype.emit=function(t){if(this.hasHandler(t)){var e=Array.prototype.slice.call(arguments,1);this.events[t].forEach(function(t){t.apply(void 0,e)})}},t.EventEmitter.prototype.hasHandler=function(t){return t in this.events},t.tokenizer=function(t){if(!arguments.length||null==t||void 0==t)return[];if(Array.isArray(t))return t.map(function(t){return t.toLowerCase()});for(var e=t.toString().replace(/^\s+/,""),n=e.length-1;n>=0;n--)if(/\S/.test(e.charAt(n))){e=e.substring(0,n+1);break}return e.split(/(?:\s+|\-)/).filter(function(t){return!!t}).map(function(t){return t.toLowerCase()})},t.Pipeline=function(){this._stack=[]},t.Pipeline.registeredFunctions={},t.Pipeline.registerFunction=function(e,n){n in this.registeredFunctions&&t.utils.warn("Overwriting existing registered function: "+n),e.label=n,t.Pipeline.registeredFunctions[e.label]=e},t.Pipeline.warnIfFunctionNotRegistered=function(e){var n=e.label&&e.label in this.registeredFunctions;n||t.utils.warn("Function is not registered with pipeline. This may cause problems when serialising the index.\n",e)},t.Pipeline.load=function(e){var n=new t.Pipeline;return e.forEach(function(e){var i=t.Pipeline.registeredFunctions[e];if(!i)throw new Error("Cannot load un-registered function: "+e);n.add(i)}),n},t.Pipeline.prototype.add=function(){var e=Array.prototype.slice.call(arguments);e.forEach(function(e){t.Pipeline.warnIfFunctionNotRegistered(e),this._stack.push(e)},this)},t.Pipeline.prototype.after=function(e,n){t.Pipeline.warnIfFunctionNotRegistered(n);var i=this._stack.indexOf(e)+1;this._stack.splice(i,0,n)},t.Pipeline.prototype.before=function(e,n){t.Pipeline.warnIfFunctionNotRegistered(n);var i=this._stack.indexOf(e);this._stack.splice(i,0,n)},t.Pipeline.prototype.remove=function(t){var e=this._stack.indexOf(t);this._stack.splice(e,1)},t.Pipeline.prototype.run=function(t){for(var e=[],n=t.length,i=this._stack.length,o=0;n>o;o++){for(var r=t[o],s=0;i>s&&(r=this._stack[s](r,o,t),void 0!==r);s++);void 0!==r&&e.push(r)}return e},t.Pipeline.prototype.reset=function(){this._stack=[]},t.Pipeline.prototype.toJSON=function(){return this._stack.map(function(e){return t.Pipeline.warnIfFunctionNotRegistered(e),e.label})},t.Vector=function(){this._magnitude=null,this.list=void 0,this.length=0},t.Vector.Node=function(t,e,n){this.idx=t,this.val=e,this.next=n},t.Vector.prototype.insert=function(e,n){var i=this.list;if(!i)return this.list=new t.Vector.Node(e,n,i),this.length++;for(var o=i,r=i.next;void 0!=r;){if(en.idx?n=n.next:(i+=e.val*n.val,e=e.next,n=n.next);return i},t.Vector.prototype.similarity=function(t){return this.dot(t)/(this.magnitude()*t.magnitude())},t.SortedSet=function(){this.length=0,this.elements=[]},t.SortedSet.load=function(t){var e=new this;return e.elements=t,e.length=t.length,e},t.SortedSet.prototype.add=function(){Array.prototype.slice.call(arguments).forEach(function(t){~this.indexOf(t)||this.elements.splice(this.locationFor(t),0,t)},this),this.length=this.elements.length},t.SortedSet.prototype.toArray=function(){return this.elements.slice()},t.SortedSet.prototype.map=function(t,e){return this.elements.map(t,e)},t.SortedSet.prototype.forEach=function(t,e){return this.elements.forEach(t,e)},t.SortedSet.prototype.indexOf=function(t,e,n){var e=e||0,n=n||this.elements.length,i=n-e,o=e+Math.floor(i/2),r=this.elements[o];return 1>=i?r===t?o:-1:t>r?this.indexOf(t,o,n):r>t?this.indexOf(t,e,o):r===t?o:void 0},t.SortedSet.prototype.locationFor=function(t,e,n){var e=e||0,n=n||this.elements.length,i=n-e,o=e+Math.floor(i/2),r=this.elements[o];if(1>=i){if(r>t)return o;if(t>r)return o+1}return t>r?this.locationFor(t,o,n):r>t?this.locationFor(t,e,o):void 0},t.SortedSet.prototype.intersect=function(e){for(var n=new t.SortedSet,i=0,o=0,r=this.length,s=e.length,a=this.elements,h=e.elements;;){if(i>r-1||o>s-1)break;a[i]!==h[o]?a[i]h[o]&&o++:(n.add(a[i]),i++,o++)}return n},t.SortedSet.prototype.clone=function(){var e=new t.SortedSet;return e.elements=this.toArray(),e.length=e.elements.length,e},t.SortedSet.prototype.union=function(t){var e,n,i;return this.length>=t.length?(e=this,n=t):(e=t,n=this),i=e.clone(),i.add.apply(i,n.toArray()),i},t.SortedSet.prototype.toJSON=function(){return this.toArray()},t.Index=function(){this._fields=[],this._ref="id",this.pipeline=new t.Pipeline,this.documentStore=new t.Store,this.tokenStore=new t.TokenStore,this.corpusTokens=new t.SortedSet,this.eventEmitter=new t.EventEmitter,this._idfCache={},this.on("add","remove","update",function(){this._idfCache={}}.bind(this))},t.Index.prototype.on=function(){var t=Array.prototype.slice.call(arguments);return this.eventEmitter.addListener.apply(this.eventEmitter,t)},t.Index.prototype.off=function(t,e){return this.eventEmitter.removeListener(t,e)},t.Index.load=function(e){e.version!==t.version&&t.utils.warn("version mismatch: current "+t.version+" importing "+e.version);var n=new this;return n._fields=e.fields,n._ref=e.ref,n.documentStore=t.Store.load(e.documentStore),n.tokenStore=t.TokenStore.load(e.tokenStore),n.corpusTokens=t.SortedSet.load(e.corpusTokens),n.pipeline=t.Pipeline.load(e.pipeline),n},t.Index.prototype.field=function(t,e){var e=e||{},n={name:t,boost:e.boost||1};return this._fields.push(n),this},t.Index.prototype.ref=function(t){return this._ref=t,this},t.Index.prototype.add=function(e,n){var i={},o=new t.SortedSet,r=e[this._ref],n=void 0===n?!0:n;this._fields.forEach(function(n){var r=this.pipeline.run(t.tokenizer(e[n.name]));i[n.name]=r,t.SortedSet.prototype.add.apply(o,r)},this),this.documentStore.set(r,o),t.SortedSet.prototype.add.apply(this.corpusTokens,o.toArray());for(var s=0;s0&&(i=1+Math.log(this.tokenStore.length/n)),this._idfCache[e]=i},t.Index.prototype.search=function(e){var n=this.pipeline.run(t.tokenizer(e)),i=new t.Vector,o=[],r=this._fields.reduce(function(t,e){return t+e.boost},0),s=n.some(function(t){return this.tokenStore.has(t)},this);if(!s)return[];n.forEach(function(e,n,s){var a=1/s.length*this._fields.length*r,h=this,u=this.tokenStore.expand(e).reduce(function(n,o){var r=h.corpusTokens.indexOf(o),s=h.idf(o),u=1,l=new t.SortedSet;if(o!==e){var c=Math.max(3,o.length-e.length);u=1/Math.log(c)}return r>-1&&i.insert(r,a*s*u),Object.keys(h.tokenStore.get(o)).forEach(function(t){l.add(t)}),n.union(l)},new t.SortedSet);o.push(u)},this);var a=o.reduce(function(t,e){return t.intersect(e)});return a.map(function(t){return{ref:t,score:i.similarity(this.documentVector(t))}},this).sort(function(t,e){return e.score-t.score})},t.Index.prototype.documentVector=function(e){for(var n=this.documentStore.get(e),i=n.length,o=new t.Vector,r=0;i>r;r++){var s=n.elements[r],a=this.tokenStore.get(s)[e].tf,h=this.idf(s);o.insert(this.corpusTokens.indexOf(s),a*h)}return o},t.Index.prototype.toJSON=function(){return{version:t.version,fields:this._fields,ref:this._ref,documentStore:this.documentStore.toJSON(),tokenStore:this.tokenStore.toJSON(),corpusTokens:this.corpusTokens.toJSON(),pipeline:this.pipeline.toJSON()}},t.Index.prototype.use=function(t){var e=Array.prototype.slice.call(arguments,1);e.unshift(this),t.apply(this,e)},t.Store=function(){this.store={},this.length=0},t.Store.load=function(e){var n=new this;return n.length=e.length,n.store=Object.keys(e.store).reduce(function(n,i){return n[i]=t.SortedSet.load(e.store[i]),n},{}),n},t.Store.prototype.set=function(t,e){this.has(t)||this.length++,this.store[t]=e},t.Store.prototype.get=function(t){return this.store[t]},t.Store.prototype.has=function(t){return t in this.store},t.Store.prototype.remove=function(t){this.has(t)&&(delete this.store[t],this.length--)},t.Store.prototype.toJSON=function(){return{store:this.store,length:this.length}},t.stemmer=function(){var t={ational:"ate",tional:"tion",enci:"ence",anci:"ance",izer:"ize",bli:"ble",alli:"al",entli:"ent",eli:"e",ousli:"ous",ization:"ize",ation:"ate",ator:"ate",alism:"al",iveness:"ive",fulness:"ful",ousness:"ous",aliti:"al",iviti:"ive",biliti:"ble",logi:"log"},e={icate:"ic",ative:"",alize:"al",iciti:"ic",ical:"ic",ful:"",ness:""},n="[^aeiou]",i="[aeiouy]",o=n+"[^aeiouy]*",r=i+"[aeiou]*",s="^("+o+")?"+r+o,a="^("+o+")?"+r+o+"("+r+")?$",h="^("+o+")?"+r+o+r+o,u="^("+o+")?"+i,l=new RegExp(s),c=new RegExp(h),p=new RegExp(a),f=new RegExp(u),d=/^(.+?)(ss|i)es$/,v=/^(.+?)([^s])s$/,m=/^(.+?)eed$/,g=/^(.+?)(ed|ing)$/,y=/.$/,S=/(at|bl|iz)$/,w=new RegExp("([^aeiouylsz])\\1$"),x=new RegExp("^"+o+i+"[^aeiouwxy]$"),k=/^(.+?[^aeiou])y$/,b=/^(.+?)(ational|tional|enci|anci|izer|bli|alli|entli|eli|ousli|ization|ation|ator|alism|iveness|fulness|ousness|aliti|iviti|biliti|logi)$/,E=/^(.+?)(icate|ative|alize|iciti|ical|ful|ness)$/,_=/^(.+?)(al|ance|ence|er|ic|able|ible|ant|ement|ment|ent|ou|ism|ate|iti|ous|ive|ize)$/,O=/^(.+?)(s|t)(ion)$/,F=/^(.+?)e$/,P=/ll$/,T=new RegExp("^"+o+i+"[^aeiouwxy]$"),$=function(n){var i,o,r,s,a,h,u;if(n.length<3)return n;if(r=n.substr(0,1),"y"==r&&(n=r.toUpperCase()+n.substr(1)),s=d,a=v,s.test(n)?n=n.replace(s,"$1$2"):a.test(n)&&(n=n.replace(a,"$1$2")),s=m,a=g,s.test(n)){var $=s.exec(n);s=l,s.test($[1])&&(s=y,n=n.replace(s,""))}else if(a.test(n)){var $=a.exec(n);i=$[1],a=f,a.test(i)&&(n=i,a=S,h=w,u=x,a.test(n)?n+="e":h.test(n)?(s=y,n=n.replace(s,"")):u.test(n)&&(n+="e"))}if(s=k,s.test(n)){var $=s.exec(n);i=$[1],n=i+"i"}if(s=b,s.test(n)){var $=s.exec(n);i=$[1],o=$[2],s=l,s.test(i)&&(n=i+t[o])}if(s=E,s.test(n)){var $=s.exec(n);i=$[1],o=$[2],s=l,s.test(i)&&(n=i+e[o])}if(s=_,a=O,s.test(n)){var $=s.exec(n);i=$[1],s=c,s.test(i)&&(n=i)}else if(a.test(n)){var $=a.exec(n);i=$[1]+$[2],a=c,a.test(i)&&(n=i)}if(s=F,s.test(n)){var $=s.exec(n);i=$[1],s=c,a=p,h=T,(s.test(i)||a.test(i)&&!h.test(i))&&(n=i)}return s=P,a=c,s.test(n)&&a.test(n)&&(s=y,n=n.replace(s,"")),"y"==r&&(n=r.toLowerCase()+n.substr(1)),n};return $}(),t.Pipeline.registerFunction(t.stemmer,"stemmer"),t.stopWordFilter=function(e){return-1===t.stopWordFilter.stopWords.indexOf(e)?e:void 0},t.stopWordFilter.stopWords=new t.SortedSet,t.stopWordFilter.stopWords.length=119,t.stopWordFilter.stopWords.elements=["","a","able","about","across","after","all","almost","also","am","among","an","and","any","are","as","at","be","because","been","but","by","can","cannot","could","dear","did","do","does","either","else","ever","every","for","from","get","got","had","has","have","he","her","hers","him","his","how","however","i","if","in","into","is","it","its","just","least","let","like","likely","may","me","might","most","must","my","neither","no","nor","not","of","off","often","on","only","or","other","our","own","rather","said","say","says","she","should","since","so","some","than","that","the","their","them","then","there","these","they","this","tis","to","too","twas","us","wants","was","we","were","what","when","where","which","while","who","whom","why","will","with","would","yet","you","your"],t.Pipeline.registerFunction(t.stopWordFilter,"stopWordFilter"),t.trimmer=function(t){return t.replace(/^\W+/,"").replace(/\W+$/,"")},t.Pipeline.registerFunction(t.trimmer,"trimmer"),t.TokenStore=function(){this.root={docs:{}},this.length=0},t.TokenStore.load=function(t){var e=new this;return e.root=t.root,e.length=t.length,e},t.TokenStore.prototype.add=function(t,e,n){var n=n||this.root,i=t[0],o=t.slice(1);return i in n||(n[i]={docs:{}}),0===o.length?(n[i].docs[e.ref]=e,void(this.length+=1)):this.add(o,e,n[i])},t.TokenStore.prototype.has=function(t){if(!t)return!1;for(var e=this.root,n=0;n" ); + $el = $(this); + $languages = $el.find('.languages'); + $el.find('pre').css('display', 'none'); + $el.find('pre').first().css('display', 'block'); + + $el.find('pre').each(function(j){ + $languages.append("
  • " + $(this).attr('data-language') + "
  • "); + }) + + $languages.find('a').first().addClass('active'); + + $el.find('a').click(function() { + $el = $(this).closest('.code-viewer'); + $el.find('pre').css('display', 'none'); + $el.find('pre').eq($(this).parent().index()).css('display', 'block'); + + $el.find('.languages').find('a').removeClass('active'); + $(this).addClass('active'); + + return false; + }); + }); + + setActiveSidebarLink(); + + function fixSidebar() { + var top = window.scrollY; + + if (top < $main.offset().top + 10) { + top = 80; + } + + if (top < $main.offset().top + $main.height() - $sidebar.height()) { + $sidebar.css('top', top); + } + }; + + + function setActiveSidebarLink() { + $('.sidebar a').removeClass('active'); + var $closest = getClosestHeader(); + $closest.addClass('active'); + document.title = $closest.text(); + }; +}); + +function getClosestHeader() { + var $links = $('.sidebar a'), + top = window.scrollY, + $last = $links.first(); + + if (top < 300) { + return $last; + } + + for (var i = 0; i < $links.length; i++) { + var $link = $links.eq(i), + href = $link.attr("href"); + + if (href != undefined && href.charAt(0) === "#" && href.length > 1) { + var $anchor = $(href); + + if ($anchor.length > 0) { + var offset = $anchor.offset(); + + if (top < offset.top - 300) { + return $last; + } + + $last = $link; + } + } + } + return $last; +}; diff --git a/js/search.js b/js/search.js new file mode 100644 index 00000000..a01e38c4 --- /dev/null +++ b/js/search.js @@ -0,0 +1,71 @@ +jQuery(function() { + var $search = $("#search"), + data = $.getJSON('/search_data.json'), + $search_results = $("#search_results"); + + $(document).click(function(event) { + if(!$(event.target).closest('#search_results').length && !$(event.target).closest('#search').length) { + if( $search_results.is(":visible")) { + $search_results.hide(); + } + } + }); + + $( document ).on( "click", "#search_results a", function() { + $search_results.hide(); + }); + + window.idx = lunr(function () { + this.field('id'); + this.field('title', { boost: 10 }); + this.field('description'); + this.field('type'); + }); + + data.then(function(data){ + $.each(data, function(index, value){ + window.idx.add( + $.extend({ "id": index }, value) + ); + }); + }); + + + $search.keyup(function() { + perform_search(); + }).focus(function() { + perform_search(); + }); + + function perform_search() { + var query = $search.val(); + + if (query === ''){ + $search_results.hide(); + } else { + var results = window.idx.search(query); + data.then(function(data) { + + if (results.length) { + $search_results.empty().append('').show(); + } else { + $search_results.html('
    • No results found
    ').show(); + } + }); + } + } +}); diff --git a/search_data.json b/search_data.json new file mode 100644 index 00000000..8dff2a2d --- /dev/null +++ b/search_data.json @@ -0,0 +1,24 @@ +--- +layout: null +--- + +{ + {% for collection in site.collections %} + {% if collection[1].render %} + {% unless forloop.first %} + , + {% endunless %} + + {% for doc in collection[1].docs %} + "{{ doc.url | replace: '/', '' | replace: '.', '' }}": { + "title": "{{ doc.title | xml_escape }}", + "description": "{{doc.description | xml_escape }}", + "type": "{{doc.type | xml_escape}}" + } + {% unless forloop.last %} + , + {% endunless %} + {% endfor %} + {% endif %} + {% endfor %} +}