-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'remotes/origin/ss4-compat'
# Conflicts: # README.md
- Loading branch information
Showing
16 changed files
with
531 additions
and
345 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# For more information about the properties used in | ||
# this file, please see the EditorConfig documentation: | ||
# http://editorconfig.org/ | ||
|
||
[*] | ||
charset = utf-8 | ||
end_of_line = lf | ||
indent_size = 4 | ||
indent_style = space | ||
insert_final_newline = true | ||
trim_trailing_whitespace = true | ||
|
||
[*.md] | ||
trim_trailing_whitespace = false | ||
|
||
[*.{yml,js,json,css,scss,eslintrc}] | ||
indent_size = 2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,76 +1,101 @@ | ||
Markdown Editor and DBField | ||
================= | ||
# Markdown Editor and DBField | ||
|
||
Adds a field and a data type that allows for Markdown editing, uses a supported renderer (default is the github api) to render the html | ||
Adds a field and a data type that allows for Markdown editing, uses a supported renderer (default is the GitHub API) | ||
to render the HTML. | ||
|
||
## Requirements | ||
* SilverStripe 3.x | ||
* PHP Curl Support | ||
|
||
* SilverStripe 4.x | ||
* PHP cURL Support | ||
|
||
## Installation | ||
* Download the module from here https://github.com/UndefinedOffset/silverstripe-markdown/downloads | ||
* Extract the downloaded archive into your site root so that the destination folder is called markdown, opening the extracted folder should contain _config.php in the root along with other files/folders | ||
* Run dev/build?flush=all to regenerate the manifest | ||
* Upon entering the cms and using MarkdownEditor for the first time you make need to add ?flush=all to the end of the address to force the templates to regenerate | ||
|
||
* Install with [composer](https://getcomposer.org): `composer require undefinedoffset/silverstripe-markdown ^2.0` | ||
* Run `dev/build?flush=all` to regenerate the manifest | ||
|
||
## Usage | ||
|
||
Use the Markdown data type as your fields data type, then use the MarkdownEditor field in the cms for editing. | ||
|
||
### Page class: | ||
### Page class | ||
|
||
```php | ||
class MyPage extends Page { | ||
public static $db=array( | ||
'MarkdownContent'=>'Markdown' | ||
); | ||
use UndefinedOffset\Markdown\Forms\MarkdownEditor; | ||
|
||
class MyPage extends Page | ||
{ | ||
public static $db = array( | ||
'MarkdownContent' => 'Markdown' | ||
); | ||
|
||
public function getCMSFields() { | ||
$fields=parent::getCMSFields(); | ||
public function getCMSFields() | ||
{ | ||
$fields = parent::getCMSFields(); | ||
|
||
$editor = new MarkdownEditor('MarkdownContent', 'Page Content (Markdown)'); | ||
$editor->setRows(15); //optional, set number of rows in CMS | ||
$editor->setWrapMode(true); //optional, turn on word wrapping | ||
$fields->addFieldToTab("Root.Main", $editor); | ||
$fields->addFieldToTab('Root.Main', $editor); | ||
|
||
return $fields; | ||
} | ||
} | ||
``` | ||
|
||
### Template | ||
|
||
### Template: | ||
```html | ||
<div class="content"> | ||
$MarkdownContent <!-- Will show as rendered html --> | ||
$MarkdownContent <!-- Will show as rendered HTML --> | ||
</div> | ||
``` | ||
|
||
You may also request the markdown using Github Flavored Markdown by calling $YourField.AsHTML(true) in your template by default Github Flavored Markdown is not used just regular Markdown is used. | ||
You may also request the markdown using Github Flavored Markdown by calling $YourField.AsHTML(true) in your template | ||
by default Github Flavored Markdown is not used just regular Markdown is used. | ||
|
||
```html | ||
<div class="content"> | ||
$MarkdownContent.AsHTML(true) <!-- Will render the content using Github Flavoured Markdown --> | ||
</div> | ||
``` | ||
|
||
### Configuration: | ||
The default renderer is the Github renderer. However, other renderers are supported. | ||
### Configuration | ||
|
||
The default renderer is the GitHub renderer. However, other renderers are supported. | ||
|
||
To set what renderer to use, in **_config.php** do the following: | ||
To set what renderer to use, in `_config.php` do the following: | ||
|
||
```php | ||
Markdown::setRenderer('GithubMarkdownRenderer'); //Class name of any implementation of IMarkdownRenderer will work | ||
use UndefinedOffset\Markdown\Model\FieldTypes\Markdown; | ||
|
||
// Fully qualified (namespaced) class name of any implementation of IMarkdownRenderer will work: | ||
Markdown::setRenderer('UndefinedOffset\\Markdown\\Renderer\\GithubMarkdownRenderer'); | ||
``` | ||
|
||
#### GithubMarkdownRenderer | ||
|
||
The following options are available on the default GithubMarkdownRenderer: | ||
|
||
```php | ||
GithubMarkdownRenderer::useBasicAuth('github username', 'github password'); //authenticate to the Github API to get 5,000 requests per hour instead of 60 | ||
GithubMarkdownRenderer::setUseGFM(true); //whether or not to use Github Flavoured Markdown | ||
use UndefinedOffset\Markdown\Renderer\GitHubMarkdownRenderer; | ||
|
||
// authenticate to the Github API to get 5,000 requests per hour instead of 60 | ||
GithubMarkdownRenderer::useBasicAuth('github username', 'github password'); | ||
// whether or not to use Github Flavoured Markdown | ||
GithubMarkdownRenderer::setUseGFM(true); | ||
``` | ||
|
||
#### PHPMarkdownMarkdownRenderer | ||
PHPMarkdownMarkdownRenderer is simple and has no options. Use this to avoid the delay on page load the first time after editing that comes from using the Github renderer (especially if the page has many sections of markdown). You will need to install [PHP Markdown](https://github.com/michelf/php-markdown) for this to work - it can be installed with composer. | ||
|
||
PHPMarkdownMarkdownRenderer is simple and has no options. Use this to avoid the delay on page load the first time | ||
after editing that comes from using the Github renderer (especially if the page has many sections of markdown). You | ||
will need to install [PHP Markdown](https://github.com/michelf/php-markdown) for this to work - it can be installed | ||
with composer. | ||
|
||
**Note:** This renderer does not support Github Flavoured Markdown. | ||
|
||
```php | ||
Markdown::setRenderer('PHPMarkdownMarkdownRenderer'); | ||
use UndefinedOffset\Markdown\Model\FieldTypes\Markdown; | ||
|
||
Markdown::setRenderer('UndefinedOffset\\Markdown\\Renderer\\PHPMarkdownMarkdownRenderer'); | ||
``` |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
--- | ||
Name: markdowninjector | ||
--- | ||
SilverStripe\Core\Injector\Injector: | ||
Markdown: | ||
class: UndefinedOffset\Markdown\Model\FieldTypes\DBMarkdown |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.