copious-transitions
Version:
Framework for working with frameworks
1,455 lines (378 loc) • 22.3 kB
HTML
<html lang="en">
<head>
<meta charset="utf-8">
<title>JSDoc: Class: GeneralStatic</title>
<script src="scripts/prettify/prettify.js"> </script>
<script src="scripts/prettify/lang-css.js"> </script>
<!--[if lt IE 9]>
<script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
<link type="text/css" rel="stylesheet" href="styles/prettify-tomorrow.css">
<link type="text/css" rel="stylesheet" href="styles/jsdoc-default.css">
</head>
<body>
<div id="main">
<h1 class="page-title">Class: GeneralStatic</h1>
<section>
<header>
<h2><span class="attribs"><span class="type-signature"></span></span>
<span class="ancestors"><a href="base.html">base</a>.</span>GeneralStatic<span class="signature">()</span><span class="type-signature"></span></h2>
<div class="class-description"><p>This class provide a basic interface for carrying out actions required for providing static content.
Here <strong>Static Content</strong> is taken to mean content that is created previous to the launch of the application.</p>
<p>The application sets a static store by passing a class (constructor) to the GeneralStatic constructor
as in new GeneralStatic(MyStaticStoreClass) v.s. new GeneralStatic(), which uses the general database static storage class.</p>
<p>This static storage is not a replacement for all ways of serving static files. The primary web server of an website might
be the best place for setting up static file service.</p>
<p>The presence of this class in the library can be used in conjunction with the contractual access clases. And, there may be some
files best stored with the application code - and that might have more to do with installation of an application than configuring
the static load.</p>
<p>Also, this module has methods for preparing JSON descriptors of HTML and JavaScript that goes with it. This allows for
parts of pages to be delivered as lazy loaded components.</p>
<p>Finally, some processes may request files from the local process.</p></div>
</header>
<article>
<div class="container-overview">
<h2>Constructor</h2>
<h4 class="name" id="GeneralStatic"><span class="type-signature"></span>new GeneralStatic<span class="signature">()</span><span class="type-signature"></span></h4>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="lib_general_static.js.html">lib/general_static.js</a>, <a href="lib_general_static.js.html#line115">line 115</a>
</li></ul></dd>
</dl>
</div>
<h3 class="subsection-title">Methods</h3>
<h4 class="name" id="fetch"><span class="type-signature">(async) </span>fetch<span class="signature">(asset_key, etc)</span><span class="type-signature"> → {object}</span></h4>
<div class="description">
<p>This method may be the point of this module. It attempts to find a static asset and return an object
describing it if it does find it.</p>
<p>The contractual methods that use this method
prefer to have an object delivered wiht two fields <code>mime_type</code> and <code>string</code>. The first field
identifies the type of object that it is, the second is the string representation of the object.</p>
<p>In most cases, this returns an object from the <code>_preloaded</code> table. But, if the object is not there,
this method will try to find it in the DB or in the custom static store.</p>
</div>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>asset_key</code></td>
<td class="type">
<span class="param-type">string</span>
</td>
<td class="description last"></td>
</tr>
<tr>
<td class="name"><code>etc</code></td>
<td class="type">
<span class="param-type">object</span>
</td>
<td class="description last"><p>and object to pass to <code>static_store</code> if used.</p></td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="lib_general_static.js.html">lib/general_static.js</a>, <a href="lib_general_static.js.html#line181">line 181</a>
</li></ul></dd>
</dl>
<h5>Returns:</h5>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type">object</span>
</dd>
</dl>
<h4 class="name" id="generic_prep_cwd_offset"><span class="type-signature"></span>generic_prep_cwd_offset<span class="signature">(conf)</span><span class="type-signature"></span></h4>
<div class="description">
<p>Some applications call this method during preloading.
This method looks for the field <code>app_spec</code> on the <code>static_files</code> field of the configuration object.</p>
<p>After making an attemp to clean up the string, which is a relative directory to the root directory,
this method update all the <code>fname</code> fields of the descriptors stored in the <code>_preloaded</code> map.</p>
</div>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>conf</code></td>
<td class="type">
<span class="param-type">object</span>
</td>
<td class="description last"></td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="lib_general_static.js.html">lib/general_static.js</a>, <a href="lib_general_static.js.html#line319">line 319</a>
</li></ul></dd>
</dl>
<h4 class="name" id="initialize"><span class="type-signature"></span>initialize<span class="signature">(db_obj, conf)</span><span class="type-signature"></span></h4>
<div class="description">
<p>Loads files from locations that are identified in the <code>static_files</code> field of the configuration.
The <code>static_files</code> object may have a directory field, in which case all the files in the directory will be loaded.
Otherwise, it will have a map of files, <em>files</em>, which will be transfered into the <code>_preloaded</code> map.</p>
<p>Once all the entries are established in the map <code>_preloaded</code>, they data is loaded into the map for later access.</p>
</div>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>db_obj</code></td>
<td class="type">
<span class="param-type">object</span>
</td>
<td class="description last"></td>
</tr>
<tr>
<td class="name"><code>conf</code></td>
<td class="type">
<span class="param-type">object</span>
</td>
<td class="description last"></td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="lib_general_static.js.html">lib/general_static.js</a>, <a href="lib_general_static.js.html#line140">line 140</a>
</li></ul></dd>
</dl>
<h4 class="name" id="preload_all"><span class="type-signature"></span>preload_all<span class="signature">(conf)</span><span class="type-signature"></span></h4>
<div class="description">
<p>The configuration object is available for those applications that use it to identify files
to be loaded.</p>
<p>The result of calling this method should be that the table <code>_preloaded[fileKey]</code> should have a number
of assests stored in memory for later retrieval.</p>
<p>If the <code>custom_static_store</code> has been set up using a parameter to the constructor (AppStaticStorageClass),
the custom store will be used to load the <code>_preloaded</code> map. Otherwise, files will be loaded from the paths
found in thie objects stored in the the <code>_preloaded</code> map.</p>
</div>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>conf</code></td>
<td class="type">
<span class="param-type">object</span>
</td>
<td class="description last"></td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="lib_general_static.js.html">lib/general_static.js</a>, <a href="lib_general_static.js.html#line254">line 254</a>
</li></ul></dd>
</dl>
<h4 class="name" id="prepare_asset"><span class="type-signature"></span>prepare_asset<span class="signature">(data)</span><span class="type-signature"> → {object}</span></h4>
<div class="description">
<p>Some assets are delivered to the web app as an object with two parts, script and html...
This takes an html page (maybe just some part of one) with script and html. It splits the page into the two parts
and then it stores the pair for delivery.</p>
</div>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>data</code></td>
<td class="type">
<span class="param-type">Buffer</span>
</td>
<td class="description last"></td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="lib_general_static.js.html">lib/general_static.js</a>, <a href="lib_general_static.js.html#line287">line 287</a>
</li></ul></dd>
</dl>
<h5>Returns:</h5>
<div class="param-desc">
<ul>
<li>this is an object with two fields, <code>html</code> and <code>script</code>.</li>
</ul>
</div>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type">object</span>
</dd>
</dl>
<h4 class="name" id="reload"><span class="type-signature">(async) </span>reload<span class="signature">(fileKey)</span><span class="type-signature"> → {string}</span></h4>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>fileKey</code></td>
<td class="type">
<span class="param-type">string</span>
</td>
<td class="description last"></td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="lib_general_static.js.html">lib/general_static.js</a>, <a href="lib_general_static.js.html#line270">line 270</a>
</li></ul></dd>
</dl>
<h5>Returns:</h5>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type">string</span>
</dd>
</dl>
<h4 class="name" id="set_transition_engine"><span class="type-signature"></span>set_transition_engine<span class="signature">(transition_engine)</span><span class="type-signature"></span></h4>
<div class="description">
<p>Set the transion engine reference.</p>
</div>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>transition_engine</code></td>
<td class="type">
<span class="param-type">object</span>
</td>
<td class="description last"><p>a reference to the application transition engine</p></td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="lib_general_static.js.html">lib/general_static.js</a>, <a href="lib_general_static.js.html#line159">line 159</a>
</li></ul></dd>
</dl>
<h4 class="name" id="static_store"><span class="type-signature"></span>static_store<span class="signature">(asset_key, etc)</span><span class="type-signature"> → {object|boolean}</span></h4>
<div class="description">
<p>static_store -- a custom store supplied by the application in lieu of other other stores the application may supply to the db
the app might not want to call out a DB implementation... so this is a little extra
This makes the supplied static store custom for just the static pathways and falls out of scope of other assets
managed through the DB. (Use this option carefully)</p>
</div>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>asset_key</code></td>
<td class="type">
<span class="param-type">*</span>
</td>
<td class="description last"></td>
</tr>
<tr>
<td class="name"><code>etc</code></td>
<td class="type">
<span class="param-type">*</span>
</td>
<td class="description last"></td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="lib_general_static.js.html">lib/general_static.js</a>, <a href="lib_general_static.js.html#line209">line 209</a>
</li></ul></dd>
</dl>
<h5>Returns:</h5>
<div class="param-desc">
<p>returns false if no <code>custom_static_store</code> has been set up. Returns the result of <code>custom_static_store.fetch</code> othewise.</p>
</div>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type">object</span>
|
<span class="param-type">boolean</span>
</dd>
</dl>
</article>
</section>
</div>
<nav>
<h2><a href="index.html">Home</a></h2><h3>Namespaces</h3><ul><li><a href="Contractual.html">Contractual</a></li><li><a href="CopiousTransitions.html">CopiousTransitions</a></li><li><a href="DefaultDB.html">DefaultDB</a></li><li><a href="base.html">base</a></li><li><a href="field_validators.html">field_validators</a></li></ul><h3>Classes</h3><ul><li><a href="Contractual.LocalTObjectCache.html">LocalTObjectCache</a></li><li><a href="Contractual.MimeHandling.html">MimeHandling</a></li><li><a href="Contractual.TransitionHandling.html">TransitionHandling</a></li><li><a href="Contractual.UserHandling.html">UserHandling</a></li><li><a href="CopiousTransitions.CopiousTransitions.html">CopiousTransitions</a></li><li><a href="DefaultDB.CustomizationMethodsByApplication.html">CustomizationMethodsByApplication</a></li><li><a href="DefaultDB.FauxInMemStore.html">FauxInMemStore</a></li><li><a href="DefaultDB.FileMapper.html">FileMapper</a></li><li><a href="DefaultDB.FilesAndRelays.html">FilesAndRelays</a></li><li><a href="DefaultDB.FilesAndRelays_base.html">FilesAndRelays_base</a></li><li><a href="DefaultDB.LocalStaticDB.html">LocalStaticDB</a></li><li><a href="DefaultDB.LocalStorageLifeCycle.html">LocalStorageLifeCycle</a></li><li><a href="DefaultDB.LocalStorageSerialization.html">LocalStorageSerialization</a></li><li><a href="DefaultDB.PageableMemStoreElement.html">PageableMemStoreElement</a></li><li><a href="DefaultDB.PersistenceContracts.html">PersistenceContracts</a></li><li><a href="DefaultDB.RemoteMessaging.html">RemoteMessaging</a></li><li><a href="DefaultDB.StaticDBDefault.html">StaticDBDefault</a></li><li><a href="GeneralUserDBWrapperImpl.html">GeneralUserDBWrapperImpl</a></li><li><a href="SessionTokenManager.html">SessionTokenManager</a></li><li><a href="base.DBClass.html">DBClass</a></li><li><a href="base.EndpointManager.html">EndpointManager</a></li><li><a href="base.GeneralAppLifeCycle.html">GeneralAppLifeCycle</a></li><li><a href="base.GeneralAuth.html">GeneralAuth</a></li><li><a href="base.GeneralBusiness.html">GeneralBusiness</a></li><li><a href="base.GeneralDynamic.html">GeneralDynamic</a></li><li><a href="base.GeneralMiddleWare.html">GeneralMiddleWare</a></li><li><a href="base.GeneralStatic.html">GeneralStatic</a></li><li><a href="base.GeneralTransitionEngImpl.html">GeneralTransitionEngImpl</a></li><li><a href="base.SessionManager.html">SessionManager</a></li><li><a href="base.SessionManager_Lite.html">SessionManager_Lite</a></li><li><a href="base.TaggedTransition.html">TaggedTransition</a></li><li><a href="base.TokenTables.html">TokenTables</a></li><li><a href="base.UserMessageEndpoint.html">UserMessageEndpoint</a></li><li><a href="base.WebSocketManager.html">WebSocketManager</a></li><li><a href="field_validators.DataLookupField.html">DataLookupField</a></li><li><a href="field_validators.EmailField.html">EmailField</a></li><li><a href="field_validators.EmailVerifyField.html">EmailVerifyField</a></li><li><a href="field_validators.FieldTest.html">FieldTest</a></li><li><a href="field_validators.FieldValidatorTools.html">FieldValidatorTools</a></li><li><a href="field_validators.ForeignAuth.html">ForeignAuth</a></li><li><a href="field_validators.GeneralValidator.html">GeneralValidator</a></li><li><a href="field_validators.LengthyAlphabetField.html">LengthyAlphabetField</a></li><li><a href="field_validators.LengthyDigitalField.html">LengthyDigitalField</a></li><li><a href="field_validators.LengthyField.html">LengthyField</a></li><li><a href="field_validators.LengthyStringField.html">LengthyStringField</a></li><li><a href="field_validators.PasswordField.html">PasswordField</a></li><li><a href="field_validators.PasswordVerifyField.html">PasswordVerifyField</a></li><li><a href="field_validators.TypeCheckField.html">TypeCheckField</a></li></ul><h3>Global</h3><ul><li><a href="global.html#generate_password_block">generate_password_block</a></li><li><a href="global.html#load_configuration">load_configuration</a></li><li><a href="global.html#load_parameters">load_parameters</a></li><li><a href="global.html#module_top">module_top</a></li></ul>
</nav>
<br class="clear">
<footer>
Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 4.0.2</a> on Tue Oct 31 2023 17:32:59 GMT-0700 (Pacific Daylight Time)
</footer>
<script> prettyPrint(); </script>
<script src="scripts/linenumber.js"> </script>
</body>
</html>