Commit 9f252d49 authored by delanoe's avatar delanoe

[RENAME] journal -> source in hyperdata.

parent 12a3283b
......@@ -165,7 +165,7 @@ class NodeListResource(APIView):
writer = csv.writer(response, delimiter='\t', quoting=csv.QUOTE_MINIMAL)
keys = [ 'title' , 'journal'
keys = [ 'title' , 'source'
, 'publication_year', 'publication_month', 'publication_day'
, 'abstract', 'authors']
......@@ -280,7 +280,7 @@ class NodeListHaving(APIView):
'id': node.id,
'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:
node_dict[key] = node.hyperdata[key]
nodes_list.append(node_dict)
......@@ -558,12 +558,12 @@ class CorpusFavorites(APIView):
class CorpusFacet(APIView):
"""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 view: tests.ngramstable.views.get_journals_json()
# - old url: '^project/(\d+)/corpus/(\d+)/source/sources.json$',
# - old view: tests.ngramstable.views.get_sourcess_json()
# - now generalized for various hyperdata field:
# -> journal
# -> source
# -> publication_year
# -> rubrique
# -> language...
......@@ -587,7 +587,7 @@ class CorpusFacet(APIView):
# check that the hyperfield parameter makes sense
_facet_available_subfields = [
'journal', 'publication_year', 'rubrique',
'source', 'publication_year', 'rubrique',
'language_iso2', 'language_iso3', 'language_name',
'authors'
]
......@@ -609,8 +609,8 @@ class CorpusFacet(APIView):
'by': { subfield: xcounts }
})
def _ndocs_by_facet(self, subfield='journal'):
"""for example on 'journal'
def _ndocs_by_facet(self, subfield='source'):
"""for example on 'source'
xcounts = {'j good sci' : 25, 'nature' : 32, 'j bla bla' : 1... }"""
xcounts = defaultdict(int)
......
......@@ -20,7 +20,7 @@ urlpatterns = [ url(r'^nodes$' , nodes.NodeListResource.as_view()
#?view=docs
#Corpora
, url(r'^projects/(\d+)/corpora/(\d+)$' , corpora.CorpusView.as_view() )
#?view=journal
#?view=source
#?view=title
#?view=analytics
#Sources
......
......@@ -46,11 +46,11 @@ def docs_by_titles(request, project_id, corpus_id):
)
@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
NB: javascript in page will GET counts from our api: facets?subfield=journal
# TODO refactor Journals_dyna_charts_and_table.js
Browse source titles for a given corpus
NB: javascript in page will GET counts from our api: facets?subfield=source
# TODO refactor Sources_dyna_charts_and_table.js
'''
# we pass our corpus to mark it's a corpora page
corpus = cache.Node[corpus_id]
......@@ -60,9 +60,9 @@ def docs_by_journals(request, project_id, corpus_id):
source_type = corpus.resources()[0]['type']
# rendered page : journals.html
# rendered page : sources.html
return render(
template_name = 'pages/corpora/journals.html',
template_name = 'pages/corpora/sources.html',
request = request,
context = {
'debug': settings.DEBUG,
......@@ -70,7 +70,7 @@ def docs_by_journals(request, project_id, corpus_id):
'project': project,
'corpus' : corpus,
'resourcename' : get_resource(source_type)['name'],
'view': 'journals'
'view': 'sources'
},
)
......@@ -79,7 +79,7 @@ def docs_by_authors(request, project_id, corpus_id):
'''
Browse authors for a given corpus
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
corpus = cache.Node[corpus_id]
......@@ -89,7 +89,7 @@ def docs_by_authors(request, project_id, corpus_id):
source_type = corpus.resources()[0]['type']
# rendered page : journals.html
# rendered page : sources.html
return render(
template_name = 'pages/corpora/authors.html',
request = request,
......
......@@ -24,10 +24,10 @@ urlpatterns = [
# corpora
url(r'^projects/(\d+)/corpora/(\d+)/?$', corpora.docs_by_titles),
# corpus by journals
url(r'^projects/(\d+)/corpora/(\d+)/journals/?$', corpora.docs_by_journals),
# corpus by sources
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),
# terms table for the corpus
......
......@@ -143,7 +143,7 @@ var RecDict={};
var AjaxRecords = []
var Garbage = {}
var countByTitles = {} // useful for title duplicates
var countByMeta = {} // for title + date + journal duplicates
var countByMeta = {} // for title + date + source duplicates
var favorites = {}
function getRecord(rec_id) {
......@@ -197,7 +197,7 @@ function transformContent2(rec_id, trClass) {
if (elem["del"]) {
result["id"] = elem["id"]
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["isFavorite"] = favstatusToStar(rec_id, elem["isFavorite"], boolStrike=true)
result["rawtitle"] = elem["rawtitle"]
......@@ -211,7 +211,7 @@ function transformContent2(rec_id, trClass) {
} else {
result["id"] = elem["id"]
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["isFavorite"] = favstatusToStar(rec_id, elem["isFavorite"])
result["rawtitle"] = elem["rawtitle"]
......@@ -350,7 +350,7 @@ function metaSignature(docRecord) {
var keyStr = ""
keyStr = (docRecord.rawtitle
+"--"+
docRecord.hyperdata.journal
docRecord.hyperdata.source
+"--"+
docRecord.hyperdata.publication_date
)
......@@ -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"+'<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 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"+'<th data-dynatable-column="isFavorite">'+"\n"
div_table += "\t"+"\t"+'<span class="glyphicon glyphicon-star"></span>'+"\n"
......@@ -553,7 +553,7 @@ function Main_test(Data) {
sortTypes: {
signature: 'signatureSort',
docurl: 'rawtitleSort',
'hyperdata.journal': 'journalSort'
'hyperdata.source': 'sourceSort'
}
},
features: {
......@@ -628,10 +628,10 @@ function Main_test(Data) {
MyTable.data('dynatable').sorts.functions["rawtitleSort"] = makeAlphaSortFunctionOnProperty('rawtitle')
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
if (direction == 1) return rec1.hyperdata.journal.localeCompare(rec2.hyperdata.journal)
else return rec2.hyperdata.journal.localeCompare(rec1.hyperdata.journal)
if (direction == 1) return rec1.hyperdata.source.localeCompare(rec2.hyperdata.source)
else return rec2.hyperdata.source.localeCompare(rec1.hyperdata.source)
}
// hook on page change
......
......@@ -397,7 +397,7 @@ function Main_test( data , initial) {
.title(function (d) {
var value = d.data.value.avg ? d.data.value.avg : d.data.value;
if (isNaN(value)) value = 0;
return value+" journals with "+Number(d.key)+" publications";
return value+" sources with "+Number(d.key)+" publications";
})
.xAxis();
LineChart.yAxis().ticks(5)
......@@ -494,21 +494,21 @@ console.log(window.location.href)
// match corpus_id in the url
var corpus_id ;
rematch = window.location.href.match(/corpora\/(\d+)\/journals\/?$/)
rematch = window.location.href.match(/corpora\/(\d+)\/sources\/?$/)
if (rematch) {
corpus_id = rematch[1] ;
$.ajax({
url: window.location.origin
+ "/api/nodes/"
+ corpus_id
+ "/facets?hyperfield=journal",
+ "/facets?hyperfield=source",
success: function(data){
console.log(data)
$("#content_loader").remove()
// // Initializing the Charts and Table
var result = Main_test( data.by.journal , "FirstScore" )
var result = Main_test( data.by.source , "FirstScore" )
console.log( result )
$("#content_loader").remove()
......
......@@ -524,9 +524,9 @@ function genericGetTopPapers(theids , corpus_id , thediv) {
var gquery = "https://search.iscpif.fr/?categories=general&q="+pub["title"].replace(" "+"+")
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"]) {
ifauthors = "By "+pub["authors"]+"";
if(pub["authors"] == "not found") {
......@@ -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'
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 +="</li>\n";
// for(var j in pub) {
......@@ -624,9 +624,9 @@ function getTopPapers(type){
// 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 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"]) {
ifauthors = "By "+pub["authors"]+"";
if(pub["authors"] == "not found") {
......@@ -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'
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 +="</li>\n";
// for(var j in pub) {
......
......@@ -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" href="javascript:volumeChart.filterAll();dc.redrawAll();">Reset</a></p>
<!-- <p style="font-size:70%">
<b>x</b>: amount of documents for the journal
<b>y</b>: number of journals with that amount
<b>x</b>: amount of documents for the source
<b>y</b>: number of sources with that amount
</p> -->
<div class="clearfix"></div>
</center>
......@@ -70,7 +70,7 @@
<div class="panel-body">
<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>
......@@ -86,6 +86,6 @@
<script type="text/javascript" src="{% static "lib/jquery/dynatable/jquery.dynatable.js" %}"></script>
<!-- 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 %}
......@@ -117,11 +117,11 @@
</li>
<li>
<a type="button" class="btn btn-default {% if view == 'journals' %} active {% endif %}"
onclick="javascript:location.href='/projects/{{project.id}}/corpora/{{ corpus.id }}/journals'"
<a type="button" class="btn btn-default {% if view == 'sources' %} active {% endif %}"
onclick="javascript:location.href='/projects/{{project.id}}/corpora/{{ corpus.id }}/sources'"
data-target='#' href='#'>
<span class="glyphicon glyphicon-globe" aria-hidden="true"></span>
Journals
Sources
</a>
</li>
......@@ -245,7 +245,7 @@
{% else %}
<!-- TODO export journal table -->
<!-- TODO export source table -->
{% endif %}
</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