comparison sat_frontends/jp/cmd_blog.py @ 2944:efb915a20d5d

jp (blog/set): fixed missing current_syntax
author Goffi <goffi@goffi.org>
date Sun, 05 May 2019 18:50:35 +0200
parents 781b5b6a33ee
children 6c264c224614
comparison
equal deleted inserted replaced
2943:781b5b6a33ee 2944:efb915a20d5d
41 __commands__ = ["Blog"] 41 __commands__ = ["Blog"]
42 42
43 SYNTAX_XHTML = u"xhtml" 43 SYNTAX_XHTML = u"xhtml"
44 # extensions to use with known syntaxes 44 # extensions to use with known syntaxes
45 SYNTAX_EXT = { 45 SYNTAX_EXT = {
46 # FIXME: default syntax doesn't sounds needed, there should always be a syntax set
47 # by the plugin.
46 "": "txt", # used when the syntax is not found 48 "": "txt", # used when the syntax is not found
47 SYNTAX_XHTML: "xhtml", 49 SYNTAX_XHTML: "xhtml",
48 "markdown": "md", 50 "markdown": "md",
49 } 51 }
50 52
103 105
104 106
105 class BlogPublishCommon(object): 107 class BlogPublishCommon(object):
106 """handle common option for publising commands (Set and Edit)""" 108 """handle common option for publising commands (Set and Edit)"""
107 109
110 @property
111 def current_syntax(self):
112 if self._current_syntax is None:
113 self._current_syntax = self.host.bridge.getParamA(
114 "Syntax", "Composition", "value", self.profile
115 )
116 return self._current_syntax
117
108 def add_parser_options(self): 118 def add_parser_options(self):
109 self.parser.add_argument( 119 self.parser.add_argument(
110 "-T", "--title", type=base.unicode_decoder, help=_(u"title of the item") 120 "-T", "--title", type=base.unicode_decoder, help=_(u"title of the item")
111 ) 121 )
112 self.parser.add_argument( 122 self.parser.add_argument(
178 def mbSendCb(self): 188 def mbSendCb(self):
179 self.disp(u"Item published") 189 self.disp(u"Item published")
180 self.host.quit(C.EXIT_OK) 190 self.host.quit(C.EXIT_OK)
181 191
182 def start(self): 192 def start(self):
193 self._current_syntax = self.args.syntax
183 self.pubsub_item = self.args.item 194 self.pubsub_item = self.args.item
184 mb_data = {} 195 mb_data = {}
185 self.setMbDataFromArgs(mb_data) 196 self.setMbDataFromArgs(mb_data)
186 if self.pubsub_item: 197 if self.pubsub_item:
187 mb_data["id"] = self.pubsub_item 198 mb_data["id"] = self.pubsub_item
429 use_verbose=True, 440 use_verbose=True,
430 help=_(u"edit an existing or new blog post"), 441 help=_(u"edit an existing or new blog post"),
431 ) 442 )
432 BlogPublishCommon.__init__(self) 443 BlogPublishCommon.__init__(self)
433 common.BaseEdit.__init__(self, self.host, BLOG_TMP_DIR, use_metadata=True) 444 common.BaseEdit.__init__(self, self.host, BLOG_TMP_DIR, use_metadata=True)
434
435 @property
436 def current_syntax(self):
437 if self._current_syntax is None:
438 self._current_syntax = self.host.bridge.getParamA(
439 "Syntax", "Composition", "value", self.profile
440 )
441 return self._current_syntax
442 445
443 def add_parser_options(self): 446 def add_parser_options(self):
444 BlogPublishCommon.add_parser_options(self) 447 BlogPublishCommon.add_parser_options(self)
445 self.parser.add_argument( 448 self.parser.add_argument(
446 "-P", 449 "-P",