mirror of
https://github.com/OCA/knowledge.git
synced 2025-07-27 10:58:41 -06:00
[ADD] website_document_page
This commit is contained in:
parent
84e8bc4b32
commit
a0216780f8
1
setup/website_document_page/odoo/addons/website_document_page
Symbolic link
1
setup/website_document_page/odoo/addons/website_document_page
Symbolic link
@ -0,0 +1 @@
|
||||
../../../../website_document_page
|
6
setup/website_document_page/setup.py
Normal file
6
setup/website_document_page/setup.py
Normal file
@ -0,0 +1,6 @@
|
||||
import setuptools
|
||||
|
||||
setuptools.setup(
|
||||
setup_requires=['setuptools-odoo'],
|
||||
odoo_addon=True,
|
||||
)
|
21
website_document_page/README.rst
Normal file
21
website_document_page/README.rst
Normal file
@ -0,0 +1,21 @@
|
||||
**This file is going to be generated by oca-gen-addon-readme.**
|
||||
|
||||
*Manual changes will be overwritten.*
|
||||
|
||||
Please provide content in the ``readme`` directory:
|
||||
|
||||
* **DESCRIPTION.rst** (required)
|
||||
* INSTALL.rst (optional)
|
||||
* CONFIGURE.rst (optional)
|
||||
* **USAGE.rst** (optional, highly recommended)
|
||||
* DEVELOP.rst (optional)
|
||||
* ROADMAP.rst (optional)
|
||||
* HISTORY.rst (optional, recommended)
|
||||
* **CONTRIBUTORS.rst** (optional, highly recommended)
|
||||
* CREDITS.rst (optional)
|
||||
|
||||
Content of this README will also be drawn from the addon manifest,
|
||||
from keys such as name, authors, maintainers, development_status,
|
||||
and license.
|
||||
|
||||
A good, one sentence summary in the manifest is also highly recommended.
|
4
website_document_page/__init__.py
Normal file
4
website_document_page/__init__.py
Normal file
@ -0,0 +1,4 @@
|
||||
# Copyright (C) 2020 Open Source Integrators
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||
from . import controllers
|
||||
from . import models
|
23
website_document_page/__manifest__.py
Normal file
23
website_document_page/__manifest__.py
Normal file
@ -0,0 +1,23 @@
|
||||
# Copyright (C) 2020 Open Source Integrators
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||
{
|
||||
"name": "Website Document Page",
|
||||
"summary": "Provides a wiki to host documentation",
|
||||
"version": "13.0.1.0.0",
|
||||
"category": "Knowledge Management",
|
||||
"author": "Open Source Integrators, Odoo Community Association (OCA)",
|
||||
"website": "https://github.com/OCA/knowledge",
|
||||
"license": "AGPL-3",
|
||||
"depends": ["document_tag", "website"],
|
||||
"data": [
|
||||
"security/ir.model.access.csv",
|
||||
"security/ir_rule.xml",
|
||||
"views/templates.xml",
|
||||
"views/document_page.xml",
|
||||
"views/document_tag.xml",
|
||||
"views/website.xml",
|
||||
"data/website_menu.xml",
|
||||
],
|
||||
"development_status": "Alpha",
|
||||
"maintainers": ["max3903"],
|
||||
}
|
3
website_document_page/controllers/__init__.py
Normal file
3
website_document_page/controllers/__init__.py
Normal file
@ -0,0 +1,3 @@
|
||||
# Copyright (C) 2020 Open Source Integrators
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||
from . import main
|
64
website_document_page/controllers/main.py
Normal file
64
website_document_page/controllers/main.py
Normal file
@ -0,0 +1,64 @@
|
||||
# Copyright (C) 20020 Open Source Integrators
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||
from odoo import http
|
||||
from odoo.http import request
|
||||
|
||||
|
||||
class WikiController(http.Controller):
|
||||
@http.route(
|
||||
[
|
||||
"""/wiki""",
|
||||
"""/wiki/page/<model('document.page'):page>""",
|
||||
"""/wiki/category/<model('document.page'):category>""",
|
||||
"""/wiki/tag/<model('document.tag'):tag>""",
|
||||
],
|
||||
type="http",
|
||||
auth="public",
|
||||
website=True,
|
||||
)
|
||||
def wiki(self, page=None, category=None, tag=None, search=""):
|
||||
Page = request.env["document.page"]
|
||||
Tag = request.env["document.tag"]
|
||||
pages = {}
|
||||
page_tags = {}
|
||||
|
||||
# Page
|
||||
if not page and not category and not tag and not search:
|
||||
website = request.env["website"].get_current_website()
|
||||
page_id = website.wiki_id.id or False
|
||||
page = Page.browse(page_id)
|
||||
# Page Tags
|
||||
if page:
|
||||
page_tags = page.tag_ids
|
||||
# Category
|
||||
if category:
|
||||
pages = Page.search([("parent_id", "=", category.id)])
|
||||
# Tag
|
||||
if tag:
|
||||
pages = Page.search([("tag_ids", "in", tag.id)])
|
||||
# Search
|
||||
if search:
|
||||
pages = Page.search(
|
||||
["|", ("name", "like", search), ("content", "like", search)]
|
||||
)
|
||||
search_count = len(pages)
|
||||
# Menu
|
||||
menu_categories = Page.search(
|
||||
[("parent_id", "=", False), ("is_menu", "=", True)]
|
||||
)
|
||||
menu_pages = Page.search([("parent_id", "!=", False), ("is_menu", "=", True)])
|
||||
menu_tags = Tag.search([("is_menu", "=", True)])
|
||||
|
||||
values = {
|
||||
"category": category,
|
||||
"pages": pages,
|
||||
"page": page,
|
||||
"page_tags": page_tags,
|
||||
"tag": tag,
|
||||
"search": search,
|
||||
"search_count": search_count,
|
||||
"menu_categories": menu_categories,
|
||||
"menu_pages": menu_pages,
|
||||
"menu_tags": menu_tags,
|
||||
}
|
||||
return request.render("website_document_page.wiki", values)
|
8
website_document_page/data/website_menu.xml
Normal file
8
website_document_page/data/website_menu.xml
Normal file
@ -0,0 +1,8 @@
|
||||
<odoo noupdate="1">
|
||||
<record id="menu_wiki" model="website.menu">
|
||||
<field name="name">Wiki</field>
|
||||
<field name="url">/wiki</field>
|
||||
<field name="parent_id" ref="website.main_menu" />
|
||||
<field name="sequence" type="int">30</field>
|
||||
</record>
|
||||
</odoo>
|
7
website_document_page/models/__init__.py
Normal file
7
website_document_page/models/__init__.py
Normal file
@ -0,0 +1,7 @@
|
||||
# Copyright (C) 2020 Open Source Integrators
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||
from . import (
|
||||
document_page,
|
||||
document_tag,
|
||||
website,
|
||||
)
|
16
website_document_page/models/document_page.py
Normal file
16
website_document_page/models/document_page.py
Normal file
@ -0,0 +1,16 @@
|
||||
# Copyright (C) 2020 Open Source Integrators
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||
from odoo import fields, models
|
||||
|
||||
|
||||
class DocumentPage(models.Model):
|
||||
_inherit = [
|
||||
"document.page",
|
||||
"website.seo.metadata",
|
||||
"website.published.multi.mixin",
|
||||
]
|
||||
_name = "document.page"
|
||||
_order = "sequence"
|
||||
|
||||
is_menu = fields.Boolean("Show in the Wiki menu")
|
||||
sequence = fields.Integer("Sequence")
|
11
website_document_page/models/document_tag.py
Normal file
11
website_document_page/models/document_tag.py
Normal file
@ -0,0 +1,11 @@
|
||||
# Copyright (C) 2020 Open Source Integrators
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||
from odoo import fields, models
|
||||
|
||||
|
||||
class DocumentTag(models.Model):
|
||||
_inherit = "document.tag"
|
||||
_order = "sequence"
|
||||
|
||||
is_menu = fields.Boolean("Show in the Wiki menu")
|
||||
sequence = fields.Integer("Sequence")
|
9
website_document_page/models/website.py
Normal file
9
website_document_page/models/website.py
Normal file
@ -0,0 +1,9 @@
|
||||
# Copyright (C) 2020 Open Source Integrators
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||
from odoo import fields, models
|
||||
|
||||
|
||||
class Website(models.Model):
|
||||
_inherit = "website"
|
||||
|
||||
wiki_id = fields.Many2one("document.page", string="Wiki Main Page")
|
3
website_document_page/readme/CONTRIBUTORS.rst
Normal file
3
website_document_page/readme/CONTRIBUTORS.rst
Normal file
@ -0,0 +1,3 @@
|
||||
* `Open Source Integrators <https://www.opensourceintegrators.com>`_
|
||||
|
||||
* Maxime Chambreuil <mchambreuil@opensourceintegrators.com>
|
1
website_document_page/readme/DESCRIPTION.rst
Normal file
1
website_document_page/readme/DESCRIPTION.rst
Normal file
@ -0,0 +1 @@
|
||||
This module allows you to write web pages and publish documentation.
|
5
website_document_page/readme/USAGE.rst
Normal file
5
website_document_page/readme/USAGE.rst
Normal file
@ -0,0 +1,5 @@
|
||||
To use this module, you need to:
|
||||
|
||||
* Go to Knowledge menu
|
||||
* Click on Categories to create the document's category you need with the template
|
||||
* Click on Pages to create pages and select the previous category to use the template
|
4
website_document_page/security/ir.model.access.csv
Normal file
4
website_document_page/security/ir.model.access.csv
Normal file
@ -0,0 +1,4 @@
|
||||
id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
|
||||
document_page_nobody,document.page nobody,document_page.model_document_page,,1,0,0,0
|
||||
document_tag_nobody,document.tag nobody,document_tag.model_document_tag,,1,0,0,0
|
||||
document_page_history_nobody,document.page.history nobody,document_page.model_document_page_history,,1,0,0,0
|
|
15
website_document_page/security/ir_rule.xml
Normal file
15
website_document_page/security/ir_rule.xml
Normal file
@ -0,0 +1,15 @@
|
||||
<odoo noupdate="1">
|
||||
<record id="document_page_public" model="ir.rule">
|
||||
<field name="name">Public document page</field>
|
||||
<field name="model_id" ref="document_page.model_document_page" />
|
||||
<field name="domain_force">[('website_published', '=', True)]</field>
|
||||
<field
|
||||
name="groups"
|
||||
eval="[(4, ref('base.group_public')), (4, ref('base.group_portal'))]"
|
||||
/>
|
||||
<field name="perm_read" eval="True" />
|
||||
<field name="perm_write" eval="False" />
|
||||
<field name="perm_create" eval="False" />
|
||||
<field name="perm_unlink" eval="False" />
|
||||
</record>
|
||||
</odoo>
|
BIN
website_document_page/static/description/icon.png
Normal file
BIN
website_document_page/static/description/icon.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 9.2 KiB |
@ -0,0 +1,32 @@
|
||||
#wrap {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
margin-right: -15px;
|
||||
margin-left: -15px;
|
||||
}
|
||||
|
||||
.wiki_menu {
|
||||
position: relative;
|
||||
flex: 0 0 20%;
|
||||
max-width: 20%;
|
||||
}
|
||||
|
||||
.wiki_content {
|
||||
position: relative;
|
||||
flex: 0 0 59%;
|
||||
max-width: 59%;
|
||||
}
|
||||
|
||||
.wiki_page_footer {
|
||||
border: 1px solid #aaa;
|
||||
background-color: #f9f9f9;
|
||||
padding: 5px;
|
||||
margin-top: 1em;
|
||||
clear: both;
|
||||
}
|
||||
|
||||
.wiki_sidebar {
|
||||
position: relative;
|
||||
flex: 0 0 20%;
|
||||
max-width: 20%;
|
||||
}
|
49
website_document_page/views/document_page.xml
Normal file
49
website_document_page/views/document_page.xml
Normal file
@ -0,0 +1,49 @@
|
||||
<odoo>
|
||||
<!-- Category view form -->
|
||||
<record id="view_document_category_form_website" model="ir.ui.view">
|
||||
<field name="name">view.document.page.website</field>
|
||||
<field name="model">document.page</field>
|
||||
<field name="inherit_id" ref="document_page.view_category_form" />
|
||||
<field name="arch" type="xml">
|
||||
<notebook position="inside">
|
||||
<page string="Website" id="name">
|
||||
<group id="website-main">
|
||||
<group id="website-left">
|
||||
<field name="is_menu" />
|
||||
<field
|
||||
name="sequence"
|
||||
attrs="{'invisible': [('is_menu', '=', False)]}"
|
||||
/>
|
||||
</group>
|
||||
<group id="website-right" />
|
||||
</group>
|
||||
</page>
|
||||
</notebook>
|
||||
</field>
|
||||
</record>
|
||||
<!-- Page view form -->
|
||||
<record id="view_document_page_form_published" model="ir.ui.view">
|
||||
<field name="name">view.document.page.published</field>
|
||||
<field name="model">document.page</field>
|
||||
<field name="inherit_id" ref="document_page.view_wiki_form" />
|
||||
<field name="arch" type="xml">
|
||||
<div name="button_box" position="inside">
|
||||
<field name="is_published" widget="website_redirect_button" />
|
||||
</div>
|
||||
<notebook position="inside">
|
||||
<page string="Website" id="name">
|
||||
<group id="website-main">
|
||||
<group id="website-left">
|
||||
<field name="is_menu" />
|
||||
<field
|
||||
name="sequence"
|
||||
attrs="{'invisible': [('is_menu', '=', False)]}"
|
||||
/>
|
||||
</group>
|
||||
<group id="website-right" />
|
||||
</group>
|
||||
</page>
|
||||
</notebook>
|
||||
</field>
|
||||
</record>
|
||||
</odoo>
|
16
website_document_page/views/document_tag.xml
Normal file
16
website_document_page/views/document_tag.xml
Normal file
@ -0,0 +1,16 @@
|
||||
<odoo>
|
||||
<record id="view_document_tag_form_website" model="ir.ui.view">
|
||||
<field name="name">view.document.tag.website</field>
|
||||
<field name="model">document.tag</field>
|
||||
<field name="inherit_id" ref="document_tag.view_document_tag_form" />
|
||||
<field name="arch" type="xml">
|
||||
<group id="main-right" position="inside">
|
||||
<field name="is_menu" />
|
||||
<field
|
||||
name="sequence"
|
||||
attrs="{'invisible': [('is_menu', '=', False)]}"
|
||||
/>
|
||||
</group>
|
||||
</field>
|
||||
</record>
|
||||
</odoo>
|
141
website_document_page/views/templates.xml
Normal file
141
website_document_page/views/templates.xml
Normal file
@ -0,0 +1,141 @@
|
||||
<odoo>
|
||||
<!-- Main Layout -->
|
||||
<template id="wiki" name="wiki">
|
||||
<t t-call="website.layout">
|
||||
<t t-set="additional_title">Wiki - Home Page</t>
|
||||
<div id="wrap">
|
||||
<div class="wiki_menu">
|
||||
<t t-call="website_document_page.wiki_menu" />
|
||||
</div>
|
||||
<div class="wiki_content">
|
||||
<t t-if="pages">
|
||||
<t t-call="website_document_page.wiki_list_page" />
|
||||
</t>
|
||||
<t t-elif="page">
|
||||
<t t-call="website_document_page.wiki_page" />
|
||||
</t>
|
||||
<t t-else="">
|
||||
No page here.
|
||||
</t>
|
||||
</div>
|
||||
<div class="wiki_sidebar">
|
||||
<t t-call="website_document_page.wiki_sidebar" />
|
||||
</div>
|
||||
</div>
|
||||
</t>
|
||||
</template>
|
||||
<!-- List Pages -->
|
||||
<template id="wiki_list_page" name="wiki_list_page">
|
||||
<h1>
|
||||
<t t-if="category">
|
||||
Category: <span t-field="category.name" />
|
||||
</t>
|
||||
<t t-if="tag">
|
||||
Tag: <span t-field="tag.name" />
|
||||
</t>
|
||||
<t t-if="search">
|
||||
Search: "<t t-esc="search" />" (<t
|
||||
t-esc="search_count"
|
||||
/> page(s) found)
|
||||
</t>
|
||||
</h1>
|
||||
<t t-if="pages">
|
||||
<ul t-foreach="pages" t-as="p">
|
||||
<li>
|
||||
<a t-attf-href="/wiki/page#{ '/%s' % slug(p) }" t-field="p.name" />
|
||||
</li>
|
||||
</ul>
|
||||
</t>
|
||||
</template>
|
||||
<!-- Menu -->
|
||||
<template id="wiki_menu" name="wiki_menu">
|
||||
<ul>
|
||||
<li>Pages
|
||||
<ul t-foreach="menu_pages" t-as="p">
|
||||
<li>
|
||||
<a
|
||||
t-attf-href="/wiki/page#{ '/%s' % slug(p) }"
|
||||
t-field="p.name"
|
||||
/>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li>Categories
|
||||
<ul t-foreach="menu_categories" t-as="c">
|
||||
<li>
|
||||
<a
|
||||
t-attf-href="/wiki/category#{ '/%s' % slug(c) }"
|
||||
t-field="c.name"
|
||||
/>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li>Tags
|
||||
<ul t-foreach="menu_tags" t-as="t">
|
||||
<li>
|
||||
<a
|
||||
t-attf-href="/wiki/tag#{ '/%s' % slug(t) }"
|
||||
t-field="t.name"
|
||||
/>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
</template>
|
||||
<!-- Page -->
|
||||
<template id="wiki_page" name="wiki_page">
|
||||
<t t-call="website_document_page.wiki_page_header" />
|
||||
<span t-raw="page.content" />
|
||||
<t t-call="website_document_page.wiki_page_footer" />
|
||||
</template>
|
||||
<!-- Page Header -->
|
||||
<template id="wiki_page_header" name="wiki_page_header">
|
||||
<h1>
|
||||
<span t-field="page.name" />
|
||||
</h1>
|
||||
</template>
|
||||
<!-- Page Footer -->
|
||||
<template id="wiki_page_footer" name="wiki_page_footer">
|
||||
<div class="wiki_page_footer">
|
||||
<t t-if="page.parent_id">
|
||||
Category: <a
|
||||
t-attf-href="/wiki/category#{ '/%s' % slug(page.parent_id) }"
|
||||
t-field="page.parent_id.name"
|
||||
/>
|
||||
</t>
|
||||
<t t-if="page_tags">
|
||||
Tags:
|
||||
<t t-foreach="page_tags" t-as="t">
|
||||
<a t-attf-href="/wiki/tag#{ '/%s' % slug(t) }" t-field="t.name" />
|
||||
</t>
|
||||
</t>
|
||||
</div>
|
||||
</template>
|
||||
<!-- Sidebar -->
|
||||
<template id="wiki_sidebar" name="wiki_sidebar">
|
||||
<t t-call="website_document_page.wiki_search" />
|
||||
</template>
|
||||
<!-- Search Box -->
|
||||
<template
|
||||
id="wiki_search"
|
||||
name="wiki_search"
|
||||
inherit_id="website.website_search_box"
|
||||
>
|
||||
<xpath expr="//div[@role='search']" position="replace">
|
||||
<form t-att-action="action if action else '/wiki'" method="get">
|
||||
<t>$0</t>
|
||||
<t t-raw="0" />
|
||||
</form>
|
||||
</xpath>
|
||||
</template>
|
||||
<!-- Assets -->
|
||||
<template id="assets_frontend" inherit_id="website.assets_frontend">
|
||||
<xpath expr="link[last()]" position="after">
|
||||
<link
|
||||
rel="stylesheet"
|
||||
type="text/scss"
|
||||
href="/website_document_page/static/src/scss/website_document_page.scss"
|
||||
/>
|
||||
</xpath>
|
||||
</template>
|
||||
</odoo>
|
12
website_document_page/views/website.xml
Normal file
12
website_document_page/views/website.xml
Normal file
@ -0,0 +1,12 @@
|
||||
<odoo>
|
||||
<record id="view_website_form_wiki" model="ir.ui.view">
|
||||
<field name="name">view.website.form.wiki</field>
|
||||
<field name="model">website</field>
|
||||
<field name="inherit_id" ref="website.view_website_form" />
|
||||
<field name="arch" type="xml">
|
||||
<field name="default_lang_id" position="after">
|
||||
<field name="wiki_id" />
|
||||
</field>
|
||||
</field>
|
||||
</record>
|
||||
</odoo>
|
Loading…
Reference in New Issue
Block a user