Mercurial > libervia-desktop-kivy
comparison cagou/plugins/plugin_wid_blog.py @ 491:203755bbe0fe
massive refactoring from camelCase -> snake_case. See backend commit log for more details
author | Goffi <goffi@goffi.org> |
---|---|
date | Sat, 08 Apr 2023 13:44:32 +0200 |
parents | beedff600d2b |
children |
comparison
equal
deleted
inserted
replaced
490:962d17c4078c | 491:203755bbe0fe |
---|---|
68 blog = properties.ObjectProperty() | 68 blog = properties.ObjectProperty() |
69 size_hint_close = (1, 0) | 69 size_hint_close = (1, 0) |
70 size_hint_open = (1, 0.9) | 70 size_hint_open = (1, 0.9) |
71 | 71 |
72 def _publish_cb(self, item_id: str) -> None: | 72 def _publish_cb(self, item_id: str) -> None: |
73 G.host.addNote( | 73 G.host.add_note( |
74 _("blog post published"), | 74 _("blog post published"), |
75 _("your blog post has been published with ID {item_id}").format( | 75 _("your blog post has been published with ID {item_id}").format( |
76 item_id=item_id | 76 item_id=item_id |
77 ) | 77 ) |
78 ) | 78 ) |
79 self.blog.load_blog() | 79 self.blog.load_blog() |
80 | 80 |
81 def _publish_eb(self, exc: BridgeException) -> None: | 81 def _publish_eb(self, exc: BridgeException) -> None: |
82 G.host.addNote( | 82 G.host.add_note( |
83 _("Problem while publish blog post"), | 83 _("Problem while publish blog post"), |
84 _("Can't publish blog post at {node!r} from {service}: {problem}").format( | 84 _("Can't publish blog post at {node!r} from {service}: {problem}").format( |
85 node=self.blog.node or G.host.ns_map.get("microblog"), | 85 node=self.blog.node or G.host.ns_map.get("microblog"), |
86 service=( | 86 service=( |
87 self.blog.service if self.blog.service | 87 self.blog.service if self.blog.service |
103 if e2ee: | 103 if e2ee: |
104 mb_data["encrypted"] = True | 104 mb_data["encrypted"] = True |
105 title = title.strip() | 105 title = title.strip() |
106 if title: | 106 if title: |
107 mb_data["title_rich"] = title | 107 mb_data["title_rich"] = title |
108 G.host.bridge.mbSend( | 108 G.host.bridge.mb_send( |
109 self.blog.service, | 109 self.blog.service, |
110 self.blog.node, | 110 self.blog.node, |
111 data_format.serialise(mb_data), | 111 data_format.serialise(mb_data), |
112 self.blog.profile, | 112 self.blog.profile, |
113 callback=self._publish_cb, | 113 callback=self._publish_cb, |
133 | 133 |
134 def __init__(self, host, target, profiles): | 134 def __init__(self, host, target, profiles): |
135 quick_widgets.QuickWidget.__init__(self, G.host, target, profiles) | 135 quick_widgets.QuickWidget.__init__(self, G.host, target, profiles) |
136 cagou_widget.CagouWidget.__init__(self) | 136 cagou_widget.CagouWidget.__init__(self) |
137 search_btn = SearchButton(blog=self) | 137 search_btn = SearchButton(blog=self) |
138 self.headerInputAddExtra(search_btn) | 138 self.header_input_add_extra(search_btn) |
139 new_post_btn = NewPostButton(blog=self) | 139 new_post_btn = NewPostButton(blog=self) |
140 self.headerInputAddExtra(new_post_btn) | 140 self.header_input_add_extra(new_post_btn) |
141 self.load_blog() | 141 self.load_blog() |
142 | 142 |
143 def on_kv_post(self, __): | 143 def on_kv_post(self, __): |
144 self.bind( | 144 self.bind( |
145 service=lambda __, value: self.load_blog(), | 145 service=lambda __, value: self.load_blog(), |
146 node=lambda __, value: self.load_blog(), | 146 node=lambda __, value: self.load_blog(), |
147 ) | 147 ) |
148 | 148 |
149 def onHeaderInput(self): | 149 def on_header_wid_input(self): |
150 text = self.header_input.text.strip() | 150 text = self.header_input.text.strip() |
151 # for now we only use text as node | 151 # for now we only use text as node |
152 self.node = text | 152 self.node = text |
153 | 153 |
154 def show_new_post_menu(self): | 154 def show_new_post_menu(self): |
162 | 162 |
163 def _mb_get_eb( | 163 def _mb_get_eb( |
164 self, | 164 self, |
165 exc: BridgeException, | 165 exc: BridgeException, |
166 ) -> None: | 166 ) -> None: |
167 G.host.addNote( | 167 G.host.add_note( |
168 _("Problem while getting blog data"), | 168 _("Problem while getting blog data"), |
169 _("Can't get blog for {node!r} at {service}: {problem}").format( | 169 _("Can't get blog for {node!r} at {service}: {problem}").format( |
170 node=self.node or G.host.ns_map.get("microblog"), | 170 node=self.node or G.host.ns_map.get("microblog"), |
171 service=self.service if self.service else G.host.profiles[self.profile].whoami, | 171 service=self.service if self.service else G.host.profiles[self.profile].whoami, |
172 problem=exc | 172 problem=exc |
178 self, | 178 self, |
179 ) -> None: | 179 ) -> None: |
180 """Retrieve a blog and display it""" | 180 """Retrieve a blog and display it""" |
181 extra = {} | 181 extra = {} |
182 self.posts_widget.clear_widgets() | 182 self.posts_widget.clear_widgets() |
183 G.host.bridge.mbGet( | 183 G.host.bridge.mb_get( |
184 self.service, | 184 self.service, |
185 self.node, | 185 self.node, |
186 20, | 186 20, |
187 [], | 187 [], |
188 data_format.serialise(extra), | 188 data_format.serialise(extra), |