Jordi Boggiano преди 13 години
родител
ревизия
a60f1c8271

+ 1 - 1
app/config/security.yml

@@ -29,7 +29,7 @@ security:
         # Secured part of the site
         # This config requires being logged for the whole site and having the admin role for the admin part.
         # Change these rules to adapt them to your needs
-        - { path: ^/submit$, role: ROLE_USER }
+        - { path: ^/packages/submit$, role: ROLE_USER }
         - { path: ^/admin/, role: ROLE_ADMIN }
 
     role_hierarchy:

+ 4 - 4
src/Packagist/WebBundle/Controller/WebController.php

@@ -63,11 +63,11 @@ class WebController extends Controller
 
         $packages = $this->getDoctrine()
             ->getRepository('PackagistWebBundle:Package')
-            ->findAll();
+            ->getBaseQueryBuilder();
 
-        $paginator = new Pagerfanta(new DoctrineORMAdapter($packages));
-        $paginator->setMaxPerPage(20);
-        $paginator->setCurrentPage($this->get('request')->query->get('page', 1), false, true);
+        $paginator = new Pagerfanta(new DoctrineORMAdapter($packages, true));
+        $paginator->setMaxPerPage(15);
+        $paginator->setCurrentPage($req->query->get('page', 1), false, true);
 
         return $this->render('PackagistWebBundle:Web:browse.html.twig', array('packages' => $packages));
     }

+ 1 - 6
src/Packagist/WebBundle/Entity/PackageRepository.php

@@ -30,11 +30,6 @@ class PackageRepository extends EntityRepository
         return $qb->getQuery()->getResult();
     }
 
-    public function findAll()
-    {
-        return $this->getBaseQueryBuilder();
-    }
-
     public function findOneByName($name)
     {
         $qb = $this->getBaseQueryBuilder()
@@ -63,7 +58,7 @@ class PackageRepository extends EntityRepository
         return $qb->getQuery()->getResult();
     }
 
-    private function getBaseQueryBuilder()
+    public function getBaseQueryBuilder()
     {
         $qb = $this->getEntityManager()->createQueryBuilder();
         $qb->select('p, v, t, m')

+ 9 - 0
src/Packagist/WebBundle/Resources/public/css/main.css

@@ -254,6 +254,15 @@ p {
   background: #53a51d;
 }
 
+.packages nav {
+  padding: 4px;
+}
+
+.packages nav span {
+  margin-right: 5px;
+  display: inline-block;
+}
+
 .getting-started {
   float: left;
   width: 48%;

+ 34 - 33
src/Packagist/WebBundle/Resources/views/Web/list.html.twig

@@ -3,41 +3,42 @@
 {% block content %}
     {% block content_title %}<h1>Packages</h1>{% endblock %}
     {% if packages|length %}
-    <ul class="packages">
-    {% for package in packages %}
-        <li class="has-popup">
-            <section>
-                {% if package.versions|length and package.versions[0].description|length %}
-                    <h1 class="has-description"><a href="{{ url('view', { 'name' : package.name }) }}">{{ package.name }}</a></h1>
-                    <p class="package-description">{{ package.versions[0].description }}</p>
-                {% else %}
-                    <h1><a href="{{ url('view', { 'name' : package.name }) }}">{{ package.name }}</a></h1>
-                {% endif %}
-                <div class="package-details"><div>
-                {% if package.versions|length %}
-                    <p class="description">{{ package.versions[0].description }}</p>
-                    <p class="license">License: {{ package.versions[0].license ? package.versions[0].license|join(', ') : "Unknown" }}</p>
-                    <p class="links">
-                        {% if package.versions[0].homepage %}
-                            Homepage: <a href="{{ package.versions[0].homepage }}">{{ package.versions[0].homepage|replace({'http://': ''}) }}</a><br />
+        <ul class="packages">
+            {% for package in packages %}
+                <li class="has-popup">
+                    <section>
+                        {% if package.versions|length and package.versions[0].description|length %}
+                            <h1 class="has-description"><a href="{{ url('view', { 'name' : package.name }) }}">{{ package.name }}</a></h1>
+                            <p class="package-description">{{ package.versions[0].description }}</p>
+                        {% else %}
+                            <h1><a href="{{ url('view', { 'name' : package.name }) }}">{{ package.name }}</a></h1>
+                        {% endif %}
+                        <div class="package-details"><div>
+                        {% if package.versions|length %}
+                            <p class="description">{{ package.versions[0].description }}</p>
+                            <p class="license">License: {{ package.versions[0].license ? package.versions[0].license|join(', ') : "Unknown" }}</p>
+                            <p class="links">
+                                {% if package.versions[0].homepage %}
+                                    Homepage: <a href="{{ package.versions[0].homepage }}">{{ package.versions[0].homepage|replace({'http://': ''}) }}</a><br />
+                                {% endif %}
+                                Tags: {% for tag in package.versions[0].tags %}<a href="{{ url("browse", { "tag" : tag.name }) }}">{{ tag.name }}</a>{{ loop.last ? '' : ', ' }}{% endfor %}
+                            </p>
+                        {% elseif package.crawledAt is null %}
+                            <p>This package has not been crawled yet, some information is missing.</p>
+                        {% else %}
+                            <p>This package has no released version yet, and little information is available yet.</p>
                         {% endif %}
-                        Tags: {% for tag in package.versions[0].tags %}<a href="{{ url("browse", { "tag" : tag.name }) }}">{{ tag.name }}</a>{{ loop.last ? '' : ', ' }}{% endfor %}
-                    </p>
-                {% elseif package.crawledAt is null %}
-                    <p>This package has not been crawled yet, some information is missing.</p>
-                {% else %}
-                    <p>This package has no released version yet, and little information is available yet.</p>
-                {% endif %}
 
-                <p class="maintainers">Maintainer{{ package.maintainers|length > 1 ? 's' : '' }}:
-                {% for maintainer in package.maintainers %}
-                    <a href="{{ url("user_packages", { "name" : maintainer.username }) }}">{{ maintainer.username }}</a>{{ loop.last ? '' : ', ' }}
-                {% endfor %}</p>
-                </div></div>
-            </section>
-        </li>
-    {% endfor %}
-    </ul>
+                        <p class="maintainers">Maintainer{{ package.maintainers|length > 1 ? 's' : '' }}:
+                        {% for maintainer in package.maintainers %}
+                            <a href="{{ url("user_packages", { "name" : maintainer.username }) }}">{{ maintainer.username }}</a>{{ loop.last ? '' : ', ' }}
+                        {% endfor %}</p>
+                        </div></div>
+                    </section>
+                </li>
+            {% endfor %}
+            {{ pagerfanta(packages, 'default', {'proximity': 2}) }}
+        </ul>
     {% else %}
         <p>No packages found.</p>
     {% endif %}

+ 2 - 2
src/Packagist/WebBundle/Resources/views/Web/view.html.twig

@@ -34,7 +34,7 @@
             {% for version in package.versions %}
                 <li{% if loop.index0 > 0 and not ('-dev' in version.version) %} class="has-popup"{% endif %}>
                     <section>
-                        <h1>Version {{ version.version }}</h1>
+                        <h1>{{ version.version }}</h1>
                         {% if loop.index0 > 0 and not ('-dev' in version.version) %}
                             <div class="package-details"><div>
                         {% else %}
@@ -51,7 +51,7 @@
                         <p class="links">
                             Tags:
                             {% for tag in version.tags -%}
-                                <a href="{{ url("tag", { "name" : tag.name }) }}">{{ tag.name }}</a>{{ loop.last ? '' : ', ' }}
+                                <a href="{{ url("browse", { "tag" : tag.name }) }}">{{ tag.name }}</a>{{ loop.last ? '' : ', ' }}
                             {%- endfor %}
                         </p>
                         <p class="authors">Author{{ version.authors|length > 1 ? 's' : '' }}: