Skip to content

Commit

Permalink
Automatic Content Deploy
Browse files Browse the repository at this point in the history
  • Loading branch information
Skullbock committed Feb 12, 2020
1 parent ae2fa3a commit 1aba6c2
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 5 deletions.
4 changes: 3 additions & 1 deletion language/en-GB/en-GB.plg_system_sitesauce.ini
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,6 @@ PLG_SYSTEM_SITESAUCE_QUICKICON_LABEL_DESC="The text used in the QuickIcon"
PLG_SYSTEM_SITESAUCE_QUICKICON_ICON_LABEL="QuickIcon Icon"
PLG_SYSTEM_SITESAUCE_QUICKICON_ICON_DESC="The FontAwesome Icon used in the QuickIcon"
PLG_SYSTEM_SITESAUCE_DEPLOY_STARTED="Deploy Started"
PLG_SYSTEM_SITESAUCE_DEPLOY_FAILED="Deploy Started"
PLG_SYSTEM_SITESAUCE_DEPLOY_FAILED="Deploy Started"
PLG_SYSTEM_SITESAUCE_ENABLE_AUTODEPLOY_LABEL="Enable Automaic Deploy"
PLG_SYSTEM_SITESAUCE_ENABLE_AUTODEPLOY_DESC="Deploy the site after each content save / delete / publish / unpublish"
28 changes: 24 additions & 4 deletions sitesauce.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,21 @@ class plgSystemSitesauce extends JPlugin
*/
protected $app;

/***
* @param $context
* @return array|void
*/
public function onContentAfterSave()
{
$this->automaticDeploy();
}

public function onContentAfterDelete()
{
$this->automaticDeploy();
}

public function onContentChangeState()
{
$this->automaticDeploy();
}

public function onGetIcons($context)
{
if ($context !== 'mod_quickicon') {
Expand Down Expand Up @@ -84,4 +95,13 @@ protected function deploy()
$this->app->enqueueMessage('PLG_SYSTEM_SITESAUCE_DEPLOY_FAILED');
$this->app->redirect(\JRoute::_('index.php', false));
}

protected function automaticDeploy()
{
if (!$this->params->get('autodeploy', false)) {
return;
}

JHttpFactory::getHttp()->get($this->params->get('build_hook'));
}
}
4 changes: 4 additions & 0 deletions sitesauce.xml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@
<option value="1">JYES</option>
<option value="0">JNO</option>
</field>
<field name="autodeploy" type="list" default="0" size="255" label="PLG_SYSTEM_SITESAUCE_ENABLE_AUTODEPLOY_LABEL" description="PLG_SYSTEM_SITESAUCE_ENABLE_AUTODEPLOY_DESC">
<option value="1">JYES</option>
<option value="0">JNO</option>
</field>
<field name="quickicon_label" type="text" default="Deploy Static Site" size="255" label="PLG_SYSTEM_SITESAUCE_QUICKICON_LABEL_LABEL" description="PLG_SYSTEM_SITESAUCE_QUICKICON_LABEL_DESC" />
<field name="quickicon_icon" type="text" default="star" size="255" label="PLG_SYSTEM_SITESAUCE_QUICKICON_ICON_LABEL" description="PLG_SYSTEM_SITESAUCE_QUICKICON_ICON_DESC" />
</fieldset>
Expand Down

0 comments on commit 1aba6c2

Please sign in to comment.