Version Description
- Added ability to cache remote code requests for a set period of time to reduce server load. See Settings > Crayon > Misc. You can clear the cache at any time in settings. Set the cache clearing interval to "Immediately" to prevent caching.
- Fixed a bug preventing dropdown settings from being set correctly
- Fixed AJAX settings bug
- Fixed CSS syntax bug for fonts
- Improved code popup, strips style atts
- Added preview code for shell, renamed to 'Shell'
- Code popup window now shows either highlighted or plain code, depending on which is currently visible
Download this release
Release Info
Developer | akarmenia |
Plugin | Crayon Syntax Highlighter |
Version | 1.5.0 |
Comparing to | |
See all releases |
Code changes from version 1.4.4 to 1.5.0
- crayon_formatter.class.php +1 -2
- crayon_highlighter.class.php +19 -4
- crayon_settings.class.php +29 -5
- crayon_settings_wp.class.php +61 -1
- crayon_wp.class.php +1 -1
- css/style.css +10 -2
- js/crayon.js +12 -3
- langs/sh/sh.txt +2 -2
- log.txt +0 -66
- readme.txt +23 -5
- screenshot-1.png +0 -0
- screenshot-2.png +0 -0
- util/ajax.php +3 -1
- util/crayon_util.class.php +28 -0
- util/sample/sh.txt +12 -0
crayon_formatter.class.php
CHANGED
@@ -32,7 +32,6 @@ class CrayonFormatter {
|
|
32 |
self::$elements = array_values($elements);
|
33 |
$code = preg_replace_callback($regex, 'CrayonFormatter::format_match', $code);
|
34 |
}
|
35 |
-
|
36 |
} catch (Exception $e) {
|
37 |
$error = 'An error occured when formatting: ' . $e->message();
|
38 |
$hl ? $hl->log($error) : CrayonLog::syslog($error);
|
@@ -251,7 +250,7 @@ class CrayonFormatter {
|
|
251 |
$font = CrayonResources::fonts()->get($font_id);
|
252 |
if ($hl->setting_val(CrayonSettings::FONT) != CrayonFonts::DEFAULT_FONT && !empty($font_id) && $font != NULL && !$font->used()) {
|
253 |
$url = CrayonGlobalSettings::plugin_path() . CrayonUtil::pathf(CRAYON_FONT_DIR) . $font_id . '.css?ver' . $CRAYON_VERSION;
|
254 |
-
$output .= '<link rel="
|
255 |
$font_id_dashed = ' crayon-font-' . CrayonUtil::clean_css_name($font_id);
|
256 |
}
|
257 |
|
32 |
self::$elements = array_values($elements);
|
33 |
$code = preg_replace_callback($regex, 'CrayonFormatter::format_match', $code);
|
34 |
}
|
|
|
35 |
} catch (Exception $e) {
|
36 |
$error = 'An error occured when formatting: ' . $e->message();
|
37 |
$hl ? $hl->log($error) : CrayonLog::syslog($error);
|
250 |
$font = CrayonResources::fonts()->get($font_id);
|
251 |
if ($hl->setting_val(CrayonSettings::FONT) != CrayonFonts::DEFAULT_FONT && !empty($font_id) && $font != NULL && !$font->used()) {
|
252 |
$url = CrayonGlobalSettings::plugin_path() . CrayonUtil::pathf(CRAYON_FONT_DIR) . $font_id . '.css?ver' . $CRAYON_VERSION;
|
253 |
+
$output .= '<link rel="stylesheet" type="text/css" href="' . $url . '" />' . CRAYON_NL;
|
254 |
$font_id_dashed = ' crayon-font-' . CrayonUtil::clean_css_name($font_id);
|
255 |
}
|
256 |
|
crayon_highlighter.class.php
CHANGED
@@ -82,11 +82,25 @@ class CrayonHighlighter {
|
|
82 |
$url = 'http://' . $url;
|
83 |
}
|
84 |
$http_code = 0;
|
|
|
85 |
if (function_exists('wp_remote_get')) {
|
86 |
-
|
87 |
-
$
|
88 |
-
|
89 |
-
$
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
90 |
} else {
|
91 |
$ch = curl_init($url);
|
92 |
curl_setopt($ch, CURLOPT_HEADER, FALSE);
|
@@ -95,6 +109,7 @@ class CrayonHighlighter {
|
|
95 |
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
|
96 |
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 20);
|
97 |
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, TRUE);
|
|
|
98 |
curl_setopt($ch, CURLOPT_MAXREDIRS, 5);
|
99 |
curl_setopt($ch, CURLOPT_USERAGENT, $_SERVER['HTTP_USER_AGENT']);
|
100 |
$content = curl_exec($ch);
|
82 |
$url = 'http://' . $url;
|
83 |
}
|
84 |
$http_code = 0;
|
85 |
+
// If available, use the built in wp remote http get function, we don't need SSL
|
86 |
if (function_exists('wp_remote_get')) {
|
87 |
+
$url_uid = 'crayon_' . CrayonUtil::str_uid($url);
|
88 |
+
$cached = get_transient($url_uid, 'crayon-syntax');
|
89 |
+
CrayonSettingsWP::load_cache();
|
90 |
+
if ($cached !== FALSE) {
|
91 |
+
$content = $cached;
|
92 |
+
$http_code = 200;
|
93 |
+
} else {
|
94 |
+
$response = wp_remote_get($url, array('sslverify' => false, 'timeout' => 20));
|
95 |
+
$content = wp_remote_retrieve_body($response);
|
96 |
+
$http_code = wp_remote_retrieve_response_code($response);
|
97 |
+
$cache = $this->setting_val(CrayonSettings::CACHE);
|
98 |
+
$cache_sec = CrayonSettings::get_cache_sec($cache);
|
99 |
+
if ($cache_sec > 1 && $http_code >= 200 && $http_code < 400) {
|
100 |
+
set_transient($url_uid, $content, $cache_sec);
|
101 |
+
CrayonSettingsWP::add_cache($url_uid);
|
102 |
+
}
|
103 |
+
}
|
104 |
} else {
|
105 |
$ch = curl_init($url);
|
106 |
curl_setopt($ch, CURLOPT_HEADER, FALSE);
|
109 |
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
|
110 |
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 20);
|
111 |
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, TRUE);
|
112 |
+
curl_setopt($ch, CURLOPT_FRESH_CONNECT, FALSE);
|
113 |
curl_setopt($ch, CURLOPT_MAXREDIRS, 5);
|
114 |
curl_setopt($ch, CURLOPT_USERAGENT, $_SERVER['HTTP_USER_AGENT']);
|
115 |
$content = curl_exec($ch);
|
crayon_settings.class.php
CHANGED
@@ -66,6 +66,19 @@ class CrayonSettings {
|
|
66 |
const ERROR_MSG_SHOW = 'error-msg-show';
|
67 |
const ERROR_MSG = 'error-msg';
|
68 |
const HIDE_HELP = 'hide-help';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
69 |
|
70 |
// The current settings, should be loaded with default if none exists
|
71 |
private $settings = array();
|
@@ -91,7 +104,6 @@ class CrayonSettings {
|
|
91 |
global $CRAYON_VERSION;
|
92 |
$settings = array(
|
93 |
new CrayonSetting(self::VERSION, $CRAYON_VERSION, NULL, TRUE),
|
94 |
-
|
95 |
new CrayonSetting(self::THEME, CrayonThemes::DEFAULT_THEME),
|
96 |
new CrayonSetting(self::FONT, CrayonFonts::DEFAULT_FONT),
|
97 |
new CrayonSetting(self::FONT_SIZE_ENABLE, FALSE),
|
@@ -144,7 +156,8 @@ class CrayonSettings {
|
|
144 |
new CrayonSetting(self::ERROR_LOG_SYS, TRUE),
|
145 |
new CrayonSetting(self::ERROR_MSG_SHOW, TRUE),
|
146 |
new CrayonSetting(self::ERROR_MSG, 'An error has occurred. Please try again later.'),
|
147 |
-
new CrayonSetting(self::HIDE_HELP, FALSE)
|
|
|
148 |
);
|
149 |
|
150 |
$this->set($settings);
|
@@ -570,12 +583,16 @@ class CrayonSetting {
|
|
570 |
*/
|
571 |
function value($value = NULL) {
|
572 |
if ($value === NULL) {
|
573 |
-
if ($this->is_array) {
|
574 |
return $this->default[$this->value]; // value at index
|
575 |
-
} else if ($this->value !== NULL) {
|
576 |
return $this->value;
|
577 |
} else {
|
578 |
-
|
|
|
|
|
|
|
|
|
579 |
}
|
580 |
} else if ($this->locked === FALSE) {
|
581 |
if ($this->is_array) {
|
@@ -586,6 +603,13 @@ class CrayonSetting {
|
|
586 |
}
|
587 |
}
|
588 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
589 |
|
590 |
/**
|
591 |
* Sets/gets default value.
|
66 |
const ERROR_MSG_SHOW = 'error-msg-show';
|
67 |
const ERROR_MSG = 'error-msg';
|
68 |
const HIDE_HELP = 'hide-help';
|
69 |
+
const CACHE = 'cache';
|
70 |
+
|
71 |
+
private static $cache_array = array('Hourly' => 3600, 'Daily' => 86400, 'Weekly' => 604800, 'Monthly' => 18144000, 'Immediately' => 1);
|
72 |
+
|
73 |
+
public static function get_cache_sec($cache) {
|
74 |
+
$values = array_values(self::$cache_array);
|
75 |
+
//$cache = $this->get(self::CACHE);
|
76 |
+
if (array_key_exists($cache, $values)) {
|
77 |
+
return $values[$cache];
|
78 |
+
} else {
|
79 |
+
return $values[0];
|
80 |
+
}
|
81 |
+
}
|
82 |
|
83 |
// The current settings, should be loaded with default if none exists
|
84 |
private $settings = array();
|
104 |
global $CRAYON_VERSION;
|
105 |
$settings = array(
|
106 |
new CrayonSetting(self::VERSION, $CRAYON_VERSION, NULL, TRUE),
|
|
|
107 |
new CrayonSetting(self::THEME, CrayonThemes::DEFAULT_THEME),
|
108 |
new CrayonSetting(self::FONT, CrayonFonts::DEFAULT_FONT),
|
109 |
new CrayonSetting(self::FONT_SIZE_ENABLE, FALSE),
|
156 |
new CrayonSetting(self::ERROR_LOG_SYS, TRUE),
|
157 |
new CrayonSetting(self::ERROR_MSG_SHOW, TRUE),
|
158 |
new CrayonSetting(self::ERROR_MSG, 'An error has occurred. Please try again later.'),
|
159 |
+
new CrayonSetting(self::HIDE_HELP, FALSE),
|
160 |
+
new CrayonSetting(self::CACHE, array_keys(self::$cache_array), 1),
|
161 |
);
|
162 |
|
163 |
$this->set($settings);
|
583 |
*/
|
584 |
function value($value = NULL) {
|
585 |
if ($value === NULL) {
|
586 |
+
/*if ($this->is_array) {
|
587 |
return $this->default[$this->value]; // value at index
|
588 |
+
} else */if ($this->value !== NULL) {
|
589 |
return $this->value;
|
590 |
} else {
|
591 |
+
if ($this->is_array) {
|
592 |
+
return 0;
|
593 |
+
} else {
|
594 |
+
return $this->default;
|
595 |
+
}
|
596 |
}
|
597 |
} else if ($this->locked === FALSE) {
|
598 |
if ($this->is_array) {
|
603 |
}
|
604 |
}
|
605 |
}
|
606 |
+
|
607 |
+
function array_value() {
|
608 |
+
if ($this->is_array) {
|
609 |
+
return NULL;
|
610 |
+
}
|
611 |
+
return $this->default[$this->value];
|
612 |
+
}
|
613 |
|
614 |
/**
|
615 |
* Sets/gets default value.
|
crayon_settings_wp.class.php
CHANGED
@@ -13,11 +13,14 @@ class CrayonSettingsWP {
|
|
13 |
|
14 |
// A copy of the current options in db
|
15 |
private static $options = NULL;
|
|
|
|
|
16 |
private static $plugin_hook = '';
|
17 |
|
18 |
const SETTINGS = 'crayon_fields';
|
19 |
const FIELDS = 'crayon_settings';
|
20 |
const OPTIONS = 'crayon_options';
|
|
|
21 |
const GENERAL = 'crayon_general';
|
22 |
const DEBUG = 'crayon_debug';
|
23 |
const ABOUT = 'crayon_about';
|
@@ -139,6 +142,51 @@ class CrayonSettingsWP {
|
|
139 |
update_option(self::OPTIONS, CrayonGlobalSettings::get_array());
|
140 |
}
|
141 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
142 |
public static function wp_root_path() {
|
143 |
return preg_replace('#wp\-content.*#', '', CRAYON_ROOT_PATH);
|
144 |
}
|
@@ -200,7 +248,7 @@ class CrayonSettingsWP {
|
|
200 |
global $CRAYON_EMAIL;
|
201 |
// When reset button is pressed, remove settings so default loads next time
|
202 |
if (array_key_exists('reset', $inputs)) {
|
203 |
-
|
204 |
return array();
|
205 |
}
|
206 |
// Clear the log if needed
|
@@ -216,10 +264,19 @@ class CrayonSettingsWP {
|
|
216 |
CrayonLog::email($CRAYON_EMAIL);
|
217 |
}
|
218 |
|
|
|
|
|
|
|
|
|
|
|
219 |
// Validate inputs
|
220 |
foreach ($inputs as $input => $value) {
|
221 |
// Convert all array setting values to ints
|
222 |
$inputs[$input] = CrayonSettings::validate($input, $value);
|
|
|
|
|
|
|
|
|
223 |
}
|
224 |
|
225 |
// If settings don't exist in input, set them to default
|
@@ -498,6 +555,9 @@ class CrayonSettingsWP {
|
|
498 |
}
|
499 |
|
500 |
public static function misc() {
|
|
|
|
|
|
|
501 |
self::checkbox(array(CrayonSettings::TOUCHSCREEN, 'Disable mouse gestures for touchscreen devices (eg. MouseOver)'));
|
502 |
self::checkbox(array(CrayonSettings::DISABLE_ANIM, 'Disable animations'));
|
503 |
self::checkbox(array(CrayonSettings::DISABLE_RUNTIME, 'Disable runtime stats'));
|
13 |
|
14 |
// A copy of the current options in db
|
15 |
private static $options = NULL;
|
16 |
+
// An array of cache names for use with Transients API
|
17 |
+
private static $cache = NULL;
|
18 |
private static $plugin_hook = '';
|
19 |
|
20 |
const SETTINGS = 'crayon_fields';
|
21 |
const FIELDS = 'crayon_settings';
|
22 |
const OPTIONS = 'crayon_options';
|
23 |
+
const CACHE = 'crayon_cache';
|
24 |
const GENERAL = 'crayon_general';
|
25 |
const DEBUG = 'crayon_debug';
|
26 |
const ABOUT = 'crayon_about';
|
142 |
update_option(self::OPTIONS, CrayonGlobalSettings::get_array());
|
143 |
}
|
144 |
|
145 |
+
// Cache
|
146 |
+
public static function add_cache($name) {
|
147 |
+
self::load_cache();
|
148 |
+
if (!in_array($name, self::$cache)) {
|
149 |
+
self::$cache[] = $name;
|
150 |
+
}
|
151 |
+
self::save_cache();
|
152 |
+
}
|
153 |
+
|
154 |
+
public static function remove_cache($name) {
|
155 |
+
self::load_cache();
|
156 |
+
if (in_array($name, self::$cache)) {
|
157 |
+
unset(self::$cache[$name]);
|
158 |
+
}
|
159 |
+
self::save_cache();
|
160 |
+
}
|
161 |
+
|
162 |
+
public static function clear_cache() {
|
163 |
+
self::load_cache();
|
164 |
+
foreach (self::$cache as $name) {
|
165 |
+
delete_transient($name);
|
166 |
+
}
|
167 |
+
self::$cache = array();
|
168 |
+
self::save_cache();
|
169 |
+
}
|
170 |
+
|
171 |
+
public static function load_cache() {
|
172 |
+
/*if (self::$cache !== NULL) {
|
173 |
+
return;
|
174 |
+
}*/
|
175 |
+
// Load cache from db
|
176 |
+
if (!(self::$cache = get_option(self::CACHE))) {
|
177 |
+
self::$cache = array();
|
178 |
+
update_option(self::CACHE, self::$cache);
|
179 |
+
}
|
180 |
+
}
|
181 |
+
|
182 |
+
public static function save_cache() {
|
183 |
+
update_option(self::CACHE, self::$cache);
|
184 |
+
self::load_cache();
|
185 |
+
}
|
186 |
+
|
187 |
+
|
188 |
+
// Paths
|
189 |
+
|
190 |
public static function wp_root_path() {
|
191 |
return preg_replace('#wp\-content.*#', '', CRAYON_ROOT_PATH);
|
192 |
}
|
248 |
global $CRAYON_EMAIL;
|
249 |
// When reset button is pressed, remove settings so default loads next time
|
250 |
if (array_key_exists('reset', $inputs)) {
|
251 |
+
self::clear_cache();
|
252 |
return array();
|
253 |
}
|
254 |
// Clear the log if needed
|
264 |
CrayonLog::email($CRAYON_EMAIL);
|
265 |
}
|
266 |
|
267 |
+
// Clear the cache
|
268 |
+
if (array_key_exists('crayon-cache-clear', $_POST)) {
|
269 |
+
self::clear_cache();
|
270 |
+
}
|
271 |
+
|
272 |
// Validate inputs
|
273 |
foreach ($inputs as $input => $value) {
|
274 |
// Convert all array setting values to ints
|
275 |
$inputs[$input] = CrayonSettings::validate($input, $value);
|
276 |
+
// Clear cache when changed
|
277 |
+
if ($input == CrayonSettings::CACHE && $value != CrayonGlobalSettings::val(CrayonSettings::CACHE)) {
|
278 |
+
self::clear_cache();
|
279 |
+
}
|
280 |
}
|
281 |
|
282 |
// If settings don't exist in input, set them to default
|
555 |
}
|
556 |
|
557 |
public static function misc() {
|
558 |
+
echo 'Clear the cache used to store remote code requests: ';
|
559 |
+
self::dropdown(CrayonSettings::CACHE, false);
|
560 |
+
echo '<input type="submit" id="crayon-cache-clear" name="crayon-cache-clear" class="button-secondary" value="Clear Now" /><br/>';
|
561 |
self::checkbox(array(CrayonSettings::TOUCHSCREEN, 'Disable mouse gestures for touchscreen devices (eg. MouseOver)'));
|
562 |
self::checkbox(array(CrayonSettings::DISABLE_ANIM, 'Disable animations'));
|
563 |
self::checkbox(array(CrayonSettings::DISABLE_RUNTIME, 'Disable runtime stats'));
|
crayon_wp.class.php
CHANGED
@@ -3,7 +3,7 @@
|
|
3 |
Plugin Name: Crayon Syntax Highlighter
|
4 |
Plugin URI: http://ak.net84.net/
|
5 |
Description: Supports multiple languages, themes, highlighting from a URL, local file or post text. <a href="options-general.php?page=crayon_settings">View Settings.</a>
|
6 |
-
Version: 1.
|
7 |
Author: Aram Kocharyan
|
8 |
Author URI: http://ak.net84.net/
|
9 |
License: GPL2
|
3 |
Plugin Name: Crayon Syntax Highlighter
|
4 |
Plugin URI: http://ak.net84.net/
|
5 |
Description: Supports multiple languages, themes, highlighting from a URL, local file or post text. <a href="options-general.php?page=crayon_settings">View Settings.</a>
|
6 |
+
Version: 1.5.0
|
7 |
Author: Aram Kocharyan
|
8 |
Author URI: http://ak.net84.net/
|
9 |
License: GPL2
|
css/style.css
CHANGED
@@ -44,17 +44,25 @@ coloring etc.
|
|
44 |
}
|
45 |
|
46 |
.crayon-popup {
|
47 |
-
position: static !important
|
|
|
|
|
|
|
|
|
|
|
|
|
48 |
}
|
49 |
|
50 |
.crayon-popup .crayon-main,
|
51 |
.crayon-popup .crayon-table {
|
|
|
|
|
52 |
display: block !important;
|
53 |
opacity: 100 !important;
|
54 |
margin: 0 !important;
|
55 |
padding: 0 !important;
|
56 |
width: 100% !important;
|
57 |
-
height: auto !important
|
58 |
}
|
59 |
|
60 |
.crayon-syntax,
|
44 |
}
|
45 |
|
46 |
.crayon-popup {
|
47 |
+
/*position: static !important;*/
|
48 |
+
}
|
49 |
+
|
50 |
+
.crayon-popup .crayon-plain {
|
51 |
+
display: block !important;
|
52 |
+
width: 100% !important;
|
53 |
+
height: 100% !important;
|
54 |
}
|
55 |
|
56 |
.crayon-popup .crayon-main,
|
57 |
.crayon-popup .crayon-table {
|
58 |
+
/*max-width: 0;
|
59 |
+
max-height: 0;
|
60 |
display: block !important;
|
61 |
opacity: 100 !important;
|
62 |
margin: 0 !important;
|
63 |
padding: 0 !important;
|
64 |
width: 100% !important;
|
65 |
+
height: auto !important;*/
|
66 |
}
|
67 |
|
68 |
.crayon-syntax,
|
js/crayon.js
CHANGED
@@ -217,8 +217,10 @@ function code_popup(uid) {
|
|
217 |
if (typeof crayon[uid] == 'undefined') {
|
218 |
return make_uid(uid);
|
219 |
}
|
|
|
220 |
var settings = crayon[uid].popup_settings;
|
221 |
-
settings.data = get_all_css() + '<body style="padding:0; margin:0;"><div class="' + crayon[uid].attr('class') +
|
|
|
222 |
if (typeof settings == 'undefined') {
|
223 |
return;
|
224 |
}
|
@@ -228,6 +230,10 @@ function get_jquery_str(object) {
|
|
228 |
return jQuery('<div>').append(object.clone()).remove().html();
|
229 |
}
|
230 |
|
|
|
|
|
|
|
|
|
231 |
// Get all CSS on the page as a string
|
232 |
function get_all_css() {
|
233 |
var css_str = ''
|
@@ -353,6 +359,7 @@ function toggle_plain(uid, hover, select) {
|
|
353 |
if (hover) {
|
354 |
visible = main;
|
355 |
hidden = plain;
|
|
|
356 |
} else {
|
357 |
visible = plain;
|
358 |
hidden = main;
|
@@ -361,11 +368,11 @@ function toggle_plain(uid, hover, select) {
|
|
361 |
if (main.css('z-index') == 1) {
|
362 |
visible = main;
|
363 |
hidden = plain;
|
364 |
-
crayon[uid].plain_visible = true;
|
365 |
} else {
|
366 |
visible = plain;
|
367 |
hidden = main;
|
368 |
-
crayon[uid].plain_visible = false;
|
369 |
}
|
370 |
}
|
371 |
|
@@ -418,6 +425,8 @@ function toggle_plain(uid, hover, select) {
|
|
418 |
plain.focus();
|
419 |
}
|
420 |
}
|
|
|
|
|
421 |
});
|
422 |
|
423 |
// Restore scroll positions to hidden
|
217 |
if (typeof crayon[uid] == 'undefined') {
|
218 |
return make_uid(uid);
|
219 |
}
|
220 |
+
var code = crayon[uid].plain_visible ? crayon[uid].plain : crayon[uid].main;
|
221 |
var settings = crayon[uid].popup_settings;
|
222 |
+
settings.data = get_all_css() + '<body style="padding:0; margin:0;"><div class="' + crayon[uid].attr('class') +
|
223 |
+
' crayon-popup">' + remove_css_inline(get_jquery_str(code)) + '</div></body>';
|
224 |
if (typeof settings == 'undefined') {
|
225 |
return;
|
226 |
}
|
230 |
return jQuery('<div>').append(object.clone()).remove().html();
|
231 |
}
|
232 |
|
233 |
+
function remove_css_inline(string) {
|
234 |
+
return string.replace(/style="[^"]+"/mi, '');
|
235 |
+
}
|
236 |
+
|
237 |
// Get all CSS on the page as a string
|
238 |
function get_all_css() {
|
239 |
var css_str = ''
|
359 |
if (hover) {
|
360 |
visible = main;
|
361 |
hidden = plain;
|
362 |
+
//crayon[uid].plain_visible = true;
|
363 |
} else {
|
364 |
visible = plain;
|
365 |
hidden = main;
|
368 |
if (main.css('z-index') == 1) {
|
369 |
visible = main;
|
370 |
hidden = plain;
|
371 |
+
//crayon[uid].plain_visible = true;
|
372 |
} else {
|
373 |
visible = plain;
|
374 |
hidden = main;
|
375 |
+
//crayon[uid].plain_visible = false;
|
376 |
}
|
377 |
}
|
378 |
|
425 |
plain.focus();
|
426 |
}
|
427 |
}
|
428 |
+
|
429 |
+
crayon[uid].plain_visible = (hidden == plain);
|
430 |
});
|
431 |
|
432 |
// Restore scroll positions to hidden
|
langs/sh/sh.txt
CHANGED
@@ -2,8 +2,8 @@
|
|
2 |
|
3 |
# ELEMENT_NAME [optional-css-class] REGULAR_EXPRESSION
|
4 |
|
5 |
-
NAME Shell
|
6 |
-
VERSION 1.
|
7 |
|
8 |
COMMENT (?default)|(#.*?$)
|
9 |
STRING (?default)
|
2 |
|
3 |
# ELEMENT_NAME [optional-css-class] REGULAR_EXPRESSION
|
4 |
|
5 |
+
NAME Shell
|
6 |
+
VERSION 1.1
|
7 |
|
8 |
COMMENT (?default)|(#.*?$)
|
9 |
STRING (?default)
|
log.txt
CHANGED
@@ -1,66 +0,0 @@
|
|
1 |
-
==============================================================================
|
2 |
-
Crayon Syntax Highlighter Log Entry
|
3 |
-
==============================================================================
|
4 |
-
8:58:32 AM - 07 Nov 2011
|
5 |
-
string(135) "The provided URL ('https://raw.github.com/aramkocharyan/jQueryPopup/master/jquery.popup.js') could not be accessed locally or remotely."
|
6 |
-
------------------------------------------------------------------------------
|
7 |
-
8:58:34 AM - 07 Nov 2011
|
8 |
-
string(55) "The specified URL is empty, please provide a valid URL."
|
9 |
-
------------------------------------------------------------------------------
|
10 |
-
==============================================================================
|
11 |
-
Crayon Syntax Highlighter Log Entry
|
12 |
-
==============================================================================
|
13 |
-
10:13:05 AM - 07 Nov 2011
|
14 |
-
string(55) "The specified URL is empty, please provide a valid URL."
|
15 |
-
------------------------------------------------------------------------------
|
16 |
-
==============================================================================
|
17 |
-
Crayon Syntax Highlighter Log Entry
|
18 |
-
==============================================================================
|
19 |
-
10:41:56 AM - 07 Nov 2011
|
20 |
-
string(55) "The specified URL is empty, please provide a valid URL."
|
21 |
-
------------------------------------------------------------------------------
|
22 |
-
==============================================================================
|
23 |
-
Crayon Syntax Highlighter Log Entry
|
24 |
-
==============================================================================
|
25 |
-
10:41:57 AM - 07 Nov 2011
|
26 |
-
string(55) "The specified URL is empty, please provide a valid URL."
|
27 |
-
------------------------------------------------------------------------------
|
28 |
-
==============================================================================
|
29 |
-
Crayon Syntax Highlighter Log Entry
|
30 |
-
==============================================================================
|
31 |
-
10:55:53 AM - 07 Nov 2011
|
32 |
-
string(135) "The provided URL ('https://raw.github.com/aramkocharyan/jQueryPopup/master/jquery.popup.js') could not be accessed locally or remotely."
|
33 |
-
------------------------------------------------------------------------------
|
34 |
-
10:55:55 AM - 07 Nov 2011
|
35 |
-
string(55) "The specified URL is empty, please provide a valid URL."
|
36 |
-
------------------------------------------------------------------------------
|
37 |
-
==============================================================================
|
38 |
-
Crayon Syntax Highlighter Log Entry
|
39 |
-
==============================================================================
|
40 |
-
10:56:28 AM - 07 Nov 2011
|
41 |
-
string(55) "The specified URL is empty, please provide a valid URL."
|
42 |
-
------------------------------------------------------------------------------
|
43 |
-
==============================================================================
|
44 |
-
Crayon Syntax Highlighter Log Entry
|
45 |
-
==============================================================================
|
46 |
-
11:08:51 AM - 07 Nov 2011
|
47 |
-
string(134) "Local url (Users/Aram/Development/Web/crayon/wp-content/plugins/crayon-syntax-highlighter/util/sample/default.txt) could not be loaded"
|
48 |
-
------------------------------------------------------------------------------
|
49 |
-
==============================================================================
|
50 |
-
Crayon Syntax Highlighter Log Entry
|
51 |
-
==============================================================================
|
52 |
-
11:08:59 AM - 07 Nov 2011
|
53 |
-
string(134) "Local url (Users/Aram/Development/Web/crayon/wp-content/plugins/crayon-syntax-highlighter/util/sample/default.txt) could not be loaded"
|
54 |
-
------------------------------------------------------------------------------
|
55 |
-
==============================================================================
|
56 |
-
Crayon Syntax Highlighter Log Entry
|
57 |
-
==============================================================================
|
58 |
-
11:09:13 AM - 07 Nov 2011
|
59 |
-
string(134) "Local url (Users/Aram/Development/Web/crayon/wp-content/plugins/crayon-syntax-highlighter/util/sample/default.txt) could not be loaded"
|
60 |
-
------------------------------------------------------------------------------
|
61 |
-
==============================================================================
|
62 |
-
Crayon Syntax Highlighter Log Entry
|
63 |
-
==============================================================================
|
64 |
-
11:22:21 AM - 07 Nov 2011
|
65 |
-
string(55) "The specified URL is empty, please provide a valid URL."
|
66 |
-
------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
readme.txt
CHANGED
@@ -4,7 +4,7 @@ Donate link: http://ak.net84.net/
|
|
4 |
Tags: syntax highlighter, syntax, highlighter, highlighting, crayon, code highlighter
|
5 |
Requires at least: 3.0
|
6 |
Tested up to: 3.3
|
7 |
-
Stable tag: 1.
|
8 |
|
9 |
Syntax Highlighter supporting multiple languages, themes, fonts, highlighting from a URL, local file or post text.
|
10 |
|
@@ -15,12 +15,13 @@ It can highlight from a URL, a local file or Wordpress post text. Crayon makes i
|
|
15 |
custom language elements with regular expressions.
|
16 |
It also supports some neat features like:
|
17 |
|
18 |
-
* Mobile/touchscreen device detection
|
19 |
-
* Mouse event interaction (showing plain code on double click, toolbar on mouseover)
|
20 |
* Toggled plain code
|
21 |
* Toggled line numbers
|
22 |
* Copy/paste code
|
23 |
-
* Open code in a new window
|
|
|
|
|
|
|
24 |
* Tab sizes
|
25 |
* Code title
|
26 |
* Toggled toolbar
|
@@ -56,6 +57,13 @@ Live Demo: <a href="http://bit.ly/poKNqs" target="_blank">http://bit.ly/poKNqs</
|
|
56 |
|
57 |
Short How-To: <a href="http://ak.net84.net/projects/crayon-syntax-highlighter/" target="_blank">http://ak.net84.net/projects/crayon-syntax-highlighter/</a>
|
58 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
59 |
== Installation ==
|
60 |
|
61 |
Download the .zip of the plugin and extract the contents. Upload it to the Wordpress plugin directory and activate the plugin.
|
@@ -77,10 +85,20 @@ Contact me at http://twitter.com/crayonsyntax or crayon.syntax@gmail.com.
|
|
77 |
|
78 |
== Screenshots ==
|
79 |
|
80 |
-
1.
|
|
|
81 |
|
82 |
== Changelog ==
|
83 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
84 |
= 1.4.4 =
|
85 |
* Revised CSS style printing
|
86 |
* Fixed bugs with the "open in new window" and copy/paste actions
|
4 |
Tags: syntax highlighter, syntax, highlighter, highlighting, crayon, code highlighter
|
5 |
Requires at least: 3.0
|
6 |
Tested up to: 3.3
|
7 |
+
Stable tag: 1.5.0
|
8 |
|
9 |
Syntax Highlighter supporting multiple languages, themes, fonts, highlighting from a URL, local file or post text.
|
10 |
|
15 |
custom language elements with regular expressions.
|
16 |
It also supports some neat features like:
|
17 |
|
|
|
|
|
18 |
* Toggled plain code
|
19 |
* Toggled line numbers
|
20 |
* Copy/paste code
|
21 |
+
* Open code in a new window (popup)
|
22 |
+
* Remote request caching
|
23 |
+
* Mobile/touchscreen device detection
|
24 |
+
* Mouse event interaction (showing plain code on double click, toolbar on mouseover)
|
25 |
* Tab sizes
|
26 |
* Code title
|
27 |
* Toggled toolbar
|
57 |
|
58 |
Short How-To: <a href="http://ak.net84.net/projects/crayon-syntax-highlighter/" target="_blank">http://ak.net84.net/projects/crayon-syntax-highlighter/</a>
|
59 |
|
60 |
+
**Planned Features**
|
61 |
+
|
62 |
+
* Translations
|
63 |
+
* Multiple highlighting per Crayon
|
64 |
+
* Highlighting priority
|
65 |
+
* Theme Editor
|
66 |
+
|
67 |
== Installation ==
|
68 |
|
69 |
Download the .zip of the plugin and extract the contents. Upload it to the Wordpress plugin directory and activate the plugin.
|
85 |
|
86 |
== Screenshots ==
|
87 |
|
88 |
+
1. Classic theme in Live Preview under Settings > Crayon.
|
89 |
+
2. Twilight theme.
|
90 |
|
91 |
== Changelog ==
|
92 |
|
93 |
+
= 1.5.0 =
|
94 |
+
* Added ability to cache remote code requests for a set period of time to reduce server load. See Settings > Crayon > Misc. You can clear the cache at any time in settings. Set the cache clearing interval to "Immediately" to prevent caching.
|
95 |
+
* Fixed a bug preventing dropdown settings from being set correctly
|
96 |
+
* Fixed AJAX settings bug
|
97 |
+
* Fixed CSS syntax bug for fonts
|
98 |
+
* Improved code popup, strips style atts
|
99 |
+
* Added preview code for shell, renamed to 'Shell'
|
100 |
+
* Code popup window now shows either highlighted or plain code, depending on which is currently visible
|
101 |
+
|
102 |
= 1.4.4 =
|
103 |
* Revised CSS style printing
|
104 |
* Fixed bugs with the "open in new window" and copy/paste actions
|
screenshot-1.png
CHANGED
Binary file
|
screenshot-2.png
ADDED
Binary file
|
util/ajax.php
CHANGED
@@ -1,9 +1,11 @@
|
|
1 |
<?php
|
2 |
|
|
|
|
|
3 |
require_once(dirname(dirname(__FILE__)) . '/crayon_wp.class.php');
|
4 |
require_once(CrayonSettingsWP::wp_load_path());
|
5 |
|
6 |
-
|
7 |
|
8 |
if ( array_key_exists(CrayonSettings::HIDE_HELP, $_GET) && $_GET[CrayonSettings::HIDE_HELP] ) {
|
9 |
CrayonGlobalSettings::set(CrayonSettings::HIDE_HELP, TRUE);
|
1 |
<?php
|
2 |
|
3 |
+
// Used to send requests to db from jQuery
|
4 |
+
|
5 |
require_once(dirname(dirname(__FILE__)) . '/crayon_wp.class.php');
|
6 |
require_once(CrayonSettingsWP::wp_load_path());
|
7 |
|
8 |
+
CrayonSettingsWP::load_settings(true);
|
9 |
|
10 |
if ( array_key_exists(CrayonSettings::HIDE_HELP, $_GET) && $_GET[CrayonSettings::HIDE_HELP] ) {
|
11 |
CrayonGlobalSettings::set(CrayonSettings::HIDE_HELP, TRUE);
|
util/crayon_util.class.php
CHANGED
@@ -281,6 +281,34 @@ class CrayonUtil {
|
|
281 |
$path = self::pathf($path);
|
282 |
return preg_replace('#\.\w+$#m', '', $path);
|
283 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
284 |
|
285 |
// strpos with an array of $needles
|
286 |
public static function strposa($haystack, $needles) {
|
281 |
$path = self::pathf($path);
|
282 |
return preg_replace('#\.\w+$#m', '', $path);
|
283 |
}
|
284 |
+
|
285 |
+
// Shorten a URL into a string of given length, used to identify a URL uniquely
|
286 |
+
public static function shorten_url_to_length($url, $length) {
|
287 |
+
if ($length < 1) {
|
288 |
+
return '';
|
289 |
+
}
|
290 |
+
$url = preg_replace('#(^\w+://)|([/\.])#si', '', $url);
|
291 |
+
if (strlen($url) > $length) {
|
292 |
+
$diff = strlen($url) - $length;
|
293 |
+
$rem = floor(strlen($url)/$diff);
|
294 |
+
$rem_count = 0;
|
295 |
+
for ($i = $rem-1; $i < strlen($url) && $rem_count < $diff; $i=$i+$rem) {
|
296 |
+
$url[$i] = '.';
|
297 |
+
$rem_count++;
|
298 |
+
}
|
299 |
+
$url = preg_replace('#\.#s', '', $url);
|
300 |
+
}
|
301 |
+
return $url;
|
302 |
+
}
|
303 |
+
|
304 |
+
// Creates a unique ID from a string
|
305 |
+
function str_uid($str) {
|
306 |
+
$uid = 0;
|
307 |
+
for ($i = 1; $i < strlen($str); $i++) {
|
308 |
+
$uid += round(ord($str[$i]) * ($i / strlen($str)), 2) * 100;
|
309 |
+
}
|
310 |
+
return strval(dechex(strlen($str))).strval(dechex($uid));
|
311 |
+
}
|
312 |
|
313 |
// strpos with an array of $needles
|
314 |
public static function strposa($haystack, $needles) {
|
util/sample/sh.txt
ADDED
@@ -0,0 +1,12 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
#!/bin/bash
|
2 |
+
for jpg in "$@" ; do
|
3 |
+
png="${jpg%.jpg}.png"
|
4 |
+
echo converting "$jpg" ...
|
5 |
+
if convert "$jpg" jpg.to.png ; then
|
6 |
+
mv jpg.to.png "$png"
|
7 |
+
else
|
8 |
+
echo 'error: failed output saved in "jpg.to.png".' 1>&2
|
9 |
+
exit 1
|
10 |
+
fi
|
11 |
+
done
|
12 |
+
echo all conversions successful
|