Skip to content
This repository has been archived by the owner on Aug 27, 2024. It is now read-only.

Commit

Permalink
v0.12.0: Generate button added to Grav Admin (#5)
Browse files Browse the repository at this point in the history
  • Loading branch information
Barry authored and Barry committed Mar 29, 2018
1 parent 52751b6 commit 7a69817
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 9 deletions.
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
# v0.12.0
## 3/29/2018

1. [](#new)
* Generate button added to Grav admin ([#5](https://github.com/barrymode/grav-plugin-blackhole/issues/5))
1. [](#improved)
* Assets no longer logs errors when processing data URIs
* Assets ignores canonical links

# v0.11.2
## 3/28/2018

1. [](#improved)
* Breaking change: `--copy-assets` -> `--assets`
* Assets has been simplified and no longer accepts input.
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ The **Blackhole** Plugin is for [Grav CMS](http://github.com/getgrav/grav).

Why Blackhole? Grav is a space term, so I think this plugin should follow suit. Time stops at the event horizon of a black hole, which is exactly what this plugin does to your website. It freezes it in a state. By Increasing **grav**ity to infinity you get a **static** black hole, or in this case you generate a **static** html copy of your **Grav** website.

*Currently, Blackhole only supports pages.*
*Currently, Blackhole doesn't support taxonomy.*

## Installation

Expand All @@ -25,7 +25,7 @@ If you can't use GPM you can manually install this plugin. Download the zip vers

### Generate Command

Generate your static site. `generate` can also be written as `gen` or `g`.
The generate command can be used from the command line or directly in the Grav Admin Panel. Generate your static site. `generate` can also be written as `gen` or `g`.

- **Input URL** (required) - Set the URL of your live Grav site.

Expand Down
14 changes: 9 additions & 5 deletions blackhole.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,6 @@ public function onPageInitialized() {
if (!empty($_GET['pages']) && $_GET['pages'] == 'all') {
ob_start();

// get output_path from plugin settings
$output_path = $this->config->get('plugins.blackhole.output_path');

// get all routes from grav
$routes = $this->grav['pages']->routes();

Expand All @@ -31,9 +28,12 @@ public function onPageInitialized() {
unset($routes[$path]);
}
}

// set the content for ?pages=all
$this->content = json_encode($routes, JSON_UNESCAPED_SLASHES);
} else if (!empty($_GET['generate']) && $_GET['generate'] == 'true') {
// get generate_command from plugin settings
$generate_command = $this->config->get('plugins.blackhole.generate_command');

$this->content = $generate_command;
}
}

Expand All @@ -43,5 +43,9 @@ public function onOutputRendered() {
ob_end_clean();
echo $this->content;
}
// action for generate button
if (!empty($_GET['generate']) && $_GET['generate'] == 'true') {
shell_exec('bin/plugin blackhole generate ' . $this->content);
}
}
}
9 changes: 7 additions & 2 deletions blueprints.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: Blackhole
version: 0.11.2
version: 0.12.0
description: Static site generator for Grav
icon: circle
author:
Expand All @@ -22,4 +22,9 @@ form:
1: Enabled
0: Disabled
validate:
type: bool
type: bool

generate_command:
type: text
label: '<a class="button" href="?generate=true"><i class="fa fa-fw fa-circle"></i> Generate</a><style>.form-data.block.size-2-3[data-grav-field="text"]:before { font-weight: bold; content: "bin/plugin blackhole generate"; } .form-data.block.size-2-3[data-grav-field="text"] .form-input-wrapper { display: inline-block; width: 50%; }</style>'
default:

0 comments on commit 7a69817

Please sign in to comment.