Mercurial > libervia-backend
comparison sat_frontends/jp/cmd_blog.py @ 3841:b337d7da72e5
li (blog): new `repeat` subcommand, to re-publish a blog post:
rel 370
author | Goffi <goffi@goffi.org> |
---|---|
date | Thu, 14 Jul 2022 12:55:19 +0200 |
parents | a6dfd3db372b |
children | 7d11e42b150e |
comparison
equal
deleted
inserted
replaced
3840:5b192a5eb72d | 3841:b337d7da72e5 |
---|---|
671 except Exception as e: | 671 except Exception as e: |
672 self.disp(f"can't rename item: {e}", error=True) | 672 self.disp(f"can't rename item: {e}", error=True) |
673 self.host.quit(C.EXIT_BRIDGE_ERRBACK) | 673 self.host.quit(C.EXIT_BRIDGE_ERRBACK) |
674 else: | 674 else: |
675 self.disp("Item renamed") | 675 self.disp("Item renamed") |
676 self.host.quit(C.EXIT_OK) | |
677 | |
678 | |
679 class Repeat(base.CommandBase): | |
680 def __init__(self, host): | |
681 super().__init__( | |
682 host, | |
683 "repeat", | |
684 use_pubsub=True, | |
685 pubsub_flags={C.SINGLE_ITEM}, | |
686 help=_("repeat (re-publish) a blog item"), | |
687 ) | |
688 | |
689 def add_parser_options(self): | |
690 pass | |
691 | |
692 async def start(self): | |
693 try: | |
694 repeat_id = await self.host.bridge.mbRepeat( | |
695 self.args.service, | |
696 self.args.node, | |
697 self.args.item, | |
698 "", | |
699 self.profile, | |
700 ) | |
701 except Exception as e: | |
702 self.disp(f"can't repeat item: {e}", error=True) | |
703 self.host.quit(C.EXIT_BRIDGE_ERRBACK) | |
704 else: | |
705 if repeat_id: | |
706 self.disp(f"Item repeated at ID {str(repeat_id)!r}") | |
707 else: | |
708 self.disp("Item repeated") | |
676 self.host.quit(C.EXIT_OK) | 709 self.host.quit(C.EXIT_OK) |
677 | 710 |
678 | 711 |
679 class Preview(base.CommandBase, common.BaseEdit): | 712 class Preview(base.CommandBase, common.BaseEdit): |
680 # TODO: need to be rewritten with template output | 713 # TODO: need to be rewritten with template output |
1037 | 1070 |
1038 await self.set_progress_id(progress_id) | 1071 await self.set_progress_id(progress_id) |
1039 | 1072 |
1040 | 1073 |
1041 class Blog(base.CommandBase): | 1074 class Blog(base.CommandBase): |
1042 subcommands = (Set, Get, Edit, Rename, Preview, Import) | 1075 subcommands = (Set, Get, Edit, Rename, Repeat, Preview, Import) |
1043 | 1076 |
1044 def __init__(self, host): | 1077 def __init__(self, host): |
1045 super(Blog, self).__init__( | 1078 super(Blog, self).__init__( |
1046 host, "blog", use_profile=False, help=_("blog/microblog management") | 1079 host, "blog", use_profile=False, help=_("blog/microblog management") |
1047 ) | 1080 ) |