Skip to content
Kion edited this page May 17, 2021 · 3 revisions

This is the page for the Whitmir memory structure. The coding style uses a convention this.MEM which is accessible from inside the Whitmir module. No steps have been taken to prevent access to this object from outside the module, but otherwise getter and setter methods should be written to interact with the memory object from outside the module. The structure is given by the code segment below.

this.MEM = { 
    tiny : [ Object ],
    config :  [ Object ],
    book : [ Object ],
    activeBook : [ HTML Element ],
    chapter : [ Object ],
    activeChaper : [ HTML Element ]
}

Each one of the attributes will be described in its own section below.

Tiny

The this.MEM.tiny stores a reference to the single instance of TinyMCE rich text editor that is used for editing the chapters of each book. This is mostly used for getting and setting the contents of the editor.

Config

The config object stores the references to the books in Google Drive, and their category to be rendered in the sidebar. The structure is given by the code snippet below.

this.MEM.config = {
    id : "1_uLId9FW3iFVaV5zLr2tmnRv4j7On5Lz",
    unsorted : [ List of Books ],
    categories : {
        "gtk.dashgl.com" : [ List of Books ],
        "egl.dashgl.com" : [ List of Books ]
    },
    createdOn : 1619864095715,
    updatedOn : 1619932492633
}

The config object, referenced by this.MEM.config is stringified and saved in Google Drive as whitmir.io/config.json. Any changes to this object will trigger an update to the file on Google Drive, so that the file can be loaded on the next page load to retrieve the state of the application. The id attribute is used to keep a reference to the file id in Google Drive. The attributes createdOn and updatedOn contain a Unix timestamp for when the object was created and last updated. These attributes are redundant as these changes are tracked by the Google Drive API, they are included to make sure to be able to debug if the files have been successfully updated from the application or not.

The unsorted and categories have the same structure. The unsorted attribute contains the list of books that do not have a category and are listed in the top of the navigation. The categories attribute is an object where the keys are the name of each category. The value of each key is an array that holds a list of books that are in each category. In each case, the structure is a list of books. So we will provide the data structure for the books in the code snippet below.

{
    name : "Brickout",
    folder : "1UHG608mwPXPoTC4TUGIZ_nFf4E3j4HqY",
    createdOn : 1619888865735,
    icon : "fas fa-book",
    cover : boolean,
    table_of_contents : boolean
    chapters : [ List of Chapters ]
}

The ``nameattribute is the title of the book. Thefolder``` attribute is the id of the folder in Google Drive. In this case ```createdOn``` is the creation date as a Unix timestamp, which is not needed, but is included for debug purposes. The ```icon``` attribute is a slug for the FontAwesome library to allow for different icons to be used in the navigation list. This functionality is not yet implemented. As of right now the ```cover``` and ```table_of_contents``` attributes are not yet implemented. To avoid any possible overlap, these might need to be implemented as files in the root directory of the ```whitmir.io``` folder.

Last is the chapters array. Which contains a list of chapters. This will be defined in a different section as to be separated from the book data format. Note that as the book structure is stored in JSON, more attributes might be added depending on which options are implemented in the settings menu.

Clone this wiki locally