webmcp
view framework/env/__init.lua @ 212:47ebf4213716
Storage of Moonbridge's HTTP request and request handler options in request environment
| author | jbe | 
|---|---|
| date | Sat Jan 10 00:50:44 2015 +0100 (2015-01-10) | 
| parents | 77c4774e8342 | 
| children | bf690b4be420 | 
 line source
     1 -- string localization function
     2 function _(text, replacements)
     3   local text = locale._get_translation_table()[text] or text
     4   if replacements then
     5     return (
     6       string.gsub(
     7         text,
     8         "#{(.-)}",
     9         function (placeholder)
    10           return replacements[placeholder]
    11         end
    12       )
    13     )
    14   else
    15     return text
    16   end
    17 end
    19 --[[--
    20 cloned_table =  -- newly generated table
    21 table.new(
    22   table_or_nil  -- keys of a given table will be copied to the new table
    23 )
    25 If a table is given, then a cloned table is returned.
    26 If nil is given, then a new empty table is returned.
    28 --]]--
    29 function table.new(tbl)
    30   new_tbl = {}
    31   if tbl then
    32     for key, value in pairs(tbl) do
    33       new_tbl[key] = value
    34     end
    35   end
    36   return new_tbl
    37 end
    38 --//--
    40 -- load libraries
    41 extos       = require 'extos'
    42 nihil       = require 'nihil'
    43 multirand   = require 'multirand'
    44 mondelefant = require 'mondelefant'
    45 mondelefant.connection_prototype.error_objects = true
    46 atom        = require 'atom'
    47 json        = require 'json'
    48 require 'mondelefant_atom_connector'
    50 --[[--
    51 app  -- table to store an application state
    53 'app' is a global table for storing any application state data
    54 --]]--
    55 app = {}
    56 --//--
    58 --[[--
    59 config  -- table to store application configuration
    61 'config' is a global table, which can be modified by a config file of an application to modify the behaviour of that application.
    62 --]]--
    63 config = {}
    64 --//--
