...
  View open merge request
Commits (2)
......@@ -6,3 +6,5 @@ __pycache__
/docs
/utils/new-devices-stats/pmaports/
/pmaports
\ No newline at end of file
import collections
import configparser
from glob import glob
import logo
import markdown
import os
......@@ -159,6 +162,62 @@ def static_page(page):
], extension_configs={"markdown.extensions.toc": {"anchorlink": True}})
return render_template('page.html', **data)
def parse_deviceinfo(path):
with open(path) as handle:
raw = handle.read()
result = {}
for line in raw.splitlines():
if line.startswith('#') or line.strip() == "":
continue
try:
key, value = line.strip().split('=', maxsplit=1)
key = key.replace('deviceinfo_', '')
value = value.replace('"', '')
result[key] = value
except Exception as e:
pass
return result
@app.route('/device/')
def devices():
manufacturer_devices = {}
for path in glob('pmaports/device/*/deviceinfo'):
info = parse_deviceinfo(path)
manufacturer = info['manufacturer']
if manufacturer not in manufacturer_devices:
manufacturer_devices[manufacturer] = []
manufacturer_devices[manufacturer].append(info)
sort_dev = collections.OrderedDict(sorted(manufacturer_devices.items()))
return render_template('devices.html', manufacturer_devices=sort_dev)
@app.route('/device/<codename>')
def device(codename):
path = 'pmaports/device/device-{}/deviceinfo'.format(codename)
info = parse_deviceinfo(path)
hwtest_path = 'pmaports/device/device-{}/hwtest.ini'.format(codename)
hwtest = None
if os.path.isfile(hwtest_path):
hwtest = {}
hwtest_parser = configparser.ConfigParser()
hwtest_parser.read(hwtest_path)
for section in hwtest_parser.sections():
if section == "hwtest":
continue
hwtest[section] = []
for component in hwtest_parser.items(section):
hwtest[section].append({'model': component[0], 'status': component[1]})
print(component)
return render_template('device.html', info=info, hwtest=hwtest)
@app.route('/<slug>/')
def wiki_redirect(slug):
......
.title h1 {
grid-area: title;
margin: 60px 0;
font-size: 30pt;
text-align: center;
line-height: 50pt;
display: block;
}
.grid {
display: grid;
grid-template-areas: "text . side";
grid-template-columns: 1fr 20px 250px;
align-items: start;
}
.grid-text {
grid-area: text;
}
.grid-side {
grid-area: side;
background: rgba(255, 255, 255, 0.5);
border: 1px solid #ccc;
font-size: 0.9em;
}
.grid-side img,
.grid-side video {
max-width: 100%;
}
.grid-side table {
width: 100%;
}
.grid-text table {
background: rgba(255, 255, 255, 0.5);
border: 1px solid #ccc;
width: 100%;
border-collapse: collapse;
}
.grid-text table th {
text-align: left;
font-size: 0.8em;
padding: 5px;
}
.grid-text table td {
padding: 5px;
line-height: 1;
}
.grid-text table .category-row td {
border-top: 1px solid #ccc;
}
.grid-side table th {
font-size: 0.9em;
text-align: left;
}
table .subhead {
text-align: center;
font-weight: bold;
border-bottom: 1px solid #ccc;
}
\ No newline at end of file
{% extends 'base.html' %}
{% block title %}postmarketOS // {{ info.name }}{% endblock %}
{% block extra_link %}
<link rel="stylesheet" href="/static/css/device.css">
{% endblock %}
{% block body %}
<div class="title">
<h1>{{ info.name }}</h1>
</div>
<div class="separator"></div>
<article class="content alt">
<div class="grid">
<div class="grid-text">
wiki text here
{% if hwtest %}
<h2>Hardware test results</h2>
<table>
<tr>
<th>Category</th>
<th>Model</th>
<th>Status</th>
</tr>
{% for category, components in hwtest.items() %}
<tr class="category-row">
<td rowspan="{{ components|length }}">{{ category }}</td>
<td>{{ components[0].model }}</td>
<td>{{ components[0].status }}</td>
</tr>
{% for component in components[1:] %}
<tr>
<td>{{ component.model }}</td>
<td>{{ component.status }}</td>
</tr>
{% endfor %}
{% endfor %}
</table>
{% endif %}
</div>
<div class="grid-side">
<table class="infotable">
<tr>
<th>Codename</th>
<td>{{ info.codename }}</td>
</tr>
<tr>
<th>Manufacturer</th>
<td>{{ info.manufacturer }}</td>
</tr>
<tr>
<td colspan="2" class="subhead">Hardware</td>
</tr>
<tr>
<th>Architecture</th>
<td>{{ info.arch }}</td>
</tr>
<tr>
<th>Screen</th>
<td>{{ info.screen_width }}x{{ info.screen_height }}</td>
</tr>
</table>
</div>
</div>
</article>
{% endblock %}
{% extends 'base.html' %}
{% block title %}postmarketOS // devices{% endblock %}
{%block extra_link %}
<link rel="stylesheet" href="/static/css/devices.css">
{%endblock%}
{% block body %}
{% for manufacturer, devices in manufacturer_devices.items() %}
<div class="content {% if loop.index is divisibleby 2 %}alt{% endif %}">
<h2>{{ manufacturer }}</h2>
{% for device in devices %}
<div class="device">
<a class="title" href="{{ url_for('device', codename=device.codename) }}">{{ device.name }}</a>
</div>
{% endfor %}
</div>
{% if not loop.last %}
<div class="separator"></div>
{% endif %}
{% endfor %}
{% endblock %}