#!/usr/bin/env lua package.path = package.path .. ";/Users/rszwarc/Developer/Lua/LU/?.lua" package.path = package.path .. ";/Users/rszwarc/Developer/Lua/MIME/?.lua" package.path = package.path .. ";/Users/rszwarc/Developer/Lua/LU/Library/Lua/?.lua" package.cpath = package.cpath .. ";/Users/rszwarc/Developer/Lua/LU/Library/Modules/?.so" local LULog = require( "LULog" ) local LUList = require( "LUList" ) local LULocale = require( "LULocale" ) local LUMap = require( "LUMap" ) local LUURI = require( "LUURI" ) local LWApplication = require( "LWApplication" ) local LWBrowserService = require( "LWBrowserService" ) local LWDAVService = require( "LWDAVService" ) local LWFileService = require( "LWFileService" ) local LWDirectoryService = require( "LWDirectoryService" ) local LWInfoService = require( "LWInfoService" ) local LWImage = require( "LWImage" ) local LWLink = require( "LWLink" ) local LWString = require( "LWString" ) local LWDigestAuthentication = require( "LWDigestAuthentication" ) local TestService = require( "TestService" ) local HelloService = require( "HelloService" ) local Web = require( "Web" ) LULocale:default() local anApplication = LWApplication( 1080 ) local anAuthenticator = nil -- LWDigestAuthentication() local aService = LWDAVService( "/dav/", "/Volumes/Brooklyn/Users/rszwarc/Downloads", anAuthenticator ) -- local aService = LWFileService:new( "/file/", "/Volumes/Brooklyn/Users/rszwarc/Downloads" ) -- local aService = LWDirectoryService:new( "/", "/Volumes/Brooklyn/Users/rszwarc/Downloads", anAuthenticator ) anApplication:registerService( aService ) anApplication:registerService( LWInfoService( "/info/" ) ) anApplication:registerService( TestService( "/test/" ) ) anApplication:registerService( HelloService( "/hello/" ) ) aService = LWBrowserService( "/browser/", "/Volumes/Brooklyn/Users/rszwarc/Downloads", anAuthenticator ) anApplication:registerService( aService ) aService = Web( "/web/", { "(%w*)", function( aName ) print( "Hello! ", aName ) end } ) anApplication:registerService( aService ) LULog:debug( anApplication ) LULog:debug( anApplication:services() ) -- LULog:setVerbosity( LULog.Warning ) anApplication:start() local someBindings = LUMap() someBindings:put( "object", anApplication ) someBindings:put( "title", "Application" ) someBindings:put( "backgroundColor", "black" ) someBindings:put( "color", "white" ) someBindings:put( "fontFamily", "fantasy" ) someBindings:put( "fontSize", "xx-small" ) someBindings:put( "fontStyle", "italic" ) someBindings:put( "isAbbreviation", true ) someBindings:put( "isSmall", true ) someBindings:put( "isTeletype", true ) local aComponent = LWString( nil, nil, someBindings ) LULog:debug( LWString:styles() ) LULog:debug( LWString:tags() ) print( aComponent ) someBindings = LUMap() someBindings:put( "value", "/file/image.png" ) someBindings:put( "height", 12 ) someBindings:put( "width", 12 ) aComponent = LWImage( nil, nil, someBindings ) print( aComponent ) someBindings = LUMap() someBindings:put( "object", anApplication ) someBindings:put( "value", "/" ) someBindings:put( "content", aComponent ) someBindings:put( "title", "Application" ) aComponent = LWLink( nil, nil, someBindings ) print( aComponent ) local anURI = LUURI( "https://user:password@www.example.com:1080/cgilua/index.lua?a=2#there" ) -- local anURI = LUURI( "/cgilua/index.lua?a=2#there" ) print( "scheme", anURI:scheme() ) print( "authority", anURI:authority() ) print( "path", anURI:path() ) print( "pathComponents", anURI:pathComponents() ) print( "parameter", anURI:parameter() ) print( "query", anURI:query() ) print( "queries", anURI:queries() ) print( "fragment", anURI:fragment() ) print( "userInfo", anURI:userInfo() ) print( "host", anURI:host() ) print( "port", anURI:port() ) print( "anURI", anURI ) local aParameter = "name=al&query=a%2Bb+%3D+c&q=yes+or+no" local someParameters = LUURI:componentsWithParameter( aParameter ) local someComponents = LUList( { "path", "to", "somewhere", "/~@home/" } ) print( someParameters ) print( LUURI:parameterWithComponents( someParameters ) ) print( LUURI:componentsWithParameter( LUURI:parameterWithComponents( someParameters ) ) ) print( LUURI:pathWithComponents( someComponents ) ) print( LUURI:componentsWithPath( LUURI:pathWithComponents( someComponents ) ) ) print( LUURI:marks() ) someComponents = LUMap() someComponents:put( "scheme", "https" ) someComponents:put( "user", LUURI:encode( "@user@" ) ) someComponents:put( "password", LUURI:encode( ": password :" ) ) someComponents:put( "host", "localhost" ) someComponents:put( "port", 1080 ) someComponents:put( "path", LUURI:pathWithComponents( LUList( { "+a+", "/path/", "to", "no", "where" } ), true, true ) ) someComponents:put( "parameter", LUURI:parameterWithComponents( LUMap( { parameter = "&value" } ) ) ) someComponents:put( "query", LUURI:parameterWithComponents( LUMap( { query = " question" } ) ) ) someComponents:put( "fragment", "fragment" ) print( LUURI( nil, someComponents ) ) print( LUURI:encode( "-" ) ) print( LUURI:encodePathComponent( ";" ) )