Skip to content
This repository has been archived by the owner on Jul 23, 2019. It is now read-only.

Commit

Permalink
-cache bust parameter
Browse files Browse the repository at this point in the history
  • Loading branch information
kevinranks committed Oct 3, 2014
1 parent ec7fe35 commit 60b4816
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 13 deletions.
13 changes: 7 additions & 6 deletions lib/js/emojione.js
Original file line number Diff line number Diff line change
Expand Up @@ -3773,6 +3773,7 @@
ns.sprites = false; // if this is true then sprite markup will be used (if SVG image type is set then you must include the SVG sprite file locally)
ns.unicodeAlt = true; // use the unicode char as the alt attribute (makes copy and pasting the resulting text better)
ns.ascii = false; // change to true to convert ascii smileys
ns.cacheBustParam = '?v=1.2.3'; // you can [optionally] modify this to force browsers to refresh their cache. it will be appended to the send of the filenames

ns.toImage = function(str) {
str = ns.unicodeToImage(str);
Expand Down Expand Up @@ -3869,7 +3870,7 @@
replaceWith = '<span class="emojione-'+unicode+'" title="'+shortname+'">'+alt+'</span>';
}
else {
replaceWith = '<img class="emojione" alt="'+alt+'" src="'+ns.imagePathPNG+unicode+'.png"/>';
replaceWith = '<img class="emojione" alt="'+alt+'" src="'+ns.imagePathPNG+unicode+'.png'+ns.cacheBustParam+'"/>';
}
}
else {
Expand All @@ -3878,7 +3879,7 @@
replaceWith = '<svg class="emojione"><description>'+alt+'</description><use xlink:href="'+ns.imagePathSVGSprites+'#emoji-'+unicode+'"></use></svg>';
}
else {
replaceWith = '<object class="emojione" data="'+ns.imagePathSVG+unicode+'.svg" type="image/svg+xml" standby="'+alt+'">'+alt+'</object>';
replaceWith = '<object class="emojione" data="'+ns.imagePathSVG+unicode+'.svg'+ns.cacheBustParam+'" type="image/svg+xml" standby="'+alt+'">'+alt+'</object>';
}
}

Expand Down Expand Up @@ -3906,7 +3907,7 @@
replaceWith = m2+'<span class="emojione-'+unicode.toUpperCase()+'" title="'+ns.escapeHTML(m3)+'">'+alt+'</span>';
}
else {
replaceWith = m2+'<img class="emojione" alt="'+alt+'" src="'+ns.imagePathPNG+unicode+'.png"/>';
replaceWith = m2+'<img class="emojione" alt="'+alt+'" src="'+ns.imagePathPNG+unicode+'.png'+ns.cacheBustParam+'"/>';
}
}
else {
Expand All @@ -3915,7 +3916,7 @@
replaceWith = '<svg class="emojione"><description>'+alt+'</description><use xlink:href="'+ns.imagePathSVGSprites+'#emoji-'+unicode.toUpperCase()+'"></use></svg>';
}
else {
replaceWith = m2+'<object class="emojione" data="'+ns.imagePathSVG+unicode+'.svg" type="image/svg+xml" standby="'+alt+'">'+alt+'</object>';
replaceWith = m2+'<object class="emojione" data="'+ns.imagePathSVG+unicode+'.svg'+ns.cacheBustParam+'" type="image/svg+xml" standby="'+alt+'">'+alt+'</object>';
}
}

Expand Down Expand Up @@ -3953,7 +3954,7 @@
replaceWith = '<span class="emojione-'+unicode.toUpperCase()+'" title="'+mappedUnicode[unicode]+'">'+alt+'</span>';
}
else {
replaceWith = '<img class="emojione" alt="'+alt+'" src="'+ns.imagePathPNG+unicode+'.png"/>';
replaceWith = '<img class="emojione" alt="'+alt+'" src="'+ns.imagePathPNG+unicode+'.png'+ns.cacheBustParam+'"/>';
}
}
else {
Expand All @@ -3962,7 +3963,7 @@
replaceWith = '<svg class="emojione"><description>'+alt+'</description><use xlink:href="'+ns.imagePathSVGSprites+'#emoji-'+unicode.toUpperCase()+'"></use></svg>';
}
else {
replaceWith = '<object class="emojione" data="'+ns.imagePathSVG+unicode+'.svg" type="image/svg+xml" standby="'+alt+'">'+alt+'</object>';
replaceWith = '<object class="emojione" data="'+ns.imagePathSVG+unicode+'.svg'+ns.cacheBustParam+'" type="image/svg+xml" standby="'+alt+'">'+alt+'</object>';
}
}

Expand Down
2 changes: 1 addition & 1 deletion lib/js/emojione.min.js

Large diffs are not rendered by default.

