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
a45d8db1
Commit
a45d8db1
authored
Jan 08, 2015
by
Administrator
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'testing'
Login/logout and parser
parents
0073a5ea
0f39af9a
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
19 additions
and
8 deletions
+19
-8
urls.py
gargantext_web/urls.py
+1
-0
views.py
gargantext_web/views.py
+5
-1
EuropressFileParser.py
parsing/FileParsers/EuropressFileParser.py
+11
-5
authentication.html
templates/authentication.html
+1
-1
menu.html
templates/menu.html
+1
-1
No files found.
gargantext_web/urls.py
View file @
a45d8db1
...
@@ -18,6 +18,7 @@ urlpatterns = patterns('',
...
@@ -18,6 +18,7 @@ urlpatterns = patterns('',
url
(
r'^grappelli/'
,
include
(
'grappelli.urls'
)),
url
(
r'^grappelli/'
,
include
(
'grappelli.urls'
)),
url
(
r'^auth/$'
,
views
.
login_user
),
url
(
r'^auth/$'
,
views
.
login_user
),
url
(
r'^auth/logout/$'
,
views
.
logout_user
),
# User Home view
# User Home view
url
(
r'^$'
,
views
.
home
),
url
(
r'^$'
,
views
.
home
),
...
...
gargantext_web/views.py
View file @
a45d8db1
...
@@ -51,6 +51,10 @@ def login_user(request):
...
@@ -51,6 +51,10 @@ def login_user(request):
return
render_to_response
(
'authentication.html'
,
context_instance
=
RequestContext
(
request
))
return
render_to_response
(
'authentication.html'
,
context_instance
=
RequestContext
(
request
))
def
logout_user
(
request
):
logout
(
request
)
return
HttpResponseRedirect
(
'/'
)
# Redirect to a success page.
def
query_to_dicts
(
query_string
,
*
query_args
):
def
query_to_dicts
(
query_string
,
*
query_args
):
"""Run a simple query and produce a generator
"""Run a simple query and produce a generator
...
@@ -117,7 +121,7 @@ def projects(request):
...
@@ -117,7 +121,7 @@ def projects(request):
To each project, we can link a resource that can be an image.
To each project, we can link a resource that can be an image.
'''
'''
if
not
request
.
user
.
is_authenticated
():
if
not
request
.
user
.
is_authenticated
():
return
redirect
(
'/a
dmin/logout/?next=
%
s'
%
request
.
path
)
return
redirect
(
'/a
uth/'
)
t
=
get_template
(
'projects.html'
)
t
=
get_template
(
'projects.html'
)
...
...
parsing/FileParsers/EuropressFileParser.py
View file @
a45d8db1
...
@@ -3,6 +3,7 @@ import locale
...
@@ -3,6 +3,7 @@ import locale
from
lxml
import
etree
from
lxml
import
etree
from
datetime
import
datetime
,
date
from
datetime
import
datetime
,
date
from
django.utils
import
timezone
from
django.utils
import
timezone
import
dateutil.parser
from
.FileParser
import
FileParser
from
.FileParser
import
FileParser
from
..NgramsExtractors
import
*
from
..NgramsExtractors
import
*
...
@@ -23,9 +24,9 @@ class EuropressFileParser(FileParser):
...
@@ -23,9 +24,9 @@ class EuropressFileParser(FileParser):
#print(len(contents))
#print(len(contents))
#return []
#return []
encoding
=
self
.
detect_encoding
(
contents
)
encoding
=
self
.
detect_encoding
(
contents
)
print
(
encoding
)
#
print(encoding)
if
encoding
!=
"utf-8"
:
#
if encoding != "utf-8":
contents
=
contents
.
decode
(
encoding
,
errors
=
'replace'
)
.
encode
(
codif
)
contents
=
contents
.
decode
(
encoding
,
errors
=
'replace'
)
.
encode
(
codif
)
try
:
try
:
html_parser
=
etree
.
HTMLParser
(
encoding
=
codif
)
html_parser
=
etree
.
HTMLParser
(
encoding
=
codif
)
...
@@ -78,14 +79,19 @@ class EuropressFileParser(FileParser):
...
@@ -78,14 +79,19 @@ class EuropressFileParser(FileParser):
text
=
text
.
replace
(
'ű'
,
'û'
)
text
=
text
.
replace
(
'ű'
,
'û'
)
text
=
text
.
replace
(
' aot '
,
' août '
)
text
=
text
.
replace
(
' aot '
,
' août '
)
try
:
try
:
metadata
[
'publication_date'
]
=
datetime
.
strptime
(
text
,
'
%
d
%
B
%
Y'
)
metadata
[
'publication_date'
]
=
datetime
.
strptime
(
text
,
'
%
d
%
B
%
Y'
)
except
:
except
:
try
:
try
:
metadata
[
'publication_date'
]
=
datetime
.
strptime
(
text
,
'
%
B
%
Y'
)
metadata
[
'publication_date'
]
=
datetime
.
strptime
(
text
,
'
%
B
%
Y'
)
except
:
except
:
print
(
text
)
try
:
pass
metadata
[
'publication_date'
]
=
dateutil
.
parser
.
parse
(
text
)
except
Exception
as
error
:
print
(
error
)
print
(
text
)
pass
if
test_date_en
is
not
None
:
if
test_date_en
is
not
None
:
localeEncoding
=
"en_GB.UTF-8"
localeEncoding
=
"en_GB.UTF-8"
...
...
templates/authentication.html
View file @
a45d8db1
...
@@ -93,7 +93,7 @@
...
@@ -93,7 +93,7 @@
<script
type=
"text/javascript"
>
<script
type=
"text/javascript"
>
(
function
(
$
)
{
(
function
(
$
)
{
$
(
window
).
load
(
function
(){
$
(
'#
id_
username'
).
focus
();
});
$
(
window
).
load
(
function
(){
$
(
'#username'
).
focus
();
});
})(
grp
.
jQuery
);
})(
grp
.
jQuery
);
</script>
</script>
</body>
</body>
...
...
templates/menu.html
View file @
a45d8db1
...
@@ -43,7 +43,7 @@
...
@@ -43,7 +43,7 @@
<li><a tabindex="-1" href="/auth/">Login</a></li>
<li><a tabindex="-1" href="/auth/">Login</a></li>
<li><a tabindex="-1" href="#">Profile</a></li>
<li><a tabindex="-1" href="#">Profile</a></li>
<li class="divider"></li>
<li class="divider"></li>
<li><a tabindex="-1" href="
#">Help
</a></li>
<li><a tabindex="-1" href="
/auth/logout">Logout
</a></li>
</ul>
</ul>
</li>
</li>
</ul>
</ul>
...
...
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