Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
  • 6 commits
  • 10 files changed
  • 0 comments
  • 1 contributor
2  Makefile
@@ -167,7 +167,7 @@ docbook-html: manpages copyimages
167 167 #
168 168 #
169 169 mkdir -p "$(BUILDDIR)"
170   - "$(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"
  170 + "$(ASCIIDOC)" $(ASCIIDOC_FLAGS) --backend docbook --attribute docinfo1 --attribute console=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"
171 171 xmllint --nonet --noout --xinclude --postvalid "$(DOCBOOKFILEHTML)"
172 172
173 173 pdf: docbook-shortinfo copyimages
12 src/bin/resources/console/console.conf
... ... @@ -0,0 +1,12 @@
  1 +#
  2 +# AsciiDoc console filter configuration file.
  3 +#
  4 +
  5 +[console-filter-style]
  6 +console-style=template="console-block",filter='console.py "{console}" {title?"{title}"}'
  7 +
  8 +[blockdef-listing]
  9 +template::[console-filter-style]
  10 +
  11 +[console-block]
  12 +template::[openblock]
49 src/bin/resources/console/console.py
... ... @@ -0,0 +1,49 @@
  1 +#!/usr/bin/env python
  2 +# -*- mode: Python; coding: utf-8 -*-
  3 +
  4 +import sys
  5 +
  6 +if len(sys.argv) > 1:
  7 + active = sys.argv[1].startswith('1')
  8 +
  9 +if not active:
  10 + sys.stdout.write(' ')
  11 +else:
  12 + title = ''
  13 + if len(sys.argv) > 2:
  14 + title = sys.argv[2]
  15 + db = []
  16 + query = []
  17 + found_empty_line = False
  18 + data = sys.stdin.readlines()
  19 + for line in data:
  20 + if found_empty_line:
  21 + query.append(line)
  22 + else:
  23 + if len(line.strip()) == 0:
  24 + found_empty_line = True
  25 + else:
  26 + db.append(line)
  27 + if len(db) == 0:
  28 + sys.exit("A database has to be defined.")
  29 + if len(query) == 0:
  30 + sys.exit("A query has to be defined.")
  31 + body = []
  32 + if len(title) > 0:
  33 + body.append('<formalpara role="cypherconsole"><title>')
  34 + body.append(title)
  35 + body.append('</title><para>')
  36 + else:
  37 + body.append('<simpara role="cypherconsole">')
  38 + body.append('<database>')
  39 + body.extend(db)
  40 + body.append('</database>')
  41 + body.append('<command>')
  42 + body.append(' '.join(query))
  43 + body.append('</command>')
  44 + if len(title) > 1:
  45 + body.append('</para></formalpara>')
  46 + else:
  47 + body.append('</simpara>')
  48 + sys.stdout.write(''.join(body))
  49 +
36 src/main/resources/community/docs.txt
@@ -464,6 +464,42 @@ include::{importdir}/neo4j-examples-docs-jar/dev/examples/hello-world-sample-cha
464 464
465 465 :leveloffset: 2
466 466
  467 +== Integrated Live Console ==
  468 +
  469 +An interactive console can be added and will show up in the online HTML version.
  470 +An optional title can be added, which will be used for the text of the button.
  471 +
  472 +This is how to do it, using Geoff to define the data, with an empty line to separate it from the query:
  473 +
  474 +[source]
  475 +----
  476 + .Interactive Matrix Example
  477 + [console]
  478 + ----
  479 + (A) {"name" : "Neo"};
  480 + (B) {"name" : "Trinity"};
  481 + (A)-[:LOVES]->(B)
  482 +
  483 + start n = node(*)
  484 + return n
  485 + ----
  486 +----
  487 +
  488 +And this is the result:
  489 +
  490 +.Interactive Matrix Example
  491 +[console]
  492 +----
  493 +(A) {"name" : "Neo"};
  494 +(B) {"name" : "Trinity"};
  495 +(A)-[:LOVES]->(B)
  496 +
  497 +start n = node(*)
  498 +return n
  499 +----
  500 +
  501 +
  502 +
467 503 == Toolchain ==
468 504
469 505 Useful links when configuring the docbook toolchain:
4 src/main/resources/conf/head-offline.xsl
@@ -59,6 +59,10 @@
59 59
60 60 <script type="text/javascript" src="js/tablestyler.js"></script>
61 61
  62 +<!-- Cypher Console -->
  63 +
  64 +<script type="text/javascript" src="js/cypherconsole.js"></script>
  65 +
62 66 ]]>
63 67 </xsl:text>
64 68
4 src/main/resources/conf/head.xsl
@@ -63,6 +63,10 @@
63 63
64 64 <script type="text/javascript" src="js/versionswitcher.js"></script>
65 65
  66 +<!-- Cypher Console -->
  67 +
  68 +<script type="text/javascript" src="js/cypherconsole.js"></script>
  69 +
66 70 ]]>
67 71 </xsl:text>
68 72
19 src/main/resources/css/neo.css
@@ -491,3 +491,22 @@ div.configsetting table tfoot th
491 491 font-weight: normal;
492 492 }
493 493
  494 +p.cypherconsole
  495 +{
  496 + display: none;
  497 +}
  498 +
  499 +button.cypherconsole img
  500 +{
  501 + vertical-align: bottom;
  502 + padding-right: .5em;
  503 +}
  504 +
  505 +iframe.console
  506 +{
  507 + width: 80em;
  508 + max-width: 95%;
  509 + height: 23em;
  510 + display: block;
  511 +}
  512 +
BIN  src/main/resources/css/utilities-terminal.png
64 src/main/resources/js/cypherconsole.js
... ... @@ -0,0 +1,64 @@
  1 +/**
  2 + * Licensed to Neo Technology under one or more contributor
  3 + * license agreements. See the NOTICE file distributed with
  4 + * this work for additional information regarding copyright
  5 + * ownership. Neo Technology licenses this file to you under
  6 + * the Apache License, Version 2.0 (the "License"); you may
  7 + * not use this file except in compliance with the License.
  8 + * You may obtain a copy of the License at
  9 + *
  10 + * http://www.apache.org/licenses/LICENSE-2.0
  11 + *
  12 + * Unless required by applicable law or agreed to in writing,
  13 + * software distributed under the License is distributed on an
  14 + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  15 + * KIND, either express or implied. See the License for the
  16 + * specific language governing permissions and limitations
  17 + * under the License.
  18 + */
  19 +
  20 +/* Cypher Console
  21 + * Adds live cypher console feature to a page.
  22 + */
  23 +
  24 +jQuery( document ).ready( function()
  25 +{
  26 + createCypherConsoles( jQuery );
  27 +});
  28 +
  29 +function createCypherConsoles( $ )
  30 +{
  31 + $('p.cypherconsole').each( function()
  32 + {
  33 + var title = $.trim( $( 'b', this ).eq(0).text() ) || 'Live Cypher Console';
  34 + title = title.replace( /\.$/, '' );
  35 + var database = $( 'span.database', this ).eq(0).text();
  36 + if ( !database ) return;
  37 + var command = $( 'strong', this ).eq(0).text();
  38 + if ( !command ) return;
  39 + var button = $( '<button class="cypherconsole" type="button"><img src="css/utilities-terminal.png" /> ' + title + '</button>' );
  40 + button.click( function()
  41 + {
  42 + handleCypherClick( button, database, command, title );
  43 + });
  44 + button.insertAfter( this );
  45 + });
  46 +
  47 + function handleCypherClick( button, database, command, title )
  48 + {
  49 + var iframe=$( "#console" );
  50 + if ( iframe.length )
  51 + {
  52 + iframe.remove();
  53 + }
  54 + else
  55 + {
  56 + var url="http://console.neo4j.org/?";
  57 + url += "init=" + encodeURIComponent( database );
  58 + url += "&query=" + encodeURIComponent( command );
  59 + iframe = $( "<iframe/>" ).attr( "id", "console" ).addClass( "console" ).attr( "src", url );
  60 + button.after( iframe );
  61 + }
  62 + }
  63 +}
  64 +
2  src/main/resources/neo4j-manual.txt
@@ -7,6 +7,8 @@ The Neo4j Manual v{revnumber}
7 7
8 8 :lucene-version: 3_5_0
9 9
  10 +:console: 0
  11 +
10 12 include::preface/preface.txt[]
11 13
12 14 :leveloffset: 0

No commit comments for this range

Something went wrong with that request. Please try again.