external compiler script is not necessary
This commit is contained in:
parent
2f604ff440
commit
d9af374eb7
2 changed files with 48 additions and 59 deletions
|
@ -1,28 +0,0 @@
|
|||
#!/bin/sh
|
||||
UID="$1"
|
||||
FILE="tmp/$UID/document.ms"
|
||||
OUT="tmp/$UID.pdf"
|
||||
|
||||
# Configuration
|
||||
|
||||
SOELIM="/usr/bin/soelim" # soelim PATH
|
||||
REFER="/usr/bin/refer" # refer PATH
|
||||
GROFF="/usr/bin/groff" # groff PATH
|
||||
PRE="-ketpG" # Preprocessors
|
||||
|
||||
BIB="bibliography" # Bibliography file
|
||||
MAC="macros" # Macros dir
|
||||
|
||||
sed "
|
||||
s/Á/\\\['A\]/g;
|
||||
s/É/\\\['E\]/g;
|
||||
s/Í/\\\['I\]/g;
|
||||
s/Ó/\\\['O\]/g;
|
||||
s/Ú/\\\['U\]/g;
|
||||
s/á/\\\['a\]/g;
|
||||
s/é/\\\['e\]/g;
|
||||
s/í/\\\['i\]/g;
|
||||
s/ó/\\\['o\]/g;
|
||||
s/ú/\\\['u\]/g;
|
||||
" "$FILE" |
|
||||
"$SOELIM" -I "$MAC" | "$REFER" -p "$BIB" | "$GROFF" -mspdf -T pdf -U "$PRE" > "$OUT"
|
|
@ -17,6 +17,17 @@
|
|||
-->
|
||||
<html>
|
||||
|
||||
<?php
|
||||
# Generate an uid for each new document
|
||||
$uid = exec("head /dev/urandom | tr -dc 'a-zA-Z0-9' | head -c 10");
|
||||
# groff settings
|
||||
$groff = "/usr/bin/groff";
|
||||
$comp = "$groff -ketpG -mspdf -Tpdf tmp/$uid.ms > tmp/$uid.pdf";
|
||||
# In case you want to use an external
|
||||
# script to compile with groff:
|
||||
#$comp = "sh groff-compiler.sh";
|
||||
?>
|
||||
|
||||
<head>
|
||||
<title>Groff Web</title>
|
||||
<link rel="shortcut icon" href="#">
|
||||
|
@ -24,73 +35,79 @@
|
|||
* {
|
||||
background-color: #121212;
|
||||
font-family: monospace;
|
||||
margin: 0 0 10px;
|
||||
text-align: center;
|
||||
margin: 4px auto;
|
||||
color: #928374;
|
||||
}
|
||||
|
||||
h1 {
|
||||
margin: 10px 0 0;
|
||||
h1,h2,h3,h4,h5 {
|
||||
color: #fe8019;
|
||||
}
|
||||
|
||||
textarea {
|
||||
background-color: #282828;
|
||||
color: #83a598;
|
||||
textarea,object,.columns {
|
||||
border-radius: 10px;
|
||||
border-width: 1px;
|
||||
max-width: 1300px;
|
||||
width: 100%;
|
||||
columns: 2;
|
||||
}
|
||||
|
||||
body {
|
||||
text-align: center;
|
||||
margin: 0 auto;
|
||||
width: 100%;
|
||||
@media only screen and (max-width: 800px) {
|
||||
.columns {
|
||||
columns: 1;
|
||||
width: 90%;
|
||||
}
|
||||
}
|
||||
|
||||
/* codebox */
|
||||
textarea {
|
||||
background-color: #282828;
|
||||
text-align: left;
|
||||
color: #83a598;
|
||||
height: 734px;
|
||||
}
|
||||
|
||||
/* pdf */
|
||||
object {
|
||||
height: 800px;
|
||||
}
|
||||
|
||||
.button {
|
||||
padding: 5px 10px 5px;
|
||||
border-radius: 10px;
|
||||
border-width: 1px;
|
||||
padding: 5px 30px;
|
||||
margin: 10px;
|
||||
}
|
||||
|
||||
.columns {
|
||||
max-width: 1300px;
|
||||
margin: 0 auto;
|
||||
columns: 2;
|
||||
width: 95%;
|
||||
}
|
||||
|
||||
textarea#codebox {
|
||||
height: 730px;
|
||||
width: 100%;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
|
||||
<?php
|
||||
exec("rm -rf tmp/*");
|
||||
$uid = exec("head -n 10 /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 10 | head -n 1");
|
||||
exec("mkdir -p tmp/$uid");
|
||||
if($_POST['codebox']){
|
||||
$file_open = fopen("tmp/$uid/document.ms","w+");
|
||||
$file_open = fopen("tmp/$uid.ms","w+");
|
||||
fwrite($file_open, $_POST['codebox']);
|
||||
fclose($file_open);
|
||||
}
|
||||
exec("sh compiler.sh $uid");
|
||||
exec("$comp");
|
||||
?>
|
||||
|
||||
<body>
|
||||
<h1>Groff Web</h1>
|
||||
<p><?php echo exec("/usr/bin/groff -v | head -n 1") ?></p>
|
||||
|
||||
<p><?php echo exec("$groff -v | head -n 1")?></p>
|
||||
|
||||
<div class=columns>
|
||||
<div style="width: 100%"><form method="POST">
|
||||
<div><input type=submit value=Compile class=button name=button></div>
|
||||
<div><input type=submit value="Compile PDF" class=button></div>
|
||||
|
||||
<textarea id="codebox" name="codebox"><?php
|
||||
$datalines = file ("tmp/$uid/document.ms");
|
||||
$datalines = file ("tmp/$uid.ms");
|
||||
foreach ($datalines as $zz) {
|
||||
echo $zz; }
|
||||
?></textarea>
|
||||
</form></div>
|
||||
|
||||
<object width="100%" height="800" type="application/pdf" data="/tmp/<?php echo $uid ?>.pdf?#&navpanes=0">
|
||||
<object type="application/pdf" data="/tmp/<?php echo $uid?>.pdf?#&navpanes=0">
|
||||
<p>PDF cannot be displayed.</p>
|
||||
</object>
|
||||
</div>
|
||||
|
|
Loading…
Reference in a new issue