view release on metacpan or search on metacpan
cp/codepress/codepress.html view on Meta::CPAN
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
<title>CodePress - Real Time Syntax Highlighting Editor written in JavaScript</title>
<meta name="description" content="CodePress - source code editor window" />
<script type="text/javascript">
var language = 'generic';
var engine = 'older';
var ua = navigator.userAgent;
var ts = (new Date).getTime(); // timestamp to avoid cache
var lh = location.href;
if(ua.match('MSIE')) engine = 'msie';
else if(ua.match('KHTML')) engine = 'khtml';
else if(ua.match('Opera')) engine = 'opera';
else if(ua.match('Gecko')) engine = 'gecko';
if(lh.match('language=')) language = lh.replace(/.*language=(.*?)(&.*)?$/,'$1');
document.write('<link type="text/css" href="codepress.css?ts='+ts+'" rel="stylesheet" />');
document.write('<link type="text/css" href="languages/'+language+'.css?ts='+ts+'" rel="stylesheet" id="cp-lang-style" />');
document.write('<scr'+'ipt type="text/javascript" src="engines/'+engine+'.js?ts='+ts+'"></scr'+'ipt>');
document.write('<scr'+'ipt type="text/javascript" src="languages/'+language+'.js?ts='+ts+'"></scr'+'ipt>');
</script>
</head>
<script type="text/javascript">
if(engine == "msie" || engine == "gecko") document.write('<body><pre> </pre></body>');
else if(engine == "opera") document.write('<body></body>');
// else if(engine == "khtml") document.write('<body> </body>');
cp/codepress/engines/gecko.js view on Meta::CPAN
words = words.replace(/[\s\n\r\);\W]/g,'\n').split('\n');
return words[words.length-1].replace(/[\W]/gi,'').toLowerCase();
},
snippets : function(evt) {
var snippets = Language.snippets;
var trigger = this.getLastWord();
for (var i=0; i<snippets.length; i++) {
if(snippets[i].input == trigger) {
var content = snippets[i].output.replace(/</g,'<');
content = content.replace(/>/g,'>');
if(content.indexOf('$0')<0) content += cc;
else content = content.replace(/\$0/,cc);
content = content.replace(/\n/g,'<br>');
var pattern = new RegExp(trigger+cc,'gi');
evt.preventDefault(); // prevent the tab key from being added
this.syntaxHighlight('snippets',pattern,content);
}
}
},
cp/codepress/engines/gecko.js view on Meta::CPAN
code = code.replace(/&/gi,'&');
return code;
},
// put code inside editor
setCode : function() {
var code = arguments[0];
code = code.replace(/\u2009/gi,'');
code = code.replace(/&/gi,'&');
code = code.replace(/</g,'<');
code = code.replace(/>/g,'>');
editor.innerHTML = code;
if (code == '')
document.getElementsByTagName('body')[0].innerHTML = '';
},
// undo and redo methods
actions : {
pos : -1, // actual history position
history : [], // history vector
cp/codepress/engines/msie.js view on Meta::CPAN
o = o.replace(/<P>/g,'\n');
o = o.replace(/<\/P>/g,'\r');
o = o.replace(/<.*?>/g,'');
o = o.replace(/ /g,'');
o = '<PRE><P>'+o+'</P></PRE>';
o = o.replace(/\n\r/g,'<P></P>');
o = o.replace(/\n/g,'<P>');
o = o.replace(/\r/g,'<\/P>');
o = o.replace(/<P>(<P>)+/,'<P>');
o = o.replace(/<\/P>(<\/P>)+/,'</P>');
o = o.replace(/<P><\/P>/g,'<P><BR/></P>');
x = z = this.split(o,flag);
if(arguments[1]&&arguments[2]) x = x.replace(arguments[1],arguments[2]);
for(i=0;i<Language.syntax.length;i++)
x = x.replace(Language.syntax[i].input,Language.syntax[i].output);
editor.innerHTML = this.actions.history[this.actions.next()] = (flag=='scroll') ? x : o.replace(z,x);
if(flag!='init') this.findString();
},
snippets : function(evt) {
var snippets = Language.snippets;
var trigger = this.getLastWord();
for (var i=0; i<snippets.length; i++) {
if(snippets[i].input == trigger) {
var content = snippets[i].output.replace(/</g,'<');
content = content.replace(/>/g,'>');
if(content.indexOf('$0')<0) content += cc;
else content = content.replace(/\$0/,cc);
content = content.replace(/\n/g,'</P><P>');
var pattern = new RegExp(trigger+cc,"gi");
this.syntaxHighlight('snippets',pattern,content);
}
}
},
readOnly : function() {
cp/codepress/engines/msie.js view on Meta::CPAN
code = code.replace(/&/gi,'&');
return code;
},
// put code inside editor
setCode : function() {
var code = arguments[0];
code = code.replace(/\u2009/gi,'');
code = code.replace(/&/gi,'&');
code = code.replace(/</g,'<');
code = code.replace(/>/g,'>');
editor.innerHTML = '<pre>'+code+'</pre>';
},
// undo and redo methods
actions : {
pos : -1, // actual history position
history : [], // history vector
undo : function() {
cp/codepress/engines/opera.js view on Meta::CPAN
words = words.replace(/[\s\n\r\);\W]/g,'\n').split('\n');
return words[words.length-1].replace(/[\W]/gi,'').toLowerCase();
},
snippets : function(evt) {
var snippets = Language.snippets;
var trigger = this.getLastWord();
for (var i=0; i<snippets.length; i++) {
if(snippets[i].input == trigger) {
var content = snippets[i].output.replace(/</g,'<');
content = content.replace(/>/g,'>');
if(content.indexOf('$0')<0) content += cc;
else content = content.replace(/\$0/,cc);
content = content.replace(/\n/g,'<br>');
var pattern = new RegExp(trigger+cc,'gi');
evt.preventDefault(); // prevent the tab key from being added
this.syntaxHighlight('snippets',pattern,content);
}
}
},
cp/codepress/engines/opera.js view on Meta::CPAN
code = code.replace(/&/gi,'&');
return code;
},
// put code inside editor
setCode : function() {
var code = arguments[0];
code = code.replace(/\u2009/gi,'');
code = code.replace(/&/gi,'&');
code = code.replace(/</g,'<');
code = code.replace(/>/g,'>');
editor.innerHTML = code;
},
// undo and redo methods
actions : {
pos : -1, // actual history position
history : [], // history vector
undo : function() {
if(editor.innerHTML.indexOf(cc)==-1){
cp/codepress/index.html view on Meta::CPAN
</head>
<body>
<div id="container">
<div id="logo">
<h1><a href="http://codepress.org/">CodePress</a></h1>
<h2><a href="http://codepress.org/">Online Real Time Syntax Highlighting Editor</a></h2>
</div>
<br />
<table cellpadding="0" cellspacing="0" id="menu">
<tr>
<td>
<a href="http://www.codepress.org/index.php">Home/Download</a>
</td>
<td>
<a href="http://www.codepress.org/install.php"> Install </a>
</td>
<td>
cp/codepress/index.html view on Meta::CPAN
<textarea id="cp1" class="codepress php" style="width:700px;height:300px;" wrap="off">
<?php
// Very simple implementation of server side script
if(isset($_GET['file'])) {
$file = basename($_GET['file']);
$full_file = $path['server'].'/'.$path['webdocs'].'/'.$path['files']."/".$file;
if(file_exists($full_file)) {
$code = file_get_contents($full_file);
$code = preg_replace("/>/","&gt;",$code);
$code = preg_replace("/</","&lt;",$code);
$language = getLanguage($file);
}
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
<title>CodePress - Real Time Syntax Highlighting Editor written in JavaScript</title>
<link type="text/css" href="languages/codepress-<?=$language?>.css" rel="stylesheet" id="cp-lang-style" />
<script type="text/javascript" src="codepress.js"></script>
<script type="text/javascript">
CodePress.language = '<?=$language?>';
</script>
</head>
<body id="ffedt"><pre id="ieedt"><?=$code?></pre></body>
</html>
</textarea>
<br /><br />
<textarea id="codepress2" class="codepress javascript linenumbers-off" style="width:700px;height:200px;" wrap="off">
//set language
this.setLanguage = function() {
if(arguments[0]) {
language = (typeof(Content.languages[arguments[0]])!='undefined') ? arguments[0] : this.setLanguage();
cpLanguage.innerHTML = Content.languages[language].name;
if(cpBody.document.designMode=='on') cpBody.document.designMode = 'off';
CodePress.loadScript(cpBody.document, '../languages/'+language+'.js', function () { cpBody.CodePress.syntaxHighlight('init'); })
cpBody.document.getElementById('cp-lang-style').href = '../languages/'+language+'.css';
cp/codepress/index.html view on Meta::CPAN
<button class="actions" onclick="codepress2.toggleReadOnly()">turn on/off read only</button>
</p>
<h3>Installation</h3>
<ol>
<li>
<p>
<a href="http://codepress.org/">Download</a> and uncompress CodePress under a directory inside your webserver.<br>
Example:<strong> http://yourserver/codepress/</strong><br />
Since CodePress is pure JavaScript and HTML, you can also test it without a webserver.
</p>
</li>
<li>
<p>
Insert CodePress script somewhere in your page inside the <code><head></code> or above the <code></body></code> tag.
</p>
<p class="copycode">
<script src="/codepress/codepress.js" type="text/javascript"></script>
</p>
</li>
<li>
<p>
Add the <code><textarea></code> tag to the place on your page you want CodePress to appear. CodePress will inherit the width and height of your textarea.
When the page loads, it will automatically replace your textarea with a CodePress window.
</p>
<p class="copycode">
<textarea id="myCpWindow" class="codepress javascript linenumbers-off"><br />
// your code here<br />
</textarea>
</p>
<ul>
<li>
The <code>javascript</code> portion of the class="" means that the language being edited is JavaScript.
</li>
<li>
The <code>codepress</code> portion of the class="" is mandatory and indicates a textarea to be replaced for a CodePress window.
</li>
<li>
cp/codepress/index.html view on Meta::CPAN
Careful not to use the same id for two different CodePress windows (<code><textarea id="<strong>xx</strong>"...></code>)
</li>
</ul>
</li>
</ol>
<h3>You also can...</h3>
<ol>
<li>
Open/edit code from a different textarea.<br />
Example: <code>textarea_id.edit('other_textarea_id','language')</code><br>
</li>
<li>
Get code from CodePress window.<br />
Example: <code>textarea_id.getCode()</code><br>
</li>
<li>
Turn on/off CodePress editor and return to the regular textarea.<br />
Example: <code>textarea_id.toggleEditor()</code><br>
</li>
<li>
Turn on/off line numbers.<br />
Example: <code>textarea_id.toggleLineNumbers()</code><br>
</li>
<li>
Turn on/off read only.<br />
Example: <code>textarea_id.toggleReadOnly()</code><br>
</li>
<li>
Turn on/off auto-complete.<br />
Example: <code>textarea_id.toggleAutoComplete()</code><br>
</li>
</ol>
<!-- p>
You may want to use [id].getCode() to get the content code from CodePress window and save it to your server since CodePress only edit files and do not save them.
</p>
<p>
You may also want to open files from server. You'll have to write a server side script and replace the JavaScript call on codepress.js from codepress.html to codepress.php (if your server side language is PHP, of course).
cp/codepress/index.html view on Meta::CPAN
<!-- hidden codes for loading -->
<textarea id="cp-php" class="hidden-code">
<?php
// Very simple implementation of server side script
if(isset($_GET['file'])) {
$file = basename($_GET['file']);
$full_file = $path['server'].'/'.$path['webdocs'].'/'.$path['files']."/".$file;
if(file_exists($full_file)) {
$code = file_get_contents($full_file);
$code = preg_replace("/>/","&gt;",$code);
$code = preg_replace("/</","&lt;",$code);
$language = getLanguage($file);
}
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
<title>CodePress - Real Time Syntax Highlighting Editor written in JavaScript</title>
<link type="text/css" href="languages/codepress-<?=$language?>.css" rel="stylesheet" id="cp-lang-style" />
<script type="text/javascript" src="codepress.js"></script>
<script type="text/javascript">
CodePress.language = '<?=$language?>';
</script>
</head>
<body id="ffedt"><pre id="ieedt"><?=$code?></pre></body>
</html>
</textarea>
<textarea id="cp-javascript" class="hidden-code">
cp/codepress/index.html view on Meta::CPAN
<script type="text/javascript">
function getCode() {
alert(textWithoutHighlighting);
}
</script>
</head>
<body>
<div id="logo">
<h1><a href="http://codepress.org/">CodePress</a></h1>
<h2>Online Real Time Syntax Highlighting Editor</h2>
<img src="testimage.gif" />
</div>
<div id="languages">
<em>choose language:</em>
<button onclick="edit('codepress.php',this)" id="default">PHP</button>
<button onclick="edit('FileManager.java',this)">Java</button>
</div>
</body>
</html>
</textarea>
cp/codepress/languages/asp.js view on Meta::CPAN
Language.complete = [
//{ input : '\'', output : '\'$0\'' },
{ input : '"', output : '"$0"' },
{ input : '(', output : '\($0\)' },
{ input : '[', output : '\[$0\]' },
{ input : '{', output : '{\n\t$0\n}' }
]
Language.shortcuts = [
{ input : '[space]', output : ' ' },
{ input : '[enter]', output : '<br />' } ,
{ input : '[j]', output : 'testing' },
{ input : '[7]', output : '&' }
]
cp/codepress/languages/html.js view on Meta::CPAN
Language.snippets = [
{ input : 'aref', output : '<a href="$0"></a>' },
{ input : 'h1', output : '<h1>$0</h1>' },
{ input : 'h2', output : '<h2>$0</h2>' },
{ input : 'h3', output : '<h3>$0</h3>' },
{ input : 'h4', output : '<h4>$0</h4>' },
{ input : 'h5', output : '<h5>$0</h5>' },
{ input : 'h6', output : '<h6>$0</h6>' },
{ input : 'html', output : '<html>\n\t$0\n</html>' },
{ input : 'head', output : '<head>\n\t<meta http-equiv="content-type" content="text/html; charset=utf-8" />\n\t<title>$0</title>\n\t\n</head>' },
{ input : 'img', output : '<img src="$0" alt="" />' },
{ input : 'input', output : '<input name="$0" id="" type="" value="" />' },
{ input : 'label', output : '<label for="$0"></label>' },
{ input : 'legend', output : '<legend>\n\t$0\n</legend>' },
{ input : 'link', output : '<link rel="stylesheet" href="$0" type="text/css" media="screen" charset="utf-8" />' },
{ input : 'base', output : '<base href="$0" />' },
{ input : 'body', output : '<body>\n\t$0\n</body>' },
{ input : 'css', output : '<link rel="stylesheet" href="$0" type="text/css" media="screen" charset="utf-8" />' },
{ input : 'div', output : '<div>\n\t$0\n</div>' },
{ input : 'divid', output : '<div id="$0">\n\t\n</div>' },
{ input : 'dl', output : '<dl>\n\t<dt>\n\t\t$0\n\t</dt>\n\t<dd></dd>\n</dl>' },
{ input : 'fieldset', output : '<fieldset>\n\t$0\n</fieldset>' },
{ input : 'form', output : '<form action="$0" method="" name="">\n\t\n</form>' },
{ input : 'meta', output : '<meta name="$0" content="" />' },
{ input : 'p', output : '<p>$0</p>' },
{ input : 'script', output : '<script type="text/javascript" language="javascript" charset="utf-8">\n\t$0\t\n</script>' },
{ input : 'scriptsrc', output : '<script src="$0" type="text/javascript" language="javascript" charset="utf-8"></script>' },
{ input : 'span', output : '<span>$0</span>' },
{ input : 'table', output : '<table border="$0" cellspacing="" cellpadding="">\n\t<tr><th></th></tr>\n\t<tr><td></td></tr>\n</table>' },
{ input : 'style', output : '<style type="text/css" media="screen">\n\t$0\n</style>' }
]
Language.complete = [
{ input : '\'',output : '\'$0\'' },
cp/codepress/languages/php.js view on Meta::CPAN
Language.complete = [
{ input : '\'', output : '\'$0\'' },
{ input : '"', output : '"$0"' },
{ input : '(', output : '\($0\)' },
{ input : '[', output : '\[$0\]' },
{ input : '{', output : '{\n\t$0\n}' }
]
Language.shortcuts = [
{ input : '[space]', output : ' ' },
{ input : '[enter]', output : '<br />' } ,
{ input : '[j]', output : 'testing' },
{ input : '[7]', output : '&' }
]
cp/codepress/languages/vbscript.js view on Meta::CPAN
Language.complete = [
//{ input : '\'', output : '\'$0\'' },
{ input : '"', output : '"$0"' },
{ input : '(', output : '\($0\)' },
{ input : '[', output : '\[$0\]' },
{ input : '{', output : '{\n\t$0\n}' }
]
Language.shortcuts = [
{ input : '[space]', output : ' ' },
{ input : '[enter]', output : '<br />' } ,
{ input : '[j]', output : 'testing' },
{ input : '[7]', output : '&' }
]
cp/codepress/languages/xsl.js view on Meta::CPAN
Language.snippets = [
{input : 'aref', output : '<a href="$0"></a>' },
{input : 'h1', output : '<h1>$0</h1>' },
{input : 'h2', output : '<h2>$0</h2>' },
{input : 'h3', output : '<h3>$0</h3>' },
{input : 'h4', output : '<h4>$0</h4>' },
{input : 'h5', output : '<h5>$0</h5>' },
{input : 'h6', output : '<h6>$0</h6>' },
{input : 'html', output : '<html>\n\t$0\n</html>' },
{input : 'head', output : '<head>\n\t<meta http-equiv="content-type" content="text/html; charset=utf-8" />\n\t<title>$0</title>\n\t\n</head>' },
{input : 'img', output : '<img src="$0" width="" height="" alt="" border="0" />' },
{input : 'input', output : '<input name="$0" id="" type="" value="" />' },
{input : 'label', output : '<label for="$0"></label>' },
{input : 'legend', output : '<legend>\n\t$0\n</legend>' },
{input : 'link', output : '<link rel="stylesheet" href="$0" type="text/css" media="screen" charset="utf-8" />' },
{input : 'base', output : '<base href="$0" />' },
{input : 'body', output : '<body>\n\t$0\n</body>' },
{input : 'css', output : '<link rel="stylesheet" href="$0" type="text/css" media="screen" charset="utf-8" />' },
{input : 'div', output : '<div>\n\t$0\n</div>' },
{input : 'divid', output : '<div id="$0">\n\t\n</div>' },
{input : 'dl', output : '<dl>\n\t<dt>\n\t\t$0\n\t</dt>\n\t<dd></dd>\n</dl>' },
{input : 'fieldset', output : '<fieldset>\n\t$0\n</fieldset>' },
{input : 'form', output : '<form action="$0" method="" name="">\n\t\n</form>' },
{input : 'meta', output : '<meta name="$0" content="" />' },
{input : 'p', output : '<p>$0</p>' },
{input : 'b', output : '<b>$0</b>' },
{input : 'li', output : '<li>$0</li>' },
{input : 'ul', output : '<ul>$0</ul>' },
{input : 'ol', output : '<ol>$0</ol>' },
{input : 'strong', output : '<strong>$0</strong>' },
{input : 'br', output : '<br />' },
{input : 'script', output : '<script type="text/javascript" language="javascript" charset="utf-8">\n\t$0\t\n</script>' },
{input : 'scriptsrc', output : '<script src="$0" type="text/javascript" language="javascript" charset="utf-8"></script>' },
{input : 'span', output : '<span>$0</span>' },
{input : 'table', output : '<table border="$0" cellspacing="" cellpadding="">\n\t<tr><th></th></tr>\n\t<tr><td></td></tr>\n</table>' },
{input : 'style', output : '<style type="text/css" media="screen">\n\t$0\n</style>' },
{input : 'xsl:stylesheet', output : '<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">' },
{input : 'xsl:template', output : '<xsl:template>$0</xsl:template>' },
{input : 'xsl:for-each', output : '<xsl:for-each select="$0"></xsl:for-each>' },
{input : 'xsl:choose', output : '<xsl:choose>$0<\xsl:choose>' },
{input : 'xsl:param', output : '<xsl:param name="$0" />' },
{input : 'xsl:variable', output : '<xsl:variable name="$0"></xsl:variable>' },
{input : 'xsl:if', output : '<xsl:if test="$0"></xsl:if>' },
{input : 'xsl:when', output : '<xsl:when test="$0"></xsl:when>' },
{input : 'xsl:otherwise', output : '<xsl:otherwise>$0</xsl:otherwise>' },
{input : 'xsl:attribute', output : '<xsl:attribute name="$0"></xsl:attribute>' },
{input : 'xsl:value-of', output : '<xsl:value-of select="$0"/>' },
{input : 'xsl:with-param', output : '<xsl:with-param name="$0" select="" />' },
{input : 'xsl:call-template', output : '<xsl:call-template name="$0">' }
];
Language.complete = [ // Auto complete only for 1 character
{input : '\'',output : '\'$0\'' },
{input : '"', output : '"$0"' },
{input : '(', output : '\($0\)' },
{input : '[', output : '\[$0\]' },
{input : '{', output : '{\n\t$0\n}' }
lib/Alien/CodePress/Archive.pm view on Meta::CPAN
No bugs have been reported.
Please report any bugs or feature requests to
C<bug-alien-codepress@rt.cpan.org>, or through the web interface at
L<http://rt.cpan.org>.
=head1 SEE ALSO
=over 4
=item * L<http://codepress.org/>
The official CodePress home page.
=item * L<Alien>
The manifesto of the Alien namespace.
=back
=head1 AUTHOR