Skip to content

Commit ca46b6c

Browse files
author
Iain S Gillis
committed
initial commit
0 parents  commit ca46b6c

21 files changed

Lines changed: 1363 additions & 0 deletions

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# v0.1.0
2+
## 11/12/2021
3+
4+
1. [](#new)
5+
* ChangeLog started...

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
The MIT License (MIT)
2+
3+
Copyright (c) 2021 Iain Gillis
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
# Highlight Php Plugin
2+
3+
**This README.md file should be modified to describe the features, installation, configuration, and general usage of the plugin.**
4+
5+
The **Highlight Php** Plugin is an extension for [Grav CMS](http://github.com/getgrav/grav). Server-side syntax highlighting (i.e., without JavaScript) using the [highlight.php](https://github.com/scrivo/highlight.php) library
6+
7+
## Installation
8+
9+
Installing the Highlight Php plugin can be done in one of three ways: The GPM (Grav Package Manager) installation method lets you quickly install the plugin with a simple terminal command, the manual method lets you do so via a zip file, and the admin method lets you do so via the Admin Plugin.
10+
11+
### GPM Installation (Preferred)
12+
13+
To install the plugin via the [GPM](http://learn.getgrav.org/advanced/grav-gpm), through your system's terminal (also called the command line), navigate to the root of your Grav-installation, and enter:
14+
15+
bin/gpm install highlight-php
16+
17+
This will install the Highlight Php plugin into your `/user/plugins`-directory within Grav. Its files can be found under `/your/site/grav/user/plugins/highlight-php`.
18+
19+
### Manual Installation
20+
21+
To install the plugin manually, download the zip-version of this repository and unzip it under `/your/site/grav/user/plugins`. Then rename the folder to `highlight-php`. You can find these files on [GitHub](https://github.com/iainsgillis/grav-plugin-highlight-php) or via [GetGrav.org](http://getgrav.org/downloads/plugins#extras).
22+
23+
You should now have all the plugin files under
24+
25+
/your/site/grav/user/plugins/highlight-php
26+
27+
> NOTE: This plugin is a modular component for Grav which may require other plugins to operate, please see its [blueprints.yaml-file on GitHub](https://github.com/iainsgillis/grav-plugin-highlight-php/blob/master/blueprints.yaml).
28+
29+
### Admin Plugin
30+
31+
If you use the Admin Plugin, you can install the plugin directly by browsing the `Plugins`-menu and clicking on the `Add` button.
32+
33+
## Configuration
34+
35+
Before configuring this plugin, you should copy the `user/plugins/highlight-php/highlight-php.yaml` to `user/config/plugins/highlight-php.yaml` and only edit that copy.
36+
37+
Here is the default configuration and an explanation of available options:
38+
39+
```yaml
40+
enabled: true
41+
```
42+
43+
Note that if you use the Admin Plugin, a file with your configuration named highlight-php.yaml will be saved in the `user/config/plugins/`-folder once the configuration is saved in the Admin.
44+
45+
## Usage
46+
47+
**Describe how to use the plugin.**
48+
49+
## Credits
50+
51+
**Did you incorporate third-party code? Want to thank somebody?**
52+
53+
## To Do
54+
55+
- [ ] Future plans, if any
56+

blueprints.yaml

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
name: Highlight Php
2+
slug: highlight-php
3+
type: plugin
4+
version: 0.1.0
5+
description: Server-side syntax highlighting (i.e., without JavaScript) using the [highlight.php](https://github.com/scrivo/highlight.php) library
6+
icon: plug
7+
author:
8+
name: Iain Gillis
9+
email: iain@iainsgillis.com
10+
homepage: https://github.com/iainsgillis/grav-plugin-highlight-php
11+
demo: http://demo.yoursite.com
12+
keywords: grav, plugin, etc
13+
bugs: https://github.com/iainsgillis/grav-plugin-highlight-php/issues
14+
docs: https://github.com/iainsgillis/grav-plugin-highlight-php/blob/develop/README.md
15+
license: MIT
16+
17+
dependencies:
18+
- { name: grav, version: '>=1.6.0' }
19+
20+
form:
21+
validation: loose
22+
fields:
23+
enabled:
24+
type: toggle
25+
label: PLUGIN_ADMIN.PLUGIN_STATUS
26+
highlight: 1
27+
default: 0
28+
options:
29+
1: PLUGIN_ADMIN.ENABLED
30+
0: PLUGIN_ADMIN.DISABLED
31+
validate:
32+
type: bool
33+
text_var:
34+
type: text
35+
label: PLUGIN_HIGHLIGHT_PHP.TEXT_VARIABLE
36+
help: PLUGIN_HIGHLIGHT_PHP.TEXT_VARIABLE_HELP

composer.json

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
{
2+
"name": "iainsgillis/highlight-php",
3+
"type": "grav-plugin",
4+
"description": "Server-side syntax highlighting (i.e., without JavaScript) using the [highlight.php](https://github.com/scrivo/highlight.php) library",
5+
"keywords": ["plugin"],
6+
"homepage": "https://github.com/iainsgillis/grav-plugin-highlight-php",
7+
"license": "MIT",
8+
"authors": [
9+
{
10+
"name": "Iain Gillis",
11+
"email": "iain@iainsgillis.com",
12+
"role": "Developer"
13+
}
14+
],
15+
"require": {
16+
"php": ">=7.1.3"
17+
},
18+
"autoload": {
19+
"psr-4": {
20+
"Grav\\Plugin\\HighlightPhp\\": "classes/"
21+
},
22+
"classmap": ["highlight-php.php"]
23+
},
24+
"config": {
25+
"platform": {
26+
"php": "7.1.3"
27+
}
28+
}
29+
}

composer.lock

Lines changed: 23 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

highlight-php.php

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
<?php
2+
namespace Grav\Plugin;
3+
4+
use Composer\Autoload\ClassLoader;
5+
use Grav\Common\Plugin;
6+
7+
/**
8+
* Class HighlightPhpPlugin
9+
* @package Grav\Plugin
10+
*/
11+
class HighlightPhpPlugin extends Plugin
12+
{
13+
/**
14+
* @return array
15+
*
16+
* The getSubscribedEvents() gives the core a list of events
17+
* that the plugin wants to listen to. The key of each
18+
* array section is the event that the plugin listens to
19+
* and the value (in the form of an array) contains the
20+
* callable (or function) as well as the priority. The
21+
* higher the number the higher the priority.
22+
*/
23+
public static function getSubscribedEvents(): array
24+
{
25+
return [
26+
'onPluginsInitialized' => [
27+
// Uncomment following line when plugin requires Grav < 1.7
28+
// ['autoload', 100000],
29+
['onPluginsInitialized', 0]
30+
]
31+
];
32+
}
33+
34+
/**
35+
* Composer autoload
36+
*
37+
* @return ClassLoader
38+
*/
39+
public function autoload(): ClassLoader
40+
{
41+
return require __DIR__ . '/vendor/autoload.php';
42+
}
43+
44+
/**
45+
* Initialize the plugin
46+
*/
47+
public function onPluginsInitialized(): void
48+
{
49+
// Don't proceed if we are in the admin plugin
50+
if ($this->isAdmin()) {
51+
return;
52+
}
53+
54+
// Enable the main events we are interested in
55+
$this->enable([
56+
// Put your main events here
57+
]);
58+
}
59+
}

highlight-php.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
enabled: true
2+
text_var: Custom Text added by the **Highlight Php** plugin (disable plugin to remove)

languages.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
en:
2+
PLUGIN_HIGHLIGHT_PHP:
3+
TEXT_VARIABLE: Text Variable
4+
TEXT_VARIABLE_HELP: Text to add to the top of a page

vendor/autoload.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<?php
2+
3+
// autoload.php @generated by Composer
4+
5+
require_once __DIR__ . '/composer/autoload_real.php';
6+
7+
return ComposerAutoloaderInit61b57ed6dfbb65cd70f7b41ac33678ff::getLoader();

0 commit comments

Comments
 (0)