Merge branch 'master' of ssh://git.crans.org/git/usr-scripts
This commit is contained in:
commit
285c9d8d9f
2 changed files with 61 additions and 57 deletions
|
@ -3,17 +3,16 @@
|
|||
import os
|
||||
import PagesPerso
|
||||
|
||||
def comptes():
|
||||
"""Retourne la liste des comptes"""
|
||||
return filter(lambda x: os.path.isdir(u"/home/club/%s" % x) and not os.path.islink(u"/home/club/%s" % x),
|
||||
os.listdir(u"/home/club"))
|
||||
class ClubList(PagesPerso.AccountList):
|
||||
home = "/home/club"
|
||||
www = ""
|
||||
url = "http://clubs.ens-cachan.fr/%s/"
|
||||
|
||||
def url(self):
|
||||
"""URL vers la page perso"""
|
||||
return u"http://clubs.ens-cachan.fr/%s/" % self.login
|
||||
def comptes(self):
|
||||
"""Retourne la liste des comptes"""
|
||||
return filter(lambda x: os.path.isdir(u"/home/club/%s" % x) and not os.path.islink(u"/home/club/%s" % x),
|
||||
os.listdir(u"/home/club"))
|
||||
|
||||
def execute(macro, args):
|
||||
return macro.formatter.rawHTML(ClubList().to_html())
|
||||
|
||||
PagesPerso.comptes = comptes
|
||||
PagesPerso.account.home = "/home/club"
|
||||
PagesPerso.account.www = ""
|
||||
PagesPerso.account.url = url
|
||||
execute = PagesPerso.execute
|
||||
|
|
|
@ -2,16 +2,57 @@
|
|||
|
||||
import os
|
||||
|
||||
class account:
|
||||
"""Classe représentant la page perso d'une personne"""
|
||||
|
||||
class AccountList:
|
||||
home = "/home"
|
||||
www = "/www"
|
||||
url = "http://perso.crans.org/%s/"
|
||||
|
||||
def __init__(self, login):
|
||||
def __init__(self):
|
||||
return
|
||||
|
||||
def comptes(self):
|
||||
"""Retourne la liste des comptes"""
|
||||
return filter(lambda x: os.path.isdir(u"/home/%s/www" % x) and not os.path.islink(u"/home/%s/www" % x),
|
||||
os.listdir(u"/home/mail"))
|
||||
|
||||
|
||||
def makeAnchor(self,letter):
|
||||
return u"<div class=\"vignetteperso\"><a class=\"letter_anchor\" name=\"index_%s\"><span>%s:</span></a></div>" % ( letter, letter )
|
||||
|
||||
def makeIndex(self,letter_list):
|
||||
index = u''
|
||||
for aLetter in letter_list:
|
||||
index = u"%s<a href=\"#index_%s\">%s</a>" % ( index, aLetter, aLetter)
|
||||
return u"<div class=\"alphabetic_index\">%s</div>" % index
|
||||
|
||||
def to_html(self):
|
||||
dirs = self.comptes()
|
||||
dirs.sort()
|
||||
html = u""
|
||||
|
||||
premiere_lettre = ''
|
||||
letter_list = []
|
||||
for d in dirs:
|
||||
if premiere_lettre != d[0]:
|
||||
premiere_lettre = d[0]
|
||||
letter_list.append(premiere_lettre)
|
||||
html = u"%s\n%s" % ( html, self.makeAnchor(premiere_lettre) )
|
||||
html = u"%s\n%s" % (html, Account(self.home, d, self.www, self.url).to_html())
|
||||
|
||||
index = self.makeIndex(letter_list)
|
||||
html = index + html
|
||||
html += u'<br style="clear: both">'
|
||||
return html
|
||||
|
||||
class Account:
|
||||
"""Classe représentant la page perso d'une personne"""
|
||||
|
||||
def __init__(self, home, login, www, url):
|
||||
"""Instanciation avec le `login' de la personne"""
|
||||
self.login = login
|
||||
self.home = "%s/%s" % (self.home, login)
|
||||
self.home = "%s/%s" % (home, login)
|
||||
self.www = www
|
||||
self.url = url
|
||||
|
||||
_info = None
|
||||
def info(self, champ):
|
||||
|
@ -39,10 +80,6 @@ class account:
|
|||
"""Chemin vers le www"""
|
||||
return u"%s%s" % (self.home, self.www)
|
||||
|
||||
def url(self):
|
||||
"""URL vers la page perso"""
|
||||
return u"http://perso.crans.org/%s/" % self.login
|
||||
|
||||
def logo(self):
|
||||
"""URL du logo s'il y en a un"""
|
||||
if self.info("logo"):
|
||||
|
@ -52,13 +89,13 @@ class account:
|
|||
else:
|
||||
logo = self.info("logo")
|
||||
if os.path.isfile("%s/%s" % (self.chemin(), logo)):
|
||||
return u"%s%s" % (self.url(), logo)
|
||||
return u"%s%s" % (self.url % self.login, logo)
|
||||
return u"http://perso.crans.org/pageperso.png"
|
||||
|
||||
def __str__(self):
|
||||
def to_html(self):
|
||||
"""Renvoie le code HTML correspondant au fichier .info"""
|
||||
html = [ u'<div class="vignetteperso">',
|
||||
u'<a href="%s">' % self.url(),
|
||||
u'<a href="%s">' % (self.url % self.login),
|
||||
u'<img src="%s" alt="%s">' % (self.logo(), self.login),
|
||||
u'</a><br>',
|
||||
self.info("nom") and u'<b>%s</b><br>' % self.info("nom") or u'%s<br>' % self.login,
|
||||
|
@ -66,38 +103,6 @@ class account:
|
|||
u'</div>' ]
|
||||
return u'\n'.join(html)
|
||||
|
||||
def comptes():
|
||||
"""Retourne la liste des comptes"""
|
||||
return filter(lambda x: os.path.isdir(u"/home/%s/www" % x) and not os.path.islink(u"/home/%s/www" % x),
|
||||
os.listdir(u"/home/mail"))
|
||||
|
||||
|
||||
def makeAnchor(letter):
|
||||
return u"<div class=\"vignetteperso\"><a class=\"letter_anchor\" name=\"index_%s\"><span>%s:</span></a></div>" % ( letter, letter )
|
||||
|
||||
def makeIndex(letter_list):
|
||||
index = u''
|
||||
for aLetter in letter_list:
|
||||
index = u"%s<a href=\"#index_%s\">%s</a>" % ( index, aLetter, aLetter)
|
||||
return u"<div class=\"alphabetic_index\">%s</div>" % index
|
||||
|
||||
def execute(macro, args):
|
||||
dirs = comptes()
|
||||
dirs.sort()
|
||||
|
||||
html = u""
|
||||
|
||||
premiere_lettre = ''
|
||||
letter_list = []
|
||||
for d in dirs:
|
||||
if premiere_lettre != d[0]:
|
||||
premiere_lettre = d[0]
|
||||
letter_list.append(premiere_lettre)
|
||||
html = u"%s\n%s" % ( html, makeAnchor(premiere_lettre) )
|
||||
html = u"%s\n%s" % (html, account(d).__str__())
|
||||
|
||||
|
||||
index = makeIndex(letter_list)
|
||||
html = index + html
|
||||
html += u'<br style="clear: both">'
|
||||
return macro.formatter.rawHTML(html)
|
||||
return macro.formatter.rawHTML(AccountList().to_html())
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue