Skip to content

Commit

Permalink
Allow to see plugins and themes list without internet connection. Als…
Browse files Browse the repository at this point in the history
…o add a more helpful message in the "add" view. re getgrav/grav#1008
  • Loading branch information
flaviocopes committed Jan 22, 2017
1 parent d6afa39 commit 2c58db3
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 18 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@

1. [](#improved)
* It is now possible to manually specify a format for the `datetime` field [#1261](https://github.com/getgrav/grav/issues/1261)
* Allow to see plugins and themes list without internet connection. Also add a more helpful message in the "add" view [grav#1008](https://github.com/getgrav/grav/issues/1008)
1. [](#bugfix)
* Fixed issue with downloaded package when installing a testing release

# v1.2.9
## 01/18/2017

Expand Down
44 changes: 30 additions & 14 deletions classes/admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -708,15 +708,21 @@ public function plugins($local = true)
return false;
}

return $local
? $gpm->getInstalledPlugins()
: $gpm->getRepositoryPlugins()->filter(function (
$package,
$slug
) use ($gpm) {
return !$gpm->isPluginInstalled($slug);
})
;
if ($local) {
return $gpm->getInstalledPlugins();
} else {
$plugins = $gpm->getRepositoryPlugins();
if ($plugins) {
return $plugins->filter(function (
$package,
$slug
) use ($gpm) {
return !$gpm->isPluginInstalled($slug);
});
} else {
return [];
}
}
}

/**
Expand All @@ -734,11 +740,21 @@ public function themes($local = true)
return false;
}

return $local
? $gpm->getInstalledThemes()
: $gpm->getRepositoryThemes()->filter(function ($package, $slug) use ($gpm) {
return !$gpm->isThemeInstalled($slug);
});
if ($local) {
return $gpm->getInstalledThemes();
} else {
$themes = $gpm->getRepositoryThemes();
if ($themes) {
return $themes->filter(function (
$package,
$slug
) use ($gpm) {
return !$gpm->isThemeInstalled($slug);
});
} else {
return [];
}
}
}

/**
Expand Down
3 changes: 2 additions & 1 deletion languages/en.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -632,4 +632,5 @@ PLUGIN_ADMIN:
NEVER_CACHE_TWIG: "Never Cache Twig"
NEVER_CACHE_TWIG_HELP: "Only cache content and process Twig every time for pages. Ignores twig_first setting."
ALLOW_WEBSERVER_GZIP: "Allow WebServer Gzip"
ALLOW_WEBSERVER_GZIP_HELP: "Off by default. When enabled, WebServer-configured Gzip/Deflate compression will work, but http connection will not be closed before onShutDown() event causing slower page loading"
ALLOW_WEBSERVER_GZIP_HELP: "Off by default. When enabled, WebServer-configured Gzip/Deflate compression will work, but http connection will not be closed before onShutDown() event causing slower page loading"
OFFLINE_WARNING: "The connection to the GPM cannot be established"
4 changes: 3 additions & 1 deletion themes/grav/templates/partials/plugins-list.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
{% for slug, plugin in admin.plugins(not installing).toArray|ksort %}
{% set data = admin.data('plugins/' ~ slug) %}
{% set isTestingRelease = admin.gpm.isTestingRelease(slug) %}
{% set releaseDate = plugin.date ?: admin.gpm.findPackage(slug).date %}
{% set releaseDate = plugin.date ?: admin.gpm.findPackage(slug, true).date %}

<tr data-gpm-plugin="{{ slug|url_encode }}" data-gpm-name="{{ plugin.name }}" data-gpm-release-date="{{ releaseDate }}" data-gpm-author="{{ plugin.author.name }}" data-gpm-official="{{ admin.isTeamGrav(plugin) ? '1' : '2' }}" data-gpm-updatable="{{ admin.gpm.isUpdatable(slug) ? '1' : '2' }}" data-gpm-enabled="{{ data.get('enabled') ? '1' : '2' }}" data-gpm-testing="{{ isTestingRelease ? '1' : '2' }}">
<td class="gpm-name quadruple">
Expand Down Expand Up @@ -65,6 +65,8 @@
</div>
</td>
</tr>
{% else %}
<tr><td>{{ "PLUGIN_ADMIN.OFFLINE_WARNING"|tu }}</td></tr>
{% endfor %}
</table>

Expand Down
4 changes: 3 additions & 1 deletion themes/grav/templates/partials/themes-list.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
{% if (installing) %}{% set state = 'installing' %}{% endif %}
{% if (config.get('system.pages.theme') == slug) %}{% set state = 'active' %}{% endif %}
{% set isTestingRelease = admin.gpm.isTestingRelease(slug) %}
{% set releaseDate = theme.date ?: admin.gpm.findPackage(slug).date %}
{% set releaseDate = theme.date ?: admin.gpm.findPackage(slug, true).date %}

<div class="theme card-item pure-u-1-3 {{ state }}-theme" data-gpm-theme="{{ slug|url_encode }}" data-gpm-name="{{ theme.name }}" data-gpm-release-date="{{ releaseDate }}" data-gpm-author="{{ theme.author.name }}" data-gpm-official="{{ admin.isTeamGrav(theme) ? '1' : '2' }}" data-gpm-updatable="{{ admin.gpm.isUpdatable(slug) ? '1' : '2' }}" data-gpm-enabled="{{ data.get('enabled') ? '1' : '2' }}" data-gpm-testing="{{ isTestingRelease ? '1' : '2' }}">
<div class="gpm-name">
Expand Down Expand Up @@ -56,6 +56,8 @@
</a>
{% endif %}
</div>
{% else %}
<tr><td>{{ "PLUGIN_ADMIN.OFFLINE_WARNING"|tu }}</td></tr>
{% endfor %}
</div>

Expand Down

0 comments on commit 2c58db3

Please sign in to comment.