mirror of
https://github.com/laurent22/joplin.git
synced 2024-11-27 08:21:03 +02:00
Chore: Plugins: Allow absolute paths and URLs in screenshot src
s (#9254)
This commit is contained in:
parent
e61c4acce5
commit
1e530b74d4
@ -93,19 +93,24 @@ function validateCategories(categories) {
|
||||
|
||||
function validateScreenshots(screenshots) {
|
||||
if (!screenshots) return null;
|
||||
// eslint-disable-next-line github/array-foreach -- Old code before rule was applied
|
||||
screenshots.forEach(screenshot => {
|
||||
for (const screenshot of screenshots) {
|
||||
if (!screenshot.src) throw new Error('You must specify a src for each screenshot');
|
||||
|
||||
// Avoid attempting to download and verify URL screenshots.
|
||||
if (screenshot.src.startsWith('https://') || screenshot.src.startsWith('http://')) {
|
||||
continue;
|
||||
}
|
||||
|
||||
const screenshotType = screenshot.src.split('.').pop();
|
||||
if (!allPossibleScreenshotsType.includes(screenshotType)) throw new Error(`${screenshotType} is not a valid screenshot type. Valid types are: \n${allPossibleScreenshotsType}\n`);
|
||||
|
||||
const screenshotPath = path.resolve(srcDir, screenshot.src);
|
||||
const screenshotPath = path.resolve(rootDir, screenshot.src);
|
||||
|
||||
// Max file size is 1MB
|
||||
const fileMaxSize = 1024;
|
||||
const fileSize = fs.statSync(screenshotPath).size / 1024;
|
||||
if (fileSize > fileMaxSize) throw new Error(`Max screenshot file size is ${fileMaxSize}KB. ${screenshotPath} is ${fileSize}KB`);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
function readManifest(manifestPath) {
|
||||
|
@ -37,8 +37,10 @@ Name | Type | Required? | Description
|
||||
|
||||
| Properties | Description |
|
||||
| --- | --- |
|
||||
| src | a relative path to src dir. |
|
||||
| label | description of the image. |
|
||||
| src | a path or URL to a screenshot. If a path, `src` should be relative to the root of the repository (e.g. `screenshots/a.png`). |
|
||||
| label | description of the image. This label will be used by screen readers or if the image cannot be loaded. |
|
||||
|
||||
**Note**: If `src` is a path and not a URL, either `repository_url` or `homepage_url` must point to a GitHub repository for the screenshot to appear on the Joplin Plugins Website. See [the relevant issue](https://github.com/joplin/website-plugin-discovery/issues/35).
|
||||
|
||||
## Icons
|
||||
|
||||
@ -60,10 +62,16 @@ Name | Type | Required? | Description
|
||||
"author": "John Smith",
|
||||
"app_min_version": "1.4",
|
||||
"homepage_url": "https://joplinapp.org",
|
||||
"screenshots": [{
|
||||
"screenshots": [
|
||||
{
|
||||
"src": "path/to/image.png",
|
||||
"label": "image description"
|
||||
}],
|
||||
},
|
||||
{
|
||||
"src": "https://example.com/path/to/the/screenshot.png",
|
||||
"label": "image description"
|
||||
}
|
||||
],
|
||||
"icons": {
|
||||
"16": "path/to/icon16.png",
|
||||
"32": "path/to/icon32.png",
|
||||
|
Loading…
Reference in New Issue
Block a user