commit
807c408602
19 changed files with 317 additions and 0 deletions
@ -0,0 +1,4 @@ |
|||||
|
# -*- coding: utf-8 -*- |
||||
|
|
||||
|
from . import models |
||||
|
from . import controllers |
@ -0,0 +1,26 @@ |
|||||
|
# -*- coding: utf-8 -*- |
||||
|
{ |
||||
|
'name': 'Sitemap URL Remover', |
||||
|
'description': 'This remove the unwanted urls from the sutemap url for website.', |
||||
|
'summary': 'Remove URLs from the sitemap for better search engine indexing', |
||||
|
'category': 'Website', |
||||
|
'version': '14.0.0.1', |
||||
|
'author': "Magnetposts.com", |
||||
|
'company': 'Magnetposts.com', |
||||
|
'maintainer': 'Magnetposts', |
||||
|
'website': "https://www.magnetposts.com", |
||||
|
'currency': 'USD', |
||||
|
'category': 'Website', |
||||
|
'depends': ['website'], |
||||
|
'data': [ |
||||
|
'security/ir.model.access.csv', |
||||
|
'views/seo_seo_view.xml', |
||||
|
], |
||||
|
'images': [ |
||||
|
'static/description/cover.gif', |
||||
|
], |
||||
|
'license': 'LGPL-3', |
||||
|
'installable': True, |
||||
|
'application': True, |
||||
|
'auto_install': False, |
||||
|
} |
Binary file not shown.
@ -0,0 +1 @@ |
|||||
|
from . import main |
Binary file not shown.
Binary file not shown.
@ -0,0 +1,93 @@ |
|||||
|
import logging |
||||
|
import datetime |
||||
|
import base64 |
||||
|
import copy |
||||
|
|
||||
|
from odoo import http, fields, _ |
||||
|
from odoo.http import request |
||||
|
|
||||
|
from odoo.addons.website.controllers.main import Website |
||||
|
|
||||
|
SITEMAP_CACHE_TIME = datetime.timedelta(hours=12) |
||||
|
LOC_PER_SITEMAP = 45000 |
||||
|
|
||||
|
|
||||
|
class WebsiteExtended(Website): |
||||
|
|
||||
|
@http.route('/sitemap.xml', type='http', auth="public", website=True, multilang=False, sitemap=False) |
||||
|
def sitemap_xml_index(self, **kwargs): |
||||
|
current_website = request.website |
||||
|
Attachment = request.env['ir.attachment'].sudo() |
||||
|
View = request.env['ir.ui.view'].sudo() |
||||
|
mimetype = 'application/xml;charset=utf-8' |
||||
|
content = None |
||||
|
|
||||
|
def create_sitemap(url, content): |
||||
|
return Attachment.create({ |
||||
|
'raw': content.encode(), |
||||
|
'mimetype': mimetype, |
||||
|
'type': 'binary', |
||||
|
'name': url, |
||||
|
'url': url, |
||||
|
}) |
||||
|
dom = [('url', '=', '/sitemap-%d.xml' % current_website.id), ('type', '=', 'binary')] |
||||
|
sitemap = Attachment.search(dom, limit=1) |
||||
|
seos = request.env['seo.seo'].sudo().search([('is_indexed', '=', False)]) |
||||
|
if sitemap and not seos: |
||||
|
# Check if stored version is still valid |
||||
|
create_date = fields.Datetime.from_string(sitemap.create_date) |
||||
|
delta = datetime.datetime.now() - create_date |
||||
|
if delta < SITEMAP_CACHE_TIME: |
||||
|
content = base64.b64decode(sitemap.datas) |
||||
|
|
||||
|
if not content: |
||||
|
# Remove all sitemaps in ir.attachments as we're going to regenerated them |
||||
|
dom = [('type', '=', 'binary'), '|', ('url', '=like', '/sitemap-%d-%%.xml' % current_website.id), |
||||
|
('url', '=', '/sitemap-%d.xml' % current_website.id)] |
||||
|
sitemaps = Attachment.search(dom) |
||||
|
sitemaps.unlink() |
||||
|
|
||||
|
pages = 0 |
||||
|
locs = request.website.with_user(request.website.user_id)._enumerate_pages() |
||||
|
locs = list(locs) |
||||
|
for rec in request.env['seo.seo'].sudo().search([]): |
||||
|
# for item in enumerate(locs): |
||||
|
# if rec.url_containing in item['loc']: |
||||
|
# del locs[n] |
||||
|
locs = [item for item in locs if rec.url_containing not in item['loc']] |
||||
|
rec.is_indexed = True |
||||
|
while True: |
||||
|
values = { |
||||
|
'locs': locs, |
||||
|
'url_root': request.httprequest.url_root[:-1], |
||||
|
} |
||||
|
urls = View._render_template('website.sitemap_locs', values) |
||||
|
if urls.strip(): |
||||
|
content = View._render_template('website.sitemap_xml', {'content': urls}) |
||||
|
pages += 1 |
||||
|
last_sitemap = create_sitemap('/sitemap-%d-%d.xml' % (current_website.id, pages), content) |
||||
|
if len(locs) * pages < LOC_PER_SITEMAP: |
||||
|
break |
||||
|
else: |
||||
|
break |
||||
|
|
||||
|
if not pages: |
||||
|
return request.not_found() |
||||
|
elif pages == 1: |
||||
|
# rename the -id-page.xml => -id.xml |
||||
|
last_sitemap.write({ |
||||
|
'url': "/sitemap-%d.xml" % current_website.id, |
||||
|
'name': "/sitemap-%d.xml" % current_website.id, |
||||
|
}) |
||||
|
else: |
||||
|
# TODO: in master/saas-15, move current_website_id in template directly |
||||
|
pages_with_website = ["%d-%d" % (current_website.id, p) for p in range(1, pages + 1)] |
||||
|
|
||||
|
# Sitemaps must be split in several smaller files with a sitemap index |
||||
|
content = View._render_template('website.sitemap_index_xml', { |
||||
|
'pages': pages_with_website, |
||||
|
'url_root': request.httprequest.url_root, |
||||
|
}) |
||||
|
create_sitemap('/sitemap-%d.xml' % current_website.id, content) |
||||
|
|
||||
|
return request.make_response(content, [('Content-Type', mimetype)]) |
@ -0,0 +1 @@ |
|||||
|
from . import seo_seo |
Binary file not shown.
Binary file not shown.
@ -0,0 +1,13 @@ |
|||||
|
# -*- coding: utf-8 -*- |
||||
|
# Part of Odoo. See LICENSE file for full copyright and licensing details. |
||||
|
|
||||
|
from odoo import api, fields, models |
||||
|
|
||||
|
|
||||
|
class SeoSeo(models.Model): |
||||
|
_name = 'seo.seo' |
||||
|
_rec_name = 'name' |
||||
|
|
||||
|
name = fields.Char('Name', required=True) |
||||
|
url_containing = fields.Char('URL containing') |
||||
|
is_indexed = fields.Boolean(default=False) |
After Width: | Height: | Size: 1.2 MiB |
After Width: | Height: | Size: 72 KiB |
After Width: | Height: | Size: 58 KiB |
After Width: | Height: | Size: 170 KiB |
After Width: | Height: | Size: 105 KiB |
@ -0,0 +1,132 @@ |
|||||
|
<div class="row py-3"> |
||||
|
<div class="col-md-12"> |
||||
|
<div class="alert alert-info" role="alert"> |
||||
|
<p class="mb-0"> <i class="fa fa-info-circle"> </i> Module developed on the top of <strong>website</strong>.</p> |
||||
|
</div> |
||||
|
</div> |
||||
|
<div class="col-md-6 py-3" style="text-align: center;"> |
||||
|
<h1 style="color: #000;font-weight: bold;margin-top: 100px;"> |
||||
|
This application removes the unwanted urls from the sitemap.xml file. That avoid unwanted server overloading by the search engine and other website crawlers. |
||||
|
</h1> |
||||
|
</div> |
||||
|
<div class="col-md-6"> |
||||
|
<img class="img img-fluid shadow" src="icon.png" |
||||
|
style="/* background-color: #0f0f0c; *//* padding: 9px 0px; */border-radius: 10px;border: 1px solid #cccccc7a;background-color: #f8f9fa;padding-top: 10px;"> |
||||
|
</div> |
||||
|
</div> |
||||
|
|
||||
|
<h1 style="color: #000;font-weight: bold;/* font-size: 50px; */" class="mt-5 text-center mb-0">How it works?</h1> |
||||
|
<div class="text-center text-muted" style="font-weight:400; margin-bottom:18px"> |
||||
|
<span style="width:73px;height: 10px;display:inline-block;border-radius: 4px;background-color: #ff1e00;"> </span> |
||||
|
</div> |
||||
|
|
||||
|
<div class="row py-3"> |
||||
|
<div class="col-md-6 py-3 d-flex flex-column justify-content-center" style="text-align: center;"> |
||||
|
<h1 style="font-weight: bold;">Check unwanted urls</h1> |
||||
|
<p class="lead pr-4" style="color: #000;font-size: 20px;font-weight: 300;font-family: lato;"> |
||||
|
Open the <strong>/sitemap.xml</strong> url in your browser and check the unwanted URL's format. |
||||
|
</p> |
||||
|
</div> |
||||
|
<div class="col-md-6"> |
||||
|
<img class="img img-fluid shadow" src="images/Image_02.png" |
||||
|
style="background-color: #0f0f0c;padding: 9px 0px;border-radius: 10px;"> |
||||
|
</div> |
||||
|
</div> |
||||
|
|
||||
|
<div class="row py-3"> |
||||
|
<div class="col-md-6"> |
||||
|
<img class="img img-fluid shadow" src="images/Image_01.png" |
||||
|
style="border-radius: 10px;border: 1px solid #cccccc7a;background-color: #ffffff;padding: 10px;"> |
||||
|
</div> |
||||
|
<div class="col-md-6 py-3 d-flex flex-column justify-content-center" style="text-align: center;"> |
||||
|
<h1 style="font-weight: bold;">Create record for selected format</h1> |
||||
|
<p class="lead pr-4" style="color: #000;font-size: 20px;font-weight: 300;font-family: lato;"> |
||||
|
Go to website >> click on menu - Remove Sitemap URL >> Create a record (As shown in screenshot) |
||||
|
</p> |
||||
|
</div> |
||||
|
</div> |
||||
|
|
||||
|
<div class="row py-3"> |
||||
|
<div class="col-md-6 py-3 d-flex flex-column justify-content-center" style="text-align: center;"> |
||||
|
<h1 style="font-weight: bold;">Check sitemap URLs</h1> |
||||
|
<p class="lead pr-4" style="color: #000;font-size: 20px;font-weight: 300;font-family: lato;"> |
||||
|
Boom.. All urls removed from the sitemap. |
||||
|
</p> |
||||
|
</div> |
||||
|
<div class="col-md-6"> |
||||
|
<img class="img img-fluid shadow" src="images/Image_03.png" |
||||
|
style="border-radius: 10px;border: 1px solid #cccccc7a;background-color: #ffffff;padding: 10px;"> |
||||
|
</div> |
||||
|
</div> |
||||
|
|
||||
|
<h1 style="color: #000;font-weight: bold;/* font-size: 50px; */" class="mt-5 text-center mb-0">How to configure</h1> |
||||
|
<div class="text-center text-muted" style="font-weight:400; margin-bottom:18px"> |
||||
|
<span style="width:73px;height: 10px;display:inline-block;border-radius: 4px;background-color: #ff3300;"> </span> |
||||
|
</div> |
||||
|
|
||||
|
<h3> |
||||
|
<span class="badge badge-pill mr-2" |
||||
|
style="background-color: #0077ff;color: #fff;padding: 5px 17px;font-size: 14px;"> Step 1 </span><span |
||||
|
style="display: inline-block;font-size: 19px;"> Download the module and place the module in apps folder. </span> |
||||
|
</h3> |
||||
|
|
||||
|
<h3> |
||||
|
<span class="badge badge-pill mr-2" |
||||
|
style="background-color: #0077ff;color: #fff;padding: 5px 17px;font-size: 14px;"> Step 2 </span><span |
||||
|
style="display: inline-block;font-size: 19px;"> |
||||
|
Install this module in your Odoo instance. |
||||
|
</span> |
||||
|
</h3> |
||||
|
|
||||
|
<h3> |
||||
|
<span class="badge badge-pill mr-2" |
||||
|
style="background-color: #0077ff;color: #fff;padding: 5px 17px;font-size: 14px;"> Step 3 </span><span |
||||
|
style="display: inline-block;font-size: 19px;"> Activate |
||||
|
<span style="color:#0077ff;"> developer mode. </span> |
||||
|
and open settings. |
||||
|
</span> |
||||
|
</h3> |
||||
|
|
||||
|
<h3> |
||||
|
<span class="badge badge-pill mr-2" |
||||
|
style="background-color: #0077ff;color: #fff;padding: 5px 17px;font-size: 14px;"> Step 4 </span><span |
||||
|
style="display: inline-block;font-size: 19px;"> Go to Website >> Sitemap URL Remove >> Add records. |
||||
|
</span> |
||||
|
</h3> |
||||
|
|
||||
|
<h3 class="mt-3"> |
||||
|
<span class="badge badge-pill mr-2" |
||||
|
style="background-color: #1ab5b2;color: #fff;padding: 5px 17px;font-size: 14px;"> <i class="fa fa-thumbs-up"> |
||||
|
</i> DONE </span><span style="display: inline-block;font-size: 19px;"> |
||||
|
That's it done. |
||||
|
</span> |
||||
|
</h3> |
||||
|
|
||||
|
<h1 style="color: #000;font-weight: bold;/* font-size: 50px; */" class="mt-5 text-center mb-0">Changelog</h1> |
||||
|
<div class="text-center text-muted" style="font-weight:400; margin-bottom:18px"> |
||||
|
<span style="width:73px;height: 10px;display:inline-block;border-radius: 4px;background-color: #ff3300;"> </span> |
||||
|
</div> |
||||
|
|
||||
|
<div class="card mx-auto w-md-75"> |
||||
|
<div class="card-header bg-200"> |
||||
|
<h4 class="m-0">v14.0.0.1</h4> |
||||
|
</div> |
||||
|
<div class="card-body"> |
||||
|
<div> <b class="text-success"> NEW </b> New extended module for v14. </div> |
||||
|
</div> |
||||
|
</div> |
||||
|
|
||||
|
<div class="row mt-5 border text-center"> |
||||
|
<div class="col-md-6 py-3" style="background-color: #ff8800;color: white;"> |
||||
|
<h4 style="color: white;" class="mb-0"> Developed by <b>Magnetposts</b></h4> |
||||
|
<div style="font-family: 'Montserrat';font-weight: 500;"> |
||||
|
https://www.magnetposts.com |
||||
|
</div> |
||||
|
</div> |
||||
|
<div class="col-md-6 border-right py-3" style="background-color: #5d0df0;color: white;"> |
||||
|
<h4 style="color: white;" class="mb-0"> Contact Us</h4> |
||||
|
<div style="font-family: 'Montserrat';font-weight: 500;color: #ffffff;"> |
||||
|
contact@magnetposts.com |
||||
|
</div> |
||||
|
</div> |
||||
|
</div> |
@ -0,0 +1,45 @@ |
|||||
|
<?xml version="1.0" encoding="utf-8"?> |
||||
|
<odoo> |
||||
|
|
||||
|
<record id="view_seo_seo_list" model="ir.ui.view"> |
||||
|
<field name="name">seo.seo.list</field> |
||||
|
<field name="model">seo.seo</field> |
||||
|
<field name="arch" type="xml"> |
||||
|
<tree string="Seo"> |
||||
|
<field name="name"/> |
||||
|
<field name="url_containing"/> |
||||
|
</tree> |
||||
|
</field> |
||||
|
</record> |
||||
|
|
||||
|
<record id="view_seo_seo_form" model="ir.ui.view"> |
||||
|
<field name="name">seo.seo.form</field> |
||||
|
<field name="model">seo.seo</field> |
||||
|
<field name="arch" type="xml"> |
||||
|
<form string="Seo"> |
||||
|
<sheet> |
||||
|
<group> |
||||
|
<field name="name"/> |
||||
|
<field name="url_containing"/> |
||||
|
<field name="is_indexed"/> |
||||
|
</group> |
||||
|
</sheet> |
||||
|
</form> |
||||
|
</field> |
||||
|
</record> |
||||
|
|
||||
|
<record id="action_seo_seo" model="ir.actions.act_window"> |
||||
|
<field name="name">Seo Optimize</field> |
||||
|
<field name="res_model">seo.seo</field> |
||||
|
<field name="view_mode">tree,form</field> |
||||
|
</record> |
||||
|
|
||||
|
<menuitem |
||||
|
name="Sitemap URL Remove" |
||||
|
id="menu_seo_seo" |
||||
|
sequence="22" |
||||
|
parent="website.menu_website_configuration" |
||||
|
groups="website.group_website_designer" |
||||
|
action="action_seo_seo"/> |
||||
|
|
||||
|
</odoo> |
Loading…
Reference in new issue