# HG changeset patch # User Adam Chlipala # Date 1256228191 14400 # Node ID 59097824f19b2213907a4df09c9cedfeccd4560c # Parent 1911e84df4613ee9e6adae2a6ce95b7fa5b02d75 Viewing papers diff -r 1911e84df461 -r 59097824f19b demo/more/conference.ur --- a/demo/more/conference.ur Thu Oct 22 11:51:31 2009 -0400 +++ b/demo/more/conference.ur Thu Oct 22 12:16:31 2009 -0400 @@ -11,6 +11,7 @@ val review : $(map meta review) val submissionDeadline : time + val summarizePaper : $(map fst paper) -> xbody end) = struct table user : {Id : int, Nam : string, Password : string, Chair : bool, OnPc : bool} @@ -42,6 +43,15 @@ WHERE user.Id = {[r.Id]} AND user.Password = {[r.Password]}) + fun checkPaper id = + ro <- checkLogin; + if (case ro of + None => False + | Some r => r.OnPc) then + return () + else + error You must be logged in to do that. + structure Users = BulkEdit.Make(struct con keyName = #Id val visible = {Nam = string "Name", @@ -122,6 +132,11 @@ else } + {if me.OnPc then +
  • All papers
  • + else + } + {if now < M.submissionDeadline then
  • Submit
  • else @@ -135,10 +150,13 @@ and submit () = let - fun doSubmit r = return - MIME type: {[fileMimeType r.Document]}
    - Length: {[blobSize (fileData r.Document)]} -
    + fun doSubmit r = + id <- nextval paperId; + dml (insert paper ({Id = sql_inject id, Document = sql_inject (fileData r.Document)} + ++ ensql M.paper (r -- #Document) M.paperFolder)); + return + OK, done! + in return

    Submit a Paper

    @@ -151,4 +169,42 @@
    end + and all () = + ps <- queryX (SELECT paper.Id, paper.{{map fst M.paper}} FROM paper) + (fn r =>
  • {M.summarizePaper (r.Paper -- #Id)}
  • ); + return +

    All Papers

    + +
      + {ps} +
    +
    + + and one id = + checkPaper id; + ro <- oneOrNoRows (SELECT paper.{{map fst M.paper}}, octet_length(paper.Document) AS N + FROM paper + WHERE paper.Id = {[id]}); + case ro of + None => error Paper not found! + | Some r => return +

    Paper #{[id]}

    + + {allContent M.paper r.Paper M.paperFolder}
    + + {if r.N = 0 then +
    No paper uploaded yet.
    + else + Download paper ({[r.N]} bytes)} +
    + + and download id = + checkPaper id; + ro <- oneOrNoRows (SELECT paper.Document + FROM paper + WHERE paper.Id = {[id]}); + case ro of + None => error Paper not found! + | Some r => returnBlob r.Paper.Document (blessMime "application/pdf") + end diff -r 1911e84df461 -r 59097824f19b demo/more/conference.urp --- a/demo/more/conference.urp Thu Oct 22 11:51:31 2009 -0400 +++ b/demo/more/conference.urp Thu Oct 22 12:16:31 2009 -0400 @@ -1,3 +1,4 @@ +allow mime application/pdf $/option $/list diff -r 1911e84df461 -r 59097824f19b demo/more/conference.urs --- a/demo/more/conference.urs Thu Oct 22 11:51:31 2009 -0400 +++ b/demo/more/conference.urs Thu Oct 22 12:16:31 2009 -0400 @@ -9,6 +9,7 @@ val review : $(map Meta.meta review) val submissionDeadline : time + val summarizePaper : $(map fst paper) -> xbody end) : sig val main : unit -> transaction page diff -r 1911e84df461 -r 59097824f19b demo/more/conference1.ur --- a/demo/more/conference1.ur Thu Oct 22 11:51:31 2009 -0400 +++ b/demo/more/conference1.ur Thu Oct 22 12:16:31 2009 -0400 @@ -6,4 +6,6 @@ val review = {} val submissionDeadline = readError "2009-10-22 23:59:59" + + fun summarizePaper r = cdata r.Title end) diff -r 1911e84df461 -r 59097824f19b demo/more/conferenceFields.ur --- a/demo/more/conferenceFields.ur Thu Oct 22 11:51:31 2009 -0400 +++ b/demo/more/conferenceFields.ur Thu Oct 22 12:16:31 2009 -0400 @@ -1,7 +1,4 @@ open Meta -con title = (string, string) val title = string "Title" - -con abstract = (string, string) val abstract = textarea "Abstract" diff -r 1911e84df461 -r 59097824f19b demo/more/conferenceFields.urs --- a/demo/more/conferenceFields.urs Thu Oct 22 11:51:31 2009 -0400 +++ b/demo/more/conferenceFields.urs Thu Oct 22 12:16:31 2009 -0400 @@ -1,5 +1,2 @@ -con title :: (Type * Type) -val title : Meta.meta title - -con abstract :: (Type * Type) -val abstract : Meta.meta abstract +val title : Meta.meta (string, string) +val abstract : Meta.meta (string, string) diff -r 1911e84df461 -r 59097824f19b demo/more/meta.ur --- a/demo/more/meta.ur Thu Oct 22 11:51:31 2009 -0400 +++ b/demo/more/meta.ur Thu Oct 22 12:16:31 2009 -0400 @@ -35,6 +35,13 @@ Parse = fn s => s, Inject = _} +fun allContent [ts ::: {(Type * Type)}] (r : $(map meta ts)) (vs : $(map fst ts)) (fl : folder ts) = + foldRX2 [meta] [fst] [_] + (fn [nm :: Name] [p :: (Type * Type)] [rest :: {(Type * Type)}] [[nm] ~ rest] + (m : meta p) v => + {[m.Nam]}: {m.Show v}
    ) + [_] fl r vs + fun allWidgets [ts ::: {(Type * Type)}] (r : $(map meta ts)) (fl : folder ts) = foldR [meta] [fn ts :: {(Type * Type)} => xml form [] (map snd ts)] (fn [nm :: Name] [t :: (Type * Type)] [rest :: {(Type * Type)}] diff -r 1911e84df461 -r 59097824f19b demo/more/meta.urs --- a/demo/more/meta.urs Thu Oct 22 11:51:31 2009 -0400 +++ b/demo/more/meta.urs Thu Oct 22 12:16:31 2009 -0400 @@ -13,6 +13,8 @@ val textarea : string -> meta (string, string) +val allContent : ts ::: {(Type * Type)} -> $(map meta ts) -> $(map fst ts) -> folder ts -> xbody + val allWidgets : ts ::: {(Type * Type)} -> $(map meta ts) -> folder ts -> xml form [] (map snd ts)