Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 4afb60e
Showing
46 changed files
with
12,749 additions
and
0 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,130 @@ | ||
<?php | ||
|
||
namespace Kanboard\Plugin\EmojiSupport\Helper; | ||
|
||
require __DIR__.'/../vendor/emojione/emojione/lib/php/autoload.php'; | ||
|
||
use Kanboard\Core\Markdown; | ||
use Kanboard\Core\Base; | ||
use Emojione\Client; | ||
use Emojione\RuleSet; | ||
|
||
|
||
/** | ||
* Text Helpers | ||
* | ||
* @package helper | ||
* @author Frederic Guillot | ||
*/ | ||
class EmojiTextHelper extends Base | ||
{ | ||
/** | ||
* HTML escaping | ||
* | ||
* @param string $value Value to escape | ||
* @return string | ||
*/ | ||
public function e($value) | ||
{ | ||
return htmlspecialchars($value, ENT_QUOTES, 'UTF-8', false); | ||
} | ||
|
||
/** | ||
* Join with HTML escaping | ||
* | ||
* @param $glue | ||
* @param array $list | ||
* @return string | ||
*/ | ||
public function implode($glue, array $list) | ||
{ | ||
array_walk($list, function (&$value) { $value = htmlspecialchars($value, ENT_QUOTES, 'UTF-8', false); }); | ||
return implode($glue, $list); | ||
} | ||
|
||
/** | ||
* Markdown transformation | ||
* | ||
* @param string $text | ||
* @param boolean $isPublicLink | ||
* @return string | ||
*/ | ||
public function markdown($text, $isPublicLink = false) | ||
{ | ||
$emoji = new Client(new Ruleset()); | ||
$parser = new Markdown($this->container, $isPublicLink); | ||
$parser->setMarkupEscaped(MARKDOWN_ESCAPE_HTML); | ||
return $emoji->shortnameToImage($parser->text($text)); | ||
} | ||
|
||
/** | ||
* Format a file size | ||
* | ||
* @param integer $size Size in bytes | ||
* @param integer $precision Precision | ||
* @return string | ||
*/ | ||
public function bytes($size, $precision = 2) | ||
{ | ||
if ($size == 0) { | ||
return 0; | ||
} | ||
|
||
$base = log($size) / log(1024); | ||
$suffixes = array('', 'k', 'M', 'G', 'T'); | ||
|
||
return round(pow(1024, $base - floor($base)), $precision).$suffixes[(int)floor($base)]; | ||
} | ||
|
||
/** | ||
* Get the number of bytes from PHP size | ||
* | ||
* @param integer $val PHP size (example: 2M) | ||
* @return integer | ||
*/ | ||
public function phpToBytes($val) | ||
{ | ||
$size = (int) substr($val, 0, -1); | ||
$last = strtolower(substr($val, -1)); | ||
|
||
switch ($last) { | ||
case 'g': | ||
$size *= 1024; | ||
case 'm': | ||
$size *= 1024; | ||
case 'k': | ||
$size *= 1024; | ||
} | ||
|
||
return $size; | ||
} | ||
|
||
/** | ||
* Return true if needle is contained in the haystack | ||
* | ||
* @param string $haystack Haystack | ||
* @param string $needle Needle | ||
* @return boolean | ||
*/ | ||
public function contains($haystack, $needle) | ||
{ | ||
return strpos($haystack, $needle) !== false; | ||
} | ||
|
||
/** | ||
* Return a value from a dictionary | ||
* | ||
* @param mixed $id Key | ||
* @param array $listing Dictionary | ||
* @param string $default_value Value displayed when the key doesn't exists | ||
* @return string | ||
*/ | ||
public function in($id, array $listing, $default_value = '?') | ||
{ | ||
if (isset($listing[$id])) { | ||
return $this->helper->text->e($listing[$id]); | ||
} | ||
|
||
return $default_value; | ||
} | ||
} |
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,21 @@ | ||
MIT License | ||
|
||
Copyright (c) 2019 Craig Crosby | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
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,42 @@ | ||
<?php | ||
|
||
namespace Kanboard\Plugin\EmojiSupport; | ||
|
||
use Kanboard\Core\Plugin\Base; | ||
use Kanboard\Plugin\EmojiSupport\Helper\EmojiTextHelper; | ||
|
||
|
||
class Plugin extends Base | ||
|
||
{ | ||
public function initialize() | ||
{ | ||
//Helpers | ||
$this->helper->register('text', '\Kanboard\Plugin\EmojiSupport\Helper\EmojiTextHelper'); | ||
} | ||
|
||
public function getPluginName() | ||
{ | ||
return 'EmojiSupport'; | ||
} | ||
|
||
public function getPluginAuthor() | ||
{ | ||
return 'Craig Crosby'; | ||
} | ||
|
||
public function getPluginVersion() | ||
{ | ||
return '1.0.0'; | ||
} | ||
|
||
public function getPluginDescription() | ||
{ | ||
return 'Emoji Support in Markdown for Kanboard'; | ||
} | ||
|
||
public function getPluginHomepage() | ||
{ | ||
return 'https://github.com/creecros/EmojiSupport'; | ||
} | ||
} |
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,12 @@ | ||
[![Latest release](https://img.shields.io/github/release/creecros/EmojiSupport.svg)](https://github.com/creecros/EmojiSupport/releases) | ||
![GitHub license](https://img.shields.io/github/license/Naereen/StrapDown.js.svg) | ||
[![Maintenance](https://img.shields.io/badge/Maintained%3F-yes-green.svg)](https://github.com/creecros/EmojiSupport/graphs/contributors) | ||
![Open Source Love](https://badges.frapsoft.com/os/v1/open-source.svg?v=103) | ||
![Downloads](https://img.shields.io/github/downloads/creecros/EmojiSupport/total.svg) | ||
|
||
**:star: If you use it, you should star it on Github!** | ||
*It's the least you can do for all the work put into it!* | ||
|
||
# EmojiSupport | ||
|
||
Adds Emoji Support to all Markdown in Kanboard! |
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,5 @@ | ||
{ | ||
"require": { | ||
"emojione/emojione": "^4.5" | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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,7 @@ | ||
<?php | ||
|
||
// autoload.php @generated by Composer | ||
|
||
require_once __DIR__ . '/composer/autoload_real.php'; | ||
|
||
return ComposerAutoloaderInit65a8882e640840f82a5b23de49691603::getLoader(); |
Oops, something went wrong.