From 9b2d72de59efd0048c8860875d8ad456a3793bef Mon Sep 17 00:00:00 2001 From: Rand McKinney Date: Mon, 3 Feb 2014 10:38:38 -0800 Subject: [PATCH 1/3] Spurious file Dummy file no longer needed. --- gs.html | 10 ---------- 1 file changed, 10 deletions(-) delete mode 100644 gs.html diff --git a/gs.html b/gs.html deleted file mode 100644 index 74b9821a8..000000000 --- a/gs.html +++ /dev/null @@ -1,10 +0,0 @@ - - - - - LoopBack Getting Started - - - TBD - - From f6fabd4d85731bf38b21480365419c2b4db8e872 Mon Sep 17 00:00:00 2001 From: Rand McKinney Date: Mon, 3 Feb 2014 10:39:07 -0800 Subject: [PATCH 2/3] Spurious file Dummy file no longer needed. --- examples.html | 10 ---------- 1 file changed, 10 deletions(-) delete mode 100644 examples.html diff --git a/examples.html b/examples.html deleted file mode 100644 index a75396e63..000000000 --- a/examples.html +++ /dev/null @@ -1,10 +0,0 @@ - - - - - LoopBack Examples - - - TBD - - From bcb7e3517fb8eaf0c7b751b247de46d979b039d5 Mon Sep 17 00:00:00 2001 From: crandmck Date: Mon, 3 Feb 2014 13:21:14 -0800 Subject: [PATCH 3/3] add prism syntax highlighting --- css/prism.css | 114 ++++++++++++++++++++++++++++++++++++++++++++ css/styles.css | 10 +++- index.html | 127 ++++++++++++++++++++++++------------------------- js/prism.js | 14 ++++++ 4 files changed, 199 insertions(+), 66 deletions(-) create mode 100644 css/prism.css create mode 100644 js/prism.js diff --git a/css/prism.css b/css/prism.css new file mode 100644 index 000000000..1e544d64e --- /dev/null +++ b/css/prism.css @@ -0,0 +1,114 @@ +/** + * okaidia theme for JavaScript, CSS and HTML + * Loosely based on Monokai textmate theme by http://www.monokai.nl/ + * @author ocodia + */ + +code[class*="language-"], +pre[class*="language-"] { + color: #f8f8f2; + text-shadow: 0 1px rgba(0,0,0,0.3); + font-family: Consolas, Monaco, 'Andale Mono', monospace; + direction: ltr; + text-align: left; + white-space: pre; + word-spacing: normal; + word-break: normal; + + -moz-tab-size: 4; + -o-tab-size: 4; + tab-size: 4; + + -webkit-hyphens: none; + -moz-hyphens: none; + -ms-hyphens: none; + hyphens: none; +} + +/* Code blocks */ +pre[class*="language-"] { + padding: 1em; + margin: .5em 0; + overflow: auto; + border-radius: 0.3em; +} + +:not(pre) > code[class*="language-"], +pre[class*="language-"] { + background: #272822; +} + +/* Inline code */ +:not(pre) > code[class*="language-"] { + padding: .1em; + border-radius: .3em; +} + +.token.comment, +.token.prolog, +.token.doctype, +.token.cdata { + color: slategray; +} + +.token.punctuation { + color: #f8f8f2; +} + +.namespace { + opacity: .7; +} + +.token.property, +.token.tag, +.token.constant, +.token.symbol { + color: #f92672; +} + +.token.boolean, +.token.number{ + color: #ae81ff; +} + +.token.selector, +.token.attr-name, +.token.string, +.token.builtin { + color: #a6e22e; +} + + +.token.operator, +.token.entity, +.token.url, +.language-css .token.string, +.style .token.string, +.token.variable { + color: #f8f8f2; +} + +.token.atrule, +.token.attr-value +{ + color: #e6db74; +} + + +.token.keyword{ +color: #66d9ef; +} + +.token.regex, +.token.important { + color: #fd971f; +} + +.token.important { + font-weight: bold; +} + +.token.entity { + cursor: help; +} + diff --git a/css/styles.css b/css/styles.css index 40c74a59c..5541c3349 100755 --- a/css/styles.css +++ b/css/styles.css @@ -149,7 +149,7 @@ pre { position: relative; text-transform: uppercase; font-weight: bold; - font-size: 26px; + font-size: 34px; } .fancy span:before, .fancy span:after { @@ -274,14 +274,16 @@ pre { /* START: SECTIONS*/ #examples .article h3, #gs .article h3, #about .article h3 { - margin-top: 0px; + margin-top: 30px; margin-bottom: 15px; font-weight: 700; + font-size: 32px; } #examples .article p, #gs .article p, #about .article p { margin-bottom: 20px; text-align: left; + font-size: 22px; } h3 .item { @@ -289,8 +291,12 @@ h3 .item { } #examples .article li, #gs .article li, #about .article li { text-align: left; + font-size: 22px; + margin-bottom: 10px; } +pre {font-size: 16px;} + /* END: SECTIONS */ /* START: CONTACT SECTION (NOT CURRENTLY IN DOCUMENT) */ diff --git a/index.html b/index.html index ddc498a75..992f25b3a 100755 --- a/index.html +++ b/index.html @@ -25,6 +25,9 @@ + + + - LoopBack + LoopBack @@ -64,7 +67,7 @@
-

LoopBack is here

+

LoopBack is here


@@ -157,28 +160,26 @@

More information

Assuming you have already installed Node...

Install

-
$ slc install -g strong-cli
+
$ npm install -g strong-cli

Create app

-
$ slc lb project my-app
+
$ slc lb project my-app

Create models

-
-$ slc lb model bank
+
$ slc lb model bank
 $ slc lb model account
 $ slc lb model transaction
-
+

Secure with access control

-
-$ slc lb acl --all-models --deny --everyone
+
$ slc lb acl --all-models --deny --everyone
 $ slc lb acl --allow --everyone --read --model bank
 $ slc lb acl --allow --everyone --call create --model user
 $ slc lb acl --allow --owner --all --model user
 $ slc lb acl --allow --owner --read --model account
 $ slc lb acl --allow --owner --write --model account
-
+

Interact with data

-

The following are from the Banking App

+

The following are from the banking example app

Create backend app and models

-
-$ slc lb project my-bank-app
+
$ slc lb project my-bank-app
 $ cd my-bank-app
 $ slc lb model bank
 $ slc lb model account
 $ slc lb model transaction
-
+
+

Create a secure REST API using command-line tools

-
-$ slc lb acl --all-models --deny --everyone
+
$ slc lb acl --all-models --deny --everyone
 $ slc lb acl --allow --everyone --read --model bank
 $ slc lb acl --allow --everyone --call create --model user
 $ slc lb acl --allow --owner --all --model user
 $ slc lb acl --allow --owner --read --model account
 $ slc lb acl --allow --owner --write --model account
-
+

Easily persist data

-
-MyProduct = loopback.Model.extend('my-product');
+
MyProduct = loopback.Model.extend('my-product');
 app.model(MyProduct);
 MyProduct.create({
-  name: 'Pencil',
-  price: 0.99
+    name: 'Pencil',
+    price: 0.99
 });
-
+

Run ad-hoc queries

-
-MyProduct.find({
-  where: {price: {lt: 100}},
-  order: 'price ASC',
-  limit: 3
+
MyProduct.find({
+    where: {price: {lt: 100}},
+    order: 'price ASC',
+    limit: 3
 }, function(err, products) {
   ...
 });
-
+
+

Build data model with command-line tools

-
-var Model = require('loopback').Model;
+
var Model = require('loopback').Model;
 var Product = Model.extend('product');
 var Inventory = Model.extend('customer');
+
 // Attach data sources
 var db = loopback.createDataSource({
-  connector: require('loopback-connector-mongodb')
+    connector: require('loopback-connector-mongodb')
 });
+
 // Enable the model to use the MongoDB API
 Product.attachTo(db);
+
 // Create a new product in the database
 Product.create({ name: 'widget', price: 99.99 },
-  function(err, widget) {
-    // The product's id, added by MongoDB
-    console.log(widget.id);
+    function(err, widget) {
+        console.log(widget.id);  // The product's id, added by MongoDB
 });
-
+

Connect to Oracle database

-
-var loopback = require('loopback'); 
+
var loopback = require('loopback'); 
 var ds = loopback.createDataSource('oracle', { 
-               "host": "demo.strongloop.com", 
-               "port": 1521, 
-               "database": "XE", 
-               "username": "demo", 
-               "password": "L00pBack" 
-           });	
-
+ "host": "demo.strongloop.com", + "port": 1521, + "database": "XE", + "username": "demo", + "password": "L00pBack" +}); +

Automatically discover and expose database tables through REST API

-
-var ds = require('../data-sources/db.js')('oracle');	
+
var ds = require('../data-sources/db.js')('oracle');	
 	
 // Discover and build models from INVENTORY table	
 ds.discoverAndBuildModels('INVENTORY', 
-   {visited: {}, owner: 'LOOPBACK', associations: true}, 
-   function (err, models) {	
-       models.Inventory.findOne({}, function (err, inv) {
-       if (err) {	
-          console.error(err);	
-          return;	
-       }	
-    console.log("\nInventory: ", inv);	
-    inv.product(function (err, prod) {	
-       console.log(err);	
-       console.log("\nProduct: ", prod);	
-       console.log("\n ------------- ");	
-     });	
-   });
-
- - + {visited: {}, owner: 'LOOPBACK', associations: true}, + function (err, models) { + models.Inventory.findOne({}, function (err, inv) { + if (err) { + console.error(err); + return; + } + console.log("\nInventory: ", inv); + inv.product(function (err, prod) { + console.log(err); + console.log("\nProduct: ", prod); + console.log("\n ------------- "); + }); + }); + } +) +
@@ -336,9 +334,10 @@

Automatically discover and expose database tables through REST API

- + + \ No newline at end of file diff --git a/js/prism.js b/js/prism.js new file mode 100644 index 000000000..f56275fbb --- /dev/null +++ b/js/prism.js @@ -0,0 +1,14 @@ +/** + * Prism: Lightweight, robust, elegant syntax highlighting + * MIT license http://www.opensource.org/licenses/mit-license.php/ + * @author Lea Verou http://lea.verou.me + */(function(){var e=/\blang(?:uage)?-(?!\*)(\w+)\b/i,t=self.Prism={util:{type:function(e){return Object.prototype.toString.call(e).match(/\[object (\w+)\]/)[1]},clone:function(e){var n=t.util.type(e);switch(n){case"Object":var r={};for(var i in e)e.hasOwnProperty(i)&&(r[i]=t.util.clone(e[i]));return r;case"Array":return e.slice()}return e}},languages:{extend:function(e,n){var r=t.util.clone(t.languages[e]);for(var i in n)r[i]=n[i];return r},insertBefore:function(e,n,r,i){i=i||t.languages;var s=i[e],o={};for(var u in s)if(s.hasOwnProperty(u)){if(u==n)for(var a in r)r.hasOwnProperty(a)&&(o[a]=r[a]);o[u]=s[u]}return i[e]=o},DFS:function(e,n){for(var r in e){n.call(e,r,e[r]);t.util.type(e)==="Object"&&t.languages.DFS(e[r],n)}}},highlightAll:function(e,n){var r=document.querySelectorAll('code[class*="language-"], [class*="language-"] code, code[class*="lang-"], [class*="lang-"] code');for(var i=0,s;s=r[i++];)t.highlightElement(s,e===!0,n)},highlightElement:function(r,i,s){var o,u,a=r;while(a&&!e.test(a.className))a=a.parentNode;if(a){o=(a.className.match(e)||[,""])[1];u=t.languages[o]}if(!u)return;r.className=r.className.replace(e,"").replace(/\s+/g," ")+" language-"+o;a=r.parentNode;/pre/i.test(a.nodeName)&&(a.className=a.className.replace(e,"").replace(/\s+/g," ")+" language-"+o);var f=r.textContent;if(!f)return;f=f.replace(/&/g,"&").replace(/e.length)break e;if(p instanceof i)continue;a.lastIndex=0;var d=a.exec(p);if(d){l&&(c=d[1].length);var v=d.index-1+c,d=d[0].slice(c),m=d.length,g=v+m,y=p.slice(0,v+1),b=p.slice(g+1),w=[h,1];y&&w.push(y);var E=new i(u,f?t.tokenize(d,f):d);w.push(E);b&&w.push(b);Array.prototype.splice.apply(s,w)}}}return s},hooks:{all:{},add:function(e,n){var r=t.hooks.all;r[e]=r[e]||[];r[e].push(n)},run:function(e,n){var r=t.hooks.all[e];if(!r||!r.length)return;for(var i=0,s;s=r[i++];)s(n)}}},n=t.Token=function(e,t){this.type=e;this.content=t};n.stringify=function(e,r,i){if(typeof e=="string")return e;if(Object.prototype.toString.call(e)=="[object Array]")return e.map(function(t){return n.stringify(t,r,e)}).join("");var s={type:e.type,content:n.stringify(e.content,r,i),tag:"span",classes:["token",e.type],attributes:{},language:r,parent:i};s.type=="comment"&&(s.attributes.spellcheck="true");t.hooks.run("wrap",s);var o="";for(var u in s.attributes)o+=u+'="'+(s.attributes[u]||"")+'"';return"<"+s.tag+' class="'+s.classes.join(" ")+'" '+o+">"+s.content+""};if(!self.document){self.addEventListener("message",function(e){var n=JSON.parse(e.data),r=n.language,i=n.code;self.postMessage(JSON.stringify(t.tokenize(i,t.languages[r])));self.close()},!1);return}var r=document.getElementsByTagName("script");r=r[r.length-1];if(r){t.filename=r.src;document.addEventListener&&!r.hasAttribute("data-manual")&&document.addEventListener("DOMContentLoaded",t.highlightAll)}})();; +Prism.languages.markup={comment:/<!--[\w\W]*?-->/g,prolog:/<\?.+?\?>/,doctype:/<!DOCTYPE.+?>/,cdata:/<!\[CDATA\[[\w\W]*?]]>/i,tag:{pattern:/<\/?[\w:-]+\s*(?:\s+[\w:-]+(?:=(?:("|')(\\?[\w\W])*?\1|\w+))?\s*)*\/?>/gi,inside:{tag:{pattern:/^<\/?[\w:-]+/i,inside:{punctuation:/^<\/?/,namespace:/^[\w-]+?:/}},"attr-value":{pattern:/=(?:('|")[\w\W]*?(\1)|[^\s>]+)/gi,inside:{punctuation:/=|>|"/g}},punctuation:/\/?>/g,"attr-name":{pattern:/[\w:-]+/g,inside:{namespace:/^[\w-]+?:/}}}},entity:/&#?[\da-z]{1,8};/gi};Prism.hooks.add("wrap",function(e){e.type==="entity"&&(e.attributes.title=e.content.replace(/&/,"&"))});; +Prism.languages.css={comment:/\/\*[\w\W]*?\*\//g,atrule:{pattern:/@[\w-]+?.*?(;|(?=\s*{))/gi,inside:{punctuation:/[;:]/g}},url:/url\((["']?).*?\1\)/gi,selector:/[^\{\}\s][^\{\};]*(?=\s*\{)/g,property:/(\b|\B)[\w-]+(?=\s*:)/ig,string:/("|')(\\?.)*?\1/g,important:/\B!important\b/gi,ignore:/&(lt|gt|amp);/gi,punctuation:/[\{\};:]/g};Prism.languages.markup&&Prism.languages.insertBefore("markup","tag",{style:{pattern:/(<|<)style[\w\W]*?(>|>)[\w\W]*?(<|<)\/style(>|>)/ig,inside:{tag:{pattern:/(<|<)style[\w\W]*?(>|>)|(<|<)\/style(>|>)/ig,inside:Prism.languages.markup.tag.inside},rest:Prism.languages.css}}});; +Prism.languages.clike={comment:{pattern:/(^|[^\\])(\/\*[\w\W]*?\*\/|(^|[^:])\/\/.*?(\r?\n|$))/g,lookbehind:!0},string:/("|')(\\?.)*?\1/g,"class-name":{pattern:/((?:(?:class|interface|extends|implements|trait|instanceof|new)\s+)|(?:catch\s+\())[a-z0-9_\.\\]+/ig,lookbehind:!0,inside:{punctuation:/(\.|\\)/}},keyword:/\b(if|else|while|do|for|return|in|instanceof|function|new|try|throw|catch|finally|null|break|continue)\b/g,"boolean":/\b(true|false)\b/g,"function":{pattern:/[a-z0-9_]+\(/ig,inside:{punctuation:/\(/}}, number:/\b-?(0x[\dA-Fa-f]+|\d*\.?\d+([Ee]-?\d+)?)\b/g,operator:/[-+]{1,2}|!|<=?|>=?|={1,3}|(&){1,2}|\|?\||\?|\*|\/|\~|\^|\%|\$/g,ignore:/&(lt|gt|amp);/gi,punctuation:/[{}[\];(),.:]/g}; +; +Prism.languages.javascript=Prism.languages.extend("clike",{keyword:/\b(var|let|if|else|while|do|for|return|in|instanceof|function|new|with|typeof|try|throw|catch|finally|null|break|continue)\b/g,number:/\b-?(0x[\dA-Fa-f]+|\d*\.?\d+([Ee]-?\d+)?|NaN|-?Infinity)\b/g});Prism.languages.insertBefore("javascript","keyword",{regex:{pattern:/(^|[^/])\/(?!\/)(\[.+?]|\\.|[^/\r\n])+\/[gim]{0,3}(?=\s*($|[\r\n,.;})]))/g,lookbehind:!0}});Prism.languages.markup&&Prism.languages.insertBefore("markup","tag",{script:{pattern:/(<|<)script[\w\W]*?(>|>)[\w\W]*?(<|<)\/script(>|>)/ig,inside:{tag:{pattern:/(<|<)script[\w\W]*?(>|>)|(<|<)\/script(>|>)/ig,inside:Prism.languages.markup.tag.inside},rest:Prism.languages.javascript}}}); +; +Prism.languages.java=Prism.languages.extend("clike",{keyword:/\b(abstract|continue|for|new|switch|assert|default|goto|package|synchronized|boolean|do|if|private|this|break|double|implements|protected|throw|byte|else|import|public|throws|case|enum|instanceof|return|transient|catch|extends|int|short|try|char|final|interface|static|void|class|finally|long|strictfp|volatile|const|float|native|super|while)\b/g,number:/\b0b[01]+\b|\b0x[\da-f]*\.?[\da-fp\-]+\b|\b\d*\.?\d+[e]?[\d]*[df]\b|\W\d*\.?\d+\b/gi,operator:{pattern:/([^\.]|^)([-+]{1,2}|!|=?<|=?>|={1,2}|(&){1,2}|\|?\||\?|\*|\/|%|\^|(<){2}|($gt;){2,3}|:|~)/g,lookbehind:!0}});; +Prism.languages.bash=Prism.languages.extend("clike",{comment:{pattern:/(^|[^"{\\])(#.*?(\r?\n|$))/g,lookbehind:!0},string:{pattern:/("|')(\\?[\s\S])*?\1/g,inside:{property:/\$([a-zA-Z0-9_#\?\-\*!@]+|\{[^\}]+\})/g}},keyword:/\b(if|then|else|elif|fi|for|break|continue|while|in|case|function|select|do|done|until|echo|exit|return|set|declare|slc lb|npm install)\b/g});Prism.languages.insertBefore("bash","keyword",{property:/\$([a-zA-Z0-9_#\?\-\*!@]+|\{[^}]+\})/g});Prism.languages.insertBefore("bash","comment",{important:/(^#!\s*\/bin\/bash)|(^#!\s*\/bin\/sh)/g}); +;