forked from nicolas-petit/website
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch '8.0-extract' into release/9.0/website_seo_redirection
- Loading branch information
Showing
17 changed files
with
676 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
.. image:: https://img.shields.io/badge/licence-LGPL--3-blue.svg | ||
:target: http://www.gnu.org/licenses/lgpl-3.0-standalone.html | ||
:alt: License: LGPL-3 | ||
|
||
======================= | ||
Website SEO Redirection | ||
======================= | ||
|
||
This module extends the functionality of the website to support using custom | ||
URLs and allow you to improve the SEO. | ||
|
||
Usage | ||
===== | ||
|
||
Let's assume you created a blog post entry that is absolutely amazing and you | ||
want a fixed and beautiful URL for it. That entry is posted in | ||
``https://example.com/blog/our-news-1/post/amazing-post-23``, but you want it | ||
at ``https://example.com/amazing``. You need to: | ||
|
||
#. Go to *Settings > Configuration > SEO Redirections > Create*. | ||
#. Set ``/blog/our-news-1/post/amazing-post-23`` as *Original URL*. | ||
#. Set ``/amazing`` as *Redirected URL*. | ||
|
||
Now navigate to any of both URLs, and you will get to the blog post, but with | ||
the URL you wanted. | ||
|
||
.. image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas | ||
:alt: Try me on Runbot | ||
:target: https://runbot.odoo-community.org/runbot/186/8.0 | ||
|
||
Known issues / Roadmap | ||
====================== | ||
|
||
* The frontend *Promote* view should be extended to display and modify this | ||
information more easily. | ||
* Add ability to have several redirected URLs for a single original URL. | ||
* Make it multiwebsite-compatible. | ||
|
||
Bug Tracker | ||
=========== | ||
|
||
Bugs are tracked on `GitHub Issues | ||
<https://github.com/OCA/website/issues>`_. In case of trouble, please | ||
check there if your issue has already been reported. If you spotted it first, | ||
help us smashing it by providing a detailed and welcomed feedback. | ||
|
||
Credits | ||
======= | ||
|
||
Images | ||
------ | ||
|
||
* Odoo Community Association: `Icon <https://github.com/OCA/maintainer-tools/blob/master/template/module/static/description/icon.svg>`_. | ||
|
||
Contributors | ||
------------ | ||
|
||
* Jairo Llopis <[email protected]> | ||
|
||
Maintainer | ||
---------- | ||
|
||
.. image:: https://odoo-community.org/logo.png | ||
:alt: Odoo Community Association | ||
:target: https://odoo-community.org | ||
|
||
This module is maintained by the OCA. | ||
|
||
OCA, or the Odoo Community Association, is a nonprofit organization whose | ||
mission is to support the collaborative development of Odoo features and | ||
promote its widespread use. | ||
|
||
To contribute to this module, please visit https://odoo-community.org. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# -*- coding: utf-8 -*- | ||
# © 2016 Jairo Llopis <[email protected]> | ||
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl). | ||
|
||
from . import models |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
# -*- coding: utf-8 -*- | ||
# © 2016 Jairo Llopis <[email protected]> | ||
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl). | ||
{ | ||
"name": "Website SEO Redirection", | ||
"summary": "Redirect any controller to the URL of your dreams", | ||
"version": "8.0.1.0.0", | ||
"category": "Website", | ||
"website": "https://tecnativa.com/", | ||
"author": "Tecnativa, Odoo Community Association (OCA)", | ||
"license": "LGPL-3", | ||
"application": False, | ||
"installable": True, | ||
"depends": [ | ||
"website", | ||
], | ||
"data": [ | ||
"security/ir.model.access.csv", | ||
"views/assets.xml", | ||
"views/website_seo_redirection_view.xml", | ||
], | ||
"demo": [ | ||
"demo/website_seo_redirection_demo.xml", | ||
], | ||
} |
52 changes: 52 additions & 0 deletions
52
website_seo_redirection/demo/website_seo_redirection_demo.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<!-- © 2016 Jairo Llopis <[email protected]> | ||
License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl). --> | ||
|
||
<openerp> | ||
<data> | ||
|
||
<template id="sample_page" page="True"> | ||
<t t-call="website.layout"> | ||
<div id="wrap" class="oe_structure oe_empty"> | ||
<section class="jumbotron mt16 mb16"> | ||
<div class="container"> | ||
<h1>Welcome, this is SEO.</h1> | ||
<p> | ||
The original URL for this page is | ||
<a href="/page/website_seo_redirection.sample_page" | ||
id="origin"> | ||
/page/website_seo_redirection.sample_page | ||
</a>, but | ||
<a href="/seo/sample" id="destination">/seo/sample</a> | ||
is beautier, right? | ||
</p> | ||
</div> | ||
</section> | ||
</div> | ||
</t> | ||
</template> | ||
|
||
<record id="sample_menu" model="website.menu"> | ||
<field name="name">SEO Sample</field> | ||
<field name="parent_id" ref="website.main_menu"/> | ||
</record> | ||
|
||
<record id="sample_origin_menu" model="website.menu"> | ||
<field name="name">Original URL</field> | ||
<field name="url">/page/website_seo_redirection.sample_page</field> | ||
<field name="parent_id" ref="sample_menu"/> | ||
</record> | ||
|
||
<record id="sample_destination_menu" model="website.menu"> | ||
<field name="name">Redirected URL</field> | ||
<field name="url">/seo/sample</field> | ||
<field name="parent_id" ref="sample_menu"/> | ||
</record> | ||
|
||
<record id="sample_redirection" model="website.seo.redirection"> | ||
<field name="origin">/page/website_seo_redirection.sample_page</field> | ||
<field name="destination">/seo/sample</field> | ||
</record> | ||
|
||
</data> | ||
</openerp> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
# -*- coding: utf-8 -*- | ||
# © 2016 Jairo Llopis <[email protected]> | ||
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl). | ||
|
||
from openerp import exceptions | ||
|
||
|
||
class NoOriginError(exceptions.ValidationError): | ||
pass | ||
|
||
|
||
class NoRedirectionError(exceptions.ValidationError): | ||
pass |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,141 @@ | ||
# Translation of Odoo Server. | ||
# This file contains the translation of the following modules: | ||
# * website_seo_redirection | ||
# | ||
msgid "" | ||
msgstr "" | ||
"Project-Id-Version: Odoo Server 8.0\n" | ||
"Report-Msgid-Bugs-To: \n" | ||
"POT-Creation-Date: 2016-05-23 12:19+0200\n" | ||
"PO-Revision-Date: 2016-05-23 12:22+0200\n" | ||
"Language-Team: \n" | ||
"MIME-Version: 1.0\n" | ||
"Content-Type: text/plain; charset=UTF-8\n" | ||
"Content-Transfer-Encoding: 8bit\n" | ||
"Plural-Forms: nplurals=2; plural=(n != 1);\n" | ||
"X-Generator: Poedit 1.8.7.1\n" | ||
"Last-Translator: \n" | ||
"Language: es_ES\n" | ||
|
||
#. module: website_seo_redirection | ||
#: view:website:website_seo_redirection.sample_page | ||
msgid ", but" | ||
msgstr ", pero" | ||
|
||
#. module: website_seo_redirection | ||
#: view:website:website_seo_redirection.sample_page | ||
msgid "/page/website_seo_redirection.sample_page" | ||
msgstr "/page/website_seo_redirection.sample_page" | ||
|
||
#. module: website_seo_redirection | ||
#: view:website:website_seo_redirection.sample_page | ||
msgid "/seo/sample" | ||
msgstr "/seo/sample" | ||
|
||
#. module: website_seo_redirection | ||
#: field:website.seo.redirection,create_uid:0 | ||
msgid "Created by" | ||
msgstr "Creado por" | ||
|
||
#. module: website_seo_redirection | ||
#: field:website.seo.redirection,create_date:0 | ||
msgid "Created on" | ||
msgstr "Creado el" | ||
|
||
#. module: website_seo_redirection | ||
#: field:website.seo.redirection,display_name:0 | ||
msgid "Display Name" | ||
msgstr "Nombre a mostrar" | ||
|
||
#. module: website_seo_redirection | ||
#: sql_constraint:website.seo.redirection:0 | ||
msgid "Duplicated new URL" | ||
msgstr "Nueva URL duplicada" | ||
|
||
#. module: website_seo_redirection | ||
#: sql_constraint:website.seo.redirection:0 | ||
msgid "Duplicated original URL" | ||
msgstr "URL original duplicada" | ||
|
||
#. module: website_seo_redirection | ||
#: model:ir.model,name:website_seo_redirection.model_ir_http | ||
msgid "HTTP routing" | ||
msgstr "Enrutamiento HTTP" | ||
|
||
#. module: website_seo_redirection | ||
#: field:website.seo.redirection,id:0 | ||
msgid "ID" | ||
msgstr "ID" | ||
|
||
#. module: website_seo_redirection | ||
#: field:website.seo.redirection,__last_update:0 | ||
msgid "Last Modified on" | ||
msgstr "Última modificación el" | ||
|
||
#. module: website_seo_redirection | ||
#: field:website.seo.redirection,write_uid:0 | ||
msgid "Last Updated by" | ||
msgstr "Última modificación por" | ||
|
||
#. module: website_seo_redirection | ||
#: field:website.seo.redirection,write_date:0 | ||
msgid "Last Updated on" | ||
msgstr "Última actualización el" | ||
|
||
#. module: website_seo_redirection | ||
#: model:ir.model,name:website_seo_redirection.model_ir_module_module | ||
msgid "Module" | ||
msgstr "Módulo" | ||
|
||
#. module: website_seo_redirection | ||
#: model:website.menu,name:website_seo_redirection.sample_origin_menu | ||
#: field:website.seo.redirection,origin:0 | ||
msgid "Original URL" | ||
msgstr "URL original" | ||
|
||
#. module: website_seo_redirection | ||
#: help:website.seo.redirection,destination:0 | ||
msgid "Path where the controller will be found now." | ||
msgstr "Ruta donde el controlador se encontrará ahora." | ||
|
||
#. module: website_seo_redirection | ||
#: help:website.seo.redirection,origin:0 | ||
msgid "Path where the original controller was found." | ||
msgstr "Ruta donde se encontraba el controlador original." | ||
|
||
#. module: website_seo_redirection | ||
#: model:website.menu,name:website_seo_redirection.sample_destination_menu | ||
#: field:website.seo.redirection,destination:0 | ||
msgid "Redirected URL" | ||
msgstr "URL redireccionada" | ||
|
||
#. module: website_seo_redirection | ||
#: model:ir.actions.act_window,name:website_seo_redirection.website_seo_redirection_action_open | ||
#: model:ir.ui.menu,name:website_seo_redirection.website_seo_redirection_menu | ||
msgid "SEO Redirections" | ||
msgstr "Redirecciones SEO" | ||
|
||
#. module: website_seo_redirection | ||
#: model:website.menu,name:website_seo_redirection.sample_menu | ||
msgid "SEO Sample" | ||
msgstr "Muestra SEO" | ||
|
||
#. module: website_seo_redirection | ||
#: model:ir.model,name:website_seo_redirection.model_website_seo_redirection | ||
msgid "SEO controller redirections" | ||
msgstr "Redirecciones de controladores SEO" | ||
|
||
#. module: website_seo_redirection | ||
#: view:website:website_seo_redirection.sample_page | ||
msgid "The original URL for this page is" | ||
msgstr "La URL original para esta página es" | ||
|
||
#. module: website_seo_redirection | ||
#: view:website:website_seo_redirection.sample_page | ||
msgid "Welcome, this is SEO." | ||
msgstr "Bienvenido, esto es SEO." | ||
|
||
#. module: website_seo_redirection | ||
#: view:website:website_seo_redirection.sample_page | ||
msgid "is beautier, right?" | ||
msgstr "es más bonita, ¿verdad?" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# -*- coding: utf-8 -*- | ||
# © 2016 Jairo Llopis <[email protected]> | ||
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl). | ||
|
||
from . import ir_http, website_seo_redirection |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
# -*- coding: utf-8 -*- | ||
# © 2016 Jairo Llopis <[email protected]> | ||
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl). | ||
|
||
from openerp import models | ||
from openerp.http import request | ||
from ..exceptions import NoOriginError, NoRedirectionError | ||
|
||
|
||
class IrHttp(models.AbstractModel): | ||
_inherit = "ir.http" | ||
|
||
def _dispatch(self): | ||
"""Handle SEO-redirected URLs.""" | ||
# Only handle redirections for HTTP requests | ||
if not hasattr(request, "jsonrequest"): | ||
wsr = request.env["website.seo.redirection"] | ||
|
||
try: | ||
# Redirect user to SEO version of this URL if possible | ||
return wsr.redirect_auto() | ||
except NoRedirectionError: | ||
try: | ||
# Make Odoo believe it is in the original controller | ||
return self.reroute(wsr.find_origin()) | ||
except NoOriginError: | ||
pass | ||
|
||
return super(IrHttp, self)._dispatch() |
Oops, something went wrong.