{
$data = array(
'pageabsaddr' => index_url($_SERVER),
+ 'sslenabled' => !empty($_SERVER['HTTPS'])
);
$pluginManager->executeHooks('render_tools', $data);
|--- markdown.css
|--- markdown.meta
|--- markdown.php
- |--- Parsedown.php
|--- README.md
```
To enable the plugin, just check it in the plugin administration page.
-You can also add `markdown` to your list of enabled plugins in `data/config.php`
-(`ENABLED_PLUGINS` array).
+You can also add `markdown` to your list of enabled plugins in `data/config.json.php`
+(`general.enabled_plugins` list).
This should look like:
```
-$GLOBALS['config']['ENABLED_PLUGINS'] = array('qrcode', 'any_other_plugin', 'markdown')
+"general": {
+ "enabled_plugins": [
+ "markdown",
+ [...]
+ ],
+}
```
+Parsedown parsing library is imported using Composer. If you installed Shaarli using `git`,
+or the `master` branch, run
+
+ composer update --no-dev --prefer-dist
+
### No Markdown tag
-If the tag `.nomarkdown` is set for a shaare, it won't be converted to Markdown syntax.
+If the tag `nomarkdown` is set for a shaare, it won't be converted to Markdown syntax.
-> Note: it's a private tag (leading dot), so it won't be displayed to visitors.
+> Note: this is a special tag, so it won't be displayed in link list.
### HTML rendering
{
foreach ($data['links'] as &$value) {
if (!empty($value['tags']) && noMarkdownTag($value['tags'])) {
- $value['taglist'] = stripNoMarkdownTag($value['taglist']);
+ $value = stripNoMarkdownTag($value);
continue;
}
$value['description'] = process_markdown($value['description']);
{
foreach ($data['links'] as &$value) {
if (!empty($value['tags']) && noMarkdownTag($value['tags'])) {
- $value['tags'] = stripNoMarkdownTag($value['tags']);
+ $value = stripNoMarkdownTag($value);
continue;
}
$value['description'] = process_markdown($value['description']);
foreach ($data['cols'] as &$value) {
foreach ($value as &$value2) {
if (!empty($value2['tags']) && noMarkdownTag($value2['tags'])) {
+ $value2 = stripNoMarkdownTag($value2);
continue;
}
$value2['formatedDescription'] = process_markdown($value2['formatedDescription']);
*/
function noMarkdownTag($tags)
{
- return strpos($tags, NO_MD_TAG) !== false;
+ return preg_match('/(^|\s)'. NO_MD_TAG .'(\s|$)/', $tags);
}
/**
* Remove the no-markdown meta tag so it won't be displayed.
*
- * @param string $tags Tag list.
+ * @param array $link Link data.
*
- * @return string tag list without no markdown tag.
+ * @return array Updated link without no markdown tag.
*/
-function stripNoMarkdownTag($tags)
+function stripNoMarkdownTag($link)
{
- unset($tags[array_search(NO_MD_TAG, $tags)]);
- return array_values($tags);
+ if (! empty($link['taglist'])) {
+ $offset = array_search(NO_MD_TAG, $link['taglist']);
+ if ($offset !== false) {
+ unset($link['taglist'][$offset]);
+ }
+ }
+
+ if (!empty($link['tags'])) {
+ str_replace(NO_MD_TAG, '', $link['tags']);
+ }
+
+ return $link;
}
/**
require_once 'plugins/markdown/markdown.php';
/**
- * Class PlugQrcodeTest
- * Unit test for the QR-Code plugin
+ * Class PluginMarkdownTest
+ * Unit test for the Markdown plugin
*/
class PluginMarkdownTest extends PHPUnit_Framework_TestCase
{
))
);
- $data = hook_markdown_render_linklist($data);
- $this->assertEquals($str, $data['links'][0]['description']);
+ $processed = hook_markdown_render_linklist($data);
+ $this->assertEquals($str, $processed['links'][0]['description']);
+
+ $processed = hook_markdown_render_feed($data);
+ $this->assertEquals($str, $processed['links'][0]['description']);
$data = array(
// Columns data
$this->assertEquals($str, $data['cols'][0][0]['formatedDescription']);
}
+ /**
+ * Test that a close value to nomarkdown is not understand as nomarkdown (previous value `.nomarkdown`).
+ */
+ function testNoMarkdownNotExcactlyMatching()
+ {
+ $str = 'All _work_ and `no play` makes Jack a *dull* boy.';
+ $data = array(
+ 'links' => array(array(
+ 'description' => $str,
+ 'tags' => '.' . NO_MD_TAG,
+ 'taglist' => array('.'. NO_MD_TAG),
+ ))
+ );
+
+ $data = hook_markdown_render_feed($data);
+ $this->assertContains('<em>', $data['links'][0]['description']);
+ }
+
/**
* Test hashtag links processed with markdown.
*/
{elseif="$link.description==''"}onload="document.linkform.lf_description.focus();"
{else}onload="document.linkform.lf_tags.focus();"{/if} >
<div id="pageheader">
- {if="$source !== 'firefoxsocialapi'"}
- {include="page.header"}
- {/if}
- <div id="editlinkform">
- <form method="post" name="linkform">
- <input type="hidden" name="lf_linkdate" value="{$link.linkdate}">
- <label for="lf_url"><i>URL</i></label><br><input type="text" name="lf_url" id="lf_url" value="{$link.url}" class="lf_input"><br>
+ {if="$source !== 'firefoxsocialapi'"}
+ {include="page.header"}
+ {else}
+ <div id="shaarli_title"><a href="{$titleLink}">{$shaarlititle}</a></div>
+ {/if}
+ <div id="editlinkform">
+ <form method="post" name="linkform">
+ <input type="hidden" name="lf_linkdate" value="{$link.linkdate}">
+ <label for="lf_url"><i>URL</i></label><br><input type="text" name="lf_url" id="lf_url" value="{$link.url}" class="lf_input"><br>
<label for="lf_title"><i>Title</i></label><br><input type="text" name="lf_title" id="lf_title" value="{$link.title}" class="lf_input"><br>
<label for="lf_description"><i>Description</i></label><br><textarea name="lf_description" id="lf_description" rows="4" cols="25">{$link.description}</textarea><br>
<label for="lf_tags"><i>Tags</i></label><br>
{$value}
{/loop}
- {if="($link_is_new && $default_private_links) || $link.private == true"}
+ {if="($link_is_new && $default_private_links) || $link.private == true"}
<input type="checkbox" checked="checked" name="lf_private" id="lf_private">
<label for="lf_private"><i>Private</i></label><br>
{else}
<input type="checkbox" name="lf_private" id="lf_private">
<label for="lf_private"><i>Private</i></label><br>
{/if}
- <input type="submit" value="Save" name="save_edit" class="bigbutton">
- <input type="submit" value="Cancel" name="cancel_edit" class="bigbutton">
- {if="!$link_is_new"}<input type="submit" value="Delete" name="delete_link" class="bigbutton delete" onClick="return confirmDeleteLink();">{/if}
- <input type="hidden" name="token" value="{$token}">
- {if="$http_referer"}<input type="hidden" name="returnurl" value="{$http_referer}">{/if}
- </form>
- </div>
+ <input type="submit" value="Save" name="save_edit" class="bigbutton">
+ <input type="submit" value="Cancel" name="cancel_edit" class="bigbutton">
+ {if="!$link_is_new"}<input type="submit" value="Delete" name="delete_link" class="bigbutton delete" onClick="return confirmDeleteLink();">{/if}
+ <input type="hidden" name="token" value="{$token}">
+ {if="$http_referer"}<input type="hidden" name="returnurl" value="{$http_referer}">{/if}
+ </form>
+ </div>
</div>
{if="$source !== 'firefoxsocialapi'"}
{include="page.footer"}
Then click "✚Add Note" button anytime to start composing a private Note (text post) to your Shaarli.
</span>
</a><br><br>
+
+ {if="$sslenabled"}
<a class="smallbutton" onclick="activateFirefoxSocial(this)">
<b>✚Add to Firefox social</b>
</a>
<a href="#">
<span>⇐ Click on this button to add Shaarli to the "Share this page" button in Firefox.</span>
</a><br><br>
+ {/if}
{loop="$tools_plugin"}
{$value}
<div class="clear"></div>
<script>
+ {if="$sslenabled"}
function activateFirefoxSocial(node) {
var loc = location.href;
var baseURL = loc.substring(0, loc.lastIndexOf("/"));
var activate = new CustomEvent("ActivateSocialFeature");
node.dispatchEvent(activate);
}
-
+ {/if}
function alertBookmarklet() {
alert('Drag this link to your bookmarks toolbar, or right-click it and choose Bookmark This Link...');
return false;