Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
gargantext
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
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
humanities
gargantext
Commits
d18bd9ce
Commit
d18bd9ce
authored
9 years ago
by
delanoe
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'refactoring' into refactoring-ngrams
parents
f525e222
33904b8b
Changes
22
Show whitespace changes
Inline
Side-by-side
Showing
22 changed files
with
461 additions
and
186 deletions
+461
-186
app.css
annotations/static/annotations/app.css
+6
-0
document.js
annotations/static/annotations/document.js
+56
-4
http.js
annotations/static/annotations/http.js
+45
-0
main.html
annotations/templates/annotations/main.html
+4
-3
urls.py
annotations/urls.py
+5
-4
views.py
annotations/views.py
+1
-0
settings.py
gargantext/settings.py
+1
-1
urls.py
gargantext/urls.py
+3
-3
nodes.py
gargantext/views/api/nodes.py
+160
-64
__init__.py
moissonneurs/__init__.py
+0
-0
istex.py
moissonneurs/istex.py
+1
-1
pubmed.py
moissonneurs/pubmed.py
+1
-1
urls.py
moissonneurs/urls.py
+7
-7
util.py
moissonneurs/util.py
+0
-0
Docs_dyna_chart_and_table.js
static/js/gargantext/Docs_dyna_chart_and_table.js
+94
-36
Journals_dyna_chart_and_table.js
static/js/gargantext/Journals_dyna_chart_and_table.js
+1
-1
journals.html
templates/pages/corpora/journals.html
+6
-3
terms.html
templates/pages/corpora/terms.html
+5
-2
titles.html
templates/pages/corpora/titles.html
+9
-5
menu.html
templates/pages/menu.html
+47
-45
overview.html
templates/pages/projects/overview.html
+1
-0
project.html
templates/pages/projects/project.html
+8
-6
No files found.
annotations/static/annotations/app.css
View file @
d18bd9ce
...
...
@@ -161,3 +161,9 @@
.float-right
{
float
:
right
;
}
.favactive
{
/* yellow */
color
:
#FFF50D
;
text-shadow
:
-1px
0
#777777
,
0
1px
#777777
,
1px
0
#777777
,
0
-1px
#777777
;
}
This diff is collapsed.
Click to expand it.
annotations/static/annotations/document.js
View file @
d18bd9ce
...
...
@@ -52,12 +52,64 @@
}]);
annotationsAppDocument
.
controller
(
'DocFavoriteController'
,
[
'$scope'
,
'$rootScope'
,
'DocumentHttpService'
,
function
(
$scope
,
$rootScope
,
DocumentHttpService
)
{
[
'$scope'
,
'$rootScope'
,
'MainApiFavoritesHttpService'
,
function
(
$scope
,
$rootScope
,
MainApiFavoritesHttpService
)
{
$scope
.
isFavorite
=
false
;
MainApiFavoritesHttpService
.
get
(
{
'corpusId'
:
$rootScope
.
corpusId
,
'docId'
:
$rootScope
.
docId
},
function
(
data
)
{
if
(
data
[
'favdocs'
].
length
>
0
&&
data
[
'favdocs'
][
0
]
==
$scope
.
docId
)
{
$scope
.
isFavorite
=
true
;
}
else
{
$scope
.
isFavorite
=
false
;
}
},
function
(
data
)
{
console
.
error
(
"unable to check if document belongs to favorites"
);
$scope
.
isFavorite
=
false
;
}
)
;
$scope
.
onStarClick
=
function
(
$event
)
{
console
.
log
(
$scope
.
isFavorite
)
// console.log($scope)
console
.
log
(
"TODO"
);
var
myAction
;
if
(
!
$scope
.
isFavorite
)
{
// PUT api/nodes/574/favorites?docs=576
myAction
=
MainApiFavoritesHttpService
.
put
}
else
{
// DELETE api/nodes/574/favorites?docs=576
myAction
=
MainApiFavoritesHttpService
.
delete
}
// (1) do the action
myAction
(
{
'corpusId'
:
$rootScope
.
corpusId
,
'docId'
:
$rootScope
.
docId
},
// success
function
(
data
)
{
// (2) toggle status and refresh
$scope
.
isFavorite
=
!
$scope
.
isFavorite
$rootScope
.
refreshDisplay
();
},
// failure
function
(
data
)
{
console
.
error
(
"unable to change favorite status"
);
}
);
};
$scope
.
isFavorite
=
false
;
}]);
})(
window
);
This diff is collapsed.
Click to expand it.
annotations/static/annotations/http.js
View file @
d18bd9ce
...
...
@@ -122,4 +122,49 @@
}
);
});
/*
* MainApiFavoritesHttpService: Check/Add/Del Document in favorites
* ============================
* route: api/nodes/574/favorites?docs=576
* /!\ for this route we reach out of this annotation module
* and send directly to the gargantext api route for favs
* (cross origin request with http protocol scheme)
* ------
*
* exemple:
* --------
* {
* "favdocs": [576] // <== if doc is among favs
* "missing": [] // <== if doc is not in favs
* }
*
*/
http
.
factory
(
'MainApiFavoritesHttpService'
,
function
(
$resource
)
{
return
$resource
(
// adding explicit "http://" b/c this a cross origin request
'http://'
+
window
.
GARG_ROOT_URL
+
"/api/nodes/:corpusId/favorites?docs=:docId"
,
{
corpusId
:
'@corpusId'
,
docId
:
'@docId'
},
{
get
:
{
method
:
'GET'
,
params
:
{
corpusId
:
'@corpusId'
,
docId
:
'@docId'
}
},
put
:
{
method
:
'PUT'
,
params
:
{
corpusId
:
'@corpusId'
,
docId
:
'@docId'
}
},
delete
:
{
method
:
'DELETE'
,
params
:
{
corpusId
:
'@corpusId'
,
docId
:
'@docId'
}
}
}
);
});
})(
window
);
This diff is collapsed.
Click to expand it.
annotations/templates/annotations/main.html
View file @
d18bd9ce
...
...
@@ -73,7 +73,7 @@
</div>
<div
class=
"col-md-2 col-xs-2 clearfix"
>
<button
ng-controller=
"DocFavoriteController"
type=
"button"
class=
"btn btn-default float-right"
ng-click=
"onStarClick($event)"
>
<span
class=
"glyphicon"
ng-class=
"{'glyphicon-star-empty': isFavorite == false, 'glyphicon-star': isFavorite == true}"
></span>
<span
class=
"glyphicon"
ng-class=
"{'glyphicon-star-empty': isFavorite == false, 'glyphicon-star
favactive
': isFavorite == true}"
></span>
</button>
<!--<nav>
<ul class="pager">
...
...
@@ -129,6 +129,7 @@
/* Constants required for annotations app JS to work */
window
.
STATIC_URL
=
"{% static '' %}"
;
window
.
ANNOTATION_API_URL
=
"{{ api_url }}"
;
window
.
GARG_ROOT_URL
=
"{{ garg_url }}"
;
window
.
NODES_API_URL
=
"{{ nodes_api_url }}"
;
</script>
<script
src=
"{% static 'annotations/main.js' %}"
></script>
...
...
This diff is collapsed.
Click to expand it.
annotations/urls.py
View file @
d18bd9ce
...
...
@@ -6,12 +6,13 @@ from annotations import views
urlpatterns
=
[
# GET [DocumentHttpService]
# json:title,id,authors,journal,
# publication_date
# abstract_text,full_text
url
(
r'^documents/(?P<doc_id>[0-9]+)$'
,
views
.
Document
.
as_view
()),
# document view
# GET
:
# GET
[NgramListHttpService]
# was : lists ∩ document (ngram_ids intersection if connected to list node_id and doc node_id)
# fixed 2016-01: just lists (because document doesn't get updated by POST create cf. ngram.lists.DocNgram filter commented)
url
(
r'^corpora/(?P<corpus_id>[0-9]+)/documents/(?P<doc_id>[0-9]+)$'
,
views
.
NgramList
.
as_view
()),
# the list associated with an ngram
...
...
This diff is collapsed.
Click to expand it.
annotations/views.py
View file @
d18bd9ce
...
...
@@ -30,6 +30,7 @@ def main(request, project_id, corpus_id, document_id):
return
render_to_response
(
'annotations/main.html'
,
{
# TODO use reverse()
'api_url'
:
urljoin
(
request
.
get_host
(),
'/annotations/'
),
'garg_url'
:
request
.
get_host
(),
'nodes_api_url'
:
urljoin
(
request
.
get_host
(),
'/api/'
),
},
context_instance
=
RequestContext
(
request
))
...
...
This diff is collapsed.
Click to expand it.
gargantext/settings.py
View file @
d18bd9ce
...
...
@@ -51,7 +51,7 @@ INSTALLED_APPS = [
'djcelery'
,
'annotations'
,
'graphExplorer'
,
'
scrape
rs'
,
'
moissonneu
rs'
,
]
MIDDLEWARE_CLASSES
=
[
...
...
This diff is collapsed.
Click to expand it.
gargantext/urls.py
View file @
d18bd9ce
...
...
@@ -26,7 +26,7 @@ from annotations.views import main as annotations_main_view
import
graphExplorer.urls
# Module Scrapers
import
scrape
rs.urls
import
moissonneu
rs.urls
urlpatterns
=
[
url
(
r'^admin/'
,
admin
.
site
.
urls
)
...
...
@@ -43,6 +43,6 @@ urlpatterns = [ url(r'^admin/' , admin.site.urls )
,
url
(
r'^annotations/'
,
include
(
annotations_urls
)
)
,
url
(
r'^projects/(\d+)/corpora/(\d+)/documents/(\d+)/$'
,
annotations_main_view
)
# Module Scrapers
,
url
(
r'^
scrapers/'
,
include
(
scrape
rs
.
urls
)
)
# Module Scrapers
(Moissonneurs in French)
,
url
(
r'^
moissonneurs/'
,
include
(
moissonneu
rs
.
urls
)
)
]
This diff is collapsed.
Click to expand it.
gargantext/views/api/nodes.py
View file @
d18bd9ce
...
...
@@ -11,8 +11,11 @@ from gargantext.util.http import ValidationException, APIView \
from
collections
import
defaultdict
import
csv
_node_available_fields
=
[
'id'
,
'parent_id'
,
'name'
,
'typename'
,
'hyperdata'
,
'ngrams'
]
_node_default_fields
=
[
'id'
,
'parent_id'
,
'name'
,
'typename'
]
_node_available_formats
=
[
'json'
,
'csv'
,
'bibex'
]
_node_available_types
=
NODETYPES
...
...
@@ -21,6 +24,7 @@ def _query_nodes(request, node_id=None):
# parameters validation
parameters
=
get_parameters
(
request
)
parameters
=
validate
(
parameters
,
{
'type'
:
dict
,
'items'
:
{
'formated'
:
{
'type'
:
str
,
'required'
:
False
,
'default'
:
'json'
},
'pagination_limit'
:
{
'type'
:
int
,
'default'
:
10
},
'pagination_offset'
:
{
'type'
:
int
,
'default'
:
0
},
'fields'
:
{
'type'
:
list
,
'default'
:
_node_default_fields
,
'items'
:
{
...
...
@@ -65,6 +69,8 @@ class NodeListResource(APIView):
"""Displays the list of nodes corresponding to the query.
"""
parameters
,
query
,
count
=
_query_nodes
(
request
)
if
parameters
[
'formated'
]
==
'json'
:
return
JsonHttpResponse
({
'parameters'
:
parameters
,
'count'
:
count
,
...
...
@@ -74,6 +80,29 @@ class NodeListResource(APIView):
]
})
elif
parameters
[
'formated'
]
==
'csv'
:
response
=
HttpResponse
(
content_type
=
'text/csv'
)
response
[
'Content-Disposition'
]
=
'attachment; filename="Gargantext_Corpus.csv"'
writer
=
csv
.
writer
(
response
)
keys
=
[
'title'
,
'journal'
,
'publication_date'
,
'abstract'
,
'authors'
]
writer
.
writerow
(
keys
)
for
node
in
query
:
data
=
list
()
for
key
in
keys
:
try
:
data
.
append
(
node
.
hyperdata
[
key
])
except
:
data
.
append
(
""
)
writer
.
writerow
(
data
)
return
response
def
post
(
self
,
request
):
"""Create a new node.
...
...
@@ -200,11 +229,17 @@ class NodeResource(APIView):
return
JsonHttpResponse
({
'deleted'
:
result
.
rowcount
})
class
CorpusFavorites
(
APIView
):
"""Retrieve/update/delete
a corpus node's associated favorite doc
s
"""Retrieve/update/delete
one or several docs from a corpus associated fav
s
(url: GET /api/nodes/<corpus_id>/favorites)
=> lists all favorites
(url: GET /api/nodes/<corpus_id>/favorites?docs[]=doc1,doc2)
=> checks for each doc if it is in favorites
(url: DEL /api/nodes/<corpus_id>/favorites?docs[]=doc1,doc2)
=> removes each doc from favorites
(url: PUT /api/nodes/<corpus_id>/favorites?docs[]=doc1,doc2)
=> add each doc to favorites
"""
def
_get_fav_node
(
self
,
corpus_id
):
...
...
@@ -224,25 +259,57 @@ class CorpusFavorites(APIView):
else
:
self
.
corpus
=
corpus
fav_node
=
self
.
corpus
.
children
(
'FAVORITES'
)
.
first
()
return
fav_node
def
get
(
self
,
request
,
corpus_id
):
response
=
{}
"""
2 possibilities with/without param
1) GET http://localhost:8000/api/nodes/2/favorites
(returns the full list of fav docs within corpus 2)
2) GET http://localhost:8000/api/nodes/2/favorites?docs=53,54
(will test if docs 53 and 54 are among the favorites of corpus 2)
(returns the intersection of fav docs with [53,54])
"""
fav_node
=
self
.
_get_fav_node
(
corpus_id
)
req_params
=
validate
(
get_parameters
(
request
),
{
'docs'
:
list
,
'default'
:
""
}
)
response
=
{}
if
fav_node
==
None
:
response
=
{
'warning'
:
'No favorites node is defined for this corpus (
\'
%
s
\'
)'
%
self
.
corpus
.
name
,
'
doc_id
s'
:[]
'
favdoc
s'
:[]
}
el
se
:
el
if
'docs'
not
in
req_params
:
# each docnode associated to the favnode of this corpusnode
q
=
(
session
.
query
(
NodeNode
.
node2_id
)
.
filter
(
NodeNode
.
node1_id
==
fav_node
.
id
))
doc_ids
=
[
row
.
node2_id
for
row
in
q
.
all
()]
all_
doc_ids
=
[
row
.
node2_id
for
row
in
q
.
all
()]
response
=
{
'doc_ids'
:
doc_ids
'favdocs'
:
all_doc_ids
}
else
:
nodeids_to_check
=
[
int
(
did
)
for
did
in
req_params
[
'docs'
]
.
split
(
','
)]
# each docnode from the input list, if it is associated to the favnode
q
=
(
session
.
query
(
NodeNode
.
node2_id
)
.
filter
(
NodeNode
.
node1_id
==
fav_node
.
id
)
.
filter
(
NodeNode
.
node2_id
.
in_
(
nodeids_to_check
)))
present_doc_ids
=
[
row
.
node2_id
for
row
in
q
.
all
()]
absent_doc_ids
=
[
did
for
did
in
nodeids_to_check
if
did
not
in
present_doc_ids
]
response
=
{
'favdocs'
:
present_doc_ids
,
'missing'
:
absent_doc_ids
}
return
JsonHttpResponse
(
response
)
...
...
@@ -252,17 +319,27 @@ class CorpusFavorites(APIView):
DELETE http://localhost:8000/api/nodes/2/favorites?docs=53,54
(will delete docs 53 and 54 from the favorites of corpus 2)
"""
#
if not request.user.is_authenticated():
#
# can't use @requires_auth because of positional 'self' within class
#
return HttpResponse('Unauthorized', status=401)
if
not
request
.
user
.
is_authenticated
():
# can't use @requires_auth because of positional 'self' within class
return
HttpResponse
(
'Unauthorized'
,
status
=
401
)
# user is ok
fav_node
=
self
.
_get_fav_node
(
corpus_id
)
response
=
{}
if
fav_node
==
None
:
response
=
{
'warning'
:
'No favorites node is defined for this corpus (
\'
%
s
\'
)'
%
self
.
corpus
.
name
,
'count_removed'
:
0
}
else
:
req_params
=
validate
(
get_parameters
(
request
),
{
'docs'
:
list
,
'default'
:
""
}
)
nodeids_to_delete
=
req_params
[
'docs'
]
.
split
(
','
)
nodeids_to_delete
=
[
int
(
did
)
for
did
in
req_params
[
'docs'
]
.
split
(
','
)]
# it deletes from favourites but not from DB
result
=
session
.
execute
(
...
...
@@ -271,20 +348,32 @@ class CorpusFavorites(APIView):
.
where
(
NodeNode
.
node2_id
.
in_
(
nodeids_to_delete
))
)
session
.
commit
()
return
JsonHttpResponse
({
'count_removed'
:
result
.
rowcount
})
response
=
{
'count_removed'
:
result
.
rowcount
}
return
JsonHttpResponse
(
response
)
def
put
(
self
,
request
,
corpus_id
,
check_each_doc
=
True
):
#
if not request.user.is_authenticated():
#
# can't use @requires_auth because of positional 'self' within class
#
return HttpResponse('Unauthorized', status=401)
if
not
request
.
user
.
is_authenticated
():
# can't use @requires_auth because of positional 'self' within class
return
HttpResponse
(
'Unauthorized'
,
status
=
401
)
# user is ok
fav_node
=
self
.
_get_fav_node
(
corpus_id
)
response
=
{}
if
fav_node
==
None
:
response
=
{
'warning'
:
'No favorites node is defined for this corpus (
\'
%
s
\'
)'
%
self
.
corpus
.
name
,
'count_added'
:
0
}
else
:
req_params
=
validate
(
get_parameters
(
request
),
{
'docs'
:
list
,
'default'
:
""
}
)
nodeids_to_add
=
req_params
[
'docs'
]
.
split
(
','
)
nodeids_to_add
=
[
int
(
did
)
for
did
in
req_params
[
'docs'
]
.
split
(
','
)]
if
check_each_doc
:
# verification que ce sont bien des documents du bon corpus
...
...
@@ -295,6 +384,8 @@ class CorpusFavorites(APIView):
.
filter
(
Node
.
typename
==
'DOCUMENT'
)
)
lookup
=
{
known_doc
.
id
:
True
for
known_doc
in
known_docs_q
.
all
()}
# debug
# print("lookup hash", lookup)
rejected_list
=
[]
for
doc_node_id
in
nodeids_to_add
:
if
(
doc_node_id
not
in
lookup
):
...
...
@@ -311,7 +402,12 @@ class CorpusFavorites(APIView):
((
fav_node
.
id
,
doc_node_id
,
1.0
)
for
doc_node_id
in
nodeids_to_add
)
)
return
JsonHttpResponse
({
'count_added'
:
len
(
nodeids_to_add
)})
# todo count really added (here: counts input param not result)
response
=
{
'count_added'
:
len
(
nodeids_to_add
)}
return
JsonHttpResponse
(
response
)
class
CorpusFacet
(
APIView
):
"""Loop through a corpus node's docs => do counts by a hyperdata field
...
...
This diff is collapsed.
Click to expand it.
scrape
rs/__init__.py
→
moissonneu
rs/__init__.py
View file @
d18bd9ce
File moved
This diff is collapsed.
Click to expand it.
scrape
rs/istex.py
→
moissonneu
rs/istex.py
View file @
d18bd9ce
...
...
@@ -15,7 +15,7 @@ from gargantext.util.http import JsonHttpResponse
from
gargantext.util.scheduling
import
scheduled
from
gargantext.util.toolchain
import
parse_extract_indexhyperdata
from
scrape
rs.util
import
Scraper
from
moissonneu
rs.util
import
Scraper
...
...
This diff is collapsed.
Click to expand it.
scrape
rs/pubmed.py
→
moissonneu
rs/pubmed.py
View file @
d18bd9ce
...
...
@@ -26,7 +26,7 @@ from gargantext.util.http import JsonHttpResponse
from
gargantext.util.scheduling
import
scheduled
from
gargantext.util.toolchain
import
parse_extract_indexhyperdata
from
scrape
rs.util
import
Scraper
from
moissonneu
rs.util
import
Scraper
...
...
This diff is collapsed.
Click to expand it.
scrape
rs/urls.py
→
moissonneu
rs/urls.py
View file @
d18bd9ce
...
...
@@ -7,7 +7,7 @@
#
#
Scrape
rs == getting data from external databases
#
moissonneu
rs == getting data from external databases
# Available databases :
...
...
@@ -18,19 +18,19 @@
from
django.conf.urls
import
url
import
scrape
rs.pubmed
as
pubmed
import
scrape
rs.istex
as
istex
import
moissonneu
rs.pubmed
as
pubmed
import
moissonneu
rs.istex
as
istex
# TODO
#import
scrape
rs.cern as cern
#import
moissonneu
rs.cern as cern
# TODO
#import
scrape
rs.hal as hal
#import
scrape
rs.revuesOrg as revuesOrg
#import
moissonneu
rs.hal as hal
#import
moissonneu
rs.revuesOrg as revuesOrg
# TODO ?
# REST API for the
scrape
rs
# REST API for the
moissonneu
rs
# /!\ urls patterns here are *without* the trailing slash
urlpatterns
=
[
url
(
r'^pubmed/query$'
,
pubmed
.
query
)
...
...
This diff is collapsed.
Click to expand it.
scrape
rs/util.py
→
moissonneu
rs/util.py
View file @
d18bd9ce
File moved
This diff is collapsed.
Click to expand it.
static/js/gargantext/Docs_dyna_chart_and_table.js
View file @
d18bd9ce
...
...
@@ -143,6 +143,7 @@ var RecDict={};
var
AjaxRecords
=
[]
var
Garbage
=
{}
var
countByTitles
=
{}
// useful for title duplicates
var
favorites
=
{}
function
getRecord
(
rec_id
)
{
return
MyTable
.
data
(
'dynatable'
).
settings
.
dataset
.
originalRecords
[
rec_id
];
...
...
@@ -153,6 +154,39 @@ function getRecords() {
return
MyTable
.
data
(
'dynatable'
).
settings
.
dataset
.
originalRecords
;
}
function
favstatusToStar
(
rec_id
,
boolFavstatus
,
boolStrike
=
false
){
var
starStr
=
boolFavstatus
?
"glyphicon-star"
:
"glyphicon-star-empty"
;
var
styleStr
=
boolStrike
?
"style='text-decoration:line-through'"
:
""
;
var
htmlStr
=
"<span class='glyphicon "
+
starStr
+
"' "
+
styleStr
;
htmlStr
+=
" onclick='toggleFavstatus("
+
rec_id
+
")'"
;
htmlStr
+=
">"
;
htmlStr
+=
"</span>"
;
return
htmlStr
}
function
toggleFavstatus
(
rec_id
)
{
var
doc_id
=
AjaxRecords
[
rec_id
][
"id"
]
var
statusBefore
=
AjaxRecords
[
rec_id
][
"isFavorite"
]
var
myHttpAction
=
statusBefore
?
'DELETE'
:
'PUT'
$
.
ajax
({
url
:
'http://localhost:8000/api/nodes/'
+
corpus_id
+
'/favorites?docs='
+
doc_id
,
type
:
myHttpAction
,
beforeSend
:
function
(
xhr
)
{
xhr
.
setRequestHeader
(
"X-CSRFToken"
,
getCookie
(
"csrftoken"
));
},
success
:
function
(
favdata
)
{
// it's been toggled in the DB so we toggle locally
if
(
statusBefore
)
delete
favorites
[
doc_id
]
else
favorites
[
doc_id
]
=
true
AjaxRecords
[
rec_id
][
"isFavorite"
]
=
!
statusBefore
;
// and we reprocess table directly (no need for new ajax of other recs)
MyTable
.
data
(
'dynatable'
).
process
();
},
});
}
function
transformContent2
(
rec_id
)
{
// pr("\t\ttransformContent2: "+rec_id)
var
elem
=
AjaxRecords
[
rec_id
];
...
...
@@ -162,12 +196,14 @@ function transformContent2(rec_id) {
result
[
"id"
]
=
elem
[
"id"
]
result
[
"date"
]
=
'<strike>'
+
elem
[
"date"
]
+
'</strike>'
result
[
"docurl"
]
=
'<strike>'
+
elem
[
"docurl"
]
+
'</strike>'
result
[
"isFavorite"
]
=
favstatusToStar
(
rec_id
,
elem
[
"isFavorite"
],
boolStrike
=
true
)
result
[
"rawtitle"
]
=
elem
[
"rawtitle"
]
result
[
"del"
]
=
'<input id='
+
rec_id
+
' onclick="overRide(this)" type="checkbox" checked/>'
}
else
{
result
[
"id"
]
=
elem
[
"id"
]
result
[
"date"
]
=
elem
[
"date"
]
result
[
"docurl"
]
=
elem
[
"docurl"
]
result
[
"isFavorite"
]
=
favstatusToStar
(
rec_id
,
elem
[
"isFavorite"
])
result
[
"rawtitle"
]
=
elem
[
"rawtitle"
]
result
[
"del"
]
=
'<input id='
+
rec_id
+
' onclick="overRide(this)" type="checkbox"/>'
}
...
...
@@ -269,6 +305,9 @@ function Main_test(Data) {
div_table
+=
"
\
t"
+
"
\
t"
+
'<span class="glyphicon glyphicon-calendar"></span> Date</th>'
+
"
\n
"
div_table
+=
"
\
t"
+
"
\
t"
+
'<th data-dynatable-column="docurl">'
+
"
\n
"
div_table
+=
"
\
t"
+
"
\
t"
+
'<span class="glyphicon glyphicon-text-size"></span> Title</th>'
+
"
\n
"
div_table
+=
"
\
t"
+
"
\
t"
+
'<th data-dynatable-column="isFavorite">'
+
"
\n
"
div_table
+=
"
\
t"
+
"
\
t"
+
'<span class="glyphicon glyphicon-star"></span>'
+
"
\n
"
div_table
+=
"
\
t"
+
"
\
t"
+
'</th>'
+
"
\n
"
div_table
+=
"
\
t"
+
"
\
t"
+
'<th data-dynatable-column="del" data-dynatable-no-sort="true">'
+
"
\n
"
div_table
+=
"
\
t"
+
"
\
t"
+
'<span class="glyphicon glyphicon-trash"></span>'
+
"
\n
"
div_table
+=
"
\
t"
+
"
\
t"
+
'</th>'
+
"
\n
"
...
...
@@ -445,7 +484,7 @@ function Main_test(Data) {
},
inputs
:
{
// our own search which differentiates title vs abstract queries
queries
:
$
(
'#doubleSearch, #d
up
Filter'
)
queries
:
$
(
'#doubleSearch, #d
oc
Filter'
)
},
writers
:
{
_rowWriter
:
ulWriter
...
...
@@ -495,14 +534,16 @@ function Main_test(Data) {
}
// MyTable.data('dynatable').process();
// also append another bound filter for duplicates
// also append another bound filter for duplicates
/favorites
MyTable
.
data
(
'dynatable'
).
queries
.
functions
[
'dupFilter'
]
=
function
(
record
,
selected
)
{
return
(
selected
==
'filter_all'
)
||
(
countByTitles
[
record
.
rawtitle
]
>
1
)
.
functions
[
'docFilter'
]
=
function
(
record
,
opt
)
{
if
(
opt
==
'filter_all'
)
return
true
else
if
(
opt
==
'filter_favs'
)
return
favorites
[
record
.
id
]
else
if
(
opt
==
'filter_dupl'
)
return
(
countByTitles
[
record
.
rawtitle
]
>
1
)
}
// and set this filter's initial status to 'filter_all'
MyTable
.
data
(
'dynatable'
).
settings
.
dataset
.
queries
[
'd
up
Filter'
]
=
'filter_all'
MyTable
.
data
(
'dynatable'
).
settings
.
dataset
.
queries
[
'd
oc
Filter'
]
=
'filter_all'
MyTable
.
data
(
'dynatable'
).
sorts
.
functions
[
"rawtitleSort"
]
=
function
testSort
(
rec1
,
rec2
)
{
...
...
@@ -531,20 +572,20 @@ function Main_test(Data) {
var
dupFlag
=
false
;
$
(
"#div-table"
).
on
(
"dynatable:queries:added"
,
function
(
e
,
qname
,
qval
)
{
if
(
!
dupFlag
&&
qname
==
'd
up
Filter'
&&
qval
==
"filter_dupl"
)
{
MyTable
.
data
(
'dynatable'
).
queries
.
remove
(
'd
up
Filter'
)
if
(
!
dupFlag
&&
qname
==
'd
oc
Filter'
&&
qval
==
"filter_dupl"
)
{
MyTable
.
data
(
'dynatable'
).
queries
.
remove
(
'd
oc
Filter'
)
// to avoid recursion when we'll call this filter again in 4 lines
dupFlag
=
true
;
// sort alphabetically **before** duplicates filter
MyTable
.
data
(
'dynatable'
).
sorts
.
clear
();
MyTable
.
data
(
'dynatable'
).
sorts
.
add
(
'rawtitle'
,
-
1
)
// -1 <==> DESC (ASC doesn't work well ?)
MyTable
.
data
(
'dynatable'
).
queries
.
add
(
'd
up
Filter'
,
'filter_dupl'
)
MyTable
.
data
(
'dynatable'
).
queries
.
add
(
'd
oc
Filter'
,
'filter_dupl'
)
MyTable
.
data
(
'dynatable'
).
process
();
}
});
$
(
"#div-table"
).
on
(
"dynatable:queries:removed"
,
function
(
e
,
qname
)
{
if
(
qname
==
'd
up
Filter'
)
{
if
(
qname
==
'd
oc
Filter'
)
{
dupFlag
=
false
;
}
});
...
...
@@ -556,14 +597,29 @@ $.ajax({
url
:
'/api/nodes?types[]=DOCUMENT&pagination_limit=-1&parent_id='
+
corpus_id
+
'&fields[]=parent_id&fields[]=id&fields[]=name&fields[]=typename&fields[]=hyperdata'
,
success
:
function
(
data
){
$
(
"#content_loader"
).
remove
();
$
.
each
(
data
.
records
,
function
(
i
,
record
){
success
:
function
(
maindata
){
// unfortunately favorites info is in a separate request (other nodes)
$
.
ajax
({
url
:
'http://localhost:8000/api/nodes/'
+
corpus_id
+
'/favorites'
,
success
:
function
(
favdata
){
// initialize favs lookup
for
(
var
i
in
favdata
[
'favdocs'
])
{
doc_id
=
favdata
[
'favdocs'
][
i
]
favorites
[
doc_id
]
=
true
;
}
// now process the nodes data from 1st request
$
.
each
(
maindata
.
records
,
function
(
i
,
record
){
var
orig_id
=
parseInt
(
record
.
id
);
var
arr_id
=
parseInt
(
i
)
RecDict
[
orig_id
]
=
arr_id
;
record
.
rawtitle
=
record
.
name
;
record
.
isFavorite
=
false
;
if
(
favorites
[
orig_id
])
{
record
.
isFavorite
=
true
;
}
// trick to have a clickable title in docurl slot, but could be done in transformContent2
record
.
docurl
=
'<a target="_blank" href="/projects/'
+
project_id
+
'/corpora/'
+
corpus_id
+
'/documents/'
+
record
.
id
+
'">'
+
record
.
name
+
'</a>'
;
record
.
date
=
get_node_date
(
record
);
...
...
@@ -571,8 +627,8 @@ $.ajax({
});
// initialize CountByTitle census
for
(
var
i
in
data
.
records
)
{
ourTitle
=
data
.
records
[
i
][
'rawtitle'
]
;
for
(
var
i
in
main
data
.
records
)
{
ourTitle
=
main
data
.
records
[
i
][
'rawtitle'
]
;
if
(
countByTitles
.
hasOwnProperty
(
ourTitle
))
{
countByTitles
[
ourTitle
]
++
;
}
...
...
@@ -580,12 +636,14 @@ $.ajax({
countByTitles
[
ourTitle
]
=
1
;
}
}
AjaxRecords
=
data
.
records
;
// backup-ing in global variable!
AjaxRecords
=
main
data
.
records
;
// backup-ing in global variable!
var
result
=
Main_test
(
data
.
records
)
$
(
"#content_loader"
).
remove
();
$
(
"#content_loader"
).
remove
(
)
var
result
=
Main_test
(
maindata
.
records
)
console
.
log
(
result
)
},
});
},
});
This diff is collapsed.
Click to expand it.
static/js/gargantext/Journals_dyna_chart_and_table.js
View file @
d18bd9ce
...
...
@@ -290,7 +290,7 @@ function Main_test( data , initial) {
var
div_table
=
'<p align="right">'
+
"
\n
"
div_table
+=
'<table id="my-ajax-table" class="table table-bordered table-hover">'
+
"
\n
"
div_table
+=
"
\
t"
+
'<thead>'
+
"
\n
"
div_table
+=
"
\
t"
+
"
\
t"
+
'<th data-dynatable-column="name">Title</th>'
+
"
\n
"
div_table
+=
"
\
t"
+
"
\
t"
+
'<th data-dynatable-column="name">
<span class="glyphicon glyphicon-text-size"></span>
Title</th>'
+
"
\n
"
div_table
+=
"
\
t"
+
"
\
t"
+
'<th data-dynatable-column="score" data-dynatable-sorts="score">No. Pubs</th>'
+
"
\n
"
// div_table += "\t"+"\t"+'<th id="score_column_id" data-dynatable-sorts="score" data-dynatable-column="score">Score</th>'+"\n"
div_table
+=
"
\
t"
+
"
\
t"
+
'</th>'
+
"
\n
"
...
...
This diff is collapsed.
Click to expand it.
templates/pages/corpora/journals.html
View file @
d18bd9ce
...
...
@@ -59,9 +59,12 @@
<div
class=
"panel panel-default"
>
<div
class=
"panel-heading"
>
<h4
class=
"panel-title"
>
<h2
class=
"panel-title"
>
<center>
<span
class=
"glyphicon glyphicon-hand-down"
aria-hidden=
"true"
></span>
Publications by source
</h4>
</center>
</h2>
</div>
...
...
This diff is collapsed.
Click to expand it.
templates/pages/corpora/terms.html
View file @
d18bd9ce
...
...
@@ -55,12 +55,15 @@
<div
class=
"panel panel-default"
>
<div
class=
"panel-heading"
>
<h4
class=
"panel-title"
>
<h2
class=
"panel-title"
>
<center>
<span
class=
"glyphicon glyphicon-hand-down"
aria-hidden=
"true"
></span>
Extracted terms
<!-- <button title='run test function' onclick="doATest()">
TEST
</button> -->
</a>
</center>
</h2>
<!-- see in javascript function queries.functions['my_state_filter'] -->
<div
class=
"pull-left"
style=
"margin-top:1.85em;"
>
...
...
This diff is collapsed.
Click to expand it.
templates/pages/corpora/titles.html
View file @
d18bd9ce
...
...
@@ -54,9 +54,12 @@
<div
class=
"jumbotron"
>
<div
class=
"panel panel-default"
>
<div
class=
"panel-heading"
>
<h4
class=
"panel-title"
>
<h2
class=
"panel-title"
>
<center>
<span
class=
"glyphicon glyphicon-hand-down"
aria-hidden=
"true"
></span>
Publications by title
</h4>
</center>
</h2>
<!-- search box with custom function in Docs_dyna_chart_and_tables.js -->
<div
class=
"pull-left"
style=
"margin-top:1.85em; font-size: 16px;"
>
<span
class=
"glyphicon glyphicon-search"
aria-hidden=
"true"
></span>
...
...
@@ -70,9 +73,10 @@
<input
title=
"Search in Abstracts"
id=
"searchAB"
name=
"searchAB"
type=
"checkbox"
>
AB
</span>
<span
class=
"glyphicon glyphicon-filter"
aria-hidden=
"true"
></span>
<select
id=
"d
upFilter"
name=
"dup
Filter"
>
<select
id=
"d
ocFilter"
name=
"doc
Filter"
>
<option
value=
"filter_all"
>
All
</option>
<option
value=
"filter_dupl"
>
Duplicates by Title
</option>
<option
value=
"filter_favs"
>
Favorite documents
</option>
<option
value=
"filter_dupl"
>
Duplicates by title
</option>
</select>
</div>
</div>
...
...
This diff is collapsed.
Click to expand it.
templates/pages/menu.html
View file @
d18bd9ce
...
...
@@ -111,6 +111,7 @@
</a>
<i
class=
"caret"
></i>
<ul
class=
"dropdown-menu"
>
{% if view != "graph" %}
<li>
<a
tabindex=
"-1"
data-url=
"/projects/{{project.id}}/corpora/{{ corpus.id }}/explorer?field1=ngrams&field2=ngrams&distance=conditional&bridgeness=5"
onclick=
'gotoexplorer(this)'
>
With conditional distance
</a>
...
...
@@ -119,6 +120,17 @@
<a
tabindex=
"-1"
data-url=
"/projects/{{project.id}}/corpora/{{ corpus.id }}/explorer?field1=ngrams&field2=ngrams&distance=distributional&bridgeness=5"
onclick=
'gotoexplorer(this)'
>
With distributional distance
</a>
</li>
{% else %}
<li>
<a
tabindex=
"-1"
href=
"/projects/{{project.id}}/corpora/{{ corpus.id }}/explorer?field1=ngrams&field2=ngrams&distance=conditional&bridgeness=5"
>
With conditional distance
</a>
</li>
<li>
<a
tabindex=
"-1"
href=
"/projects/{{project.id}}/corpora/{{ corpus.id }}/explorer?field1=ngrams&field2=ngrams&distance=distributional&bridgeness=5"
>
With distributional distance
</a>
</li>
{% endif %}
</ul>
</li>
{% endif %}
...
...
@@ -138,50 +150,40 @@
<div
class=
"jumbotron"
style=
"margin-bottom:0"
>
<br>
<br>
<!--
<a type="button" class="btn btn-default
href="/projects/{{project.id}}/corpora/{{ corpus.id }}/">Export corpus</a>
--!>
<!-- <li class="divider"></li> --!>
<div
class=
"row"
>
<div class="col-md-
4
">
{% if project %}
<h3>
<a href="/projects/{{project.id}}">
<div
class=
"col-md-
3
"
>
<h3>
<a
href=
"/projects/{{project.id}}"
>
<span
class=
"glyphicon glyphicon-book"
aria-hidden=
"true"
></span>
{{ project.name }}
{{ project.name
| truncatechars:15
}}
</a>
<br>
</h3>
</div>
<div
class=
"col-md-5"
>
<h3>
<span
class=
"glyphicon glyphicon-cd"
aria-hidden=
"true"
></span>
{{ resourcename | truncatechars:20 }}
<br>
</h3>
<h3>
<span
class=
"glyphicon glyphicon-file"
aria-hidden=
"true"
></span>
{{ corpus.name
}}
<br
>
<span class="glyphicon glyphicon-
calendar
" aria-hidden="true"></span>
{{ corpus.date }}
{{ corpus.name | truncatechars:20
}}
<a
class=
"btn btn-default"
role=
"button"
href=
"/api/nodes?parent_id={{corpus.id}}&types[]=DOCUMENT&pagination_limit=100000&formated=csv"
>
<span
class=
"glyphicon glyphicon-
download
"
aria-hidden=
"true"
></span>
</a>
</h3>
{% endif %}
</div>
<div class="col-md-4">
</div>
<div
class=
"col-md-4"
>
<br>
<!-- <a class="btn btn-default" role="button" href="/project/{{project.id}}/corpus/{{corpus.id}}/{{view}}/update">Update</a> -->
<!--
<a class="btn btn-default" role="button" href="/project/{{project.id}}/corpus/{{ corpus.id }}/corpus.csv">Download</a>
<a type="button" class="btn btn-default" data-container="body" data-toggle="popover" data-placement="bottom"
data-content='
<ul>
<li> Rename </li>
<li> Add new documents </li>
<li><a href="/delete/{{corpus.id}}">Delete</a></li>
</ul>
'>Manage</a>
-->
<!-- <a class="btn btn-primary btn-lg" role="button" href="/admin/documents/corpus/{{ corpus.id }}/">Add documents</a></p> -->
</div>
<h3>
<span
class=
"glyphicon glyphicon-calendar"
aria-hidden=
"true"
></span>
{{ corpus.date }}
</h3>
<h3>
<span
class=
"glyphicon glyphicon-user"
aria-hidden=
"true"
></span>
Author(s):
</h3>
<h4>
{{ user.username | truncatechars:15}}
</h4>
</div>
</div>
</div>
...
...
This diff is collapsed.
Click to expand it.
templates/pages/projects/overview.html
View file @
d18bd9ce
...
...
@@ -78,6 +78,7 @@
<div
id=
"project_{{project.id}}"
class=
"row"
>
<h3>
<div
class=
"col-md-1 content"
></div>
<div
class=
"col-md-5 content"
>
<a
href=
"/projects/{{ project.id }}"
>
...
...
This diff is collapsed.
Click to expand it.
templates/pages/projects/project.html
View file @
d18bd9ce
...
...
@@ -73,6 +73,7 @@
{% for key, corpora in list_corpora.items %}
<h2>
<div
class=
"row"
>
<div
class=
"col-md-1 content"
></div>
<span
class=
"glyphicon glyphicon-cd"
aria-hidden=
"true"
></span>
{{ key }}
</h2>
...
...
@@ -80,6 +81,7 @@
<div
id=
"corpus_{{corpus.id}}"
>
<div
class=
"row"
>
<h4>
<div
class=
"col-md-1 content"
></div>
<div
class=
"col-md-5 content"
>
<a
href=
"/projects/{{project.id}}/corpora/{{corpus.id}}"
>
<span
class=
"glyphicon glyphicon-file"
aria-hidden=
"true"
></span>
...
...
@@ -109,7 +111,7 @@
</button>
</div>
<div
class=
"col-md-
5
content"
>
<div
class=
"col-md-
4
content"
>
{% for state in corpus.hyperdata.statuses %}
{% ifequal state.action "ngrams_extraction" %}
{% if state.complete %}
...
...
@@ -293,7 +295,7 @@
$
.
ajax
({
// contentType: "application/json",
url
:
window
.
location
.
origin
+
"/
scrape
rs/pubmed/save/"
+
projectid
,
url
:
window
.
location
.
origin
+
"/
moissonneu
rs/pubmed/save/"
+
projectid
,
data
:
pubmedifiedQuery
,
type
:
'POST'
,
beforeSend
:
function
(
xhr
)
{
...
...
@@ -365,7 +367,7 @@
if
(
theType
==
"Pubmed (XML format)"
)
{
$
.
ajax
({
// contentType: "application/json",
url
:
window
.
location
.
origin
+
"/
scrape
rs/pubmed/query"
,
url
:
window
.
location
.
origin
+
"/
moissonneu
rs/pubmed/query"
,
data
:
formData
,
type
:
'POST'
,
beforeSend
:
function
(
xhr
)
{
...
...
@@ -403,10 +405,10 @@
}
if
(
theType
==
"ISTex"
)
{
console
.
log
(
window
.
location
.
origin
+
"
scrape
rs/istex/query"
)
console
.
log
(
window
.
location
.
origin
+
"
moissonneu
rs/istex/query"
)
$
.
ajax
({
// contentType: "application/json",
url
:
window
.
location
.
origin
+
"/
scrape
rs/istex/query"
,
url
:
window
.
location
.
origin
+
"/
moissonneu
rs/istex/query"
,
data
:
formData
,
type
:
'POST'
,
beforeSend
:
function
(
xhr
)
{
...
...
@@ -537,7 +539,7 @@
$
.
ajax
({
// contentType: "application/json",
url
:
window
.
location
.
origin
+
"/
scrape
rs/istex/save/"
+
projectid
,
url
:
window
.
location
.
origin
+
"/
moissonneu
rs/istex/save/"
+
projectid
,
data
:
postQuery
,
type
:
'POST'
,
beforeSend
:
function
(
xhr
)
{
...
...
This diff is collapsed.
Click to expand it.
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