Permalink
Browse files

add examples directory and a couple examples to start

  • Loading branch information...
1 parent 5ca1498 commit 0e9d3b9cb4d2f1e69f500963d845a6794bb54455 @Caged committed Apr 15, 2012
View
@@ -1,3 +1,2 @@
node_modules
-examples
npm-debug.log
@@ -0,0 +1,5 @@
+# Comment here
+api = octo.api()
+api.post('/some-nonexistent-resource').on('error', (name, msg, req) ->
+ console.log "#{req.status} ERROR. #{name}: #{msg}"
+)()
View
@@ -0,0 +1,15 @@
+<!DOCTYPE html>
+<html>
+<head>
+ <title>octo.js example</title>
+ <link rel="stylesheet" href="/ven/blackboard.css" />
+ <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
+ <script src="../octo.js"></script>
+ <script src="/ven/rainbow.js"></script>
+ <script src="/ven/coffeescript.js"></script>
+ <script type="text/javascript">{{{REPLACE_ME}}}</script>
+</head>
+<body>
+ <pre id="source"><code data-language="javascript">{{{SOURCE_ME}}}</code></pre>
+</body>
+</html>
@@ -0,0 +1,3 @@
+# Inspect results in your browser's console
+api = octo.api()
+api.get('/events').on('success', (data) -> console.log data)()
@@ -0,0 +1,63 @@
+/**
+ * Blackboard theme
+ *
+ * Adapted from Domenico Carbotta's TextMate theme of the same name
+ *
+ * @author Domenico Carbotta
+ * @author Craig Campbell
+ * @version 1.0.2
+ */
+pre {
+ background: #0B1022;
+ word-wrap: break-word;
+ margin: 0px;
+ padding: 0px;
+ padding: 10px;
+ color: #fff;
+ font-size: 14px;
+ margin-bottom: 20px;
+}
+
+pre, code {
+ font-family: 'Monaco', courier, monospace;
+}
+
+pre .comment {
+ color: #727272;
+}
+
+pre .constant {
+ color: #D8FA3C;
+}
+
+pre .storage {
+ color: #FBDE2D;
+}
+
+pre .string, pre .comment.docstring {
+ color: #61CE3C;
+}
+
+pre .string.regexp, pre .support.tag.script, pre .support.tag.style {
+ color: #fff;
+}
+
+pre .keyword, pre .selector {
+ color: #FBDE2D;
+}
+
+pre .inherited-class {
+ font-style: italic;
+}
+
+pre .entity {
+ color: #FF6400;
+}
+
+pre .support, *[data-language="c"] .function.call {
+ color: #8DA6CE;
+}
+
+pre .variable.global, pre .variable.class, pre .variable.instance {
+ color: #FF6400;
+}
@@ -0,0 +1,102 @@
+/**
+ * Javascript patterns
+ *
+ * @author Craig Campbell
+ * @version 1.0.6
+ */
+Rainbow.extend('javascript', [
+ {
+ 'name': 'comment',
+ 'pattern': /\#*?$/g
+ },
+ /**
+ * matches $. or $(
+ */
+ {
+ 'name': 'selector',
+ 'pattern': /(\s|^)\$(?=\.|\()/g
+ },
+ {
+ 'name': 'support',
+ 'pattern': /\b(window|document)\b/g
+ },
+ {
+ 'matches': {
+ 1: 'support.property'
+ },
+ 'pattern': /\.(length|node(Name|Value))\b/g
+ },
+ {
+ 'matches': {
+ 1: 'support.function'
+ },
+ 'pattern': /(setTimeout|setInterval)(?=\()/g
+
+ },
+ {
+ 'matches': {
+ 1: 'support.method'
+ },
+ 'pattern': /\.(getAttribute|push|getElementById|getElementsByClassName|log|setTimeout|setInterval)(?=\()/g
+ },
+ {
+ 'matches': {
+ 1: 'support.tag.script',
+ 2: [
+ {
+ 'name': 'string',
+ 'pattern': /('|")(.*?)(\1)/g
+ },
+ {
+ 'name': 'entity.tag.script',
+ 'pattern': /(\w+)/g
+ }
+ ],
+ 3: 'support.tag.script'
+ },
+ 'pattern': /(&lt;\/?)(script.*?)(&gt;)/g
+ },
+
+ /**
+ * matches any escaped characters inside of a js regex pattern
+ *
+ * @see https://github.com/ccampbell/rainbow/issues/22
+ *
+ * this was causing single line comments to fail so it now makes sure
+ * the opening / is not directly followed by a *
+ *
+ * @todo check that there is valid regex in match group 1
+ */
+ {
+ 'name': 'string.regexp',
+ 'matches': {
+ 1: 'string.regexp.open',
+ 2: {
+ 'name': 'constant.regexp.escape',
+ 'pattern': /\\(.){1}/g
+ },
+ 3: 'string.regexp.close',
+ 4: 'string.regexp.modifier'
+ },
+ 'pattern': /(\/)(?!\*)(.+)(\/)([igm]{0,3})/g
+ },
+
+ /**
+ * matches runtime function declarations
+ */
+ {
+ 'matches': {
+ 1: 'storage',
+ 3: 'entity.function'
+ },
+ 'pattern': /(var)?(\s|^)(.*)(?=\s?=\s?function\()/g
+ },
+
+ /**
+ * matches any function call in the style functionName: function()
+ */
+ {
+ 'name': 'entity.function',
+ 'pattern': /(\w+)(?=:\s{0,}function)/g
+ }
+]);

0 comments on commit 0e9d3b9

Please sign in to comment.