1
0
Fork 0
mirror of https://github.com/Oreolek/kohana-markdown.git synced 2024-06-16 13:40:43 +03:00

Added initial version of the markdown module.

This commit is contained in:
Gary Stidston-Broadbent 2010-07-13 00:09:28 +08:00
commit e60c3298e4
4 changed files with 1693 additions and 0 deletions

85
README.md Normal file
View file

@ -0,0 +1,85 @@
## Kohana Markdown ##
###### *Last edited: Wed, 07 July 2010 (stroppytux)* ######
A text-to-HTML conversion tool for web writers for Kohana 3.
Based off the php created by Michel Fortin under the gpl lisense. For more
information, please refer to:
<http://michelf.com/projects/php-markdown/>
Original Markdown concept by John Gruber. Please refer to:
<http://daringfireball.net/projects/markdown/>
Markdown is a text-to-HTML filter; it translates an easy-to-read /
easy-to-write structured text format into HTML. Markdown's text format
is most similar to that of plain text email, and supports features such
as headers, *emphasis*, code blocks, blockquotes, and links.
Markdown's syntax is designed not as a generic markup language, but
specifically to serve as a front-end to (X)HTML. You can use span-level
HTML tags anywhere in a Markdown document, and you can use block level
HTML tags (like <div> and <table> as well).
For more information about Markdown's syntax, see:
<http://daringfireball.net/projects/markdown/>
## Installation ##
1. ### Check out the main source ###
Checkout the main repository from github. In order to do this, you will need
a github key configured. Please check the github documentation for more
details.
git clone git@github.com:stroppytux/kohana-markdown.git markdown
This should give you the following (in the markdown directory):
README.md classes config
2. ### Configure Markdown ###
Copy the configuration file located in markdown/config to your application
configuration directory.
cp modules/markdown/config/markdown.php application/config/
3. ### Enable Markdown ###
In order to enable the markdown module, edit the application/bootstrap.php
file and add and enable the markdown module.
'markdown' => MODPATH.'markdown', // Markdown module
4. ### Process strings ###
Now add the markdown transformer in between the value received from the
user, and the storage. eg.
<?php defined('SYSPATH') or die('No direct script access.');
class Model_Description extends Model {
public function add($data)
{
$query = DB::query(Database::INSERT, '
INSERT INTO `Descriptions`
(`d_title`, `d_description`)
VALUES
(:title, :description)');
/* Sort out the description */
$description = Markdown::instance()->transform($data['description']);
/* Add the paramaters to the query */
$query->param(':title', $data['title']);
$query->param(':description', $description);
return $query->execute();
}
}
5. ### Validation rules ###
TODO: Need to create a regex validation rule for markdown.

1582
classes/kohana/markdown.php Normal file

File diff suppressed because it is too large Load diff

15
classes/markdown.php Normal file
View file

@ -0,0 +1,15 @@
<?php defined('SYSPATH') or die('No direct script access.');
/**
* Markdown abstract reference class
*
* @Gary Stidston-Broadbent <kohana_api@stroppytux.net>
* @package Markdown
* @copyright (c) 2010 Unmagnify team
* @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt
* @version $id$
* @link http://www.stroppytux.net/projects/kohana-markdown/
* @since Available since Release 1.0
* *
*/
abstract class Markdown extends Kohana_Markdown {}
?>

11
config/markdown.php Normal file
View file

@ -0,0 +1,11 @@
<?php defined('SYSPATH') or die('No direct script access.');
return array
(
'default' => array
(
'type' => 'xhtml', // html or xhtml
'tab_width' => 4, // Tab width for output
// Many more options to come
)
);
?>