This repository has been archived by the owner on Dec 28, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
marrs/slite
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
THIS PROJECT HAS BEEN ARCHIVED. IT REMAINS AS A HISTORICAL ARTIFACT OF LITTLE SIGNIFICANCE. Slite ===== A PAC framework written in Javascript. WARNING This project is a work in progress. Features documented here may not work, or even exist. They are here for the author's benefit only. At the time of writing this framework is capable of serving static content. It may not serve it very well! FEATURES * Caches any data retrieved to improve subsequent look-up. * Uses a RESTful interface internally as well as externally. * Non-blocking dependency resolution. DEPENDENCIES * Node.js HOW IT WORKS Every reusable element of a page (called a "component" in Slite, or a "partial" in other frameworks) implements a full PAC model. Components can be made up of smaller components (compound components) by calling them through their controllers. In this sense, one can think of the final web page as being a component: it is fundamentally no different from any other component. --Model-- Slite expects to be provided with a data model. It does not, and will not ever, provide any tools for retrieving data from a database. Slite sticks to the UNIX principle of doing one job and doing it well. If you wish to use an ORM, you will have to provide your own. --View-- Multiple views can provide different data formats for a component (e.g. html, xml, json). Views should only ever contain component templates and never any logic or data. (They may contain helpers for looping etc.) Views are mapped directly to controller actions. For example, an HTML template serving the shop.index action will be found in the shop/index.html file. A JSON template would be in shop/index.json, and so on. --Controller-- * binds data to a template and returns result. * RESTful in nature. * can make requests of other controllers. * option to overload with other methods may be added later if it can be done safely. Controller functions must be provided for the HTTP methods supported by Slite (so far this includes GET, and only GET). See the demo app controllers for an example of how to create a controller. Each function is used as the constructor for an object at runtime. This means that the `this` keyword is available and required for use. this.get: Used to fetch nested components. * 1st arg: an array of dependencies (identified by path) * 2nd arg: a callback containing functions for resolving those paths. These functions take the following arguments: * 1st arg: the name of the property in the view you wish to attach the payload to. * 2nd arg: an object that can override the nested component's view Examples: (SUBJECT TO CHANGE) ```javascript get(['/path/to/resource'], function(a) { // Bind the payload straight to this property. a('placeholderName'); // As above, but override nested component's view.foo // with 'bar'. }); ``` The original version had options for fetching the data in different formats, and also an option for choosing different templates. It would be nice to get this back into the new code. It would also be nice to be able to manipulate the payload before binding it. Post: * 1st arg: a request object (containing request method, data, etc). * 2nd arg: callback function(s) to execute on response. or... * 1st arg: a URL path for the component being requested. * 2nd arg: object containing data to post * 3rd arg: callback function(s) to execute on response. Examples: (SUBJECT TO CHANGE) post('/path/to/component', data_object, callback); post(request_object, callback); post(request_object, { success: function(response) { /* success callback */}, failure: function(response) { /* failure callback */}, }); Slite posts should be manually routed to the originating component for handling. If there are multiple components on a page requiring queries, these can be namespaced using the '?foo[bar]=baz' notation.
About
Simple light web framework (aren't they all?)
Resources
Stars
Watchers
Forks
Releases
No releases published
Packages 0
No packages published