Permalink
Browse files

refactored public user profile

  • Loading branch information...
inmarelibero committed Nov 17, 2012
1 parent 88698a9 commit 3fd63988ae7b6deba22f6b6348f60e11bce76fb3
@@ -12,7 +12,7 @@
class UserProfileController extends Controller
{
/**
- * @Route("/show/{username}", name="userprofile_show")
+ * @Route("/public/{username}", name="userprofile_show")
* @Template()
*/
public function showAction($username)
@@ -25,12 +25,35 @@ public function showAction($username)
throw $this->createNotFoundException("Unable to find User \"{$username}\".");
}
-
+ return array(
+ 'user' => $user
+ );
+ }
+
+ /**
+ * @Route("/public/{username}/brickspublished", name="userprofile_bricks_publihed")
+ * @Template()
+ */
+ public function bricksPublishedAction($username)
+ {
+ $userManager = $this->container->get('fos_user.user_manager');
+
+ $user = $userManager->findUserByUsername($username);
+
+ if (!$user) {
+ throw $this->createNotFoundException("Unable to find User \"{$username}\".");
+ }
+
$em = $this->getDoctrine()->getManager();
- $publishedBricks = $em->getRepository('BricksSiteBundle:Brick')->findBy(array(
- 'user' => $user,
- 'published' => true
- ));
+ $publishedBricks = $em->getRepository('BricksSiteBundle:Brick')->findBy(
+ array(
+ 'user' => $user,
+ 'published' => true
+ ),
+ array(
+ 'updated_at' =>'DESC'
+ )
+ );
return array(
'user' => $user,
@@ -0,0 +1,24 @@
+/******************************************************************************************
+CONTROLLER-USER_PROFILE.LESS
+
+rules for all the templates loaded through Bricks\SiteBundle\UserProfileController
+******************************************************************************************/
+
+/**
+ general rules for user public profile layout
+*/
+body.route-userprofile {
+ /* user profile navbar */
+ #nav-userprofile {
+ .nav-header { padding-left: 0px; }
+ }
+
+ /* userprofile content section */
+ .content {
+ h3 {
+ padding: 0px;
+ margin-top: 0px;
+ border-bottom: 1px solid #CCC;
+ }
+ }
+}
@@ -0,0 +1,8 @@
+####################################################################################################################
+# Translations #
+# #
+# translation related to Bricks\SiteBundles\Controller\UserProfileController #
+####################################################################################################################
+nav-userprofile:
+ user_profile: User profile
+ published_bricks: Published Bricks
@@ -0,0 +1,8 @@
+####################################################################################################################
+# Translations #
+# #
+# translation related to Bricks\SiteBundles\Controller\UserProfileController #
+####################################################################################################################
+nav-userprofile:
+ user_profile: Perfil usuario
+ published_bricks: Bricks Publicados
@@ -0,0 +1,8 @@
+####################################################################################################################
+# Translations #
+# #
+# translation related to Bricks\SiteBundles\Controller\UserProfileController #
+####################################################################################################################
+nav-userprofile:
+ user_profile: Profilo utente
+ published_bricks: Bricks Pubblicati
@@ -0,0 +1,22 @@
+{% extends 'BricksSiteBundle:UserProfile:layout.html.twig' %}
+
+{% block user_profile_content %}
+
+ <h3>
+ {{ 'nav-userprofile.activity'|trans({}, 'controller-userprofile') }}
+ </h3>
+
+ <ul class="activity">
+ {% for log in brickLogEntries %}
+ <li>
+ <i class="icon-calendar"></i> last update: {{ log.loggedAt|date('d/m/Y') }}
+ {#
+ <a href="{{ path('brick_show', {id: brick.id, slug: brick.slug}) }}">
+ {{ brick.title }}
+ </a>
+ #}
+ </li>
+ {% endfor %}
+ </ul>
+
+{% endblock %}
@@ -0,0 +1,24 @@
+{% extends 'BricksSiteBundle:UserProfile:layout.html.twig' %}
+
+{% block user_profile_content %}
+
+ <h3>
+ {{ 'nav-userprofile.published_bricks'|trans({}, 'controller-userprofile') }}
+ </h3>
+
+ <ul class="bricks-list">
+ {% for brick in publishedBricks %}
+ <li>
+ <a href="{{ path('brick_show', {id: brick.id, slug: brick.slug}) }}">
+ {{ brick.title }}
+ </a>
+ <p>
+ <i class="icon-user"></i> <a href="{{ path('userprofile_show', {'username': brick.user.username}) }}">{{ brick.user }}</a>
+ |
+ <i class="icon-calendar"></i> last update: {{ brick.updatedAt|date('d/m/Y') }}
+ </p>
+ </li>
+ {% endfor %}
+ </ul>
+
+{% endblock %}
@@ -0,0 +1,49 @@
+{% extends 'BricksSiteBundle::layout.html.twig' %}
+
+{# add a class to the <body> tag #}
+{% block body_class %}route-userprofile{% endblock %}
+
+{% block main %}
+
+ <div class="user-profile-wrapper">
+ <div class="row">
+ <div class="span12">
+ <h1>
+ <i class="icon-user"></i> {{ user.username }}
+ </h1>
+ </div>
+ </div>
+
+ <div class="row">
+ <div class="span3">
+ <ul id="nav-userprofile" class="nav nav-list">
+ <li class="nav-header">
+ {{ 'nav-userprofile.user_profile'|trans({}, 'controller-userprofile') }}
+ </li>
+ <li class="">
+ <a href="{{ path('userprofile_show', {username: user.username}) }}">
+ Home
+ </a>
+ </li>
+ <li class="">
+ <a href="{{ path('userprofile_bricks_publihed', {username: user.username}) }}">
+ {{ 'nav-userprofile.published_bricks'|trans({}, 'controller-userprofile') }}
+ </a>
+ </li>
+ <li class="">
+ <a href="{{ path('userprofile_activity', {username: user.username}) }}">
+ {{ 'nav-userprofile.activity'|trans({}, 'controller-userprofile') }}
+ </a>
+ </li>
+ </ul>
+ </div>
+ <div class="span9 content">
+ {% block user_profile_content %}{% endblock %}
+ </div>
+ </div>
+ </div>
+
+{% endblock %}
+
+{# SEO #}
+{% block meta_title_content %}{{ user.username }} profile | SymfonyBricks.com{% endblock %}
@@ -1,39 +1,13 @@
-{% extends 'BricksSiteBundle::layout.html.twig' %}
+{% extends 'BricksSiteBundle:UserProfile:layout.html.twig' %}
-{% block main %}
+{% block user_profile_content %}
- <div id="userprofile-show-wrapper">
-
- <div class="row">
- <div class="span12">
-
- <h1>{{ user.username }}</h1>
-
- <hr>
-
- <h3>Published bricks</h3>
-
- <ul class="bricks-list">
- {% for brick in publishedBricks %}
- <li>
- <a href="{{ path('brick_show', {id: brick.id, slug: brick.slug}) }}">
- {{ brick.title }}
- </a>
- <p>
- <i class="icon-user"></i> <a href="{{ path('userprofile_show', {'username': brick.user.username}) }}">{{ brick.user }}</a>
- |
- <i class="icon-calendar"></i> last update: {{ brick.updatedAt|date('d/m/Y') }}
- </p>
- </li>
- {% endfor %}
- </ul>
-
- </div>
- </div>
-
- </div>
+ {% if 'it' == app.request.locale %}
+ Profilo pubblico di {{ user.username|capitalize }}
+ {% elseif 'es' == app.request.locale %}
+ Perfil público de {{ user.username|capitalize }}
+ {% else %}
+ {{ user.username|capitalize }} public profile
+ {% endif %}
{% endblock %}
-
-{# SEO #}
-{% block meta_title_content %}{{ user.username }} profile | SymfonyBricks.com{% endblock %}

0 comments on commit 3fd6398

Please sign in to comment.