From a00aa5957baacd62f148649946feef75d2a8d388 Mon Sep 17 00:00:00 2001 From: Sharaf Zaman Date: Wed, 30 Jan 2019 03:40:11 +0530 Subject: [PATCH] Migration to lighttouch app --- .gitignore | 1 + Readme.md | 65 +++++++++++++++++++ .../3825ab63-c8c0-4152-b286-71f301408fe6 | 7 ++ .../620eb83e-a8cb-4f97-9fbd-8dffd111e74e | 7 ++ .../94cdb493-9326-4dcc-b99f-9c1a4bb23888 | 7 ++ .../c800a360-d198-4a87-877e-b353f7dd0a9d | 4 ++ .../03ff7d93-6865-4c8b-8a4b-0144bd9ee755 | 6 ++ .../47e423cc-1ba5-4d85-9d68-c1afa169f08f | 6 ++ .../4f28d841-4e63-4ba4-8531-212d0425af48 | 5 ++ .../d3562615-c6c9-4a41-8fb9-f39117ed55cd | 4 ++ home-store.txt | 1 + import.scl | 63 ++++++++++++++---- init.lua | 1 + torchbear.scl | 15 +++++ 14 files changed, 178 insertions(+), 14 deletions(-) create mode 100644 Readme.md create mode 100644 content/811332fb-2b80-4e99-950d-3b76f3719e80/3825ab63-c8c0-4152-b286-71f301408fe6 create mode 100644 content/811332fb-2b80-4e99-950d-3b76f3719e80/620eb83e-a8cb-4f97-9fbd-8dffd111e74e create mode 100644 content/811332fb-2b80-4e99-950d-3b76f3719e80/94cdb493-9326-4dcc-b99f-9c1a4bb23888 create mode 100644 content/811332fb-2b80-4e99-950d-3b76f3719e80/c800a360-d198-4a87-877e-b353f7dd0a9d create mode 100644 content/d3562615-c6c9-4a41-8fb9-f39117ed55cd/03ff7d93-6865-4c8b-8a4b-0144bd9ee755 create mode 100644 content/d3562615-c6c9-4a41-8fb9-f39117ed55cd/47e423cc-1ba5-4d85-9d68-c1afa169f08f create mode 100644 content/d3562615-c6c9-4a41-8fb9-f39117ed55cd/4f28d841-4e63-4ba4-8531-212d0425af48 create mode 100644 content/d3562615-c6c9-4a41-8fb9-f39117ed55cd/d3562615-c6c9-4a41-8fb9-f39117ed55cd create mode 100644 home-store.txt create mode 100644 torchbear.scl diff --git a/.gitignore b/.gitignore index ad54090..56fc422 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,4 @@ /.mp /contentdb /third-party +/log diff --git a/Readme.md b/Readme.md new file mode 100644 index 0000000..0550787 --- /dev/null +++ b/Readme.md @@ -0,0 +1,65 @@ +

lighttouch logo
This Project is Currently in Stealth Mode.
please do not post a news story until v0.1 is released very shortly.
thank you.

+ +

+ Contributions Welcome + Chat +

+ +Lighttouch is a framework that makes complex application development simpler. It does this through broad use of [component-oriented design](https://en.wikipedia.org/wiki/Component-based_software_engineering) intended to offer programmers a well-researched alternative to starting with a blank canvas - "put your code anywhere". + +[Code organized](https://en.wikipedia.org/wiki/Structured_programming) this way is: +- easier to program +- unlimited in its reusability of implementations +- easier to extend with other developers' plugins +- possible to socially cross-pollenate diverse and complex applications +- possible to use as a base for [visual programming environments](https://en.wikipedia.org/wiki/Visual_programming_language) + +Without this, applications tend to: +- get walled into handling only a single use case +- grow, but at huge cost and pain while extending +- repetively [make messy mistakes](https://news.ycombinator.com/item?id=18443327), like [spaghetti code](http://wiki.c2.com/?SpaghettiCode) and [code duplication](http://wiki.c2.com/?DuplicatedCode) +- suffer too many layers of abstraction + +Below you'll learn what is ECA-Rules, but to begin let's start with a simple diagram from the [Drupal Rules module](https://drupal.org/project/rules), a project which greatly influenced this one. + +ECA-Rules diagram + +### Lighttouch Packages + +Packages are Lighttouch's main unit of addon functionality. They leverage [event-driven](https://en.wikipedia.org/wiki/Event-driven_programming), [rule-based](https://en.wikipedia.org/wiki/Rule-based_system) programming. This basically means that packages have actions, events, and rules. Events are like [hooks](https://stackoverflow.com/questions/467557/what-is-meant-by-the-term-hook-in-programming) where additional logic can run. Rules check a conditional statement of any complexity and trigger events. When an event triggers, its actions run in weight order. Actions are the individual mechanisms of additional functionality that have a distilled purpose and can run on any associated event. + +80% of this functionality builds on top of [Luvent: A Simple Event Library for Lua](https://github.com/ejmr/Luvent). You could probably get away with the summary below of Lighttouch's use of its API, but it's still worth checking out. It has a great Readme. The basic difference between what Luvent does and what Lighttouch does is that while writing a Lighttouch app, you put functionality into individual files, and Lighttouch sets everything up for you. + +Events are very simple. They get loaded into a global list by reading each package's `events.txt` file. They can be disabled in a `disabled_events.txt` file. (aside: Potential improvements include a simpler interface and ordering execution by weight.) + +Rules are basically an `IF` statement with some metadata. If the configured conditions, specified in the body of a rule as Lua code are `TRUE`, then the specified events will trigger and the objects specified in the input parameters will get passed to the attached actions. + +Actions are individual, [lazy loaded functions](https://whatis.techtarget.com/definition/lazy-loading-dynamic-function-loading) that can run where they are needed. You simply code what you want to do, and leave the parts about when it will run and in what order to the other logic connected through the yaml header. Actions should not have conditions in them. + +### Core Modules (including third-party) + +Lighttouch also provides modules for content management, robust logging, syntax sugar, and more. These core modules + loaders mentioned for packages + and init script make up [Lighttouch Base](https://github.com/foundpatterns/lighttouch-base), which has: +- Packaged ECA-Rules Loaders: described above +- Content Module: file-based, document-oriented databases (see Grav) with data models in YAML, similar to JSON Schema (content types), and validation +- Logging: automatically setup out of the box (set log level in `config.toml`, default is `INFO`) +- ... + +### Packages + +- Lighttouch Web Logging: (for web automation) log every incoming request, outgoing response, outgoing request, and incoming response (server and client logging out of the box.. makes debugging web applications much easier) to log directory (log entries are content, btw) +- Lighttouch JSON Interface: REST API built on content module +- Lighttouch HTTP Interface: form-driven content entry mechanism, username:password protected (autogenerated at each initialization) +- Lighttouch Crypto Tools: setup a profile with cryptographic signing keys for yourself and friends to verify incoming responses and requests, and sign outgoing requests and responses + and more + +### Installation + +Lightouch has 3 dependencies: +* **[torchbear](https://github.com/foundpatterns/torchbear)** (an [application framework](https://stackoverflow.com/questions/4241919/what-is-meant-by-application-framework)) +* **[git](https://git-scm.com)** (a [version control manager](https://en.wikipedia.org/wiki/Version_control)) +* **[peru](https://github.com/buildinspace/peru)** (a [package manager](https://en.wikipedia.org/wiki/Package_manager)) + +Once these are installed, clone the repo with git, run `peru sync` to install its components, and run it with `torchbear`. To update, use `git pull` and `peru reup`. + +### Developing + +To modify any functionality in Lighttouch, create a git repo outside of it for the component your are modifying, and add an override in `peru.yaml` so that it will use that source directory. For example, to modify `lightouch-base`, clone it somewhere else, then run `peru override add lighttouch-base {{ path to lighttouch-base repo }}`. Then, after making each change to the source, run `peru sync` to update your Lighttouch. diff --git a/content/811332fb-2b80-4e99-950d-3b76f3719e80/3825ab63-c8c0-4152-b286-71f301408fe6 b/content/811332fb-2b80-4e99-950d-3b76f3719e80/3825ab63-c8c0-4152-b286-71f301408fe6 new file mode 100644 index 0000000..9509cb1 --- /dev/null +++ b/content/811332fb-2b80-4e99-950d-3b76f3719e80/3825ab63-c8c0-4152-b286-71f301408fe6 @@ -0,0 +1,7 @@ +--- +title = "Fast" +model = "slide" +slideshow = "c800a360-d198-4a87-877e-b353f7dd0a9d" +image-address = "http://unsplash.com/photos/CpkOjOcXdUY/download?force=true" +weight = 1 +... diff --git a/content/811332fb-2b80-4e99-950d-3b76f3719e80/620eb83e-a8cb-4f97-9fbd-8dffd111e74e b/content/811332fb-2b80-4e99-950d-3b76f3719e80/620eb83e-a8cb-4f97-9fbd-8dffd111e74e new file mode 100644 index 0000000..daefff7 --- /dev/null +++ b/content/811332fb-2b80-4e99-950d-3b76f3719e80/620eb83e-a8cb-4f97-9fbd-8dffd111e74e @@ -0,0 +1,7 @@ +--- +title = "Simple" +model = "slide" +slideshow = "c800a360-d198-4a87-877e-b353f7dd0a9d" +image-address = "http://unsplash.com/photos/x2Tmfd1-SgA/download?force=true" +weight = 2 +... diff --git a/content/811332fb-2b80-4e99-950d-3b76f3719e80/94cdb493-9326-4dcc-b99f-9c1a4bb23888 b/content/811332fb-2b80-4e99-950d-3b76f3719e80/94cdb493-9326-4dcc-b99f-9c1a4bb23888 new file mode 100644 index 0000000..bf37fd3 --- /dev/null +++ b/content/811332fb-2b80-4e99-950d-3b76f3719e80/94cdb493-9326-4dcc-b99f-9c1a4bb23888 @@ -0,0 +1,7 @@ +--- +title = "Powerful" +model = "slide" +slideshow = "c800a360-d198-4a87-877e-b353f7dd0a9d" +image-address = "http://unsplash.com/photos/pqvp1P7re-w/download?force=true" +weight = 3 +... diff --git a/content/811332fb-2b80-4e99-950d-3b76f3719e80/c800a360-d198-4a87-877e-b353f7dd0a9d b/content/811332fb-2b80-4e99-950d-3b76f3719e80/c800a360-d198-4a87-877e-b353f7dd0a9d new file mode 100644 index 0000000..50795af --- /dev/null +++ b/content/811332fb-2b80-4e99-950d-3b76f3719e80/c800a360-d198-4a87-877e-b353f7dd0a9d @@ -0,0 +1,4 @@ +--- +title = "Found Patterns Introduction" +model = "slideshow" +... diff --git a/content/d3562615-c6c9-4a41-8fb9-f39117ed55cd/03ff7d93-6865-4c8b-8a4b-0144bd9ee755 b/content/d3562615-c6c9-4a41-8fb9-f39117ed55cd/03ff7d93-6865-4c8b-8a4b-0144bd9ee755 new file mode 100644 index 0000000..a5c1594 --- /dev/null +++ b/content/d3562615-c6c9-4a41-8fb9-f39117ed55cd/03ff7d93-6865-4c8b-8a4b-0144bd9ee755 @@ -0,0 +1,6 @@ +--- +model = "key" +kind = "sign_private" +profile = "d3562615-c6c9-4a41-8fb9-f39117ed55cd" +... ++qEY1pRSYy7gTfJ58GLrDQTuhgiTf49Cy9yEgvix3vHGkq2b5t55E36RPtVYgnTn+2SF0Of8nEeVOyTvcvlnnQ== diff --git a/content/d3562615-c6c9-4a41-8fb9-f39117ed55cd/47e423cc-1ba5-4d85-9d68-c1afa169f08f b/content/d3562615-c6c9-4a41-8fb9-f39117ed55cd/47e423cc-1ba5-4d85-9d68-c1afa169f08f new file mode 100644 index 0000000..aa630d5 --- /dev/null +++ b/content/d3562615-c6c9-4a41-8fb9-f39117ed55cd/47e423cc-1ba5-4d85-9d68-c1afa169f08f @@ -0,0 +1,6 @@ +--- +model = "key" +kind = "sign_public" +profile = "d3562615-c6c9-4a41-8fb9-f39117ed55cd" +... +xpKtm+beeRN+kT7VWIJ05/tkhdDn/JxHlTsk73L5Z50= diff --git a/content/d3562615-c6c9-4a41-8fb9-f39117ed55cd/4f28d841-4e63-4ba4-8531-212d0425af48 b/content/d3562615-c6c9-4a41-8fb9-f39117ed55cd/4f28d841-4e63-4ba4-8531-212d0425af48 new file mode 100644 index 0000000..87f686d --- /dev/null +++ b/content/d3562615-c6c9-4a41-8fb9-f39117ed55cd/4f28d841-4e63-4ba4-8531-212d0425af48 @@ -0,0 +1,5 @@ +--- +host = "http://foundpatterns.com:3000/" +model = "place" +profile = "d3562615-c6c9-4a41-8fb9-f39117ed55cd" +... diff --git a/content/d3562615-c6c9-4a41-8fb9-f39117ed55cd/d3562615-c6c9-4a41-8fb9-f39117ed55cd b/content/d3562615-c6c9-4a41-8fb9-f39117ed55cd/d3562615-c6c9-4a41-8fb9-f39117ed55cd new file mode 100644 index 0000000..47f4a44 --- /dev/null +++ b/content/d3562615-c6c9-4a41-8fb9-f39117ed55cd/d3562615-c6c9-4a41-8fb9-f39117ed55cd @@ -0,0 +1,4 @@ +--- +model = "profile" +name = "foundpatterns" +... diff --git a/home-store.txt b/home-store.txt new file mode 100644 index 0000000..013db87 --- /dev/null +++ b/home-store.txt @@ -0,0 +1 @@ +0382e080-dd03-46e2-9610-115b72b3af27 \ No newline at end of file diff --git a/import.scl b/import.scl index 5b64bd6..891b1e7 100644 --- a/import.scl +++ b/import.scl @@ -1,30 +1,65 @@ imports = { - luvent = "third-party/", - valua = "third-party/", - torchbear-libs = "third-party/", - contentdb-lua = "contentdb", - torchbear-libs-dev = "third-party/", + lighttouch-logging = "packages/lighttouch-logging", + lighttouch-json-interface = "packages/lighttouch-json-interface", + lighttouch-html-interface = "packages/lighttouch-html-interface", + homepage-package = "packages/homepage-package", + base-theme = "themes/base-theme", + send-file-package = "packages/send-file-package", + lighttouch-change-management = "packages/lighttouch-change-management", + luvent = "third-party/", + valua = "third-party/", + torchbear-libs = "third-party/", + contentdb-lua = "contentdb", + torchbear-libs-dev = "third-party/", } torchbear-libs = { - url = "https://github.com/foundpatterns/torchbear-libs", - repo = true, + url = "https://github.com/foundpatterns/torchbear-libs", + repo = true, } torchbear-libs-dev = { - url = "https://github.com/foundpatterns/torchbear-libs-dev", - repo = true, + url = "https://github.com/foundpatterns/torchbear-libs-dev", + repo = true, } luvent = { - url = "https://github.com/ejmr/Luvent", - export = "src" + url = "https://github.com/ejmr/Luvent", + export = "src" } valua = { - url = "https://github.com/sailorproject/valua", - pluck = "valua.lua", + url = "https://github.com/sailorproject/valua", + pluck = "valua.lua", } contentdb-lua = { - url = "https://github.com/foundpatterns/contentdb.lua", + url = "https://github.com/foundpatterns/contentdb-lua", +} + +lighttouch-logging = { + url = "https://github.com/foundpatterns/lighttouch-logging", +} + +lighttouch-json-interface = { + url = "https://github.com/foundpatterns/lighttouch-json-interface", +} + +lighttouch-html-interface = { + url = "https://github.com/foundpatterns/lighttouch-html-interface", +} + +homepage-package = { + url = "https://github.com/foundpatterns/homepage-package", +} + +base-theme = { + url = "https://github.com/foundpatterns/base-theme", +} + +send-file-package = { + url = "https://github.com/foundpatterns/send-file-package", +} + +lighttouch-change-management = { + url = "https://github.com/foundpatterns/lighttouch-change-management", } diff --git a/init.lua b/init.lua index 293563f..506de9c 100644 --- a/init.lua +++ b/init.lua @@ -1,3 +1,4 @@ +#!/usr/bin/env torchbear -- Lighttouch ยท Torchbear App -- this config must be before requires diff --git a/torchbear.scl b/torchbear.scl new file mode 100644 index 0000000..7fb2eb4 --- /dev/null +++ b/torchbear.scl @@ -0,0 +1,15 @@ +web-server = { + address = "0.0.0.0", + port = "3000", + single_actor = true, +} + +general = { + init = "lighttouch-base/init.lua", + theme = "base-theme", + log_level = "trace", + sitename = "Lighttouch", + slideshow = "c800a360-d198-4a87-877e-b353f7dd0a9d", + user = "admin", + password = "admin", +}