-
Notifications
You must be signed in to change notification settings - Fork 111
Improve image attachment management #2426
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
Merged
Merged
Changes from 1 commit
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
cad9a1d
change image target in markdown content to relative path, handle it i…
4d418ae
handle .attachments.OTHER_DOC_ID image targets, try webdav, fallback …
d3ae17c
adjust cypress tests to new markdown image target
b8a7932
improve ImageView code quality
b95deb9
remove ImageView Jest tests, we will make better ones with Cypress
1715a7c
move test, add comments for cleanup regexps
5782287
Compile assets
nextcloud-command File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next
Next commit
change image target in markdown content to relative path, handle it i…
…n ImageView Signed-off-by: Julien Veyssier <[email protected]>
- Loading branch information
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -7,36 +7,54 @@ | |
| use OCP\Files\Folder; | ||
|
|
||
| class TextTest extends \PHPUnit\Framework\TestCase { | ||
| private static $attachmentNames = [ | ||
| 'aaa.png', | ||
| 'aaa (2).png', | ||
| 'aaa 2).png', | ||
| 'aaa (2.png', | ||
| 'aaa ((2.png', | ||
| 'aaa 2)).png', | ||
| 'a[a]a.png', | ||
| 'a(a)a.png', | ||
| 'a](a.png', | ||
| ',;:!?.§-_a_', | ||
| 'a`a`.png', | ||
| ]; | ||
|
|
||
| public function testDummy() { | ||
| $app = new Application(); | ||
| $this->assertEquals('text', $app::APP_NAME); | ||
| } | ||
|
|
||
| public function testGetAttachmentNamesFromContent() { | ||
| $contentNames = [ | ||
| 'aaa.png', | ||
| 'aaa (2).png', | ||
| 'aaa 2).png', | ||
| 'aaa (2.png', | ||
| 'aaa ((2.png', | ||
| 'aaa 2)).png', | ||
| 'a[a]a.png', | ||
| 'a(a)a.png', | ||
| 'a](a.png', | ||
| ',;:!?.§-_a_', | ||
| 'a`a`.png', | ||
| ]; | ||
| public function testGetOldAttachmentNamesFromContent() { | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Something for a separate PR but we should move those tests into tests/unit/Service/ImageServiceTest.php |
||
| $content = "some content\n"; | ||
| foreach ($contentNames as $name) { | ||
| foreach (self::$attachmentNames as $name) { | ||
| // this is how it's generated in MenuBar.vue | ||
| $linkText = preg_replace('/[[\]]/', '', $name); | ||
| $encodedName = urlencode($name); | ||
| $content .= '\n"; | ||
| } | ||
| $content .= 'some content'; | ||
|
|
||
| $computedNames = ImageService::getAttachmentNamesFromContent($content); | ||
| foreach ($contentNames as $contentName) { | ||
| $computedNames = ImageService::getAttachmentNamesFromContent($content, 33); | ||
| foreach (self::$attachmentNames as $contentName) { | ||
| $this->assertContains($contentName, $computedNames); | ||
| } | ||
| } | ||
|
|
||
|
|
||
| public function testGetAttachmentNamesFromContent() { | ||
| $content = "some content\n"; | ||
| foreach (self::$attachmentNames as $name) { | ||
| // this is how it's generated in MenuBar.vue | ||
| $linkText = preg_replace('/[[\]]/', '', $name); | ||
| $encodedName = urlencode($name); | ||
| $content .= '\n"; | ||
| } | ||
| $content .= 'some content'; | ||
|
|
||
| $computedNames = ImageService::getAttachmentNamesFromContent($content, 33); | ||
| foreach (self::$attachmentNames as $contentName) { | ||
| $this->assertContains($contentName, $computedNames); | ||
| } | ||
| } | ||
|
|
||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.