Explorar o código

add link to "forgot password", "user profile", refactor some templates

Igor Wiedler %!s(int64=13) %!d(string=hai) anos
pai
achega
52e6f7444c

+ 17 - 0
app/Resources/FOSUserBundle/views/Profile/show.html.twig

@@ -0,0 +1,17 @@
+{% extends "PackagistWebBundle::layout.html.twig" %}
+
+{% import "PackagistWebBundle::macros.html.twig" as macros %}
+
+{% block content %}
+    <div class="box clearfix">
+        <h1>{{ user.username }} (that's you!)</h1>
+        <p>This is your profile. You can <a href="{{ path('fos_user_profile_edit') }}">edit</a>.</p>
+
+        <h1>Your packages</h1>
+        {% if user.packages|length %}
+            {{ macros.listPackages(user.packages) }}
+        {% else %}
+            <p>No packages found.</p>
+        {% endif %}
+    </div>
+{% endblock %}

+ 2 - 0
app/Resources/FOSUserBundle/views/Security/login.html.twig

@@ -23,4 +23,6 @@
 
     <input type="submit" id="_submit" name="_submit" value="{{ 'security.login.submit'|trans({}, 'FOSUserBundle') }}" />
 </form>
+
+<a href="{{ path('fos_user_resetting_request') }}">Forgot password?</a>
 {% endblock fos_user_content %}

+ 3 - 39
src/Packagist/WebBundle/Resources/views/Web/list.html.twig

@@ -1,48 +1,12 @@
 {% extends "PackagistWebBundle::layout.html.twig" %}
 
+{% import "PackagistWebBundle::macros.html.twig" as macros %}
+
 {% block content %}
     <div class="box clearfix">
         {% 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="{{ path('view_package', { 'name' : package.name }) }}">{{ package.name }}</a></h1>
-                                <p class="package-description">{{ package.versions[0].description }}</p>
-                            {% else %}
-                                <h1><a href="{{ path('view_package', { '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="{{ path("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="{{ path("user_packages", { "name" : maintainer.username }) }}">{{ maintainer.username }}</a>{{ loop.last ? '' : ', ' }}
-                            {% endfor %}</p>
-                            </div></div>
-                        </section>
-                    </li>
-                {% endfor %}
-
-                {% if paginate is defined and paginate %}
-                    {{ pagerfanta(packages, 'default', {'proximity': 2}) }}
-                {% endif %}
-            </ul>
+            {{ macros.listPackages(packages, paginate) }}
         {% else %}
             <p>No packages found.</p>
         {% endif %}

+ 1 - 1
src/Packagist/WebBundle/Resources/views/layout.html.twig

@@ -29,7 +29,7 @@
         <div class="container">
             <div class="user">
                 {% if app.user %}
-                    {{ app.user.username }} | <a href="{{ path('fos_user_security_logout') }}">Logout</a>
+                    <a href="{{ path('fos_user_profile_show') }}">{{ app.user.username }}</a> | <a href="{{ path('fos_user_security_logout') }}">Logout</a>
                 {% else %}
                     <a href="{{ path('fos_user_registration_register') }}">Create a new account</a>
                     |

+ 41 - 0
src/Packagist/WebBundle/Resources/views/macros.html.twig

@@ -0,0 +1,41 @@
+{% macro listPackages(packages, paginate) %}
+    <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="{{ path('view_package', { 'name' : package.name }) }}">{{ package.name }}</a></h1>
+                        <p class="package-description">{{ package.versions[0].description }}</p>
+                    {% else %}
+                        <h1><a href="{{ path('view_package', { '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="{{ path("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="{{ path("user_packages", { "name" : maintainer.username }) }}">{{ maintainer.username }}</a>{{ loop.last ? '' : ', ' }}
+                    {% endfor %}</p>
+                    </div></div>
+                </section>
+            </li>
+        {% endfor %}
+
+        {% if paginate is defined and paginate %}
+            {{ pagerfanta(packages, 'default', {'proximity': 2}) }}
+        {% endif %}
+    </ul>
+{% endmacro %}