diff --git a/Examples/WebPublic/BasicAPIExamples.css b/Examples/BasicAPIExamples.css similarity index 100% rename from Examples/WebPublic/BasicAPIExamples.css rename to Examples/BasicAPIExamples.css diff --git a/Examples/WebPublic/index.html b/Examples/WebPublic/index.html deleted file mode 100644 index dd92f6bb0dd6ec89cb68556d9ae63ee284667108..0000000000000000000000000000000000000000 --- a/Examples/WebPublic/index.html +++ /dev/null @@ -1,37 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/Libraries/iTasks/Extensions/Admin/WebPublic/css/WorkflowAdmin.css b/Libraries/iTasks/Extensions/Admin/WorkflowAdmin.css similarity index 100% rename from Libraries/iTasks/Extensions/Admin/WebPublic/css/WorkflowAdmin.css rename to Libraries/iTasks/Extensions/Admin/WorkflowAdmin.css diff --git a/Libraries/iTasks/UI/WebPublic/index.html b/Libraries/iTasks/UI/WebPublic/index.html index a2ee4efb905e416df5dec9114fc0d6c98d400c7a..b73d9c1701f8e843b5be8740c90156d1ff2713dd 100644 --- a/Libraries/iTasks/UI/WebPublic/index.html +++ b/Libraries/iTasks/UI/WebPublic/index.html @@ -5,6 +5,7 @@ + diff --git a/Tools/WebResourceCollector.icl b/Tools/WebResourceCollector.icl index 797134443a4a6705df135a0588e428fdebcbfeea..4813e75a9b87eb3e4f5cae9c3fd697724d65cc85 100644 --- a/Tools/WebResourceCollector.icl +++ b/Tools/WebResourceCollector.icl @@ -1,14 +1,17 @@ module WebResourceCollector /** -* This program collects all the necessary public web resources that an iTasks program +* This program collects and creates all the necessary public web resources that an iTasks program * needs to run. These are for example, static javascript files, images and the html launch page. * -* The way this collector works is straightforward. It looks in a project file which modules are +* To find bundled public resources it looks in a project file which modules are * used by a program and then checks for each module if a directory called "-webpublic" exists * if it exists, the full contents of that directory are copied to the collection directory called "-webpublic" +* +* It also creates an aggregated css file with additional style rules that are needed by Clean modules. +* If for an imported Clean module a file exists with the same name, but a .css extension it is included in the aggregation. +* The total collected css is written to "-webpublic/css/itasks-modules.css" * -* To always bundle the right versions of web resources, this program must be run after every build -* in the link phase. +* To always bundle the right versions of web resources, this program must be run after every build in the link phase. */ import StdEnv @@ -28,11 +31,21 @@ Start world # content = fromOk content # outDir = exePathToOutputDir (lookupExePath content) # inDirs = objectPathsToInputDirs (lookupObjectPaths content) - //Create output dir + # cssParts = objectPathsToCSSFiles (lookupObjectPaths content) + # cssFile = outDir "css" "itasks-modules.css" + # world = print ("Output css file " +++ cssFile) world + //Create output dir and 'css' dir in it # (mbErr,world) = createDirectory outDir world | not (mbErr =: (Ok _) || mbErr =: (Error (17,_))) //Ignore 'File exists' errors # (errorcode,errormsg) = fromError mbErr = print errormsg world + # (mbErr,world) = createDirectory (outDir "css") world + | not (mbErr =: (Ok _) || mbErr =: (Error (17,_))) //Ignore 'File exists' errors + # (errorcode,errormsg) = fromError mbErr + = print errormsg world + //Create the aggregated css file + # (mbErr,world) = writeFile cssFile "" world + # world = foldr (\f w -> aggregateCSS f cssFile w) world cssParts //Copy the contents of the input dirs if they exist # world = foldr (\d w -> copyWebResources d outDir w) world inDirs = world @@ -59,7 +72,7 @@ lookupObjectPaths linkopts exePathToOutputDir :: FilePath-> FilePath exePathToOutputDir path = dropExtension path +++ "-www" -//Determine the potential input folders +//Determine the potential input folders and css fragments objectPathsToInputDirs :: [FilePath] -> [FilePath] objectPathsToInputDirs paths = flatten (map rewrite paths) where @@ -68,6 +81,11 @@ where ,join {pathSeparator} ((filter ((<>) "Clean System Files") (split {pathSeparator} (takeDirectory path)))) "WebPublic" ] +objectPathsToCSSFiles :: [FilePath] -> [FilePath] +objectPathsToCSSFiles paths = map rewrite paths +where + rewrite path = addExtension (join {pathSeparator} ((filter ((<>) "Clean System Files") (split {pathSeparator} (dropExtension path))))) "css" + //Copy the web resources if the input directory exists copyWebResources :: !FilePath !FilePath !*World -> *World copyWebResources indir outdir world @@ -77,6 +95,14 @@ copyWebResources indir outdir world = copyDirectoryContent indir outdir world | otherwise = world +aggregateCSS :: !FilePath !FilePath !*World -> *World +aggregateCSS inFile outFile world + # (exists,world) = fileExists inFile world + | exists + # world = print ("Adding css file "+++inFile) world + = copyFile inFile outFile True world + | otherwise = world + //GENERAL UTIL, SHOULD BE PART OF PLATFORM isDirectory :: !FilePath !*World -> (!Bool, !*World) isDirectory path world = case getFileInfo path world of @@ -96,14 +122,14 @@ where # (_,world) = createDirectory (outdir item) world = copyDirectoryContent (indir item) (outdir item) world | otherwise //Copy the file - = copyFile (indir item) (outdir item) world + = copyFile (indir item) (outdir item) False world -copyFile :: !FilePath !FilePath !*World -> *World -copyFile inf outf world +copyFile :: !FilePath !FilePath !Bool !*World -> *World +copyFile inf outf append world # (ok,inh,world) = fopen inf FReadData world | not ok = world - # (ok,outh,world) = fopen outf FWriteData world + # (ok,outh,world) = fopen outf (if append FAppendData FWriteData) world | not ok = world # (inh,outh) = copy inh outh