mirror of
https://github.com/getgrav/grav-plugin-admin.git
synced 2025-11-03 03:46:30 +01:00
Support for Premium Resources (#809)
* Initial premium preparation for licenses and gpm handling * Premium styling * Removed unused import * Synced CSS * Updated selectize
This commit is contained in:
@@ -5,6 +5,7 @@ use DateTime;
|
|||||||
use Grav\Common\Data;
|
use Grav\Common\Data;
|
||||||
use Grav\Common\File\CompiledYamlFile;
|
use Grav\Common\File\CompiledYamlFile;
|
||||||
use Grav\Common\GPM\GPM;
|
use Grav\Common\GPM\GPM;
|
||||||
|
use Grav\Common\GPM\Licenses;
|
||||||
use Grav\Common\GPM\Response;
|
use Grav\Common\GPM\Response;
|
||||||
use Grav\Common\Grav;
|
use Grav\Common\Grav;
|
||||||
use Grav\Common\Language\LanguageCodes;
|
use Grav\Common\Language\LanguageCodes;
|
||||||
@@ -472,7 +473,7 @@ class Admin
|
|||||||
*
|
*
|
||||||
* @param bool $local
|
* @param bool $local
|
||||||
*
|
*
|
||||||
* @return array
|
* @return mixed
|
||||||
*/
|
*/
|
||||||
public function plugins($local = true)
|
public function plugins($local = true)
|
||||||
{
|
{
|
||||||
@@ -500,6 +501,11 @@ class Admin
|
|||||||
return $package;
|
return $package;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function license($package_slug)
|
||||||
|
{
|
||||||
|
return Licenses::get($package_slug);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Generate an array of dependencies for a package, used to generate a list of
|
* Generate an array of dependencies for a package, used to generate a list of
|
||||||
* packages that can be removed when removing a package.
|
* packages that can be removed when removing a package.
|
||||||
@@ -932,6 +938,22 @@ class Admin
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Determine if the plugin or theme info passed is premium
|
||||||
|
*
|
||||||
|
* @param object $info Plugin or Theme info object
|
||||||
|
*
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
public function isPremiumProduct($info)
|
||||||
|
{
|
||||||
|
if (isset($info['premium'])) {
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Renders phpinfo
|
* Renders phpinfo
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ namespace Grav\Plugin\Admin;
|
|||||||
|
|
||||||
use Grav\Common\Grav;
|
use Grav\Common\Grav;
|
||||||
use Grav\Common\GPM\GPM as GravGPM;
|
use Grav\Common\GPM\GPM as GravGPM;
|
||||||
|
use Grav\Common\GPM\Licenses;
|
||||||
use Grav\Common\GPM\Installer;
|
use Grav\Common\GPM\Installer;
|
||||||
use Grav\Common\GPM\Response;
|
use Grav\Common\GPM\Response;
|
||||||
use Grav\Common\GPM\Upgrader;
|
use Grav\Common\GPM\Upgrader;
|
||||||
@@ -92,7 +93,8 @@ class Gpm
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
$local = static::download($package);
|
$license = Licenses::get($package->slug);
|
||||||
|
$local = static::download($package, $license);
|
||||||
|
|
||||||
Installer::install($local, $options['destination'],
|
Installer::install($local, $options['destination'],
|
||||||
['install_path' => $package->install_path, 'theme' => $options['theme']]);
|
['install_path' => $package->install_path, 'theme' => $options['theme']]);
|
||||||
@@ -194,9 +196,28 @@ class Gpm
|
|||||||
*
|
*
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
private static function download(Package $package)
|
private static function download(Package $package, $license = null)
|
||||||
{
|
{
|
||||||
$contents = Response::get($package->zipball_url, []);
|
$query = '';
|
||||||
|
|
||||||
|
if ($package->premium) {
|
||||||
|
$query = \json_encode(array_merge(
|
||||||
|
$package->premium,
|
||||||
|
[
|
||||||
|
'slug' => $package->slug,
|
||||||
|
'filename' => $package->premium['filename'],
|
||||||
|
'license_key' => $license
|
||||||
|
]
|
||||||
|
));
|
||||||
|
|
||||||
|
$query = '?d=' . base64_encode($query);
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
$contents = Response::get($package->zipball_url . $query, []);
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
throw new \RuntimeException($e->getMessage());
|
||||||
|
}
|
||||||
|
|
||||||
$tmp_dir = Admin::getTempDir() . '/Grav-' . uniqid();
|
$tmp_dir = Admin::getTempDir() . '/Grav-' . uniqid();
|
||||||
Folder::mkdir($tmp_dir);
|
Folder::mkdir($tmp_dir);
|
||||||
|
|||||||
@@ -610,6 +610,7 @@ PLUGIN_ADMIN:
|
|||||||
DROPZONE_MAX_FILES_EXCEEDED: "You can not upload any more files."
|
DROPZONE_MAX_FILES_EXCEEDED: "You can not upload any more files."
|
||||||
DROPZONE_REMOVE_FILE: "Remove file"
|
DROPZONE_REMOVE_FILE: "Remove file"
|
||||||
DROPZONE_RESPONSE_ERROR: "Server responded with {{statusCode}} code."
|
DROPZONE_RESPONSE_ERROR: "Server responded with {{statusCode}} code."
|
||||||
|
PREMIUM_PRODUCT: "Premium"
|
||||||
ADMIN_CACHING: "Enable Admin Caching"
|
ADMIN_CACHING: "Enable Admin Caching"
|
||||||
ADMIN_CACHING_HELP: "Caching in the admin can be controlled independently from the front-end site"
|
ADMIN_CACHING_HELP: "Caching in the admin can be controlled independently from the front-end site"
|
||||||
DESTINATION_NOT_SPECIFIED: "Destination not specified"
|
DESTINATION_NOT_SPECIFIED: "Destination not specified"
|
||||||
|
|||||||
2
themes/grav/css-compiled/preset.css
vendored
2
themes/grav/css-compiled/preset.css
vendored
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
2
themes/grav/css-compiled/template.css
vendored
2
themes/grav/css-compiled/template.css
vendored
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
2
themes/grav/js/vendor.min.js
vendored
2
themes/grav/js/vendor.min.js
vendored
File diff suppressed because one or more lines are too long
@@ -27,7 +27,7 @@
|
|||||||
"js-yaml": "^3.6.1",
|
"js-yaml": "^3.6.1",
|
||||||
"mout": "^1.0.0",
|
"mout": "^1.0.0",
|
||||||
"remodal": "^1.1.0",
|
"remodal": "^1.1.0",
|
||||||
"selectize": "^0.12.3",
|
"selectize": "^0.12.4",
|
||||||
"sortablejs": "^1.4.2",
|
"sortablejs": "^1.4.2",
|
||||||
"speakingurl": "^10.0.0",
|
"speakingurl": "^10.0.0",
|
||||||
"toastr": "^2.1.2",
|
"toastr": "^2.1.2",
|
||||||
|
|||||||
@@ -254,6 +254,12 @@ tr {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#admin-main .admin-block a.gumroad-button {
|
||||||
|
background: $critical-bg !important;
|
||||||
|
color: $critical-text !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
#admin-login-wrapper {
|
#admin-login-wrapper {
|
||||||
background: radial-gradient(circle at center, lighten($page-bg, 10%) 0%, darken($page-bg, 10%) 100%);
|
background: radial-gradient(circle at center, lighten($page-bg, 10%) 0%, darken($page-bg, 10%) 100%);
|
||||||
}
|
}
|
||||||
@@ -940,6 +946,10 @@ form {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.notice-reverse, .note-reverse {
|
||||||
|
color: $notice-bg;
|
||||||
|
}
|
||||||
|
|
||||||
.error, .warning {
|
.error, .warning {
|
||||||
background: $critical-bg;
|
background: $critical-bg;
|
||||||
color: $critical-text;
|
color: $critical-text;
|
||||||
@@ -960,6 +970,10 @@ form {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.error-reverse, .warning-reverse {
|
||||||
|
color: $critical-bg;
|
||||||
|
}
|
||||||
|
|
||||||
.primary-accent {
|
.primary-accent {
|
||||||
background: darken($primary-accent-bg, 5%);
|
background: darken($primary-accent-bg, 5%);
|
||||||
color: $primary-accent-fg;
|
color: $primary-accent-fg;
|
||||||
|
|||||||
@@ -101,3 +101,18 @@
|
|||||||
left: 0;
|
left: 0;
|
||||||
z-index: 990;
|
z-index: 990;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Override style for stubborn gumroad button
|
||||||
|
#admin-main .admin-block a.gumroad-button {
|
||||||
|
padding: 0.3rem 1.5rem !important;
|
||||||
|
font-size: inherit !important;
|
||||||
|
font-weight: 300 !important;
|
||||||
|
line-height: inherit !important;
|
||||||
|
font-family: inherit !important;
|
||||||
|
border-radius: 4px !important;
|
||||||
|
box-shadow: inherit !important;
|
||||||
|
.gumroad-button-logo {
|
||||||
|
display: none !important;
|
||||||
|
background-image: none !important;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
{% set installed = gpm.isPluginInstalled(admin.route) %}
|
{% set installed = gpm.isPluginInstalled(admin.route) %}
|
||||||
{% set isTestingRelease = gpm.isTestingRelease(plugin.slug) %}
|
{% set isTestingRelease = gpm.isTestingRelease(plugin.slug) %}
|
||||||
|
|
||||||
|
<script src="//gumroad.com/js/gumroad.js"></script>
|
||||||
<div class="grav-update plugin" data-gpm-plugin="{{ admin.route }}">
|
<div class="grav-update plugin" data-gpm-plugin="{{ admin.route }}">
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@@ -10,6 +11,9 @@
|
|||||||
{% if admin.isTeamGrav(plugin) %}
|
{% if admin.isTeamGrav(plugin) %}
|
||||||
<small><span class="info-reverse"><i class="fa fa-check-circle" title="{{ "PLUGIN_ADMIN.GRAV_OFFICIAL_PLUGIN"|tu }}"></i></span></small>
|
<small><span class="info-reverse"><i class="fa fa-check-circle" title="{{ "PLUGIN_ADMIN.GRAV_OFFICIAL_PLUGIN"|tu }}"></i></span></small>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
{% if admin.isPremiumProduct(plugin) %}
|
||||||
|
<small><span class="badge warning premium"><i class="fa fa-star-o"></i> {{ "PLUGIN_ADMIN.PREMIUM_PRODUCT"|tu }}</span></small>
|
||||||
|
{% endif %}
|
||||||
{% if plugin.symlink %}
|
{% if plugin.symlink %}
|
||||||
<small class="hint--bottom" data-hint="{{ "PLUGIN_ADMIN.PLUGIN_SYMBOLICALLY_LINKED"|tu }}">
|
<small class="hint--bottom" data-hint="{{ "PLUGIN_ADMIN.PLUGIN_SYMBOLICALLY_LINKED"|tu }}">
|
||||||
<i class="fa fa-fw fa-link"></i>
|
<i class="fa fa-fw fa-link"></i>
|
||||||
@@ -36,7 +40,11 @@
|
|||||||
|
|
||||||
{% else %}
|
{% else %}
|
||||||
<div class="button-bar success">
|
<div class="button-bar success">
|
||||||
<a class="button" href="#" data-remodal-target="add-package" data-packages-slugs="{{ plugin.slug }}" data-plugin-action="start-package-installation"><i class="fa fa-plus"></i> {{ "PLUGIN_ADMIN.INSTALL_PLUGIN"|tu }}</a>
|
{% if (plugin.premium and not admin.license(plugin.slug)) %}
|
||||||
|
<a class="gumroad-button button" href="https://gum.co/{{ plugin.premium.product_permalink }}" target="_blank" data-gumroad-single-product="true"><i class="fa fa-shopping-cart"></i> {{ "Buy Now"|tu }}</a>
|
||||||
|
{% else %}
|
||||||
|
<a class="button" href="#" data-remodal-target="add-package" data-packages-slugs="{{ plugin.slug }}" data-plugin-action="start-package-installation"><i class="fa fa-plus"></i> {{ "PLUGIN_ADMIN.INSTALL_PLUGIN"|tu }}</a>
|
||||||
|
{% endif %}
|
||||||
</div>
|
</div>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
<script src="//gumroad.com/js/gumroad.js"></script>
|
||||||
<div class="grav-update plugins"></div>
|
<div class="grav-update plugins"></div>
|
||||||
{% if installing %}
|
{% if installing %}
|
||||||
{% include 'partials/release-toggle.html.twig' %}
|
{% include 'partials/release-toggle.html.twig' %}
|
||||||
@@ -25,6 +26,9 @@
|
|||||||
{% if admin.isTeamGrav(plugin) %}
|
{% if admin.isTeamGrav(plugin) %}
|
||||||
<small><span class="info-reverse"><i class="fa fa-check-circle" title="{{ "PLUGIN_ADMIN.GRAV_OFFICIAL_PLUGIN"|tu }}"></i></span></small>
|
<small><span class="info-reverse"><i class="fa fa-check-circle" title="{{ "PLUGIN_ADMIN.GRAV_OFFICIAL_PLUGIN"|tu }}"></i></span></small>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
{% if admin.isPremiumProduct(plugin) %}
|
||||||
|
<small><span class="badge warning premium"><i class="fa fa-star-o"></i> {{ "PLUGIN_ADMIN.PREMIUM_PRODUCT"|tu }}</span></small>
|
||||||
|
{% endif %}
|
||||||
{% if plugin.symlink %}
|
{% if plugin.symlink %}
|
||||||
<span class="hint--bottom" data-hint="{{ "PLUGIN_ADMIN.PLUGIN_SYMBOLICALLY_LINKED"|tu }}">
|
<span class="hint--bottom" data-hint="{{ "PLUGIN_ADMIN.PLUGIN_SYMBOLICALLY_LINKED"|tu }}">
|
||||||
<i class="fa fa-fw fa-link"></i>
|
<i class="fa fa-fw fa-link"></i>
|
||||||
@@ -39,7 +43,11 @@
|
|||||||
<i class="fa fa-fw fa-toggle-{{ data.get('enabled') ? 'on' : 'off' }}"></i>
|
<i class="fa fa-fw fa-toggle-{{ data.get('enabled') ? 'on' : 'off' }}"></i>
|
||||||
</a>
|
</a>
|
||||||
{% elseif (installing) %}
|
{% elseif (installing) %}
|
||||||
<a class="button" href="#" data-remodal-target="add-package" data-packages-slugs="{{ plugin.slug }}" data-plugin-action="start-package-installation"><i class="fa fa-plus"></i> {{ "PLUGIN_ADMIN.INSTALL"|tu }}</a>
|
{% if (plugin.premium and not admin.license(plugin.slug)) %}
|
||||||
|
<a class="gumroad-button button" href="https://gum.co/{{ plugin.premium.product_permalink }}" target="_blank" data-gumroad-single-product="true"><i class="fa fa-shopping-cart"></i> {{ "Buy Now"|tu }}</a>
|
||||||
|
{% else %}
|
||||||
|
<a class="button" href="#" data-remodal-target="add-package" data-packages-slugs="{{ plugin.slug }}" data-plugin-action="start-package-installation"><i class="fa fa-plus"></i> {{ "PLUGIN_ADMIN.INSTALL"|tu }}</a>
|
||||||
|
{% endif %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
<span class="gpm-details-expand"><i class="fa fa-chevron-down"></i></span>
|
<span class="gpm-details-expand"><i class="fa fa-chevron-down"></i></span>
|
||||||
</td>
|
</td>
|
||||||
|
|||||||
@@ -10,6 +10,9 @@
|
|||||||
{% if admin.isTeamGrav(theme) %}
|
{% if admin.isTeamGrav(theme) %}
|
||||||
<small><span class="info-reverse"><i class="fa fa-check-circle" title="Grav Official Theme"></i></span></small>
|
<small><span class="info-reverse"><i class="fa fa-check-circle" title="Grav Official Theme"></i></span></small>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
{% if admin.isPremiumProduct(theme) %}
|
||||||
|
<small><span class="badge warning premium"><i class="fa fa-star-o"></i> {{ "PLUGIN_ADMIN.PREMIUM_PRODUCT"|tu }}</span></small>
|
||||||
|
{% endif %}
|
||||||
{% if theme.symlink %}
|
{% if theme.symlink %}
|
||||||
<small class="hint--bottom" data-hint="{{ "PLUGIN_ADMIN.THEME_SYMBOLICALLY_LINKED"|tu }}">
|
<small class="hint--bottom" data-hint="{{ "PLUGIN_ADMIN.THEME_SYMBOLICALLY_LINKED"|tu }}">
|
||||||
<i class="fa fa-fw fa-link"></i>
|
<i class="fa fa-fw fa-link"></i>
|
||||||
|
|||||||
@@ -27,6 +27,9 @@
|
|||||||
{% if admin.isTeamGrav(theme) %}
|
{% if admin.isTeamGrav(theme) %}
|
||||||
<small><span class="info-reverse"><i class="fa fa-check-circle" title="{{ "PLUGIN_ADMIN.GRAV_OFFICIAL_THEME"|tu }}"></i></span></small>
|
<small><span class="info-reverse"><i class="fa fa-check-circle" title="{{ "PLUGIN_ADMIN.GRAV_OFFICIAL_THEME"|tu }}"></i></span></small>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
{% if admin.isPremiumProduct(theme) %}
|
||||||
|
<small><span class="badge warning premium"><i class="fa fa-star-o"></i> {{ "PLUGIN_ADMIN.PREMIUM_PRODUCT"|tu }}</span></small>
|
||||||
|
{% endif %}
|
||||||
{% if theme.symlink %}
|
{% if theme.symlink %}
|
||||||
<span class="hint--bottom" data-hint="{{ "PLUGIN_ADMIN.THEME_SYMBOLICALLY_LINKED"|tu }}">
|
<span class="hint--bottom" data-hint="{{ "PLUGIN_ADMIN.THEME_SYMBOLICALLY_LINKED"|tu }}">
|
||||||
<i class="fa fa-fw fa-link"></i>
|
<i class="fa fa-fw fa-link"></i>
|
||||||
|
|||||||
@@ -3788,9 +3788,9 @@ sax@~1.2.1:
|
|||||||
version "1.2.1"
|
version "1.2.1"
|
||||||
resolved "https://registry.yarnpkg.com/sax/-/sax-1.2.1.tgz#7b8e656190b228e81a66aea748480d828cd2d37a"
|
resolved "https://registry.yarnpkg.com/sax/-/sax-1.2.1.tgz#7b8e656190b228e81a66aea748480d828cd2d37a"
|
||||||
|
|
||||||
selectize@^0.12.3:
|
selectize@^0.12.4:
|
||||||
version "0.12.3"
|
version "0.12.4"
|
||||||
resolved "https://registry.yarnpkg.com/selectize/-/selectize-0.12.3.tgz#25a5c0a89e4c6c4da5e17ea311b1b530df46849d"
|
resolved "https://registry.yarnpkg.com/selectize/-/selectize-0.12.4.tgz#50c697526b609dea11da153cf7252b98948f4c0e"
|
||||||
dependencies:
|
dependencies:
|
||||||
microplugin "0.0.3"
|
microplugin "0.0.3"
|
||||||
sifter "^0.5.1"
|
sifter "^0.5.1"
|
||||||
|
|||||||
Reference in New Issue
Block a user