Skip to content

New files_latexeditor code #5

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 12 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
20 changes: 19 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,28 @@ files_latexeditor
=================

File Latex Editor/compiler APP for OwnCloud 5.x and above
You MUST disabled the standard "Text Editor" to allow this one.
The standard "Text Editor" must be enabled.

installation
=================
- run 'apt-get install texlive'
- change to owncloud app directory 'cd /var/www/owncloud/apps'
- now run 'git clone https://github.com/domcars0/files_latexeditor.git'
- open change to your webinterface and open the apps page <your-ip>/owncloud/index.php/settings/apps
- search for 'LatexTex Editor and Compiler' and activate it

note
=================
Latexeditor does not seem to work with the encryption app from ownloud

change log
=================
27.01.2014
Merge the erasche feature (Adds support for selection of LaTeX compiler) and bug fixe for multiple directories latex project.
Bug fixed when owncloud is not installed in the root of the webServer.
01.12.2013
Remove all the files_texteditor code.
We detect now if the editor is open and then add (or not) the Compile button.
30.11.2013
compatibility with OC5
If a shared directory contains a tex file, friends can compile.
Expand Down
25 changes: 16 additions & 9 deletions ajax/compile.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,13 @@
set_time_limit(0); //scanning can take ages

$dir = isset($_POST['path']) ? $_POST['path'] : '';
$pdflatex = isset($_POST['pdflatex']) ? (bool) $_POST['pdflatex'] : false;

// Check if we've been given a compiler, otherwise use latex as default
$compiler = isset($_POST['compiler']) ? $_POST['compiler'] : 'latex';
// If they've set the compiler to something other than an allowable option....
if( !($compiler === 'xelatex' || $compiler === 'pdflatex' || $compiler === 'latex')){
$compiler = 'latex';
}
$file = isset($_POST['filename']) ? $_POST['filename'] : '';

$userid = OCP\USER::getUser();
Expand All @@ -32,15 +38,16 @@

$outpath = "/tmp/latex_" . $userid . "_" . $projectname;

$mkdir_command = "mkdir -p " . $outpath ;
$copy_directory_tree_command = "rsync -av -f\"+ */\" -f\"- *\" $workdir/ $outpath";
$cd_command = "cd " . str_replace(' ','\ ',trim($workdir)) ;
if ($pdflatex === true)
$latex_command .= "pdflatex -output-directory $outpath $file";
if($compiler == 'xelatex' || $compiler == 'pdflatex')
$latex_command .= $compiler . " -output-directory $outpath $file";
else
$latex_command .= "latex -output-directory=$outpath $file ; cd $outpath; dvips $dvifile ; ps2pdf $psfile";
$latex_command = "latex -output-directory=$outpath $file ; cd $outpath; dvips $dvifile ; ps2pdf $psfile";

$output = "========BEGIN COMPILE $psfile ======== \n "; // % $latex_command\n";

$return = shell_exec($mkdir_command . " && " . $cd_command . " && " . $latex_command);
$return = shell_exec($copy_directory_tree_command . " && " . $cd_command . " && " . $latex_command);
$log = file_get_contents($outpath . '/' . $logfile);

while (preg_match('/Rerun to get cross-references right/',$log) || preg_match('/No file '.$tocfile.'/',$log)){
Expand Down Expand Up @@ -77,7 +84,7 @@

if(file_exists($workdir . '/' . $pdffile))
\OC\Files\Filesystem::unlink($workdir . '/' . $pdffile);
if (!$pdflatex && file_exists($workdir . '/' . $psfile) )
if ($compiler === 'latex' && file_exists($workdir . '/' . $psfile) )
\OC\Files\Filesystem::unlink($workdir . '/' . $psfile);

if (!@rename(trim($outpath . '/' . $pdffile), trim($workdir . '/'. $pdffile))) {
Expand All @@ -87,7 +94,7 @@
$output.="<strong>" . trim($outpath . '/' . $pdffile) . " to " . trim($workdir . '/' . $pdffile) . "</strong>";
} else {
$output.="<strong> Copy " . trim($outpath . '/' . $pdffile) . " to " . trim($workdir . '/' . $pdffile) . "</strong>";
if (!$pdflatex) {
if ($compiler === 'latex') {
if (!@rename(trim($outpath . '/' . $psfile), trim($workdir . '/' . $psfile))) {
$errors = error_get_last();
$output.="\n>>>> " . $l->t("COPY ERROR: ") . $errors['type'];
Expand All @@ -101,7 +108,7 @@
$target = OCP\Files::buildNotExistingFileName(stripslashes($workdir), $pdffile);
$target = \OC\Files\Filesystem::normalizePath($target);
$meta = \OC\Files\Filesystem::getFileInfo($target);
if (!$pdflatex) {
if ( $compiler === 'latex' ) {
$target = OCP\Files::buildNotExistingFileName(stripslashes($workdir), $psfile);
$target = \OC\Files\Filesystem::normalizePath($target);
$meta = \OC\Files\Filesystem::getFileInfo($target);
Expand Down
54 changes: 0 additions & 54 deletions ajax/loadfile.php

This file was deleted.

49 changes: 0 additions & 49 deletions ajax/mtime.php

This file was deleted.

15 changes: 0 additions & 15 deletions ajax/phplatex/compile.php

This file was deleted.

51 changes: 0 additions & 51 deletions ajax/phplatex/layout.html

This file was deleted.

12 changes: 0 additions & 12 deletions ajax/phplatex/simple/simple.aux

This file was deleted.

84 changes: 0 additions & 84 deletions ajax/phplatex/simple/simple.log

This file was deleted.

Binary file removed ajax/phplatex/simple/simple.pdf
Binary file not shown.
Loading