diff frontends/src/jp/cmd_blog.py @ 2270:07caa12be945

jp (blog, common): added --force-item option to avoid magic and use argument as actual item id: - creation of new item with item id has been fixed - --force-item allow to use url as item id, or keyword - pubsub_item can is now returned by getItemPath. If not None, the id is known and must be used
author Goffi <goffi@goffi.org>
date Tue, 27 Jun 2017 17:00:52 +0200
parents 606ff34d30f2
children 2fae89f30b8d
line wrap: on
line diff
--- a/frontends/src/jp/cmd_blog.py	Tue Jun 27 16:23:28 2017 +0200
+++ b/frontends/src/jp/cmd_blog.py	Tue Jun 27 17:00:52 2017 +0200
@@ -301,6 +301,7 @@
         self.parser.add_argument("-T", '--title', type=base.unicode_decoder, help=_(u"title of the item"))
         self.parser.add_argument("-t", '--tag', type=base.unicode_decoder, action='append', help=_(u"tag (category) of your item"))
         self.parser.add_argument("--no-comment", action='store_true', help=_(u"disable comments"))
+        common.BaseEdit.add_parser_options(self)
 
     def buildMetadataFile(self, content_file_path, mb_data=None):
         """Build a metadata file using json
@@ -351,9 +352,10 @@
     def edit(self, content_file_path, content_file_obj,
              mb_data=None):
         """Edit the file contening the content using editor, and publish it"""
-        self.item_ori_mb_data = mb_data
+        if mb_data is not None:
+            self.pubsub_item = mb_data['id']
         # we first create metadata file
-        meta_ori, meta_file_path = self.buildMetadataFile(content_file_path, self.item_ori_mb_data)
+        meta_ori, meta_file_path = self.buildMetadataFile(content_file_path, mb_data)
 
         # do we need a preview ?
         if self.args.preview:
@@ -369,8 +371,8 @@
     def publish(self, content, mb_data):
         mb_data['content_rich'] =  content
 
-        if self.item_ori_mb_data is not None:
-            mb_data['id'] = self.item_ori_mb_data['id']
+        if self.pubsub_item is not None:
+            mb_data['id'] = self.pubsub_item
 
         self.host.bridge.mbSend(self.pubsub_service, self.pubsub_node, mb_data, self.profile)
         self.disp(u"Blog item published")
@@ -398,7 +400,7 @@
         SYNTAX_EXT.update(config.getConfig(self.sat_conf, 'jp', CONF_SYNTAX_EXT, {}))
         self.current_syntax = None
 
-        self.pubsub_service, self.pubsub_node, content_file_path, content_file_obj, mb_data = self.getItemPath(self.args.item)
+        self.pubsub_service, self.pubsub_node, self.pubsub_item, content_file_path, content_file_obj, mb_data = self.getItemPath(self.args.item)
 
         self.edit(content_file_path, content_file_obj, mb_data=mb_data)