( jc – 29.03.2010 1:04)
Textile mit highlight_string() verheiraten..
Mittels eines recht trivialen Hacks läßt sich die PHP Funktion highlight_string() zum syntax-highliting von PHP Code innerhalb von ganz normalen, textile-formatierten Textblöcken einsetzen. Notwendig sind lediglich 5 10 15 zusätzliche Zeilen in der class.textile.inc.php.
Beispiel
Textile Standard..
<?php
if (!function_exists('fb')) {
function fb() {
echo 'no FirePHP installed!';
}
}
?>
vs. Patch …
<?php
if (!function_exists('fb')) {
function fb() {
echo 'no FirePHP installed!';
}
}
?>
..auch ohne PHP tags
// see mom, no tags!
if (!function_exists('fb')) {
function fb() {
echo 'no FirePHP installed!';
}
}
..und mit Leerzeilen
// jetzt auch..
if (!function_exists('fb')) {
function fb() { // ..mit Leerstand
echo 'no FirePHP installed!';
}
}
Textile markup
Die Standard-tags pre. und bc. bleiben von dem Hack unberührt und verhalten sich wie immer, da für den Umweg über die highlight_string() Funktion ein eigenes textile-tag hinzukommt.. z.b. bcphp. .
Für zwischendurch..
Dieser Hack kann natürlich keine ernsthafte Syntax highlighter ersetzen, und bei längerem, komplexen Code wird er evtl. auch ausstiegen, aber um mal eben innerhalb eines Textile Text-Blocks (wie auf dieser Seite.. alles ein Modul/Block) ein bischen Code zu bemalen reichts allemal.
Patch
// Zeile 254: "rexcode" in das tag array einfügen..
$this->btag = array('bq', 'bc', 'rexcode', 'notextile', 'pre', 'h[1-6]', 'fn\d+', 'p');
// Zeile 641 ff.: elseif Block für das rexcode tag..
elseif ($tag == 'rexcode') {
if(strpos($atts,'class=') !== false) {
$atts = str_replace('class="','class="'.$tag.' ',$atts);
}
else {
$atts = ' class="'.$tag.'"';
}
$o1 = '<p '.$atts.'>';
$c1 = '</p>';
$o2 = $c2 ='';
$content = '<?php'.$content.' ?>';
$content = highlight_string($content, TRUE);
$content = preg_replace('/<\?php/', '', $content, 1);
$content = preg_replace('/\?>(?!.*\?>)/', '', $content);
$content = $this->shelve($content.'<br /><br />'); // 2! Leerzeichen vor slash! Würden sonst wg. üblicher post Textile Ersetzung verloren gehen!
}
Andere Sprachen
Rein aus Neugier um mal zu sehn was passiert.. Ergebnisse überwiegend zwischen “ok, immerhin bunt” und komplett unbrauchbar (CSS), außer JS: nicht soo schlecht.
JS
<script type="text/javascript">
<!--
jQuery(function($) {
$("#rex-form-login").focus();
$("#javascript").val("1");
var time_el = $("div.rex-message p span strong");
if(time_el.length == 1) {
function disableLogin() {
time_el.html((parseInt(time_el.html(), 10)-1) + "");
if(parseInt(time_el.html(), 10) > 0) {
setTimeout(disableLogin, 1000);
} else {
$("div.rex-message p span").html("Bitte anmelden.");
$("#loginformular input:not(:hidden)").attr("disabled", "");
$("#rex-form-login").focus();
}
};
$("#loginformular input:not(:hidden)").attr("disabled", "disabled");
setTimeout(disableLogin, 1000);
}
});
//-->
</script>
CSS
/* RexHELP Overrides*/
.hud_content {background:white;}
#RexHELP .hud_content {background: transparent url(pwc/themes/hud/C.png);}
.RexHelpContent {display:none;}
#RexHELP {
filter:alpha(opacity=90);
-moz-opacity: 0.9;
opacity:0.9;
}
div.dialog table.top,
div.dialog table.bot,
div.dialog table td.hud_w,
div.dialog table td.hud_e
{
filter:alpha(opacity=90);
-moz-opacity: 0.9;
opacity:0.9;
}
#RexHELP #HELPContent {margin:0;padding:8px;}
#RexHELP #HELPContent h1 {color:#ffffff;font-size:18px;}
#RexHELP #HELPContent > h1 {margin-top:0;padding-top:0;}
#RexHELP #HELPContent h1.helptopic
{
color:silver;
background:#464B52 url(/files/_rexhelp/icon_help.png)no-repeat 8px 4px;
padding:4px 4px 4px 34px;
margin:0 0 0 0;
-moz-border-radius:4px;
-webkit-border-radius:4px;
}
#RexHELP #HELPContent h1.navi
{
color:silver;
background:#464B52 url(/files/_rexhelp/icon_navi.png)no-repeat 8px 4px;
padding:4px 4px 4px 34px;
margin:0 0 0 0;
-moz-border-radius:4px;
-webkit-border-radius:4px;
}
/* RexHELP #HELPContent > h1:before {content:"/// ";color:#34AAFE} */
#RexHELP #HELPContent .error h1 {color:red;font-size:14px;}
#RexHELP #HELPContent h2 {color:#efefef;font-size:18px;}
#RexHELP #HELPContent h3 {color:#f6f6f6;font-size:14px;}
#RexHELP #HELPContent h4 {color:gray;font-size:12px;}
#RexHELP #HELPContent table {margin:0;padding:0;}
#RexHELP #HELPContent ul {padding:3px 0 3px 15px;font-size:12px;}
#RexHELP #HELPContent ul ul {
background:url(/files/_layout/bg_grey_20.png);
padding:4px 8px 4px 8px;
-moz-border-radius:4px;
-webkit-border-radius:4px;}
#RexHELP #HELPContent ul li {color:silver;font-size:14px;font-weight:bold;margin-top:4px;list-style-type:decimal;list-style-position:inside}
#RexHELP #HELPContent ul ul li {font-size:12px;font-weight:bold;margin-top:2px;list-style-type:none;list-style-position:outside;}
#RexHELP #HELPContent ul ul ul li {font-size:12px;font-weight:normal;list-style-type:none;list-style-position:outside;}
#RexHELP #HELPContent a {color:#24ABFF;text-decoration:none;/*list-style-type:circle;*/}
#RexHELP #HELPContent a:hover {color:#57A9DD;/*list-style-type:circle;*/}
#RexHELP #HELPContent a:active {color:red;/*list-style-type:circle;*/}
#RexHELP #HELPContent input {background:white;color:black;}
/* textile hilfe*/
#RexHELP #HELPContent .a79_help_overview h3.a79 {display:none;}
#RexHELP #HELPContent .a79_help_overview table {background:transparent;border:0;}
#RexHELP #HELPContent .a79_help_overview thead {/*border:1px solid #464B52*/;background:transparent;}
#RexHELP #HELPContent .a79_help_overview tbody {border-left:45px solid #30353C;}
#RexHELP #HELPContent .a79_help_overview thead th {/*background:#383D44*/;padding:4px;font-size:14px;webkit-border-radius:4px;text-align:left;}
#RexHELP #HELPContent .a79_help_overview thead th a {background:url(/files/_rexhelp/arrow_closed.gif) no-repeat;padding-left:20px;}
#RexHELP #HELPContent .a79_help_overview tbody th {border:1px solid #464B52;background:#464B52;color:silver;width:49%;}
#RexHELP #HELPContent .a79_help_overview td {background:#3D4148;/*border:1px solid #464B52;*/padding:1px 1px 1px 8px;}
#RexHELP #HELPContent .a79_help_overview col {}
#RexHELP #HELPContent .a79_help_overview .helpchapter {display:block;}
BASH
#!/bin/bash
#
# Usage: fixidcs3jobtitle job user title copies options [filename]
#
# Main use: CUPS filter to fix InDesign 5.0.0 (ID CS3) job titles in
# PostScript print jobs containing special characters, eg. umlauts.
# Tested with CUPS 1.1.23
#
#############################################################################
#
# author: Thomas Kaiser <mailto:Thomas.Kaiser@phg-online.de>
# url: http://kaiser-edv.de/en/CUPS/fixidcs3jobtitle-filter
# license: http://www.opensource.org/licenses/bsd-license.php
# date: 1 May 2007 (v0.1.1)
# kudos to: Axel Rose for the Perl code below (hacked together in his limited
# spare time)
#
#############################################################################
#
# Changes
#
# 0.1.1: - fixed version which transparently handles the PS code passed through
#
# 0.1.0: - first official release (30 Apr 2007)
#
#############################################################################
#
# Non-Warranty:
# This script comes with absolutely no warranty.
#
# Use at your own risk!
#
#############################################################################
case $# in
5)
# print job is on stdin
echo "DEBUG: filter postscript stream originating from stdin" >&2
cat | perl -CO -ne 'if(/^%%Title: ]+)>?$/){$m=$1;if($m!~/^FEFF/){print}else{while($m=~/(.{4})/g){$s=$1;next if$s eq"FEFF";last if$s eq"0000";$t.=pack("U*",hex($s));}print"%%Title: $t\n";}}else{print}' | /usr/libexec/cups/filter/pstops "$1" "$2" "$3" "$4" "$5"
;;
6)
# print job is $6
echo "DEBUG: filter postscript stream originating from \"$6\"" >&2
cat "$6" | perl -CO -ne 'if(/^%%Title: ]+)>?$/){$m=$1;if(!~/^FEFF/){print}else{while($m=~/(.{4})/g){$s=$1;next if$s eq"FEFF";last if$s eq"0000";$t.=pack("U*",hex($s));}print"%%Title: $t\n";}}else{print}' | /usr/libexec/cups/filter/pstops "$1" "$2" "$3" "$4" "$5"
;;
*)
echo "ERROR: $(basename "$0") job user title copies options [filename]" >&2
;;
esac
Applescript
(*
* mp3-Dropbox Folder Action Applescript
*
* @version 0.3
* @author rexdev.de
*
* $Id: mp3-dropbox.applescript 9 2010-03-17 15:00:01Z jeffe $:
*)
-- # PROPERTIES ------------------------------------------------------------------
property DelayTime : 5
property verbosity : 0
property useGROWL : false
property useSPEECH : false
property LogPath : (path to desktop as string) & "mp3_dropbox_error_log.txt"
property playlistROOT : "DROPBOX"
-- # GROWL ------------------------------------------------------------------
property GROWLactive : false
property GROWLregistered : false
property GallNotificationsList : {"mp3-Dropbox Folder Action", "Status Message", "Error Message", "Debug Message"}
property GenabledNotificationsList : {"mp3-Dropbox Folder Action", "Status Message", "Error Message"}
-- # MAIN ROUTINE ---------------------------------------------------------------------------
if useGROWL then
check4GROWL() -- Growl installed and active?
if GROWLactive = true and GROWLregistered = false then
registerGROWL() -- register this script with Growl
end if
end if
on adding folder items to watchedFOLDER after receiving addedITEMS
-- # CREATE ROOT FOLDER
makePLAYLIST(false, playlistROOT)
tellME("The following files have been added", 2)
repeat with f in addedITEMS
tellME((name of (info for f)), 2)
tellME("Checking transfer state of file " & name of (info for f), 3)
set oldSize to 0
set newSize to -1
-- When newSize equals oldSize, it means the copy is complete because the size hasn't changed.
repeat while newSize is not equal to oldSize
-- Get the file size.
set oldSize to size of (info for f)
delay DelayTime
-- Sample the size again after delay for comparison.
set newSize to size of (info for f)
end repeat
tellME("The file" & name of (info for f) & "has been fully transfered.", 3)
-- iTunes
try
if (folder of (info for f)) = true then
-- # CREATE SPECIFIC PLAYLIST ACCORDING TO FOLDER NAME
makePLAYLIST(name of (info for f), playlistROOT)
tell application "iTunes" to add f to playlist (name of (info for f))
else
-- # CREATE GENERIC PLAYLIST PER DAY
set today to do shell script "date +%d.%m.%y"
makePLAYLIST(today, playlistROOT)
tell application "iTunes" to add f to playlist today
end if
on error errMsg number errNr
tellME(errMsg, 3)
if errMsg does not start with "Es ist ein Fehler" then
set Fehlertext to errNr & tab & errMsg
writeCodes(Fehlertext)
-- log (errNr as string) & tab & errMsg
end if
end try
tell application "Finder" to set the label index of f to 4
end repeat
end adding folder items to
-- # SUBROUTINES ---------------------------------------------------------------------------
on check4GROWL()
set psax to do shell script "ps ax | grep --count -i GrowlHelperApp"
if psax ? 1 then
set GROWLactive to true
end if
end check4GROWL
on registerGROWL()
if GROWLregistered is false then
if GROWLactive is true then
tell application "GrowlHelperApp"
set the allNotificationsList to GallNotificationsList
set the enabledNotificationsList to GenabledNotificationsList
register as application "mp3-Dropbox Folder Action" all notifications allNotificationsList default notifications enabledNotificationsList icon of application "Script Editor"
end tell
growl("mp3-Dropbox Folder Action", "mp3-Dropbox Folder Action", "Successfully registered with Growl..", "mp3-Dropbox Folder Action")
end if
end if
end registerGROWL
on growl(Gname, Gtitle, Gdescritption, Gappname)
if GROWLactive = true then
tell application "GrowlHelperApp" to notify with name Gname title Gtitle description Gdescritption application name Gappname
end if
end growl
on tellME(msg, thisVERBOSITY)
if thisVERBOSITY ? verbosity then
if useGROWL then
--growl("Name der notification (def:GallNotificationsList)", "Fenstertitel", "Text", "Name der registrierten App")
growl("Status Message", "Status Message", msg, "mp3-Dropbox Folder Action")
end if
if useSPEECH then
say msg using "Vicki"
end if
end if
end tellME
on writeCodes(Fehlertext)
set tRef to (open for access file LogPath with write permission)
set Datei_Ende to (get eof tRef)
if Datei_Ende = 0 then
set neuerText to Fehlertext
else
set neuerText to return & Fehlertext
end if
try
write neuerText to tRef starting at Datei_Ende + 1
close access tRef
on error
close access tRef
end try
end writeCodes
on makePLAYLIST(thePLAYLIST, PLAYLISTfolder)
tell application "iTunes"
if PLAYLISTfolder is not false and PLAYLISTfolder is not in (name of folder playlists) then
make new folder playlist with properties {name:PLAYLISTfolder}
if verbosity > 1 then my tellME("Playlist folder created: " & PLAYLISTfolder)
end if
if thePLAYLIST is not false and thePLAYLIST is not in (name of playlists) then
make new playlist with properties {name:thePLAYLIST}
move playlist thePLAYLIST to folder playlist PLAYLISTfolder
if verbosity > 1 then my tellME("Playlist created: " & thePLAYLIST)
end if
end tell
end makePLAYLIST