[Pkg-debile-commits] [debile-web] 02/04: add the support of the prefix search
Sylvestre Ledru
sylvestre at moszumanska.debian.org
Wed Dec 18 10:56:40 UTC 2013
This is an automated email from the git hooks/post-receive script.
sylvestre pushed a commit to branch update-usuability
in repository debile-web.
commit e54781946a8604f2f92f6ab9cf25a2f4c13adfd8
Author: Sylvestre Ledru <sylvestre at debian.org>
Date: Tue Dec 17 21:19:34 2013 +0100
add the support of the prefix search
---
debileweb/blueprints/consts.py | 28 ++++++++++++++++++++++++++
debileweb/blueprints/frontend.py | 43 +++++++++++++++++++++++++++++++++++++++-
templates/index.html | 8 ++++++++
templates/macros.inc.html | 10 ++++++++++
templates/prefix.html | 8 ++++++++
templates/prefix_list.html | 37 ++++++++++++++++++++++++++++++++++
templates/search.html | 3 ++-
7 files changed, 135 insertions(+), 2 deletions(-)
diff --git a/debileweb/blueprints/consts.py b/debileweb/blueprints/consts.py
new file mode 100644
index 0000000..145c92f
--- /dev/null
+++ b/debileweb/blueprints/consts.py
@@ -0,0 +1,28 @@
+# Copyright (c) 2013 Sylvestre Ledru <sylvestre at debian.org>
+#
+# Permission is hereby granted, free of charge, to any person obtaining a
+# copy of this software and associated documentation files (the "Software"),
+# to deal in the Software without restriction, including without limitation
+# the rights to use, copy, modify, merge, publish, distribute, sublicense,
+# and/or sell copies of the Software, and to permit persons to whom the
+# Software is furnished to do so, subject to the following conditions:
+#
+# The above copyright notice and this permission notice shall be included in
+# all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+# DEALINGS IN THE SOFTWARE.
+
+PREFIXES_DEFAULT = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e',
+ 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'lib3', 'liba', 'libb',
+ 'libc', 'libd', 'libe', 'libf', 'libg', 'libh', 'libi',
+ 'libj', 'libk', 'libl', 'libm', 'libn', 'libo', 'libp',
+ 'libq', 'libr', 'libs', 'libt', 'libu', 'libv', 'libw',
+ 'libx', 'liby', 'libz', 'm', 'n', 'o', 'p', 'q', 'r', 's',
+ 't', 'u', 'v', 'w', 'x', 'y', 'z']
+
diff --git a/debileweb/blueprints/frontend.py b/debileweb/blueprints/frontend.py
index 9dc9c53..b5bb207 100644
--- a/debileweb/blueprints/frontend.py
+++ b/debileweb/blueprints/frontend.py
@@ -24,6 +24,7 @@ from flask import Blueprint, render_template, send_file, request, redirect
from flask.ext.jsonpify import jsonify
from sqlalchemy.orm import joinedload
+from sqlalchemy.sql.expression import bindparam
from debilemaster.orm import Source, Binary, Machine, User, Job, Group
from debilemaster.config import Config
@@ -37,6 +38,7 @@ from datetime import timedelta
import datetime as dt
import os.path
from forms import SearchPackageForm
+from consts import PREFIXES_DEFAULT
frontend = Blueprint('frontend', __name__, template_folder='templates')
@@ -70,6 +72,15 @@ def location_display(obj):
obj['point']['line'])
+
+def get_packages_prefixes():
+ """
+ returns the packages prefixes (a, b, ..., liba, libb, ..., y, z)
+ Note that this could be computed from the database ... but since we
+ are rebuilding Debian, we will have all letters + lib*
+ """
+ return PREFIXES_DEFAULT
+
def get_package_link(p):
if p.type == "source":
return "/source/%s/%s/%s/%s" % (p.user.login, p.name, p.version, p.run)
@@ -104,13 +115,15 @@ def index():
.count()
form = SearchPackageForm()
+ packages_prefixes = get_packages_prefixes()
+
return render_template('index.html', **{
"active_jobs_info": active_jobs_info,
"pending_jobs": pending_jobs,
+ "packages_prefixes": packages_prefixes,
"form": form
})
-
@frontend.route("/sources/")
def source_list():
session = Session()
@@ -136,6 +149,34 @@ def source_list():
})
+
+ at frontend.route("/prefix/<prefix_id>/")
+ at frontend.route("/prefix/<prefix_id>/<page>/")
+def prefix_list(prefix_id, page=0):
+ page = int(page)
+
+ # FIXME : unsafe code, catch exceptions
+ session = Session()
+ sources = session.query(Source)\
+ .filter(Source.name.startswith(prefix_id))\
+ .distinct(Source.name)\
+ .order_by(Source.name.desc())
+
+
+
+ sources_info = []
+ for s in sources:
+ info = {}
+ info['source'] = s
+ info['source_link'] = "/source/%s/%s/%s/%s" % (s.user.login, s.name, "latest", s.run)
+ sources_info.append(info)
+
+ return render_template('prefix.html', **{
+ "sources": sources_info,
+ "prefix": prefix_id,
+ "page": page,
+ })
+
@frontend.route("/group/<group_id>/")
@frontend.route("/group/<group_id>/<page>/")
def group_list(group_id, page=0):
diff --git a/templates/index.html b/templates/index.html
index ec0da63..e35b324 100644
--- a/templates/index.html
+++ b/templates/index.html
@@ -1,11 +1,15 @@
{% extends "base.html" %}
+{% import "macros.inc.html" as macros %}
+
{% block title %}About{% endblock %}
{% block content %}
This experimental infrastructure aims to provide a generic rebuild platform.<br />
Normal build, custom builds (clang based) or static analyzers (coccinelle, scan-build, etc) are managed through this infrastructure.<br /><br />
+
+<b>Work in progress</b>
{% include "search.html" %}
<br />
@@ -15,6 +19,10 @@ Normal build, custom builds (clang based) or static analyzers (coccinelle, scan-
<h1>Pending jobs</h1><br />
There are currently {{pending_jobs}} jobs to assign.<br />
+<br />
+Browse by prefix:
+{{ macros.render_packages_prefixes(packages_prefixes) }}
+<br />
<br />Last
<a href = '/sources' >uploads</a>
diff --git a/templates/macros.inc.html b/templates/macros.inc.html
new file mode 100644
index 0000000..a9e6459
--- /dev/null
+++ b/templates/macros.inc.html
@@ -0,0 +1,10 @@
+
+{% macro render_packages_prefixes(prefixes) %}
+ {%- for prefix in prefixes %}
+{# <a href="{{ url_for('prefix_html', prefix=prefix) }}">{{ prefix }}</a>
+#}
+ <a href="/prefix/{{ prefix }}">{{ prefix }}</a>
+
+ {%- endfor %}
+{% endmacro %}
+
diff --git a/templates/prefix.html b/templates/prefix.html
new file mode 100644
index 0000000..2ca7396
--- /dev/null
+++ b/templates/prefix.html
@@ -0,0 +1,8 @@
+{% extends "base.html" %}
+
+{% block title %}Package List{% endblock %}
+
+{% block content %}
+ <h1>Package list: prefix '{{prefix}}'</h1>
+ {% include "prefix_list.html" %}
+{% endblock %}
diff --git a/templates/prefix_list.html b/templates/prefix_list.html
new file mode 100644
index 0000000..42ae93c
--- /dev/null
+++ b/templates/prefix_list.html
@@ -0,0 +1,37 @@
+ <table class = 'zebra'>
+ <tr>
+ <th>What</th>
+ <th>Latest version</th>
+{# <th>Uploader</th>
+ <th>Status</th>#}
+ </tr>
+{% for info in sources %}
+ <tr>
+ <td>
+ <a href = '{{info.source_link}}' >
+{{info.source.name}}
+</td>
+<td>
+{{info.source.version}}
+</td>
+
+{# {{info.source.name}}/{{info.source.version}}{% if info.source.run > 1 %} - run {{info.source.run}}{% endif %}
+
+ </a>
+ </td>
+ <td>
+ {% if info.source.group %}
+ <a href = '{{info.group_link}}' >
+ {{info.source.group.name}}
+ </a>
+ {% endif %}
+ </td>
+ <td>
+ <a href = '{{info.user_link}}' >
+ {{info.source.user.name}}
+ </a>
+ </td>
+ </tr>
+#}
+{% endfor %}
+ </table>
diff --git a/templates/search.html b/templates/search.html
index 083a727..64e5870 100644
--- a/templates/search.html
+++ b/templates/search.html
@@ -33,11 +33,12 @@
<input type="submit" value="Search" /></div>
</form>
</td></tr>
+<!--
<tr><td>By maintainer</td><td>
<form id="searchPackageForm" action="/package/">
<div class="ui-widget">
{{form.maintainer(size=20)}} <input type="submit" value="Search" />
</div>
</form>
-</td></tr>
+</td></tr>-->
</table>
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-debile/debile-web.git
More information about the Pkg-debile-commits
mailing list