Mercurial > libervia-backend
comparison sat/plugins/plugin_misc_static_blog.py @ 2624:56f94936df1e
code style reformatting using black
author | Goffi <goffi@goffi.org> |
---|---|
date | Wed, 27 Jun 2018 20:14:46 +0200 |
parents | 26edcf3a30eb |
children | ab2696e34d29 |
comparison
equal
deleted
inserted
replaced
2623:49533de4540b | 2624:56f94936df1e |
---|---|
16 | 16 |
17 # You should have received a copy of the GNU Affero General Public License | 17 # You should have received a copy of the GNU Affero General Public License |
18 # along with this program. If not, see <http://www.gnu.org/licenses/>. | 18 # along with this program. If not, see <http://www.gnu.org/licenses/>. |
19 | 19 |
20 from sat.core.log import getLogger | 20 from sat.core.log import getLogger |
21 | |
21 log = getLogger(__name__) | 22 log = getLogger(__name__) |
22 | 23 |
23 from sat.core.i18n import _, D_ | 24 from sat.core.i18n import _, D_ |
24 from sat.core.constants import Const as C | 25 from sat.core.constants import Const as C |
25 from sat.core import exceptions | 26 from sat.core import exceptions |
33 C.PI_NAME: "Static Blog Plugin", | 34 C.PI_NAME: "Static Blog Plugin", |
34 C.PI_IMPORT_NAME: "STATIC-BLOG", | 35 C.PI_IMPORT_NAME: "STATIC-BLOG", |
35 C.PI_TYPE: "MISC", | 36 C.PI_TYPE: "MISC", |
36 C.PI_PROTOCOLS: [], | 37 C.PI_PROTOCOLS: [], |
37 C.PI_DEPENDENCIES: [], | 38 C.PI_DEPENDENCIES: [], |
38 C.PI_RECOMMENDATIONS: ['MISC-ACCOUNT'], # TODO: remove when all blogs can be retrieved | 39 C.PI_RECOMMENDATIONS: [ |
40 "MISC-ACCOUNT" | |
41 ], # TODO: remove when all blogs can be retrieved | |
39 C.PI_MAIN: "StaticBlog", | 42 C.PI_MAIN: "StaticBlog", |
40 C.PI_HANDLER: "no", | 43 C.PI_HANDLER: "no", |
41 C.PI_DESCRIPTION: _("""Plugin for static blogs""") | 44 C.PI_DESCRIPTION: _("""Plugin for static blogs"""), |
42 } | 45 } |
43 | 46 |
44 | 47 |
45 class StaticBlog(object): | 48 class StaticBlog(object): |
46 | 49 |
55 <param name="{description_name}" label="{description_label}" value="" type="string" security="0"/> | 58 <param name="{description_name}" label="{description_label}" value="" type="string" security="0"/> |
56 </category> | 59 </category> |
57 </individual> | 60 </individual> |
58 </params> | 61 </params> |
59 """.format( | 62 """.format( |
60 category_name = C.STATIC_BLOG_KEY, | 63 category_name=C.STATIC_BLOG_KEY, |
61 category_label = D_(C.STATIC_BLOG_KEY), | 64 category_label=D_(C.STATIC_BLOG_KEY), |
62 title_name = C.STATIC_BLOG_PARAM_TITLE, | 65 title_name=C.STATIC_BLOG_PARAM_TITLE, |
63 title_label = D_('Page title'), | 66 title_label=D_("Page title"), |
64 banner_name = C.STATIC_BLOG_PARAM_BANNER, | 67 banner_name=C.STATIC_BLOG_PARAM_BANNER, |
65 banner_label = D_('Banner URL'), | 68 banner_label=D_("Banner URL"), |
66 background_name = u"Background", | 69 background_name=u"Background", |
67 background_label = D_(u"Background image URL"), | 70 background_label=D_(u"Background image URL"), |
68 keywords_name = C.STATIC_BLOG_PARAM_KEYWORDS, | 71 keywords_name=C.STATIC_BLOG_PARAM_KEYWORDS, |
69 keywords_label = D_('Keywords'), | 72 keywords_label=D_("Keywords"), |
70 description_name = C.STATIC_BLOG_PARAM_DESCRIPTION, | 73 description_name=C.STATIC_BLOG_PARAM_DESCRIPTION, |
71 description_label = D_('Description'), | 74 description_label=D_("Description"), |
72 ) | 75 ) |
73 | 76 |
74 def __init__(self, host): | 77 def __init__(self, host): |
75 try: # TODO: remove this attribute when all blogs can be retrieved | 78 try: # TODO: remove this attribute when all blogs can be retrieved |
76 self.domain = host.plugins['MISC-ACCOUNT'].getNewAccountDomain() | 79 self.domain = host.plugins["MISC-ACCOUNT"].getNewAccountDomain() |
77 except KeyError: | 80 except KeyError: |
78 self.domain = None | 81 self.domain = None |
79 host.memory.updateParams(self.params) | 82 host.memory.updateParams(self.params) |
80 # host.importMenu((D_("User"), D_("Public blog")), self._displayPublicBlog, security_limit=1, help_string=D_("Display public blog page"), type_=C.MENU_JID_CONTEXT) | 83 # host.importMenu((D_("User"), D_("Public blog")), self._displayPublicBlog, security_limit=1, help_string=D_("Display public blog page"), type_=C.MENU_JID_CONTEXT) |
81 | 84 |
87 @return: dict | 90 @return: dict |
88 """ | 91 """ |
89 # FIXME: "public_blog" key has been removed | 92 # FIXME: "public_blog" key has been removed |
90 # TODO: replace this with a more generic widget call with URIs | 93 # TODO: replace this with a more generic widget call with URIs |
91 try: | 94 try: |
92 user_jid = jid.JID(menu_data['jid']) | 95 user_jid = jid.JID(menu_data["jid"]) |
93 except KeyError: | 96 except KeyError: |
94 log.error(_("jid key is not present !")) | 97 log.error(_("jid key is not present !")) |
95 return defer.fail(exceptions.DataError) | 98 return defer.fail(exceptions.DataError) |
96 | 99 |
97 # TODO: remove this check when all blogs can be retrieved | 100 # TODO: remove this check when all blogs can be retrieved |
98 if self.domain and user_jid.host != self.domain: | 101 if self.domain and user_jid.host != self.domain: |
99 info_ui = xml_tools.XMLUI("popup", title=D_("Not available")) | 102 info_ui = xml_tools.XMLUI("popup", title=D_("Not available")) |
100 info_ui.addText(D_("Retrieving a blog from an external domain is not implemented yet.")) | 103 info_ui.addText( |
101 return {'xmlui': info_ui.toXml()} | 104 D_("Retrieving a blog from an external domain is not implemented yet.") |
105 ) | |
106 return {"xmlui": info_ui.toXml()} | |
102 | 107 |
103 return {"public_blog": user_jid.userhost()} | 108 return {"public_blog": user_jid.userhost()} |