Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 20 additions & 7 deletions document_page/README.rst
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
.. image:: https://odoo-community.org/readme-banner-image
:target: https://odoo-community.org/get-involved?utm_source=readme
:alt: Odoo Community Association

=============
Document Page
=============
Expand All @@ -17,7 +13,7 @@ Document Page
.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png
:target: https://odoo-community.org/page/development-status
:alt: Beta
.. |badge2| image:: https://img.shields.io/badge/license-AGPL--3-blue.png
.. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
:alt: License: AGPL-3
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fknowledge-lightgray.png?logo=github
Expand Down Expand Up @@ -61,6 +57,12 @@ To use this module, you need to:
- Click on Pages to create pages and select the previous category to use
the template

Improve diff of history
-----------------------

If you want to improve how history is shown, you can install html_diff
python library. A new comparison method will be installed.

Bug Tracker
===========

Expand All @@ -83,23 +85,34 @@ Contributors
------------

- Gervais Naoussi <gervaisnaoussi@gmail.com>

- Maxime Chambreuil <mchambreuil@ursainfosystems.com>

- Iván Todorovich <ivan.todorovich@gmail.com>

- Jose Maria Alzaga <jose.alzaga@aselcis.com>

- Lois Rilo <lois.rilo@forgeflow.com>

- Simone Orsi <simone.orsi@camptocamp.com>

- `Tecnativa <https://www.tecnativa.com>`__:

- Ernesto Tejeda
- Víctor Martínez

Trobz
- Trobz

- Dung Tran <dungtd@trobz.com>

- Dung Tran <dungtd@trobz.com>
- `Sygel <https://www.sygel.es>`__:

- Ángel García de la Chica Herrera

- `Dixmit <https://www.dixmit.com>`__:

- Enric Tobella

Other credits
-------------

