]> jfr.im git - irc/kvirc/kvirc-scripts.git/commitdiff
fixed W3C script
authorFabio Bas <redacted>
Fri, 19 Mar 2010 12:52:39 +0000 (12:52 +0000)
committerFabio Bas <redacted>
Fri, 19 Mar 2010 12:52:39 +0000 (12:52 +0000)
TODO.txt
W3C/install.kvs
W3C/utils/installer.kvs [new file with mode: 0644]

index 94266bcd9f5e9726c7f677985594fd9597fe2b88..e7f0c3026633b6e053925ddcb46b6d3210b9a36e 100644 (file)
--- a/TODO.txt
+++ b/TODO.txt
@@ -4,9 +4,6 @@ Please keep this list up to date.
 Forza4
 KISS
 NGL fserv
-TODO.txt
-W3C
-calculator
 chanops
 chanstats
 checkers
index f19ee941cc1b8cf121f0319899b0ca67d463d11d..0b231bd88755c2fd9ddd986fc4b0bd33f33fa0c1 100644 (file)
@@ -14,7 +14,7 @@ addon.register("w3c","1.0.0",$tr("W3C validator","w3c"),$tr("It download the res
        # This is our uninstall callback: it will be called by KVIrc when addon.uninstall is invoked
        
        # This is an automatically generated alias that will erase the installed files
-       hell_w3c::uninstallfiles
+       #hell_w3c::uninstallfiles
 
        # Kill all our aliases
        alias(hell_w3c){}
@@ -41,7 +41,7 @@ parse %mypath/utils/installer.kvs
 # the documentation
 %installer->$copyFiles("%mypath/help/en/w3c/","*.html",$file.localdir("help/en/w3c"))
 # then generate the uninstall alias
-%installer->$generateUninstallAlias("hell_w3c::uninstallfiles")
+#%installer->$generateUninstallAlias("hell_w3c::uninstallfiles")
 # finally kill the installer helper
 delete %installer
 
diff --git a/W3C/utils/installer.kvs b/W3C/utils/installer.kvs
new file mode 100644 (file)
index 0000000..63a4c4d
--- /dev/null
@@ -0,0 +1,60 @@
+# A helper class for installing files and generating an uninstallation alias on the fly
+
+class(installer,object)
+{
+       constructor()
+       {
+               $this->%iNumFiles = 0
+       }
+       
+       copyFiles($0 = source dir,$1 = file regexp,$2 = target dir)
+       {
+               if($0 == "")
+               {
+                       echo "[Installer] SCRIPT BUG: The second argument to installer_copyfiles must be a source directory"
+                       halt
+               }
+       
+               if($1 == "")
+               {
+                       echo "[Installer] SCRIPT BUG: The third argument to installer_copyfiles must be a file name or file regexp"
+                       halt
+               }
+       
+               if($2 == "")
+               {
+                       echo "[Installer] SCRIPT BUG: The second argument to installer_copyfiles must be a destination directory"
+                       halt
+               }
+       
+               if($file.exists($0))
+               {
+                       %files[] = $file.ls($0,f,$1)
+                       if(%files[]#)
+                       {
+                               file.mkdir $2
+                               foreach(%file,%files[])
+                               {
+                                       $this->%lFiles[$this->%iNumFiles] = $str.replace($file.fixpath("$2/%file"),"\\\\","\\")
+                                       $this->%iNumFiles++;
+                                       file.copy -o "$0/%file" "$2/%file"
+                               }
+                       }
+               }
+       }
+       
+       generateUninstallAlias($0 = alias name)
+       {
+               %c  = "alias($0)$lf"
+               %c .= "{$lf"
+               if($this->%iNumFiles > 0)
+               {
+                       foreach(%file,$this->%lFiles[])
+                       {
+                               %c .= " file.remove \"%file\"$lf";
+                       }
+               }
+               %c .= "}"
+               eval %c
+       }
+};