Skip to content

Commit

Permalink
Moving tmp dir outside of the public web dir.
Browse files Browse the repository at this point in the history
  • Loading branch information
parpalak committed Nov 13, 2024
1 parent 4bcf894 commit 3971d69
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 12 deletions.
12 changes: 6 additions & 6 deletions config.php.dist
Original file line number Diff line number Diff line change
Expand Up @@ -7,23 +7,23 @@
*/

define('TEX_PATH', '/usr/local/texlive/${tlversion}/bin/x86_64-linux/');
define('SVGO_PATH', __DIR__.'/node_modules/svgo/bin');
define('SVGO_PATH', __DIR__ . '/node_modules/svgo/bin');

/**
* Setting up directories
* Must be absolute
*/

// LaTeX document templates
define('TPL_DIR', __DIR__.'/tpl/');
define('TPL_DIR', __DIR__ . '/tpl/');

// Render errors log
define('LOG_DIR', __DIR__.'/tex_logs');
define('LOG_DIR', __DIR__ . '/tex_logs');

// Cache and temp dirs
define('TMP_DIR', 'tmp/');
define('CACHE_SUCCESS_DIR', __DIR__.'/www/_cache/');
define('CACHE_FAIL_DIR', __DIR__.'/www/_error/');
define('TMP_DIR', __DIR__ . '/tmp/');
define('CACHE_SUCCESS_DIR', __DIR__ . '/www/_cache/');
define('CACHE_FAIL_DIR', __DIR__ . '/www/_error/');

/**
* Setting up rendering scale
Expand Down
6 changes: 4 additions & 2 deletions test/autotest.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,17 @@
$isDebug = false;
error_reporting(E_ALL);

$tmpDir = 'tmp/';

// Setting up external commands
define('LATEX_COMMAND', TEX_PATH . 'latex -output-directory=' . TMP_DIR);
define('LATEX_COMMAND', TEX_PATH . 'latex -output-directory=' . $tmpDir);
define('DVISVG_COMMAND', TEX_PATH . 'dvisvgm %1$s -o %1$s.svg -n --exact -v0 --zoom=' . OUTER_SCALE);
define('SVG2PNG_COMMAND', 'rsvg-convert %1$s -z 4 -b white'); // stdout, 4x zoom

echo "\n", 'Using ', TEX_PATH, "\n\n";

$templater = new Templater(TPL_DIR);
$renderer = new Renderer($templater, 'tmp/', TEX_PATH, LATEX_COMMAND, DVISVG_COMMAND);
$renderer = new Renderer($templater, $tmpDir, TEX_PATH, LATEX_COMMAND, DVISVG_COMMAND);
$renderer
->setLogger(new Logger('log/'))
->setIsDebug($isDebug)
Expand Down
6 changes: 4 additions & 2 deletions test/test.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,18 @@
$isDebug = defined('DEBUG') && DEBUG;
error_reporting(E_ALL);

$tmpDir = 'tmp/';

// Setting up external commands
define('LATEX_COMMAND', TEX_PATH . 'latex -output-directory=' . TMP_DIR);
define('LATEX_COMMAND', TEX_PATH . 'latex -output-directory=' . $tmpDir);
define('DVISVG_COMMAND', TEX_PATH . 'dvisvgm %1$s -o %1$s.svg -n --exact -v0 --zoom=' . OUTER_SCALE);
// define('DVIPNG_COMMAND', TEX_PATH.'dvipng -T tight %1$s -o %1$s.png -D '.(96 * OUTER_SCALE)); // outdated
define('SVG2PNG_COMMAND', 'rsvg-convert %1$s -d 96 -p 96 -b white'); // stdout

echo "\n", 'Using ', TEX_PATH, "\n\n";

$templater = new Templater(TPL_DIR);
$renderer = new Renderer($templater, 'tmp/', TEX_PATH, LATEX_COMMAND, DVISVG_COMMAND);
$renderer = new Renderer($templater, $tmpDir, TEX_PATH, LATEX_COMMAND, DVISVG_COMMAND);
$renderer
->setPngConverter(new PngConverter(SVG2PNG_COMMAND))
->setLogger(new Logger('log/'))
Expand Down
4 changes: 2 additions & 2 deletions www/tmp/.gitignore → tmp/.gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
*
!.gitignore
*
!.gitignore

0 comments on commit 3971d69

Please sign in to comment.