final hacks to get it generating correctly

This commit is contained in:
James Long 2012-01-26 15:43:07 -05:00
Родитель 8d01bcd096
Коммит d039c34d0e
4 изменённых файлов: 89 добавлений и 35 удалений

68
run.py
Просмотреть файл

@ -2,8 +2,9 @@
import sys import sys
import sqlite3 import sqlite3
import jinja2
import os import os
from datetime import datetime
import jinja2
conn = sqlite3.connect('relnotes.sqlite') conn = sqlite3.connect('relnotes.sqlite')
c = conn.cursor() c = conn.cursor()
@ -23,15 +24,33 @@ beta_suffix = 'beta'
channel_info = {} channel_info = {}
def cache_channels(): 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 ' '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() data = c.fetchall()
for record in data: for record in data:
(version, sub_version, channel) = record (version, sub_version, channel, product) = record
channel_info[channel] = {'version': version, if channel not in channel_info:
'sub_version': sub_version} 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): def publish_channel(product_name, channel_name):
c.execute('SELECT id, product_text FROM Products WHERE product_name=? LIMIT 1', (product_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)) (product_id, version, version, channel_id, version, version, channel_id))
known_issues = c.fetchall() known_issues = c.fetchall()
for ch, vs in channel_info.iteritems(): version_text = '%s.%s' % (version, sub_version)
relname = 'releasenotes' if channel_name == 'Aurora':
version_text = '%s.%s' % (vs['version'], vs['sub_version']) version_text = version_text + aurora_suffix
if ch == 'Aurora': elif channel_name == 'Beta':
version_text = version_text + aurora_suffix version_text = version_text + beta_suffix
relname = 'auroranotes'
elif ch == 'Beta':
version_text = version_text + beta_suffix
if product == 'Firefox': is_mobile = (product_name == 'Firefox for mobile')
channel_info[ch]['url'] = 'en-US/firefox/%s/%s' % (version_text, relname) out_dir = channel_info[channel_name]['mobile-url' if is_mobile else 'desktop-url']
else: out_file = '%s/index.html' % out_dir
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']
try: try:
os.makedirs(os.path.join(out_base, out_dir)); 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')) env = jinja2.Environment(loader=jinja2.FileSystemLoader('templates'))
tmpl = env.get_template(channel_name + '.html') 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: 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, 'release_date': release_date,
'version': version_text, 'version_text': version_text,
'version': version,
'whats_new': whats_new, 'whats_new': whats_new,
'fixed': fixed, 'fixed': fixed,
'known_issues': known_issues, 'known_issues': known_issues,
'release_text': release_text, 'release_text': release_text,
'product_text': product_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() cache_channels()

Просмотреть файл

@ -19,12 +19,12 @@ EXTRA_HEADERS;
{% if not is_mobile %} {% if not is_mobile %}
<span>Desktop</span> <span>Desktop</span>
{% else %} {% else %}
<a href="/firefox/{{ version }}/auroranotes/">Desktop</a> <a href="/{{ versions[version]['desktop-url'] }}">Desktop</a>
{% endif %} {% endif %}
</li> </li>
<li> <li>
{% if not is_mobile %} {% if not is_mobile %}
<a href="/mobile/{{ version }}/auroranotes/">Mobile</a> <a href="/{{ versions[version]['mobile-url'] }}">Mobile</a>
{% else %} {% else %}
<span>Mobile</span> <span>Mobile</span>
{% endif %} {% endif %}
@ -75,7 +75,19 @@ EXTRA_HEADERS;
{% for item in known_issues %} {% for item in known_issues %}
<li> <li>
<span class="tag tag-{% if item[2] %}resolved{% else %}unresolved{% endif %}"> <span class="tag tag-{% if item[2] %}resolved{% else %}unresolved{% endif %}">
{% if item[2] %}Resolved{% else %}Unresolved{% endif %} {% if item[2] %}
{% if versions[item[2]] %}
{% if is_mobile %}
<a href="/{{ versions[item[2]]['mobile-url'] }}">
{% else %}
<a href="/{{ versions[item[2]]['desktop-url'] }}">
{% endif %}
Resolved in v{{ item[2] }}
</a>
{% else %}
Resolved in v{{ item[2] }}
{% endif %}
{% else %}Unresolved{% endif %}
</span> </span>
<h5> <h5>
{{ item[1] }} {{ item[1] }}
@ -95,7 +107,7 @@ EXTRA_HEADERS;
<h3>Try Firefox Aurora</h3> <h3>Try Firefox Aurora</h3>
<ol> <ol>
<li id="try1"> <li id="try1">
<a href="{% if is_mobile %}/mobile/platforms/{% else %}/firefox/{{ version }}/system-requirements/{% endif %}"> <a href="{% if is_mobile %}/mobile/platforms/{% else %}/firefox/{{ version_text }}/system-requirements/{% endif %}">
Check » Check »
</a> </a>
</li> </li>

