Commit 3547c8f9 authored by David Spencer's avatar David Spencer

Add detail pages

parent c7d8c961
"""
SBo Dashboard
browse.py
Render browseable maintainer and slackbuild detail pages
David Spencer 2018-08-27
See LICENCE for copyright information
"""
import logging
import globals
import stats
import utils
from slackbuilds import SBinfo
from maintainers import Maintainerinfo
from problems import Problems
#-----------------------------------------------------------------------
def render_maintainer_detail():
logging.info("started")
for mntnam in SBinfo.Maintainerinfo.items():
MaintainerDetail = [] #### temporary
utils.renderer( page_subdir="maintainers",
page_name=email, #### needs to be Unix-safe
page_title=mntnam,
template="maintainer_detail",
TemplateData=MaintainerDetail )
logging.info("finished")
#-----------------------------------------------------------------------
def render_slackbuild_detail():
logging.info("started")
for prgnam, prginfo in SBinfo.items():
catnam=prginfo["catnam"]
SlackbuildDetail = { "prgnam": prgnam,
"catnam": catnam,
"version": prginfo["version"],
"homepage": prginfo["homepage"],
"maintainer": prginfo["maintainer"],
"email": prginfo["email"]
}
utils.renderer( page_subdir="slackbuilds/"+catnam,
page_name=prgnam,
page_title=catnam+"/"+prgnam,
template="slackbuild_detail",
TemplateData=SlackbuildDetail )
logging.info("finished")
#-----------------------------------------------------------------------
......@@ -26,6 +26,8 @@ import utils
import stats
import slackbuilds
Maintainerinfo={}
#-----------------------------------------------------------------------
def repology_by_maintainer(email,sess):
......@@ -81,13 +83,13 @@ def update_maintainers():
# (1) Correlate all the names and all the emails of each
# maintainer in the following dictionaries:
#
Maintainerinfo={}
# Maintainerinfo[primary]={ "mntnams": ["secondary1","secondary2"...],
# "emails": ["email1","email2"...],
# "latest": { "date":cdate,"commit":commit } }
# where 'primary' is the primary maintainer name,
# and 'secondary' is any other name we find that shares an email with
# the primary name or any of its other secondary names.
#
# Ideally there would be only one name for each maintainer, but people
# are fickle. The primary name is just the first variant to be discovered.
# It might be obsolete or a typo, but we don't care :)
......@@ -237,7 +239,7 @@ def update_maintainers():
mntdeets["tdoutofdate"]="-"
mntdeets["tdoutofdatepct"]="-"
logging.info("finished")
logging.info("finished -- ${:d} maintainers".format(mntnum))
#-----------------------------------------------------------------------
......@@ -246,8 +248,8 @@ def render_maintainers():
Render the maintainers report page
"""
logging.info("started")
utils.renderer( page_name="maintainers",
page_subdir="reports",
utils.renderer( page_subdir="reports",
page_name="maintainers.html",
page_title="SBo Maintainers",
TemplateData=Maintainerinfo )
logging.info("finished")
......
......@@ -21,6 +21,8 @@ import utils
import stats
import slackbuilds
Problems={}
#-----------------------------------------------------------------------
def catnamprgnam(p):
......@@ -52,6 +54,7 @@ def repologyproblems(repo):
prgnam=p["name"]
catnam=slackbuilds.SBinfo[prgnam]["catnam"]
maintainer=slackbuilds.SBinfo[prgnam]["maintainer"]
email=slackbuilds.SBinfo[prgnam]["email"]
# All Repology problems currently start with "Homepage link" and
# a URL, but we'll classify any that don't as "other". To make the
......@@ -67,6 +70,7 @@ def repologyproblems(repo):
problems.append({ "prgnam": prgnam,
"catnam": catnam,
"maintainer": maintainer,
"email": email,
"problem": problem,
"description": description,
"source": "repology",
......@@ -111,8 +115,8 @@ def render_problems():
Render the problems report page
"""
logging.info("started")
utils.renderer( page_name="problems",
page_subdir="reports",
utils.renderer( page_subdir="reports",
page_name="problems.html",
page_title="SBo Problems",
TemplateData=Problems )
logging.info("finished")
......
......@@ -34,9 +34,13 @@ update_security_problems()
update_build_problems()
render_problems()
from support import render_index, render_support
render_index()
from details import render_maintainer_detail, render_slackbuild_detail
render_maintainer_detail()
render_slackbuild_detail()
from support import render_support, render_indexes
render_support()
render_indexes()
stats.saveStatsHistory()
......
......@@ -16,6 +16,8 @@ import logging
import globals
import stats
SBinfo={}
#-----------------------------------------------------------------------
def update_slackbuilds():
......@@ -48,9 +50,6 @@ def update_slackbuilds():
#-----------------------------------------------------------------------
# Create a dict from the SlackBuilds info files, for easy access
SBinfo={}
def read_slackbuilds_info():
"""
Read data from SlackBuilds info files into the SBinfo dict
......@@ -58,6 +57,8 @@ def read_slackbuilds_info():
logging.debug("reading .info files")
# These regexes are used >7000 times, so we might as well compile them.
re_version=re.compile(r"VERSION=\".*\"")
re_homepage=re.compile(r"HOMEPAGE=\".*\"")
re_maint=re.compile(r"MAINTAINER=\".*\"")
re_email=re.compile(r"EMAIL=\".*\"")
......@@ -76,23 +77,32 @@ def read_slackbuilds_info():
with open(infofile, "r", encoding="latin-1") as openinfo:
info = openinfo.read()
versionarray=re_version.findall(info)
homepagearray=re_homepage.findall(info)
maintainerarray=re_maint.findall(info)
emailarray=re_email.findall(info)
if len(maintainerarray) == 1 and len(emailarray) == 1:
if len(versionarray) == 1 and len(homepagearray) == 1 and len(maintainerarray) == 1 and len(emailarray) == 1:
version=versionarray[0][9:-1]
homepage=homepagearray[0][10:-1]
maintainer=maintainerarray[0][12:-1]
email=emailarray[0][7:-1]
else:
# We're not here to validate the .info files.
# If there's not exactly one MAINTAINER and EMAIL, bollocks to it.
logging.warn("{:s} has {:d} maintainers and {:d} emails".format(infofile,len(maintainerarray),len(emailarray)))
logging.warn("{:s} has duplicated entries".format(infofile))
continue
SBinfo.update({ prgnam: { "catnam": catnam, "maintainer": maintainer, "email": email} })
SBinfo.update({ prgnam: { "catnam": catnam,
"version": version,
"homepage": homepage,
"maintainer": maintainer,
"email": email
} })
if infocount != len(SBinfo):
logging.warn("{:d} duplicate prgnams in slackbuilds repo".format(infocount-len(SBinfo)))
stats.setStats("slackbuilds.count",infocount)
logging.debug("finished reading {:d} .info files".format(infocount))
logging.debug("finished -- {:d} .info files".format(infocount))
#-----------------------------------------------------------------------
......@@ -14,8 +14,6 @@ import logging
import globals
#-----------------------------------------------------------------------
Stats={}
StatsHistory={}
......
......@@ -15,15 +15,33 @@ import logging
import globals
import utils
from maintainers import Maintainerinfo
from slackbuilds import SBinfo
#-----------------------------------------------------------------------
def render_index():
def render_indexes():
"""
Render the site index page.
Render all the index pages.
"""
logging.info("started")
utils.renderer(page_name="index",page_title="SBo Dashboard Index")
utils.renderer( page_title="SBo Dashboard Index" )
Maintainerlist=[]
utils.renderer( page_subdir="maintainers",
page_title="Maintainers Index",
template="maintainers_index",
TemplateData=Maintainerlist
)
SBlist=[]
utils.renderer( page_subdir="slackbuilds",
page_title="SlackBuilds Index",
template="slackbuilds_index",
TemplateData=SBlist
)
logging.info("finished")
#-----------------------------------------------------------------------
......
......@@ -4,14 +4,17 @@
{% include 'head.jinja2' %}
<body>
{% include 'nav.jinja2' %}
<h1>{{ page_title }}</h1>
<p>Site updated: {{ page_datetime }} </p>
<h3>Reports</h3>
<ul>
<li><a href="{{ siteurl }}/reports/maintainers.html">Maintainers</a></li>
<li><a href="{{ siteurl }}/reports/problems.html">Problems</a></li>
<li><a href="{{ siteurl }}/reports/maintainers.html">Maintainers report</a></li>
<li><a href="{{ siteurl }}/reports/problems.html">Problems report</a></li>
</ul>
<h3>Details</h3>
......
<!DOCTYPE html>
<html>
{% include 'head.jinja2' %}
<body>
{% include 'nav.jinja2' %}
<section>
<h1>{{ page_title }}</h1>
<p>Email: <p>
<p><i>(list goes here)</i></p>
<p>Last commit: </p>
<p><a href="https://repology.org/metapackages/?maintainer={{ TemplateData['email'] }}" target="_blank">Repology</a></p>
<p>Problems: </p>
<p>SlackBuilds:</p>
<p><i>(list goes here)</i></p>
</section>
{% include 'footer.jinja2' %}
</body>
</html>
......@@ -4,6 +4,10 @@
{% include 'head.jinja2' %}
<body>
{% include 'nav.jinja2' %}
<section>
<h1>{{ page_title }}</h1>
<p>SlackBuilds
......@@ -47,6 +51,8 @@
</table>
</section>
{% for mntnam, mntdeets in TemplateData.items() %}
<div id="sb{{ mntdeets['mntnum'] }}" class="modal">
<div>
......
<!DOCTYPE html>
<html>
{% include 'head.jinja2' %}
<body>
{% include 'nav.jinja2' %}
<section>
<h1>{{ page_title }}</h1>
<p><i>Dummy maintainer index</i></p>
</section>
{% include 'footer.jinja2' %}
</body>
</html>
<nav>
<a href="{{ siteurl }}">home</a> | <a href="{{ siteurl }}/maintainers/">browse maintainers</a> | <a href="{{ siteurl }}/slackbuilds/">browse slackbuilds</a> |
<a href="{{ siteurl }}//reports/maintainers.html">maintainers report</a> | <a href="{{ siteurl }}/reports/problems.html">problems report</a>
</nav>
......@@ -4,11 +4,14 @@
{% include 'head.jinja2' %}
<body>
{% include 'nav.jinja2' %}
<section>
<h1>{{ page_title }}</h1>
<p>Problems: {{ "{:d}".format(Stats["problems.count"]) }}</p>
<table class="sortable">
<thead>
......@@ -27,18 +30,20 @@
{% for problem in TemplateData %}
<tr id="{{ problem['catnam']+'/'+problem['prgnam'] }}">
<td class="catnam">{{ problem['catnam'] }}</td>
<td class="prgnam"><a href="{{ siteurl }}/slackbuilds/{{ problem['catnam']+"/"+problem['prgnam'] }}" target="_blank">{{ problem['prgnam'] }}</a></td>
<td class="prgnam"><a href="{{ siteurl }}/slackbuilds/{{ problem['catnam'] }}/{{ problem['prgnam'] }}" target="_blank">{{ problem['prgnam'] }}</a></td>
<td class="source">{{ problem['source'] }}</td>
<td class="problem">{{ problem['problem'] }}</td>
<td class="description">{{ problem['description']|urlize(40,target='_blank') }}</td>
<td class="since">{{ problem['since'] }}</td>
<td class="maintainer"><a href="{{ siteurl }}/maintainers/{{ problem['maintainer'] }}" target="_blank">{{ problem['maintainer'] }}</a></td>
<td class="maintainer"><a href="{{ siteurl }}/maintainers/{{ problem['email'] }}" target="_blank">{{ problem['maintainer'] }}</a></td>
</tr>
{% endfor %}
</tbody>
</table>
</section>
{% include 'footer.jinja2' %}
</body>
......
<!DOCTYPE html>
<html>
{% include 'head.jinja2' %}
<body>
{% include 'nav.jinja2' %}
<section>
<h1>{{ page_title }}</h1>
<p>Version: {{ TemplateData['version'] }}</p>
<p>Homepage: <a href="{{ TemplateData['homepage'] }}">{{ TemplateData['homepage'] }}</a></p>
<p>Maintainer: <a href="{{ siteurl }}/maintainers/{{ TemplateData['email'] }}">{{ TemplateData['maintainer'] }} &lt;{{ TemplateData['email'] }}&gt;</a></p>
<p>Last commit: xxxx</p>
<p><a href="https://git.slackbuilds.org/slackbuilds/log/{{ TemplateData['catnam'] }}/{{ TemplateData['prgnam'] }}" target="_blank">Commit history</a></p>
<p><a href="https://slackbuilds.org/repository/14.2/{{ TemplateData['catnam'] }}/{{ TemplateData['prgnam'] }}/" target="_blank">SBo website</a></p>
<p><a href="https://repology.org/metapackages/?search={{ TemplateData['prgnam'] }}" target="_blank">Repology</a></p>
<p>Problems: xxxx</p>
<p>Build logs: xxxx</p>
</section>
{% include 'footer.jinja2' %}
</body>
</html>
<!DOCTYPE html>
<html>
{% include 'head.jinja2' %}
<body>
{% include 'nav.jinja2' %}
<section>
<h1>{{ page_title }}</h1>
<p><i>Dummy slackbuild index</i></p>
</section>
{% include 'footer.jinja2' %}
</body>
</html>
......@@ -53,21 +53,27 @@ def unspamtrap(address):
#-----------------------------------------------------------------------
def renderer( page_name,
page_subdir="",
def renderer( page_subdir="",
page_name="index.html",
page_title="",
template="",
TemplateData=[] ):
TemplateData=None ):
"""
Render a page
"""
if page_title == "":
page_title = page_name.capitalize()
if page_name.endswith(".html"):
page_title = page_name[:-5].capitalize()
else:
page_title = page_name.capitalize()
if template == "":
template = page_name
if page_name.endswith(".html"):
template = page_name[:-5]
else:
template = page_name
page_path=os.path.join(globals.sitedir,page_subdir,page_name+".html")
page_path=os.path.join(globals.sitedir,page_subdir,page_name)
os.makedirs(os.path.dirname(page_path),exist_ok=True)
jenv = jinja2.Environment(loader=jinja2.FileSystemLoader(globals.templatesdir),autoescape=None)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment