Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Problem/Motivation
Port D7 version of filter_example to the 4.0.x branch (Drupal 9.4+).
Proposed resolution
Remaining tasks
User interface changes
API changes
Data model changes
Comment | File | Size | Author |
---|---|---|---|
#39 | drupal.org_files_issues_2023-02-19_2277629-39.patch | 16.94 KB | mrinalini9 |
#34 | interdiff-33-34.txt | 4.79 KB | jungle |
#34 | 2277629-34.patch | 16.95 KB | jungle |
#33 | 2277629-33.patch | 16.67 KB | jungle |
#31 | filter_example-2277629-31.patch | 17.03 KB | jrockowitz |
Comments
Comment #1
rosinegrean CreditAttribution: rosinegrean commentedComment #2
rosinegrean CreditAttribution: rosinegrean commentedThis is a first version. I still have 2 fatal errors in my local, but wanted to be sure I'm on the right track.
Comment #4
rosinegrean CreditAttribution: rosinegrean commentedComment #6
Mile23Generally unassigning issues. Please re-assign yourself as desired.
Comment #7
Vj CreditAttribution: Vj as a volunteer commentedInitial patch without test case. Will update new patch with tests soon.
Comment #9
Vj CreditAttribution: Vj as a volunteer commentedFinal patch with tests & documentation.
Please review and let me know if any changes required.
Comment #10
navneet0693 CreditAttribution: navneet0693 as a volunteer and at QED42 commentedGave a quick review on the patch.
drupal:filter
News line at end :-)
you can use DescriptionTemplateTrait for long inline description.
You can use %foo instead of tags and replace it just like we did for replacement.
Do we really need to enable filter_test and filter_example module for testing ?
Comment #11
Vj CreditAttribution: Vj as a volunteer commented@navneet0693
Thanks for the review. I have re-rolled the patch. Please let me know if any changes required.
Comment #12
navneet0693 CreditAttribution: navneet0693 as a volunteer and at QED42 commentedAdded changes in tests, removed depreciated function. Added few changes in module. Ouch please ignore wrong file name :(
Comment #13
navneet0693 CreditAttribution: navneet0693 as a volunteer and at QED42 commentedComment #16
navneet0693 CreditAttribution: navneet0693 as a volunteer and at QED42 commentedI think I need to add 'filter_test' for enabling filtered html and full html filter formats.
@Vj thank you for pointing me out!
Comment #17
navneet0693 CreditAttribution: navneet0693 as a volunteer and at QED42 commentedI have added a sub-module 'filter_example_test' in tests so as to import the configurations.
Comment #18
eojthebraveThis is great. I learned a bunch about how to write a filter by reviewing this code. Thank you. Here's a couple of things I found in the process that I think we can improve before committing this.
I find this paragraph to be kind of confusing. I believe what it is trying to say is that each filter can be configured differently for each of the text formats where it is enabled. This example filter provides configuration that will allow an administrator to determine what string should be replaced with the text "foo".
I think it might be worth adding an @see to \Drupal\filter\Plugin\FilterInterface which has some pretty good high level documentation on the Filter system and how it works.
As well as an @link for https://www.drupal.org/docs/8/api/filter-api
This comment needs to be wrapped to 80 characters.
I think we should add an @see to \Drupal\filter\Annotation\Filter which documents the Annotation used here.
And maybe also \Drupal\filter\Plugin\FilterInterface
This is maybe nit-picky, but the standard here appears to be {MODULE_NAME}_{FILTER}. So this might be better as "filter_example_foo" so as to not possibly conflict with something in the filer module's namespace.
"stored in the database" ... sentence is missing a "the".
This comment should be wrapped to 80 characters.
This should also get an @see for \Drupal\filter\Annotation\Filter and \Drupal\filter\Plugin\FilterInterface
And the id in the annotation should probably be filter_example_time.
This is a cool, and also kind of edge-case technique. I think it's probably worth expanding this comment a little to explain what is going on here, and when this code is going to be called.
Comment #19
navneet0693 CreditAttribution: navneet0693 as a volunteer and at QED42 commentedNeeds re-roll !
Comment #20
navneet0693 CreditAttribution: navneet0693 as a volunteer and at QED42 commentedAlso addressing issues from #18
Comment #21
navneet0693 CreditAttribution: navneet0693 as a volunteer and at QED42 commented@eojthebrave thank you for review :-)
Comment #22
Mile23Substitute 'configurable' for 'preconfigured.'
Needs better instructions. I suggest: "Edit whichever text format you're using to include these filters. Make sure Time filter happens before 'Limit HTML tags'." And whatever else is required... I couldn't get the time filter to work. See below.
The test looks pretty good, and passes locally. It adds a time tag and passes in the test, but I was unable to get the time filter to work in a live setting.
Comment #23
jlbellidoI'm attaching a new patch including the comments from #22.
Additionally I've checked the example in a live site and I could get the time filter running. The issue was that the WYSIWYG is encoding and therefore the replacement doesn't work. If you include the tag without directly, it works. It would explain why you couldn't reproduce it and the tests passed.
I'm attaching screenshots with my local example.
Comment #25
jlbellidoI'm attaching a new patch that hopefully will solve Tests errors.
Comment #26
jlbellidoAdding tags.
Comment #27
Mile23I still can't get the time filter to work. Here's how d.o swallows the instructions in #23:
And it still looks like the image in #22.
Steps I took, which follow the instructions in the module:
I also tried adding time as an allowed HTML tag, and I also tried disabling 'limit allowed HTML.'
Using the replacement filter
[filter-example-time]
works. But if we just change the filter to use that, then we don't get to demonstrateprepare()
.It only seems to work in the non-WYSIWYG format. So is there a way to include WYSIWYG?
Comment #28
Mile23Also: Needs both @ingroup filter_example and @group filter_example
Comment #29
Mile23Comment #30
Mile23Comment #31
jrockowitz CreditAttribution: jrockowitz as a volunteer and at The Big Blue House commentedI wanted to use the
fiter_example.module
during some training and saw that it had not been ported. I have limited bandwidth but I wanted to nudge this patch forward.Attached is the patch from #25 updated to work with Drupal 9.x and Examples 3.x. Because of the moving for filter_example.module to the modules directory, an interdiff is not very useful. Moving forward we should continue to include interdiffs.
Changes
examples_toolbar()
core_version_requirement: ^9
in examples.info. @see #3211322: Loose requirements of examples module for Drupal 9.1.xcore_version_requirement: ^9
to filter_example.info.yml and filter_example_test.info.yml\Drupal\filter_example\Plugin\Filter\FilterTime::process
Testing
Todo
Comment #32
jungleThanks for working on this, it's close. 4.0.x is the latest dev branch for ^9.4 || ^10
Comment #33
jungleRerolled and updated core_version_requirement to ^9.4 || ^10
Comment #34
jungleFix the test
Comment #35
jungleD8 is EOL. The title is not applicable.
Comment #36
jungleComment #37
liquidcms CreditAttribution: liquidcms commentedpatch does not apply to either 4.0.2 or latest 4.0-dev
Comment #38
liquidcms CreditAttribution: liquidcms commentedIn this example, would the config setting for filter_example_foo be translatable?
Comment #39
mrinalini9 CreditAttribution: mrinalini9 at Srijan | A Material+ Company for Drupal India Association commentedRerolled patch #34, please review it.
Thanks!