-
Notifications
You must be signed in to change notification settings - Fork 1
/
webpage.py
112 lines (88 loc) · 3.74 KB
/
webpage.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
# -*- coding: UTF-8 -*-
# Copyright (C) 2010 Henry Obein <[email protected]>
# Copyright (C) 2010 Taverne Sylvain <[email protected]>
# Copyright (C) 2011 Hervé Cauwelier <[email protected]>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# Import from itools
from itools.core import merge_dicts
from itools.datatypes import Boolean, String
from itools.gettext import MSG
# Import from ikaaro
from ikaaro.autoform import HTMLBody
from ikaaro.registry import register_resource_class, register_document_type
from ikaaro.webpage import WebPage as BaseWebPage
# Import from itws
from control_panel import CPDBResource_CommitLog, CPDBResource_Links
from control_panel import CPDBResource_Backlinks, CPSubscribe
from control_panel import CPExternalEdit, ITWS_ControlPanel
from tags import TagsAware, register_tags_aware
from webpage_views import WebPage_Edit, WebPage_View
from widgets import Advance_RTEWidget
class WebPage(TagsAware, BaseWebPage):
"""
We override the ikaaro webpage to:
- Override RTE to allow to add iframe
- Add tags to webpages
- Add publication date and time
- Allow to configure if we display title or not
"""
# TODO When publish webpage add a mechanism to check public pages
# XXX We override ikaaro class_id
class_id = 'webpage'
class_version = '20100621'
class_schema = merge_dicts(
BaseWebPage.class_schema,
TagsAware.class_schema,
display_title=Boolean(source='metadata',
title=MSG(u'Display title'), default=True),
# Handler
data=HTMLBody(source='handler',
title=MSG(u'Body'),
widget=Advance_RTEWidget,
multilingual=True, parameters_schema={'lang': String}))
class_views = ['view', 'edit', 'externaledit', 'control_panel']
class_control_panel = ['externaledit', 'subscribe',
'links', 'backlinks', 'commit_log']
def get_catalog_values(self):
return merge_dicts(BaseWebPage.get_catalog_values(self),
TagsAware.get_catalog_values(self))
#########################################################
# Links API
#########################################################
def get_links(self):
links = BaseWebPage.get_links(self)
links.update(TagsAware.get_links(self))
return links
def update_links(self, source, target):
BaseWebPage.update_links(self, source, target)
TagsAware.update_links(self, source, target)
def update_relative_links(self, source):
BaseWebPage.update_relative_links(self, source)
TagsAware.update_relative_links(self, source)
##########################
# Views
##########################
edit = WebPage_Edit()
view = WebPage_View()
control_panel = ITWS_ControlPanel()
# Control panel
commit_log = CPDBResource_CommitLog(access='is_allowed_to_edit')
links = CPDBResource_Links()
backlinks = CPDBResource_Backlinks()
subscribe = CPSubscribe()
externaledit = CPExternalEdit()
register_resource_class(WebPage, format='application/xhtml+xml')
register_document_type(WebPage)
register_tags_aware(WebPage)