Просмотреть файл

@ -30,12 +30,12 @@ EXTRA_HEADERS;
{% if not is_mobile %} {% if not is_mobile %}
<span>Desktop</span> <span>Desktop</span>
{% else %} {% else %}
<a href="/firefox/{{ version }}/releasenotes/">Desktop</a> <a href="/{{ versions[version]['desktop-url'] }}">Desktop</a>
{% endif %} {% endif %}
</li> </li>
<li> <li>
{% if not is_mobile %} {% if not is_mobile %}
<a href="/mobile/{{ version }}/releasenotes/">Mobile</a> <a href="/{{ versions[version]['mobile-url'] }}">Mobile</a>
{% else %} {% else %}
<span>Mobile</span> <span>Mobile</span>
{% endif %} {% endif %}
@ -86,7 +86,19 @@ EXTRA_HEADERS;
{% for item in known_issues %} {% for item in known_issues %}
<li> <li>
<span class="tag tag-{% if item[2] %}resolved{% else %}unresolved{% endif %}"> <span class="tag tag-{% if item[2] %}resolved{% else %}unresolved{% endif %}">
{% if item[2] %}<a href="/{{ urls[item[2]] }}">Resolved in v{{ item[2] }}</a>{% else %}Unresolved{% endif %} {% if item[2] %}
{% if versions[item[2]] %}
{% if is_mobile %}
<a href="/{{ versions[item[2]]['mobile-url'] }}">
{% else %}
<a href="/{{ versions[item[2]]['desktop-url'] }}">
{% endif %}
Resolved in v{{ item[2] }}
</a>
{% else %}
Resolved in v{{ item[2] }}
{% endif %}
{% else %}Unresolved{% endif %}
</span> </span>
<h5>{{ item[1] }}</h5> <h5>{{ item[1] }}</h5>
</li> </li>

Просмотреть файл

@ -30,12 +30,12 @@ EXTRA_HEADERS;
{% if not is_mobile %} {% if not is_mobile %}
<span>Desktop</span> <span>Desktop</span>
{% else %} {% else %}
<a href="/firefox/{{ version }}/releasenotes/">Desktop</a> <a href="/{{ versions[version]['desktop-url'] }}">Desktop</a>
{% endif %} {% endif %}
</li> </li>
<li> <li>
{% if not is_mobile %} {% if not is_mobile %}
<a href="/mobile/{{ version }}/releasenotes/">Mobile</a> <a href="/{{ versions[version]['mobile-url'] }}">Mobile</a>
{% else %} {% else %}
<span>Mobile</span> <span>Mobile</span>
{% endif %} {% endif %}
@ -86,7 +86,19 @@ EXTRA_HEADERS;
{% for item in known_issues %} {% for item in known_issues %}
<li> <li>
<span class="tag tag-{% if item[2] %}resolved{% else %}unresolved{% endif %}"> <span class="tag tag-{% if item[2] %}resolved{% else %}unresolved{% endif %}">
{% if item[2] %}Resolved{% else %}Unresolved{% endif %} {% if item[2] %}
{% if versions[item[2]] %}
{% if is_mobile %}
<a href="/{{ versions[item[2]]['mobile-url'] }}">
{% else %}
<a href="/{{ versions[item[2]]['desktop-url'] }}">
{% endif %}
Resolved in v{{ item[2] }}
</a>
{% else %}
Resolved in v{{ item[2] }}
{% endif %}
{% else %}Unresolved{% endif %}
</span> </span>
<h5>{{ item[1] }}</h5> <h5>{{ item[1] }}</h5>
</li> </li>