toolips

a manic web-development framework
    Toolips.ComponentType

    Component <: Servable

    name::String f::Function properties::Dict –––––––––

    • name::String - The name field is the way that a component is denoted in code.
    • f::Function - The function that gets called with the Connection as an

    argument.

    • properties::Dict - A dictionary of symbols and values.

    constructors

    Component(name::String, tag::String, properties::Dict)

    Toolips.ConnectionType

    Connection

    • routes::Dict
    • http::HTTP.Stream
    • extensions::Dict

    The connection type is passed into route functions and pages as an argument. This is both for functions, as well as Servable.f() methods. This constructor should not be called directly. Instead, it is called by the server and passed through the function pipeline. Indexing a Connection will return the extension named with that symbol.

    example

                      #  v The Connection
    home = route("/") do c::Connection
        c[Logger].log("We can index extensions.")
        c.routes["/"] = c::Connection -> write!(c, "rerouting!")
        httpstream = c.http
        write!(c, "Hello world!")
        myheading::Component = h("myheading", 1, text = "Whoa!")
        write!(c, myheading)
    end

    Field Info

    • routes::Dict - A dictionary of routes where the keys

    are the routed URL and the values are the functions to those keys.

    • http::HTTP.Stream - The stream for this current peer's connection.
    • extensions::Dict - A dictionary of extensions to load with the

    name to reference as keys and the extension as the pair.

    Constructors

    • Connection
    Toolips.FileType

    File

    dir::String f::Function –––––––––

    • dir::String - The directory of a file to serve.
    • f::Function - Function whose output to be written to http().

    constructors

    File(dir::String)

    Toolips.FilesType

    Files

    type::Symbol directory::String f::Function –––––––––

    • type::Symbol - The type of extension. There are three different selections

    you can choose from. :connection :routing :func. A :connection extension will be provided in Connection.extensions. A :routing function is passed a Dict of routes as an argument. The last is a function argument, which is just a specific function to run from the top-end to the server.

    • directory::String - The directory to route the files from.
    • f::Function - The function f() called with a Connection.

    constructors

    Files(dir::String)

    Toolips.LoggerType

    Logger

    out::String levels::Dict log::Function –––––––––

    Field Info

    • out::String

    Rgw output file for the logger to write to.

    • log::Function

    A Logger logs information with different levels. Holds the function log(), connected to the function _log(). Methods:

    • log(::Int64, ::String)
    • log(::String)
    • log(::HTTP.Stream, ::String)

    Writes to HTML console, and also logs at level 1 with logger.

    • levels::Dict

    Constructors

    Logger(levels::Dict{level_count::Int64 => crayon::Crayons.Crayon}; out::String = pwd() * "logs/log.txt") Logger(; out::String = pwd() * "/logs/log.txt")

    Toolips.RouteType

    Route{T}

    • path::String
    • page::T

    A route is added to a ServerTemplate using either its constructor, or the ServerTemplate.add(::Route) method. Each route calls either a particular servable or function; the type of which denoted by T. The Route type is commonly constructed using the do syntax with the route(::Function, String) method.

    example

    # Constructors
    route = Route("/", p(text = "hello"))
    
    function example(c::Connection)
        write!(c, "hello")
    end
    
    route = Route("/", example)
    
    # method
    route = route("/") do c
        write!(c, "Hello world!")
        write!(c, p(text = "hello"))
        # we can also use extensions!
        c[:logger].log("hello world!")
    end

    fields

    • path::String

    The path, e.g. "/" at which to direct to the given component.

    • page::T (::Function || T <: Component)

    The servable to serve at this given route.

    constructors

    • Route(path::String, f::Function) where
    • Route(path::String, s::Servable)
    Toolips.ServableType

    abstract type Servable

    Servables can be written to a Connection via thier f() function and the interface. They can also be indexed with strings or symbols to change properties

    Consistencies

    • f::Function - Function whose output to be written to http().
    • properties::Dict - The properties of a given Servable. These are written

    into the servable on the calling of f().

    Toolips.ServerExtensionType

    abstract type ServerExtension

    Server extensions are loaded into the server on startup, and can have a few different abilities according to their type field's value. There are three types to be aware of.

    Consistencies

    Toolips.ServerTemplateType

    ServerTemplate

    • ip::String
    • port::Integer
    • routes::Vector{Route}
    • extensions::Dict
    • remove::Function
    • add::Function
    • start::Function

    The ServerTemplate is used to configure a server before running. These are usually made and started inside of a main server file. –––––––––

    Field Info

    • ip::String
    • port::Integer
    • routes::Vector{Route}
    • extensions::Dict
    • remove::Function
    • add::Function
    • start::Function

    Constructors

    ServerTemplate(ip::String, port::Int64, routes::Dict; extensions::Dict)

    Toolips.StyleComponentType

    abstract type StyleComponent <: Servable

    No different from a normal Servable, simply an abstract type step for the interface to separate working with Animations and Styles.

    Servable Consistencies

    Servables can be written to a Connection via thier f() function and the
    interface. They can also be indexed with strings or symbols to change properties
    ##### Consistencies
    - f::Function - Function whose output to be written to http().
    - properties::Dict - The properties of a given Servable. These are written
    into the servable on the calling of f().
    Toolips.ToolipsServerType

    abstract type ToolipsServer

    ToolipsServers are returned whenever the ServerTemplate.start() field is called. If you are running your server as a module, it should be noted that commonly a global start() method is used and returns this server, and dev is where this module is loaded, served, and revised.

    Consistencies

    • routes::Dict - The server's route => function dictionary.
    • extensions::Dict - The server's currently loaded extensions.
    • server::Any - The server, whatever type it may be...
    Base.getMethod

    Interface

    get() -> ::Dict


    Quick binding for an HTTP GET request.

    example

    Base.getindexMethod

    Interface

    getindex(::Servable, ::String) -> ::Any


    Returns a property value by string or name.

    example

    Base.getindexMethod

    Interface

    getindex(::Servable, ::Symbol) -> ::Any


    Returns a property value by symbol or name.

    example

    Base.push!Method

    Interface

    push!(::Animation, p::Pair) -> _


    Pushes a keyframe pair into an animation.

    example

    Base.push!Method

    Interface

    push!(::Component, ::Component) ->


    example

    Base.push!Method

    Interface

    push!(::Component, ::Component ...) -> ::Component


    example

    Base.setindex!Method

    Interface

    setindex!(::Animation, ::Pair, ::Int64) -> _


    Sets the animation at the percentage of the Int64 to modify the properties of pair.

    example

    Base.setindex!Method

    Interface

    setindex!(::Animation, ::Pair, ::Int64) -> _


    Sets the animation at the corresponding key-word's position.

    example

    Base.setindex!Method

    Interface

    setindex!(::Servable, ::String, ::Any) -> ::Any


    Sets the property represented by the string to the provided value.

    example

    Base.setindex!Method

    Interface

    setindex!(::Servable, ::Symbol, ::Any) -> ::Any


    Sets the property represented by the symbol to the provided value.

    example

    Toolips._logMethod

    _log(http::HTTP.Stream, message::String) -> _


    Binded call for the field log() inside of Logger(). This will log both to the JavaScript/HTML console –––––––––

    example (Closure from Logger)

    log(http::HTTP.Stream, message::String) = _log(http, message)

    Toolips._logMethod

    _log(level::Int64, message::String, levels::Dict, out::String) -> _


    Binded call for the field log() inside of Logger(). See ?(Logger) for more details on the field log. All arguments are fields of that type. Return is a printout into the REPL as well as an append to the log file, provided by the out URI. –––––––––

    example (Closure from Logger)

    log(level::Int64, message::String) = _log(level, message, levels, out) log(message::String) = _log(1, message, levels, out)

    Toolips._startMethod

    Core

    _start(routes::AbstractVector, ip::String, port::Integer,

    extensions::Dict) -> (::Sockets.HTTPServer)

    This is an internal function for the ServerTemplate. This function is binded to the ServerTemplate.start field.

    example

    Toolips.animate!Method

    Interface

    animate!(::StyleComponent, ::Animation) -> _


    Sets the Animation as a rule for the StyleComponent. Note that the Animation still needs to be written to the same Connection, preferably in a StyleSheet.

    example

    Toolips.create_serverdepsMethod

    create_serverdeps(::String) -> _


    Creates the essential portions of the webapp file structure.

    example

    Toolips.delete_keyframe!Method

    Interface

    delete_keyframe!(::Animation, ::String) -> _


    Deletes a given keyframe from an animation by keyframe name.

    example

    Toolips.download!Method

    Interface

    download!() ->


    Downloads a file to a given user's computer.

    example

    Toolips.generate_routerMethod

    Core

    generate_router(routes::AbstractVector, server::Any, extensions::Dict)


    This method is used internally by the _start method. It returns a closure function that both routes and calls functions.

    example

    Toolips.getargMethod

    Interface

    getarg(::Connection, ::Symbol, ::Type) -> ::Vector


    This method is the same as getargs(::HTTP.Stream, ::Symbol), however types are parsed as type T(). Note that "Cannot convert..." errors are possible with this method.

    example

    Toolips.getargMethod

    Interface

    getargs(::Connection, ::Symbol) -> ::Dict


    Returns the requested arguments from the target.

    example

    Toolips.getargsMethod

    Interface

    getargs(::Connection) -> ::Dict


    The getargs method returns arguments from the HTTP header (GET requests.) Returns a full dictionary of these values.

    example

    Toolips.navigate!Method

    Interface

    navigate!(::Connection, ::String) -> _


    Routes a connected stream to a given URL.

    example

    Toolips.new_appFunction

    new_app(::String) -> _


    Creates a minimalistic app, usually used for creating endpoints – but can be used for anything. For an app with a real front-end, it might make sense to add some extensions.

    example

    Toolips.new_webappFunction

    new_webapp(::String) -> _


    Creates a fully-featured web-app. Adds CanonicalToolips.jl to provide more high-level interface origrannubg from Julia.

    example

    Toolips.postMethod

    Interface

    post() ->


    Quick binding for an HTTP POST request.

    example

    Toolips.postargMethod

    Interface

    postarg(::Connection, ::String) -> ::Any


    Get a body argument of a POST response by name.

    example

    Toolips.postargsMethod

    Interface

    postargs(::Connection, ::Symbol, ::Type) -> ::Dict


    Get arguments from the request body.

    example

    Toolips.properties!Method

    Interface

    properties!(::Servable, ::Servable) -> _


    Copies properties from s,properties into c.properties.

    example

    Toolips.route!Method

    Interface

    route!(::Connection, ::Route) -> _


    Modifies the routes on the Connection.

    example

    Toolips.route!Method

    Interface

    route!(::Function, ::Connection, ::String) -> _


    Routes a given String to the Function.

    example

    Toolips.routeMethod

    Interface

    route(::Function, ::String) -> ::Route


    Creates a route from the Function.

    example

    Toolips.routeMethod

    Interface

    route(::String, ::Servable) -> ::Route


    Creates a route from a Servable.

    example

    Toolips.route_from_dirMethod

    routefromdir(dir::String) -> ::Vector{String}


    Recursively appends filenames for a directory AND all subsequent directories.

    example

    x::Vector{String} = routefromdir("mypath")

    Toolips.routesMethod

    Interface

    routes(::Route ...) -> ::Vector{Route}


    Turns routes provided as arguments into a Vector{Route} with indexable routes. This is useful because this is the type that the ServerTemplate constructor likes.

    example

    Toolips.serverfuncdefsMethod

    Core

    serverfuncdefs(::AbstractVector, ::String, ::Integer,

    ::Dict) -> (::Function, ::Function, ::Function)

    This method is used internally by a constructor to generate the functions add, start, and remove for the ServerTemplate.

    example

    Toolips.startread!Method

    Interface

    startread!(::Connection) -> _


    Resets the seek on the Connection.

    example

    Toolips.stop!Method

    Interface

    stop!(x::Any) -> _


    An alternate binding for close(x). Stops a server from running.

    example

    Toolips.style!Method

    Interface

    style!(::Style, ::Style) -> _


    Copies the properties from the second style into the first style.

    example

    Toolips.style!Method

    Interface

    style!(::Servable, ::Style) -> _


    Applies the style to a servable.

    example

    Toolips.unroute!Method

    Interface

    unroute!(::Connection, ::String) -> _


    Removes the route with the key equivalent to the String.

    example

    Toolips.write!Method

    Interface

    write!(::Connection, ::Any) -> _


    Attempts to write any type to the Connection's stream.

    example

    Toolips.write!Method

    Interface

    write!(::Connection, ::String) -> _


    Writes the String into the Connection as HTML.

    example

    Toolips.write!Method

    Interface

    write!(::Connection, ::Servable) -> _


    Writes a Servable's return to a Connection's stream.

    example

    Toolips.write!Method

    Interface

    write!(c::Connection, s::Vector{Servable}) -> _


    Writes, in order of element, each Servable inside of a Vector of Servables.

    example

    Toolips.@L_strMacro

    Interface

    L_str -> _


    Creates a literal string

    example