...
 
Commits (3)
"""
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")
#-----------------------------------------------------------------------
This diff is collapsed.
......@@ -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,10 +115,10 @@ 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",
Table=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))
#-----------------------------------------------------------------------
User-agent: *
Disallow: /
......@@ -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")
#-----------------------------------------------------------------------
......@@ -34,7 +52,14 @@ def render_support():
"""
logging.info("started")
subprocess.run(
"rsync -a --delete support/ {:s}/support/".format(globals.sitedir),
"cp -a static/robots.txt {:s}/robots.txt".format(globals.sitedir),
shell=True,
cwd=globals.dashdir,
check=True,
stdout=subprocess.DEVNULL
)
subprocess.run(
"rsync -a --delete static/support/ {:s}/support/".format(globals.sitedir),
shell=True,
cwd=globals.dashdir,
check=True,
......
<footer>
<p>Page updated: {{ page_datetime }}</p>
</footer>
......@@ -4,20 +4,23 @@
{% include 'head.jinja2' %}
<body>
{% include 'nav.jinja2' %}
<h1>{{ page_title }}</h1>
<p>Updated: {{ page_datetime }}</p>
<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>
<ul>
<li><a href="{{ siteurl }}/maintainers/">Maintainers</a></li>
<li><a href="{{ siteurl }}/slackbuilds/">SlackBuilds</a></li>
<li><a href="{{ siteurl }}/maintainers/">Browse Maintainer details</a></li>
<li><a href="{{ siteurl }}/slackbuilds/">Browse SlackBuild details</a></li>
</ul>
</body>
......
<!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,9 +4,11 @@
{% include 'head.jinja2' %}
<body>
<h1>{{ page_title }}</h1>
<p>Updated: {{ page_datetime }}</p>
{% include 'nav.jinja2' %}
<section>
<h1>{{ page_title }}</h1>
<p>SlackBuilds
<br>&nbsp;&nbsp;&nbsp;total: {{ "{:d}".format(Stats["slackbuilds.count"]) }}
......@@ -34,30 +36,34 @@
</thead>
<tbody>
{% for mname, mdeets in Table|dictsort(true) %}
<tr id="m{{ mdeets['mnum'] }}" class="{{ 'm-'+mdeets['status'] }}">
<td class="m">{{ mdeets["tdmaintainer"] }}</td>
<td class="l">{{ mdeets["tdlatest"] }}</td>
<td class="s"><a href="#sb{{ mdeets["mnum"] }}">{{ mdeets["tdslackbuilds"] }}</a></td>
<td class="n">{{ mdeets["tdnewest"] }}</td>
<td class="np">{{ mdeets["tdnewestpct"] }}</td>
<td class="o">{{ mdeets["tdoutofdate"] }}</td>
<td class="op">{{ mdeets["tdoutofdatepct"] }}</td>
{% for mntnam, mntdeets in TemplateData|dictsort(true) %}
<tr id="m{{ mntdeets['mntnum'] }}" class="{{ 'm-'+mntdeets['status'] }}">
<td class="m">{{ mntdeets["tdmaintainer"] }}</td>
<td class="l">{{ mntdeets["tdlatest"] }}</td>
<td class="s"><a href="#sb{{ mntdeets["mntnum"] }}">{{ mntdeets["tdslackbuilds"] }}</a></td>
<td class="n">{{ mntdeets["tdnewest"] }}</td>
<td class="np">{{ mntdeets["tdnewestpct"] }}</td>
<td class="o">{{ mntdeets["tdoutofdate"] }}</td>
<td class="op">{{ mntdeets["tdoutofdatepct"] }}</td>
</tr>
{% endfor %}
</tbody>
</table>
{% for mname, mdeets in Table.items() %}
<div id="sb{{ mdeets['mnum'] }}" class="modal">
</section>
{% for mntnam, mntdeets in TemplateData.items() %}
<div id="sb{{ mntdeets['mntnum'] }}" class="modal">
<div>
<a href="#close" title="Close" class="closebutton">&otimes;</a>
<h3>{{ mname }}</h3>
<p class="t">{{ mdeets["slackbuilds"]|sort|join("<br>") }}</p>
<h3>{{ mntnam }}</h3>
<p class="t">{{ mntdeets["slackbuilds"]|sort|join("<br>") }}</p>
</div>
</div>
{% endfor %}
{% include 'footer.jinja2' %}
</body>
</html>
<!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,12 +4,13 @@
{% include 'head.jinja2' %}
<body>
<h1>{{ page_title }}</h1>
<p>Updated: {{ page_datetime }}</p>
{% include 'nav.jinja2' %}
<p>Problems: {{ "{:d}".format(Stats["problems.count"]) }}</p>
<section>
<h1>{{ page_title }}</h1>
<p>Problems: {{ "{:d}".format(Stats["problems.count"]) }}</p>
<table class="sortable">
......@@ -26,20 +27,24 @@
</thead>
<tbody>
{% for problem in Table %}
{% 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>
</html>
<!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,22 +53,31 @@ def unspamtrap(address):
#-----------------------------------------------------------------------
def renderer( page_name,
page_subdir="",
def renderer( page_subdir="",
page_name="index.html",
page_title="",
Table=[] ):
template="",
TemplateData=None ):
"""
Render a page
"""
if page_title == "":
page_title = page_name.capitalize()
page_path=os.path.join(globals.sitedir,page_subdir,page_name+".html")
if page_name.endswith(".html"):
page_title = page_name[:-5].capitalize()
else:
page_title = page_name.capitalize()
if template == "":
if page_name.endswith(".html"):
template = page_name[:-5]
else:
template = page_name
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)
mytemplate = jenv.get_template(page_name+".jinja2")
mytemplate = jenv.get_template(template+".jinja2")
with open(page_path,"w",encoding="utf-8") as page_file:
print(
......@@ -76,7 +85,7 @@ def renderer( page_name,
siteurl=globals.siteurl,
page_title=page_title,
page_datetime=globals.updateref.strftime("%Y-%m-%d %T %Z"),
Table=Table,
TemplateData=TemplateData,
Stats=stats.Stats
),
file=page_file
......