diff --git a/.yardoc/checksums b/.yardoc/checksums new file mode 100644 index 0000000..1beb886 --- /dev/null +++ b/.yardoc/checksums @@ -0,0 +1,4 @@ +lib/route.rb 08f479c974b86f57f2a08d702a9a051bbbe8a96f +lib/request.rb 44cbed9368e180dda2c3469fbf11f03e68aa5e19 +lib/response.rb e278bfd636164a3db91be59eabd064f08664a859 +lib/tcp_server.rb 80a60a15e660513a3791c12c7545f84ade839de0 diff --git a/.yardoc/complete b/.yardoc/complete new file mode 100644 index 0000000..e69de29 diff --git a/.yardoc/object_types b/.yardoc/object_types new file mode 100644 index 0000000..0229741 Binary files /dev/null and b/.yardoc/object_types differ diff --git a/.yardoc/objects/root.dat b/.yardoc/objects/root.dat new file mode 100644 index 0000000..492728f Binary files /dev/null and b/.yardoc/objects/root.dat differ diff --git a/.yardoc/proxy_types b/.yardoc/proxy_types new file mode 100644 index 0000000..beefda1 Binary files /dev/null and b/.yardoc/proxy_types differ diff --git a/doc/HTTPServer.html b/doc/HTTPServer.html new file mode 100644 index 0000000..aad5b43 --- /dev/null +++ b/doc/HTTPServer.html @@ -0,0 +1,363 @@ + + + + + + + Class: HTTPServer + + — Documentation by YARD 0.9.34 + + + + + + + + + + + + + + + + + + + +
+ + +

Class: HTTPServer + + + +

+
+ +
+
Inherits:
+
+ Object + +
    +
  • Object
  • + + + +
+ show all + +
+
+ + + + + + + + + + + +
+
Defined in:
+
lib/tcp_server.rb
+
+ +
+ +

Overview

+
+ +

Main class for managing and talking between sub-classes during request-response cycles. Utalizes the request, route and response classes.

+ + +
+
+
+ + +
+ + + + + + + +

+ Instance Method Summary + collapse +

+ + + + +
+

Constructor Details

+ +
+

+ + #initialize(port, router) ⇒ HTTPServer + + + + + +

+
+ +

Initializes the HTTPServer object

+ + +
+
+
+

Parameters:

+
    + +
  • + + port + + + (Int) + + + + — +
    +

    An integer representing the port number for the http server

    +
    + +
  • + +
  • + + router + + + (Router) + + + + — +
    +

    The Router class holding the expected routes for the server

    +
    + +
  • + +
+ + +
+ + + + +
+
+
+
+13
+14
+15
+16
+
+
# File 'lib/tcp_server.rb', line 13
+
+def initialize(port, router)
+    @port = port
+    @router = router
+end
+
+
+ +
+ + +
+

Instance Method Details

+ + +
+

+ + #startObject + + + + + +

+
+ +

Starts the TCP server and begins reading for requests on the designated port. When a request comes in it turns it into a request object using the request class, and sends that to the router. It then sends the matched information to the response class.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
+35
+36
+37
+38
+39
+40
+41
+
+
# File 'lib/tcp_server.rb', line 19
+
+def start
+    server = TCPServer.new(@port)
+    puts "Listening on #{@port}"
+
+    while session = server.accept
+        data = ""
+        while line = session.gets and line !~ /^\s*$/
+            data += line
+        end
+        puts "RECEIVED REQUEST"
+        puts "-" * 40
+        puts data
+        puts "-" * 40 
+
+        request = Request.new(data)
+        pp request
+        
+        routeReturn = @router.match_route(request)
+        
+        response = Response.new(routeReturn)
+        response.print(session)
+    end
+end
+
+
+ +
+ +
+ + + +
+ + \ No newline at end of file diff --git a/doc/Request.html b/doc/Request.html new file mode 100644 index 0000000..e35410e --- /dev/null +++ b/doc/Request.html @@ -0,0 +1,604 @@ + + + + + + + Class: Request + + — Documentation by YARD 0.9.34 + + + + + + + + + + + + + + + + + + + +
+ + +

Class: Request + + + +

+
+ +
+
Inherits:
+
+ Object + +
    +
  • Object
  • + + + +
