mirror of
https://github.com/GrammaticalFramework/gf-core.git
synced 2026-04-23 03:32:51 -06:00
gf -server + gfse: show modification time of public grammars
This commit is contained in:
1
gf.cabal
1
gf.cabal
@@ -112,6 +112,7 @@ executable gf
|
|||||||
directory,
|
directory,
|
||||||
random,
|
random,
|
||||||
old-time,
|
old-time,
|
||||||
|
old-locale,
|
||||||
process,
|
process,
|
||||||
pretty,
|
pretty,
|
||||||
mtl,
|
mtl,
|
||||||
|
|||||||
@@ -12,7 +12,10 @@ import GF.System.Catch(try)
|
|||||||
import System.IO.Error(isAlreadyExistsError)
|
import System.IO.Error(isAlreadyExistsError)
|
||||||
import System.Directory(doesDirectoryExist,doesFileExist,createDirectory,
|
import System.Directory(doesDirectoryExist,doesFileExist,createDirectory,
|
||||||
setCurrentDirectory,getCurrentDirectory,
|
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,
|
import System.FilePath(dropExtension,takeExtension,takeFileName,takeDirectory,
|
||||||
(</>))
|
(</>))
|
||||||
#ifndef mingw32_HOST_OS
|
#ifndef mingw32_HOST_OS
|
||||||
@@ -200,6 +203,7 @@ handle state0 cache execute1
|
|||||||
"remake" -> make skip_empty dir . raw =<< get_qs
|
"remake" -> make skip_empty dir . raw =<< get_qs
|
||||||
"upload" -> upload id . raw =<< get_qs
|
"upload" -> upload id . raw =<< get_qs
|
||||||
"ls" -> jsonList . maybe ".json" fst . lookup "ext" =<< 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
|
"rm" -> rm =<< look_file
|
||||||
"download" -> download =<< look_file
|
"download" -> download =<< look_file
|
||||||
"link_directories" -> link_directories dir =<< look "newdir"
|
"link_directories" -> link_directories dir =<< look "newdir"
|
||||||
@@ -233,7 +237,16 @@ handle state0 cache execute1
|
|||||||
|
|
||||||
skip_empty = filter (not.null.snd)
|
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 =
|
rm path | takeExtension path `elem` ok_to_delete =
|
||||||
do b <- liftIO $ doesFileExist path
|
do b <- liftIO $ doesFileExist path
|
||||||
|
|||||||
@@ -131,7 +131,7 @@ function draw_grammar_list() {
|
|||||||
var unique_id=local.get("unique_id","-")
|
var unique_id=local.get("unique_id","-")
|
||||||
var t=empty_class("table","grammar_list")
|
var t=empty_class("table","grammar_list")
|
||||||
for(var i in files) {
|
for(var i in files) {
|
||||||
var file=files[i]
|
var file=files[i].path
|
||||||
var parts=file.split(/[-.]/)
|
var parts=file.split(/[-.]/)
|
||||||
var basename=parts[0]
|
var basename=parts[0]
|
||||||
var unique_name=parts[1]+"-"+parts[2]
|
var unique_name=parts[1]+"-"+parts[2]
|
||||||
@@ -139,13 +139,17 @@ function draw_grammar_list() {
|
|||||||
var del = mine
|
var del = mine
|
||||||
? delete_button(rmpublic(file),"Don't publish this grammar")
|
? delete_button(rmpublic(file),"Don't publish this grammar")
|
||||||
: []
|
: []
|
||||||
var tit = mine
|
var tip = mine
|
||||||
? "This is a copy of your grammar"
|
? "This is a copy of your grammar"
|
||||||
: "Click to download a copy of this grammar"
|
: "Click to download a copy of this grammar"
|
||||||
|
var modt=new Date(files[i].time)
|
||||||
|
var fmtmodt=modt.toDateString()+", "+modt.toTimeString().split(" ")[0]
|
||||||
|
var when=wrap_class("small","modtime",text(" "+fmtmodt))
|
||||||
t.appendChild(edtr([td(del),
|
t.appendChild(edtr([td(del),
|
||||||
td(title(tit,
|
td(title(tip,
|
||||||
a(jsurl('open_public("'+file+'")'),
|
a(jsurl('open_public("'+file+'")'),
|
||||||
[text(basename)])))]))
|
[text(basename)]))),
|
||||||
|
td(when)]))
|
||||||
}
|
}
|
||||||
publiclist.appendChild(t)
|
publiclist.appendChild(t)
|
||||||
}
|
}
|
||||||
@@ -153,7 +157,7 @@ function draw_grammar_list() {
|
|||||||
publiclist.appendChild(p(text("No public grammars are available.")))
|
publiclist.appendChild(p(text("No public grammars are available.")))
|
||||||
}
|
}
|
||||||
if(navigator.onLine)
|
if(navigator.onLine)
|
||||||
gfcloud_public_json("ls",{},show_public,no_public)
|
gfcloud_public_json("ls-l",{},show_public,no_public)
|
||||||
var home=div_class("home",table(tr([userlist,publiclist])))
|
var home=div_class("home",table(tr([userlist,publiclist])))
|
||||||
home.appendChild(empty_id("div","sharing"));
|
home.appendChild(empty_id("div","sharing"));
|
||||||
editor.appendChild(home)
|
editor.appendChild(home)
|
||||||
|
|||||||
Reference in New Issue
Block a user