зеркало из https://github.com/mozilla/relnotes.git
final hacks to get it generating correctly
This commit is contained in:
Родитель
8d01bcd096
Коммит
d039c34d0e
60
run.py
60
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,16 +24,34 @@ 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
|
||||
(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,))
|
||||
(product_id, product_text) = c.fetchone()
|
||||
|
@ -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 = '%s.%s' % (version, sub_version)
|
||||
if channel_name == 'Aurora':
|
||||
version_text = version_text + aurora_suffix
|
||||
relname = 'auroranotes'
|
||||
elif ch == 'Beta':
|
||||
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()
|
||||
|
||||
|
|
|
@ -19,12 +19,12 @@ EXTRA_HEADERS;
|
|||
{% if not is_mobile %}
|
||||
<span>Desktop</span>
|
||||
{% else %}
|
||||
<a href="/firefox/{{ version }}/auroranotes/">Desktop</a>
|
||||
<a href="/{{ versions[version]['desktop-url'] }}">Desktop</a>
|
||||
{% endif %}
|
||||
</li>
|
||||
<li>
|
||||
{% if not is_mobile %}
|
||||
<a href="/mobile/{{ version }}/auroranotes/">Mobile</a>
|
||||
<a href="/{{ versions[version]['mobile-url'] }}">Mobile</a>
|
||||
{% else %}
|
||||
<span>Mobile</span>
|
||||
{% endif %}
|
||||
|
@ -75,7 +75,19 @@ EXTRA_HEADERS;
|
|||
{% for item in known_issues %}
|
||||
<li>
|
||||
<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>
|
||||
<h5>
|
||||
{{ item[1] }}
|
||||
|
@ -95,7 +107,7 @@ EXTRA_HEADERS;
|
|||
<h3>Try Firefox Aurora</h3>
|
||||
<ol>
|
||||
<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 »
|
||||
</a>
|
||||
</li>
|
||||
|
|
|
@ -30,12 +30,12 @@ EXTRA_HEADERS;
|
|||
{% if not is_mobile %}
|
||||
<span>Desktop</span>
|
||||
{% else %}
|
||||
<a href="/firefox/{{ version }}/releasenotes/">Desktop</a>
|
||||
<a href="/{{ versions[version]['desktop-url'] }}">Desktop</a>
|
||||
{% endif %}
|
||||
</li>
|
||||
<li>
|
||||
{% if not is_mobile %}
|
||||
<a href="/mobile/{{ version }}/releasenotes/">Mobile</a>
|
||||
<a href="/{{ versions[version]['mobile-url'] }}">Mobile</a>
|
||||
{% else %}
|
||||
<span>Mobile</span>
|
||||
{% endif %}
|
||||
|
@ -86,7 +86,19 @@ EXTRA_HEADERS;
|
|||
{% for item in known_issues %}
|
||||
<li>
|
||||
<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>
|
||||
<h5>{{ item[1] }}</h5>
|
||||
</li>
|
||||
|
|
|
@ -30,12 +30,12 @@ EXTRA_HEADERS;
|
|||
{% if not is_mobile %}
|
||||
<span>Desktop</span>
|
||||
{% else %}
|
||||
<a href="/firefox/{{ version }}/releasenotes/">Desktop</a>
|
||||
<a href="/{{ versions[version]['desktop-url'] }}">Desktop</a>
|
||||
{% endif %}
|
||||
</li>
|
||||
<li>
|
||||
{% if not is_mobile %}
|
||||
<a href="/mobile/{{ version }}/releasenotes/">Mobile</a>
|
||||
<a href="/{{ versions[version]['mobile-url'] }}">Mobile</a>
|
||||
{% else %}
|
||||
<span>Mobile</span>
|
||||
{% endif %}
|
||||
|
@ -86,7 +86,19 @@ EXTRA_HEADERS;
|
|||
{% for item in known_issues %}
|
||||
<li>
|
||||
<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>
|
||||
<h5>{{ item[1] }}</h5>
|
||||
</li>
|
||||
|
|
Загрузка…
Ссылка в новой задаче