ZappeL

flylatex_fixes.patch

Mar 24th, 2013
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Diff 4.93 KB | None | 0 0
  1. --- configs.js.o        2013-03-24 09:44:34.467603639 +0100
  2. +++ configs.js  2013-03-24 09:46:32.813600851 +0100
  3. @@ -2,11 +2,19 @@
  4.      directory: {
  5.         // absolute path of where to store compiled pdfs
  6.         // defaults to "pdfs" directory in "flylatex" repo
  7. -       path: "/Users/alabid/flylatex/blank"
  8. +       path: "/var/www/flylatex/pdfs"
  9.      }
  10.      , db : {
  11.         url : "mongodb://localhost/flydb" // for example: mongodb://localhost/flydb3"
  12.      }
  13. +    , temp : {
  14. +        // set the temppath, empty means default (absolute paths only)
  15. +        path : "/var/www/flylatex/_tmp/"
  16. +    }
  17. +    , pdflatex : {
  18. +        // where to find pdflatex, empty means "pdflatex"
  19. +        command : "/usr/bin/pdflatex"
  20. +    }
  21.  };
  22. --- routes.js.o 2013-03-24 09:44:34.505603638 +0100
  23. +++ routes.js   2013-03-24 10:24:31.566547178 +0100
  24. @@ -43,7 +43,7 @@
  25.  // ================ GLOBAL variables here =============
  26.  
  27.  // maximum number of documents a user can have
  28. -var MAX_DOCS = 20;
  29. +var MAX_DOCS = 100;
  30.  
  31.  // messageTypes
  32.  var MESSAGE_TYPES = {
  33. @@ -1169,7 +1169,7 @@
  34.     var docLines = []
  35.     , lastModified
  36.     , docText;
  37. -
  38. +  
  39.     // get document lines
  40.     doc.lines.forEach(function(item, index) {
  41.         docLines.push(item.data.toString());
  42. @@ -1182,42 +1182,53 @@
  43.     // get the document text
  44.     docText = docLines.join();
  45.  
  46. +   // fixing TEMP Path
  47. +   if(configs.temp.path.lengh !== '' &&  configs.temp.path.substring(0, 1)==='/'){
  48. +       configs.temp.path = '..' + configs.temp.path;
  49. +   }
  50. +
  51. +   // fixing pdflatex path
  52. +   if(configs.pdflatex.command === ''){
  53. +               configs.pdflatex.command = 'pdflatex';
  54. +        }
  55. +                      
  56. +
  57.     // make temporary directory to create and compile latex pdf
  58. -   temp.mkdir("pdfcreator", function(err, dirPath){
  59. +   temp.mkdir(configs.temp.path + "pdfcreator", function(err, dirPath){
  60.         var inputPath = path.join(dirPath, documentId+".tex");
  61. -      
  62. +       try {
  63. +           fs.chmodSync(dirPath, 0766);
  64. +            }catch(e){;}
  65. +            
  66.         fs.writeFile(inputPath, docText, function(err) {
  67.         if (err) {
  68.             response.errors.push("An error occured even before compiling");
  69.             res.json(response);
  70.             return;
  71.         }
  72. -       process.chdir(dirPath);
  73.  
  74.         // compile the document (or at least try)
  75.         // redirect the stdin, stderr results of compilation
  76.         // since the results of compilation will eventually be
  77.         // written to the log file
  78. -       exec("pdflatex -interaction=nonstopmode "+ inputPath +" > /dev/null 2>&1", function(err) {
  79. +       var exStr = configs.pdflatex.command + " -output-directory="+ dirPath +" -interaction=nonstopmode "+ inputPath +" > /dev/null 2>&1";
  80. +       exec(exStr, function(err) {
  81.             // store the logs for the user here
  82.             fs.readFile(path.join(dirPath, documentId+".log"), function(err, data){
  83.             if (err) {
  84. -               response.errors.push("Error while trying to read logs.");
  85. +               response.errors.push("Error while reading compiled data.");
  86. +               console.log(err);
  87. +               res.json(response);
  88. +               fs.remove(dirPath);
  89. +                            return;
  90.             }
  91.            
  92.             // store the 'logs' from the compile
  93.             response.logs = (data ? data.toString() : "");
  94.            
  95. -           var errorStr = "An error occured before or during compilation";
  96. -           if (err) {
  97. -               console.log(err);
  98. -               response.errors.push(errorStr);
  99. -               res.json(response);
  100. -               return;
  101. -           }
  102. +           var errorStr = "An error occured during compilation, please check your document syntax.";
  103.  
  104.             // store the compile pdf document in the cloud
  105. -
  106.             // create new PDFDoc
  107.             var newpdf = new PDFDoc();
  108.             newpdf.forDocument = documentId;
  109. @@ -1230,10 +1241,12 @@
  110.                 console.log(err);
  111.                 response.errors.push(errorStr);
  112.                 res.json(response);
  113. +               fs.remove(dirPath);
  114.                 return;
  115.                 } else {
  116.                 console.log("Successfully saved "+newpdf.title+" in "+configs.directory.path);
  117.                 newpdf.save(function(err) {
  118. +                   fs.remove(dirPath);
  119.                     if (err) {
  120.                     console.log(err);
  121.                     response.errors.push(errorStr);
  122. @@ -1427,8 +1440,7 @@
  123.         newLine.lastModified = new Date();
  124.        
  125.         newLine.save(function(err) {
  126. -       if (!err)
  127. -           console.log("new line saved successfully!");
  128. +       if (!err) console.log("new line saved successfully!");
  129.         });
  130.        
  131.         doc.lines[lineNum] = newLine;
  132. --- public/css/bootstrap.css.o  2013-03-23 20:32:04.852723604 +0100
  133. +++ public/css/bootstrap.css    2013-03-24 09:44:34.468603639 +0100
  134. @@ -791,7 +791,7 @@
  135.    display: inline-block;
  136.    height: 18px;
  137.    padding: 4px;
  138. +/*  margin-bottom: 9px; */
  139. -  margin-bottom: 9px;
  140.    font-size: 13px;  
  141.    line-height: 18px;
  142.    color: #555555;    
  143. @@ -3222,7 +3222,6 @@
  144.  .nav .nav-header {  
  145.    display: block;  
  146.    padding: 3px 15px;
  147. +  margin-bottom:9px;
  148.    font-size: 11px;  
  149.    font-weight: bold;
  150.    line-height: 18px;
  151. @@ -3249,7 +3248,7 @@
  152.  }
  153.  
  154.  .nav-list > li > a {
  155. -  padding: 3px 15px;
  156. +  padding: 5px 15px;
  157.  }
  158.  
  159.  .nav-list > .active > a,
Advertisement
Add Comment
Please, Sign In to add comment