From f12b8bf91ef20592e231b982d0dfdebdfded8ef4 Mon Sep 17 00:00:00 2001 From: Llewellyn van der Merwe Date: Tue, 28 Nov 2023 14:59:05 +0200 Subject: [PATCH] first commit --- README.md | 53 +++++++++++++++++ index.html | 1 + .../en-GB/en-GB.plg_system_preupverloader.ini | 3 + .../en-GB.plg_system_preupverloader.sys.ini | 3 + language/en-GB/index.html | 1 + language/index.html | 1 + preupverloader.php | 51 +++++++++++++++++ preupverloader.xml | 29 ++++++++++ script.php | 57 +++++++++++++++++++ 9 files changed, 199 insertions(+) create mode 100644 README.md create mode 100644 index.html create mode 100644 language/en-GB/en-GB.plg_system_preupverloader.ini create mode 100644 language/en-GB/en-GB.plg_system_preupverloader.sys.ini create mode 100644 language/en-GB/index.html create mode 100644 language/index.html create mode 100644 preupverloader.php create mode 100644 preupverloader.xml create mode 100644 script.php diff --git a/README.md b/README.md new file mode 100644 index 0000000..be1793a --- /dev/null +++ b/README.md @@ -0,0 +1,53 @@ +# PreUpVer Loader (1.0.0) + +## Introduction + +PreUpVer is a versatile JavaScript library designed to automatically update the version numbers of library scripts in your documentation. It identifies specific `
` tags on your webpage and updates them with the latest version tag fetched from a specified repository, ensuring your documentation always displays up-to-date information.
+
+## How It Works
+
+PreUpVer operates by searching for `
` tags with a designated class (`preupver`) and using their data attributes to perform version updates. It simplifies the process of keeping your library references up-to-date in documentation.
+
+### Automatic Detection and Updating
+
+When the webpage loads, PreUpVer finds all `
` tags marked with the `preupver` class. It then extracts necessary details from their data attributes and updates each tag with the latest library version.
+
+### Usage
+
+1. **Marking `
` Tags:**
+
+   Add the `class="preupver"` to `
` tags in your HTML and define the required data attributes for automatic updating:
+
+   ```html
+   
+   
+ ``` + + Replace `unique-id`, `username`, `library`, and other placeholders with your specific details. + +2. **Attributes Explained:** + + - `id`: A unique identifier for the `
` tag.
+   - `data-api-url`: The API URL to fetch the latest library version.
+   - `data-description`: A brief description of the library script.
+   - `data-url`: The URL of the script, where `${version}` will be replaced with the latest version number.
+
+### Example
+
+Check out the [tests](https://git.vdm.dev/Llewellyn/PreUpVer/src/branch/master/tests/) folder for the examples we use to test if this library works as expected.
+
+# Build Details
+
++ *Author*: [Llewellyn van der Merwe](mailto:joomla@vdm.io)
++ *Name*: [PreUpVer Loader](https://git.vdm.dev/Llewellyn/PreUpVer)
++ *First Build*: 17th February, 2023
++ *Last Build*: 28th November, 2023
++ *Version*: 1.0.0
++ *Copyright*: Copyright (C) 2022. All Rights Reserved
++ *License*: GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html
+
+> This **plugin** was build with a Joomla [Automated Component Builder](https://www.joomlacomponentbuilder.com).
+> Developed by [Llewellyn van der Merwe](mailto:joomla@vdm.io)
\ No newline at end of file
diff --git a/index.html b/index.html
new file mode 100644
index 0000000..fa6d84e
--- /dev/null
+++ b/index.html
@@ -0,0 +1 @@
+
\ No newline at end of file
diff --git a/language/en-GB/en-GB.plg_system_preupverloader.ini b/language/en-GB/en-GB.plg_system_preupverloader.ini
new file mode 100644
index 0000000..a452f25
--- /dev/null
+++ b/language/en-GB/en-GB.plg_system_preupverloader.ini
@@ -0,0 +1,3 @@
+PLG_SYSTEM_PREUPVERLOADER="System - PreUpVerLoader"
+PLG_SYSTEM_PREUPVERLOADER_DESCRIPTION="This plugin is used to load PreUpVer on your website. So it adds https://cdn.jsdelivr.net/gh/Llewellynvdm/PreUpVer@1.0.0/dist/js/preupver.min.js to the header of your website. See: https://git.vdm.dev/Llewellyn/PreUpVer for more details."
+PLG_SYSTEM_PREUPVERLOADER_XML_DESCRIPTION="

System - PreUpVerLoader (v.1.0.0)

This plugin is used to load PreUpVer on your website. So it adds https://cdn.jsdelivr.net/gh/Llewellynvdm/PreUpVer@1.0.0/dist/js/preupver.min.js to the header of your website. See: https://git.vdm.dev/Llewellyn/PreUpVer for more details.

Created by Llewellyn van der Merwe
Development started 28th November, 2023

" \ No newline at end of file diff --git a/language/en-GB/en-GB.plg_system_preupverloader.sys.ini b/language/en-GB/en-GB.plg_system_preupverloader.sys.ini new file mode 100644 index 0000000..a452f25 --- /dev/null +++ b/language/en-GB/en-GB.plg_system_preupverloader.sys.ini @@ -0,0 +1,3 @@ +PLG_SYSTEM_PREUPVERLOADER="System - PreUpVerLoader" +PLG_SYSTEM_PREUPVERLOADER_DESCRIPTION="This plugin is used to load PreUpVer on your website. So it adds https://cdn.jsdelivr.net/gh/Llewellynvdm/PreUpVer@1.0.0/dist/js/preupver.min.js to the header of your website. See: https://git.vdm.dev/Llewellyn/PreUpVer for more details." +PLG_SYSTEM_PREUPVERLOADER_XML_DESCRIPTION="

System - PreUpVerLoader (v.1.0.0)

This plugin is used to load PreUpVer on your website. So it adds https://cdn.jsdelivr.net/gh/Llewellynvdm/PreUpVer@1.0.0/dist/js/preupver.min.js to the header of your website. See: https://git.vdm.dev/Llewellyn/PreUpVer for more details.

Created by Llewellyn van der Merwe
Development started 28th November, 2023

" \ No newline at end of file diff --git a/language/en-GB/index.html b/language/en-GB/index.html new file mode 100644 index 0000000..fa6d84e --- /dev/null +++ b/language/en-GB/index.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/language/index.html b/language/index.html new file mode 100644 index 0000000..fa6d84e --- /dev/null +++ b/language/index.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/preupverloader.php b/preupverloader.php new file mode 100644 index 0000000..54a2335 --- /dev/null +++ b/preupverloader.php @@ -0,0 +1,51 @@ + + * @copyright Copyright (C) 2022. All Rights Reserved + * @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + * + * Joomla Extension + */ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +use Joomla\CMS\Plugin\CMSPlugin; +use Joomla\CMS\Html\HTMLHelper; + +/** + * System - PreUpVerLoader plugin. + * + * @package PreUpVerLoader + * @since 1.0.0 + */ +class PlgSystemPreUpVerLoader extends CMSPlugin +{ + /** + * Application object + * + * @var CMSApplication + * @since 1.0.0 + */ + protected $app; + + /** + * This method is called before the head is compiled and allows manipulation of the head data. + * In this case, it's used to add a JavaScript file to the front end of the Joomla site. + * + * @return void + * + * @since 3.0.0 + * @throws Exception on error. + */ + public function onBeforeCompileHead() + { + // Check if we are in the site application + if ($this->app->isClient('site')) { + HTMLHelper::_('script', 'https://cdn.jsdelivr.net/gh/Llewellynvdm/PreUpVer@1.0.0/dist/js/preupver.min.js', ['version' => 'auto']); + } + } +} diff --git a/preupverloader.xml b/preupverloader.xml new file mode 100644 index 0000000..ad341a6 --- /dev/null +++ b/preupverloader.xml @@ -0,0 +1,29 @@ + + + PLG_SYSTEM_PREUPVERLOADER + 28th November, 2023 + Llewellyn van der Merwe + octoleo@vdm.io + https://git.vdm.dev/Llewellyn + Copyright (C) 2022. All Rights Reserved + GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + 1.0.0 + PLG_SYSTEM_PREUPVERLOADER_XML_DESCRIPTION + + + script.php + + + + en-GB/en-GB.plg_system_preupverloader.ini + en-GB/en-GB.plg_system_preupverloader.sys.ini + + + + + preupverloader.php + README.md + index.html + language + + \ No newline at end of file diff --git a/script.php b/script.php new file mode 100644 index 0000000..4333c00 --- /dev/null +++ b/script.php @@ -0,0 +1,57 @@ + + * @copyright Copyright (C) 2022. All Rights Reserved + * @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + * + * Joomla Extension + */ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +/** + * System - PreUpVerLoader script file. + * + * @package PlgSystemPreUpVerLoader + */ +class plgSystemPreUpVerLoaderInstallerScript +{ + + /** + * Called before any type of action + * + * @param string $route Which action is happening (install|uninstall|discover_install|update) + * @param Joomla\CMS\Installer\InstallerAdapter $adapter The object responsible for running this script + * + * @return boolean True on success + */ + public function preflight($route, $adapter) + { + // get application + $app = JFactory::getApplication(); + + // the default for both install and update + $jversion = new JVersion(); + if (!$jversion->isCompatible('3.8.0')) + { + $app->enqueueMessage('Please upgrade to at least Joomla! 3.8.0 before continuing!', 'error'); + return false; + } + + if ('install' === $route) + { + $jversion = new JVersion(); + if (!$jversion->isCompatible('3.10.0')) { + $app->enqueueMessage('Please upgrade to at least Joomla! 3.10 before continuing!', 'error'); + return false; + } + + } + + return true; + } +}