Skip to content

Instantly share code, notes, and snippets.

@honsa
Last active October 2, 2018 18:33
Show Gist options
  • Save honsa/80169e1b222a1ede24b8d5471c650318 to your computer and use it in GitHub Desktop.
Save honsa/80169e1b222a1ede24b8d5471c650318 to your computer and use it in GitHub Desktop.
Automaticly create rules for new tags in wallabag MySQL database. Search in title and content for keyword and trigger wallabag_tagging_rule insert with this keyword.
BEGIN
SET @tag = NEW.slug;
If length(@tag) >= 3 THEN
SET @ruleTitle = CONCAT('title matches " ', @tag,' "');
SET @ruleContent = CONCAT('content matches " ',@tag,' "');
INSERT INTO wallabag_tagging_rule (config_id,rule,tags) VALUES (1,@ruleTitle, @tag);
INSERT INTO wallabag_tagging_rule (config_id,rule,tags) VALUES (1,@ruleContent, @tag);
END IF;
END
BEGIN
SET @tag = OLD.slug;
DELETE FROM wallabag_tagging_rule WHERE tags LIKE @tag;
END
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment