diff options
Diffstat (limited to 'plugins')
-rw-r--r-- | plugins/demo_plugin/demo_plugin.php | 27 | ||||
-rw-r--r-- | plugins/markdown/README.md | 34 | ||||
-rw-r--r-- | plugins/markdown/markdown.php | 30 |
3 files changed, 79 insertions, 12 deletions
diff --git a/plugins/demo_plugin/demo_plugin.php b/plugins/demo_plugin/demo_plugin.php index f5f028e0..18834e53 100644 --- a/plugins/demo_plugin/demo_plugin.php +++ b/plugins/demo_plugin/demo_plugin.php | |||
@@ -322,4 +322,29 @@ function hook_demo_plugin_delete_link($data) | |||
322 | if (strpos($data['url'], 'youtube.com') !== false) { | 322 | if (strpos($data['url'], 'youtube.com') !== false) { |
323 | exit('You can not delete a YouTube link. Don\'t ask.'); | 323 | exit('You can not delete a YouTube link. Don\'t ask.'); |
324 | } | 324 | } |
325 | } \ No newline at end of file | 325 | } |
326 | |||
327 | /** | ||
328 | * Execute render_feed hook. | ||
329 | * Called with ATOM and RSS feed. | ||
330 | * | ||
331 | * Special data keys: | ||
332 | * - _PAGE_: current page | ||
333 | * - _LOGGEDIN_: true/false | ||
334 | * | ||
335 | * @param array $data data passed to plugin | ||
336 | * | ||
337 | * @return array altered $data. | ||
338 | */ | ||
339 | function hook_demo_plugin_render_feed($data) | ||
340 | { | ||
341 | foreach ($data['links'] as &$link) { | ||
342 | if ($data['_PAGE_'] == Router::$PAGE_FEED_ATOM) { | ||
343 | $link['description'] .= ' - ATOM Feed' ; | ||
344 | } | ||
345 | elseif ($data['_PAGE_'] == Router::$PAGE_FEED_RSS) { | ||
346 | $link['description'] .= ' - RSS Feed'; | ||
347 | } | ||
348 | } | ||
349 | return $data; | ||
350 | } | ||
diff --git a/plugins/markdown/README.md b/plugins/markdown/README.md index defaacd1..4f021871 100644 --- a/plugins/markdown/README.md +++ b/plugins/markdown/README.md | |||
@@ -2,25 +2,31 @@ | |||
2 | 2 | ||
3 | Convert all your shaares description to HTML formatted Markdown. | 3 | Convert all your shaares description to HTML formatted Markdown. |
4 | 4 | ||
5 | Read more about Markdown syntax here. | 5 | [Read more about Markdown syntax](http://daringfireball.net/projects/markdown/syntax). |
6 | |||
7 | Markdown processing is done with [Parsedown library](https://github.com/erusev/parsedown). | ||
6 | 8 | ||
7 | ### Installation | 9 | ### Installation |
8 | 10 | ||
9 | Clone this repository inside your `tpl/plugins/` directory, or download the archive and unpack it there. | 11 | As a default plugin, it should already be in `tpl/plugins/` directory. |
12 | If not, download and unpack it there. | ||
13 | |||
10 | The directory structure should look like: | 14 | The directory structure should look like: |
11 | 15 | ||
12 | ``` | 16 | ``` |
13 | ??? plugins | 17 | --- plugins |
14 | ??? markdown | 18 | |--- markdown |
15 | ??? help.html | 19 | |--- help.html |
16 | ??? markdown.css | 20 | |--- markdown.css |
17 | ??? markdown.meta | 21 | |--- markdown.meta |
18 | ??? markdown.php | 22 | |--- markdown.php |
19 | ??? Parsedown.php | 23 | |--- Parsedown.php |
20 | ??? README.md | 24 | |--- README.md |
21 | ``` | 25 | ``` |
22 | 26 | ||
23 | To enable the plugin, add `markdown` to your list of enabled plugins in `data/config.php` | 27 | To enable the plugin, just check it in the plugin administration page. |
28 | |||
29 | You can also add `markdown` to your list of enabled plugins in `data/config.php` | ||
24 | (`ENABLED_PLUGINS` array). | 30 | (`ENABLED_PLUGINS` array). |
25 | 31 | ||
26 | This should look like: | 32 | This should look like: |
@@ -29,6 +35,12 @@ This should look like: | |||
29 | $GLOBALS['config']['ENABLED_PLUGINS'] = array('qrcode', 'any_other_plugin', 'markdown') | 35 | $GLOBALS['config']['ENABLED_PLUGINS'] = array('qrcode', 'any_other_plugin', 'markdown') |
30 | ``` | 36 | ``` |
31 | 37 | ||
38 | ### No Markdown tag | ||
39 | |||
40 | If the tag `.nomarkdown` is set for a shaare, it won't be converted to Markdown syntax. | ||
41 | |||
42 | > Note: it's a private tag (leading dot), so it won't be displayed to visitors. | ||
43 | |||
32 | ### Known issue | 44 | ### Known issue |
33 | 45 | ||
34 | #### Redirector | 46 | #### Redirector |
diff --git a/plugins/markdown/markdown.php b/plugins/markdown/markdown.php index 5a702c7b..544ed22e 100644 --- a/plugins/markdown/markdown.php +++ b/plugins/markdown/markdown.php | |||
@@ -8,6 +8,12 @@ | |||
8 | 8 | ||
9 | require_once 'Parsedown.php'; | 9 | require_once 'Parsedown.php'; |
10 | 10 | ||
11 | /* | ||
12 | * If this tag is used on a shaare, the description won't be processed by Parsedown. | ||
13 | * Using a private tag so it won't appear for visitors. | ||
14 | */ | ||
15 | define('NO_MD_TAG', '.nomarkdown'); | ||
16 | |||
11 | /** | 17 | /** |
12 | * Parse linklist descriptions. | 18 | * Parse linklist descriptions. |
13 | * | 19 | * |
@@ -18,6 +24,9 @@ require_once 'Parsedown.php'; | |||
18 | function hook_markdown_render_linklist($data) | 24 | function hook_markdown_render_linklist($data) |
19 | { | 25 | { |
20 | foreach ($data['links'] as &$value) { | 26 | foreach ($data['links'] as &$value) { |
27 | if (!empty($value['tags']) && noMarkdownTag($value['tags'])) { | ||
28 | continue; | ||
29 | } | ||
21 | $value['description'] = process_markdown($value['description']); | 30 | $value['description'] = process_markdown($value['description']); |
22 | } | 31 | } |
23 | 32 | ||
@@ -36,6 +45,9 @@ function hook_markdown_render_daily($data) | |||
36 | // Manipulate columns data | 45 | // Manipulate columns data |
37 | foreach ($data['cols'] as &$value) { | 46 | foreach ($data['cols'] as &$value) { |
38 | foreach ($value as &$value2) { | 47 | foreach ($value as &$value2) { |
48 | if (!empty($value2['tags']) && noMarkdownTag($value2['tags'])) { | ||
49 | continue; | ||
50 | } | ||
39 | $value2['formatedDescription'] = process_markdown($value2['formatedDescription']); | 51 | $value2['formatedDescription'] = process_markdown($value2['formatedDescription']); |
40 | } | 52 | } |
41 | } | 53 | } |
@@ -44,6 +56,18 @@ function hook_markdown_render_daily($data) | |||
44 | } | 56 | } |
45 | 57 | ||
46 | /** | 58 | /** |
59 | * Check if noMarkdown is set in tags. | ||
60 | * | ||
61 | * @param string $tags tag list | ||
62 | * | ||
63 | * @return bool true if markdown should be disabled on this link. | ||
64 | */ | ||
65 | function noMarkdownTag($tags) | ||
66 | { | ||
67 | return strpos($tags, NO_MD_TAG) !== false; | ||
68 | } | ||
69 | |||
70 | /** | ||
47 | * When link list is displayed, include markdown CSS. | 71 | * When link list is displayed, include markdown CSS. |
48 | * | 72 | * |
49 | * @param array $data includes data. | 73 | * @param array $data includes data. |
@@ -75,6 +99,12 @@ function hook_markdown_render_editlink($data) | |||
75 | { | 99 | { |
76 | // Load help HTML into a string | 100 | // Load help HTML into a string |
77 | $data['edit_link_plugin'][] = file_get_contents(PluginManager::$PLUGINS_PATH .'/markdown/help.html'); | 101 | $data['edit_link_plugin'][] = file_get_contents(PluginManager::$PLUGINS_PATH .'/markdown/help.html'); |
102 | |||
103 | // Add no markdown 'meta-tag' in tag list if it was never used, for autocompletion. | ||
104 | if (! in_array(NO_MD_TAG, $data['tags'])) { | ||
105 | $data['tags'][NO_MD_TAG] = 0; | ||
106 | } | ||
107 | |||
78 | return $data; | 108 | return $data; |
79 | } | 109 | } |
80 | 110 | ||