Commit dd1022d8 authored by Mathieu Rodic's avatar Mathieu Rodic

[GIT] "first" commit

Restart from scratch; a few static pages are available
parents
"""URL Configuration of GarganText
Views are shared between three main modules:
- `api`, for JSON and CSV interaction with data
- `pages`, to present HTML views to the user
- `contents`, for Python-generated contents
"""
from django.conf.urls import include, url
from django.contrib import admin
# import gargantext.views.api
import gargantext.views.generated.urls
import gargantext.views.pages.urls
urlpatterns = [
url(r'^admin/', admin.site.urls),
url(r'^generated/', include(gargantext.views.generated.urls)),
url(r'^', include(gargantext.views.pages.urls)),
]
# -*- coding: utf-8 -*-
# Order in script: Alphabetical order (first_name, name, mail, website)
# Order in public: Shuffled order
import random
_members = [
{ 'first_name' : 'David', 'last_name' : 'Chavalarias',
'mail' : 'david.chavalariasATiscpif.fr',
'website' : 'http://chavalarias.com',
'picture' : 'david.jpg',
'role':'principal investigator'},
# { 'first_name' : 'Elias', 'last_name' : 'Showk',
# 'mail' : '',
# 'website' : 'https://github.com/elishowk',
# 'picture' : '', 'role' : 'developer'},
{ 'first_name' : 'Mathieu', 'last_name' : 'Rodic',
'mail' : '',
'website' : 'http://rodic.fr',
'picture' : 'mathieu.jpg',
'role' : 'developer'},
{ 'first_name' : 'Samuel', 'last_name' : 'Castillo J.',
'mail' : 'kaisleanATgmail.com',
'website' : 'http://www.pksm3.droppages.com',
'picture' : 'samuel.jpg',
'role' : 'developer'},
{ 'first_name' : 'Maziyar', 'last_name' : 'Panahi',
'mail' : '',
'website' : '',
'picture' : 'maziyar.jpg',
'role' : 'developer'},
{ 'first_name' : 'Romain', 'last_name' : 'Loth',
'mail' : '',
'website' : '',
'picture' : 'romain.jpg',
'role' : 'developer'},
{ 'first_name' : 'Alexandre', 'last_name' : 'Delanoë',
'mail' : 'alexandre+gargantextATdelanoe.org',
'website' : 'http://alexandre.delanoe.org',
'picture' : 'alexandre.jpg',
'role' : 'principal investigator, developer'},
#{ 'first_name' : '', 'name' : '', 'mail' : '', 'website' : '', 'picture' : ''},
# copy-paste the line above and write your informations please
]
_institutions = [
{ 'name' : 'Mines ParisTech', 'website' : 'http://mines-paristech.fr', 'picture' : 'mines.png', 'funds':''},
{ 'name' : 'Institut Pasteur', 'website' : 'http://www.pasteur.fr', 'picture' : 'pasteur.png', 'funds':''},
{ 'name' : 'ADEME', 'website' : 'http://www.ademe.fr', 'picture' : 'ademe.png', 'funds':''},
{ 'name' : 'EHESS', 'website' : 'http://www.ehess.fr', 'picture' : 'ehess.png', 'funds':''},
#{ 'name' : '', 'website' : '', 'picture' : '', 'funds':''},
# copy paste the line above and write your informations please
]
_labs = [
{ 'name' : 'Centre de Sociologie de l\'innovation', 'website' : 'http://www.csi.mines-paristech.fr/en/', 'picture' : 'csi.png', 'funds':''},
#{ 'name' : '', 'website' : '', 'picture' : '', 'funds':''},
# copy paste the line above and write your informations please
]
_grants = [
{ 'name' : 'Forccast', 'website' : 'http://forccast.hypotheses.org/', 'picture' : 'forccast.png', 'funds':''},
{ 'name' : 'Mastodons', 'website' : 'http://www.cnrs.fr/mi/spip.php?article53&lang=fr', 'picture' : 'mastodons.png', 'funds':''},
#{ 'name' : '', 'website' : '', 'picture' : '', 'funds':''},
# copy paste the line above and write your informations please
]
def members():
random.shuffle(_members)
return _members
def institutions():
random.shuffle(_institutions)
return _institutions
def partners():
random.shuffle(_partners)
return _partners
def labs():
random.shuffle(_labs)
return _labs
def grants():
random.shuffle(_grants)
return _grants
import random
import random_words
from math import pi
def lorem(size_target=450):
'''
Function that returns paragraph with false latin language.
size_target is the number of random words that will be given.
'''
lorem = random_words.LoremIpsum()
sentences_list = lorem.get_sentences_list(sentences=5)
paragraph_size = 0
while paragraph_size < size_target :
sentences_list.append(lorem.get_sentence())
paragraph = ' '.join(sentences_list)
paragraph_size = len(paragraph)
return(paragraph)
def gargantua(size_target=500):
'''
Function that returns paragraph with chapter titles of Gargantua.
size_target is the number of random words that will be given.
'''
paragraph = list()
paragraph_size = 0
chapter_number = 1
while paragraph_size < size_target and chapter_number < 6:
chapitre = open('/srv/gargantext/static/docs/gargantua_book/gargantua_chapter_%d.txt' % chapter_number, 'r')
paragraph.append(random.choice(chapitre.readlines()).strip())
chapitre.close()
paragraph_size = len(' '.join(paragraph))
chapter_number += 1
return(' '.join(paragraph))
def random_letter(mot, size_min=5):
'''
Functions that randomize order letters of a
word which size is greater that size_min.
'''
if len(mot) > size_min:
size = round(len(mot) / pi)
first_letters = mot[:size]
last_letters = mot[-size:]
others_letters = list(mot[size:-size])
random.shuffle(others_letters)
mot_list = list()
mot_list.append(first_letters)
for letter in others_letters:
mot_list.append(letter)
mot_list.append(last_letters)
return(''.join(mot_list))
else:
return(mot)
tutoriel = """Il paraît que l'ordre des lettres dans un mot n'a pas d'importance. La première et la dernière lettre doivent être à la bonne place. Le reste peut être dans un désordre total et on peut toujours lire sans problème. On ne lit donc pas chaque lettre en elle-même, mais le mot comme un tout. Un changement de référentiel et nous transposons ce résultat au texte lui-même: l'ordre des mots est faiblement important comparé au contexte du texte qui, lui, est compté"""
def tutoreil(tutoriel=tutoriel):
'''
Functions that returns paragraph of words with words with
randomized letters.
'''
paragraph = ' '.join([ random_letter(mot) for mot in tutoriel.split(" ")]) \
+ ": comptexter avec Gargantext."
return(paragraph)
from django.template.loader import get_template
from django.template import Context, RequestContext
from django.http import Http404, HttpResponse, HttpResponseRedirect, HttpResponseForbidden
from django.shortcuts import render_to_response,redirect
from gargantext import settings
from django.conf.urls import url
# from . import main
urlpatterns = [
# url(r'^$', main.home),
]
from gargantext.util.http import *
def bootstrap(request):
template = get_template('generated/css/bootstrap.css')
css = dict()
group = "mines"
#group = "cnrs"
if group == "mines":
css['color'] = '#666666'
css['background'] = '#f8f8f7'
css['a'] = '#bd2525'
css['focus'] = '#7d1818'
css['hr'] = '#eaafae'
css['text'] = '#a2a3a2'
css['form'] = '#a5817f'
css['help'] = '#a6a6a6'
else:
css['color'] = '#E2E7EB'
css['background'] = '#8C9DAD' #container background
css['a'] = '#093558'
css['focus'] = '#556F86'
css['hr'] = '#426A8A'
css['text'] = '#214A6D'
css['form'] = '#093558'
css['help'] = '#093558'
css_data = template.render(Context({
'css': css,
}))
return HttpResponse(css_data, content_type="text/css")
from gargantext.util.http import *
def logo(request):
template = get_template('generated/img/logo.svg')
group = 'mines'
#group = 'cnrs'
if group == 'cnrs':
color = '#093558'
else:
# color of the css adapted to the logo
color = '#AE5C5C'
svg_data = template.render(Context({\
'color': color,\
}))
return HttpResponse(svg_data, content_type='image/svg+xml')
from django.conf.urls import include, url
from . import css, img
urlpatterns = [
url(r'^img/logo\.svg$', img.logo),
url(r'^css/bootstrap\.css', css.bootstrap),
]
from gargantext.util.http import *
from django.contrib import auth
def login(request):
logout(request)
username = password = ''
next_page = ""
if request.method == "GET":
additional_context = {}
# if for exemple: auth/?next=/project/5/corpus/554/document/556/
# => we'll forward ?next="..." into template with form
if ('next' in request.GET):
additional_context = {'next_page':request.GET['next']}
return render_to_response('pages/auth/login.html',
additional_context,
context_instance=RequestContext(request)
)
elif request.method == "POST":
username = request.POST['username']
# /!\ pass is sent clear in POST data
password = request.POST['password']
user = authenticate(username=username, password=password)
if user is not None:
if user.is_active:
login(request, user)
# if "next" forwarded from the GET via the template form
if ('the_next_page' in request.POST):
return HttpResponseRedirect(request.POST['the_next_page'])
else:
return HttpResponseRedirect('/projects/')
def logout(request):
'''Logout the user, and redirect to main page
'''
auth.logout(request)
return HttpResponseRedirect('/')
from gargantext.util.http import *
import datetime
from gargantext.util.generators import paragraphs, credits
def home(request):
'''
Home describes the platform.
A video draws the narratives.
If not logged a project test is shown.
'''
t = get_template('pages/main/home.html')
user = request.user
date = datetime.datetime.now()
html = t.render(Context({
'debug': settings.DEBUG,
'user': user,
'date': date,
'paragraph_gargantua': paragraphs.gargantua(),
'paragraph_lorem' : paragraphs.lorem(),
'paragraph_tutoreil': paragraphs.tutoreil(),
}))
return HttpResponse(html)
def about(request):
'''About Gargantext, its team and sponsors
'''
template = get_template('pages/main/about.html')
user = request.user
date = datetime.datetime.now()
html = template.render(Context({
'user': user,
'date': date,
'team': credits.members(),
'institutions': credits.institutions(),
'labos': credits.labs(),
'grants': credits.grants(),
}))
return HttpResponse(html)
from django.conf.urls import url
from . import main, auth
urlpatterns = [
url(r'^$', main.home),
url(r'^about/?$', main.about),
url(r'^auth/login/?$', auth.login),
url(r'^auth/logout/?$', auth.logout),
]
"""
WSGI config for gargantext project.
It exposes the WSGI callable as a module-level variable named ``application``.
For more information on this file, see
https://docs.djangoproject.com/en/1.9/howto/deployment/wsgi/
"""
import os
from django.core.wsgi import get_wsgi_application
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "gargantext.settings")
application = get_wsgi_application()
#!/usr/bin/env python
import os
import sys
if __name__ == "__main__":
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "gargantext.settings")
from django.core.management import execute_from_command_line
execute_from_command_line(sys.argv)
This diff is collapsed.
This diff is collapsed.
#!/bin/bash
convert -density 10% -resize 10% $1 $2
This diff is collapsed.
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Created with Inkscape (http://www.inkscape.org/) -->
<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
width="640"
height="480"
id="svg3041"
version="1.1"
inkscape:version="0.48.5 r10040"
sodipodi:docname="logo.svg">
<defs
id="defs3043" />
<sodipodi:namedview
id="base"
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1.0"
inkscape:pageopacity="0.0"
inkscape:pageshadow="2"
inkscape:zoom="0.86750285"
inkscape:cx="574.44134"
inkscape:cy="214.55006"
inkscape:document-units="px"
inkscape:current-layer="layer1"
showgrid="false"
inkscape:window-width="1360"
inkscape:window-height="762"
inkscape:window-x="0"
inkscape:window-y="0"
inkscape:window-maximized="0" />
<metadata
id="metadata3046">
<rdf:RDF>
<cc:Work
rdf:about="">
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
<dc:title></dc:title>
</cc:Work>
</rdf:RDF>
</metadata>
<g
inkscape:label="Calque 1"
inkscape:groupmode="layer"
id="layer1"
transform="translate(0,-572.36218)">
<rect
style="fill:#ffffff;fill-opacity:1;stroke:none"
id="rect2998"
width="410.37329"
height="315.84909"
x="102.59332"
y="641.98889"
inkscape:export-filename="/srv/gargantext/static/img/logo.png"
inkscape:export-xdpi="200"
inkscape:export-ydpi="200" />
<path
inkscape:export-ydpi="200"
inkscape:export-xdpi="200"
inkscape:export-filename="/srv/gargantext/static/img/logo.png"
id="path3950"
d="m 202.38568,655.35804 0,249.27214 130.47086,0 0,-16.6021 c -18.98946,-0.90974 -35.76303,-5.06743 -49.20478,-12.09066 -35.91671,-18.75291 -57.50584,-54.40745 -57.50584,-94.68011 0,-61.05225 40.65113,-101.66242 106.71062,-106.22939 l 0,-19.66988 -130.47086,0 z m 130.47086,19.66988 0,16.36149 c 3.35297,-0.31508 6.80528,-0.54137 10.34622,-0.54137 13.30249,0 25.59129,2.77406 37.8961,8.00029 l 4.63174,5.53403 4.99267,27.97093 18.64728,0 0,-48.84386 c -21.94909,-5.84107 -43.53556,-8.96273 -63.82184,-8.96273 -4.32186,0 -8.56494,0.19589 -12.69217,0.48122 z m 0,16.36149 c -44.82787,4.21264 -72.48382,36.2169 -72.48382,87.70241 0,53.1268 27.8084,86.66863 72.48382,92.03339 l 0,-179.7358 z m 0,179.7358 0,16.90287 c 2.62215,0.12569 5.29683,0.18036 8.00027,0.18036 19.62116,0 42.60224,-3.63639 68.87466,-10.70715 l 0,-73.50641 5.65434,-4.27083 18.28637,-1.56397 0,-12.63203 -83.19097,0 0,12.63203 23.63995,1.56397 5.65434,4.27083 0,63.94215 c -12.96993,2.76683 -24.28172,4.03022 -33.92603,4.03022 -4.47193,0 -8.80811,-0.3396 -12.99293,-0.84213 z"
style="font-size:166.11251831px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;text-align:center;line-height:125%;letter-spacing:0px;word-spacing:0px;writing-mode:lr-tb;text-anchor:middle;fill:#800000;fill-opacity:1;stroke:none;font-family:Bitstream Charter;-inkscape-font-specification:Bitstream Charter"
inkscape:connector-curvature="0" />
<path
inkscape:export-ydpi="200"
inkscape:export-xdpi="200"
inkscape:export-filename="/srv/gargantext/static/img/logo.png"
transform="matrix(1.9248814,0,0,1.9248814,982.68611,-182.71269)"
sodipodi:open="true"
sodipodi:end="6.1660663"
sodipodi:start="0"
d="m -312.87112,480.17926 a 9.0149298,9.0149298 0 1 1 -0.0618,-1.05341"
sodipodi:ry="9.0149298"
sodipodi:rx="9.0149298"
sodipodi:cy="480.17926"
sodipodi:cx="-321.88605"
id="path3952"
style="fill:#ffcc00;fill-opacity:1;stroke:none"
sodipodi:type="arc" />
<flowRoot
xml:space="preserve"
id="flowRoot3130"
style="font-size:12px;font-style:normal;font-weight:normal;line-height:125%;letter-spacing:0px;word-spacing:0px;fill:#800000;fill-opacity:1;stroke:none;font-family:Sans"
transform="translate(-222.82792,732.12538)"
inkscape:export-filename="/srv/gargantext/static/img/logo.png"
inkscape:export-xdpi="200"
inkscape:export-ydpi="200"><flowRegion
id="flowRegion3132"><rect
id="rect3134"
width="1090.0853"
height="476.31992"
x="327.0256"
y="148.23489"
style="fill:#800000" /></flowRegion><flowPara
id="flowPara3136"
style="font-size:64px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;fill:#800000;font-family:Sawasdee;-inkscape-font-specification:Sawasdee">Gargan<flowSpan
style="font-size:72px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-family:Courier;-inkscape-font-specification:Courier;fill:#800000"
id="flowSpan3019">text</flowSpan></flowPara></flowRoot> <flowRoot
xml:space="preserve"
id="flowRoot3138"
style="fill:black;stroke:none;stroke-opacity:1;stroke-width:1px;stroke-linejoin:miter;stroke-linecap:butt;fill-opacity:1;font-family:Sans;font-style:normal;font-weight:normal;font-size:12px;line-height:125%;letter-spacing:0px;word-spacing:0px"
inkscape:export-filename="/srv/gargantext/static/img/logo.png"
inkscape:export-xdpi="200"
inkscape:export-ydpi="200"><flowRegion
id="flowRegion3140"><rect
id="rect3142"
width="127.96654"
height="37.916012"
x="338.87436"
y="77.142372" /></flowRegion><flowPara
id="flowPara3144" /></flowRoot> <flowRoot
xml:space="preserve"
id="flowRoot3021"
style="fill:black;stroke:none;stroke-opacity:1;stroke-width:1px;stroke-linejoin:miter;stroke-linecap:butt;fill-opacity:1;font-family:Sans;font-style:normal;font-weight:normal;font-size:12px;line-height:125%;letter-spacing:0px;word-spacing:0px"
inkscape:export-filename="/srv/gargantext/static/img/logo.png"
inkscape:export-xdpi="200"
inkscape:export-ydpi="200"><flowRegion
id="flowRegion3023"><rect
id="rect3025"
width="3.9310031"
height="24.568769"
x="739.02856"
y="423.98322" /></flowRegion><flowPara
id="flowPara3027" /></flowRoot> </g>
</svg>
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Created with Inkscape (http://www.inkscape.org/) -->
<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
width="210mm"
height="297mm"
id="svg2"
version="1.1"
inkscape:version="0.48.5 r10040"
sodipodi:docname="mastodons.svg"
inkscape:export-filename="/srv/gargantext/static/img/sponsors/mastodons.png"
inkscape:export-xdpi="61.073017"
inkscape:export-ydpi="61.073017">
<defs
id="defs4">
<linearGradient
id="linearGradient3782">
<stop
style="stop-color:#09097e;stop-opacity:1;"
offset="0"
id="stop3784" />
<stop
id="stop3790"
offset="0.5"
style="stop-color:#09097e;stop-opacity:0.49803922;" />
<stop
style="stop-color:#09097e;stop-opacity:0;"
offset="1"
id="stop3786" />
</linearGradient>
</defs>
<sodipodi:namedview
id="base"
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1.0"
inkscape:pageopacity="0.0"
inkscape:pageshadow="2"
inkscape:zoom="7.0998446"
inkscape:cx="68.070083"
inkscape:cy="793.17743"
inkscape:document-units="px"
inkscape:current-layer="layer1"
showgrid="false"
inkscape:window-width="1360"
inkscape:window-height="762"
inkscape:window-x="0"
inkscape:window-y="0"
inkscape:window-maximized="0" />
<metadata
id="metadata7">
<rdf:RDF>
<cc:Work
rdf:about="">
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
<dc:title />
</cc:Work>
</rdf:RDF>
</metadata>
<g
inkscape:label="Calque 1"
inkscape:groupmode="layer"
id="layer1">
<path
style="fill:#04047e;fill-opacity:1;fill-rule:nonzero;stroke:#191559;stroke-width:2.37392211;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none"
d="m 67.957124,229.39485 c -21.951494,0 -40.977621,6.82314 -50.335489,16.79607 4.292013,2.97973 7.034932,7.49684 7.047344,12.55635 l 0,0.0311 c 0,5.67812 -3.440309,10.68036 -8.653863,13.59497 8.645806,10.98228 28.643543,18.67953 51.942008,18.67953 23.496654,0 43.642766,-7.82087 52.167926,-18.95081 -4.08915,-2.98628 -6.68337,-7.40599 -6.68337,-12.33159 0,-4.74462 2.40661,-9.01406 6.23781,-11.99055 -8.76845,-10.8289 -28.630779,-18.38499 -51.722366,-18.38499 z"
id="path2989"
inkscape:export-filename="/srv/gargantext/static/img/sponsors/mastodons.png"
inkscape:export-xdpi="150.35899"
inkscape:export-ydpi="150.35899"
inkscape:connector-curvature="0" />
<text
xml:space="preserve"
style="font-size:24.17494011px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;text-align:center;line-height:125%;letter-spacing:0px;word-spacing:0px;writing-mode:lr-tb;text-anchor:middle;fill:#00ffff;fill-opacity:1;stroke:none;font-family:Courier;-inkscape-font-specification:Courier"
x="120.14117"
y="156.8829"
id="text2985"
sodipodi:linespacing="125%"
transform="scale(0.58099746,1.7211779)"
inkscape:export-filename="/srv/gargantext/static/img/sponsors/mastodons.png"
inkscape:export-xdpi="150.35899"
inkscape:export-ydpi="150.35899"><tspan
sodipodi:role="line"
id="tspan2987"
x="120.14117"
y="156.8829">M<tspan
style="fill:#ffffff"
id="tspan2985">a</tspan>stod<tspan
style="fill:#ffffff"
id="tspan2992">o</tspan>n<tspan
style="fill:#ffffff"
id="tspan2996">s</tspan></tspan></text>
</g>
</svg>
This diff is collapsed.
This diff is collapsed.
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Created with Inkscape (http://www.inkscape.org/) -->
<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"