{"id":19215578,"url":"https://github.com/alwaysblank/mnemosyne","last_synced_at":"2025-06-27T03:35:12.713Z","repository":{"id":94010027,"uuid":"97287901","full_name":"alwaysblank/mnemosyne","owner":"alwaysblank","description":"Get the thing, unless there's a new thing. For WordPress!","archived":false,"fork":false,"pushed_at":"2017-10-02T18:38:34.000Z","size":47,"stargazers_count":2,"open_issues_count":2,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-01-04T18:28:49.211Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/alwaysblank.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-07-15T02:49:15.000Z","updated_at":"2017-12-10T02:26:56.000Z","dependencies_parsed_at":"2023-03-07T20:30:41.928Z","dependency_job_id":null,"html_url":"https://github.com/alwaysblank/mnemosyne","commit_stats":null,"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alwaysblank%2Fmnemosyne","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alwaysblank%2Fmnemosyne/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alwaysblank%2Fmnemosyne/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alwaysblank%2Fmnemosyne/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/alwaysblank","download_url":"https://codeload.github.com/alwaysblank/mnemosyne/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":240290781,"owners_count":19778134,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-09T14:14:08.647Z","updated_at":"2025-02-23T08:28:38.626Z","avatar_url":"https://github.com/alwaysblank.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Mnemosyne\n#### Get the thing, unless there's a new thing\n\nMnemosyne is a system that allows for hard-coded defaults to be overwritten by \nstorage-agnostic overrides. This allows for content to be described in depth \nin a theme’s code but easily overridden by a user if necessary.\n \nNamed for the [Greek Titan of memory](https://simple.wikipedia.org/wiki/Mnemosyne).\n\n## Defaults\n\nThe data stored by Mnemosyne are refered to as \"defaults\".\n\n### Importing\n\nSet your defaults by creating a file called `defaults.mnemosyne.yaml`. Mnemosyne \nwill look for this file in the root of your \"stylesheet directory\" (i.e. the \ndirectory returned by the function `get_stylesheet_directory()`), but if it can't \nfind it there it will search your entire theme.\n\nIf you would like to place it somewhere else, or avoid the processing cycles \nneeded for searching your theme, you can tell Mnemosyne where to find your file \nwith these two filters:\n\n  - `AlwaysBlank/WP/Mnemosyne/storage_file` This is the name of the file you \n    want to find. It defaults to `defaults.mnemosyne.yaml`. You can name it \n    whatever you like, but adding the extension `.mnemosyne.yaml` is recommended.\n  - `AlwaysBlank/WP/Mnemosyne/storage_path` The **absolute** path to the directory \n    that contains your file (do not include the file name). This value defaults \n    to Boolean `false`, which causes Mnemosyne to search the stylesheet directory \n    as described above.\n\n\u003e **Note**: When you pass a path to `AlwaysBlank/WP/Mnemosyne/storage_path` \n\u003e it assumes you are supplying an exact path, and _will not_ perform a search in \n\u003e that directory—it will just concatenate the file path with the file name, and \n\u003e attempt to import the file at that location.\n\nIf you want to modify the way in which Mnemosyne searches for your file, there is \na third filter available that allows you to modify the search before it is returned:\n\n  - `AlwaysBlank/WP/Mnemosyne/storage_finder` This exposes a Finder object \n    from [Symfony\\Finder](https://symfony.com/doc/current/components/finder.html) package. \n\nThis is useful if you want to do something like narrow the search to particular \nsubdirectories, or exclude a directory from the search.\n\n### Values\n\nCurrently Mnemosyne supports basic `key:value` pairs, including values that are \nmore complex data types, such as arrays. Keys support only alphanumeric \ncharacters and underscores.\n\n## Functions\n\nIt is recommended that you use Mnemosyne's convenience functions instead of \naccessing `Mnemosyne` directly.\n\nThese functions fail silently but throw exceptions when they do. Currently these \nexceptions are not displayed, but are stored in the PHP $GLOBALS variable: \n`$GLOBALS['AlwaysBlank_WP_Mnemosyne_errors']`\n\n### __m()\n\n`__m($key_name, $data_source [, $validation_function])`\n\nThis function returns a value from the defaults or source, as appropriate.\n\n`$key_name`\n\nThe key for the value we want. The key will be used to look up a default.\n \n`$data_source`\n\nThe data source that should be checked for an override. If this evaluates to a \nfalsy value (i.e. false, null, ‘’) then the default will be used. \n \n`$validation_function`\n\nAn optional callback. This is the name of a function that, if defined, will be \ncalled and passed the evaluated result of $data_source as well as the $key_name. \nIt should return either a falsy value (ideally Boolean `false`), or the result \nof $data_source.\n\n### __me()\n\n`__me($key_name, $data_source [, $validation_function])`\n\nThis function behaves identially to `__m()`, except that it echos the value.\n\n\u003e **Note:** Attempting to retrieve a value that is not echoable (i.e. not a \nstring or numeric value) will throw an exception.\n\n### mns_dig()\n\n`mns_dig($key_name, $data_source, ...$layers)`\n\nThis function returns something from inside a retrieved array, instead of \njust the entire array.\n\n`$key`\n\nThe key for our value. Functions just like `__m()`.\n\n`$data_source`\n\nThe source of our override. Functions just like `__m()`.\n\n`...$layers`\n\nA list of comma-separated array keys, dictating the path into the returned array \nthat we want to follow.\n\n#### Example\n\nLet's say the value for the key `some_key` was an array that looked like this:\n\n```php\n[\n  'part_one' =\u003e [\n    'person' =\u003e 'Jeff',\n    'animal' =\u003e 'dog'\n  ],\n  'part_two' =\u003e [\n    'spaceship' =\u003e 'enterprise'\n  ]\n]\n```\n\nHere are some examples of what `mns_dig()` would return:\n\n```php\nmns_dig('some_key', $data_source, 'part_one', 'animal');\n// 'dog'\n\nmns_dig('some_key', $data_source, 'part_two');\n// ['spaceship' =\u003e 'enterprise']\n```\n\n\u003e **Note:** `mns_dig()` does _not_ support a customized validation function like \n`__m()` or the other functions, because of the way it takes its arguments for \narray navigation.\n\n### mns_burrow()\n\n`mns_burrow($key_name, $data_source, ...$layers)`\n\nThis function is nearly identical to `mns_dig()`, but assumes that \n`$data_source` can return _the value you want_ not _an array **containing** \nthe value you want_. It will attempt to \"dig\" into the Mnemosyne default \nstore, but will simply return `$data_source` assuming it is not false.\n\n### Others\n\nSee `src/Mnemosyne/mnemosyne_functions.php` for other functions and their \ndocumentation. Includes some tools for looking at errors and checking for \noverrides.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falwaysblank%2Fmnemosyne","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Falwaysblank%2Fmnemosyne","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falwaysblank%2Fmnemosyne/lists"}