diff --git a/README.md b/README.md index 232f3d2..55b690f 100644 --- a/README.md +++ b/README.md @@ -133,15 +133,13 @@ The naming of functions is important. There are basically two styles: The task file function use the first style. The name of function starts with the action followed by the object. The object definition can be singular and/or plural. -**Examples for action**: activate, install, dev, develop, init, build, start, update, remove, delete, enable, disable, template, convert, create, edit, change, get, set, patch, fetch, generate, push, pull, import, export, list, publish, release, test, setup, prepare, restart, stop, store, restore, translate, upgrade, zip, visualize, sync, switch, run, reset, load, dump, checkout, commit, drop, deploy, handle, trigger, render, lint, uninstall, split, parse, +**Examples for action**: activate, install, dev, develop, init, build, start, update, remove, delete, enable, disable, template, convert, create, edit, change, get, set, patch, fetch, generate, push, pull, import, export, list, publish, release, test, setup, prepare, restart, stop, store, restore, translate, upgrade, zip, visualize, sync, switch, run, reset, load, dump, checkout, commit, drop, deploy, handle, trigger, render, lint, uninstall, split, parse -**Examples for object**: env, venv, submodule, container, database, snippet, model, module, repo, mail, doc, dependency, view, user, vault, file, host, node, log, password, hash, script, requirement, addon, path, config, revision, version, snippet, help, table, project, desktop, db +**Examples for object**: env, venv, submodule, container, database, snippet, model, module, repo, mail, doc, dependency, view, user, vault, file, host, node, log, password, hash, script, requirem -Objects can be tools: odoo, vupress, node, zsh, bash, fish, podman, kind, minikube, helm, nvim, docker, podman, rust, python, tmux, vim, helix, system, git, pass, llm, sql, dotenv +**Objects can be tools**: odoo, vupress, node, zsh, bash, fish, podman, kind, minikube, helm, nvim, docker, podman, rust, python, tmux, vim, helix, system, git, pass, llm, sql, dotenv -Object definitions can be combined: password-hash, git-submodule, user-model, odoo-database, help-docs - -**Examples for function**: install-module, generate-passwod-hash, pull-git-submodule, activate-venv, list-odoo-requirements, update-addon-path, restore-pass, patch-database, render-project-docs + ## Patterns The task file showed above is very basic. Commands can have parameters and functions call each other. The following is a collection of more complex task file patterns. diff --git a/_includes/layouts/base.njk b/_includes/layouts/base.njk index a1f7449..4951ee3 100644 --- a/_includes/layouts/base.njk +++ b/_includes/layouts/base.njk @@ -42,5 +42,6 @@ Edit this page on GitHub + diff --git a/eleventy.config.js b/eleventy.config.js index 2a76f08..dbd578d 100644 --- a/eleventy.config.js +++ b/eleventy.config.js @@ -23,4 +23,5 @@ module.exports = async function (eleventyConfig) { eleventyConfig.addPassthroughCopy("img"); eleventyConfig.addPassthroughCopy("css"); + eleventyConfig.addPassthroughCopy("js"); } diff --git a/js/randomFunctionNames.js b/js/randomFunctionNames.js new file mode 100644 index 0000000..45ff686 --- /dev/null +++ b/js/randomFunctionNames.js @@ -0,0 +1,66 @@ + +// Function to extract array from span content +const getItemsFromSpan = (spanId) => { + const span = document.getElementById(spanId); + if (span) { + return span.textContent.split(',').map(item => item.trim()); + } + return []; +}; + +// Load actions and objects from spans +let actions = []; +let objects = []; + +// Load after DOM is ready +document.addEventListener('DOMContentLoaded', () => { + actions = getItemsFromSpan('actions'); + objects = [ + ...getItemsFromSpan('objects'), + ...getItemsFromSpan('object-tools') + ]; +}); + +// Function to get a random item from an array +const getRandomItem = (arr) => arr[Math.floor(Math.random() * arr.length)]; + +// Function to generate random function names +const generateFunctionName = () => { + const action = getRandomItem(actions); + const object = getRandomItem(objects); + + // Randomly decide if a compound object name should be created + const compound = Math.random() > 0.7; + if (compound) { + const secondObject = getRandomItem(objects); + return `${action}-${object}-${secondObject}`; + } + + return `${action}-${object}`; +}; + +// Generate a list of random function names +const generateFunctionNames = (count = 10) => { + const names = []; + for (let i = 0; i < count; i++) { + names.push(generateFunctionName()); + } + return names; +}; + +// Display the function names on the page +const displayFunctionNames = () => { + const container = document.getElementById('function-names'); + container.innerHTML = generateFunctionNames().map(name => `
  • ${name}
  • `).join(''); +}; + +// Run on page load +document.addEventListener('DOMContentLoaded', displayFunctionNames); + +// Add event listener to the button +document.addEventListener('DOMContentLoaded', () => { + const button = document.getElementById('generate-function-names'); + if (button) { + button.addEventListener('click', displayFunctionNames); + } +}); \ No newline at end of file