tr4ck3ur des JM2L преди 8 години
родител
ревизия
cfff312f38
променени са 3 файла, в които са добавени 61 реда и са изтрити 6 реда
  1. +1
    -0
      jm2l/__init__.py
  2. +6
    -1
      jm2l/templates/Live.mako
  3. +54
    -5
      jm2l/to_print.py

+ 1
- 0
jm2l/__init__.py Целия файл

@@ -157,6 +157,7 @@ def main(global_config, **settings):
config.add_route('badge_user', '/user/{user_slug:([\w-]+)?}/badge')
config.add_route('all_badges', '/badges')
config.add_route('place_print', '/place_print')
config.add_route('stand_print', '/stand_print')
# HTML Routes - Logged
#config.add_route('profil', 'MesJM2L')


+ 6
- 1
jm2l/templates/Live.mako Целия файл

@@ -30,7 +30,12 @@ Voici les liens vers les conférences Live:
<p>
Réalisé avec le concours des admins réseau Polytech'Nice. Encore merci pour leur disponibilité .. <br/>
Rechargez la page pour voir les évenements en cours en fonction de l'heure...<br/>
Vous avez le droit de vous plaindre, c'est du Do It Yourself ;)
</p>

<p> NB : si vous n'avez pas l'audio à travers votre navigateur...<br>
n'hésitez pas à mettre à contribution votre lecteur de vidéo préféré ( VLC, ffmpeg )<br>
</p>
<p>
Vous avez le droit de vous plaindre, c'est du Do It Yourself ;)
</p>
</div>

+ 54
- 5
jm2l/to_print.py Целия файл

@@ -34,7 +34,6 @@ def JM2L_large_Logo(canvas, Offset=(0,0)):
yearobject.setWordSpace(1)
canvas.drawText(yearobject)


def one_time_step(canvas, str, hour, max_size, offset):
max_x, max_y = max_size
off_x, off_y = offset
@@ -46,6 +45,54 @@ def one_time_step(canvas, str, hour, max_size, offset):
if hour<9:
canvas.line(off_x-2, hour_place+half_step, off_x, hour_place+half_step)


@view_config(route_name='stand_print', http_cache = (EXPIRATION_TIME, {'public':True}))
def stand_print(request):
# Ok let's generate a print for place schedule
# Register LiberationMono font
ttfFile = "jm2l/static/fonts/LiberationMono-Regular.ttf"
pdfmetrics.registerFont(TTFont("Liberation", ttfFile))
# Import font
ttfFile_Logo = "jm2l/static/fonts/PWTinselLetters.ttf"
pdfmetrics.registerFont(TTFont("Logo", ttfFile_Logo))

pdf = StringIO.StringIO()
c = canvas.Canvas( pdf, pagesize=(HEIGHT, WIDTH) )
c.translate(mm, mm)
# Feed some metadata
c.setCreator("linux-azur.org")
c.setTitle("Affiches stand")

c.saveState()
year = int(request.matchdict.get('year', CurrentYear))

Events = DBSession.query(Event)\
.filter(Event.for_year == year)\
.filter(Event.event_type == "Stand")

for ev in Events:
c.setFont('Logo', 50)
c.setFillColorRGB(.5,.5,.5)
c.drawString(HEIGHT-150, 30, "JM2L")
c.setFont('Logo', 100)
c.setFillColorRGB(0.5,0.5,0.5)
c.drawCentredString(HEIGHT/2, WIDTH-90, "STAND", 0)
c.setFillColorRGB(0,0,0)
c.setFont('Helvetica', 42)
c.drawCentredString(HEIGHT/2, WIDTH/2, ev.name, 0)
c.showPage()

c.save()
pdf.seek(0)

return Response(app_iter=pdf, content_type = 'application/pdf' )



@view_config(route_name='place_print', http_cache = (EXPIRATION_TIME, {'public':True}))
def place_print(request):
# Ok let's generate a print for place schedule
@@ -103,7 +150,7 @@ def place_print(request):
for i in range(0,10):
one_time_step(c, "%.2dh00" % (i+10), i, max_size, offset)

c.setFont('Helvetica', 12)
#c.setFont('Helvetica', 12)
Events = DBSession.query(Event)\
.filter(Event.for_year == year)\
.filter(Event.salle_uid == place_uid)\
@@ -125,11 +172,13 @@ def place_time(c, ev, max_size, offset):
start_pos_y = ((int( ev.start_time.strftime('%H') )-10)*60 + int( ev.start_time.strftime('%M') )) * minute
stop_pos_y = ((int( ev.end_time.strftime('%H') )-10)*60 + int( ev.end_time.strftime('%M') )) * minute

c.setFillColorRGB(1,1,1)
c.setFillColorRGB(0.98,0.98,0.98)
c.rect(offset[0], max_y + off_y - start_pos_y, max_size[0], start_pos_y-stop_pos_y, fill=1, stroke=1)
c.setFillColorRGB(0,0,0)
#c.drawString(off_x+5, max_y + off_y - 15 - start_pos_y, ev.start_time.strftime('%H:%M'), 0)
c.setFont('Helvetica', 12)
c.drawCentredString(WIDTH/2, max_y + off_y - 35 - start_pos_y, ev.name, 0)
intervs = ','.join( [x.slug for x in ev.intervenants] )
c.drawString(WIDTH/2, max_y + off_y - 45 - start_pos_y, intervs, 0)
intervs = ', '.join( [x.slug for x in ev.intervenants] )
c.setFont('Helvetica', 10)
c.drawCentredString(WIDTH/2, max_y + off_y - 55 - start_pos_y, intervs, 0)

Зареждане…
Отказ
Запис