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
b8e3f83b
Commit
b8e3f83b
authored
Jan 13, 2015
by
Administrator
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'samuel' into unstable
parents
024b2ca5
6cd09846
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
119 additions
and
18 deletions
+119
-18
api.py
gargantext_web/api.py
+13
-0
urls.py
gargantext_web/urls.py
+1
-1
views.py
gargantext_web/views.py
+2
-1
models.py
node/models.py
+25
-0
EuropressFileParser.py
parsing/FileParsers/EuropressFileParser.py
+13
-11
delete-big.png
static/img/delete-big.png
+0
-0
corpus.html
templates/corpus.html
+17
-0
subcorpus.html
templates/subcorpus.html
+48
-5
No files found.
gargantext_web/api.py
View file @
b8e3f83b
...
...
@@ -620,7 +620,20 @@ class Nodes(APIView):
'metadata'
:
dict
(
node
.
metadata
),
})
# deleting node by id
def
delete
(
self
,
request
,
node_id
):
session
=
get_session
()
node
=
models
.
Node
.
objects
.
filter
(
id
=
node_id
)
msgres
=
""
try
:
node
.
delete
()
msgres
=
node_id
+
" deleted!"
except
:
msgres
=
"error deleting: "
+
node_id
return
JsonHttpResponse
({
'deleted'
:
msgres
,
})
class
CorpusController
:
...
...
gargantext_web/urls.py
View file @
b8e3f83b
...
...
@@ -54,7 +54,7 @@ urlpatterns = patterns('',
url
(
r'^api/nodes/(\d+)/children/duplicates$'
,
gargantext_web
.
api
.
NodesChildrenDuplicates
.
as_view
()),
url
(
r'^api/nodes/(\d+)$'
,
gargantext_web
.
api
.
Nodes
.
as_view
()),
url
(
r'^api/nodes$'
,
gargantext_web
.
api
.
NodesList
.
as_view
()),
url
(
r'^api/project/(\d+)/corpus/(\d+)/timerange/(\d+)/(\d+)$'
,
views
.
subcorpusJSON
),
url
(
r'^api/nodes/(\d+)/ngrams$'
,
gargantext_web
.
api
.
CorpusController
.
ngrams
),
...
...
gargantext_web/views.py
View file @
b8e3f83b
...
...
@@ -218,7 +218,6 @@ def project(request, project_id):
#form = CorpusForm(request.POST, request.FILES)
#print(str(request.POST))
name
=
str
(
request
.
POST
[
'name'
])
try
:
resource_type
=
ResourceType
.
objects
.
get
(
id
=
str
(
request
.
POST
[
'type'
]))
except
Exception
as
error
:
...
...
@@ -258,6 +257,8 @@ def project(request, project_id):
)
corpus
.
save
()
print
(
request
.
user
,
resource_type
,
file
)
print
(
corpus
.
language
)
corpus
.
add_resource
(
user
=
request
.
user
,
...
...
node/models.py
View file @
b8e3f83b
...
...
@@ -129,11 +129,34 @@ class Node(CTENode):
return
Resource
.
objects
.
select_related
(
'node_resource'
)
.
filter
(
node_resource__node
=
self
)
def
add_resource
(
self
,
**
kwargs
):
print
(
"printing arguments for add_resource():"
)
print
(
kwargs
)
from
django.core.files.storage
import
default_storage
from
django.core.files.base
import
ContentFile
import
os
thefile
=
kwargs
[
"file"
]
path
=
default_storage
.
save
(
'tmp/somename.zip'
,
ContentFile
(
thefile
.
read
()))
tmp_file
=
os
.
path
.
join
(
MEDIA_ROOT
,
path
)
print
(
tmp_file
)
kwargs
[
"file"
]
=
tmp_file
print
(
"final kwargs:"
)
print
(
kwargs
)
# only for tests
resource
=
Resource
(
guid
=
str
(
time
()),
digest
=
str
(
time
()),
**
kwargs
)
#resource = Resource(**kwargs)
resource
.
save
()
print
(
"printing rresource.file:"
)
print
(
resource
.
file
)
# print("printing the resource 01____:")
# print(resource.file)
# print("printing the resource 02____: asdasdasd")
# User
if
'user'
not
in
kwargs
and
'user_id'
not
in
kwargs
:
resource
.
user
=
self
.
user
...
...
@@ -170,6 +193,8 @@ class Node(CTENode):
'europress_french'
:
EuropressFileParser
,
'europress_english'
:
EuropressFileParser
,
})[
resource
.
type
.
name
]()
print
(
"parse_resources:"
)
print
(
resource
.
file
)
metadata_list
+=
parser
.
parse
(
str
(
resource
.
file
))
# retrieve info from the database
type_id
=
NodeType
.
objects
.
get
(
name
=
'Document'
)
.
id
...
...
parsing/FileParsers/EuropressFileParser.py
View file @
b8e3f83b
...
...
@@ -70,18 +70,20 @@ class EuropressFileParser(FileParser):
if
isinstance
(
text
,
bytes
):
text
=
text
.
decode
(
encoding
)
format_date_fr
=
re
.
compile
(
'
\
d*
\
s*
\
w+
\
s+
\
d{4}'
,
re
.
UNICODE
)
test_date_fr
=
format_date_fr
.
match
(
text
)
format_date_en
=
re
.
compile
(
'
\
w+
\
s+
\
d+,
\
s+
\
d{4}'
,
re
.
UNICODE
)
test_date_en
=
format_date_en
.
match
(
text
)
format_sect
=
re
.
compile
(
'(
\
D+),'
,
re
.
UNICODE
)
test_sect
=
format_sect
.
match
(
text
)
format_page
=
re
.
compile
(
', p. (
\
w+)'
,
re
.
UNICODE
)
test_page
=
format_page
.
match
(
text
)
if
text
is
not
None
:
test_date_fr
=
format_date_fr
.
match
(
text
)
format_date_en
=
re
.
compile
(
'
\
w+
\
s+
\
d+,
\
s+
\
d{4}'
,
re
.
UNICODE
)
test_date_en
=
format_date_en
.
match
(
text
)
format_sect
=
re
.
compile
(
'(
\
D+),'
,
re
.
UNICODE
)
test_sect
=
format_sect
.
match
(
text
)
format_page
=
re
.
compile
(
', p. (
\
w+)'
,
re
.
UNICODE
)
test_page
=
format_page
.
match
(
text
)
else
:
test_date_fr
=
None
test_date_en
=
None
test_sect
=
None
test_page
=
None
if
test_date_fr
is
not
None
:
self
.
localeEncoding
=
"fr_FR"
...
...
static/img/delete-big.png
0 → 100644
View file @
b8e3f83b
9.69 KB
templates/corpus.html
View file @
b8e3f83b
...
...
@@ -224,6 +224,23 @@ function updateDocuments(pagenumber,pagenav) {
}
var
current_docs
=
{}
var
BIS_dict
=
{}
var
corpusid
=
window
.
location
.
href
.
split
(
"corpus"
)[
1
].
replace
(
/
\/
/g
,
''
)
//replace all the slashes
var
theurl
=
"http://localhost:8000/api/nodes/"
+
corpusid
+
"/children/duplicates?keys=title&limit=9999"
$
.
ajax
({
url
:
theurl
,
success
:
function
(
data
)
{
bisarray
=
data
.
data
for
(
var
i
in
bisarray
)
{
onebis
=
bisarray
[
i
].
values
BIS_dict
[
onebis
[
0
]]
=
[
bisarray
[
i
].
count
,
0
];
// [ total amount , removed ]
}
pr
(
BIS_dict
)
}
});
// var gainOrLossChart = dc.pieChart("#gain-loss-chart");
// var fluctuationChart = dc.barChart("#fluctuation-chart");
// var quarterChart = dc.pieChart("#quarter-chart");
...
...
templates/subcorpus.html
View file @
b8e3f83b
{% if date %}
<p>
Today: {{date}}
</p>
{% endif %}
<div
class=
"pagination"
>
<span
class=
"step-links"
>
{% if documents.has_previous %}
...
...
@@ -25,9 +21,56 @@
<ul>
{% for doc in documents %}
{% if doc.date %}
<li>
<b>
{{ doc.date }}
</b>
:
<a
target=
"_blank"
href=
"/nodeinfo/{{doc.id}}"
>
{{ doc.name}}
</a>
, @ {{ doc.metadata.source}}
</li>
<li>
<div
id=
"doc_{{doc.id}}"
>
<b>
{{ doc.date }}
</b>
:
<a
target=
"_blank"
href=
"/nodeinfo/{{doc.id}}"
>
{{ doc.name}}
</a>
, @ {{ doc.metadata.source}}
</div>
</li>
{% endif %}
{% endfor %}
</ul>
<script>
function
getCookie
(
name
)
{
var
cookieValue
=
null
;
if
(
document
.
cookie
&&
document
.
cookie
!=
''
)
{
var
cookies
=
document
.
cookie
.
split
(
';'
);
for
(
var
i
=
0
;
i
<
cookies
.
length
;
i
++
)
{
var
cookie
=
jQuery
.
trim
(
cookies
[
i
]);
// Does this cookie string begin with the name we want?
if
(
cookie
.
substring
(
0
,
name
.
length
+
1
)
==
(
name
+
'='
))
{
cookieValue
=
decodeURIComponent
(
cookie
.
substring
(
name
.
length
+
1
));
break
;
}
}
}
return
cookieValue
;
}
function
deleteNode
(
node_id
)
{
$
.
ajax
({
url
:
'/api/nodes/'
+
node_id
,
type
:
'DELETE'
,
beforeSend
:
function
(
xhr
)
{
xhr
.
setRequestHeader
(
"X-CSRFToken"
,
getCookie
(
"csrftoken"
));
},
success
:
function
(
result
)
{
console
.
log
(
result
)
location
.
reload
();
},
error
:
function
(
result
)
{
console
.
log
(
"Data not found"
);
console
.
log
(
result
)
}
});
}
current_docs
=
[]
{
%
for
doc
in
documents
%
}
id
=
"doc_{{doc.id}}"
title
=
"{{doc.name}}"
if
(
BIS_dict
[
title
])
{
var
delimg
=
'<a title="Delete this document!" style="cursor: pointer;" onclick="deleteNode('
+
"{{doc.id}}"
+
')"><img width="20px" src="/static/img/delete-big.png"></img></a>'
$
(
"#"
+
id
).
prepend
(
delimg
)
}
{
%
endfor
%
}
</script>
{% endif %}
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