<?php
$HOME = "/home/autonoma";
$JAVA_HOME = "$HOME/bin/jdk";
$JAVA_OPTS = "-client \
-Dfile.encoding=UTF-8 \
-Xmx100m \
-XX:+SuppressFatalErrorMessage \
-XX:ReservedCodeCacheSize=64m \
-XX:OnError='rm hs_err_pid%p.log' \
-Xss256k";
$KEENQUOTES = "$HOME/bin/keenquotes.jar";
$CMD = "timeout 5 $JAVA_HOME/bin/java $JAVA_OPTS -jar $KEENQUOTES";
$source = "";
if( $_SERVER[ 'REQUEST_METHOD' ] == 'POST' ) {
$source = isset( $_POST[ 'source' ] ) ? $_POST[ 'source' ] : "";
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<title>KeenQuotes - Curl straight quotes</title>
<meta charset="utf-8" />
<link rel="stylesheet" href="dark5.min.css" type="text/css" />
<style>
@font-face {
font-family: 'GFSDidot-Regular';
font-style: normal;
font-weight: normal;
src: url('fonts/GFSDidot-Regular.eot');
src:
url("fonts/GFSDidot-Regular.otf") format("opentype"),
url("fonts/GFSDidot-Regular.eot?#iefix") format('embedded-opentype'),
url("fonts/GFSDidot-Regular.woff2") format('woff2'),
url("fonts/GFSDidot-Regular.woff") format('woff'),
url("fonts/GFSDidot-Regular.ttf") format('truetype'),
url("fonts/GFSDidot-Regular.svg#GFSDidot-Regular") format('svg');
}
body {
font-size: 14pt;
}
p.output {
white-space: pre-line;
font-size: 16pt;
font-family: 'GFSDidot-Regular', serif;
}
p.newlines {
white-space: pre;
}
input[type="text"], textarea {
background-color:
color:
}
textarea
width: 80%;
max-width: 80%;
}
</style>
</head>
<body>
<h1>KeenQuotes</h1>
<p>
KeenQuotes converts straight quotes and apostrophes to curly quotes.
</p>
<p>Paste your prose into the text area then click <strong>Curl</strong>:</p>
<form method="post">
<textarea id="source" name="source" rows="5" cols="60" autofocus><?php
if( !empty( $source ) ) {
echo htmlspecialchars( $source, ENT_QUOTES, 'UTF-8' );
}
?></textarea>
<br />
<input type="submit" value="Curl" />
<button type="button" id="sample-button">Sample</button>
<?php
if( !empty( $source ) ) {
?>
<button type="button" id="copy-button">Copy</button>
<hr style="background-color: #ccc; width: 100%;" />
<?php
}
?>
</form>
<?php
if( $_SERVER[ 'REQUEST_METHOD' ] == 'POST' && empty( $source ) ) {
?>
<p>
Don't be shy, provide some text to curl.
</p>
<?php
}
elseif( !empty( $source ) ) {
$descriptors = array(
0 => array( "pipe", "r" ),
1 => array( "pipe", "w" ),
2 => array( "pipe", "w" )
);
$proc = proc_open( $CMD, $descriptors, $pipes );
fwrite( $pipes[0], $source );
fclose( $pipes[0] );
$stdout = stream_get_contents( $pipes[1] );
$stderr = stream_get_contents( $pipes[2] );
fclose( $pipes[1] );
fclose( $pipes[2] );
$code = proc_close( $proc );
if( $code < 0 ) {
echo "Processing error, please try again.";
}
else {
echo "<p id='output' class='output'>" .
htmlspecialchars( $stdout, ENT_QUOTES, 'UTF-8' ) . "</p>";
}
}
?>
<footer>
© 2022 White Magic Software, Ltd.
</footer>
<script>
function fallbackSetClipboard( text ) {
var textarea = document.createElement( "textarea" );
textarea.value = text;
textarea.style.top = "0";
textarea.style.left = "0";
textarea.style.position = "fixed";
document.body.appendChild( textarea );
textarea.focus();
textarea.select();
try {
document.execCommand( 'copy' );
} catch( err ) {
alert( 'Copy failed' );
}
document.body.removeChild( textarea );
}
function setClipboard( text ) {
if( navigator.clipboard ) {
navigator.clipboard.writeText( text ).then( function() {
console.log( 'Copied!' );
}, function( err ) {
alert( 'Copy failed' );
});
}
else {
fallbackSetClipboard( text );
}
}
var copyButton = document.getElementById( 'copy-button' );
if( copyButton ) {
copyButton.addEventListener( 'click', function( event ) {
var output = document.getElementById( 'output' );
var oldClass = output.className;
output.className = 'newlines';
var text = output.innerText || output.textContent;
setClipboard( text );
output.className = oldClass;
});
}
var sampleButton = document.getElementById( 'sample-button' );
if( sampleButton ) {
sampleButton.addEventListener( 'click', function( event ) {
var source = document.getElementById( 'source' );
source.value = "''E's got a 'ittle box 'n a big 'un,' she said, 'wit' th' 'ittle 'un 'bout 2'×6\". An' no, y'ain't cryin' on th' \"soap box\" to me no mo, y'hear. 'Cause it 'tweren't ever a spec o' fun!' I says to my frien'.";
});
}
</script>
</body>
</html>