Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
composer.phar
/vendor/
/.phpunit.result.cache
src/config/config.json
src/config/
src/errors/errors.log.txt

17 changes: 17 additions & 0 deletions docs/public/code.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/public/cover.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions docs/src/components/Header.astro
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ const homeLink = "";
<div class="flex items-center">
<a href={base + "/" + homeLink}>
<img
src={base + "/icon.svg" }
src={base + "/icon.png" }
alt="Logo"
class="w-10 h-10 rounded-full hover:border-2 hover:border-green-400 mr-2"
class="w-10 h-10 rounded-full hover:border-2 hover:border-purple-400 mr-2"
/>
</a>
</div>
Expand Down
8 changes: 4 additions & 4 deletions docs/src/components/Sidebar.astro
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@ const { slug } = Astro.params;
{item.children && (
<ul class="space-y-1">
{item.children.map((child) => (
<li class={child.path.split("/").pop() === slug ? "active" : ""}>
<li class={child.path.split("/").pop()?.toLowerCase() === slug ? "active" : ""}>
<a
href={(base ?? "") + "/" + child.path}
class="block py-1 pl-4 text-sm hover:text-green-500 border-l-2 border-gray-200 dark:border-gray-600
hover:!border-green-400"
class="block py-1 pl-4 text-sm hover:text-purple-500 border-l-2 border-gray-200 dark:border-gray-600
hover:!border-purple-400"
>
{child.label}
</a>
Expand All @@ -36,6 +36,6 @@ const { slug } = Astro.params;

<style>
.active a {
@apply text-green-500 border-l-2 !border-green-500;
@apply text-purple-500 border-l-2 !border-purple-500;
}
</style>
16 changes: 8 additions & 8 deletions docs/src/components/baseHeader.astro
Original file line number Diff line number Diff line change
Expand Up @@ -11,20 +11,20 @@ const { title } = Astro.props;
<meta charset="UTF-8" />
<meta name="description" content="Astro description" />
<meta name="viewport" content="width=device-width" />
<link rel="icon" type="image/svg" href={(base ?? '') + "/favicon.svg"} />
<link rel="icon" type="image/svg" href={(base ?? '') + "/icon.png"} />
<meta name="generator" content={Astro.generator} />
<title>{title}</title>
<meta name="title" content="Gena - a documentation template" />
<meta name="description" content="a template to quickly get up and writing documentation." />
<meta name="description" content=" a lightweight, flexible, hook and event based plugin manager and system." />
<meta property="og:type" content="website" />
<meta property="og:url" content="https://bethropolis.github.io/gena/" />
<meta property="og:url" content="https://bethropolis.github.io/plugin-system/" />
<meta property="og:title" content="Gena- a documentation template" />
<meta property="og:description" content="a template to quickly get up and writing documentation." />
<meta property="og:image" content="https://bethropolis.github.io/gena/cover.svg" />
<meta property="og:description" content=" a lightweight, flexible, hook and event based plugin manager and system." />
<meta property="og:image" content="https://bethropolis.github.io/plugin-system/cover.png" />
<meta property="twitter:card" content="summary_large_image" />
<meta property="twitter:url" content="https://bethropolis.github.io/gena/" />
<meta property="twitter:url" content="https://bethropolis.github.io/plugin-system/" />
<meta property="twitter:title" content="Gena - a documentation template" />
<meta property="twitter:description" content="a template to quickly get up and writing documentation." />
<meta property="twitter:image" content="https://bethropolis.github.io/gena/cover.svg" />
<meta property="twitter:description" content=" a lightweight, flexible, hook and event based plugin manager and system." />
<meta property="twitter:image" content="https://bethropolis.github.io/plugin-system/cover.png" />
<link rel="sitemap" href="/sitemap-index.xml" />
</head>
9 changes: 6 additions & 3 deletions docs/src/components/breadNav.astro
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
---
const { slug } = Astro.params;
let { slug } = Astro.params;

slug = slug?.split("-").join(" ") ?? "overview";

---

<nav class="text-sm font-medium my-3 lg:hidden text-gray-500" aria-label="Breadcrumb">
<ol class="list-none p-0 inline-flex">
<ol class="!list-none p-0 inline-flex">
<li class="flex items-center">
<a href="./" class="!text-green-400 hover:!text-green-500">overview</a>
<a href="./" class="!text-purple-400 hover:!text-purple-500">overview</a>
<svg
class="fill-current w-3 h-3 mx-3"
xmlns="http://www.w3.org/2000/svg"
Expand Down
2 changes: 1 addition & 1 deletion docs/src/components/cards.astro
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { sidebarStructure, base } from "../content";
section.children.map((child) => (
<a href={base + "/" + child.path}>
<div class="bg-white rounded-xl select-none cursor-pointer shadow-lg p-3 w-11/12 md:w-64 my-2 mx-auto
md:m-2 dark:bg-gray-700 hover:!bg-gray-600">
md:m-2 dark:bg-gray-700 dark:hover:bg-gray-600 hover:bg-gray-100">
<h2 class="text-lg font-medium mb-4">{child.label}</h2>
<p class="text-gray-500">{section.label}</p>
</div>
Expand Down
1 change: 1 addition & 0 deletions docs/src/components/codebox.astro
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ let activeTab = tabs[0];
btn.classList.remove("border-b-2");
codes[i].style.display = "none";
});

button.classList.add("border-b-2");
codes[index].style.display = "block";
});
Expand Down
2 changes: 1 addition & 1 deletion docs/src/components/footer.astro
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
<footer class="text-center py-5 mt-4">
<p>Made with 💚 by <a href="http://bethropolis.github.io/" class="hover:underline">bethropolis</a></p>
<p>Made with 💜 by <a href="http://bethropolis.github.io/" class="hover:underline">bethropolis</a></p>
</footer>
4 changes: 2 additions & 2 deletions docs/src/components/list.astro
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ const { outline } = Astro.props;
{
outline &&
outline.map((item) => (
<li class="pl-2 border-l-2 border-gray-400 hover:border-green-400">
<a href={"#" + item} class="block py-1 hover:text-green-500">
<li class="pl-2 border-l-2 border-gray-400 hover:border-purple-400">
<a href={"#" + item.toLowerCase()} class="block py-1 hover:text-purple-500">
{item.split("-").join(" ")}
</a>
</li>
Expand Down
41 changes: 39 additions & 2 deletions docs/src/content.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,48 @@ export const sidebarStructure = [
path: "./docs/introduction",
},
{
label: "installation",
path: "./docs/installation",
label: "developing plugins",
path: "./docs/making-a-plugin",
},
{
label: "running a plugin",
path: "./docs/running-a-plugin",
},
{
label: "managing plugins",
path: "./docs/managing-plugins",
},
{
label: "getting plugin info",
path: "./docs/getting-plugin-info",
}
],
},
{
label: "APIs",
children: [
{
label: "System",
path: "./docs/api/system",
},
{
label: "Plugin",
path: "./docs/api/plugin",
},
{
label: "manager",
path: "./docs/api/manager",
},
{
label: "Lifecycle",
path: "./docs/api/lifecycle",
},
{
label: "Info",
path: "./docs/api/info",
}
]
},
{
label: "other",
children: [
Expand Down
52 changes: 52 additions & 0 deletions docs/src/content/docs/api/info.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
---
title: "Info api"
file_reference: "/src/Info.php"
outline:
[
"Info",
"Class-Namespace",
"$this->loadConfig",
"$this->refreshPlugins",
"$this->scanPluginsDirectory",
"$this->addPlugin",
"$this->removePlugin",
"$this->modifyPluginData",
"$this->getPlugins",
"$this->saveConfig",
]
---

## Info
the Info class handles plugin's info from plugin.json file.

### Class-Namespace

```php
use Bethropolis\PluginSystem\Info;
```

### Class Methods

#### `$this->loadConfig()` _private_
> Loads the configuration from the config file.

#### `$this->refreshPlugins()`
> Refreshes the list of plugins and plugin info.

#### `$this->scanPluginsDirectory()` _private_
> Scans the plugins directory and returns an array of plugin names.

#### `$this->addPlugin($pluginName, $data)`
> Adds a plugin to the configuration.

#### `$this->removePlugin($pluginName)`
> Removes a plugin from the configuration.

#### `$this->modifyPluginData($pluginName, $data)`
> Modifies the plugin data for a specific plugin.

#### `$this->getPlugins()`
> Retrieves the list of plugins as an array.

#### `$this->saveConfig()`
> Saves the configuration data to a file.
56 changes: 56 additions & 0 deletions docs/src/content/docs/api/lifecycle.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
---
title: "Lifecycle api"
file_reference: "/src/Lifecycle.php"
outline:
[
"Lifecycle",
"Class-Namespace",
"$this->onInstallation",
"$this->onUninstallation",
"$this->processPluginFiles",
"$this->getPluginConfigPath",
"$this->append",
"$this->remove",
"$this->resolveAbsolutePath",
"$this->resolveRelativePath",
"$this->getAbsolutePath",
"$this->getRelativePath",
]
---

## Lifecycle
the lifecycle class handles a plugin's life cycle from installation to uninstallation.

### Class-Namespace

```php
use Bethropolis\PluginSystem\Lifecycle;
```

### Class Methods

#### `$this->onInstallation($pluginName)`
> executed when a plugin is installed

#### `$this->onUninstallation($pluginName)`
> executed when a plugin is uninstalled

#### `$this->processPluginFiles($pluginName, $action)` _private_
> Process plugin files. eg plugin.json <br/>
> this allows it to perform plugin configurations e.t.c

#### `$this->getPluginConfigPath($pluginName)` _private_
> return the path to the plugin's config file

#### `$this->append($targetFile, $requireFile, $pluginName)` _private_
> Appends a require statement to a target file if it doesn't already exist.

#### `$this->remove($targetFile, $requireFile, $pluginName)` _private_
> Undos the require statement from $this-append() .

#### `$this->resolveAbsolutePath($path)` _private_
> Resolves the absolute path from a given path.

#### `$this->resolveRelativePath($path, $basePath)` _private_
> Resolves the relative path from a given base path.

65 changes: 65 additions & 0 deletions docs/src/content/docs/api/manager.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
---
title: "Manager api"
file_reference: "/src/Manager.php"
outline: [
"Manager",
"Class-Namespace",
"Manager::initialize",
"Manager::installPlugin",
"Manager::uninstallPlugin",
"Manager::updatePlugin",
"Manager::loadConfig",
"Manager::activatePlugin",
"Manager::deactivatePlugin",
]
---

## Manager

the manager class handles instalation, uninstallation and updating of plugins.

### Class Namespace
```php
use Bethropolis\PluginSystem\Manager;
```

### Class Methods

#### `Manager::initialize()`
> initializes the manager

#### `Manager::installPlugin($downloadUrl)`
> downloads a zip file and extracts it into the plugin directory

#### `Manager::uninstallPlugin($pluginName)`
> removes a plugin from the plugins directory.

#### `Manager::updatePlugin($pluginName, $pluginUrl)`
> updates a plugin.

#### `Manager::loadConfig()`
> loads/creates the config file

#### `Manager::activatePlugin($pluginName)`
> activates a plugin

#### `Manager::deactivatePlugin($pluginName)`
> deactivates a plugin

#### `Manager::togglePlugin($pluginName)`
> toggles between plugin activation and deactivation

#### `Manager::pluginExists($pluginName)`
> checks if a plugin exists

#### `Manager::isPluginActive($pluginName)`
> checks if a plugin is active

#### `Manager::getPluginMetadata($pluginName)`
> returns the metadata of a plugin

#### `Manager::saveConfig()` _private_
> saves the config file



Loading