Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
C
clinicaltrials
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
david Chavalarias
clinicaltrials
Commits
77a0f02a
Commit
77a0f02a
authored
Jul 07, 2017
by
Romain Loth
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
basic search hits templates mecanism
parent
7fa9d71a
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
152 additions
and
41 deletions
+152
-41
db.json
db.json
+6
-5
settings_explorerjs.js
settings_explorerjs.js
+2
-0
info_div.php
twbackends/phpAPI/info_div.php
+4
-0
twjs.css
twlibs/css/twjs.css
+7
-0
cortext_with_link.html
twlibs/hit_templates/cortext_with_link.html
+3
-0
universal.html
twlibs/hit_templates/universal.html
+19
-0
extras_explorerjs.js
twmain/extras_explorerjs.js
+111
-36
No files found.
db.json
View file @
77a0f02a
...
...
@@ -8,7 +8,7 @@
"reldbtype"
:
"csv"
,
"reldbfile"
:
"shale_and_ice.csv"
,
"reldbqcols"
:
[
"title"
],
"reltemplate"
:
"
_todo
"
"reltemplate"
:
"
bib_details
"
}
},
"model_calibration.gexf"
:
{
...
...
@@ -17,7 +17,7 @@
"reldbtype"
:
"csv"
,
"reldbfile"
:
"model_calibration.csv"
,
"reldbqcols"
:
[
"title"
],
"reltemplate"
:
"
_todo
"
"reltemplate"
:
"
bib_details
"
}
}
}
...
...
@@ -40,14 +40,14 @@
"reldbtype"
:
"csv"
,
"reldbfile"
:
"mini_for_csv.csv"
,
"reldbqcols"
:
[
"title"
,
"keywords"
,
"text"
],
"reltemplate"
:
"
_todo
"
"reltemplate"
:
"
bib_details
"
},
"node1"
:
{
"name"
:
"person"
,
"reldbtype"
:
"csv"
,
"reldbfile"
:
"mini_for_csv.csv"
,
"reldbqcols"
:
[
"author"
],
"reltemplate"
:
"
_todo
"
"reltemplate"
:
"
bib_details
"
}
},
"test_with_various_atts.gexf"
:
{}
...
...
@@ -73,7 +73,8 @@
"name"
:
"ISItermsWhitelistV2Oct_5 & ISItermsWhitelistV2Oct_5"
,
"reldbqtable"
:
"ISItermsWhitelistV2Oct_5"
,
"reldbfile"
:
"wos_climate-change_title_2014-2015.db"
,
"reldbtype"
:
"CortextDB"
"reldbtype"
:
"CortextDB"
,
"reltemplate"
:
"universal"
}
}
}
...
...
settings_explorerjs.js
View file @
77a0f02a
...
...
@@ -159,7 +159,9 @@ TW.conf = (function(TW){
// ------------
TWConf
.
paths
=
{
'ourlibs'
:
'twlibs'
,
'templates'
:
"twlibs/hit_templates"
,
'modules'
:
'twmodules'
,
'sourceFile'
:
""
,
// server-side .gexf|.json default source
'sourceMenu'
:
"db.json"
// ...or server-side gexf default source list
}
...
...
twbackends/phpAPI/info_div.php
View file @
77a0f02a
...
...
@@ -10,6 +10,10 @@ ini_set('display_startup_errors',1);
include
(
'tools.php'
);
include
(
'parameters_details.php'
);
if
(
$output_mode
==
"json"
)
{
header
(
'Content-Type: application/json'
);
}
$dbtype
=
null
;
if
(
array_key_exists
(
'reldbtype'
,
$my_conf
[
$ntid
]))
{
$dbtype
=
$my_conf
[
$ntid
][
'reldbtype'
];
...
...
twlibs/css/twjs.css
View file @
77a0f02a
...
...
@@ -196,6 +196,13 @@ html.waiting {
font-family
:
"Crete Round"
,
"garamond"
,
serif
;
padding
:
5px
;
}
.hit-keywords
{
color
:
#000
;
font-style
:
italic
;
font-family
:
"Crete Round"
,
"garamond"
,
serif
;
padding
:
5px
;
}
/* small messages */
p
.micromessage
{
font-size
:
85%
;
...
...
twlibs/hit_templates/cortext_with_link.html
0 → 100644
View file @
77a0f02a
<li
class=
"searchhit"
title=
'$${score}'
>
<a
href=
"$${link}"
>
$${tit}
</a>
<span
class=
"author"
>
$${au}
</span>
</li>
twlibs/hit_templates/universal.html
0 → 100644
View file @
77a0f02a
<li
class=
"searchhit"
title=
"$${score}"
>
<p>
<a
href=
"$${link}"
><b>
$${tit}
</b></a>
by
<span
class=
"author"
>
$${au}
</span>
,
<i>
$${src}
</i>
[$${date}]
</p>
<p>
<span
class=
"hit-keywords"
>
$${kws}
</span>
<span
class=
"hit-text"
>
$${txt}
</span>
</p>
</li>
twmain/extras_explorerjs.js
View file @
77a0f02a
...
...
@@ -373,12 +373,12 @@ function getTopPapers(){
topPapersFetcher
(
swNodetypes
[
0
],
qWordsbySwType
[
swNodetypes
[
0
]],
`<h2>
${
swNodetypes
[
0
]}
</h2>`
,
function
(
enrichedHtml
)
{
[[],[]]
,
function
(
priorJsonHits
)
{
topPapersFetcher
(
swNodetypes
[
1
],
qWordsbySwType
[
swNodetypes
[
1
]],
enrichedHtml
+
`<p class=centered>---</p><h2>
${
swNodetypes
[
1
]}
</h2>`
,
priorJsonHits
,
displayTopPapers
)
}
...
...
@@ -396,31 +396,30 @@ function getTopPapers(){
// - cbNext is a partial function to handle the follow-up
// (just pass it resHTML, to continue enriching or display)
//
function
topPapersFetcher
(
swType
,
qWords
,
priorHtml
,
cbNext
){
function
topPapersFetcher
(
swType
,
qWords
,
accumulHits
,
cbNext
){
if
(
isUndef
(
priorHtml
))
priorHtml
=
''
if
(
isUndef
(
cbNext
))
cbNext
=
displayTopPapers
// list of json object with hit metadata (title, author, etc.) by nodetype
if
(
isUndef
(
accumulHits
))
accumulHits
=
[[],[]]
// callback to continue accumulating json hits or display to html
if
(
isUndef
(
cbNext
))
cbNext
=
displayTopPapers
// introducing the modern node type thanks to updated db.json specs
let
nodetype
=
(
swType
==
'semantic'
)
?
0
:
1
let
stockErrMsg
=
`<p class="micromessage">
Your settings for relatedDocsType are set on
${
TW
.
conf
.
relatedDocsType
}
API but it couldn't be connected to.</p>`
if
(
TW
.
conf
.
relatedDocsType
==
"api"
)
{
stockErrMsg
+=
`<p class="micromessage">Check if it is running and
accessible:<br><span class=code>
${
TW
.
conf
.
relatedDocsAPI
}
</span></p>`
}
let
resHTML
=
''
let
apiurl
=
TW
.
conf
.
relatedDocsAPIS
[
TW
.
conf
.
relatedDocsType
]
if
(
!
apiurl
)
{
apiurl
=
TW
.
conf
.
relatedDocsAPI
}
let
stockErrMsg
=
`
<p class="micromessage">The API
${
TW
.
conf
.
relatedDocsType
}
couldn't be connected to.</p>
<p class="micromessage">The queried route found in TW.conf was: <span class=code>
${
apiurl
}
</span>
<br>Check if it is running and accessible.</p>`
let
resHTML
=
''
if
(
TW
.
conf
.
relatedDocsType
==
"twitter"
)
{
let
joinedQ
=
qWords
.
map
(
function
(
w
){
return
'('
+
w
+
')'
}).
join
(
' AND '
)
$
.
ajax
({
...
...
@@ -430,34 +429,37 @@ function topPapersFetcher(swType, qWords, priorHtml, cbNext){
contentType
:
"application/json"
,
success
:
function
(
data
){
if
(
data
.
length
)
{
for
(
var
k
in
data
)
{
let
tweetJson
=
data
[
k
]
resHTML
+=
renderTweet
(
tweetJson
)
}
accumulHits
[
nodetype
]
=
accumulHits
[
nodetype
].
concat
(
data
)
}
else
{
resHTML
+=
`<p class="micromessage centered">The query
<span class=code>
${
joinedQ
}
</span> delivers
no results on Twitter.</p>`
accumulHits
[
nodetype
].
push
({
"error"
:
`<p class="micromessage centered">The query
<span class=code>
${
joinedQ
}
</span> delivers
no results on Twitter.</p>`
})
}
cbNext
(
priorHtml
+
resHTML
)
cbNext
(
accumulHits
)
},
error
:
function
(){
console
.
log
(
`Not found: relatedDocs for
${
apiurl
}
`
)
cbNext
(
priorHtml
+
stockErrMsg
)
accumulHits
[
nodetype
].
push
({
"error"
:
stockErrMsg
})
cbNext
(
accumulHits
)
}
});
}
else
if
(
TW
.
conf
.
relatedDocsType
==
"LocalDB"
)
{
let
thisRelDocsConf
=
TW
.
gmenuInfos
[
TW
.
File
][
nodetype
]
if
(
!
thisRelDocsConf
)
{
resHTML
=
`<p>Your settings for relatedDocsType are set on a local database,
accumulHits
[
nodetype
].
push
({
"error"
:
`<p>Your settings for relatedDocsType are set on a local database,
but your servermenu file does not provide any information about
the CSV or DB table to query for related documents
(on nodetype
${
nodetype
}
:
${
swType
}
)</p>`
cbNext
(
priorHtml
+
resHTML
)
return
})
cbNext
(
accumulHits
)
return
}
else
{
// /!\ documentation and specification needed for the php use cases /!\
...
...
@@ -474,22 +476,95 @@ function topPapersFetcher(swType, qWords, priorHtml, cbNext){
type
:
'GET'
,
url
:
apiurl
+
'/info_div.php'
,
data
:
urlParams
,
contentType
:
"application/json"
,
success
:
function
(
data
){
console
.
log
(
`relatedDocs:
${
apiurl
}
/info_div.php?
${
urlParams
}
`
);
resHTML
=
data
cbNext
(
priorHtml
+
resHTML
)
if
(
data
.
hits
)
{
accumulHits
[
nodetype
]
=
accumulHits
[
nodetype
].
concat
(
data
.
hits
)
}
cbNext
(
accumulHits
)
},
error
:
function
(){
console
.
log
(
`Not found: relatedDocs for
${
apiurl
}
`
)
cbNext
(
priorHtml
+
stockErrMsg
)
accumulHits
[
nodetype
].
push
({
"error"
:
stockErrMsg
})
cbNext
(
accumulHits
)
}
});
}
}
}
function
displayTopPapers
(
enrichedHtml
)
{
$
(
"#topPapers"
).
html
(
enrichedHtml
);
function
makeRendererFromTemplate
(
tmplName
)
{
let
tmplURL
=
TW
.
conf
.
paths
.
templates
+
'/'
+
tmplName
+
'.html'
let
gotTemplate
=
AjaxSync
({
url
:
tmplURL
});
var
tmplStr
=
''
if
(
gotTemplate
[
'OK'
])
{
tmplStr
=
gotTemplate
.
data
}
// we return a customized renderJsonToHtml function
return
function
(
jsonHit
)
{
let
htmlOut
=
tmplStr
for
(
key
in
jsonHit
)
{
// our tags look like this in the template ====> by $${author}, [$${date}]
let
reKey
=
new
RegExp
(
'
\\
$
\\
$
\\
{'
+
key
+
'
\\
}'
,
'g'
)
// we replace them by value
htmlOut
=
htmlOut
.
replace
(
reKey
,
jsonHit
[
key
])
}
// we also replace any not found keys by 'N/A'
let
reKeyAll
=
new
RegExp
(
'
\\
$
\\
$
\\
{[^
\\
}]+
\\
}'
,
'g'
)
htmlOut
=
htmlOut
.
replace
(
reKeyAll
,
"N/A"
)
return
htmlOut
}
}
function
displayTopPapers
(
jsonHits
)
{
// console.log('jsonHits', jsonHits)
let
resHTML
=
'<ul class="infoitems">'
let
toHtmlFun
=
function
(){}
for
(
var
ndtypeId
in
TW
.
categories
)
{
if
(
TW
.
conf
.
relatedDocsType
==
'twitter'
)
{
toHtmlFun
=
renderTweet
}
else
{
let
thisRelDocsConf
=
TW
.
gmenuInfos
[
TW
.
File
][
ndtypeId
]
if
(
thisRelDocsConf
&&
thisRelDocsConf
.
reltemplate
)
{
// console.log("my rendering hits template", thisRelDocsConf.reltemplate)
toHtmlFun
=
makeRendererFromTemplate
(
thisRelDocsConf
.
reltemplate
)
}
else
{
console
.
warn
(
`no rendering template found in
${
TW
.
conf
.
paths
.
sourceMenu
}
for this source
${
TW
.
File
}
...`
)
// try the universal template
toHtmlFun
=
makeRendererFromTemplate
(
"universal"
)
}
}
// console.log("my rendering fun", toHtmlFun)
for
(
var
k
in
jsonHits
[
ndtypeId
])
{
let
hitJson
=
jsonHits
[
ndtypeId
][
k
]
if
(
hitJson
.
error
)
{
resHTML
+=
hitJson
.
error
}
else
{
resHTML
+=
toHtmlFun
(
hitJson
)
}
}
}
resHTML
+=
'</ul>'
// effect the changes in topPapers
$
(
"#topPapers"
).
html
(
resHTML
);
}
function
newPopup
(
url
)
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment