[wiki-lenny/local/parser/Portail.py] Le portail marche
darcs-hash:20081109222127-bd074-d3fb053d5bcfad423e5e7bba0837ad5ac2907de6.gz
This commit is contained in:
parent
7cf7940535
commit
0c660ccda9
1 changed files with 88 additions and 0 deletions
88
wiki-lenny/local/parser/Portail.py
Normal file
88
wiki-lenny/local/parser/Portail.py
Normal file
|
@ -0,0 +1,88 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
"""
|
||||
..
|
||||
.... ............ ........
|
||||
. ....... . .... ..
|
||||
. ... .. .. .. .. ..... . ..
|
||||
.. .. ....@@@. .. . ........ .
|
||||
.. . .. ..@.@@..@@. .@@@@@@@ @@@@@@. ....
|
||||
.@@@@. .@@@@. .@@@@..@@.@@..@@@..@@@..@@@@.... ....
|
||||
@@@@... .@@@.. @@ @@ .@..@@..@@...@@@. .@@@@@. ..
|
||||
.@@@.. . @@@. @@.@@..@@.@@..@@@ @@ .@@@@@@.. .....
|
||||
...@@@.... @@@ .@@.......... ........ ..... ..
|
||||
. ..@@@@.. . .@@@@. .. ....... . .............
|
||||
. .. .... .. .. . ... ....
|
||||
. . .... ............. .. ...
|
||||
.. .. ... ........ ... ...
|
||||
................................
|
||||
|
||||
MoinMoin - Portail parser
|
||||
|
||||
PURPOSE:
|
||||
Pour afficher un portail a la wikipedia.
|
||||
|
||||
CALLING SEQUENCE:
|
||||
{{{
|
||||
#!Portail
|
||||
image1.png | title1 | description 1
|
||||
image2.png | title2 | description 2
|
||||
image3.png | title3 | description 3
|
||||
}}}
|
||||
|
||||
Copyright 2008 Antoine Durand-Gasselin <adg@crans.org>
|
||||
|
||||
"""
|
||||
import os,string,re,StringIO
|
||||
from MoinMoin.action import AttachFile
|
||||
from MoinMoin.parser.text_moin_wiki import Parser as WikiParser
|
||||
|
||||
#####################################################################
|
||||
# Parser : classe principale, c'est elle qui fait tout
|
||||
#######
|
||||
class Parser:
|
||||
def __init__(self, raw, request, **kw):
|
||||
self.request = request
|
||||
self.form = request.form
|
||||
self.raw = raw
|
||||
|
||||
def format(self, formatter):
|
||||
# on divise le textes en lignes (1 ligne = une entree dans le portail)
|
||||
quotes = self.raw.split('\n')
|
||||
|
||||
# on récupere le chemin des fichiers attaches pour les images
|
||||
current_pagename=formatter.page.page_name
|
||||
attachment_path = AttachFile.getAttachDir(self.request, current_pagename, create=1)
|
||||
# on traite les ligne une à une
|
||||
entries = []
|
||||
for line in quotes:
|
||||
line=line.strip()
|
||||
items=line.split('|',2)
|
||||
if len(items)<3:
|
||||
# Voir ce qu'on fait
|
||||
## self.request.write('<!-- error, wrong number of parameters -->')
|
||||
pass
|
||||
else:
|
||||
# On récupère l'url de l'image
|
||||
pic = AttachFile.getAttachUrl(current_pagename, items[0].strip(), self.request).replace('& ','&')
|
||||
|
||||
# On va formatter le titre et la légende
|
||||
tit_buf = StringIO.StringIO()
|
||||
bod_buf = StringIO.StringIO()
|
||||
|
||||
self.request.redirect(tit_buf)
|
||||
WikiParser(items[1], self.request).format(formatter)
|
||||
title = tit_buf.getvalue()
|
||||
self.request.redirect()
|
||||
|
||||
self.request.redirect(bod_buf)
|
||||
WikiParser(items[2], self.request).format(formatter)
|
||||
body = bod_buf.getvalue()
|
||||
self.request.redirect()
|
||||
|
||||
del tit_buf
|
||||
del bod_buf
|
||||
|
||||
# Qu'on rajoute à la liste des entrées
|
||||
entries += [ (( pic, title, body )) ]
|
||||
|
||||
self.request.write(formatter.crans_portal(entries))
|
Loading…
Add table
Add a link
Reference in a new issue