Skip to content

Commit

Permalink
Pave the way for refactoring HTML generation: comments
Browse files Browse the repository at this point in the history
  • Loading branch information
jmvanel committed May 30, 2017
1 parent a032874 commit 4a7982e
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 27 deletions.
23 changes: 16 additions & 7 deletions scala/forms/src/main/scala/deductions/runtime/html/Form2HTML.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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 <form> Tag */
def wrapFieldsWithFormTag(htmlFormFields: NodeSeq): NodeSeq =

<form class="sf-standard-form" action={ actionURI } method="POST">
Expand All @@ -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 <form> tag
* this lets application developers create their own submit button(s) and <form> 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,
Expand All @@ -92,6 +94,7 @@ private[html] trait Form2HTML[NODE, URI <: NODE]
<input type="hidden" name="graphURI" value={ urlEncode(graphURI) }/>
} else Seq()

/* make Fields Label And Data */
def makeFieldsLabelAndData(fields: Seq[FormEntry]): NodeSeq = {
if (!fields.isEmpty) {
val lastEntry = fields.last
Expand All @@ -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
*/
Expand Down Expand Up @@ -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 =
Expand Down Expand Up @@ -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) ++
Expand All @@ -201,7 +207,9 @@ private[html] trait Form2HTML[NODE, URI <: NODE]
}}</div>
}

/** 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 = {
Expand Down Expand Up @@ -248,7 +256,8 @@ private[html] trait Form2HTML[NODE, URI <: NODE]
<div class="sf-value-block col-xs-12 col-sm-9 col-md-9">{ xmlField } </div>
}

/** 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) = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ trait Form2HTMLDisplay[NODE, URI <: NODE]
<div>{ if (l.lang != "" && l.lang != "No_language") " > " + l.lang }</div>
</xml:group>

/** 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,
Expand Down Expand Up @@ -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)}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand Down

0 comments on commit 4a7982e

Please sign in to comment.