-
-
Notifications
You must be signed in to change notification settings - Fork 756
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Rule based tags #1478
Rule based tags #1478
Conversation
Impressive ! Can you fix the Travis Error (it's just a |
Should be better now :) |
@@ -54,7 +54,8 @@ | |||
"lexik/form-filter-bundle": "~4.0", | |||
"j0k3r/graby": "~1.0", | |||
"friendsofsymfony/user-bundle": "dev-master", | |||
"friendsofsymfony/oauth-server-bundle": "^1.4@dev" | |||
"friendsofsymfony/oauth-server-bundle": "^1.4@dev", | |||
"kphoen/rulerz-bundle": "dev-master" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can't we use a tagged version instead?
This a good start! I wasn't aware that this bundle will include all that stuff from Hoa project 😳 Anyway, apart my first little comments:
|
My bad, I didn't properly introduce RulerZ :)
Agreed. I just wrote a list of the usable variables so that you could see the possibilities of the feature. I'll try to write a proper FAQ once the code is done :)
Done for
It was on my roadmap. I committed a first version of the validator today but it's really a naïve one: it just validates the syntax. For instance, if you use an undefined variable no validation error will be triggered. I'll improve the validator to detect these errors. |
I just gave a try 👍 Do you think that it's possible to have a command to assign these tags to existing articles? |
I also had this idea in mind, that's why I used RulerZ instead of Hoa\Ruler. While Hoa\Ruler only works on an object (in our case, an So yeah, writing a command/controller to tag existing articles should be easy :) |
Nice. Don't forget to give availability to remove rule. |
Yep, there is still some work to be done on the validation. Also, I'll make sure that even if the automatic tagging fails it does not prevent the user to add new entries. |
Thanks for your feedback btw 👍 |
I implemented a better validator for the tagging rules and also provided a way to delete them. There is still some documentation about the rules to be written. You wanted that on a separate page? Do you already have one? |
use KPhoen\RulerZBundle\Validator\Constraints as RulerZAssert; | ||
|
||
/** | ||
* Config. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bad copy/paste?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep.
Looks good 😄 About the documentation your are talking about, is that the FAQ displayed below the tagging page or something better which need to be in the documentation of wallabag? And you can add a better documentation in our doc, which is now part of the repo since #1495. Maybe you'll have to rebase your PR to get that changes. |
Conflict with v2 branch. Will try this PR maybe this evening. |
Yes 👍
Will retry
Oh nice, I didn't see this feature! What do you think having a button: "tag all the previous entries"? |
Depending on the number of entries for the current user, it could take long time to accomplish .. |
I added the |
<3 (just need documentation about this new operator maybe) |
$pattern = sprintf("'%%%s%%'", substr($pattern, 1, -1)); | ||
} | ||
|
||
return sprintf('UPPER(%s) LIKE UPPER(%s)', $subject, $pattern); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it working on MySQL, PostGres & SQLite ? Maybe a working test for the matches keyword could be a good idea.
Oops, my bad, I forgot :)
It does. I'll add a test. |
|
||
namespace Wallabag\CoreBundle\Operator\PHP; | ||
|
||
class Matches |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you explain what these classes are used for (both Operator\Doctrine\Matches
& Operator\Doctrine\PHP
) ?
In the context of your PR, we can guess but when it will be inside the project, it won't be that easy to guess
PHPdoc added, |
$entry = $em | ||
->getRepository('WallabagCoreBundle:Entry') | ||
->findOneByUrl($url); | ||
$this->assertCount(1, $entry->getTags()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you just assert that the only tag for this entry is actually wallabag
, as per the TaggingRule.
I think we are really close to get this merged 🚀 |
</div> | ||
</div> | ||
</div> | ||
|
||
{% if is_granted('ROLE_SUPER_ADMIN') %} | ||
<div id="set5" class="col s12"> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It might be a side effect of your change (and some rebase) but could you set set6
here instead of set5
? Because we have 2 set5
in the page and it breaks the layout because, if user is super admin, Add a user will always be displayed.
I found some time to fix the tests, they're green now 🎉 Anyway, thanks for all the valuable feedbacks you guys provided throughout this PR. Keep up the good work 👍 |
Note for later : Think on how to export rules from one installation to another. |
Both rules and tags can be represented as plain text so that should not be difficult :) |
@K-Phoen Huge thank to you for that 👍 |
👍 \o/ |
As described in #1477, here is my PoC for a rule-based automatic tagging.
It rules engine is RulerZ and I created a new tab in the configuration panel to manage the tagging rules. It's a quick draft but at least it allows us to create rules and test them:
It's really a WIP so there are no tests, validation for the rules or help about the DSL used for the rules.
If you like the overall direction of this feature, I'll finish my PR :)
Note: there are a lot of additions but it's mainly the
composer.lock file
. Also, reading the PR commit-by-commit should be easier.Updated screenshot: