diff options
| author | hallgren <hallgren@chalmers.se> | 2012-11-23 23:21:17 +0000 |
|---|---|---|
| committer | hallgren <hallgren@chalmers.se> | 2012-11-23 23:21:17 +0000 |
| commit | 18c8ff357978f7fd050751baaae62d36025374c0 (patch) | |
| tree | 926163fecf36091e40e006d34763afa0f2d356fa /src/compiler | |
| parent | bdaf7a8772d7ea703fa0e3144f0ee3a8914933a0 (diff) | |
gf -server + gfse: show modification time of public grammars
Diffstat (limited to 'src/compiler')
| -rw-r--r-- | src/compiler/GFServer.hs | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/src/compiler/GFServer.hs b/src/compiler/GFServer.hs index a6e4c5a52..d84363cb2 100644 --- a/src/compiler/GFServer.hs +++ b/src/compiler/GFServer.hs @@ -12,7 +12,10 @@ import GF.System.Catch(try) import System.IO.Error(isAlreadyExistsError) import System.Directory(doesDirectoryExist,doesFileExist,createDirectory, setCurrentDirectory,getCurrentDirectory, - getDirectoryContents,removeFile,removeDirectory) + getDirectoryContents,removeFile,removeDirectory, + getModificationTime) +import System.Time(toUTCTime,formatCalendarTime) +import System.Locale(defaultTimeLocale,rfc822DateFormat) import System.FilePath(dropExtension,takeExtension,takeFileName,takeDirectory, (</>)) #ifndef mingw32_HOST_OS @@ -200,6 +203,7 @@ handle state0 cache execute1 "remake" -> make skip_empty dir . raw =<< get_qs "upload" -> upload id . raw =<< get_qs "ls" -> jsonList . maybe ".json" fst . lookup "ext" =<< get_qs + "ls-l" -> jsonListLong . maybe ".json" fst . lookup "ext" =<< get_qs "rm" -> rm =<< look_file "download" -> download =<< look_file "link_directories" -> link_directories dir =<< look "newdir" @@ -233,7 +237,16 @@ handle state0 cache execute1 skip_empty = filter (not.null.snd) - jsonList ext = fmap (json200) (ls_ext "." ext) + jsonList = jsonList' return + jsonListLong = jsonList' (mapM addTime) + jsonList' details ext = fmap (json200) (details =<< ls_ext "." ext) + + addTime path = + do t <- liftIO $ getModificationTime path + return $ makeObj ["path".=path,"time".=format t] + where + format = formatCalendarTime defaultTimeLocale rfc822DateFormat + . toUTCTime rm path | takeExtension path `elem` ok_to_delete = do b <- liftIO $ doesFileExist path |
