▲▼
darkwave — obelisk
1 - introduce concept 2 - describe base setup / install ((install cash & make mods where noted in obelisk-ce codebase)) setting up the settings, adding relevant credentials 3 - patterns for doing specific things installation process (install deps) copy paste settings/dw-compatible modules --- ---

obelisk - dw-compatible shared microservices focus on heavy lifting, fast/concurrent processing only one 'complex' app to maintain, share complex functionality across applications small-scale (just for your own stuff), run it on a single vps (or scale it if you want, i don't give a shit)

obelisk-dw (dw-compatible obelisk, pull from custom ce stuff) - specialized - processing uploads, image resizing, twilio, etc ... complex/heavy back end functionality for dw apps ... boilerplate/components/patterns for dw high-powered asynchronous web services for dw (abstractions for sockets, push, complex microservices, heavy operations [media conversion/generation] boilerplate for writing custom designed to be deployed on a vps/wherever (where you can connect to a dw db), but doesn't have to be the same machine as the dw app, you interact w/ it over http implemented as collection of (gitlab-equivalent) gists w/ setup/install instruction like this: https://gist.github.com/bekce/2fedd3fdcd4a532169f9e3d193623a57 copy/paste example code for common (or specialized, idc) use cases catalogued on a web site (that's searchable) - like darkwave.ltd/obelisk -- need more power? have a lot of these sites on the same machine? build an obelisk! (multi-tenant system-level shared microservices) (you build custom code for your dw app, copy-paste these gists) accessing the settings: $.settings[site_code].mysql.host settings look like this: "SITECODE": { mysql: { host: '', user: '', password: '', database: '' }, imap: { host: '', user: '', password: '', }, }

------------ ------------ ------------ # FUNCTIONALITY (patterns from obelisk-ce) v1 - current (shared) CE needs - [ ] discussion-receive updates - [x] what to do if there are no messages? (don't show an error, just don't do anything) - [ ] kill debugging properties - [ ] support emojis from email plain text (plain text encoded as ut8?) - [ ] save attachments as files & upload to s3 -- it's all there, just needs to be set up, debugged - [ ] send text from twilio - [ ] upload fine (for DAA + investors + JCDV) - [ ] upload dropzone v2 - add cb functionality - [ ] web push notifications (import from cb-web-push) v3 - ?? - [ ] bitly - [ ] nodemailer proxy (see publicworks.static.city) - mailgun send - [ ] local weather db - once an hour or whatever, update the local weather, all sites use the weather.json (currently either in owlcam or exec sign?) - [ ] sharp image compression - [ ] upload to s3/wasabi (/edit/remove) - [ ] generate pdfs (proxy for relaxdjs/whatever, feed it html & save a pdf in a given location) - [ ] geospatial data/geocoding - [ ] web scraping - go to this address, find these fields, and put them in this db/table - [ ] web sockets (socket.io, see tmp-socket-server) - [ ] garbage collection? - [ ] backup services? - [ ] send stats/errors to dashboard? - [ ] analytics/reporting? FUTURE UPDATES (best practices) - [ ] pm2 run in cluster mode (load balancing) - https://pm2.io/docs/runtime/guide/load-balancing/ - https://pm2.keymetrics.io/docs/usage/cluster-mode/ - currently don't need to for CE, but might be helpful for future projects - [ ] disable warning for process.env.NODE_TLS_REJECT_UNAUTHORIZED = "0"; - idc that i have to do it and i don't want the warnings filling up my logs w/ that shit - ideally want to resolve SSL issues, but have to do this for email (node-imap) and twilio - [ ] ?? access tokens for each client? - [ ] discussion-receive - can it receive mail directly from cpanel? or new mail triggers a php script that calls the inbound route w/ http? - change it so the script isn't executing once a minute -------- -------- --------

- cool idea! - build a system-level go microservice that provides http endpoints for doing common web app things - complex functionality like file uploads, image processing, authentication, etc (interacting w/ 3rd party services like twilio & mailgun, producing pdfs) .. custom for CE sites, simple "bare bones" version that just does image processing and whatever for running on eqkh - does all the heavy lifting - application-agnostic, just give it the path/perms for where your files end up, creds for executing actions w/ 3rd party services on your behalf - shared local microservices - designed to be run on a single vps and shared across local applications - allows applications to share 3rd party api services (or not) - purhost system microservice -- want to do a shared system-level utility that can be used by many sites on the same vps - after doing one for CE, put it on eqkh as well Obelisk is specific formation(?), custom (dw-compatible) code built on cash.js (generic boilerplate tool) Specifically: multi-tenant shared microservices Use cash to build an obelisk build an obelisk with whatever you want (i use cash) rails, go, python, rust, i don't give a shit important part of obelisk is api & functionality (in needs to do the same thing and accept http commands at the right addressesses) (for dorkwave use, at least) obelisk is use-case specific - you build your own code suited to your own needs - but build w/ the same conventions (creating re-usable solutions that can be used for future projects, where appropriate) --- ---

current users: daa future users (ce): oip, mgmt, jcdv, tenants? signage? owlcam? ultimately cb future users (eqkh): crag? print shop? static city? equus (showrunner, equipost, eqcms, idk?) --- - default deployment/design - localhost:6969 - accessible via ip address - xx.xx.xx.xx:6969 - or behind domains - oblsk.systemhost.com
TEMPLATES
something something templates go in ./pages and you can call them whatever you want. you can organize this however you want, too! link to handlebars docs for more info.
Basic Variables

the simplest thing to do. if you use render_template, stereo includes a few by default (year, etc) as well as a few special things (is_admin, auth, user_id, etc) (title [uses the site title by default, so it's kinda optional])

php


	$app->get('/variable-example', function(){
	  $GLOBALS['app']->render_template(array(
	    'template' => 'demo',
	    'data' => array(
	      'fish' => 'salmon',
	      'dish' => 'paella',
	      'planet' => 'Nibiru'
	    )
	  ));
	});

hbs (note about literals { { { } } } vs { { } } -- by default hbars doesn't parse html tags, so if you want to have them rendered, do this)


	<h2>Simple Variables Example</h2>
	<h3>Cool Fish: {{fish}}</h3>
	<h3>Cool Dish: {{dish}}</h3>
	<h3>Cool Planet: {{planet}}</h3>
Iterating Arrays

it's hella easy, just like a foreach loop. you can even nest the arrays to infinity (and beyond) (sorry) (it can be as simple or complex as you want to make it) (see the demo controller/templates for an example of more complex array iteration)

php (simple & complex example from demo)


	$app->get('/array-example', function(){
	  $GLOBALS['app']->render_template(array(
	    'template' => 'demo',
	    'data' => array(
	      'snacks' => array(
	        'Carrots',
	        'Hay',
	        'Sugar Cubes',
	        'Oats',
	        'Apples',
	        'Weaker Horses'
	      )
	    )
	  ));
	});

hbs (simple & complex example from demo)


	<ul>
	  {{#each snacks}}
	  <li>{{this}}</li>
	  {{/each}}
	</ul>
Simple Logic

you can do some simple logic to check if a variable exists (or has value). if you would like to do more complex logic, check out [if_either], [in_array], [is]

php


	$app->get('/logic-example', function(){
	  $GLOBALS['app']->render_template(array(
	    'template' => 'demo',
	    'data' => array(
	      'fish' => 'salmon',
	      'dish' => 'paella',
	    )
	  ));
	});

hbs (if/else, unless, (normal hbars logic, link to hbars docs) maybe is & link to helpers)


	{{#if fish}}
	 Salmon is available
	{{else}} // this won't show:
	 No salmon for you.
	{{/if}}
	
	{{#unless snacks}}
	 No snacks available. We have {{dish}}, though.
	{{else}} // this won't show:
	 Look at all the snack options:
	 {{#each snacks}}
	 - {{this}} <br />
	 {{/each}}
	{{/unless}}
Partials

You can include templates in other templates! That is neat! all your partials need to be in the _partials directory, but you can organize that however you want!

normal php whatever example


	$app->get('/partials-example', function(){
	  $GLOBALS['app']->render_template(array(
	    'template' => 'demo',
	    'data' => array(
	      'fish' => 'salmon',
	      'dish' => 'paella',
	      'planet' => 'Nibiru'
	    )
	  ));
	});

hbs


	<h2>Demo page (rendered with partial from separate template)</h2>
	
	<h3>Fish: {{fish}}</h3>
	<h3>Dish: {{dish}}</h3>
	
	{{> planets-partial}}

hbs (partial code) (see how it has access to the same data?)


	<ul>
	  {{#each planets}}
	  <li>{{this}}</li>
	  {{/each}}
	</ul>
Global Layouts

if you want to use a global header footer, you can! you can define as many global wrappers/layouts as you want (like express, django, ember, whatever...wow!) if you leave the "layout" parameter blank, STEREO will use the layout in ./pages/_layouts/base.hbs by default. your content will be rendered where the [[outlet]] part is

php example


	$app->get('/layouts-example', function(){
	  $GLOBALS['app']->render_template(array(
	    'template' => 'demo',
	    'title' => 'Site Title Whatever',
	    'layout' => 'admin',  // false for nothing, base by default
	    'data' => array(
	      'fish' => 'salmon',
	      'dish' => 'paella',
	      'planets' => array(
	        'Mercury', 'Venus', 'Earth', 'Nibiru'
	      )
	    )
	  ));
	});

hbs (wrapper)


	<!DOCTYPE html>
	<html>
	<head>
	  <title>{{title}}</title>
	  <meta charset="utf-8" />
	  <meta http-equiv="X-UA-Compatible" content="IE=edge, chrome=1" />
	  <link rel="stylesheet" href="/css/app.css" />
	</head>
	<body>
	
	  <div class="header"><h1>Site Title Whatever</h1></div>
	
	  <div class="container">
	    [[outlet]]  // this is where the content will be rendered
	  </div>
	
	  <div class="footer">(c) {{year}} -- All rights reserved or whatever.</div>
	
	<script src="/js/vendor/jquery.min.js"></script>
	<script src="/js/app.js"></script>
	
	</body>
	</html>

hbs


	<h2>Demo page (rendered with global wrapper)</h2>
	
	<h3>Fish: {{fish}}</h3>
	<h3>Dish: {{dish}}</h3>
	
	<ul>
	  {{#each planets}}
	  <li>{{this}}</li>
	  {{/each}}
	</ul>
Template Locals (Global Variables)

need to make an arbitrary variable/array available to all the templates? use $GLOBALS['locals'] (hold for laugh) but seriously, folks, treat it like an array and whatever you need. and if it's an array is something you can iterate over. and, of course, all of this is available to the application as $GLOBALS['locals']['numbers'] or whatever

php example


	$GLOBALS['locals']['eat_this'] = "breakfast";

hbs


	Let's have {{locals.eat_this}} for dinner.

php example


	$GLOBALS['locals']['colors'] = array('red', 'salmon', 'lilac', 'azul');

hbs


	<ul>
	  {{#each locals.colors}}
	  <li>{{this}}</li>
	  {{/each}}
	</ul>