Permalink
Browse files

Merge pull request #18 from nawroth/livecypher

Added live cypher console.
  • Loading branch information...
2 parents 1e4a609 + c250f1f commit ebac1ae8b07113c622c252733df033840be96f1c @nawroth committed Apr 9, 2012
View
2 Makefile
@@ -167,7 +167,7 @@ docbook-html: manpages copyimages
#
#
mkdir -p "$(BUILDDIR)"
- "$(ASCIIDOC)" $(ASCIIDOC_FLAGS) --backend docbook --attribute docinfo1 --doctype book --conf-file="$(CONFDIR)/asciidoc.conf" --conf-file="$(CONFDIR)/docbook45.conf" --conf-file="$(CONFDIR)/linkedimages.conf" --out-file "$(DOCBOOKFILEHTML)" "$(SRCFILE)" 2>&1 | "$(SCRIPTDIR)/outputcheck-includefiles.sh"
+ "$(ASCIIDOC)" $(ASCIIDOC_FLAGS) --backend docbook --attribute docinfo1 --attribute cypherconsole=1 --doctype book --conf-file="$(CONFDIR)/asciidoc.conf" --conf-file="$(CONFDIR)/docbook45.conf" --conf-file="$(CONFDIR)/linkedimages.conf" --out-file "$(DOCBOOKFILEHTML)" "$(SRCFILE)" 2>&1 | "$(SCRIPTDIR)/outputcheck-includefiles.sh"
xmllint --nonet --noout --xinclude --postvalid "$(DOCBOOKFILEHTML)"
pdf: docbook-shortinfo copyimages
View
14 src/bin/resources/cypherconsole/cypherconsole.conf
@@ -0,0 +1,14 @@
+#
+# AsciiDoc cypherconsole filter configuration file.
+#
+
+[cypherconsole-filter-style]
+cypherconsole-style=template="cypherconsole-block",posattrs=("style", "db"),filter='cypherconsole.py "{cypherconsole}" {title?"title={title}"} {db?"db={db}"}'
+
+[blockdef-listing]
+template::[cypherconsole-filter-style]
+
+[cypherconsole-block]
+template::[openblock]
+
+
View
45 src/bin/resources/cypherconsole/cypherconsole.py
@@ -0,0 +1,45 @@
+#!/usr/bin/env python
+# -*- mode: Python; coding: utf-8 -*-
+
+import sys
+
+if len(sys.argv) > 1:
+ active = sys.argv[1].startswith('1')
+
+if not active:
+ sys.stdout.write(' ')
+else:
+ title = ''
+ db = ''
+ for i in [2, 3]:
+ if len(sys.argv) > i:
+ key,value = sys.argv[i].split('=')
+ if key == 'title':
+ title = value
+ elif key == 'db':
+ db = value
+ if len(db) == 0:
+ sys.exit("A database has to be defined.")
+ data = sys.stdin.readlines()
+ if len(data) == 0:
+ sys.exit("A query has to be defined.")
+ query = ''.join(data)
+ body = []
+ if len(title) > 0:
+ body.append('<formalpara role="cypherconsole"><title>')
+ body.append(title)
+ body.append('</title><para>')
+ else:
+ body.append('<simpara role="cypherconsole">')
+ body.append('<database>')
+ body.append(db)
+ body.append('</database>')
+ body.append('<command>')
+ body.append(query)
+ body.append('</command>')
+ if len(title) > 1:
+ body.append('</para></formalpara>')
+ else:
+ body.append('</simpara>')
+ sys.stdout.write(''.join(body))
+
View
4 src/main/resources/conf/head-offline.xsl
@@ -59,6 +59,10 @@
<script type="text/javascript" src="js/tablestyler.js"></script>
+<!-- Cypher Console -->
+
+<script type="text/javascript" src="js/cypherconsole.js"></script>
+
]]>
</xsl:text>
View
4 src/main/resources/conf/head.xsl
@@ -63,6 +63,10 @@
<script type="text/javascript" src="js/versionswitcher.js"></script>
+<!-- Cypher Console -->
+
+<script type="text/javascript" src="js/cypherconsole.js"></script>
+
]]>
</xsl:text>
View
19 src/main/resources/css/neo.css
@@ -491,3 +491,22 @@ div.configsetting table tfoot th
font-weight: normal;
}
+p.cypherconsole
+{
+ display: none;
+}
+
+button.cypherconsole img
+{
+ vertical-align: bottom;
+ padding-right: .5em;
+}
+
+iframe.console
+{
+ width: 80em;
+ max-width: 95%;
+ height: 23em;
+ display: block;
+}
+
View
BIN src/main/resources/css/utilities-terminal.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
64 src/main/resources/js/cypherconsole.js
@@ -0,0 +1,64 @@
+/**
+ * Licensed to Neo Technology under one or more contributor
+ * license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright
+ * ownership. Neo Technology licenses this file to you under
+ * the Apache License, Version 2.0 (the "License"); you may
+ * not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+/* Cypher Console
+ * Adds live cypher console feature to a page.
+ */
+
+jQuery( document ).ready( function()
+{
+ createCypherConsoles( jQuery );
+});
+
+function createCypherConsoles( $ )
+{
+ $('p.cypherconsole').each( function()
+ {
+ var title = $.trim( $( 'b', this ).eq(0).text() ) || 'Live Cypher Console';
+ title = title.replace( /\.$/, '' );
+ var database = $( 'span.database', this ).eq(0).text();
+ if ( !database ) return;
+ var command = $( 'strong', this ).eq(0).text();
+ if ( !command ) return;
+ var button = $( '<button class="cypherconsole" type="button"><img src="css/utilities-terminal.png" /> ' + title + '</button>' );
+ button.click( function()
+ {
+ handleCypherClick( button, database, command, title );
+ });
+ button.insertAfter( this );
+ });
+
+ function handleCypherClick( button, database, command, title )
+ {
+ var iframe=$( "#console" );
+ if ( iframe.length )
+ {
+ iframe.remove();
+ }
+ else
+ {
+ var url="http://console.neo4j.org/?";
+ url += "init=" + encodeURIComponent( database );
+ url += "&query=" + encodeURIComponent( command );
+ iframe = $( "<iframe/>" ).attr( "id", "console" ).addClass( "console" ).attr( "src", url );
+ button.after( iframe );
+ }
+ }
+}
+
View
2 src/main/resources/neo4j-manual.txt
@@ -7,6 +7,8 @@ The Neo4j Manual v{revnumber}
:lucene-version: 3_5_0
+:cypherconsole: 0
+
include::preface/preface.txt[]
:leveloffset: 0

0 comments on commit ebac1ae

Please sign in to comment.