Skip to content

Commit

Permalink
added create and some man page changes
Browse files Browse the repository at this point in the history
  • Loading branch information
akollegger committed May 28, 2012
1 parent 5223393 commit 8a0b978
Show file tree
Hide file tree
Showing 4 changed files with 170 additions and 0 deletions.
47 changes: 47 additions & 0 deletions src/main/resources/WEB-INF/lib/cypher/commands/create.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
/*
* Copyright 2009-2011 Mozilla Foundation and contributors
* Licensed under the New BSD license. See LICENSE.txt or:
* http://opensource.org/licenses/BSD-3-Clause
*/

define(function(require, exports, module) {

var gcli = require('gcli/index');
var util = require('gcli/util');
var cypher = require('cypher/index');

/**
* Registration and de-registration.
*/
exports.startup = function() {
gcli.addCommand(cypherCreatecCommandSpec);
};

exports.shutdown = function() {
gcli.removeCommand(cypherCreatecCommandSpec);
};

/**
* 'create' command.
*/
var cypherCreatecCommandSpec = {
name: 'create',
returnType: 'html',
description: 'Create nodes and relationships',
params: [
{ name: 'spec', type: 'string', description: 'specification for new nodes and relationships' }
],

exec: function(args, context) {
return cypher.query("CREATE " + args.spec, context);
},

examples: [
{ example:'CREATE n', description: 'Create a single node'},
{ example:'CREATE n = {name : \'Andres\', title : \'Developer\'}', description: 'Create single node and set properties'}
]

};


});
40 changes: 40 additions & 0 deletions src/main/resources/WEB-INF/lib/cypher/commands/help.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@

.gcli-help-name {
text-align: end;
}

.gcli-help-arrow {
font-size: 70%;
color: #AAA;
}

.gcli-help-synopsis {
font-family: monospace;
font-weight: normal;
padding: 0 3px;
margin: 0 10px;
border: 1px solid #999;
border-radius: 3px;
color: #666;
cursor: pointer;
display: inline-block;
}

.gcli-help-synopsis:before {
color: #66F;
content: '\bb';
}

.gcli-help-description {
margin: 0 20px;
padding: 0;
}

.gcli-help-parameter {
margin: 0 30px;
padding: 0;
}

.gcli-help-header {
margin: 10px 0 6px;
}
26 changes: 26 additions & 0 deletions src/main/resources/WEB-INF/lib/cypher/commands/help_list.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@

<div>
<div if="${includeIntro}">
<h2>Cypher REPL</h2>
<p>An experimental GCLI-based shell for querying Neo4j with Cypher.</p>
<p>
Useful links:
<a target='_blank' href='http://neo4j.org'>Neo4j</a>,
<a target='_blank' href='http://docs.neo4j.org/chunked/1.8.M03/cypher-query-lang.html'>Cypher Query Language</a>
</p>
</div>

<h3>${getHeading()}</h3>

<table>
<tr foreach="command in ${getMatchingCommands()}"
onclick="${onclick}" ondblclick="${ondblclick}">
<th class="gcli-help-name">${command.name}</th>
<td class="gcli-help-arrow">&#x2192;</td>
<td>
${command.description}
<span class="gcli-out-shortcut gcli-help-command">help ${command.name}</span>
</td>
</tr>
</table>
</div>
57 changes: 57 additions & 0 deletions src/main/resources/WEB-INF/lib/cypher/commands/help_man.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@

<div>
<h3>${command.name}</h3>

<h4 class="gcli-help-header">
${l10n.helpManSynopsis}:
<span class="gcli-help-synopsis" onclick="${onclick}">
<span class="gcli-help-command">${command.name}</span>
<span foreach="param in ${command.params}">
${param.defaultValue !== undefined ? '[' + param.name + ']' : param.name}
</span>
</span>
</h4>

<h4 class="gcli-help-header">${l10n.helpManDescription}:</h4>

<p class="gcli-help-description">
${command.manual || command.description}
</p>

<div if="${command.exec}">
<h4 class="gcli-help-header">${l10n.helpManParameters}:</h4>

<ul class="gcli-help-parameter">
<li if="${command.params.length === 0}">${l10n.helpManNone}</li>
<li foreach="param in ${command.params}">
<tt>${param.name}</tt> ${getTypeDescription(param)}
<br/>
${param.manual || param.description}
</li>
</ul>
</div>

<div if="${!command.exec}">
<h4 class="gcli-help-header">${l10n.subCommands}:</h4>

<ul class="gcli-help-${subcommands}">
<li if="${subcommands.length === 0}">${l10n.subcommandsNone}</li>
<li foreach="subcommand in ${subcommands}">
<strong>${subcommand.name}</strong>:
${subcommand.description}
<span class="gcli-help-synopsis" onclick="${onclick}" ondblclick="${ondblclick}">
<span class="gcli-help-command">help ${subcommand.name}</span>
</span>
</li>
</ul>
</div>

<h4 if="${command.examples}" class="gcli-help-header">Examples:</h4>

<ol if="${command.examples}">
<li foreach="example in ${command.examples}">${example.description}
<pre>${example.example}</pre>
</li>
</ol>

</div>

0 comments on commit 8a0b978

Please sign in to comment.