@ -0,0 +1,3 @@ |
|||
# -*- coding: utf-8 -*- |
|||
|
|||
from . import models |
@ -0,0 +1,30 @@ |
|||
# -*- coding: utf-8 -*- |
|||
{ |
|||
'name': 'Remove Sitemap URLS', |
|||
'version': '1.0.0', |
|||
'category': 'Website', |
|||
'summary': 'Allows the removal of specific urls from the sitemap.', |
|||
'description': """ |
|||
sitemap |
|||
remove from sitemap |
|||
exclude url from sitemap |
|||
exclude url sitemap |
|||
remove url sitemap |
|||
sitemap improvements |
|||
advanced sitemap |
|||
""", |
|||
'author': "Lean Easy", |
|||
'website': "https://www.leaneasy.co.uk", |
|||
'depends': ['base', 'website'], |
|||
'data': [ |
|||
'views/res_config_settings.xml', |
|||
], |
|||
'images': [ |
|||
'static/description/module_banner.jpg', |
|||
'static/description/icon.png' |
|||
], |
|||
'installable': True, |
|||
'auto_install': False, |
|||
'application': False, |
|||
'license': 'OPL-1', |
|||
} |
@ -0,0 +1,4 @@ |
|||
# -*- coding: utf-8 -*- |
|||
|
|||
from . import website |
|||
from . import res_config_settings |
@ -0,0 +1,7 @@ |
|||
from odoo import models, fields, api |
|||
|
|||
|
|||
class ResConfigSettings(models.TransientModel): |
|||
_inherit = 'res.config.settings' |
|||
|
|||
le_excl_sitemap_url = fields.Text(string="Exclude from Sitemap",related='website_id.le_excl_sitemap_url', readonly=False) |
@ -0,0 +1,131 @@ |
|||
# -*- coding: utf-8 -*- |
|||
|
|||
import logging |
|||
|
|||
from odoo import api, fields, models, _, http |
|||
from odoo.http import request |
|||
from odoo.addons.website.models.ir_http import sitemap_qs2dom |
|||
from odoo.osv.expression import FALSE_DOMAIN |
|||
|
|||
logger = logging.getLogger(__name__) |
|||
|
|||
|
|||
class Website(models.Model): |
|||
_inherit = 'website' |
|||
|
|||
le_excl_sitemap_url = fields.Text() |
|||
|
|||
# Overwrite default method to add our own code |
|||
def _enumerate_pages(self, query_string=None, force=False): |
|||
""" Available pages in the website/CMS. This is mostly used for links |
|||
generation and can be overridden by modules setting up new HTML |
|||
controllers for dynamic pages (e.g. blog). |
|||
By default, returns template views marked as pages. |
|||
:param str query_string: a (user-provided) string, fetches pages |
|||
matching the string |
|||
:returns: a list of mappings with two keys: ``name`` is the displayable |
|||
name of the resource (page), ``url`` is the absolute URL |
|||
of the same. |
|||
:rtype: list({name: str, url: str}) |
|||
""" |
|||
|
|||
router = http.root.get_db_router(request.db) |
|||
# Force enumeration to be performed as public user |
|||
url_set = set() |
|||
|
|||
sitemap_endpoint_done = set() |
|||
|
|||
for rule in router.iter_rules(): |
|||
if 'sitemap' in rule.endpoint.routing and rule.endpoint.routing['sitemap'] is not True: |
|||
if rule.endpoint in sitemap_endpoint_done: |
|||
continue |
|||
sitemap_endpoint_done.add(rule.endpoint) |
|||
|
|||
func = rule.endpoint.routing['sitemap'] |
|||
if func is False: |
|||
continue |
|||
for loc in func(self.env, rule, query_string): |
|||
if self._check_loc_url(loc): |
|||
yield loc |
|||
continue |
|||
|
|||
if not self.rule_is_enumerable(rule): |
|||
continue |
|||
|
|||
if 'sitemap' not in rule.endpoint.routing: |
|||
logger.warning('No Sitemap value provided for controller %s (%s)' % |
|||
(rule.endpoint.method, ','.join(rule.endpoint.routing['routes']))) |
|||
|
|||
converters = rule._converters or {} |
|||
if query_string and not converters and (query_string not in rule.build({}, append_unknown=False)[1]): |
|||
continue |
|||
|
|||
values = [{}] |
|||
# converters with a domain are processed after the other ones |
|||
convitems = sorted( |
|||
converters.items(), |
|||
key=lambda x: (hasattr(x[1], 'domain') and (x[1].domain != '[]'), rule._trace.index((True, x[0])))) |
|||
|
|||
for (i, (name, converter)) in enumerate(convitems): |
|||
if 'website_id' in self.env[converter.model]._fields and (not converter.domain or converter.domain == '[]'): |
|||
converter.domain = "[('website_id', 'in', (False, current_website_id))]" |
|||
|
|||
newval = [] |
|||
for val in values: |
|||
query = i == len(convitems) - 1 and query_string |
|||
if query: |
|||
r = "".join([x[1] for x in rule._trace[1:] if not x[0]]) # remove model converter from route |
|||
query = sitemap_qs2dom(query, r, self.env[converter.model]._rec_name) |
|||
if query == FALSE_DOMAIN: |
|||
continue |
|||
|
|||
for rec in converter.generate(uid=self.env.uid, dom=query, args=val): |
|||
newval.append(val.copy()) |
|||
newval[-1].update({name: rec}) |
|||
values = newval |
|||
|
|||
for value in values: |
|||
domain_part, url = rule.build(value, append_unknown=False) |
|||
if not query_string or query_string.lower() in url.lower(): |
|||
page = {'loc': url} |
|||
if url in url_set: |
|||
continue |
|||
url_set.add(url) |
|||
|
|||
if self._check_loc_url(page): |
|||
yield page |
|||
|
|||
# '/' already has a http.route & is in the routing_map so it will already have an entry in the xml |
|||
domain = [('url', '!=', '/')] |
|||
if not force: |
|||
domain += [('website_indexed', '=', True), ('visibility', '=', False)] |
|||
# is_visible |
|||
domain += [ |
|||
('website_published', '=', True), ('visibility', '=', False), |
|||
'|', ('date_publish', '=', False), ('date_publish', '<=', fields.Datetime.now()) |
|||
] |
|||
|
|||
if query_string: |
|||
domain += [('url', 'like', query_string)] |
|||
|
|||
pages = self._get_website_pages(domain) |
|||
|
|||
for page in pages: |
|||
record = {'loc': page['url'], 'id': page['id'], 'name': page['name']} |
|||
if page.view_id and page.view_id.priority != 16: |
|||
record['priority'] = min(round(page.view_id.priority / 32.0, 1), 1) |
|||
if page['write_date']: |
|||
record['lastmod'] = page['write_date'].date() |
|||
|
|||
if self._check_loc_url(record): |
|||
yield record |
|||
|
|||
|
|||
def _check_loc_url(self, loc): |
|||
if self.le_excl_sitemap_url: |
|||
urls = self.le_excl_sitemap_url.split('\n') |
|||
|
|||
if loc['loc'] in urls: |
|||
return False |
|||
|
|||
return True |
After Width: | Height: | Size: 3.8 KiB |
After Width: | Height: | Size: 3.7 KiB |
After Width: | Height: | Size: 3.4 KiB |
After Width: | Height: | Size: 53 KiB |
After Width: | Height: | Size: 40 KiB |
@ -0,0 +1,74 @@ |
|||
<section class="oe_container"> |
|||
<div class="oe_row oe_spaced"> |
|||
<h2 class="oe_slogan" style="color: #138513; font-weight: bold;">Remove Sitemap URLS</h2> |
|||
<h3 class="oe_slogan" style="color: #138513; font-weight: bold;">By Lean Easy Ltd</h3> |
|||
<a href="https://www.leaneasy.co.uk"><img class="mx-auto" style="width: 10%; text-align: center;" src="Lean Easy Logo.png"/><a/> |
|||
</div> |
|||
<div class="oe_row oe_spaced"> |
|||
<p> |
|||
Easily remove unwanted URLs from your sitemap, such as /website/info and a redirected links. |
|||
</p> |
|||
<br/> |
|||
<p>Only tested on Odoo Community Edition</p> |
|||
</div> |
|||
</section> |
|||
|
|||
<section class="oe_container oe_dark"> |
|||
<div class="oe_row oe_spaced"> |
|||
<h2 class="oe_slogan" style="color: #138513; font-weight: bold;">Overview</h2> |
|||
|
|||
<div class="oe_span12"> |
|||
<h3 class="oe_slogan" style="color: #138513; font-weight: bold;">Add URLs separated by new lines in settings.</h3> |
|||
<img class="oe_picture oe_screenshot mx-auto" src="settings.jpg" /> |
|||
</div> |
|||
</div> |
|||
</section> |
|||
|
|||
<section class="oe_container oe_dark" style="background-color: #15041c; border-radius: 30px"> |
|||
<div class="d-flex justify-content-center pt-3"> |
|||
<img src="Lean Easy Logo.png" alt="" class="img img-fluid" style="height: 100px" /> |
|||
</div> |
|||
<div class="justify-content-center row mx-0 pt-3 pb-3"> |
|||
<div class="col-8 text-center"> |
|||
<p style="color: #f3f3f3"> |
|||
We are a UK based Odoo development team specialising in Python, PostgreSQL, JavaScript and XML. We can supply bespoke odoo solutions including modules, customisations and website themes. We have worked closely with other companies and look forward to working with you, so feel |
|||
free to get in touch with any support questions or bespoke requests. |
|||
</p> |
|||
<h5 class="mb-2" style="color: white">Contact us by copying the link below:</h5> |
|||
<span class="" style="background-color: white; color: #212529; border-radius: 100px; border: 4px solid lime; padding: 5px 20px; display: inline-block">https://www.leaneasy.co.uk/contactus</span> |
|||
</div> |
|||
</div> |
|||
<hr style="background: #f3f3f3" /> |
|||
<div class="justify-content-center row mx-0"> |
|||
<div class="col-12 col-md-4 p-3"> |
|||
<div class="d-flex align-items-center" style="background-color: #f3f3f3; border-radius: 30px"> |
|||
<div class=""> |
|||
<img src="20945457.png" alt="" class="img img-fluid" style="height: 100px" /> |
|||
</div> |
|||
<div class=""> |
|||
<strong>Module<br />Development</strong> |
|||
</div> |
|||
</div> |
|||
</div> |
|||
<div class="col-12 col-md-4 p-3"> |
|||
<div class="d-flex align-items-center" style="background-color: #f3f3f3; border-radius: 30px"> |
|||
<div class=""> |
|||
<img src="20943761.png" alt="" class="img img-fluid" style="height: 100px" /> |
|||
</div> |
|||
<div class=""> |
|||
<strong>Module<br />Customisation</strong> |
|||
</div> |
|||
</div> |
|||
</div> |
|||
<div class="col-12 col-md-4 p-3"> |
|||
<div class="d-flex align-items-center" style="background-color: #f3f3f3; border-radius: 30px"> |
|||
<div class=""> |
|||
<img src="20945365.png" alt="" class="img img-fluid" style="height: 100px" /> |
|||
</div> |
|||
<div class=""> |
|||
<strong>Odoo<br />Websites</strong> |
|||
</div> |
|||
</div> |
|||
</div> |
|||
</div> |
|||
</section> |
After Width: | Height: | Size: 35 KiB |
After Width: | Height: | Size: 120 KiB |
@ -0,0 +1,26 @@ |
|||
<?xml version="1.0" encoding="UTF-8" ?><odoo> |
|||
|
|||
<!--Config Form--> |
|||
<record id="res_config_settings_view_form" model="ir.ui.view"> |
|||
<field name="name">res.config.settings.iw.website.exclude.view.form</field> |
|||
<field name="model">res.config.settings</field> |
|||
<field name="inherit_id" ref="website.res_config_settings_view_form"/> |
|||
<field name="arch" type="xml"> |
|||
<xpath expr="//div[@id='robots_setting'][2]" position="after"> |
|||
<div class="col-12 col-lg-6 o_setting_box"> |
|||
<div class="o_setting_left_pane"></div> |
|||
<div class="o_setting_right_pane"> |
|||
<label for="le_excl_sitemap_url"/> |
|||
<div class="text-muted"> |
|||
Each URL on a different line. Formating : /blog /website/info. |
|||
</div> |
|||
<div class="content-group mt16"> |
|||
<field name="le_excl_sitemap_url"/> |
|||
</div> |
|||
</div> |
|||
</div> |
|||
</xpath> |
|||
</field> |
|||
</record> |
|||
|
|||
</odoo> |