+ show all + +
+
+ + + + + + + + + + + +
+
Defined in:
+
lib/request.rb
+
+ +
+ +

Overview

+
+ +

Request class used as instance object of an incoming TCP request to manage that request. Splits the request into it’s method, resource, version, headers and params to be read by the router.

+ + +
+
+
+ + +
+ + + +

Instance Attribute Summary collapse

+ + + + + + +

+ Instance Method Summary + collapse +

+ + + + +
+

Constructor Details

+ +
+

+ + #initialize(input) ⇒ Request + + + + + +

+
+ +

Returns a new instance of Request.

+ + +
+
+
+

Parameters:

+
    + +
  • + + input + + + (String) + + + + — +
    +

    the string of the request

    +
    + +
  • + +
+ + +
+ + + + +
+
+
+
+6
+7
+8
+
+
# File 'lib/request.rb', line 6
+
+def initialize(input)
+    variable_definer(input)
+end
+
+
+ +
+ +
+

Instance Attribute Details

+ + + +
+

+ + #headersObject (readonly) + + + + + +

+
+ +

Returns the value of attribute headers.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+3
+4
+5
+
+
# File 'lib/request.rb', line 3
+
+def headers
+  @headers
+end
+
+
+ + + +
+

+ + #methodObject (readonly) + + + + + +

+
+ +

Returns the value of attribute method.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+3
+4
+5
+
+
# File 'lib/request.rb', line 3
+
+def method
+  @method
+end
+
+
+ + + +
+

+ + #paramsObject (readonly) + + + + + +

+
+ +

Returns the value of attribute params.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+3
+4
+5
+
+
# File 'lib/request.rb', line 3
+
+def params
+  @params
+end
+
+
+ + + +
+

+ + #resourceObject (readonly) + + + + + +

+
+ +

Returns the value of attribute resource.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+3
+4
+5
+
+
# File 'lib/request.rb', line 3
+
+def resource
+  @resource
+end
+
+
+ + + +
+

+ + #versionObject (readonly) + + + + + +

+
+ +

Returns the value of attribute version.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+3
+4
+5
+
+
# File 'lib/request.rb', line 3
+
+def version
+  @version
+end
+
+
+ +
+ + +
+ + + +
+ + \ No newline at end of file diff --git a/doc/Response.html b/doc/Response.html new file mode 100644 index 0000000..b9bca0d --- /dev/null +++ b/doc/Response.html @@ -0,0 +1,522 @@ + + + + + + + Class: Response + + — Documentation by YARD 0.9.34 + + + + + + + + + + + + + + + + + + + +
+ + +

Class: Response + + + +

+
+ +
+
Inherits:
+
+ Object + +
    +
  • Object
  • + + + +
+ show all + +
+
+ + + + + + + + + + + +
+
Defined in:
+
lib/response.rb
+
+ +
+ +

Overview

+
+ +

Reponse class used to format and respond to a request. Takes in the touple returned by the route class and returns either the requested method or the file in the requested position (if the match returned a 404 and a file is found in the requested position)

+ + +
+
+
+ + +
+ + + + + + + +

+ Instance Method Summary + collapse +

+ + + + +
+

Constructor Details

+ +
+

+ + #initialize(routeReturn) ⇒ Response + + + + + +

+
+ +

Initialize the response by checking if a response is applicable and what information should be returned

+ + +
+
+
+

Parameters:

+
    + +
  • + + routeReturn + + + (Array) + + + + — +
    +

    A list consisting of the matched request and the status

    +
    + +
  • + +
