first commit

This commit is contained in:
Llewellyn van der Merwe 2023-11-28 14:59:05 +02:00
commit f12b8bf91e
Signed by: Llewellyn
GPG Key ID: A9201372263741E7
9 changed files with 199 additions and 0 deletions

53
README.md Normal file
View File

@ -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 `<pre>` 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 `<pre>` 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 `<pre>` 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 `<pre>` Tags:**
Add the `class="preupver"` to `<pre>` tags in your HTML and define the required data attributes for automatic updating:
```html
<pre id="unique-id" class="preupver"
data-api-url="https://api.github.com/repos/username/library/tags"
data-description="Description of the library script"
data-url="https://cdn.jsdelivr.net/gh/username/library@${version}/dist/library.min.js">
</pre>
```
Replace `unique-id`, `username`, `library`, and other placeholders with your specific details.
2. **Attributes Explained:**
- `id`: A unique identifier for the `<pre>` 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)

1
index.html Normal file
View File

@ -0,0 +1 @@
<html><body bgcolor="#FFFFFF"></body></html>

View File

@ -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="<h1>System - PreUpVerLoader (v.1.0.0)</h1> <div style='clear: both;'></div><p>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.</p><p>Created by <a href='https://git.vdm.dev/Llewellyn' target='_blank'>Llewellyn van der Merwe</a><br /><small>Development started 28th November, 2023</small></p>"

View File

@ -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="<h1>System - PreUpVerLoader (v.1.0.0)</h1> <div style='clear: both;'></div><p>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.</p><p>Created by <a href='https://git.vdm.dev/Llewellyn' target='_blank'>Llewellyn van der Merwe</a><br /><small>Development started 28th November, 2023</small></p>"

View File

@ -0,0 +1 @@
<html><body bgcolor="#FFFFFF"></body></html>

1
language/index.html Normal file
View File

@ -0,0 +1 @@
<html><body bgcolor="#FFFFFF"></body></html>

51
preupverloader.php Normal file
View File

@ -0,0 +1,51 @@
<?php
/**
* @package Octoleo
*
* @created 17th February, 2023
* @author Llewellyn van der Merwe <https://git.vdm.dev/Llewellyn>
* @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']);
}
}
}

29
preupverloader.xml Normal file
View File

@ -0,0 +1,29 @@
<?xml version="1.0" encoding="utf-8"?>
<extension type="plugin" version="3.10" group="system" method="upgrade">
<name>PLG_SYSTEM_PREUPVERLOADER</name>
<creationDate>28th November, 2023</creationDate>
<author>Llewellyn van der Merwe</author>
<authorEmail>octoleo@vdm.io</authorEmail>
<authorUrl>https://git.vdm.dev/Llewellyn</authorUrl>
<copyright>Copyright (C) 2022. All Rights Reserved</copyright>
<license>GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html</license>
<version>1.0.0</version>
<description>PLG_SYSTEM_PREUPVERLOADER_XML_DESCRIPTION</description>
<!-- Scripts to run on installation -->
<scriptfile>script.php</scriptfile>
<!-- Language files -->
<languages folder="language">
<language tag="en-GB">en-GB/en-GB.plg_system_preupverloader.ini</language>
<language tag="en-GB">en-GB/en-GB.plg_system_preupverloader.sys.ini</language>
</languages>
<!-- Plugin files -->
<files>
<filename plugin="preupverloader">preupverloader.php</filename>
<filename>README.md</filename>
<filename>index.html</filename>
<folder>language</folder>
</files>
</extension>

57
script.php Normal file
View File

@ -0,0 +1,57 @@
<?php
/**
* @package Octoleo
*
* @created 17th February, 2023
* @author Llewellyn van der Merwe <https://git.vdm.dev/Llewellyn>
* @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;
}
}