From d039c34d0e4048a8d75036126a342066251cd9e0 Mon Sep 17 00:00:00 2001 From: James Long Date: Thu, 26 Jan 2012 15:43:07 -0500 Subject: [PATCH] final hacks to get it generating correctly --- run.py | 68 ++++++++++++++++++++++++++---------------- templates/Aurora.html | 20 ++++++++++--- templates/Beta.html | 18 +++++++++-- templates/Release.html | 18 +++++++++-- 4 files changed, 89 insertions(+), 35 deletions(-) diff --git a/run.py b/run.py index a66ed91..7bd8822 100755 --- a/run.py +++ b/run.py @@ -2,8 +2,9 @@ import sys import sqlite3 -import jinja2 import os +from datetime import datetime +import jinja2 conn = sqlite3.connect('relnotes.sqlite') c = conn.cursor() @@ -23,15 +24,33 @@ beta_suffix = 'beta' channel_info = {} def cache_channels(): - c.execute('SELECT r.version, r.sub_version, c.channel_name FROM Releases r ' + c.execute('SELECT r.version, r.sub_version, c.channel_name, p.product_name FROM Releases r ' 'LEFT JOIN Channels c ON c.id = r.channel ' - 'ORDER BY r.release_date ASC') + 'LEFT JOIN Products p ON p.id = r.product ' + 'ORDER BY r.release_date DESC') data = c.fetchall() for record in data: - (version, sub_version, channel) = record - channel_info[channel] = {'version': version, - 'sub_version': sub_version} + (version, sub_version, channel, product) = record + if channel not in channel_info: + channel_info[channel] = {'version': version, + 'sub_version': sub_version} + + if ('desktop-url' not in channel_info[channel] or + 'mobile-url' not in channel_info[channel]) : + relname = 'releasenotes' + version_text = '%s.%s' % (version, sub_version) + if channel == 'Aurora': + version_text = version_text + aurora_suffix + relname = 'auroranotes' + elif channel == 'Beta': + version_text = version_text + beta_suffix + + if product == 'Firefox': + channel_info[channel]['desktop-url'] = 'en-US/firefox/%s/%s' % (version_text, relname) + else: + channel_info[channel]['mobile-url'] = 'en-US/mobile/%s/%s' % (version_text, relname) + def publish_channel(product_name, channel_name): c.execute('SELECT id, product_text FROM Products WHERE product_name=? LIMIT 1', (product_name,)) @@ -80,22 +99,15 @@ def publish_channel(product_name, channel_name): (product_id, version, version, channel_id, version, version, channel_id)) known_issues = c.fetchall() - for ch, vs in channel_info.iteritems(): - relname = 'releasenotes' - version_text = '%s.%s' % (vs['version'], vs['sub_version']) - if ch == 'Aurora': - version_text = version_text + aurora_suffix - relname = 'auroranotes' - elif ch == 'Beta': - version_text = version_text + beta_suffix + version_text = '%s.%s' % (version, sub_version) + if channel_name == 'Aurora': + version_text = version_text + aurora_suffix + elif channel_name == 'Beta': + version_text = version_text + beta_suffix - if product == 'Firefox': - channel_info[ch]['url'] = 'en-US/firefox/%s/%s' % (version_text, relname) - else: - channel_info[ch]['url'] = 'en-US/mobile/%s/%s' % (version_text, relname) - - out_dir = channel_info[channel_name]['url'] - out_file = '%s/index.html' % channel_info[channel_name]['url'] + is_mobile = (product_name == 'Firefox for mobile') + out_dir = channel_info[channel_name]['mobile-url' if is_mobile else 'desktop-url'] + out_file = '%s/index.html' % out_dir try: os.makedirs(os.path.join(out_base, out_dir)); @@ -104,18 +116,24 @@ def publish_channel(product_name, channel_name): env = jinja2.Environment(loader=jinja2.FileSystemLoader('templates')) tmpl = env.get_template(channel_name + '.html') - urls = dict([(i['version'],i['url']) for (ch,i) in channel_info.iteritems()]) + versions = dict([(i['version'],i) for (ch,i) in channel_info.iteritems()]) + + rdate = datetime.strptime(release_date, "%Y-%m-%d") + release_date = datetime.strftime(rdate, "%B %d, %Y").replace(" 0", " ") with file(os.path.join(out_base, out_file), 'w') as f: - f.write(tmpl.render({'is_mobile': product_name == 'Firefox for mobile', + f.write(tmpl.render({'is_mobile': is_mobile, 'release_date': release_date, - 'version': version_text, + 'version_text': version_text, + 'version': version, 'whats_new': whats_new, 'fixed': fixed, 'known_issues': known_issues, 'release_text': release_text, 'product_text': product_text, - 'urls': urls}).encode('utf-8')) + 'versions': versions}).encode('utf-8')) + + print 'Done: %s' % os.path.join(out_base, out_file) cache_channels() diff --git a/templates/Aurora.html b/templates/Aurora.html index 7dc8bb1..737b598 100644 --- a/templates/Aurora.html +++ b/templates/Aurora.html @@ -19,12 +19,12 @@ EXTRA_HEADERS; {% if not is_mobile %} Desktop {% else %} - Desktop + Desktop {% endif %}
  • {% if not is_mobile %} - Mobile + Mobile {% else %} Mobile {% endif %} @@ -75,7 +75,19 @@ EXTRA_HEADERS; {% for item in known_issues %}
  • - {% if item[2] %}Resolved{% else %}Unresolved{% endif %} + {% if item[2] %} + {% if versions[item[2]] %} + {% if is_mobile %} + + {% else %} + + {% endif %} + Resolved in v{{ item[2] }} + + {% else %} + Resolved in v{{ item[2] }} + {% endif %} + {% else %}Unresolved{% endif %}
    {{ item[1] }} @@ -95,7 +107,7 @@ EXTRA_HEADERS;

    Try Firefox Aurora

    1. - + Check »
    2. diff --git a/templates/Beta.html b/templates/Beta.html index 881550d..c4890de 100644 --- a/templates/Beta.html +++ b/templates/Beta.html @@ -30,12 +30,12 @@ EXTRA_HEADERS; {% if not is_mobile %} Desktop {% else %} - Desktop + Desktop {% endif %}
    3. {% if not is_mobile %} - Mobile + Mobile {% else %} Mobile {% endif %} @@ -86,7 +86,19 @@ EXTRA_HEADERS; {% for item in known_issues %}
    4. - {% if item[2] %}Resolved in v{{ item[2] }}{% else %}Unresolved{% endif %} + {% if item[2] %} + {% if versions[item[2]] %} + {% if is_mobile %} + + {% else %} + + {% endif %} + Resolved in v{{ item[2] }} + + {% else %} + Resolved in v{{ item[2] }} + {% endif %} + {% else %}Unresolved{% endif %}
      {{ item[1] }}
    5. diff --git a/templates/Release.html b/templates/Release.html index 90867cc..c4890de 100644 --- a/templates/Release.html +++ b/templates/Release.html @@ -30,12 +30,12 @@ EXTRA_HEADERS; {% if not is_mobile %} Desktop {% else %} - Desktop + Desktop {% endif %}
    6. {% if not is_mobile %} - Mobile + Mobile {% else %} Mobile {% endif %} @@ -86,7 +86,19 @@ EXTRA_HEADERS; {% for item in known_issues %}
    7. - {% if item[2] %}Resolved{% else %}Unresolved{% endif %} + {% if item[2] %} + {% if versions[item[2]] %} + {% if is_mobile %} + + {% else %} + + {% endif %} + Resolved in v{{ item[2] }} + + {% else %} + Resolved in v{{ item[2] }} + {% endif %} + {% else %}Unresolved{% endif %}
      {{ item[1] }}