Permalink
Browse files

added canonical_url field to a Brick

references #24
  • Loading branch information...
inmarelibero committed Nov 21, 2012
1 parent a7ced7e commit c3fbb3442374068e1f07ff367263fbb2338cf0d5
@@ -62,6 +62,14 @@ class Brick
*/
private $published;
+ /**
+ * @var text $canonicalUrl
+ *
+ * @Gedmo\Versioned
+ * @ORM\Column(type="text", name="canonical_url")
+ */
+ private $canonicalUrl;
+
/**
* @var object $user
*
@@ -339,4 +347,27 @@ public function getUserStarsBricks()
{
return $this->userStarsBricks;
}
+
+ /**
+ * Set canonicalUrl
+ *
+ * @param string $canonicalUrl
+ * @return Brick
+ */
+ public function setCanonicalUrl($canonicalUrl)
+ {
+ $this->canonicalUrl = $canonicalUrl;
+
+ return $this;
+ }
+
+ /**
+ * Get canonicalUrl
+ *
+ * @return string
+ */
+ public function getCanonicalUrl()
+ {
+ return $this->canonicalUrl;
+ }
}
@@ -6,6 +6,16 @@
{% block meta_title_content %}{{ brick.title }} | SymfonyBricks.com{% endblock %}
{% block meta_description_content %}{{ brick.description }}{% endblock %}
+{# canonical url #}
+{% block canonical_url %}
+ {% if brick.canonicalUrl|trim != '' %}
+ {{ brick.canonicalUrl|trim }}
+ {% else %}
+ {{ app.request.uri }}
+ {% endif %}
+{% endblock canonical_url %}
+
+
{% block main %}
<div class="row">
@@ -15,7 +15,7 @@
<meta name="language" content="{% spaceless %}{% block meta_language_content %}{{ app.request.locale }}{% endblock %}{% endspaceless %}" />
{# canonical url #}
- <link rel="canonical" href="{{ app.request.uri }}"/>
+ <link rel="canonical" href="{% spaceless %}{% block canonical_url %}{{ app.request.uri }}{% endblock canonical_url %}{% endspaceless %}"/>
{% stylesheets '@stylesheets' %}
<link rel="stylesheet" type="text/css" href="{{ asset_url }}" />
@@ -15,6 +15,7 @@ public function buildForm(FormBuilderInterface $builder, array $options)
'error_bubbling' => true
))
->add('description', 'textarea')
+ ->add('canonical_url', 'text')
->add('content', 'textarea')
;
}
@@ -22,13 +22,14 @@ brick:
edit_brick: Edit brick
title: title
description: description
+ canonical_url: Canonical Url
content: content
preview: preview
confirm_deletion: "This operation cannot be undone. Confirm the deletion?"
help:
title:
- title: Brick title
+ title: "Brick: title"
body: |
This is the title of the brick (piece of code/guide/recipe) you are creating.
<br><br>
@@ -57,7 +58,7 @@ brick:
</ul>
description:
- title: Brick description
+ title: "Brick: Description"
body: |
You can provide a brief additional description, about the subject you are going to treat: this field lets you explain better what is the problem you are facing, and what is the proposed solution.
<br><br>
@@ -73,4 +74,14 @@ brick:
<b>how did you solve the problem and the solution you adopted; eg: what bundles have been installad, external libraries installed and configured, etc...</b>
</li>
</ul>
-
+
+ canonical_url:
+ title: "Brick: Canonical url"
+ body: |
+ You can specify a canonical url for a brick. Using Google's definition, <b>A canonical page is the preferred version of a set of pages with highly similar content.</b>
+ <br><br>
+ This field is useful for example when you publish a guide on your blog, and then publish the same conent on SymfonyBricks too. The <b>Canonical url</b> lets Google not to punish your blog post in search results because of the repetition of the content in SymfonyBricks.
+ <br><br>
+ Put in this field the url of the original article/blog post/webpage, so google will give priority to it instead of the content published on SymfonyBricks.
+ <br><br><br>
+ More infos are available on <a href="http://support.google.com/webmasters/bin/answer.py?hl=en&answer=139394" target="_new">this Google help page.</a>
@@ -28,7 +28,7 @@ brick:
help:
title:
- title: Título del Brick
+ title: "Brick: Título"
body: |
Este es el título del Brick (pieza de código/guía/receta) que estás creando.
<br><br>
@@ -57,7 +57,7 @@ brick:
</ul>
description:
- title: Descripción del Brick
+ title: "Brick: Descripción"
body: |
Puedes proporcionar una breve descripción adicional sobre el tema que estás tratando: Este campo te permite explicar mejor cuál es el problema al que te estás enfrentando, y cuál es la solución propuesta.
<br><br>
@@ -28,7 +28,7 @@ brick:
help:
title:
- title: Titolo del Brick
+ title: "Brick: Titolo"
body: |
Questo è il titolo del Brick (porzione di codice/guida/ricetta) che stai creando.
<br><br>
@@ -57,7 +57,7 @@ brick:
</ul>
description:
- title: Descrizione del Brick
+ title: "Brick: Descrizione"
body: |
Puoi fornire una breve descrizione aggiuntiva, relativa al tema che stai trattando: questo campo ti permette di spiegare meglio qual'è il problema che stai affrontando, e qual'è la soluzione proposta.
<br><br>
@@ -59,6 +59,21 @@
</div>
</div>
+ <div class="control-group">
+ {# info modal #}
+ <div class="control-label pull-right" for="{{ form.canonical_url.vars.id }}">
+ {{ macrosInfo.bootstrapInfoModal('brick.help.canonical_url.title'|trans({}, 'UserBundle'), 'brick.help.canonical_url.body'|trans({}, 'UserBundle')) }}
+ </div>
+
+ {# label #}
+ <div class="control-label" for="{{ form.canonical_url.vars.id }}">
+ {{ 'brick.canonical_url'|trans({}, 'UserBundle')|capitalize }}
+ </div>
+ <div class="controls">
+ {{ form_widget(form.canonical_url) }}
+ </div>
+ </div>
+
<div id="control-group-content" class="control-group">
<div class="controls">
<ul class="nav nav-tabs" id="content-tab">

0 comments on commit c3fbb34

Please sign in to comment.