+ + +
+ + + + +
+
+
+
+7
+8
+9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
+35
+36
+37
+
+
# File 'lib/response.rb', line 7
+
+def initialize(routeReturn)
+    outputContent = {}
+    status = routeReturn[1]
+    if status == 200
+        if routeReturn[0][:block] != nil
+            outputContent[:info] = routeReturn[0][:block].call
+            print("Recieved HTML, enabling as called:\n #{outputContent[:info]}")
+            outputContent[:type] = "text/html"
+            status = 200
+        else
+            outputContent[:info] = nil
+            status = 200
+        end
+    elsif status == 404
+        print("HTML route not found, searching for target file...\n")
+        if File.file?("./public/#{routeReturn[0].resource}")
+            print("Found file: ./public/#{routeReturn[0].resource}\n")
+            outputContent[:info] = File.open("./public#{routeReturn[0].resource}", "rb")
+            if outputContent[:type].to_s.split("/")[0] == "text" 
+                print("Successfully opened file \"./public#{routeReturn[0].resource}\" with contents:\n#{outputContent[:info].read}\n ")
+            end
+            outputContent[:type] = getMime(File.extname("./public/#{routeReturn[0].resource}").to_str)
+            status = 200
+        else
+            print("Could not find file: \"./public/#{routeReturn[0].resource}\"\n")
+            status = 404
+        end
+    end
+    @status = status
+    @outputContent = outputContent
+end
+
+
+ +
+ + +
+

Instance Method Details

+ + +
+

+ + #getMime(extension) ⇒ String + + + + + +

+
+ +

Gets the mime extension for respond file

+ + +
+
+
+

Parameters:

+
    + +
  • + + extension + + + (Str) + + + + — +
    +

    a string containing the extension of the file to find the MIME format for

    +
    + +
  • + +
+ +

Returns:

+
    + +
  • + + + (String) + + + + — +
    +

    the MIME format of the requested extension.

    +
    + +
  • + +
+ +
+ + + + +
+
+
+
+62
+63
+64
+65
+66
+67
+68
+69
+70
+71
+
+
# File 'lib/response.rb', line 62
+
+def getMime(extension)
+    mimes = { ".css" => "text/css", ".html" => "text/html", ".ico" => "image/vnd.microsoft.icon", ".jpg" => "image/jpeg", ".png" => "image/png"}
+    if mimes[extension] != nil
+        print("Found #{mimes[extension]} result for extension #{extension}\n")
+        return mimes[extension]
+    else
+        print("Found no result for extension #{extension}\n")
+        return nil
+    end
+end
+
+
+ +
+
+
+ +

Responds to the request with the information requested

+ + +
+
+
+

Parameters:

+
    + +
  • + + session + + + (TCPsocket) + + + + — +
    +

    A client request through the TCP port awaiting a response

    +
    + +
  • + +
+ + +
+ + + + +
+
+
+
+42
+43
+44
+45
+46
+47
+48
+49
+50
+51
+52
+53
+54
+55
+56
+
+
# File 'lib/response.rb', line 42
+
+def print(session)
+    print("\nStatus: #{@status.to_s}\n")
+    session.print "HTTP/1.1 #{@status}\r\n"
+    if @status != 404
+        session.print "Content-Type: #{@outputContent[:type]}\r\n"
+        print("\nReading content type: #{@outputContent[:type]}\n")
+        print("\nLoaded is of type: #{@outputContent[:info].class}\n")
+        print("\nSize reading: #{File.size(@outputContent[:info])}\n")
+        session.print "Content-Length: #{File.size(@outputContent[:info])}\r\n"
+        session.print "\r\n"
+        printContent = @outputContent[:info].read
+        if printContent; session.print printContent end
+    end
+    session.close
+end
+
+
+ +
+ +
+ + + +
+ + \ No newline at end of file diff --git a/doc/Router.html b/doc/Router.html new file mode 100644 index 0000000..6dd86b4 --- /dev/null +++ b/doc/Router.html @@ -0,0 +1,560 @@ + + + + + + + Class: Router + + — Documentation by YARD 0.9.34 + + + + + + + + + + + + + + + + + + + +
+ + +

Class: Router + + + +

+
+ +
+
Inherits:
+
+ Object + +
    +
  • Object
  • + + + +
+ show all + +
+
+ + + + + + + + + + + +
+
Defined in:
+
lib/route.rb
+
+ +
+ +

Overview

+
+ +

Router class for pairing incoming requests with routes

+ + +
+
+
+ + +
+ + + +

Instance Attribute Summary collapse

+ + + + + + +

+ Instance Method Summary + collapse +

+ + + + +
+

Constructor Details

+ +
+

+ + #initializeRouter + + + + + +

+
+ +

Returns a new instance of Router.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+5
+6
+7
+
+
# File 'lib/route.rb', line 5
+
+def initialize()
+    @routes = []
+end
+
+
+ +
+ +
+

Instance Attribute Details

+ + + +
+

+ + #routesObject (readonly) + + + + + +

+
+ +

Returns the value of attribute routes.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+4
+5
+6
+
+
# File 'lib/route.rb', line 4
+
+def routes
+  @routes
+end
+
+
+ +
+ + +
+

Instance Method Details

+ + +
+

+ + #add_route(method, input, &block) ⇒ Object + + + + + +

+
+ +

Method for adding a route to the router. Incoming requests will be checked against these routes to see if the incoming requests has a valid target.

+ + +
+
+
+

Parameters:

+
    + +
  • + + method + + + (String) + + + + — +
    +

    A string with the method for the request

    +
    + +
  • + +
  • + + input + + + (String) + + + + — +
    +

    A string for the input to match the request with

    +
    + +
  • + +
  • + + &block + + + (Block) + + + + — +
    +

    The block to execute and respond with if the route is matched.

    +
    + +
  • + +
+ + +
+ + + + +
+
+
+
+14
+15
+16
+17
+18
+
+
# File 'lib/route.rb', line 14
+
+def add_route(method, input, &block)
+    routeHash = {method: method, resource: input, block: block}
+    @routes << routeHash
+    p "added successfully, @routes are: #{@routes}"
+end
+
+
+ +
+

+ + #match_route(request) ⇒ Array + + + + + +

+
+ +

Method for matching the incoming requests with the expected routes. Returns a touple with either the matched object and an int 200 representing status or the request and an int 404 representing status

+ + +
+
+
+

Parameters:

+
    + +
  • + + request + + + (Request) + + + + — +
    +

    the Request class to find a match for

    +
    + +
  • + +
+ +

Returns:

+
    + +
  • + + + (Array) + + + + — +
    +

    the array consisting of the matched method or the request and the status of the match.

    +
    + +
  • + +
+ +
+ + + + +
+
+
+
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
+35
+36
+37
+38
+39
+40
+41
+42
+43
+
+
# File 'lib/route.rb', line 24
+
+def match_route(request)
+
+    match = @routes.find {|route| (route[:method] == request.method) && (request.resource.match?(route[:resource]))}
+
+    if match != nil
+        print("\nMatch: ", match, "\n")
+        returner = [match, 200]
+        return returner
+    else
+        if request.resource.match?(@routes[0][:resource]) != true #If the requested resource did not match the expected resource for that method
+            p "failed to find: #{request.resource} resource.\nExpected: #{String(@routes[0][:resource])} resource"
+        elsif @routes[0][:method] != request.method #If the current method did not match the expected method for that resource
+            p "failed to find #{request.method} method.\nExpected: #{@routes[0][:method]} method"
+        else
+            p "Failed to match, got no reason, just kinda didn't feel like it"
+        end
+        returner = [request, 404]
+        return returner
+    end
+end
+
+
+ +
+ +
+ + + +
+ + \ No newline at end of file diff --git a/doc/_index.html b/doc/_index.html new file mode 100644 index 0000000..ff39f71 --- /dev/null +++ b/doc/_index.html @@ -0,0 +1,121 @@ + + + + + + + Documentation by YARD 0.9.34 + + + + + + + + + + + + + + + + + + + +
+ + +

Documentation by YARD 0.9.34

+
+

Alphabetic Index

+ +
+

Namespace Listing A-Z

+ + + + + + + + +
+ + + + + + + +
+ +
+ +
+ + + +
+ + \ No newline at end of file diff --git a/doc/class_list.html b/doc/class_list.html new file mode 100644 index 0000000..c27ecc0 --- /dev/null +++ b/doc/class_list.html @@ -0,0 +1,51 @@ + + + + + + + + + + + + + + + + + + Class List + + + +
+
+

Class List

