Commit 4bccaa96 authored by delanoe's avatar delanoe

[RENAME] journal -> source in hyperdata.

parent d71e54a4
...@@ -165,7 +165,7 @@ class NodeListResource(APIView): ...@@ -165,7 +165,7 @@ class NodeListResource(APIView):
writer = csv.writer(response, delimiter='\t', quoting=csv.QUOTE_MINIMAL) writer = csv.writer(response, delimiter='\t', quoting=csv.QUOTE_MINIMAL)
keys = [ 'title' , 'journal' keys = [ 'title' , 'source'
, 'publication_year', 'publication_month', 'publication_day' , 'publication_year', 'publication_month', 'publication_day'
, 'abstract', 'authors'] , 'abstract', 'authors']
...@@ -280,7 +280,7 @@ class NodeListHaving(APIView): ...@@ -280,7 +280,7 @@ class NodeListHaving(APIView):
'id': node.id, 'id': node.id,
'score': score, 'score': score,
} }
for key in ('title', 'publication_date', 'journal', 'authors', 'fields'): for key in ('title', 'publication_date', 'source', 'authors', 'fields'):
if key in node.hyperdata: if key in node.hyperdata:
node_dict[key] = node.hyperdata[key] node_dict[key] = node.hyperdata[key]
nodes_list.append(node_dict) nodes_list.append(node_dict)
...@@ -558,12 +558,12 @@ class CorpusFavorites(APIView): ...@@ -558,12 +558,12 @@ class CorpusFavorites(APIView):
class CorpusFacet(APIView): class CorpusFacet(APIView):
"""Loop through a corpus node's docs => do counts by a hyperdata field """Loop through a corpus node's docs => do counts by a hyperdata field
(url: /api/nodes/<node_id>/facets?hyperfield=<journal>) (url: /api/nodes/<node_id>/facets?hyperfield=<source>)
""" """
# - old url: '^project/(\d+)/corpus/(\d+)/journals/journals.json$', # - old url: '^project/(\d+)/corpus/(\d+)/source/sources.json$',
# - old view: tests.ngramstable.views.get_journals_json() # - old view: tests.ngramstable.views.get_sourcess_json()
# - now generalized for various hyperdata field: # - now generalized for various hyperdata field:
# -> journal # -> source
# -> publication_year # -> publication_year
# -> rubrique # -> rubrique
# -> language... # -> language...
...@@ -587,7 +587,7 @@ class CorpusFacet(APIView): ...@@ -587,7 +587,7 @@ class CorpusFacet(APIView):
# check that the hyperfield parameter makes sense # check that the hyperfield parameter makes sense
_facet_available_subfields = [ _facet_available_subfields = [
'journal', 'publication_year', 'rubrique', 'source', 'publication_year', 'rubrique',
'language_iso2', 'language_iso3', 'language_name', 'language_iso2', 'language_iso3', 'language_name',
'authors' 'authors'
] ]
...@@ -609,8 +609,8 @@ class CorpusFacet(APIView): ...@@ -609,8 +609,8 @@ class CorpusFacet(APIView):
'by': { subfield: xcounts } 'by': { subfield: xcounts }
}) })
def _ndocs_by_facet(self, subfield='journal'): def _ndocs_by_facet(self, subfield='source'):
"""for example on 'journal' """for example on 'source'
xcounts = {'j good sci' : 25, 'nature' : 32, 'j bla bla' : 1... }""" xcounts = {'j good sci' : 25, 'nature' : 32, 'j bla bla' : 1... }"""
xcounts = defaultdict(int) xcounts = defaultdict(int)
......
...@@ -20,7 +20,7 @@ urlpatterns = [ url(r'^nodes$' , nodes.NodeListResource.as_view() ...@@ -20,7 +20,7 @@ urlpatterns = [ url(r'^nodes$' , nodes.NodeListResource.as_view()
#?view=docs #?view=docs
#Corpora #Corpora
, url(r'^projects/(\d+)/corpora/(\d+)$' , corpora.CorpusView.as_view() ) , url(r'^projects/(\d+)/corpora/(\d+)$' , corpora.CorpusView.as_view() )
#?view=journal #?view=source
#?view=title #?view=title
#?view=analytics #?view=analytics
#Sources #Sources
......
...@@ -46,11 +46,11 @@ def docs_by_titles(request, project_id, corpus_id): ...@@ -46,11 +46,11 @@ def docs_by_titles(request, project_id, corpus_id):
) )
@requires_auth @requires_auth
def docs_by_journals(request, project_id, corpus_id): def docs_by_sources(request, project_id, corpus_id):
''' '''
Browse journal titles for a given corpus Browse source titles for a given corpus
NB: javascript in page will GET counts from our api: facets?subfield=journal NB: javascript in page will GET counts from our api: facets?subfield=source
# TODO refactor Journals_dyna_charts_and_table.js # TODO refactor Sources_dyna_charts_and_table.js
''' '''
# we pass our corpus to mark it's a corpora page # we pass our corpus to mark it's a corpora page
corpus = cache.Node[corpus_id] corpus = cache.Node[corpus_id]
...@@ -60,9 +60,9 @@ def docs_by_journals(request, project_id, corpus_id): ...@@ -60,9 +60,9 @@ def docs_by_journals(request, project_id, corpus_id):
source_type = corpus.resources()[0]['type'] source_type = corpus.resources()[0]['type']
# rendered page : journals.html # rendered page : sources.html
return render( return render(
template_name = 'pages/corpora/journals.html', template_name = 'pages/corpora/sources.html',
request = request, request = request,
context = { context = {
'debug': settings.DEBUG, 'debug': settings.DEBUG,
...@@ -70,7 +70,7 @@ def docs_by_journals(request, project_id, corpus_id): ...@@ -70,7 +70,7 @@ def docs_by_journals(request, project_id, corpus_id):
'project': project, 'project': project,
'corpus' : corpus, 'corpus' : corpus,
'resourcename' : get_resource(source_type)['name'], 'resourcename' : get_resource(source_type)['name'],
'view': 'journals' 'view': 'sources'
}, },
) )
...@@ -79,7 +79,7 @@ def docs_by_authors(request, project_id, corpus_id): ...@@ -79,7 +79,7 @@ def docs_by_authors(request, project_id, corpus_id):
''' '''
Browse authors for a given corpus Browse authors for a given corpus
NB: javascript in page will GET counts from our api: facets?subfield=author NB: javascript in page will GET counts from our api: facets?subfield=author
# TODO refactor Author && Journals_dyna_charts_and_table.js # TODO refactor Author && Sources_dyna_charts_and_table.js
''' '''
# we pass our corpus to mark it's a corpora page # we pass our corpus to mark it's a corpora page
corpus = cache.Node[corpus_id] corpus = cache.Node[corpus_id]
...@@ -89,7 +89,7 @@ def docs_by_authors(request, project_id, corpus_id): ...@@ -89,7 +89,7 @@ def docs_by_authors(request, project_id, corpus_id):
source_type = corpus.resources()[0]['type'] source_type = corpus.resources()[0]['type']
# rendered page : journals.html # rendered page : sources.html
return render( return render(
template_name = 'pages/corpora/authors.html', template_name = 'pages/corpora/authors.html',
request = request, request = request,
......
...@@ -24,10 +24,10 @@ urlpatterns = [ ...@@ -24,10 +24,10 @@ urlpatterns = [
# corpora # corpora
url(r'^projects/(\d+)/corpora/(\d+)/?$', corpora.docs_by_titles), url(r'^projects/(\d+)/corpora/(\d+)/?$', corpora.docs_by_titles),
# corpus by journals # corpus by sources
url(r'^projects/(\d+)/corpora/(\d+)/journals/?$', corpora.docs_by_journals), url(r'^projects/(\d+)/corpora/(\d+)/sources/?$', corpora.docs_by_sources),
# corpus by journals # corpus by authors
url(r'^projects/(\d+)/corpora/(\d+)/authors/?$', corpora.docs_by_authors), url(r'^projects/(\d+)/corpora/(\d+)/authors/?$', corpora.docs_by_authors),
# terms table for the corpus # terms table for the corpus
......
...@@ -143,7 +143,7 @@ var RecDict={}; ...@@ -143,7 +143,7 @@ var RecDict={};
var AjaxRecords = [] var AjaxRecords = []
var Garbage = {} var Garbage = {}
var countByTitles = {} // useful for title duplicates var countByTitles = {} // useful for title duplicates
var countByMeta = {} // for title + date + journal duplicates var countByMeta = {} // for title + date + source duplicates
var favorites = {} var favorites = {}
function getRecord(rec_id) { function getRecord(rec_id) {
...@@ -197,7 +197,7 @@ function transformContent2(rec_id, trClass) { ...@@ -197,7 +197,7 @@ function transformContent2(rec_id, trClass) {
if (elem["del"]) { if (elem["del"]) {
result["id"] = elem["id"] result["id"] = elem["id"]
result["short_date"] = '<strike>'+elem["short_date"]+'</strike>' result["short_date"] = '<strike>'+elem["short_date"]+'</strike>'
result["hyperdata.journal"] = '<strike><small><i>'+elem["hyperdata"]["journal"]+'</small></i></strike>' result["hyperdata.source"] = '<strike><small><i>'+elem["hyperdata"]["source"]+'</small></i></strike>'
result["docurl"] = '<strike>'+elem["docurl"]+'</strike>' result["docurl"] = '<strike>'+elem["docurl"]+'</strike>'
result["isFavorite"] = favstatusToStar(rec_id, elem["isFavorite"], boolStrike=true) result["isFavorite"] = favstatusToStar(rec_id, elem["isFavorite"], boolStrike=true)
result["rawtitle"] = elem["rawtitle"] result["rawtitle"] = elem["rawtitle"]
...@@ -211,7 +211,7 @@ function transformContent2(rec_id, trClass) { ...@@ -211,7 +211,7 @@ function transformContent2(rec_id, trClass) {
} else { } else {
result["id"] = elem["id"] result["id"] = elem["id"]
result["short_date"] = elem["short_date"] result["short_date"] = elem["short_date"]
result["hyperdata.journal"] = '<small><i>'+elem["hyperdata"]["journal"]+'</i></small>' result["hyperdata.source"] = '<small><i>'+elem["hyperdata"]["source"]+'</i></small>'
result["docurl"] = elem["docurl"] result["docurl"] = elem["docurl"]
result["isFavorite"] = favstatusToStar(rec_id, elem["isFavorite"]) result["isFavorite"] = favstatusToStar(rec_id, elem["isFavorite"])
result["rawtitle"] = elem["rawtitle"] result["rawtitle"] = elem["rawtitle"]
...@@ -350,7 +350,7 @@ function metaSignature(docRecord) { ...@@ -350,7 +350,7 @@ function metaSignature(docRecord) {
var keyStr = "" var keyStr = ""
keyStr = (docRecord.rawtitle keyStr = (docRecord.rawtitle
+"--"+ +"--"+
docRecord.hyperdata.journal docRecord.hyperdata.source
+"--"+ +"--"+
docRecord.hyperdata.publication_date docRecord.hyperdata.publication_date
) )
...@@ -376,7 +376,7 @@ function Main_test(Data) { ...@@ -376,7 +376,7 @@ function Main_test(Data) {
div_table += "\t"+"\t"+'<span class="glyphicon glyphicon-calendar"></span> Date</th>'+"\n" 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"+'<th data-dynatable-column="docurl">'+"\n"
div_table += "\t"+"\t"+'<span class="glyphicon glyphicon-text-size"></span> Title</th>'+"\n" div_table += "\t"+"\t"+'<span class="glyphicon glyphicon-text-size"></span> Title</th>'+"\n"
div_table += "\t"+"\t"+'<th width="100px;" data-dynatable-column="hyperdata.journal">'+"\n" div_table += "\t"+"\t"+'<th width="100px;" data-dynatable-column="hyperdata.source">'+"\n"
div_table += "\t"+"\t"+'<span class="glyphicon glyphicon-book"></span> Source</th>'+"\n" div_table += "\t"+"\t"+'<span class="glyphicon glyphicon-book"></span> Source</th>'+"\n"
div_table += "\t"+"\t"+'<th data-dynatable-column="isFavorite">'+"\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"+'<span class="glyphicon glyphicon-star"></span>'+"\n"
...@@ -553,7 +553,7 @@ function Main_test(Data) { ...@@ -553,7 +553,7 @@ function Main_test(Data) {
sortTypes: { sortTypes: {
signature: 'signatureSort', signature: 'signatureSort',
docurl: 'rawtitleSort', docurl: 'rawtitleSort',
'hyperdata.journal': 'journalSort' 'hyperdata.source': 'sourceSort'
} }
}, },
features: { features: {
...@@ -628,10 +628,10 @@ function Main_test(Data) { ...@@ -628,10 +628,10 @@ function Main_test(Data) {
MyTable.data('dynatable').sorts.functions["rawtitleSort"] = makeAlphaSortFunctionOnProperty('rawtitle') MyTable.data('dynatable').sorts.functions["rawtitleSort"] = makeAlphaSortFunctionOnProperty('rawtitle')
MyTable.data('dynatable').sorts.functions["signatureSort"] = makeAlphaSortFunctionOnProperty('signature') MyTable.data('dynatable').sorts.functions["signatureSort"] = makeAlphaSortFunctionOnProperty('signature')
MyTable.data('dynatable').sorts.functions["journalSort"] = function journalSort (rec1,rec2, attr, direction) { MyTable.data('dynatable').sorts.functions["sourceSort"] = function sourceSort (rec1,rec2, attr, direction) {
// like rawtitle but nested property // like rawtitle but nested property
if (direction == 1) return rec1.hyperdata.journal.localeCompare(rec2.hyperdata.journal) if (direction == 1) return rec1.hyperdata.source.localeCompare(rec2.hyperdata.source)
else return rec2.hyperdata.journal.localeCompare(rec1.hyperdata.journal) else return rec2.hyperdata.source.localeCompare(rec1.hyperdata.source)
} }
// hook on page change // hook on page change
......
...@@ -397,7 +397,7 @@ function Main_test( data , initial) { ...@@ -397,7 +397,7 @@ function Main_test( data , initial) {
.title(function (d) { .title(function (d) {
var value = d.data.value.avg ? d.data.value.avg : d.data.value; var value = d.data.value.avg ? d.data.value.avg : d.data.value;
if (isNaN(value)) value = 0; if (isNaN(value)) value = 0;
return value+" journals with "+Number(d.key)+" publications"; return value+" sources with "+Number(d.key)+" publications";
}) })
.xAxis(); .xAxis();
LineChart.yAxis().ticks(5) LineChart.yAxis().ticks(5)
...@@ -494,21 +494,21 @@ console.log(window.location.href) ...@@ -494,21 +494,21 @@ console.log(window.location.href)
// match corpus_id in the url // match corpus_id in the url
var corpus_id ; var corpus_id ;
rematch = window.location.href.match(/corpora\/(\d+)\/journals\/?$/) rematch = window.location.href.match(/corpora\/(\d+)\/sources\/?$/)
if (rematch) { if (rematch) {
corpus_id = rematch[1] ; corpus_id = rematch[1] ;
$.ajax({ $.ajax({
url: window.location.origin url: window.location.origin
+ "/api/nodes/" + "/api/nodes/"
+ corpus_id + corpus_id
+ "/facets?hyperfield=journal", + "/facets?hyperfield=source",
success: function(data){ success: function(data){
console.log(data) console.log(data)
$("#content_loader").remove() $("#content_loader").remove()
// // Initializing the Charts and Table // // Initializing the Charts and Table
var result = Main_test( data.by.journal , "FirstScore" ) var result = Main_test( data.by.source , "FirstScore" )
console.log( result ) console.log( result )
$("#content_loader").remove() $("#content_loader").remove()
......
...@@ -524,9 +524,9 @@ function genericGetTopPapers(theids , corpus_id , thediv) { ...@@ -524,9 +524,9 @@ function genericGetTopPapers(theids , corpus_id , thediv) {
var gquery = "https://search.iscpif.fr/?categories=general&q="+pub["title"].replace(" "+"+") var gquery = "https://search.iscpif.fr/?categories=general&q="+pub["title"].replace(" "+"+")
var getpubAPI = window.location.origin+"/nodeinfo/"+pub["id"] var getpubAPI = window.location.origin+"/nodeinfo/"+pub["id"]
var ifjournal="",ifauthors="",ifkeywords="",ifdate="",iftitle=""; var ifsource="",ifauthors="",ifkeywords="",ifdate="",iftitle="";
if(pub["journal"]) ifjournal = "<br>Published in <a>"+pub["journal"]+"</a>"; if(pub["source"]) ifsource = "<br>Published in <a>"+pub["source"]+"</a>";
if(pub["authors"]) { if(pub["authors"]) {
ifauthors = "By "+pub["authors"]+""; ifauthors = "By "+pub["authors"]+"";
if(pub["authors"] == "not found") { if(pub["authors"] == "not found") {
...@@ -542,7 +542,7 @@ function genericGetTopPapers(theids , corpus_id , thediv) { ...@@ -542,7 +542,7 @@ function genericGetTopPapers(theids , corpus_id , thediv) {
var jsparams = 'height=700,width=800,left=10,top=10,resizable=yes,scrollbars=yes,toolbar=no,menubar=no,location=no,directories=no,status=no' var jsparams = 'height=700,width=800,left=10,top=10,resizable=yes,scrollbars=yes,toolbar=no,menubar=no,location=no,directories=no,status=no'
jsstuff += "wnws_buffer = window.open('"+getpubAPI+"', 'popUpWindow' , '"+jsparams+"')"; jsstuff += "wnws_buffer = window.open('"+getpubAPI+"', 'popUpWindow' , '"+jsparams+"')";
output += "<li><a onclick=\""+jsstuff+"\" target=_blank>"+pub["title"]+"</a>. "+ifauthors+". "+ifjournal+". "+ifkeywords+". "+ifdate+"\n"; output += "<li><a onclick=\""+jsstuff+"\" target=_blank>"+pub["title"]+"</a>. "+ifauthors+". "+ifsource+". "+ifkeywords+". "+ifdate+"\n";
output += '<a href="'+gquery+'" target=_blank><img title="Query the anonymous web" src="'+window.location.origin+'/static/img/searx.png"></img></a>' output += '<a href="'+gquery+'" target=_blank><img title="Query the anonymous web" src="'+window.location.origin+'/static/img/searx.png"></img></a>'
output +="</li>\n"; output +="</li>\n";
// for(var j in pub) { // for(var j in pub) {
...@@ -624,9 +624,9 @@ function getTopPapers(type){ ...@@ -624,9 +624,9 @@ function getTopPapers(type){
// link to matching document (with focus=selections_ids param) // link to matching document (with focus=selections_ids param)
var getpubAPI = window.location.origin+'/projects/'+url_mainIDs["projects"]+'/corpora/'+ url_mainIDs["corpora"] + '/documents/'+pub["id"]+'/focus='+theids.join(",") var getpubAPI = window.location.origin+'/projects/'+url_mainIDs["projects"]+'/corpora/'+ url_mainIDs["corpora"] + '/documents/'+pub["id"]+'/focus='+theids.join(",")
var ifjournal="",ifauthors="",ifkeywords="",ifdate="",iftitle=""; var ifsource="",ifauthors="",ifkeywords="",ifdate="",iftitle="";
if(pub["journal"]) ifjournal = "<br>Published in <a>"+pub["journal"]+"</a>"; if(pub["source"]) ifsource = "<br>Published in <a>"+pub["source"]+"</a>";
if(pub["authors"]) { if(pub["authors"]) {
ifauthors = "By "+pub["authors"]+""; ifauthors = "By "+pub["authors"]+"";
if(pub["authors"] == "not found") { if(pub["authors"] == "not found") {
...@@ -642,7 +642,7 @@ function getTopPapers(type){ ...@@ -642,7 +642,7 @@ function getTopPapers(type){
var jsparams = 'height=700,width=800,left=10,top=10,resizable=yes,scrollbars=yes,toolbar=no,menubar=no,location=no,directories=no,status=no' var jsparams = 'height=700,width=800,left=10,top=10,resizable=yes,scrollbars=yes,toolbar=no,menubar=no,location=no,directories=no,status=no'
jsstuff += "wnws_buffer = window.open('"+getpubAPI+"', 'popUpWindow' , '"+jsparams+"')"; jsstuff += "wnws_buffer = window.open('"+getpubAPI+"', 'popUpWindow' , '"+jsparams+"')";
output += "<li><a onclick=\""+jsstuff+"\" target=_blank>"+pub["title"]+"</a>. "+ifauthors+". "+ifjournal+". "+ifkeywords+". "+ifdate+"\n"; output += "<li><a onclick=\""+jsstuff+"\" target=_blank>"+pub["title"]+"</a>. "+ifauthors+". "+ifsource+". "+ifkeywords+". "+ifdate+"\n";
output += '<a href="'+gquery+'" target=_blank><img title="Query the web" src="'+window.location.origin+'/static/img/searx.png"></img></a>' output += '<a href="'+gquery+'" target=_blank><img title="Query the web" src="'+window.location.origin+'/static/img/searx.png"></img></a>'
output +="</li>\n"; output +="</li>\n";
// for(var j in pub) { // for(var j in pub) {
......
...@@ -28,8 +28,8 @@ ...@@ -28,8 +28,8 @@
<!--<a class="btn btn-xs btn-default" role="button" href="/chart/corpus/{{ corpus.id }}/data.csv">Save</a>--> <!--<a class="btn btn-xs btn-default" role="button" href="/chart/corpus/{{ corpus.id }}/data.csv">Save</a>-->
<a class="btn btn-xs btn-default" href="javascript:volumeChart.filterAll();dc.redrawAll();">Reset</a></p> <a class="btn btn-xs btn-default" href="javascript:volumeChart.filterAll();dc.redrawAll();">Reset</a></p>
<!-- <p style="font-size:70%"> <!-- <p style="font-size:70%">
<b>x</b>: amount of documents for the journal <b>x</b>: amount of documents for the source
<b>y</b>: number of journals with that amount <b>y</b>: number of sources with that amount
</p> --> </p> -->
<div class="clearfix"></div> <div class="clearfix"></div>
</center> </center>
...@@ -70,7 +70,7 @@ ...@@ -70,7 +70,7 @@
<div class="panel-body"> <div class="panel-body">
<div id="div-table"> <div id="div-table">
<!-- (table id="my-ajax-table") dynamically set by Journals_dyna_chart_and_table --> <!-- (table id="my-ajax-table") dynamically set by Sources_dyna_chart_and_table -->
</div> </div>
</div> </div>
...@@ -86,6 +86,6 @@ ...@@ -86,6 +86,6 @@
<script type="text/javascript" src="{% static "lib/jquery/dynatable/jquery.dynatable.js" %}"></script> <script type="text/javascript" src="{% static "lib/jquery/dynatable/jquery.dynatable.js" %}"></script>
<!-- custom-lib for dynatable.js and dc.js --> <!-- custom-lib for dynatable.js and dc.js -->
<script type="text/javascript" src="{% static "lib/gargantext/Journals_dyna_chart_and_table.js" %}"></script> <script type="text/javascript" src="{% static "lib/gargantext/Sources_dyna_chart_and_table.js" %}"></script>
{% endblock %} {% endblock %}
...@@ -117,11 +117,11 @@ ...@@ -117,11 +117,11 @@
</li> </li>
<li> <li>
<a type="button" class="btn btn-default {% if view == 'journals' %} active {% endif %}" <a type="button" class="btn btn-default {% if view == 'sources' %} active {% endif %}"
onclick="javascript:location.href='/projects/{{project.id}}/corpora/{{ corpus.id }}/journals'" onclick="javascript:location.href='/projects/{{project.id}}/corpora/{{ corpus.id }}/sources'"
data-target='#' href='#'> data-target='#' href='#'>
<span class="glyphicon glyphicon-globe" aria-hidden="true"></span> <span class="glyphicon glyphicon-globe" aria-hidden="true"></span>
Journals Sources
</a> </a>
</li> </li>
...@@ -245,7 +245,7 @@ ...@@ -245,7 +245,7 @@
{% else %} {% else %}
<!-- TODO export journal table --> <!-- TODO export source table -->
{% endif %} {% endif %}
</div> </div>
</div> </div>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment