From 7d0437055841ff397c5d778644354a97f6fe37cf Mon Sep 17 00:00:00 2001 From: Dylan Garrett Date: Sun, 17 Apr 2022 12:06:50 -0700 Subject: [PATCH] Initial work to allow auto tagging --- plugins/wallabag.koplugin/main.lua | 45 ++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) diff --git a/plugins/wallabag.koplugin/main.lua b/plugins/wallabag.koplugin/main.lua index 1f44e401f..d08bb78a0 100644 --- a/plugins/wallabag.koplugin/main.lua +++ b/plugins/wallabag.koplugin/main.lua @@ -214,6 +214,19 @@ function Wallabag:addToMainMenu(menu_items) end, separator = true, }, + { + text_func = function() + if not self.auto_tags or self.auto_tags == "" then + return _("Automatic tags") + end + return T(_("Automatic tags (%1)"), self.auto_tags) + end, + keep_menu_open = true, + callback = function(touchmenu_instance) + self:setAutoTags(touchmenu_instance) + end, + separator = true, + }, { text = _("Article deletion"), separator = true, @@ -966,6 +979,38 @@ function Wallabag:setIgnoreTags(touchmenu_instance) self.ignore_tags_dialog:onShowKeyboard() end +function Wallabag:setAutoTags(touchmenu_instance) + self.auto_tags_dialog = InputDialog:new { + title = _("Tags to automatically add"), + description = _("Enter a comma-separated list of tags to automatically add."), + input = self.auto_tags, + input_type = "string", + buttons = { + { + { + text = _("Cancel"), + id = "close", + callback = function() + UIManager:close(self.auto_tags_dialog) + end, + }, + { + text = _("Set tags"), + is_enter_default = true, + callback = function() + self.auto_tags = self.auto_tags_dialog:getInputText() + self:saveSettings() + touchmenu_instance:updateItems() + UIManager:close(self.auto_tags_dialog) + end, + } + } + }, + } + UIManager:show(self.auto_tags_dialog) + self.auto_tags_dialog:onShowKeyboard() +end + function Wallabag:editServerSettings() local text_info = T(_([[ Enter the details of your Wallabag server and account.