REST API

Rest API

  • server/tests/*.http

  • App/skelton/page

    this book/page is an empty but it loads the server in editor.index

    function M:didShow(UI)
     ...
        elseif httpServerOn then
          --------- pegasus init with  --------
            require("server.index").run{
              selectors = selectors,
              UI = UI,
              bookTable = bookTable,
              pageTable = pageTable,
              layerTable = layerTable
            }
          end
    ...
  • App/Transition2/page

    this is a page without a kwik index model for testing composer.gotoScene

  • App/bookFree/page1

    this is a kwip page. It has the index model. the page is loaded with app.showView()

    kwik scenes are attached with model from App/bookX/pageX/index.lua and

    local sceneName = ...
    --
    local scene = require('controller.scene').new(sceneName, {
        name = "page1",
        components = {
          layers = {
                {  bg={
                                  } },
                {  gotoBtn={ --class={"animation"}
                                  } },
                {  title={ class={"linear"} } },
          },
          audios = {},
          groups = {},
          timers = {},
          variables = {},
          page = { }
        },
        commands = { "eventOne", "eventTwo", "act01" },
        onInit = function(scene) print("onInit") end
    })
    --
    return scene

    the index.lua is loaded with app:showView()

    function app:showView(viewName, _options)
        self.currentViewName = viewName
        local scene = self.context.Router[viewName]
        if scene == ni then
          print("ERROR showView ", viewName )
          return
        end
        local options = _options or {}
        options.params = options.params or {}
        scene.UI.page = scene.model.name
        options.params.sceneProps = {app =scene.app, classType = scene.classType, UI = scene.UI, model=scene.model, getCommands = scene.getCommands}
        composer.gotoScene("App."..self.props.appName.."."..viewName, options)
    end

doGet/doPost are handled with server/harness.lua, that can access UI table

function M:init(path, params)
	projRoot = path
  self.selectors = params.selectors
  self.UI        = params.UI
  self.bookTable = params.bookTable
  self.pageTable = params.pageTable
  self.layerTable = params.layerTable

end

function M:dispatchEevnt(eventName, params)
    self.UI.scene.app:dispatchEvent {
      name = eventName, -- "editor.selector.selectApp",
      UI = self.UI,
      params = params
    }
  -- selectApp
  --   returns books
  --
end

Transition2.page

App/Transition2 is a normal page of Solar2D composer. It does not have a model of index.lua. We coulld load Transition2.page with composer.gotoScene but this way does not work with kwik model with compoennts/commands.

So let’s define I/F.

httpYac

### for composer.gotoScene
GET /Transition2/page

### selectLayer
GET /Transition2/page/character

###
POST /Transition2/page/character/transition2.to

If index.lua is not found, it is a noraml composer page, and the following I/F are used for doGet and doPost

page.lua

function scene:getLayer(layerName)

function scene:getFunc(funcName)