Skip to content

Commit

Permalink
Required plugins
Browse files Browse the repository at this point in the history
  • Loading branch information
philwareham committed Jul 7, 2020
1 parent e92c15c commit 9fcd4d6
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 0 deletions.
36 changes: 36 additions & 0 deletions src/templates/forms/misc/json_card_reader.txp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@
* Possible variables:
*
* <txp:variable name="json-repo-XXX" /> (where XXX is either homepage, bitbucket, github, gitlab - variable stores URL of project at that repo)
* <txp:variable name="json-require-plugin" /> (name of a plugin this plugin requires to be installed)
* <txp:variable name="json-require-match" /> (version match text of plugin this plugin requires to be installed)
* <txp:variable name="json-require-version" /> (version a plugin this plugin requires to be installed)
* <txp:variable name="json-beta-version" /> (latest semver of beta release)
* <txp:variable name="json-beta-manifest" /> (does plugin beta release have a manifest.json file?)
* <txp:variable name="json-beta-date" /> (date of latest PHP download beta release)
Expand Down Expand Up @@ -46,6 +49,39 @@ if (is_readable($file)) {
}
}

if (!empty($json->require)) {
foreach ($json->require as $rplug => $rver) {
$vars['require-plug-name'] = '<txp:variable name="json-require-plugin">'.txpspecialchars($rplug).'</txp:variable>';

preg_match('/([\<\=\>]+)?([\d.]+)/', $rver, $matches);
$matchType = 'equal';

switch ($matches[1]) {
case '>':
$matchType = 'greater than';
break;
case '>=':
$matchType = 'at least';
break;
case '<':
$matchType = 'less than';
break;
case '<=':
$matchType = 'no greater than';
break;
case '=':
default:
$matchType = 'equal';
break;
}

$plain_ver = $matches[2];

$vars['require-plug-match'] = '<txp:variable name="json-require-match">'.txpspecialchars($matchType).'</txp:variable>';
$vars['require-plug-version'] = '<txp:variable name="json-require-version">'.txpspecialchars($plain_ver).'</txp:variable>';
}
}

if (!empty($json->beta)) {
$vars['beta-version'] = '<txp:variable name="json-beta-version">'.txpspecialchars($json->beta->version).'</txp:variable>';

Expand Down
8 changes: 8 additions & 0 deletions src/templates/pages/plugins.txp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@
<txp:variable name="body"><txp:article><txp:body /></txp:article></txp:variable>
<txp:header value="application/json; charset=utf-8" />{
"name": "<txp:title escape="json" />",
<txp:if_variable name="json-require-plugin">
"require": {
"<txp:variable name="json-require-plugin" escape="json" />": "<txp:if_variable name="json-require-match" value="greater than">></txp:if_variable><txp:if_variable name="json-require-match" value="at least">>=</txp:if_variable><txp:if_variable name="json-require-match" value="less than"><</txp:if_variable><txp:if_variable name="json-require-match" value="no greater than"><=</txp:if_variable><txp:if_variable name="json-require-match" value="equal">=</txp:if_variable><txp:variable name="json-require-version" escape="json" />"
},
</txp:if_variable>
<txp:if_variable name="superseded-by-type">
"supersededBy": {
"name": "<txp:variable name="superseded-by-type" escape="json" />",
Expand Down Expand Up @@ -292,6 +297,9 @@ if (!empty($json2['legacy'])) {
<txp:excerpt />
</div>
</txp:if_excerpt>
<txp:if_variable name="json-require-plugin">
<p class="alert-block warning"><strong>Note:</strong> This plugin requires an additional plugin to also be installed: <a href="https://plugins.textpattern.com/plugins/<txp:variable name="json-require-plugin" />"><txp:variable name="json-require-plugin" /></a>, version <txp:variable name="json-require-match" /> <txp:variable name="json-require-version" />.</p>
</txp:if_variable>
<txp:article><txp:body /></txp:article>
<txp:if_variable not name="json-name">
<p class="alert-block error">Plugin resources not currently available. If this problem persists, <a href="https://github.com/textpattern/textpattern-curated-plugins-list/issues/new?labels=plugin-broken&amp;template=report-a-broken-textpattern-plugin-listing.md&amp;title=%5BBROKEN%5D+<txp:title escape="json" />">open an issue</a> and we’ll investigate.</p>
Expand Down

0 comments on commit 9fcd4d6

Please sign in to comment.