+ + + +
+ + +
+ + diff --git a/doc/css/common.css b/doc/css/common.css new file mode 100644 index 0000000..cf25c45 --- /dev/null +++ b/doc/css/common.css @@ -0,0 +1 @@ +/* Override this file with custom rules */ \ No newline at end of file diff --git a/doc/css/full_list.css b/doc/css/full_list.css new file mode 100644 index 0000000..fa35982 --- /dev/null +++ b/doc/css/full_list.css @@ -0,0 +1,58 @@ +body { + margin: 0; + font-family: "Lucida Sans", "Lucida Grande", Verdana, Arial, sans-serif; + font-size: 13px; + height: 101%; + overflow-x: hidden; + background: #fafafa; +} + +h1 { padding: 12px 10px; padding-bottom: 0; margin: 0; font-size: 1.4em; } +.clear { clear: both; } +.fixed_header { position: fixed; background: #fff; width: 100%; padding-bottom: 10px; margin-top: 0; top: 0; z-index: 9999; height: 70px; } +#search { position: absolute; right: 5px; top: 9px; padding-left: 24px; } +#content.insearch #search, #content.insearch #noresults { background: url(data:image/gif;base64,R0lGODlhEAAQAPYAAP///wAAAPr6+pKSkoiIiO7u7sjIyNjY2J6engAAAI6OjsbGxjIyMlJSUuzs7KamppSUlPLy8oKCghwcHLKysqSkpJqamvT09Pj4+KioqM7OzkRERAwMDGBgYN7e3ujo6Ly8vCoqKjY2NkZGRtTU1MTExDw8PE5OTj4+PkhISNDQ0MrKylpaWrS0tOrq6nBwcKysrLi4uLq6ul5eXlxcXGJiYoaGhuDg4H5+fvz8/KKiohgYGCwsLFZWVgQEBFBQUMzMzDg4OFhYWBoaGvDw8NbW1pycnOLi4ubm5kBAQKqqqiQkJCAgIK6urnJyckpKSjQ0NGpqatLS0sDAwCYmJnx8fEJCQlRUVAoKCggICLCwsOTk5ExMTPb29ra2tmZmZmhoaNzc3KCgoBISEiIiIgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH/C05FVFNDQVBFMi4wAwEAAAAh/hpDcmVhdGVkIHdpdGggYWpheGxvYWQuaW5mbwAh+QQJCAAAACwAAAAAEAAQAAAHaIAAgoMgIiYlg4kACxIaACEJCSiKggYMCRselwkpghGJBJEcFgsjJyoAGBmfggcNEx0flBiKDhQFlIoCCA+5lAORFb4AJIihCRbDxQAFChAXw9HSqb60iREZ1omqrIPdJCTe0SWI09GBACH5BAkIAAAALAAAAAAQABAAAAdrgACCgwc0NTeDiYozCQkvOTo9GTmDKy8aFy+NOBA7CTswgywJDTIuEjYFIY0JNYMtKTEFiRU8Pjwygy4ws4owPyCKwsMAJSTEgiQlgsbIAMrO0dKDGMTViREZ14kYGRGK38nHguHEJcvTyIEAIfkECQgAAAAsAAAAABAAEAAAB2iAAIKDAggPg4iJAAMJCRUAJRIqiRGCBI0WQEEJJkWDERkYAAUKEBc4Po1GiKKJHkJDNEeKig4URLS0ICImJZAkuQAhjSi/wQyNKcGDCyMnk8u5rYrTgqDVghgZlYjcACTA1sslvtHRgQAh+QQJCAAAACwAAAAAEAAQAAAHZ4AAgoOEhYaCJSWHgxGDJCQARAtOUoQRGRiFD0kJUYWZhUhKT1OLhR8wBaaFBzQ1NwAlkIszCQkvsbOHL7Y4q4IuEjaqq0ZQD5+GEEsJTDCMmIUhtgk1lo6QFUwJVDKLiYJNUd6/hoEAIfkECQgAAAAsAAAAABAAEAAAB2iAAIKDhIWGgiUlh4MRgyQkjIURGRiGGBmNhJWHm4uen4ICCA+IkIsDCQkVACWmhwSpFqAABQoQF6ALTkWFnYMrVlhWvIKTlSAiJiVVPqlGhJkhqShHV1lCW4cMqSkAR1ofiwsjJyqGgQAh+QQJCAAAACwAAAAAEAAQAAAHZ4AAgoOEhYaCJSWHgxGDJCSMhREZGIYYGY2ElYebi56fhyWQniSKAKKfpaCLFlAPhl0gXYNGEwkhGYREUywag1wJwSkHNDU3D0kJYIMZQwk8MjPBLx9eXwuETVEyAC/BOKsuEjYFhoEAIfkECQgAAAAsAAAAABAAEAAAB2eAAIKDhIWGgiUlh4MRgyQkjIURGRiGGBmNhJWHm4ueICImip6CIQkJKJ4kigynKaqKCyMnKqSEK05StgAGQRxPYZaENqccFgIID4KXmQBhXFkzDgOnFYLNgltaSAAEpxa7BQoQF4aBACH5BAkIAAAALAAAAAAQABAAAAdogACCg4SFggJiPUqCJSWGgkZjCUwZACQkgxGEXAmdT4UYGZqCGWQ+IjKGGIUwPzGPhAc0NTewhDOdL7Ykji+dOLuOLhI2BbaFETICx4MlQitdqoUsCQ2vhKGjglNfU0SWmILaj43M5oEAOwAAAAAAAAAAAA==) no-repeat center left; } +#full_list { padding: 0; list-style: none; margin-left: 0; margin-top: 80px; font-size: 1.1em; } +#full_list ul { padding: 0; } +#full_list li { padding: 0; margin: 0; list-style: none; } +#full_list li .item { padding: 5px 5px 5px 12px; } +#noresults { padding: 7px 12px; background: #fff; } +#content.insearch #noresults { margin-left: 7px; } +li.collapsed ul { display: none; } +li a.toggle { cursor: default; position: relative; left: -5px; top: 4px; text-indent: -999px; width: 10px; height: 9px; margin-left: -10px; display: block; float: left; background: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAASCAYAAABb0P4QAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAAK8AAACvABQqw0mAAAABx0RVh0U29mdHdhcmUAQWRvYmUgRmlyZXdvcmtzIENTM5jWRgMAAAAVdEVYdENyZWF0aW9uIFRpbWUAMy8xNC8wOeNZPpQAAAE2SURBVDiNrZTBccIwEEXfelIAHUA6CZ24BGaWO+FuzZAK4k6gg5QAdGAq+Bxs2Yqx7BzyL7Llp/VfzZeQhCTc/ezuGzKKnKSzpCxXJM8fwNXda3df5RZETlIt6YUzSQDs93sl8w3wBZxCCE10GM1OcWbWjB2mWgEH4Mfdyxm3PSepBHibgQE2wLe7r4HjEidpnXMYdQPKEMJcsZ4zs2POYQOcaPfwMVOo58zsAdMt18BuoVDPxUJRacELbXv3hUIX2vYmOUvi8C8ydz/ThjXrqKqqLbDIAdsCKBd+Wo7GWa7o9qzOQHVVVXeAbs+yHHCH4aTsaCOQqunmUy1yBUAXkdMIfMlgF5EXLo2OpV/c/Up7jG4hhHcYLgWzAZXUc2b2ixsfvc/RmNNfOXD3Q/oeL9axJE1yT9IOoUu6MGUkAAAAAElFTkSuQmCC) no-repeat bottom left; } +li.collapsed a.toggle { opacity: 0.5; cursor: default; background-position: top left; } +li { color: #888; cursor: pointer; } +li.deprecated { text-decoration: line-through; font-style: italic; } +li.odd { background: #f0f0f0; } +li.even { background: #fafafa; } +.item:hover { background: #ddd; } +li small:before { content: "("; } +li small:after { content: ")"; } +li small.search_info { display: none; } +a, a:visited { text-decoration: none; color: #05a; } +li.clicked > .item { background: #05a; color: #ccc; } +li.clicked > .item a, li.clicked > .item a:visited { color: #eee; } +li.clicked > .item a.toggle { opacity: 0.5; background-position: bottom right; } +li.collapsed.clicked a.toggle { background-position: top right; } +#search input { border: 1px solid #bbb; border-radius: 3px; } +#full_list_nav { margin-left: 10px; font-size: 0.9em; display: block; color: #aaa; } +#full_list_nav a, #nav a:visited { color: #358; } +#full_list_nav a:hover { background: transparent; color: #5af; } +#full_list_nav span:after { content: ' | '; } +#full_list_nav span:last-child:after { content: ''; } + +#content h1 { margin-top: 0; } +li { white-space: nowrap; cursor: normal; } +li small { display: block; font-size: 0.8em; } +li small:before { content: ""; } +li small:after { content: ""; } +li small.search_info { display: none; } +#search { width: 170px; position: static; margin: 3px; margin-left: 10px; font-size: 0.9em; color: #888; padding-left: 0; padding-right: 24px; } +#content.insearch #search { background-position: center right; } +#search input { width: 110px; } + +#full_list.insearch ul { display: block; } +#full_list.insearch .item { display: none; } +#full_list.insearch .found { display: block; padding-left: 11px !important; } +#full_list.insearch li a.toggle { display: none; } +#full_list.insearch li small.search_info { display: block; } diff --git a/doc/css/style.css b/doc/css/style.css new file mode 100644 index 0000000..eb0dbc8 --- /dev/null +++ b/doc/css/style.css @@ -0,0 +1,497 @@ +html { + width: 100%; + height: 100%; +} +body { + font-family: "Lucida Sans", "Lucida Grande", Verdana, Arial, sans-serif; + font-size: 13px; + width: 100%; + margin: 0; + padding: 0; + display: flex; + display: -webkit-flex; + display: -ms-flexbox; +} + +#nav { + position: relative; + width: 100%; + height: 100%; + border: 0; + border-right: 1px dotted #eee; + overflow: auto; +} +.nav_wrap { + margin: 0; + padding: 0; + width: 20%; + height: 100%; + position: relative; + display: flex; + display: -webkit-flex; + display: -ms-flexbox; + flex-shrink: 0; + -webkit-flex-shrink: 0; + -ms-flex: 1 0; +} +#resizer { + position: absolute; + right: -5px; + top: 0; + width: 10px; + height: 100%; + cursor: col-resize; + z-index: 9999; +} +#main { + flex: 5 1; + -webkit-flex: 5 1; + -ms-flex: 5 1; + outline: none; + position: relative; + background: #fff; + padding: 1.2em; + padding-top: 0.2em; + box-sizing: border-box; +} + +@media (max-width: 920px) { + .nav_wrap { width: 100%; top: 0; right: 0; overflow: visible; position: absolute; } + #resizer { display: none; } + #nav { + z-index: 9999; + background: #fff; + display: none; + position: absolute; + top: 40px; + right: 12px; + width: 500px; + max-width: 80%; + height: 80%; + overflow-y: scroll; + border: 1px solid #999; + border-collapse: collapse; + box-shadow: -7px 5px 25px #aaa; + border-radius: 2px; + } +} + +@media (min-width: 920px) { + body { height: 100%; overflow: hidden; } + #main { height: 100%; overflow: auto; } + #search { display: none; } +} + +#main img { max-width: 100%; } +h1 { font-size: 25px; margin: 1em 0 0.5em; padding-top: 4px; border-top: 1px dotted #d5d5d5; } +h1.noborder { border-top: 0px; margin-top: 0; padding-top: 4px; } +h1.title { margin-bottom: 10px; } +h1.alphaindex { margin-top: 0; font-size: 22px; } +h2 { + padding: 0; + padding-bottom: 3px; + border-bottom: 1px #aaa solid; + font-size: 1.4em; + margin: 1.8em 0 0.5em; + position: relative; +} +h2 small { font-weight: normal; font-size: 0.7em; display: inline; position: absolute; right: 0; } +h2 small a { + display: block; + height: 20px; + border: 1px solid #aaa; + border-bottom: 0; + border-top-left-radius: 5px; + background: #f8f8f8; + position: relative; + padding: 2px 7px; +} +.clear { clear: both; } +.inline { display: inline; } +.inline p:first-child { display: inline; } +.docstring, .tags, #filecontents { font-size: 15px; line-height: 1.5145em; } +.docstring p > code, .docstring p > tt, .tags p > code, .tags p > tt { + color: #c7254e; background: #f9f2f4; padding: 2px 4px; font-size: 1em; + border-radius: 4px; +} +.docstring h1, .docstring h2, .docstring h3, .docstring h4 { padding: 0; border: 0; border-bottom: 1px dotted #bbb; } +.docstring h1 { font-size: 1.2em; } +.docstring h2 { font-size: 1.1em; } +.docstring h3, .docstring h4 { font-size: 1em; border-bottom: 0; padding-top: 10px; } +.summary_desc .object_link a, .docstring .object_link a { + font-family: monospace; font-size: 1.05em; + color: #05a; background: #EDF4FA; padding: 2px 4px; font-size: 1em; + border-radius: 4px; +} +.rdoc-term { padding-right: 25px; font-weight: bold; } +.rdoc-list p { margin: 0; padding: 0; margin-bottom: 4px; } +.summary_desc pre.code .object_link a, .docstring pre.code .object_link a { + padding: 0px; background: inherit; color: inherit; border-radius: inherit; +} + +/* style for */ +#filecontents table, .docstring table { border-collapse: collapse; } +#filecontents table th, #filecontents table td, +.docstring table th, .docstring table td { border: 1px solid #ccc; padding: 8px; padding-right: 17px; } +#filecontents table tr:nth-child(odd), +.docstring table tr:nth-child(odd) { background: #eee; } +#filecontents table tr:nth-child(even), +.docstring table tr:nth-child(even) { background: #fff; } +#filecontents table th, .docstring table th { background: #fff; } + +/* style for
+ + + +
+ + + + + + + +
+ + + + + + + + + + \ No newline at end of file diff --git a/doc/js/app.js b/doc/js/app.js new file mode 100644 index 0000000..8d067fe --- /dev/null +++ b/doc/js/app.js @@ -0,0 +1,314 @@ +(function() { + +var localStorage = {}, sessionStorage = {}; +try { localStorage = window.localStorage; } catch (e) { } +try { sessionStorage = window.sessionStorage; } catch (e) { } + +function createSourceLinks() { + $('.method_details_list .source_code'). + before("[View source]"); + $('.toggleSource').toggle(function() { + $(this).parent().nextAll('.source_code').slideDown(100); + $(this).text("Hide source"); + }, + function() { + $(this).parent().nextAll('.source_code').slideUp(100); + $(this).text("View source"); + }); +} + +function createDefineLinks() { + var tHeight = 0; + $('.defines').after(" more..."); + $('.toggleDefines').toggle(function() { + tHeight = $(this).parent().prev().height(); + $(this).prev().css('display', 'inline'); + $(this).parent().prev().height($(this).parent().height()); + $(this).text("(less)"); + }, + function() { + $(this).prev().hide(); + $(this).parent().prev().height(tHeight); + $(this).text("more..."); + }); +} + +function createFullTreeLinks() { + var tHeight = 0; + $('.inheritanceTree').toggle(function() { + tHeight = $(this).parent().prev().height(); + $(this).parent().toggleClass('showAll'); + $(this).text("(hide)"); + $(this).parent().prev().height($(this).parent().height()); + }, + function() { + $(this).parent().toggleClass('showAll'); + $(this).parent().prev().height(tHeight); + $(this).text("show all"); + }); +} + +function searchFrameButtons() { + $('.full_list_link').click(function() { + toggleSearchFrame(this, $(this).attr('href')); + return false; + }); + window.addEventListener('message', function(e) { + if (e.data === 'navEscape') { + $('#nav').slideUp(100); + $('#search a').removeClass('active inactive'); + $(window).focus(); + } + }); + + $(window).resize(function() { + if ($('#search:visible').length === 0) { + $('#nav').removeAttr('style'); + $('#search a').removeClass('active inactive'); + $(window).focus(); + } + }); +} + +function toggleSearchFrame(id, link) { + var frame = $('#nav'); + $('#search a').removeClass('active').addClass('inactive'); + if (frame.attr('src') === link && frame.css('display') !== "none") { + frame.slideUp(100); + $('#search a').removeClass('active inactive'); + } + else { + $(id).addClass('active').removeClass('inactive'); + if (frame.attr('src') !== link) frame.attr('src', link); + frame.slideDown(100); + } +} + +function linkSummaries() { + $('.summary_signature').click(function() { + document.location = $(this).find('a').attr('href'); + }); +} + +function summaryToggle() { + $('.summary_toggle').click(function(e) { + e.preventDefault(); + localStorage.summaryCollapsed = $(this).text(); + $('.summary_toggle').each(function() { + $(this).text($(this).text() == "collapse" ? "expand" : "collapse"); + var next = $(this).parent().parent().nextAll('ul.summary').first(); + if (next.hasClass('compact')) { + next.toggle(); + next.nextAll('ul.summary').first().toggle(); + } + else if (next.hasClass('summary')) { + var list = $('