15 changes: 9 additions & 6 deletions lib/php/src/Emojione.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ class Emojione {
static $ascii = false; // convert ascii smileys?
static $unicodeAlt = true; // use the unicode char as the alt attribute (makes copy and pasting the resulting text better)
static $imageType = 'png';
static $cacheBustParam = '?v=1.2.3';
static $sprites = false;
static $imagePathPNG = '//cdn.jsdelivr.net/emojione/assets/png/';
static $imagePathSVG = '//cdn.jsdelivr.net/emojione/assets/svg/';
Expand All @@ -13,6 +14,8 @@ class Emojione {
static $unicodeRegexp = '([#0-9](?>\\xEF\\xB8\\x8F)?\\xE2\\x83\\xA3|\\xC2[\\xA9\\xAE]|\\xE2..(?>\\xEF\\xB8\\x8F)?|\\xE3(?>\\x80[\\xB0\\xBD]|\\x8A[\\x97\\x99])(?>\\xEF\\xB8\\x8F)?|\\xF0\\x9F(?>[\\x80-\\x86].(?>\\xEF\\xB8\\x8F)?|\\x87.\\xF0\\x9F\\x87.|..))';
static $shortcodeRegexp = ':([-+\\w]+):';



static $shortcode_replace = Array(
':hash:' => '0023-20e3',
':zero:' => '0030-20e3',
Expand Down Expand Up @@ -2069,15 +2072,15 @@ static function shortnameToImageCallback($m) {
return '<span class="emojione-'.strtoupper($unicode).'" title="'.htmlspecialchars($shortname).'">'.$alt.'</span>';
}
else {
return '<img class="emojione" alt="'.$alt.'" src="'.self::$imagePathPNG.$filename.'.png"/>';
return '<img class="emojione" alt="'.$alt.'" src="'.self::$imagePathPNG.$filename.'.png'.self::$cacheBustParam.'"/>';
}
}

if(self::$sprites) {
return '<svg class="emojione"><description>'.$alt.'</description><use xlink:href="'.self::$imagePathSVGSprites.'#emoji-'.strtoupper($unicode).'"></use></svg>';
}
else {
return '<object class="emojione" data="'.self::$imagePathSVG.$filename.'.svg" type="image/svg+xml" standby="'.$alt.'">'.$alt.'</object>';
return '<object class="emojione" data="'.self::$imagePathSVG.$filename.'.svg'.self::$cacheBustParam.'" type="image/svg+xml" standby="'.$alt.'">'.$alt.'</object>';
}
}
}
Expand Down Expand Up @@ -2108,15 +2111,15 @@ static function asciiToImageCallback($m) {
return $m[2].'<span class="emojione-'.strtoupper($unicode).'" title="'.htmlspecialchars($shortname).'">'.$alt.'</span>';
}
else {
return $m[2].'<img class="emojione" alt="'.$alt.'" src="'.self::$imagePathPNG.strtoupper($unicode).'.png"/>';
return $m[2].'<img class="emojione" alt="'.$alt.'" src="'.self::$imagePathPNG.strtoupper($unicode).'.png'.self::$cacheBustParam.'"/>';
}
}

if(self::$sprites) {
return $m[2].'<svg class="emojione"><description>'.$alt.'</description><use xlink:href="'.self::$imagePathSVGSprites.'#emoji-'.strtoupper($unicode).'"></use></svg>';
}
else {
return $m[2].'<object class="emojione" data="'.self::$imagePathSVG.strtoupper($unicode).'.svg" type="image/svg+xml" standby="'.$alt.'">'.$alt.'</object>';
return $m[2].'<object class="emojione" data="'.self::$imagePathSVG.strtoupper($unicode).'.svg'.self::$cacheBustParam.'" type="image/svg+xml" standby="'.$alt.'">'.$alt.'</object>';
}
}
}
Expand Down Expand Up @@ -2161,15 +2164,15 @@ static function unicodeToImageCallback($m) {
return '<span class="emojione-'.strtoupper($unicode).'" title="'.htmlspecialchars($shortname).'">'.$alt.'</span>';
}
else {
return '<img class="emojione" alt="'.$alt.'" src="'.self::$imagePathPNG.$filename.'.png"/>';
return '<img class="emojione" alt="'.$alt.'" src="'.self::$imagePathPNG.$filename.'.png'.self::$cacheBustParam.'"/>';
}
}

if(self::$sprites) {
return '<svg class="emojione"><description>'.$alt.'</description><use xlink:href="'.self::$imagePathSVGSprites.'#emoji-'.strtoupper($unicode).'"></use></svg>';
}
else {
return '<object class="emojione" data="'.self::$imagePathSVG.$filename.'.svg" type="image/svg+xml" standby="'.$alt.'">'.$alt.'</object>';
return '<object class="emojione" data="'.self::$imagePathSVG.$filename.'.svg'.self::$cacheBustParam.'" type="image/svg+xml" standby="'.$alt.'">'.$alt.'</object>';
}
}
}
Expand Down

0 comments on commit 60b4816

Please sign in to comment.