From 4a7982e6dd597d337b36a1c94769c57df58b0414 Mon Sep 17 00:00:00 2001 From: Jean-Marc Vanel Date: Tue, 30 May 2017 16:56:15 +0200 Subject: [PATCH] Pave the way for refactoring HTML generation: comments --- .../deductions/runtime/html/Form2HTML.scala | 23 +++++++++---- .../runtime/html/Form2HTMLDisplay.scala | 34 +++++++++---------- .../runtime/html/HtmlGeneratorInterface.scala | 3 -- 3 files changed, 33 insertions(+), 27 deletions(-) diff --git a/scala/forms/src/main/scala/deductions/runtime/html/Form2HTML.scala b/scala/forms/src/main/scala/deductions/runtime/html/Form2HTML.scala index e67526436..8ee416cd7 100644 --- a/scala/forms/src/main/scala/deductions/runtime/html/Form2HTML.scala +++ b/scala/forms/src/main/scala/deductions/runtime/html/Form2HTML.scala @@ -51,6 +51,7 @@ private[html] trait Form2HTML[NODE, URI <: NODE] val htmlFormFields = time("generateHTMLJustFields", generateHTMLJustFields(form, hrefPrefix, editable, graphURI, lang, request)) + /* wrap Fields With HTML
Tag */ def wrapFieldsWithFormTag(htmlFormFields: NodeSeq): NodeSeq = @@ -76,9 +77,10 @@ private[html] trait Form2HTML[NODE, URI <: NODE] /** * generate HTML, but Just Fields; - * this lets application developers create their own submit button(s) and tag + * this lets application developers create their own submit button(s) and tag + * + * PENDING if inner functions should need to be overridden, they should NOT be inner */ -// private[html] def generateHTMLJustFields(form: formMod#FormSyntax, hrefPrefix: String = config.hrefDisplayPrefix, editable: Boolean = false, @@ -92,6 +94,7 @@ private[html] trait Form2HTML[NODE, URI <: NODE] } else Seq() + /* make Fields Label And Data */ def makeFieldsLabelAndData(fields: Seq[FormEntry]): NodeSeq = { if (!fields.isEmpty) { val lastEntry = fields.last @@ -112,8 +115,7 @@ private[html] trait Form2HTML[NODE, URI <: NODE] } else Text("\n") } - /* - * makeFieldsGroups Builds a groups of HTML fields to be used with the jQuery UI tabs generator + /* makeFieldsGroups Builds a groups of HTML fields to be used with the jQuery UI tabs generator * * @return NodeSeq Fragment HTML contenant un groupe de champs */ @@ -145,6 +147,7 @@ private[html] trait Form2HTML[NODE, URI <: NODE] tabs.+:(tabsNames) } + /* make HTML for Field Subject, if different from form subject */ def makeFieldSubject(field: FormEntry): NodeSeq = { if (field.subject != nullURI && field.subject != form.subject) { val subjectField = @@ -184,7 +187,10 @@ private[html] trait Form2HTML[NODE, URI <: NODE] return htmlResult } - /** Form Header inside the form box with data fields */ + /** Form Header inside the form box with data fields: displays: + * - form title + * - form subject URI + * - class or Form specification */ private def dataFormHeader(form: formMod#FormSyntax) = { import form._ Text(form.title) ++ @@ -201,7 +207,9 @@ private[html] trait Form2HTML[NODE, URI <: NODE] }} } - /** dispatch to various Entry's: LiteralEntry, ResourceEntry; ..., editable or not */ + /** dispatch to various Entry's: LiteralEntry, ResourceEntry, BlankNodeEntry, RDFListEntry, + * editable or not; + * should not need to be overriden */ private def createHTMLField(field: formMod#Entry, editable: Boolean, hrefPrefix: String = config.hrefDisplayPrefix, lang: String = "en", request: HTTPrequest = HTTPrequest())(implicit form: FormModule[NODE, URI]#FormSyntax): NodeSeq = { @@ -248,7 +256,8 @@ private[html] trait Form2HTML[NODE, URI <: NODE]
{ xmlField }
} - /** make Field Data (display) Or Input (edit) */ + /** make Field Data (display) Or Input (edit) + * TODO: does not do much! */ private def makeFieldDataOrInput(field: formMod#Entry, hrefPrefix: String = config.hrefDisplayPrefix, editable: Boolean, lang: String = "en", request: HTTPrequest = HTTPrequest())(implicit form: FormModule[NODE, URI]#FormSyntax) = { diff --git a/scala/forms/src/main/scala/deductions/runtime/html/Form2HTMLDisplay.scala b/scala/forms/src/main/scala/deductions/runtime/html/Form2HTMLDisplay.scala index 5879907e4..41267098b 100644 --- a/scala/forms/src/main/scala/deductions/runtime/html/Form2HTMLDisplay.scala +++ b/scala/forms/src/main/scala/deductions/runtime/html/Form2HTMLDisplay.scala @@ -25,6 +25,9 @@ trait Form2HTMLDisplay[NODE, URI <: NODE]
{ if (l.lang != "" && l.lang != "No_language") " > " + l.lang }
+ /** create HTML Resource Readonly Field + * PENDING if inner val should need to be overridden, they should be directly in trait + * */ def createHTMLResourceReadonlyField( resourceEntry: formMod#ResourceEntry, hrefPrefix: String = hrefDisplayPrefix, @@ -84,23 +87,20 @@ trait Form2HTMLDisplay[NODE, URI <: NODE] else NodeSeq.Empty } - hyperlinkToField ++ - hyperlinkToObjectURI ++ - Text("\n") ++ - backLinkButton ++ - Text("\n") ++ - normalNavigationButton ++ - Text("\n") ++ - makeDrawGraphLink(objectURIstringValue) ++ - makeDrawGraphLink(objectURIstringValue, - toolURLprefix= - s"https://scenaristeur.github.io/graphe/?endpoint=${request.localSparqlEndpoint}" + - s"&sujet=", - toolname="scenaristeur/graphe" - , - imgWidth=6 - ) ++ - Text("\n") ++ + // TODO Text("\n") should be within specific val's + hyperlinkToField ++ + hyperlinkToObjectURI ++ Text("\n") ++ + backLinkButton ++ Text("\n") ++ + normalNavigationButton ++ Text("\n") ++ + makeDrawGraphLink(objectURIstringValue) ++ +// makeDrawGraphLink(objectURIstringValue, +// toolURLprefix= +// s"https://scenaristeur.github.io/graphe/?endpoint=${request.localSparqlEndpoint}" + +// s"&sujet=", +// toolname="scenaristeur/graphe" +// , +// imgWidth=6 +// ) ++ Text("\n") ++ thumbnail ++ {makeUserInfoOnTriples(resourceEntry.metadata,resourceEntry.timeMetadata)} } diff --git a/scala/forms/src/main/scala/deductions/runtime/html/HtmlGeneratorInterface.scala b/scala/forms/src/main/scala/deductions/runtime/html/HtmlGeneratorInterface.scala index 541d144c2..29d16a761 100644 --- a/scala/forms/src/main/scala/deductions/runtime/html/HtmlGeneratorInterface.scala +++ b/scala/forms/src/main/scala/deductions/runtime/html/HtmlGeneratorInterface.scala @@ -1,8 +1,5 @@ package deductions.runtime.html -import java.net.URLEncoder -import java.security.MessageDigest - import scala.xml.NodeSeq import deductions.runtime.abstract_syntax.FormModule