Spec: Question Component

The goal of this component is to encapsulate all functionality, schema, views, stylesheets, and anything else into a single directory. I'm not sure how to tie it all together.

The pieces of THIS component are:

  • Views
    • Page (view the question & all of it's answers)
    • Compose (Create/Edit a question)
    • List (To show multiple questions on an 'Office' or 'Candi' page)
      • or does this go in Office?
    • ListItem (that which is shown in the list)
  • RDBModel
  • Schema (defined by Views/Compose)
  • Routes
  • Backed-up-db (would this go in the component?)
  • PHP helper code, as needed

A simple version would have directories:

  • view
  • class

The routes would be set via the public-dir. The submit script would become '$this->component('Question')->submit($_POST);`

So then to simplify that...
I create a file named Question.component in the public dir (or I could make it a directory??)
Then the routing (when preparing a file map) will load the default Component class (passing the name of the component). This component class will then provide the routes... thus the whole component can be delivered.

  1. How do I tell Liaison that I have a component to load?
    Place the component into the components directory.
  2. How do I tell Liaison to deliver the Compose view at /question/(question-slug:question-id)?/(\?office_id=office-id)?
  3. How do I tell Liaison (& other parts of the component) that the submit-url is /question/submit/?
  4. How do I specify a base-url for the compoment?
    a) Inside the component:
    b) Inside the app:
    c) Outside of Liaison:
  5. If I provide Views (& no routes), how can Liaison turn them into routes?

/*

  • Special Characters: (char in file path is a charB in url)
  •  -  FILE_CHAR     URL_CHAR        USE  
    
  •  -       .       /  
    
  •  -       @                       @POST, @GET... specify valid request types  
    
  •  -       []                      OPTIONAL url paramater. EACH [\_a-zA-Z]+ becomes same-name PHP variable. [^\_a-zA-Z]+ uses standard character-substitution (like `.` replaced with `/`)  
    
  •  -       ()                      REQUIRED url paramater. Otherwise SAME AS `[]`  
    

*/

/*

Example url: /city-council/mayor/  
  file path: @GET(office.position)  
Results in PHP variable:  
    a)  $office = city-council   && $position = mayor  
    b) OR $officePosition = city-council/mayor  

*/

Routing

Routing can be performed in 1 of... maybe 4 ways
- Public/ - Place files in the public directory with the naming convention below
- Route/ - Every php file will be included & $route object can be called to create routes
- Task/ - A task can be registered to run & tasks can basically do anything
- /init.php - init.php is included every time a component is loaded & can do anything
- /init-once.php is included the FIRST time the component is loaded on a request... and can do anything
- Lia/Component.php - The optional Component class can override the default Component class & use overridden methods to do certain things, as the Component loading process specifies

All routing will use the following naming conventions. Note that .item is a feature I'm removing, in favor of these.
- @METHOD specifies the method(s) to respond to. Such as @POST@GET.
- If none is specified, Only GET requests are allowed
- This MUST be at the beginning of the file name
- The method list is terminated with a .
- $paramater - paramater (in the file name) must match REGEX [a-zA-Z0-9\_]+\#?.
- Any character NOT matching this terminates the dynamic portion of the url & is a literal character
- # terminates the param name but IS NOT a literal character. You can subsequently add another # after the terminating # to have a literal #
- Ex: file $pet1##$pet2 responds to url /cat#dog/
- $&paramater declares an optional paramater.
- . declares a / in the url
- .. or literal.$&optional.php (where the optional param is not present) will be handled as a single ....
aka... there will never be double slash (//) in a url, and it doesn't matter how many dots (.) are adjacent
- How do I do a literal . in the url? Or a literal $? or literal &
- V1: No . in urls. No $ in urls
- V2:
- Maybe &.?
- and &$ ?
- and && ?