Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Nicer visual look for the web-page

  • Loading branch information...
commit 279eddd883333151ac984c0f018ee53dadda489d 1 parent 7c08af8
@exhuma authored
View
1  MANIFEST.in
@@ -1,4 +1,5 @@
recursive-include mypi/templates *
+recursive-include mypi/static *
recursive-include mod_wsgi *
recursive-include db_repo *.sql *.py *.cfg README
include README.rst
View
113 mypi/db.py
@@ -56,62 +56,6 @@ def rebind(uri, echo=False):
#doc="Defines access rights to packages for users"
)
-class Package(Base):
- __tablename__ = 'package'
-
- name = Column(String, primary_key=True)
- inserted = Column(DateTime, nullable=False, default=datetime.now)
- updated = Column(DateTime, nullable=False, default=datetime.now)
-
- users = relationship("User", secondary=package_auth, backref="packages")
- releases = relationship('Release')
-
- @classmethod
- def get_or_add(self, session, name):
- """
- Return a package reference. If the package does not yet exist, create a
- new one and return that one
- """
- q = session.query(Package)
- q = q.filter(Package.name == name)
- proj = q.first()
- if proj:
- return proj
-
- proj = Package(name)
- session.add(proj)
- return proj
-
- @classmethod
- def get(self, session, name):
- """
- Return a package reference
- """
- q = session.query(Package)
- q = q.filter(Package.name == name)
- proj = q.first()
- return proj
-
- @classmethod
- def all(self, session):
- """
- Return a list of packages
- """
- q = session.query(Package)
- q = q.order_by(Package.name)
- return q
-
- def __init__(self, name):
- self.name = name
-
- def __eq__(self, other):
-
- if not isinstance(other, Package):
- return False
-
- return other.name == self.name and other.author_email == self.author_email
-
-
class User(Base):
__tablename__ = 'user'
@@ -180,6 +124,7 @@ class Release(Base):
)
files = relationship('File')
+ author = relationship('User')
package = Column(String, ForeignKey('package.name'))
license = Column(String)
@@ -282,6 +227,62 @@ def __eq__(self, other):
and self.version == other.version)
+class Package(Base):
+ __tablename__ = 'package'
+
+ name = Column(String, primary_key=True)
+ inserted = Column(DateTime, nullable=False, default=datetime.now)
+ updated = Column(DateTime, nullable=False, default=datetime.now)
+
+ users = relationship("User", secondary=package_auth, backref="packages")
+ releases = relationship('Release', order_by=Release.updated.desc())
+
+ @classmethod
+ def get_or_add(self, session, name):
+ """
+ Return a package reference. If the package does not yet exist, create a
+ new one and return that one
+ """
+ q = session.query(Package)
+ q = q.filter(Package.name == name)
+ proj = q.first()
+ if proj:
+ return proj
+
+ proj = Package(name)
+ session.add(proj)
+ return proj
+
+ @classmethod
+ def get(self, session, name):
+ """
+ Return a package reference
+ """
+ q = session.query(Package)
+ q = q.filter(Package.name == name)
+ proj = q.first()
+ return proj
+
+ @classmethod
+ def all(self, session):
+ """
+ Return a list of packages
+ """
+ q = session.query(Package)
+ q = q.order_by(Package.name)
+ return q
+
+ def __init__(self, name):
+ self.name = name
+
+ def __eq__(self, other):
+
+ if not isinstance(other, Package):
+ return False
+
+ return other.name == self.name and other.author_email == self.author_email
+
+
class File(Base):
__tablename__ = "file"
__table_args__ = (
View
108 mypi/static/style.css
@@ -0,0 +1,108 @@
+BODY{
+ margin: 0;
+ padding: 0;
+}
+
+BODY>H1:first-child {
+ margin: 0;
+ padding: 0.2em 1em;
+ font-family: 'Fondamento', sans-serif;
+ color: #ffa;
+
+ background-image: linear-gradient(bottom, rgb(39,65,87) 28%, rgb(54,90,122) 73%);
+ background-image: -o-linear-gradient(bottom, rgb(39,65,87) 28%, rgb(54,90,122) 73%);
+ background-image: -moz-linear-gradient(bottom, rgb(39,65,87) 28%, rgb(54,90,122) 73%);
+ background-image: -webkit-linear-gradient(bottom, rgb(39,65,87) 28%, rgb(54,90,122) 73%);
+ background-image: -ms-linear-gradient(bottom, rgb(39,65,87) 28%, rgb(54,90,122) 73%);
+
+ background-image: -webkit-gradient(
+ linear,
+ left bottom,
+ left top,
+ color-stop(0.28, rgb(39,65,87)),
+ color-stop(0.73, rgb(54,90,122))
+ );
+
+ -webkit-box-shadow: 2px 2px 2px 2px rgba(0, 0, 0, 0.3);
+ -moz-box-shadow: 2px 2px 2px 2px rgba(0, 0, 0, 0.3);
+ box-shadow: 2px 2px 2px 2px rgba(0, 0, 0, 0.3);
+
+ text-shadow: -1px -1px 2px #000000;
+ filter: dropshadow(color=#000000, offx=-1, offy=-1);
+
+}
+
+H1 A{
+ text-decoration: none;
+ color: #ffa;
+}
+
+#content{
+ max-width: 800px;
+ margin: auto;
+}
+
+DIV.package {
+ -moz-border-radius-topleft: 10px;
+ -moz-border-radius-topright: 10px;
+ -moz-border-radius-bottomright: 10px;
+ -moz-border-radius-bottomleft: 10px;
+ -webkit-border-radius: 10px 10px 10px 10px;
+ border-radius: 10px 10px 10px 10px;
+ -webkit-box-shadow: 2px 2px 2px 0px rgba(0, 0, 0, 0.3);
+ -moz-box-shadow: 2px 2px 2px 0px rgba(0, 0, 0, 0.3);
+ box-shadow: 2px 2px 2px 0px rgba(0, 0, 0, 0.3);
+ border: 1px solid #eee;
+ padding: 2px 10px 2px 10px;
+}
+
+DIV.package:hover {
+ background-color: #eee;
+}
+
+DIV.package DIV.release_date {
+ color: #888;
+ float: right;
+}
+
+DIV.package DIV.author {
+ color: #888;
+ float: left;
+}
+
+#release_list {
+ border: 1px solid black;
+}
+
+#release_list{
+ border-spacing: 0;
+}
+
+#release_list TH, #release_list TD {
+ padding: 0.2em 1em;
+}
+
+#release_list TH{
+ text-align: left;
+ background: #eee;
+ border-bottom: 1px solid black;
+}
+
+#file_list {
+ border: 1px solid black;
+}
+
+#file_list{
+ border-spacing: 0;
+}
+
+#file_list TH, #file_list TD {
+ padding: 0.2em 1em;
+ white-space: nowrap;
+}
+
+#file_list TH{
+ text-align: left;
+ background: #eee;
+ border-bottom: 1px solid black;
+}
View
18 mypi/templates/master.html
@@ -0,0 +1,18 @@
+<!DOCTYPE HTML>
+<html lang="en">
+ <head>
+ {% block head %}
+ <meta charset="UTF-8">
+ <link href='http://fonts.googleapis.com/css?family=Fondamento' rel='stylesheet' type='text/css'>
+ <link rel="stylesheet" href="{{ url_for('static', filename='style.css') }}" />
+ <title>{% block title %}{% endblock %} - MyPi</title>
+ {% endblock %}
+ </head>
+ <body>
+
+ <h1><a href="{{url_for('index')}}">MyPi</a></h1>
+ <div id="content">{% block content %}{% endblock %}</div>
+
+ </body>
+</html>
+
View
99 mypi/templates/package.html
@@ -1,44 +1,47 @@
-<!DOCTYPE HTML>
-<html lang="en">
-<head>
- <meta charset="UTF-8">
- <title>Package: {{package.name}}</title>
-</head>
-<body>
+{% extends "master.html" %}
+{% block title %}{{package.name}}{% endblock %}
+{% block content %}
+<h1>{{package.name}}</h1>
- <h1>{{package.name}}</h1>
- <h2>{{package.author_email}}</h2>
- <pre>{{package.description}}</pre>
+<a href="#description">Description</a> &nbsp; | &nbsp; <a href="#releases">Releases</a>
+<br />
- <h2>Releases</h2>
- <table>
- <thead>
- <tr>
- <th>Version</th>
- <th>Platform</th>
- <th>License</th>
- <th>Author</th>
- </tr>
- </thead>
- <tbody>
- {% for rel in package.releases %}
- <tr>
- <td>{{ rel.version }}</td>
- <td>{{ rel.platform }}</td>
- <td>{{ rel.license }}</td>
- <td>{{ rel.author }}</td>
- </tr>
- <tr>
- <td colspan="4">
- <table>
- <thead>
- <th colspan="2">File</th>
- <th>Python Version</th>
- <th>MD5</th>
- <th>Comment</th>
- </thead>
- <tbody>
- {% for file in rel.files %}
+{% if package.description %}
+<div id="description">{{package.description}}</div>
+{% else %}
+<div id="description">{{package.releases[0].description}}</div>
+{% endif %}
+
+<h2 id="releases">Releases</h2>
+<table id="release_list">
+ <thead>
+ <tr>
+ <th>Version</th>
+ <th>Platform</th>
+ <th>License</th>
+ <th>Author</th>
+ </tr>
+ </thead>
+ <tbody>
+ {% for rel in package.releases %}
+ <tr>
+ <td>{{ rel.version }}</td>
+ <td>{{ rel.platform }}</td>
+ <td>{{ rel.license }}</td>
+ <td>{{ rel.author.full_name }}</td>
+ </tr>
+ <tr>
+ <td colspan="4">
+ <table id="file_list">
+ <thead>
+ <th>File</th>
+ <th>Type</th>
+ <th>Python Version</th>
+ <th>MD5</th>
+ <th>Comment</th>
+ </thead>
+ <tbody>
+ {% for file in rel.files %}
<tr>
<td><a href="{{url_for('download', package=package.name, filename=file.filename) }}#md5={{file.md5_digest}}">{{ file.filename }}</a></td>
<td>{{ file.filetype}}</td>
@@ -47,12 +50,12 @@
<td>{{ file.comment }}</td>
</tr>
{% endfor %}
- </tbody>
- </table>
- </td>
- </tr>
- {% endfor %}
- </tbody>
- </table>
-</body>
-</html>
+ </tbody>
+ </table>
+ </td>
+ </tr>
+ {% endfor %}
+ </tbody>
+</table>
+
+{% endblock %}
View
29 mypi/templates/package_list.html
@@ -1,17 +1,16 @@
-<!DOCTYPE HTML>
-<html lang="en">
-<head>
- <meta charset="UTF-8">
- <title>Private Package Index</title>
-</head>
-<body>
+{% extends "master.html" %}
+{% block title %}Package List{% endblock %}
+{% block content %}
- <ul>
- {% for p in packages %}
- <li><a href="{{url_for('package', name=p.name)}}">{{p.name}}</a></li>
- {% endfor %}
- </ul>
+<h1>Available packages</h1>
+{% for p in packages %}
+<div class="package">
+ <a href="{{url_for('package', name=p.name)}}">{{p.name}}</a><br />
+ {{ p.releases[0].summary}}
+ <div class="release_date">Latest Release: {{ p.releases[0].updated }}</div>
+ <div class="author">Author: {{p.releases[0].author.full_name }}</div>
+ <br clear="both" />
+</div>
+{% endfor %}
-
-</body>
-</html>
+{% endblock %}
Please sign in to comment.
Something went wrong with that request. Please try again.