Giter VIP home page Giter VIP logo

insight's Introduction

Insight

A server that allows multiple users to edit and run code simultaneously. Anyone who connects to the server is able to edit the text. If the host connects to the server it is given a permission to set a certain command. Any user is able to request the command execution.

For additional materials also see Insight Goodies.

Requirements

  • Node.js installed

Installation

Download the repo via any browser or clone it via git:

git clone https://github.com/lunakoly/Insight.git

Usage

Navigate to the project folder and start Node.js server:

node . [options...]

Available options:

  • -h, --help: prints usage message
  • -p, --port: sets the port to start the server on
  • -c, --command: sets the initial value of the [Run] command
  • -l, --language: sets the identifier of the syntax highlight rules to be used initially (terminates if the requested language is not presented)
  • -f, --file: specifies the file which contents should be used as initial text

When no options specified the default ones are used:

  • The port is 1234
  • The initial command is print Hello!
  • The initial language is plain text
  • The initial text will be Type here...

For example:

$ node . -pc 25565 "echo Bye!" --file ~/welcome.txt

Overriding Defaults

Alternative default options can be specifier in ~/.insight/defaults.json file. Top-level keys must be exactly the same options as the ones defined above except they should not have -- prefix:

{
    "command": "python code",
    "language": "python",
    "file": "C:\\\\Users\\luna_koly\\.insight\\greeting.py"
}

Accessing Code

When any user requests [Run] the text is written into a file named code inside of a certain directory references as runtime. The command is then executed within the runtime as it's current working directory.

Languages

To add different syntax highlighting schemes the one needs to have a corresponding .json file inside of ~/.insight/languages/. The name of the file (without the extension) is used as a language identifier. The name plain text.json is forbidden since such an identifier is already in use.

Examples of languages are also available at Insight Goodies.

The structure of the file:

{
    /**
     * Name is required and will be displayed
     * in the select control on the client side
     */
    "name": "Python",

    /**
     * Scopes are requred and represent actual syntax
     * highlighting rules to be applied
     */
    "scopes": {
        /**
         * Keys are the identifiers of context.
         * Values are the contexts themselves.
         * Global scope is required since it's
         * a starting point of the highlight
         */
        "global": {
            /**
             * Patterns are required and define
             * regex string representations as keys
             * and actions to be done as their mapped
             * values.
             * 'patterns' may be empty.
             */
            "patterns": {
                /**
                 * In our example it defines a start of
                 * quoted text
                 */
                "'": {
                    /**
                     * Style to apply to the result of
                     * the "'" match.
                     */
                    "style_class": "single-quoted",
                    /**
                     * The name of the scope to use
                     * recursively scince now
                     */
                    "push": "single_quote_scope"
                },

                /**
                 * An example of matching keywords
                 */
                "\\b(if|elif|else)\\b": {
                    "style_class": "keyword"
                }
            }
        },

        /**
         * The quoted text in our example.
         */
        "single_quote_scope": {
            /**
             * Optional parameter defining the style class
             * for the whole scope
             */
            "style_class": "single-quoted",

            "patterns": {
                "'": {
                    /**
                     * Tells the interpreter to escape the
                     * current scope
                     */
                    "pop": true
                },

                /**
                 * Match escape sequences
                 */
                "\\\\.": {
                    "style_class": "keyword"
                }
            }
        }
    }
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.