fix date calc
[gitlive] / WindowLog.js
index 806b7be..62fe24e 100644 (file)
@@ -20,6 +20,8 @@ Gtk = imports.gi.Gtk ;
 Spawn = imports.Spawn;
 File  = imports.File.File;
 GLib        = imports.gi.GLib;
+Gio = imports.gi.Gio;
+
 //Gtk.init(Seed.argv);
 xDate = imports.Date;
 xorg = imports.xorg;
@@ -78,7 +80,11 @@ WindowLog = {
     },
     lastdir : false,
     
-    write : function (cmd , str) {
+    
+    
+    
+    write : function (cmd , str)
+    {
         
         var dir =  this.outdir + (xDate.newDate()).format("/Y/m");
         if (!this.lastdir || this.lastdir != dir) {
@@ -87,23 +93,26 @@ WindowLog = {
             }
             this.lastdir = dir;
         }
+        var ctime = xDate.newDate();
+        var fname = ctime.format("/d") + ".log";
+        var path  = dir + '/' + fname;
+        var time  = ctime.format("H:i:s ")
         
-        var path = dir + (xDate.newDate()).format("/d") + ".log";
-        var time = (xDate.newDate()).format("H:i:s ")
-        
-        File.append (path, time + str + ' ' + cmd + "\n");
-        
-        return;
-        // upload it..
-        new XMLHttpRequest({
-            url : 'http://www.roojs.com/admin.php', // configurable?
-            method : 'POST',
-            params : {
-                cmd : cmd,
-                title : str,
-                start_dt : (xDate.newDate()).format("Y-m-d H:i:s")
-            }
-        })
+        File.append (path, "\n" +time + str + ' ' + cmd );
+
+        // copy to gitlive/gitlog (each user should check out their own gitlog!?
+        if (this.lastcopy && this.lastcopy > ctime.add(xDate.Date.HOUR, -1)) {
+            return;
+        }
+        this.lastcopy = ctime;
+        var cpdir = imports.GitMonitor.GitMonitor.gitlive +
+                    '/gitlog' +  (xDate.newDate()).format("/Y/m");
+                    
+        if (!File.isDirectory(cpdir)) {
+           File.mkdir(cpdir,true);
+        }
+        File.copy(path, cpdir + fname, Gio.FileCopyFlags.OVERWRITE );
         
         
     }
@@ -111,4 +120,4 @@ WindowLog = {
 }
 
 
-  
\ No newline at end of file
+