Expand Down
5 changes: 4 additions & 1 deletion document_page/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
],
"website": "https://github.com/OCA/knowledge",
"license": "AGPL-3",
"depends": ["mail", "document_knowledge"],
"depends": ["mail", "document_knowledge", "web_editor"],
"data": [
"security/document_page_security.xml",
"security/ir.model.access.csv",
Expand All @@ -30,6 +30,9 @@
],
"demo": ["demo/document_page.xml"],
"assets": {
"web._assets_primary_variables": [
"document_page/static/src/**/document_page_variables.scss",
],
"web.assets_backend": [
"document_page/static/src/scss/document_page.scss",
"document_page/static/src/js/document_page_kanban_controller.esm.js",
Expand Down
27 changes: 6 additions & 21 deletions document_page/models/document_page_history.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

import difflib

from odoo import api, fields, models

from odoo.addons.web_editor.models.diff_utils import (
generate_comparison,
)


class DocumentPageHistory(models.Model):
"""This model is necessary to manage a document history."""
Expand All @@ -17,7 +20,7 @@ class DocumentPageHistory(models.Model):
name = fields.Char(index=True)
summary = fields.Char(index=True)
content = fields.Html(sanitize=False)
diff = fields.Html(compute="_compute_diff")
diff = fields.Html(compute="_compute_diff", sanitize_tags=False)

company_id = fields.Many2one(
"res.company",
Expand All @@ -43,28 +46,10 @@ def _compute_diff(self):
)
rec.diff = self._get_diff(prev.id, rec.id)

@api.model
def _get_diff(self, v1, v2):
"""Return the difference between two version of document version."""
text1 = v1 and self.browse(v1).content or ""
text2 = v2 and self.browse(v2).content or ""
# Include line breaks to make it more readable
# TODO: consider using a beautify library directly on the content
text1 = text1.replace("</p><p>", "</p>\r\n<p>")
text2 = text2.replace("</p><p>", "</p>\r\n<p>")
line1 = text1.splitlines(True)
line2 = text2.splitlines(True)
if line1 == line2:
return self.env._("There are no changes in revisions.")
else:
diff = difflib.HtmlDiff()
return diff.make_table(
line1,
line2,
f"Revision-{v1}",
f"Revision-{v2}",
context=True,
)
return generate_comparison(text1, text2)

@api.depends("page_id")
def _compute_display_name(self):
Expand Down
7 changes: 5 additions & 2 deletions document_page/readme/CONTRIBUTORS.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,11 @@
- Ernesto Tejeda
- Víctor Martínez

Trobz
- Trobz
- Dung Tran \<<dungtd@trobz.com>\>

- Dung Tran \<<dungtd@trobz.com>\>
- [Sygel](https://www.sygel.es):
- Ángel García de la Chica Herrera

- [Dixmit](https://www.dixmit.com):
- Enric Tobella
5 changes: 5 additions & 0 deletions document_page/readme/USAGE.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,8 @@ To use this module, you need to:
the template
- Click on Pages to create pages and select the previous category to use
the template

## Improve diff of history

If you want to improve how history is shown, you can install html_diff python library.
A new comparison method will be installed.
64 changes: 35 additions & 29 deletions document_page/static/description/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="generator" content="Docutils: https://docutils.sourceforge.io/" />
<title>README.rst</title>
<title>Document Page</title>
<style type="text/css">

/*
Expand Down Expand Up @@ -360,49 +360,47 @@
</style>
</head>
<body>
<div class="document">
<div class="document" id="document-page">
<h1 class="title">Document Page</h1>


<a class="reference external image-reference" href="https://odoo-community.org/get-involved?utm_source=readme">
<img alt="Odoo Community Association" src="https://odoo-community.org/readme-banner-image" />
</a>
<div class="section" id="document-page">
<h1>Document Page</h1>
<!-- !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:029a3933b3eea6e056988a1f6fb36f83a4539b5a7d32e7bef7b60dfc3f871c98
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
<p><a class="reference external image-reference" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <a class="reference external image-reference" href="http://www.gnu.org/licenses/agpl-3.0-standalone.html"><img alt="License: AGPL-3" src="https://img.shields.io/badge/license-AGPL--3-blue.png" /></a> <a class="reference external image-reference" href="https://github.com/OCA/knowledge/tree/18.0/document_page"><img alt="OCA/knowledge" src="https://img.shields.io/badge/github-OCA%2Fknowledge-lightgray.png?logo=github" /></a> <a class="reference external image-reference" href="https://translation.odoo-community.org/projects/knowledge-18-0/knowledge-18-0-document_page"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external image-reference" href="https://runboat.odoo-community.org/builds?repo=OCA/knowledge&amp;target_branch=18.0"><img alt="Try me on Runboat" src="https://img.shields.io/badge/runboat-Try%20me-875A7B.png" /></a></p>
<p><a class="reference external image-reference" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <a class="reference external image-reference" href="http://www.gnu.org/licenses/agpl-3.0-standalone.html"><img alt="License: AGPL-3" src="https://img.shields.io/badge/licence-AGPL--3-blue.png" /></a> <a class="reference external image-reference" href="https://github.com/OCA/knowledge/tree/18.0/document_page"><img alt="OCA/knowledge" src="https://img.shields.io/badge/github-OCA%2Fknowledge-lightgray.png?logo=github" /></a> <a class="reference external image-reference" href="https://translation.odoo-community.org/projects/knowledge-18-0/knowledge-18-0-document_page"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external image-reference" href="https://runboat.odoo-community.org/builds?repo=OCA/knowledge&amp;target_branch=18.0"><img alt="Try me on Runboat" src="https://img.shields.io/badge/runboat-Try%20me-875A7B.png" /></a></p>
<p>This module allows you to write web pages for internal documentation.</p>
<p><strong>Table of contents</strong></p>
<div class="contents local topic" id="contents">
<ul class="simple">
<li><a class="reference internal" href="#installation" id="toc-entry-1">Installation</a></li>
<li><a class="reference internal" href="#configuration" id="toc-entry-2">Configuration</a></li>
<li><a class="reference internal" href="#usage" id="toc-entry-3">Usage</a></li>
<li><a class="reference internal" href="#bug-tracker" id="toc-entry-4">Bug Tracker</a></li>
<li><a class="reference internal" href="#credits" id="toc-entry-5">Credits</a><ul>
<li><a class="reference internal" href="#authors" id="toc-entry-6">Authors</a></li>
<li><a class="reference internal" href="#contributors" id="toc-entry-7">Contributors</a></li>
<li><a class="reference internal" href="#other-credits" id="toc-entry-8">Other credits</a></li>
<li><a class="reference internal" href="#maintainers" id="toc-entry-9">Maintainers</a></li>
<li><a class="reference internal" href="#usage" id="toc-entry-3">Usage</a><ul>
<li><a class="reference internal" href="#improve-diff-of-history" id="toc-entry-4">Improve diff of history</a></li>
</ul>
</li>
<li><a class="reference internal" href="#bug-tracker" id="toc-entry-5">Bug Tracker</a></li>
<li><a class="reference internal" href="#credits" id="toc-entry-6">Credits</a><ul>
<li><a class="reference internal" href="#authors" id="toc-entry-7">Authors</a></li>
<li><a class="reference internal" href="#contributors" id="toc-entry-8">Contributors</a></li>
<li><a class="reference internal" href="#other-credits" id="toc-entry-9">Other credits</a></li>
<li><a class="reference internal" href="#maintainers" id="toc-entry-10">Maintainers</a></li>
</ul>
</li>
</ul>
</div>
<div class="section" id="installation">
<h2><a class="toc-backref" href="#toc-entry-1">Installation</a></h2>
<h1><a class="toc-backref" href="#toc-entry-1">Installation</a></h1>
<p>This module depends on module knowledge. So make sure to have it in your
addons list.</p>
</div>
<div class="section" id="configuration">
<h2><a class="toc-backref" href="#toc-entry-2">Configuration</a></h2>
<h1><a class="toc-backref" href="#toc-entry-2">Configuration</a></h1>
<p>No configuration required.</p>
</div>
<div class="section" id="usage">
<h2><a class="toc-backref" href="#toc-entry-3">Usage</a></h2>
<h1><a class="toc-backref" href="#toc-entry-3">Usage</a></h1>
<p>To use this module, you need to:</p>
<ul class="simple">
<li>Go to Knowledge menu</li>
Expand All @@ -411,25 +409,30 @@ <h2><a class="toc-backref" href="#toc-entry-3">Usage</a></h2>
<li>Click on Pages to create pages and select the previous category to use
the template</li>
</ul>
<div class="section" id="improve-diff-of-history">
<h2><a class="toc-backref" href="#toc-entry-4">Improve diff of history</a></h2>
<p>If you want to improve how history is shown, you can install html_diff
python library. A new comparison method will be installed.</p>
</div>
</div>
<div class="section" id="bug-tracker">
<h2><a class="toc-backref" href="#toc-entry-4">Bug Tracker</a></h2>
<h1><a class="toc-backref" href="#toc-entry-5">Bug Tracker</a></h1>
<p>Bugs are tracked on <a class="reference external" href="https://github.com/OCA/knowledge/issues">GitHub Issues</a>.
In case of trouble, please check there if your issue has already been reported.
If you spotted it first, help us to smash it by providing a detailed and welcomed
<a class="reference external" href="https://github.com/OCA/knowledge/issues/new?body=module:%20document_page%0Aversion:%2018.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
<p>Do not contact contributors directly about support or help with technical issues.</p>
</div>
<div class="section" id="credits">
<h2><a class="toc-backref" href="#toc-entry-5">Credits</a></h2>
<h1><a class="toc-backref" href="#toc-entry-6">Credits</a></h1>
<div class="section" id="authors">
<h3><a class="toc-backref" href="#toc-entry-6">Authors</a></h3>
<h2><a class="toc-backref" href="#toc-entry-7">Authors</a></h2>
<ul class="simple">
<li>OpenERP SA</li>
</ul>
</div>
<div class="section" id="contributors">
<h3><a class="toc-backref" href="#toc-entry-7">Contributors</a></h3>
<h2><a class="toc-backref" href="#toc-entry-8">Contributors</a></h2>
<ul class="simple">
<li>Gervais Naoussi &lt;<a class="reference external" href="mailto:gervaisnaoussi&#64;gmail.com">gervaisnaoussi&#64;gmail.com</a>&gt;</li>
<li>Maxime Chambreuil &lt;<a class="reference external" href="mailto:mchambreuil&#64;ursainfosystems.com">mchambreuil&#64;ursainfosystems.com</a>&gt;</li>
Expand All @@ -442,18 +445,22 @@ <h3><a class="toc-backref" href="#toc-entry-7">Contributors</a></h3>
<li>Víctor Martínez</li>
</ul>
</li>
</ul>
<p>Trobz</p>
<ul class="simple">
<li>Trobz<ul>
<li>Dung Tran &lt;<a class="reference external" href="mailto:dungtd&#64;trobz.com">dungtd&#64;trobz.com</a>&gt;</li>
</ul>
</li>
<li><a class="reference external" href="https://www.sygel.es">Sygel</a>:<ul>
<li>Ángel García de la Chica Herrera</li>
</ul>
</li>
<li><a class="reference external" href="https://www.dixmit.com">Dixmit</a>:<ul>
<li>Enric Tobella</li>
</ul>
</li>
</ul>
</div>
<div class="section" id="other-credits">
<h3><a class="toc-backref" href="#toc-entry-8">Other credits</a></h3>
<h2><a class="toc-backref" href="#toc-entry-9">Other credits</a></h2>
<p>The development of this module has been financially supported by:</p>
<ul class="simple">
<li>Odoo SA &lt;<a class="reference external" href="http://www.odoo.com">http://www.odoo.com</a>&gt;</li>
Expand All @@ -462,7 +469,7 @@ <h3><a class="toc-backref" href="#toc-entry-8">Other credits</a></h3>
</ul>
</div>
<div class="section" id="maintainers">
<h3><a class="toc-backref" href="#toc-entry-9">Maintainers</a></h3>
<h2><a class="toc-backref" href="#toc-entry-10">Maintainers</a></h2>
<p>This module is maintained by the OCA.</p>
<a class="reference external image-reference" href="https://odoo-community.org">
<img alt="Odoo Community Association" src="https://odoo-community.org/logo.png" />
Expand All @@ -475,6 +482,5 @@ <h3><a class="toc-backref" href="#toc-entry-9">Maintainers</a></h3>
</div>
</div>
</div>
</div>
</body>
</html>
52 changes: 32 additions & 20 deletions document_page/static/src/scss/document_page.scss
Original file line number Diff line number Diff line change
@@ -1,28 +1,40 @@
table.diff {
font-family: Courier;
border: medium;
.o_document_page_diff {
table.diff {
font-family: Courier;
border: medium;

.diff_header {
background-color: #e0e0e0;
}
.diff_header {
background-color: $o_document_page_diff_header_background;
}

td.diff_header {
text-align: right;
}
td.diff_header {
text-align: right;
}

.diff_next {
background-color: #c0c0c0;
}
.diff_next {
background-color: $o_document_page_diff_next_background;
}

.diff_add {
background-color: #aaffaa;
}
.diff_add {
background-color: $o_document_page_diff_add_background;
}

.diff_chg {
background-color: #ffff77;
}
.diff_chg {
background-color: $o_document_page_diff_change_background;
}

.diff_sub {
background-color: #ffaaaa;
.diff_sub {
background-color: $o_document_page_diff_subtract_background;
}
}
removed {
display: inline;
text-decoration: line-through;
opacity: 0.5;
background-color: $o_document_page_diff_subtract_background;
}
added {
display: inline;
background-color: $o_document_page_diff_add_background;
}
}
5 changes: 5 additions & 0 deletions document_page/static/src/scss/document_page_variables.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
$o_document_page_diff_header_background: #e0e0e0;
$o_document_page_diff_next_background: #c0c0c0;
$o_document_page_diff_add_background: #aaffaa;
$o_document_page_diff_change_background: #ffff77;
$o_document_page_diff_subtract_background: #ffaaaa;
Loading