install prettier
This commit is contained in:
parent
2662c78080
commit
9e2961421d
57 changed files with 2367 additions and 1162 deletions
38
.eslintrc
38
.eslintrc
|
|
@ -1,23 +1,17 @@
|
||||||
{
|
{
|
||||||
"root": true,
|
"root": true,
|
||||||
"parser": "@typescript-eslint/parser",
|
"parser": "@typescript-eslint/parser",
|
||||||
"env": { "node": true },
|
"env": { "node": true },
|
||||||
"plugins": [
|
"plugins": ["@typescript-eslint"],
|
||||||
"@typescript-eslint"
|
"extends": ["eslint:recommended", "plugin:@typescript-eslint/eslint-recommended", "plugin:@typescript-eslint/recommended"],
|
||||||
],
|
"parserOptions": {
|
||||||
"extends": [
|
"sourceType": "module"
|
||||||
"eslint:recommended",
|
},
|
||||||
"plugin:@typescript-eslint/eslint-recommended",
|
"rules": {
|
||||||
"plugin:@typescript-eslint/recommended"
|
"no-unused-vars": "off",
|
||||||
],
|
"@typescript-eslint/no-unused-vars": ["error", { "args": "none" }],
|
||||||
"parserOptions": {
|
"@typescript-eslint/ban-ts-comment": "off",
|
||||||
"sourceType": "module"
|
"no-prototype-builtins": "off",
|
||||||
},
|
"@typescript-eslint/no-empty-function": "off"
|
||||||
"rules": {
|
}
|
||||||
"no-unused-vars": "off",
|
}
|
||||||
"@typescript-eslint/no-unused-vars": ["error", { "args": "none" }],
|
|
||||||
"@typescript-eslint/ban-ts-comment": "off",
|
|
||||||
"no-prototype-builtins": "off",
|
|
||||||
"@typescript-eslint/no-empty-function": "off"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
|
||||||
6
.github/ISSUE_TEMPLATE/api-request.md
vendored
6
.github/ISSUE_TEMPLATE/api-request.md
vendored
|
|
@ -4,7 +4,6 @@ about: Suggest a new API to be added to this plugin.
|
||||||
title: ''
|
title: ''
|
||||||
labels: API request
|
labels: API request
|
||||||
assignees: ''
|
assignees: ''
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
**Name**
|
**Name**
|
||||||
|
|
@ -16,6 +15,5 @@ A link to their API documentation
|
||||||
**What does the API do/offer**
|
**What does the API do/offer**
|
||||||
A short description of what data the API offers
|
A short description of what data the API offers
|
||||||
|
|
||||||
|
- [ ] Is the API free to use
|
||||||
- [ ] Is the API free to use
|
- [ ] Does the API require authentication
|
||||||
- [ ] Does the API require authentication
|
|
||||||
|
|
|
||||||
17
.github/ISSUE_TEMPLATE/bug_report.md
vendored
17
.github/ISSUE_TEMPLATE/bug_report.md
vendored
|
|
@ -4,17 +4,17 @@ about: Create a report to help us improve
|
||||||
title: ''
|
title: ''
|
||||||
labels: bug
|
labels: bug
|
||||||
assignees: ''
|
assignees: ''
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
- [ ] The Plugin is up to date
|
- [ ] The Plugin is up to date
|
||||||
- [ ] Obsidian is up to date
|
- [ ] Obsidian is up to date
|
||||||
|
|
||||||
**Describe the bug**
|
**Describe the bug**
|
||||||
A clear and concise description of what the bug is.
|
A clear and concise description of what the bug is.
|
||||||
|
|
||||||
**To Reproduce**
|
**To Reproduce**
|
||||||
Steps to reproduce the behavior:
|
Steps to reproduce the behavior:
|
||||||
|
|
||||||
1. Go to '...'
|
1. Go to '...'
|
||||||
2. Click on '....'
|
2. Click on '....'
|
||||||
3. Scroll down to '....'
|
3. Scroll down to '....'
|
||||||
|
|
@ -27,11 +27,12 @@ A clear and concise description of what you expected to happen.
|
||||||
If applicable, add screenshots to help explain your problem.
|
If applicable, add screenshots to help explain your problem.
|
||||||
|
|
||||||
**Occurs on**
|
**Occurs on**
|
||||||
- [ ] Windows
|
|
||||||
- [ ] macOS
|
- [ ] Windows
|
||||||
- [ ] Linux
|
- [ ] macOS
|
||||||
- [ ] Android
|
- [ ] Linux
|
||||||
- [ ] iOS
|
- [ ] Android
|
||||||
|
- [ ] iOS
|
||||||
|
|
||||||
**Plugin version**
|
**Plugin version**
|
||||||
x.x.x
|
x.x.x
|
||||||
|
|
|
||||||
1
.github/ISSUE_TEMPLATE/feature_request.md
vendored
1
.github/ISSUE_TEMPLATE/feature_request.md
vendored
|
|
@ -4,7 +4,6 @@ about: Suggest an idea for this project
|
||||||
title: ''
|
title: ''
|
||||||
labels: feature request
|
labels: feature request
|
||||||
assignees: ''
|
assignees: ''
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
**Is your feature request related to a problem? Please describe.**
|
**Is your feature request related to a problem? Please describe.**
|
||||||
|
|
|
||||||
134
.github/workflows/release.yml
vendored
134
.github/workflows/release.yml
vendored
|
|
@ -4,7 +4,7 @@ on:
|
||||||
push:
|
push:
|
||||||
# Sequence of patterns matched against refs/tags
|
# Sequence of patterns matched against refs/tags
|
||||||
tags:
|
tags:
|
||||||
- "*" # Push events to matching any tag format, i.e. 1.0, 20.15.10
|
- '*' # Push events to matching any tag format, i.e. 1.0, 20.15.10
|
||||||
|
|
||||||
env:
|
env:
|
||||||
PLUGIN_NAME: obsidian-media-db-plugin # Change this to the name of your plugin-id folder
|
PLUGIN_NAME: obsidian-media-db-plugin # Change this to the name of your plugin-id folder
|
||||||
|
|
@ -14,69 +14,69 @@ jobs:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v2
|
||||||
- name: Use Node.js
|
- name: Use Node.js
|
||||||
uses: actions/setup-node@v1
|
uses: actions/setup-node@v1
|
||||||
with:
|
with:
|
||||||
node-version: "14.x" # You might need to adjust this value to your own version
|
node-version: '14.x' # You might need to adjust this value to your own version
|
||||||
- name: Build
|
- name: Build
|
||||||
id: build
|
id: build
|
||||||
run: |
|
run: |
|
||||||
yarn
|
yarn
|
||||||
yarn run build --if-present
|
yarn run build --if-present
|
||||||
mkdir ${{ env.PLUGIN_NAME }}
|
mkdir ${{ env.PLUGIN_NAME }}
|
||||||
cp main.js manifest.json styles.css ${{ env.PLUGIN_NAME }}
|
cp main.js manifest.json styles.css ${{ env.PLUGIN_NAME }}
|
||||||
zip -r ${{ env.PLUGIN_NAME }}.zip ${{ env.PLUGIN_NAME }}
|
zip -r ${{ env.PLUGIN_NAME }}.zip ${{ env.PLUGIN_NAME }}
|
||||||
ls
|
ls
|
||||||
echo "::set-output name=tag_name::$(git tag --sort version:refname | tail -n 1)"
|
echo "::set-output name=tag_name::$(git tag --sort version:refname | tail -n 1)"
|
||||||
- name: Create Release
|
- name: Create Release
|
||||||
id: create_release
|
id: create_release
|
||||||
uses: actions/create-release@v1
|
uses: actions/create-release@v1
|
||||||
env:
|
env:
|
||||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
VERSION: ${{ github.ref }}
|
VERSION: ${{ github.ref }}
|
||||||
with:
|
with:
|
||||||
tag_name: ${{ github.ref }}
|
tag_name: ${{ github.ref }}
|
||||||
release_name: ${{ github.ref }}
|
release_name: ${{ github.ref }}
|
||||||
draft: false
|
draft: false
|
||||||
prerelease: false
|
prerelease: false
|
||||||
- name: Upload zip file
|
- name: Upload zip file
|
||||||
id: upload-zip
|
id: upload-zip
|
||||||
uses: actions/upload-release-asset@v1
|
uses: actions/upload-release-asset@v1
|
||||||
env:
|
env:
|
||||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
with:
|
with:
|
||||||
upload_url: ${{ steps.create_release.outputs.upload_url }}
|
upload_url: ${{ steps.create_release.outputs.upload_url }}
|
||||||
asset_path: ./${{ env.PLUGIN_NAME }}.zip
|
asset_path: ./${{ env.PLUGIN_NAME }}.zip
|
||||||
asset_name: ${{ env.PLUGIN_NAME }}-${{ steps.build.outputs.tag_name }}.zip
|
asset_name: ${{ env.PLUGIN_NAME }}-${{ steps.build.outputs.tag_name }}.zip
|
||||||
asset_content_type: application/zip
|
asset_content_type: application/zip
|
||||||
- name: Upload main.js
|
- name: Upload main.js
|
||||||
id: upload-main
|
id: upload-main
|
||||||
uses: actions/upload-release-asset@v1
|
uses: actions/upload-release-asset@v1
|
||||||
env:
|
env:
|
||||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
with:
|
with:
|
||||||
upload_url: ${{ steps.create_release.outputs.upload_url }}
|
upload_url: ${{ steps.create_release.outputs.upload_url }}
|
||||||
asset_path: ./main.js
|
asset_path: ./main.js
|
||||||
asset_name: main.js
|
asset_name: main.js
|
||||||
asset_content_type: text/javascript
|
asset_content_type: text/javascript
|
||||||
- name: Upload manifest.json
|
- name: Upload manifest.json
|
||||||
id: upload-manifest
|
id: upload-manifest
|
||||||
uses: actions/upload-release-asset@v1
|
uses: actions/upload-release-asset@v1
|
||||||
env:
|
env:
|
||||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
with:
|
with:
|
||||||
upload_url: ${{ steps.create_release.outputs.upload_url }}
|
upload_url: ${{ steps.create_release.outputs.upload_url }}
|
||||||
asset_path: ./manifest.json
|
asset_path: ./manifest.json
|
||||||
asset_name: manifest.json
|
asset_name: manifest.json
|
||||||
asset_content_type: application/json
|
asset_content_type: application/json
|
||||||
- name: Upload styles.css
|
- name: Upload styles.css
|
||||||
id: upload-css
|
id: upload-css
|
||||||
uses: actions/upload-release-asset@v1
|
uses: actions/upload-release-asset@v1
|
||||||
env:
|
env:
|
||||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
with:
|
with:
|
||||||
upload_url: ${{ steps.create_release.outputs.upload_url }}
|
upload_url: ${{ steps.create_release.outputs.upload_url }}
|
||||||
asset_path: ./styles.css
|
asset_path: ./styles.css
|
||||||
asset_name: styles.css
|
asset_name: styles.css
|
||||||
asset_content_type: text/css
|
asset_content_type: text/css
|
||||||
|
|
|
||||||
5
.prettierignore
Normal file
5
.prettierignore
Normal file
|
|
@ -0,0 +1,5 @@
|
||||||
|
/lib
|
||||||
|
node_modules
|
||||||
|
package-lock.json
|
||||||
|
data.json
|
||||||
|
main.js
|
||||||
7
.prettierrc.json
Normal file
7
.prettierrc.json
Normal file
|
|
@ -0,0 +1,7 @@
|
||||||
|
{
|
||||||
|
"printWidth": 180,
|
||||||
|
"useTabs": true,
|
||||||
|
"semi": true,
|
||||||
|
"singleQuote": true,
|
||||||
|
"arrowParens": "avoid"
|
||||||
|
}
|
||||||
328
LICENSE.md
328
LICENSE.md
|
|
@ -1,190 +1,190 @@
|
||||||
GNU GENERAL PUBLIC LICENSE
|
GNU GENERAL PUBLIC LICENSE
|
||||||
Version 3, 29 June 2007
|
Version 3, 29 June 2007
|
||||||
|
|
||||||
Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
|
Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
|
||||||
Everyone is permitted to copy and distribute verbatim copies
|
Everyone is permitted to copy and distribute verbatim copies
|
||||||
of this license document, but changing it is not allowed.
|
of this license document, but changing it is not allowed.
|
||||||
|
|
||||||
Preamble
|
Preamble
|
||||||
|
|
||||||
The GNU General Public License is a free, copyleft license for
|
The GNU General Public License is a free, copyleft license for
|
||||||
software and other kinds of works.
|
software and other kinds of works.
|
||||||
|
|
||||||
The licenses for most software and other practical works are designed
|
The licenses for most software and other practical works are designed
|
||||||
to take away your freedom to share and change the works. By contrast,
|
to take away your freedom to share and change the works. By contrast,
|
||||||
the GNU General Public License is intended to guarantee your freedom to
|
the GNU General Public License is intended to guarantee your freedom to
|
||||||
share and change all versions of a program--to make sure it remains free
|
share and change all versions of a program--to make sure it remains free
|
||||||
software for all its users. We, the Free Software Foundation, use the
|
software for all its users. We, the Free Software Foundation, use the
|
||||||
GNU General Public License for most of our software; it applies also to
|
GNU General Public License for most of our software; it applies also to
|
||||||
any other work released this way by its authors. You can apply it to
|
any other work released this way by its authors. You can apply it to
|
||||||
your programs, too.
|
your programs, too.
|
||||||
|
|
||||||
When we speak of free software, we are referring to freedom, not
|
When we speak of free software, we are referring to freedom, not
|
||||||
price. Our General Public Licenses are designed to make sure that you
|
price. Our General Public Licenses are designed to make sure that you
|
||||||
have the freedom to distribute copies of free software (and charge for
|
have the freedom to distribute copies of free software (and charge for
|
||||||
them if you wish), that you receive source code or can get it if you
|
them if you wish), that you receive source code or can get it if you
|
||||||
want it, that you can change the software or use pieces of it in new
|
want it, that you can change the software or use pieces of it in new
|
||||||
free programs, and that you know you can do these things.
|
free programs, and that you know you can do these things.
|
||||||
|
|
||||||
To protect your rights, we need to prevent others from denying you
|
To protect your rights, we need to prevent others from denying you
|
||||||
these rights or asking you to surrender the rights. Therefore, you have
|
these rights or asking you to surrender the rights. Therefore, you have
|
||||||
certain responsibilities if you distribute copies of the software, or if
|
certain responsibilities if you distribute copies of the software, or if
|
||||||
you modify it: responsibilities to respect the freedom of others.
|
you modify it: responsibilities to respect the freedom of others.
|
||||||
|
|
||||||
For example, if you distribute copies of such a program, whether
|
For example, if you distribute copies of such a program, whether
|
||||||
gratis or for a fee, you must pass on to the recipients the same
|
gratis or for a fee, you must pass on to the recipients the same
|
||||||
freedoms that you received. You must make sure that they, too, receive
|
freedoms that you received. You must make sure that they, too, receive
|
||||||
or can get the source code. And you must show them these terms so they
|
or can get the source code. And you must show them these terms so they
|
||||||
know their rights.
|
know their rights.
|
||||||
|
|
||||||
Developers that use the GNU GPL protect your rights with two steps:
|
Developers that use the GNU GPL protect your rights with two steps:
|
||||||
(1) assert copyright on the software, and (2) offer you this License
|
(1) assert copyright on the software, and (2) offer you this License
|
||||||
giving you legal permission to copy, distribute and/or modify it.
|
giving you legal permission to copy, distribute and/or modify it.
|
||||||
|
|
||||||
For the developers' and authors' protection, the GPL clearly explains
|
For the developers' and authors' protection, the GPL clearly explains
|
||||||
that there is no warranty for this free software. For both users' and
|
that there is no warranty for this free software. For both users' and
|
||||||
authors' sake, the GPL requires that modified versions be marked as
|
authors' sake, the GPL requires that modified versions be marked as
|
||||||
changed, so that their problems will not be attributed erroneously to
|
changed, so that their problems will not be attributed erroneously to
|
||||||
authors of previous versions.
|
authors of previous versions.
|
||||||
|
|
||||||
Some devices are designed to deny users access to install or run
|
Some devices are designed to deny users access to install or run
|
||||||
modified versions of the software inside them, although the manufacturer
|
modified versions of the software inside them, although the manufacturer
|
||||||
can do so. This is fundamentally incompatible with the aim of
|
can do so. This is fundamentally incompatible with the aim of
|
||||||
protecting users' freedom to change the software. The systematic
|
protecting users' freedom to change the software. The systematic
|
||||||
pattern of such abuse occurs in the area of products for individuals to
|
pattern of such abuse occurs in the area of products for individuals to
|
||||||
use, which is precisely where it is most unacceptable. Therefore, we
|
use, which is precisely where it is most unacceptable. Therefore, we
|
||||||
have designed this version of the GPL to prohibit the practice for those
|
have designed this version of the GPL to prohibit the practice for those
|
||||||
products. If such problems arise substantially in other domains, we
|
products. If such problems arise substantially in other domains, we
|
||||||
stand ready to extend this provision to those domains in future versions
|
stand ready to extend this provision to those domains in future versions
|
||||||
of the GPL, as needed to protect the freedom of users.
|
of the GPL, as needed to protect the freedom of users.
|
||||||
|
|
||||||
Finally, every program is threatened constantly by software patents.
|
Finally, every program is threatened constantly by software patents.
|
||||||
States should not allow patents to restrict development and use of
|
States should not allow patents to restrict development and use of
|
||||||
software on general-purpose computers, but in those that do, we wish to
|
software on general-purpose computers, but in those that do, we wish to
|
||||||
avoid the special danger that patents applied to a free program could
|
avoid the special danger that patents applied to a free program could
|
||||||
make it effectively proprietary. To prevent this, the GPL assures that
|
make it effectively proprietary. To prevent this, the GPL assures that
|
||||||
patents cannot be used to render the program non-free.
|
patents cannot be used to render the program non-free.
|
||||||
|
|
||||||
The precise terms and conditions for copying, distribution and
|
The precise terms and conditions for copying, distribution and
|
||||||
modification follow.
|
modification follow.
|
||||||
|
|
||||||
TERMS AND CONDITIONS
|
TERMS AND CONDITIONS
|
||||||
|
|
||||||
0. Definitions.
|
0. Definitions.
|
||||||
|
|
||||||
"This License" refers to version 3 of the GNU General Public License.
|
"This License" refers to version 3 of the GNU General Public License.
|
||||||
|
|
||||||
"Copyright" also means copyright-like laws that apply to other kinds of
|
"Copyright" also means copyright-like laws that apply to other kinds of
|
||||||
works, such as semiconductor masks.
|
works, such as semiconductor masks.
|
||||||
|
|
||||||
"The Program" refers to any copyrightable work licensed under this
|
"The Program" refers to any copyrightable work licensed under this
|
||||||
License. Each licensee is addressed as "you". "Licensees" and
|
License. Each licensee is addressed as "you". "Licensees" and
|
||||||
"recipients" may be individuals or organizations.
|
"recipients" may be individuals or organizations.
|
||||||
|
|
||||||
To "modify" a work means to copy from or adapt all or part of the work
|
To "modify" a work means to copy from or adapt all or part of the work
|
||||||
in a fashion requiring copyright permission, other than the making of an
|
in a fashion requiring copyright permission, other than the making of an
|
||||||
exact copy. The resulting work is called a "modified version" of the
|
exact copy. The resulting work is called a "modified version" of the
|
||||||
earlier work or a work "based on" the earlier work.
|
earlier work or a work "based on" the earlier work.
|
||||||
|
|
||||||
A "covered work" means either the unmodified Program or a work based
|
A "covered work" means either the unmodified Program or a work based
|
||||||
on the Program.
|
on the Program.
|
||||||
|
|
||||||
To "propagate" a work means to do anything with it that, without
|
To "propagate" a work means to do anything with it that, without
|
||||||
permission, would make you directly or secondarily liable for
|
permission, would make you directly or secondarily liable for
|
||||||
infringement under applicable copyright law, except executing it on a
|
infringement under applicable copyright law, except executing it on a
|
||||||
computer or modifying a private copy. Propagation includes copying,
|
computer or modifying a private copy. Propagation includes copying,
|
||||||
distribution (with or without modification), making available to the
|
distribution (with or without modification), making available to the
|
||||||
public, and in some countries other activities as well.
|
public, and in some countries other activities as well.
|
||||||
|
|
||||||
To "convey" a work means any kind of propagation that enables other
|
To "convey" a work means any kind of propagation that enables other
|
||||||
parties to make or receive copies. Mere interaction with a user through
|
parties to make or receive copies. Mere interaction with a user through
|
||||||
a computer network, with no transfer of a copy, is not conveying.
|
a computer network, with no transfer of a copy, is not conveying.
|
||||||
|
|
||||||
An interactive user interface displays "Appropriate Legal Notices"
|
An interactive user interface displays "Appropriate Legal Notices"
|
||||||
to the extent that it includes a convenient and prominently visible
|
to the extent that it includes a convenient and prominently visible
|
||||||
feature that (1) displays an appropriate copyright notice, and (2)
|
feature that (1) displays an appropriate copyright notice, and (2)
|
||||||
tells the user that there is no warranty for the work (except to the
|
tells the user that there is no warranty for the work (except to the
|
||||||
extent that warranties are provided), that licensees may convey the
|
extent that warranties are provided), that licensees may convey the
|
||||||
work under this License, and how to view a copy of this License. If
|
work under this License, and how to view a copy of this License. If
|
||||||
the interface presents a list of user commands or options, such as a
|
the interface presents a list of user commands or options, such as a
|
||||||
menu, a prominent item in the list meets this criterion.
|
menu, a prominent item in the list meets this criterion.
|
||||||
|
|
||||||
1. Source Code.
|
1. Source Code.
|
||||||
|
|
||||||
The "source code" for a work means the preferred form of the work
|
The "source code" for a work means the preferred form of the work
|
||||||
for making modifications to it. "Object code" means any non-source
|
for making modifications to it. "Object code" means any non-source
|
||||||
form of a work.
|
form of a work.
|
||||||
|
|
||||||
A "Standard Interface" means an interface that either is an official
|
A "Standard Interface" means an interface that either is an official
|
||||||
standard defined by a recognized standards body, or, in the case of
|
standard defined by a recognized standards body, or, in the case of
|
||||||
interfaces specified for a particular programming language, one that
|
interfaces specified for a particular programming language, one that
|
||||||
is widely used among developers working in that language.
|
is widely used among developers working in that language.
|
||||||
|
|
||||||
The "System Libraries" of an executable work include anything, other
|
The "System Libraries" of an executable work include anything, other
|
||||||
than the work as a whole, that (a) is included in the normal form of
|
than the work as a whole, that (a) is included in the normal form of
|
||||||
packaging a Major Component, but which is not part of that Major
|
packaging a Major Component, but which is not part of that Major
|
||||||
Component, and (b) serves only to enable use of the work with that
|
Component, and (b) serves only to enable use of the work with that
|
||||||
Major Component, or to implement a Standard Interface for which an
|
Major Component, or to implement a Standard Interface for which an
|
||||||
implementation is available to the public in source code form. A
|
implementation is available to the public in source code form. A
|
||||||
"Major Component", in this context, means a major essential component
|
"Major Component", in this context, means a major essential component
|
||||||
(kernel, window system, and so on) of the specific operating system
|
(kernel, window system, and so on) of the specific operating system
|
||||||
(if any) on which the executable work runs, or a compiler used to
|
(if any) on which the executable work runs, or a compiler used to
|
||||||
produce the work, or an object code interpreter used to run it.
|
produce the work, or an object code interpreter used to run it.
|
||||||
|
|
||||||
The "Corresponding Source" for a work in object code form means all
|
The "Corresponding Source" for a work in object code form means all
|
||||||
the source code needed to generate, install, and (for an executable
|
the source code needed to generate, install, and (for an executable
|
||||||
work) run the object code and to modify the work, including scripts to
|
work) run the object code and to modify the work, including scripts to
|
||||||
control those activities. However, it does not include the work's
|
control those activities. However, it does not include the work's
|
||||||
System Libraries, or general-purpose tools or generally available free
|
System Libraries, or general-purpose tools or generally available free
|
||||||
programs which are used unmodified in performing those activities but
|
programs which are used unmodified in performing those activities but
|
||||||
which are not part of the work. For example, Corresponding Source
|
which are not part of the work. For example, Corresponding Source
|
||||||
includes interface definition files associated with source files for
|
includes interface definition files associated with source files for
|
||||||
the work, and the source code for shared libraries and dynamically
|
the work, and the source code for shared libraries and dynamically
|
||||||
linked subprograms that the work is specifically designed to require,
|
linked subprograms that the work is specifically designed to require,
|
||||||
such as by intimate data communication or control flow between those
|
such as by intimate data communication or control flow between those
|
||||||
subprograms and other parts of the work.
|
subprograms and other parts of the work.
|
||||||
|
|
||||||
The Corresponding Source need not include anything that users
|
The Corresponding Source need not include anything that users
|
||||||
can regenerate automatically from other parts of the Corresponding
|
can regenerate automatically from other parts of the Corresponding
|
||||||
Source.
|
Source.
|
||||||
|
|
||||||
The Corresponding Source for a work in source code form is that
|
The Corresponding Source for a work in source code form is that
|
||||||
same work.
|
same work.
|
||||||
|
|
||||||
2. Basic Permissions.
|
2. Basic Permissions.
|
||||||
|
|
||||||
All rights granted under this License are granted for the term of
|
All rights granted under this License are granted for the term of
|
||||||
copyright on the Program, and are irrevocable provided the stated
|
copyright on the Program, and are irrevocable provided the stated
|
||||||
conditions are met. This License explicitly affirms your unlimited
|
conditions are met. This License explicitly affirms your unlimited
|
||||||
permission to run the unmodified Program. The output from running a
|
permission to run the unmodified Program. The output from running a
|
||||||
covered work is covered by this License only if the output, given its
|
covered work is covered by this License only if the output, given its
|
||||||
content, constitutes a covered work. This License acknowledges your
|
content, constitutes a covered work. This License acknowledges your
|
||||||
rights of fair use or other equivalent, as provided by copyright law.
|
rights of fair use or other equivalent, as provided by copyright law.
|
||||||
|
|
||||||
You may make, run and propagate covered works that you do not
|
You may make, run and propagate covered works that you do not
|
||||||
convey, without conditions so long as your license otherwise remains
|
convey, without conditions so long as your license otherwise remains
|
||||||
in force. You may convey covered works to others for the sole purpose
|
in force. You may convey covered works to others for the sole purpose
|
||||||
of having them make modifications exclusively for you, or provide you
|
of having them make modifications exclusively for you, or provide you
|
||||||
with facilities for running those works, provided that you comply with
|
with facilities for running those works, provided that you comply with
|
||||||
the terms of this License in conveying all material for which you do
|
the terms of this License in conveying all material for which you do
|
||||||
not control copyright. Those thus making or running the covered works
|
not control copyright. Those thus making or running the covered works
|
||||||
for you must do so exclusively on your behalf, under your direction
|
for you must do so exclusively on your behalf, under your direction
|
||||||
and control, on terms that prohibit them from making any copies of
|
and control, on terms that prohibit them from making any copies of
|
||||||
your copyrighted material outside their relationship with you.
|
your copyrighted material outside their relationship with you.
|
||||||
|
|
||||||
Conveying under any other circumstances is permitted solely under
|
Conveying under any other circumstances is permitted solely under
|
||||||
the conditions stated below. Sublicensing is not allowed; section 10
|
the conditions stated below. Sublicensing is not allowed; section 10
|
||||||
makes it unnecessary.
|
makes it unnecessary.
|
||||||
|
|
||||||
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
|
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
|
||||||
|
|
||||||
No covered work shall be deemed part of an effective technological
|
No covered work shall be deemed part of an effective technological
|
||||||
measure under any applicable law fulfilling obligations under article
|
measure under any applicable law fulfilling obligations under article
|
||||||
11 of the WIPO copyright treaty adopted on 20 December 1996, or
|
11 of the WIPO copyright treaty adopted on 20 December 1996, or
|
||||||
similar laws prohibiting or restricting circumvention of such
|
similar laws prohibiting or restricting circumvention of such
|
||||||
measures.
|
measures.
|
||||||
|
|
||||||
When you convey a covered work, you waive any legal power to forbid
|
When you convey a covered work, you waive any legal power to forbid
|
||||||
circumvention of technological measures to the extent such circumvention
|
circumvention of technological measures to the extent such circumvention
|
||||||
is effected by exercising rights under this License with respect to
|
is effected by exercising rights under this License with respect to
|
||||||
the covered work, and you disclaim any intention to limit operation or
|
the covered work, and you disclaim any intention to limit operation or
|
||||||
|
|
@ -192,9 +192,9 @@ modification of the work as a means of enforcing, against the work's
|
||||||
users, your or third parties' legal rights to forbid circumvention of
|
users, your or third parties' legal rights to forbid circumvention of
|
||||||
technological measures.
|
technological measures.
|
||||||
|
|
||||||
4. Conveying Verbatim Copies.
|
4. Conveying Verbatim Copies.
|
||||||
|
|
||||||
You may convey verbatim copies of the Program's source code as you
|
You may convey verbatim copies of the Program's source code as you
|
||||||
receive it, in any medium, provided that you conspicuously and
|
receive it, in any medium, provided that you conspicuously and
|
||||||
appropriately publish on each copy an appropriate copyright notice;
|
appropriately publish on each copy an appropriate copyright notice;
|
||||||
keep intact all notices stating that this License and any
|
keep intact all notices stating that this License and any
|
||||||
|
|
@ -202,12 +202,12 @@ non-permissive terms added in accord with section 7 apply to the code;
|
||||||
keep intact all notices of the absence of any warranty; and give all
|
keep intact all notices of the absence of any warranty; and give all
|
||||||
recipients a copy of this License along with the Program.
|
recipients a copy of this License along with the Program.
|
||||||
|
|
||||||
You may charge any price or no price for each copy that you convey,
|
You may charge any price or no price for each copy that you convey,
|
||||||
and you may offer support or warranty protection for a fee.
|
and you may offer support or warranty protection for a fee.
|
||||||
|
|
||||||
5. Conveying Modified Source Versions.
|
5. Conveying Modified Source Versions.
|
||||||
|
|
||||||
You may convey a work based on the Program, or the modifications to
|
You may convey a work based on the Program, or the modifications to
|
||||||
produce it from the Program, in the form of source code under the
|
produce it from the Program, in the form of source code under the
|
||||||
terms of section 4, provided that you also meet all of these conditions:
|
terms of section 4, provided that you also meet all of these conditions:
|
||||||
|
|
||||||
|
|
@ -232,19 +232,19 @@ terms of section 4, provided that you also meet all of these conditions:
|
||||||
interfaces that do not display Appropriate Legal Notices, your
|
interfaces that do not display Appropriate Legal Notices, your
|
||||||
work need not make them do so.
|
work need not make them do so.
|
||||||
|
|
||||||
A compilation of a covered work with other separate and independent
|
A compilation of a covered work with other separate and independent
|
||||||
works, which are not by their nature extensions of the covered work,
|
works, which are not by their nature extensions of the covered work,
|
||||||
and which are not combined with it such as to form a larger program,
|
and which are not combined with it such as to form a larger program,
|
||||||
in or on a volume of a storage or distribution medium, is called an
|
in or on a volume of a storage or distribution medium, is called an
|
||||||
"aggregate" if the compilation and its resulting copyright are not
|
"aggregate" if the compilation and its resulting copyright are not
|
||||||
used to limit the access or legal rights of the compilation's users
|
used to limit the access or legal rights of the compilation's users
|
||||||
beyond what the individual works permit. Inclusion of a covered work
|
beyond what the individual works permit. Inclusion of a covered work
|
||||||
in an aggregate does not cause this License to apply to the other
|
in an aggregate does not cause this License to apply to the other
|
||||||
parts of the aggregate.
|
parts of the aggregate.
|
||||||
|
|
||||||
6. Conveying Non-Source Forms.
|
6. Conveying Non-Source Forms.
|
||||||
|
|
||||||
You may convey a covered work in object code form under the terms
|
You may convey a covered work in object code form under the terms
|
||||||
of sections 4 and 5, provided that you also convey the
|
of sections 4 and 5, provided that you also convey the
|
||||||
machine-readable Corresponding Source under the terms of this License,
|
machine-readable Corresponding Source under the terms of this License,
|
||||||
in one of these ways:
|
in one of these ways:
|
||||||
|
|
@ -290,75 +290,75 @@ in one of these ways:
|
||||||
Source of the work are being offered to the general public at no
|
Source of the work are being offered to the general public at no
|
||||||
charge under subsection 6d.
|
charge under subsection 6d.
|
||||||
|
|
||||||
A separable portion of the object code, whose source code is excluded
|
A separable portion of the object code, whose source code is excluded
|
||||||
from the Corresponding Source as a System Library, need not be
|
from the Corresponding Source as a System Library, need not be
|
||||||
included in conveying the object code work.
|
included in conveying the object code work.
|
||||||
|
|
||||||
A "User Product" is either (1) a "consumer product", which means any
|
A "User Product" is either (1) a "consumer product", which means any
|
||||||
tangible personal property which is normally used for personal, family,
|
tangible personal property which is normally used for personal, family,
|
||||||
or household purposes, or (2) anything designed or sold for incorporation
|
or household purposes, or (2) anything designed or sold for incorporation
|
||||||
into a dwelling. In determining whether a product is a consumer product,
|
into a dwelling. In determining whether a product is a consumer product,
|
||||||
doubtful cases shall be resolved in favor of coverage. For a particular
|
doubtful cases shall be resolved in favor of coverage. For a particular
|
||||||
product received by a particular user, "normally used" refers to a
|
product received by a particular user, "normally used" refers to a
|
||||||
typical or common use of that class of product, regardless of the status
|
typical or common use of that class of product, regardless of the status
|
||||||
of the particular user or of the way in which the particular user
|
of the particular user or of the way in which the particular user
|
||||||
actually uses, or expects or is expected to use, the product. A product
|
actually uses, or expects or is expected to use, the product. A product
|
||||||
is a consumer product regardless of whether the product has substantial
|
is a consumer product regardless of whether the product has substantial
|
||||||
commercial, industrial or non-consumer uses, unless such uses represent
|
commercial, industrial or non-consumer uses, unless such uses represent
|
||||||
the only significant mode of use of the product.
|
the only significant mode of use of the product.
|
||||||
|
|
||||||
"Installation Information" for a User Product means any methods,
|
"Installation Information" for a User Product means any methods,
|
||||||
procedures, authorization keys, or other information required to install
|
procedures, authorization keys, or other information required to install
|
||||||
and execute modified versions of a covered work in that User Product from
|
and execute modified versions of a covered work in that User Product from
|
||||||
a modified version of its Corresponding Source. The information must
|
a modified version of its Corresponding Source. The information must
|
||||||
suffice to ensure that the continued functioning of the modified object
|
suffice to ensure that the continued functioning of the modified object
|
||||||
code is in no case prevented or interfered with solely because
|
code is in no case prevented or interfered with solely because
|
||||||
modification has been made.
|
modification has been made.
|
||||||
|
|
||||||
If you convey an object code work under this section in, or with, or
|
If you convey an object code work under this section in, or with, or
|
||||||
specifically for use in, a User Product, and the conveying occurs as
|
specifically for use in, a User Product, and the conveying occurs as
|
||||||
part of a transaction in which the right of possession and use of the
|
part of a transaction in which the right of possession and use of the
|
||||||
User Product is transferred to the recipient in perpetuity or for a
|
User Product is transferred to the recipient in perpetuity or for a
|
||||||
fixed term (regardless of how the transaction is characterized), the
|
fixed term (regardless of how the transaction is characterized), the
|
||||||
Corresponding Source conveyed under this section must be accompanied
|
Corresponding Source conveyed under this section must be accompanied
|
||||||
by the Installation Information. But this requirement does not apply
|
by the Installation Information. But this requirement does not apply
|
||||||
if neither you nor any third party retains the ability to install
|
if neither you nor any third party retains the ability to install
|
||||||
modified object code on the User Product (for example, the work has
|
modified object code on the User Product (for example, the work has
|
||||||
been installed in ROM).
|
been installed in ROM).
|
||||||
|
|
||||||
The requirement to provide Installation Information does not include a
|
The requirement to provide Installation Information does not include a
|
||||||
requirement to continue to provide support service, warranty, or updates
|
requirement to continue to provide support service, warranty, or updates
|
||||||
for a work that has been modified or installed by the recipient, or for
|
for a work that has been modified or installed by the recipient, or for
|
||||||
the User Product in which it has been modified or installed. Access to a
|
the User Product in which it has been modified or installed. Access to a
|
||||||
network may be denied when the modification itself materially and
|
network may be denied when the modification itself materially and
|
||||||
adversely affects the operation of the network or violates the rules and
|
adversely affects the operation of the network or violates the rules and
|
||||||
protocols for communication across the network.
|
protocols for communication across the network.
|
||||||
|
|
||||||
Corresponding Source conveyed, and Installation Information provided,
|
Corresponding Source conveyed, and Installation Information provided,
|
||||||
in accord with this section must be in a format that is publicly
|
in accord with this section must be in a format that is publicly
|
||||||
documented (and with an implementation available to the public in
|
documented (and with an implementation available to the public in
|
||||||
source code form), and must require no special password or key for
|
source code form), and must require no special password or key for
|
||||||
unpacking, reading or copying.
|
unpacking, reading or copying.
|
||||||
|
|
||||||
7. Additional Terms.
|
7. Additional Terms.
|
||||||
|
|
||||||
"Additional permissions" are terms that supplement the terms of this
|
"Additional permissions" are terms that supplement the terms of this
|
||||||
License by making exceptions from one or more of its conditions.
|
License by making exceptions from one or more of its conditions.
|
||||||
Additional permissions that are applicable to the entire Program shall
|
Additional permissions that are applicable to the entire Program shall
|
||||||
be treated as though they were included in this License, to the extent
|
be treated as though they were included in this License, to the extent
|
||||||
that they are valid under applicable law. If additional permissions
|
that they are valid under applicable law. If additional permissions
|
||||||
apply only to part of the Program, that part may be used separately
|
apply only to part of the Program, that part may be used separately
|
||||||
under those permissions, but the entire Program remains governed by
|
under those permissions, but the entire Program remains governed by
|
||||||
this License without regard to the additional permissions.
|
this License without regard to the additional permissions.
|
||||||
|
|
||||||
When you convey a copy of a covered work, you may at your option
|
When you convey a copy of a covered work, you may at your option
|
||||||
remove any additional permissions from that copy, or from any part of
|
remove any additional permissions from that copy, or from any part of
|
||||||
it. (Additional permissions may be written to require their own
|
it. (Additional permissions may be written to require their own
|
||||||
removal in certain cases when you modify the work.) You may place
|
removal in certain cases when you modify the work.) You may place
|
||||||
additional permissions on material, added by you to a covered work,
|
additional permissions on material, added by you to a covered work,
|
||||||
for which you have or can give appropriate copyright permission.
|
for which you have or can give appropriate copyright permission.
|
||||||
|
|
||||||
Notwithstanding any other provision of this License, for material you
|
Notwithstanding any other provision of this License, for material you
|
||||||
add to a covered work, you may (if authorized by the copyright holders of
|
add to a covered work, you may (if authorized by the copyright holders of
|
||||||
that material) supplement the terms of this License with terms:
|
that material) supplement the terms of this License with terms:
|
||||||
|
|
||||||
|
|
@ -385,74 +385,74 @@ that material) supplement the terms of this License with terms:
|
||||||
any liability that these contractual assumptions directly impose on
|
any liability that these contractual assumptions directly impose on
|
||||||
those licensors and authors.
|
those licensors and authors.
|
||||||
|
|
||||||
All other non-permissive additional terms are considered "further
|
All other non-permissive additional terms are considered "further
|
||||||
restrictions" within the meaning of section 10. If the Program as you
|
restrictions" within the meaning of section 10. If the Program as you
|
||||||
received it, or any part of it, contains a notice stating that it is
|
received it, or any part of it, contains a notice stating that it is
|
||||||
governed by this License along with a term that is a further
|
governed by this License along with a term that is a further
|
||||||
restriction, you may remove that term. If a license document contains
|
restriction, you may remove that term. If a license document contains
|
||||||
a further restriction but permits relicensing or conveying under this
|
a further restriction but permits relicensing or conveying under this
|
||||||
License, you may add to a covered work material governed by the terms
|
License, you may add to a covered work material governed by the terms
|
||||||
of that license document, provided that the further restriction does
|
of that license document, provided that the further restriction does
|
||||||
not survive such relicensing or conveying.
|
not survive such relicensing or conveying.
|
||||||
|
|
||||||
If you add terms to a covered work in accord with this section, you
|
If you add terms to a covered work in accord with this section, you
|
||||||
must place, in the relevant source files, a statement of the
|
must place, in the relevant source files, a statement of the
|
||||||
additional terms that apply to those files, or a notice indicating
|
additional terms that apply to those files, or a notice indicating
|
||||||
where to find the applicable terms.
|
where to find the applicable terms.
|
||||||
|
|
||||||
Additional terms, permissive or non-permissive, may be stated in the
|
Additional terms, permissive or non-permissive, may be stated in the
|
||||||
form of a separately written license, or stated as exceptions;
|
form of a separately written license, or stated as exceptions;
|
||||||
the above requirements apply either way.
|
the above requirements apply either way.
|
||||||
|
|
||||||
8. Termination.
|
8. Termination.
|
||||||
|
|
||||||
You may not propagate or modify a covered work except as expressly
|
You may not propagate or modify a covered work except as expressly
|
||||||
provided under this License. Any attempt otherwise to propagate or
|
provided under this License. Any attempt otherwise to propagate or
|
||||||
modify it is void, and will automatically terminate your rights under
|
modify it is void, and will automatically terminate your rights under
|
||||||
this License (including any patent licenses granted under the third
|
this License (including any patent licenses granted under the third
|
||||||
paragraph of section 11).
|
paragraph of section 11).
|
||||||
|
|
||||||
However, if you cease all violation of this License, then your
|
However, if you cease all violation of this License, then your
|
||||||
license from a particular copyright holder is reinstated (a)
|
license from a particular copyright holder is reinstated (a)
|
||||||
provisionally, unless and until the copyright holder explicitly and
|
provisionally, unless and until the copyright holder explicitly and
|
||||||
finally terminates your license, and (b) permanently, if the copyright
|
finally terminates your license, and (b) permanently, if the copyright
|
||||||
holder fails to notify you of the violation by some reasonable means
|
holder fails to notify you of the violation by some reasonable means
|
||||||
prior to 60 days after the cessation.
|
prior to 60 days after the cessation.
|
||||||
|
|
||||||
Moreover, your license from a particular copyright holder is
|
Moreover, your license from a particular copyright holder is
|
||||||
reinstated permanently if the copyright holder notifies you of the
|
reinstated permanently if the copyright holder notifies you of the
|
||||||
violation by some reasonable means, this is the first time you have
|
violation by some reasonable means, this is the first time you have
|
||||||
received notice of violation of this License (for any work) from that
|
received notice of violation of this License (for any work) from that
|
||||||
copyright holder, and you cure the violation prior to 30 days after
|
copyright holder, and you cure the violation prior to 30 days after
|
||||||
your receipt of the notice.
|
your receipt of the notice.
|
||||||
|
|
||||||
Termination of your rights under this section does not terminate the
|
Termination of your rights under this section does not terminate the
|
||||||
licenses of parties who have received copies or rights from you under
|
licenses of parties who have received copies or rights from you under
|
||||||
this License. If your rights have been terminated and not permanently
|
this License. If your rights have been terminated and not permanently
|
||||||
reinstated, you do not qualify to receive new licenses for the same
|
reinstated, you do not qualify to receive new licenses for the same
|
||||||
material under section 10.
|
material under section 10.
|
||||||
|
|
||||||
9. Acceptance Not Required for Having Copies.
|
9. Acceptance Not Required for Having Copies.
|
||||||
|
|
||||||
You are not required to accept this License in order to receive or
|
You are not required to accept this License in order to receive or
|
||||||
run a copy of the Program. Ancillary propagation of a covered work
|
run a copy of the Program. Ancillary propagation of a covered work
|
||||||
occurring solely as a consequence of using peer-to-peer transmission
|
occurring solely as a consequence of using peer-to-peer transmission
|
||||||
to receive a copy likewise does not require acceptance. However,
|
to receive a copy likewise does not require acceptance. However,
|
||||||
nothing other than this License grants you permission to propagate or
|
nothing other than this License grants you permission to propagate or
|
||||||
modify any covered work. These actions infringe copyright if you do
|
modify any covered work. These actions infringe copyright if you do
|
||||||
not accept this License. Therefore, by modifying or propagating a
|
not accept this License. Therefore, by modifying or propagating a
|
||||||
covered work, you indicate your acceptance of this License to do so.
|
covered work, you indicate your acceptance of this License to do so.
|
||||||
|
|
||||||
10. Automatic Licensing of Downstream Recipients.
|
10. Automatic Licensing of Downstream Recipients.
|
||||||
|
|
||||||
Each time you convey a covered work, the recipient automatically
|
Each time you convey a covered work, the recipient automatically
|
||||||
receives a license from the original licensors, to run, modify and
|
receives a license from the original licensors, to run, modify and
|
||||||
propagate that work, subject to this License. You are not responsible
|
propagate that work, subject to this License. You are not responsible
|
||||||
for enforcing compliance by third parties with this License.
|
for enforcing compliance by third parties with this License.
|
||||||
|
|
||||||
An "entity transaction" is a transaction transferring control of an
|
An "entity transaction" is a transaction transferring control of an
|
||||||
organization, or substantially all assets of one, or subdividing an
|
organization, or substantially all assets of one, or subdividing an
|
||||||
organization, or merging organizations. If propagation of a covered
|
organization, or merging organizations. If propagation of a covered
|
||||||
work results from an entity transaction, each party to that
|
work results from an entity transaction, each party to that
|
||||||
transaction who receives a copy of the work also receives whatever
|
transaction who receives a copy of the work also receives whatever
|
||||||
licenses to the work the party's predecessor in interest had or could
|
licenses to the work the party's predecessor in interest had or could
|
||||||
|
|
@ -460,43 +460,43 @@ give under the previous paragraph, plus a right to possession of the
|
||||||
Corresponding Source of the work from the predecessor in interest, if
|
Corresponding Source of the work from the predecessor in interest, if
|
||||||
the predecessor has it or can get it with reasonable efforts.
|
the predecessor has it or can get it with reasonable efforts.
|
||||||
|
|
||||||
You may not impose any further restrictions on the exercise of the
|
You may not impose any further restrictions on the exercise of the
|
||||||
rights granted or affirmed under this License. For example, you may
|
rights granted or affirmed under this License. For example, you may
|
||||||
not impose a license fee, royalty, or other charge for exercise of
|
not impose a license fee, royalty, or other charge for exercise of
|
||||||
rights granted under this License, and you may not initiate litigation
|
rights granted under this License, and you may not initiate litigation
|
||||||
(including a cross-claim or counterclaim in a lawsuit) alleging that
|
(including a cross-claim or counterclaim in a lawsuit) alleging that
|
||||||
any patent claim is infringed by making, using, selling, offering for
|
any patent claim is infringed by making, using, selling, offering for
|
||||||
sale, or importing the Program or any portion of it.
|
sale, or importing the Program or any portion of it.
|
||||||
|
|
||||||
11. Patents.
|
11. Patents.
|
||||||
|
|
||||||
A "contributor" is a copyright holder who authorizes use under this
|
A "contributor" is a copyright holder who authorizes use under this
|
||||||
License of the Program or a work on which the Program is based. The
|
License of the Program or a work on which the Program is based. The
|
||||||
work thus licensed is called the contributor's "contributor version".
|
work thus licensed is called the contributor's "contributor version".
|
||||||
|
|
||||||
A contributor's "essential patent claims" are all patent claims
|
A contributor's "essential patent claims" are all patent claims
|
||||||
owned or controlled by the contributor, whether already acquired or
|
owned or controlled by the contributor, whether already acquired or
|
||||||
hereafter acquired, that would be infringed by some manner, permitted
|
hereafter acquired, that would be infringed by some manner, permitted
|
||||||
by this License, of making, using, or selling its contributor version,
|
by this License, of making, using, or selling its contributor version,
|
||||||
but do not include claims that would be infringed only as a
|
but do not include claims that would be infringed only as a
|
||||||
consequence of further modification of the contributor version. For
|
consequence of further modification of the contributor version. For
|
||||||
purposes of this definition, "control" includes the right to grant
|
purposes of this definition, "control" includes the right to grant
|
||||||
patent sublicenses in a manner consistent with the requirements of
|
patent sublicenses in a manner consistent with the requirements of
|
||||||
this License.
|
this License.
|
||||||
|
|
||||||
Each contributor grants you a non-exclusive, worldwide, royalty-free
|
Each contributor grants you a non-exclusive, worldwide, royalty-free
|
||||||
patent license under the contributor's essential patent claims, to
|
patent license under the contributor's essential patent claims, to
|
||||||
make, use, sell, offer for sale, import and otherwise run, modify and
|
make, use, sell, offer for sale, import and otherwise run, modify and
|
||||||
propagate the contents of its contributor version.
|
propagate the contents of its contributor version.
|
||||||
|
|
||||||
In the following three paragraphs, a "patent license" is any express
|
In the following three paragraphs, a "patent license" is any express
|
||||||
agreement or commitment, however denominated, not to enforce a patent
|
agreement or commitment, however denominated, not to enforce a patent
|
||||||
(such as an express permission to practice a patent or covenant not to
|
(such as an express permission to practice a patent or covenant not to
|
||||||
sue for patent infringement). To "grant" such a patent license to a
|
sue for patent infringement). To "grant" such a patent license to a
|
||||||
party means to make such an agreement or commitment not to enforce a
|
party means to make such an agreement or commitment not to enforce a
|
||||||
patent against the party.
|
patent against the party.
|
||||||
|
|
||||||
If you convey a covered work, knowingly relying on a patent license,
|
If you convey a covered work, knowingly relying on a patent license,
|
||||||
and the Corresponding Source of the work is not available for anyone
|
and the Corresponding Source of the work is not available for anyone
|
||||||
to copy, free of charge and under the terms of this License, through a
|
to copy, free of charge and under the terms of this License, through a
|
||||||
publicly available network server or other readily accessible means,
|
publicly available network server or other readily accessible means,
|
||||||
|
|
@ -504,13 +504,13 @@ then you must either (1) cause the Corresponding Source to be so
|
||||||
available, or (2) arrange to deprive yourself of the benefit of the
|
available, or (2) arrange to deprive yourself of the benefit of the
|
||||||
patent license for this particular work, or (3) arrange, in a manner
|
patent license for this particular work, or (3) arrange, in a manner
|
||||||
consistent with the requirements of this License, to extend the patent
|
consistent with the requirements of this License, to extend the patent
|
||||||
license to downstream recipients. "Knowingly relying" means you have
|
license to downstream recipients. "Knowingly relying" means you have
|
||||||
actual knowledge that, but for the patent license, your conveying the
|
actual knowledge that, but for the patent license, your conveying the
|
||||||
covered work in a country, or your recipient's use of the covered work
|
covered work in a country, or your recipient's use of the covered work
|
||||||
in a country, would infringe one or more identifiable patents in that
|
in a country, would infringe one or more identifiable patents in that
|
||||||
country that you have reason to believe are valid.
|
country that you have reason to believe are valid.
|
||||||
|
|
||||||
If, pursuant to or in connection with a single transaction or
|
If, pursuant to or in connection with a single transaction or
|
||||||
arrangement, you convey, or propagate by procuring conveyance of, a
|
arrangement, you convey, or propagate by procuring conveyance of, a
|
||||||
covered work, and grant a patent license to some of the parties
|
covered work, and grant a patent license to some of the parties
|
||||||
receiving the covered work authorizing them to use, propagate, modify
|
receiving the covered work authorizing them to use, propagate, modify
|
||||||
|
|
@ -518,10 +518,10 @@ or convey a specific copy of the covered work, then the patent license
|
||||||
you grant is automatically extended to all recipients of the covered
|
you grant is automatically extended to all recipients of the covered
|
||||||
work and works based on it.
|
work and works based on it.
|
||||||
|
|
||||||
A patent license is "discriminatory" if it does not include within
|
A patent license is "discriminatory" if it does not include within
|
||||||
the scope of its coverage, prohibits the exercise of, or is
|
the scope of its coverage, prohibits the exercise of, or is
|
||||||
conditioned on the non-exercise of one or more of the rights that are
|
conditioned on the non-exercise of one or more of the rights that are
|
||||||
specifically granted under this License. You may not convey a covered
|
specifically granted under this License. You may not convey a covered
|
||||||
work if you are a party to an arrangement with a third party that is
|
work if you are a party to an arrangement with a third party that is
|
||||||
in the business of distributing software, under which you make payment
|
in the business of distributing software, under which you make payment
|
||||||
to the third party based on the extent of your activity of conveying
|
to the third party based on the extent of your activity of conveying
|
||||||
|
|
@ -533,73 +533,73 @@ for and in connection with specific products or compilations that
|
||||||
contain the covered work, unless you entered into that arrangement,
|
contain the covered work, unless you entered into that arrangement,
|
||||||
or that patent license was granted, prior to 28 March 2007.
|
or that patent license was granted, prior to 28 March 2007.
|
||||||
|
|
||||||
Nothing in this License shall be construed as excluding or limiting
|
Nothing in this License shall be construed as excluding or limiting
|
||||||
any implied license or other defenses to infringement that may
|
any implied license or other defenses to infringement that may
|
||||||
otherwise be available to you under applicable patent law.
|
otherwise be available to you under applicable patent law.
|
||||||
|
|
||||||
12. No Surrender of Others' Freedom.
|
12. No Surrender of Others' Freedom.
|
||||||
|
|
||||||
If conditions are imposed on you (whether by court order, agreement or
|
If conditions are imposed on you (whether by court order, agreement or
|
||||||
otherwise) that contradict the conditions of this License, they do not
|
otherwise) that contradict the conditions of this License, they do not
|
||||||
excuse you from the conditions of this License. If you cannot convey a
|
excuse you from the conditions of this License. If you cannot convey a
|
||||||
covered work so as to satisfy simultaneously your obligations under this
|
covered work so as to satisfy simultaneously your obligations under this
|
||||||
License and any other pertinent obligations, then as a consequence you may
|
License and any other pertinent obligations, then as a consequence you may
|
||||||
not convey it at all. For example, if you agree to terms that obligate you
|
not convey it at all. For example, if you agree to terms that obligate you
|
||||||
to collect a royalty for further conveying from those to whom you convey
|
to collect a royalty for further conveying from those to whom you convey
|
||||||
the Program, the only way you could satisfy both those terms and this
|
the Program, the only way you could satisfy both those terms and this
|
||||||
License would be to refrain entirely from conveying the Program.
|
License would be to refrain entirely from conveying the Program.
|
||||||
|
|
||||||
13. Use with the GNU Affero General Public License.
|
13. Use with the GNU Affero General Public License.
|
||||||
|
|
||||||
Notwithstanding any other provision of this License, you have
|
Notwithstanding any other provision of this License, you have
|
||||||
permission to link or combine any covered work with a work licensed
|
permission to link or combine any covered work with a work licensed
|
||||||
under version 3 of the GNU Affero General Public License into a single
|
under version 3 of the GNU Affero General Public License into a single
|
||||||
combined work, and to convey the resulting work. The terms of this
|
combined work, and to convey the resulting work. The terms of this
|
||||||
License will continue to apply to the part which is the covered work,
|
License will continue to apply to the part which is the covered work,
|
||||||
but the special requirements of the GNU Affero General Public License,
|
but the special requirements of the GNU Affero General Public License,
|
||||||
section 13, concerning interaction through a network will apply to the
|
section 13, concerning interaction through a network will apply to the
|
||||||
combination as such.
|
combination as such.
|
||||||
|
|
||||||
14. Revised Versions of this License.
|
14. Revised Versions of this License.
|
||||||
|
|
||||||
The Free Software Foundation may publish revised and/or new versions of
|
The Free Software Foundation may publish revised and/or new versions of
|
||||||
the GNU General Public License from time to time. Such new versions will
|
the GNU General Public License from time to time. Such new versions will
|
||||||
be similar in spirit to the present version, but may differ in detail to
|
be similar in spirit to the present version, but may differ in detail to
|
||||||
address new problems or concerns.
|
address new problems or concerns.
|
||||||
|
|
||||||
Each version is given a distinguishing version number. If the
|
Each version is given a distinguishing version number. If the
|
||||||
Program specifies that a certain numbered version of the GNU General
|
Program specifies that a certain numbered version of the GNU General
|
||||||
Public License "or any later version" applies to it, you have the
|
Public License "or any later version" applies to it, you have the
|
||||||
option of following the terms and conditions either of that numbered
|
option of following the terms and conditions either of that numbered
|
||||||
version or of any later version published by the Free Software
|
version or of any later version published by the Free Software
|
||||||
Foundation. If the Program does not specify a version number of the
|
Foundation. If the Program does not specify a version number of the
|
||||||
GNU General Public License, you may choose any version ever published
|
GNU General Public License, you may choose any version ever published
|
||||||
by the Free Software Foundation.
|
by the Free Software Foundation.
|
||||||
|
|
||||||
If the Program specifies that a proxy can decide which future
|
If the Program specifies that a proxy can decide which future
|
||||||
versions of the GNU General Public License can be used, that proxy's
|
versions of the GNU General Public License can be used, that proxy's
|
||||||
public statement of acceptance of a version permanently authorizes you
|
public statement of acceptance of a version permanently authorizes you
|
||||||
to choose that version for the Program.
|
to choose that version for the Program.
|
||||||
|
|
||||||
Later license versions may give you additional or different
|
Later license versions may give you additional or different
|
||||||
permissions. However, no additional obligations are imposed on any
|
permissions. However, no additional obligations are imposed on any
|
||||||
author or copyright holder as a result of your choosing to follow a
|
author or copyright holder as a result of your choosing to follow a
|
||||||
later version.
|
later version.
|
||||||
|
|
||||||
15. Disclaimer of Warranty.
|
15. Disclaimer of Warranty.
|
||||||
|
|
||||||
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
|
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
|
||||||
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
|
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
|
||||||
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
|
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
|
||||||
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
|
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
|
||||||
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||||
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
|
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
|
||||||
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
|
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
|
||||||
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
|
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
|
||||||
|
|
||||||
16. Limitation of Liability.
|
16. Limitation of Liability.
|
||||||
|
|
||||||
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
||||||
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
|
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
|
||||||
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
|
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
|
||||||
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
|
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
|
||||||
|
|
@ -609,9 +609,9 @@ PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
|
||||||
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
|
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
|
||||||
SUCH DAMAGES.
|
SUCH DAMAGES.
|
||||||
|
|
||||||
17. Interpretation of Sections 15 and 16.
|
17. Interpretation of Sections 15 and 16.
|
||||||
|
|
||||||
If the disclaimer of warranty and limitation of liability provided
|
If the disclaimer of warranty and limitation of liability provided
|
||||||
above cannot be given local legal effect according to their terms,
|
above cannot be given local legal effect according to their terms,
|
||||||
reviewing courts shall apply local law that most closely approximates
|
reviewing courts shall apply local law that most closely approximates
|
||||||
an absolute waiver of all civil liability in connection with the
|
an absolute waiver of all civil liability in connection with the
|
||||||
|
|
@ -622,11 +622,11 @@ copy of the Program in return for a fee.
|
||||||
|
|
||||||
How to Apply These Terms to Your New Programs
|
How to Apply These Terms to Your New Programs
|
||||||
|
|
||||||
If you develop a new program, and you want it to be of the greatest
|
If you develop a new program, and you want it to be of the greatest
|
||||||
possible use to the public, the best way to achieve this is to make it
|
possible use to the public, the best way to achieve this is to make it
|
||||||
free software which everyone can redistribute and change under these terms.
|
free software which everyone can redistribute and change under these terms.
|
||||||
|
|
||||||
To do so, attach the following notices to the program. It is safest
|
To do so, attach the following notices to the program. It is safest
|
||||||
to attach them to the start of each source file to most effectively
|
to attach them to the start of each source file to most effectively
|
||||||
state the exclusion of warranty; and each file should have at least
|
state the exclusion of warranty; and each file should have at least
|
||||||
the "copyright" line and a pointer to where the full notice is found.
|
the "copyright" line and a pointer to where the full notice is found.
|
||||||
|
|
@ -649,7 +649,7 @@ the "copyright" line and a pointer to where the full notice is found.
|
||||||
|
|
||||||
Also add information on how to contact you by electronic and paper mail.
|
Also add information on how to contact you by electronic and paper mail.
|
||||||
|
|
||||||
If the program does terminal interaction, make it output a short
|
If the program does terminal interaction, make it output a short
|
||||||
notice like this when it starts in an interactive mode:
|
notice like this when it starts in an interactive mode:
|
||||||
|
|
||||||
<program> Copyright (C) <year> <name of author>
|
<program> Copyright (C) <year> <name of author>
|
||||||
|
|
@ -658,17 +658,17 @@ notice like this when it starts in an interactive mode:
|
||||||
under certain conditions; type `show c' for details.
|
under certain conditions; type `show c' for details.
|
||||||
|
|
||||||
The hypothetical commands `show w' and `show c' should show the appropriate
|
The hypothetical commands `show w' and `show c' should show the appropriate
|
||||||
parts of the General Public License. Of course, your program's commands
|
parts of the General Public License. Of course, your program's commands
|
||||||
might be different; for a GUI interface, you would use an "about box".
|
might be different; for a GUI interface, you would use an "about box".
|
||||||
|
|
||||||
You should also get your employer (if you work as a programmer) or school,
|
You should also get your employer (if you work as a programmer) or school,
|
||||||
if any, to sign a "copyright disclaimer" for the program, if necessary.
|
if any, to sign a "copyright disclaimer" for the program, if necessary.
|
||||||
For more information on this, and how to apply and follow the GNU GPL, see
|
For more information on this, and how to apply and follow the GNU GPL, see
|
||||||
<https://www.gnu.org/licenses/>.
|
<https://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
The GNU General Public License does not permit incorporating your program
|
The GNU General Public License does not permit incorporating your program
|
||||||
into proprietary programs. If your program is a subroutine library, you
|
into proprietary programs. If your program is a subroutine library, you
|
||||||
may consider it more useful to permit linking proprietary applications with
|
may consider it more useful to permit linking proprietary applications with
|
||||||
the library. If this is what you want to do, use the GNU Lesser General
|
the library. If this is what you want to do, use the GNU Lesser General
|
||||||
Public License instead of this License. But first, please read
|
Public License instead of this License. But first, please read
|
||||||
<https://www.gnu.org/licenses/why-not-lgpl.html>.
|
<https://www.gnu.org/licenses/why-not-lgpl.html>.
|
||||||
|
|
|
||||||
124
README.md
124
README.md
|
|
@ -3,69 +3,82 @@
|
||||||
A plugin that can query multiple APIs for movies, series, anime, games, music and wiki articles, and import them into your vault.
|
A plugin that can query multiple APIs for movies, series, anime, games, music and wiki articles, and import them into your vault.
|
||||||
|
|
||||||
### Features
|
### Features
|
||||||
|
|
||||||
#### Search by Title
|
#### Search by Title
|
||||||
|
|
||||||
Search a movie, series, anime, game, music release or wiki article by its name across multiple APIs.
|
Search a movie, series, anime, game, music release or wiki article by its name across multiple APIs.
|
||||||
|
|
||||||
#### Search by ID
|
#### Search by ID
|
||||||
|
|
||||||
Allows you to search by an ID that varies from API to API. Concrete information on this feature can be found in the description of the individual APIs.
|
Allows you to search by an ID that varies from API to API. Concrete information on this feature can be found in the description of the individual APIs.
|
||||||
|
|
||||||
#### Templates
|
#### Templates
|
||||||
|
|
||||||
The plugin allows you to set a template note that gets added to the end of any note created by this plugin.
|
The plugin allows you to set a template note that gets added to the end of any note created by this plugin.
|
||||||
The plugin also offers simple "template tgs". E.g. if the template includes `{{ title }}`, it will be replaced by the title of the movie, show or game.
|
The plugin also offers simple "template tgs". E.g. if the template includes `{{ title }}`, it will be replaced by the title of the movie, show or game.
|
||||||
Note that "template tags" are surrounded with two curly braces and that the spaces inside the curly braces are important.
|
Note that "template tags" are surrounded with two curly braces and that the spaces inside the curly braces are important.
|
||||||
|
|
||||||
For arrays there are two special ways of displaying them.
|
For arrays there are two special ways of displaying them.
|
||||||
- using `{{ LIST:variable_name }}` will result in
|
|
||||||
```
|
- using `{{ LIST:variable_name }}` will result in
|
||||||
- element 1
|
```
|
||||||
- element 2
|
- element 1
|
||||||
- element 3
|
- element 2
|
||||||
- ...
|
- element 3
|
||||||
```
|
- ...
|
||||||
- using `{{ ENUM:variable_name }}` will result in
|
```
|
||||||
```
|
- using `{{ ENUM:variable_name }}` will result in
|
||||||
element 1, element 2, element 3, ...
|
```
|
||||||
```
|
element 1, element 2, element 3, ...
|
||||||
|
```
|
||||||
|
|
||||||
Available variables that can be used in template tags are the same variables from the metadata of the note.
|
Available variables that can be used in template tags are the same variables from the metadata of the note.
|
||||||
|
|
||||||
I also published my own templates [here](https://github.com/mProjectsCode/obsidian-media-db-templates).
|
I also published my own templates [here](https://github.com/mProjectsCode/obsidian-media-db-templates).
|
||||||
|
|
||||||
#### Metadata field customization
|
#### Metadata field customization
|
||||||
|
|
||||||
Allows you to rename the metadata fields this plugin generates through mappings.
|
Allows you to rename the metadata fields this plugin generates through mappings.
|
||||||
|
|
||||||
A mapping has to follow this syntax `[origional property name] -> [new property name]`.
|
A mapping has to follow this syntax `[origional property name] -> [new property name]`.
|
||||||
Multiple mappings are separated by a new line.
|
Multiple mappings are separated by a new line.
|
||||||
So e.g.:
|
So e.g.:
|
||||||
|
|
||||||
```
|
```
|
||||||
title -> name
|
title -> name
|
||||||
year -> releaseYear
|
year -> releaseYear
|
||||||
```
|
```
|
||||||
|
|
||||||
#### Bulk Import
|
#### Bulk Import
|
||||||
|
|
||||||
The plugin allows you to import your preexisting media collection and upgrade them to Media DB entries.
|
The plugin allows you to import your preexisting media collection and upgrade them to Media DB entries.
|
||||||
|
|
||||||
##### Prerequisites
|
##### Prerequisites
|
||||||
|
|
||||||
The preexisting media notes must be inside a folder in your vault.
|
The preexisting media notes must be inside a folder in your vault.
|
||||||
For the plugin to be able to query them they need one metadata field that is used as the title the piece of media is searched by.
|
For the plugin to be able to query them they need one metadata field that is used as the title the piece of media is searched by.
|
||||||
This can be achieved by for example using a `csv` import plugin to import an existing list from outside of obsidian.
|
This can be achieved by for example using a `csv` import plugin to import an existing list from outside of obsidian.
|
||||||
|
|
||||||
##### Importing
|
##### Importing
|
||||||
|
|
||||||
To start the import process, right-click on the folder and select the `Import folder as Media DB entries` option.
|
To start the import process, right-click on the folder and select the `Import folder as Media DB entries` option.
|
||||||
Then specify the API to search, if the current note content and metadata should be appended to the Media DB entry and the name of the metadata field that contains the title of the piece of media.
|
Then specify the API to search, if the current note content and metadata should be appended to the Media DB entry and the name of the metadata field that contains the title of the piece of media.
|
||||||
|
|
||||||
Then the plugin will go through every file in the folder and prompt you to select from the search results.
|
Then the plugin will go through every file in the folder and prompt you to select from the search results.
|
||||||
|
|
||||||
##### Post import
|
##### Post import
|
||||||
|
|
||||||
After all files have been imported or the import was canceled, you will find the new entries as well as an error report that contains any errors or skipped/canceled files in the folder specified in the setting of the plugin.
|
After all files have been imported or the import was canceled, you will find the new entries as well as an error report that contains any errors or skipped/canceled files in the folder specified in the setting of the plugin.
|
||||||
|
|
||||||
### How to install
|
### How to install
|
||||||
|
|
||||||
**The plugin is now released, so it can be installed directly through obsidian's plugin installer.**
|
**The plugin is now released, so it can be installed directly through obsidian's plugin installer.**
|
||||||
|
|
||||||
Alternatively, you can manually download the zip archive from the latest release here on GitHub.
|
Alternatively, you can manually download the zip archive from the latest release here on GitHub.
|
||||||
After downloading, extract the archive into the `.obsidian/plugins` folder in your vault.
|
After downloading, extract the archive into the `.obsidian/plugins` folder in your vault.
|
||||||
|
|
||||||
The folder structure should look like this:
|
The folder structure should look like this:
|
||||||
|
|
||||||
```
|
```
|
||||||
[path to your vault]
|
[path to your vault]
|
||||||
|_ .obsidian
|
|_ .obsidian
|
||||||
|
|
@ -76,8 +89,8 @@ The folder structure should look like this:
|
||||||
|_ styles.css
|
|_ styles.css
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
### How to use
|
### How to use
|
||||||
|
|
||||||
(pictures are coming)
|
(pictures are coming)
|
||||||
|
|
||||||
Once you have installed this plugin, you will find a database icon in the left ribbon.
|
Once you have installed this plugin, you will find a database icon in the left ribbon.
|
||||||
|
|
@ -88,15 +101,17 @@ After clicking search, a new popup will open prompting you to select from the se
|
||||||
Now you select the result you want and the plugin will cast it's magic and create a new note in your vault, that contains the metadata of the selected search result.
|
Now you select the result you want and the plugin will cast it's magic and create a new note in your vault, that contains the metadata of the selected search result.
|
||||||
|
|
||||||
### Currently supported media types
|
### Currently supported media types
|
||||||
- movies (including specials)
|
|
||||||
- series (including OVAs)
|
- movies (including specials)
|
||||||
- games
|
- series (including OVAs)
|
||||||
- music releases
|
- games
|
||||||
- wiki articles
|
- music releases
|
||||||
|
- wiki articles
|
||||||
|
|
||||||
### Currently supported APIs:
|
### Currently supported APIs:
|
||||||
|
|
||||||
| Name | Description | Supported formats | Authentification | Rate limiting | SFW filter support |
|
| Name | Description | Supported formats | Authentification | Rate limiting | SFW filter support |
|
||||||
|------------------------------------------------------|---------------------------------------------------------------------------------------------------|--------------------------------|------------------------------------------------------------------------------|--------------------------------|--------------------|
|
| ---------------------------------------------------- | ------------------------------------------------------------------------------------------------- | ------------------------------ | ---------------------------------------------------------------------------- | ------------------------------ | ------------------ |
|
||||||
| [Jikan](https://jikan.moe/) | Jikan is an API that uses [My Anime List](https://myanimelist.net) and offers metadata for anime. | series, movies, specials, OVAs | No | 60 per minute and 3 per second | Yes |
|
| [Jikan](https://jikan.moe/) | Jikan is an API that uses [My Anime List](https://myanimelist.net) and offers metadata for anime. | series, movies, specials, OVAs | No | 60 per minute and 3 per second | Yes |
|
||||||
| [OMDb](https://www.omdbapi.com/) | OMDb is an API that offers metadata for movie, series and games. | series, movies, games | Yes, you can get a free key here [here](https://www.omdbapi.com/apikey.aspx) | 1000 per day | No |
|
| [OMDb](https://www.omdbapi.com/) | OMDb is an API that offers metadata for movie, series and games. | series, movies, games | Yes, you can get a free key here [here](https://www.omdbapi.com/apikey.aspx) | 1000 per day | No |
|
||||||
| [MusicBrainz](https://musicbrainz.org/) | MusicBrainz is an API that offers information about music releases. | music releases | No | 50 per second | No |
|
| [MusicBrainz](https://musicbrainz.org/) | MusicBrainz is an API that offers information about music releases. | music releases | No | 50 per second | No |
|
||||||
|
|
@ -104,59 +119,70 @@ Now you select the result you want and the plugin will cast it's magic and creat
|
||||||
| [Steam](https://store.steampowered.com/) | The Steam API offers information on all steam games. | games | No | 10000 per day | No |
|
| [Steam](https://store.steampowered.com/) | The Steam API offers information on all steam games. | games | No | 10000 per day | No |
|
||||||
|
|
||||||
#### Notes
|
#### Notes
|
||||||
- [Jikan](https://jikan.moe/)
|
|
||||||
- sometimes the api is very slow, this is normal
|
- [Jikan](https://jikan.moe/)
|
||||||
- you need to use the title the anime has on [My Anime List](https://myanimelist.net), which is in most cases the japanese title
|
- sometimes the api is very slow, this is normal
|
||||||
- e.g. instead of "Demon Slayer" you have to search "Kimetsu no Yaiba"
|
- you need to use the title the anime has on [My Anime List](https://myanimelist.net), which is in most cases the japanese title
|
||||||
|
- e.g. instead of "Demon Slayer" you have to search "Kimetsu no Yaiba"
|
||||||
|
|
||||||
#### Search by ID
|
#### Search by ID
|
||||||
- [Jikan](https://jikan.moe/)
|
|
||||||
- the ID you need is the ID of the anime on [My Anime List](https://myanimelist.net)
|
- [Jikan](https://jikan.moe/)
|
||||||
- you can find this ID in the URL
|
- the ID you need is the ID of the anime on [My Anime List](https://myanimelist.net)
|
||||||
- e.g. for "Beyond the Boundary" the URL looks like this `https://myanimelist.net/anime/18153/Kyoukai_no_Kanata` so the ID is `18153`
|
- you can find this ID in the URL
|
||||||
- [OMDb](https://www.omdbapi.com/)
|
- e.g. for "Beyond the Boundary" the URL looks like this `https://myanimelist.net/anime/18153/Kyoukai_no_Kanata` so the ID is `18153`
|
||||||
- the ID you need is the ID of the movie or show on [IMDb](https://www.imdb.com)
|
- [OMDb](https://www.omdbapi.com/)
|
||||||
- you can find this ID in the URL
|
- the ID you need is the ID of the movie or show on [IMDb](https://www.imdb.com)
|
||||||
- e.g. for "Rogue One" the URL looks like this `https://www.imdb.com/title/tt3748528/` so the ID is `tt3748528`
|
- you can find this ID in the URL
|
||||||
- [MusicBrainz](https://musicbrainz.org/)
|
- e.g. for "Rogue One" the URL looks like this `https://www.imdb.com/title/tt3748528/` so the ID is `tt3748528`
|
||||||
- the id of a release is not easily accessible, you are better off just searching by title
|
- [MusicBrainz](https://musicbrainz.org/)
|
||||||
- [Wikipedia](https://en.wikipedia.org/wiki/Main_Page)
|
- the id of a release is not easily accessible, you are better off just searching by title
|
||||||
- [here](https://en.wikipedia.org/wiki/Wikipedia:Finding_a_Wikidata_ID) is a guide to finding the Wikipedia ID for an article
|
- [Wikipedia](https://en.wikipedia.org/wiki/Main_Page)
|
||||||
- [Steam](https://store.steampowered.com/)
|
- [here](https://en.wikipedia.org/wiki/Wikipedia:Finding_a_Wikidata_ID) is a guide to finding the Wikipedia ID for an article
|
||||||
- you can find this ID in the URL
|
- [Steam](https://store.steampowered.com/)
|
||||||
- e.g. for "Factorio" the URL looks like this `https://store.steampowered.com/app/427520/Factorio/` so the ID is `427520`
|
- you can find this ID in the URL
|
||||||
|
- e.g. for "Factorio" the URL looks like this `https://store.steampowered.com/app/427520/Factorio/` so the ID is `427520`
|
||||||
|
|
||||||
### Problems, unexpected behavior or improvement suggestions?
|
### Problems, unexpected behavior or improvement suggestions?
|
||||||
|
|
||||||
You are more than welcome to open an issue on [GitHub](https://github.com/mProjectsCode/obsidian-media-db-plugin/issues).
|
You are more than welcome to open an issue on [GitHub](https://github.com/mProjectsCode/obsidian-media-db-plugin/issues).
|
||||||
|
|
||||||
### Changelog
|
### Changelog
|
||||||
|
|
||||||
#### 0.3.2
|
#### 0.3.2
|
||||||
- Added Board Game Geek API (documentation pending)
|
|
||||||
- More information in the search results
|
- Added Board Game Geek API (documentation pending)
|
||||||
- various fixes
|
- More information in the search results
|
||||||
|
- various fixes
|
||||||
|
|
||||||
#### 0.3.1
|
#### 0.3.1
|
||||||
- various fixes
|
|
||||||
|
- various fixes
|
||||||
|
|
||||||
#### 0.3.0
|
#### 0.3.0
|
||||||
- Added bulk import. Import a folder of media notes as Media DB entries (thanks to [PaperOrb](https://github.com/PaperOrb) on GitHub for their input and for helping me test this feature)
|
|
||||||
- Added a custom result select modal that allows you to select multiple results at once
|
- Added bulk import. Import a folder of media notes as Media DB entries (thanks to [PaperOrb](https://github.com/PaperOrb) on GitHub for their input and for helping me test this feature)
|
||||||
- Fixed a bug where the note creation would fail when the metadata included a field with the values `null` or `undefined`
|
- Added a custom result select modal that allows you to select multiple results at once
|
||||||
|
- Fixed a bug where the note creation would fail when the metadata included a field with the values `null` or `undefined`
|
||||||
|
|
||||||
#### 0.2.1
|
#### 0.2.1
|
||||||
- fixed a small bug with the initial selection of an API in the ID search modal
|
|
||||||
|
- fixed a small bug with the initial selection of an API in the ID search modal
|
||||||
|
|
||||||
#### 0.2.0
|
#### 0.2.0
|
||||||
- Added the option to rename metadata fields through property mappings
|
|
||||||
- fixed note creation falling, when the folder set in the settings did not exist
|
- Added the option to rename metadata fields through property mappings
|
||||||
|
- fixed note creation falling, when the folder set in the settings did not exist
|
||||||
|
|
||||||
### Contributions
|
### Contributions
|
||||||
|
|
||||||
Thank you for wanting to contribute to this project.
|
Thank you for wanting to contribute to this project.
|
||||||
|
|
||||||
Contributions are always welcome. If you have an idea, feel free to open a feature request under the issue tab or even create a pull request.
|
Contributions are always welcome. If you have an idea, feel free to open a feature request under the issue tab or even create a pull request.
|
||||||
|
|
||||||
### Credits
|
### Credits
|
||||||
|
|
||||||
Credits go to:
|
Credits go to:
|
||||||
- https://github.com/anpigon/obsidian-book-search-plugin for some inspiration and the idea to make this plugin
|
|
||||||
- https://github.com/liamcain/obsidian-periodic-notes for 99% of `Suggest.ts` and `FolderSuggest.ts`
|
- https://github.com/anpigon/obsidian-book-search-plugin for some inspiration and the idea to make this plugin
|
||||||
|
- https://github.com/liamcain/obsidian-periodic-notes for 99% of `Suggest.ts` and `FolderSuggest.ts`
|
||||||
|
|
|
||||||
|
|
@ -1,32 +1,32 @@
|
||||||
import { RequestUrlParam, RequestUrlResponse } from "obsidian";
|
import { RequestUrlParam, RequestUrlResponse } from 'obsidian';
|
||||||
|
|
||||||
export function requestUrl(request: RequestUrlParam): Promise<RequestUrlResponse> {
|
export function requestUrl(request: RequestUrlParam): Promise<RequestUrlResponse> {
|
||||||
return fetch(request.url, {
|
return fetch(request.url, {
|
||||||
method: request.method,
|
method: request.method,
|
||||||
headers: request.headers,
|
headers: request.headers,
|
||||||
body: request.body,
|
body: request.body,
|
||||||
}).then(async (response) => {
|
}).then(async response => {
|
||||||
if (response.status >= 400 && request.throw) {
|
if (response.status >= 400 && request.throw) {
|
||||||
throw new Error(`Request failed, ${response.status}`);
|
throw new Error(`Request failed, ${response.status}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Turn response headers into Record<string, string> object
|
// Turn response headers into Record<string, string> object
|
||||||
const headers: Record<string, string> = {};
|
const headers: Record<string, string> = {};
|
||||||
response.headers.forEach((value, key) => {
|
response.headers.forEach((value, key) => {
|
||||||
headers[key] = value;
|
headers[key] = value;
|
||||||
});
|
});
|
||||||
|
|
||||||
const arraybuffer = await response.arrayBuffer();
|
const arraybuffer = await response.arrayBuffer();
|
||||||
const text = arraybuffer ? new TextDecoder().decode(arraybuffer) : '';
|
const text = arraybuffer ? new TextDecoder().decode(arraybuffer) : '';
|
||||||
const json = text ? JSON.parse(text) : {};
|
const json = text ? JSON.parse(text) : {};
|
||||||
|
|
||||||
let response_body: RequestUrlResponse = {
|
let response_body: RequestUrlResponse = {
|
||||||
status: response.status,
|
status: response.status,
|
||||||
headers: headers,
|
headers: headers,
|
||||||
arrayBuffer: arraybuffer,
|
arrayBuffer: arraybuffer,
|
||||||
json: json,
|
json: json,
|
||||||
text: text,
|
text: text,
|
||||||
};
|
};
|
||||||
return response_body;
|
return response_body;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
@ -4,57 +4,59 @@ import builtins from 'builtin-modules';
|
||||||
import esbuildSvelte from 'esbuild-svelte';
|
import esbuildSvelte from 'esbuild-svelte';
|
||||||
import sveltePreprocess from 'svelte-preprocess';
|
import sveltePreprocess from 'svelte-preprocess';
|
||||||
|
|
||||||
const banner =
|
const banner = `/*
|
||||||
`/*
|
|
||||||
THIS IS A GENERATED/BUNDLED FILE BY ESBUILD
|
THIS IS A GENERATED/BUNDLED FILE BY ESBUILD
|
||||||
if you want to view the source, please visit the github repository of this plugin
|
if you want to view the source, please visit the github repository of this plugin
|
||||||
*/
|
*/
|
||||||
`;
|
`;
|
||||||
|
|
||||||
const prod = (process.argv[2] === 'production');
|
const prod = process.argv[2] === 'production';
|
||||||
|
|
||||||
esbuild.build({
|
esbuild
|
||||||
banner: {
|
.build({
|
||||||
js: banner,
|
banner: {
|
||||||
},
|
js: banner,
|
||||||
entryPoints: ['src/main.ts'],
|
},
|
||||||
bundle: true,
|
entryPoints: ['src/main.ts'],
|
||||||
external: [
|
bundle: true,
|
||||||
'obsidian',
|
external: [
|
||||||
'electron',
|
'obsidian',
|
||||||
'@codemirror/autocomplete',
|
'electron',
|
||||||
'@codemirror/closebrackets',
|
'@codemirror/autocomplete',
|
||||||
'@codemirror/collab',
|
'@codemirror/closebrackets',
|
||||||
'@codemirror/commands',
|
'@codemirror/collab',
|
||||||
'@codemirror/comment',
|
'@codemirror/commands',
|
||||||
'@codemirror/fold',
|
'@codemirror/comment',
|
||||||
'@codemirror/gutter',
|
'@codemirror/fold',
|
||||||
'@codemirror/highlight',
|
'@codemirror/gutter',
|
||||||
'@codemirror/history',
|
'@codemirror/highlight',
|
||||||
'@codemirror/language',
|
'@codemirror/history',
|
||||||
'@codemirror/lint',
|
'@codemirror/language',
|
||||||
'@codemirror/matchbrackets',
|
'@codemirror/lint',
|
||||||
'@codemirror/panel',
|
'@codemirror/matchbrackets',
|
||||||
'@codemirror/rangeset',
|
'@codemirror/panel',
|
||||||
'@codemirror/rectangular-selection',
|
'@codemirror/rangeset',
|
||||||
'@codemirror/search',
|
'@codemirror/rectangular-selection',
|
||||||
'@codemirror/state',
|
'@codemirror/search',
|
||||||
'@codemirror/stream-parser',
|
'@codemirror/state',
|
||||||
'@codemirror/text',
|
'@codemirror/stream-parser',
|
||||||
'@codemirror/tooltip',
|
'@codemirror/text',
|
||||||
'@codemirror/view',
|
'@codemirror/tooltip',
|
||||||
...builtins],
|
'@codemirror/view',
|
||||||
format: 'cjs',
|
...builtins,
|
||||||
watch: !prod,
|
],
|
||||||
target: 'es2016',
|
format: 'cjs',
|
||||||
logLevel: 'info',
|
watch: !prod,
|
||||||
sourcemap: prod ? false : 'inline',
|
target: 'es2016',
|
||||||
treeShaking: true,
|
logLevel: 'info',
|
||||||
outfile: 'main.js',
|
sourcemap: prod ? false : 'inline',
|
||||||
plugins: [
|
treeShaking: true,
|
||||||
esbuildSvelte({
|
outfile: 'main.js',
|
||||||
compilerOptions: { css: true },
|
plugins: [
|
||||||
preprocess: sveltePreprocess(),
|
esbuildSvelte({
|
||||||
}),
|
compilerOptions: { css: true },
|
||||||
],
|
preprocess: sveltePreprocess(),
|
||||||
}).catch(() => process.exit(1));
|
}),
|
||||||
|
],
|
||||||
|
})
|
||||||
|
.catch(() => process.exit(1));
|
||||||
|
|
|
||||||
|
|
@ -1,13 +1,7 @@
|
||||||
module.exports = {
|
module.exports = {
|
||||||
"roots": [
|
roots: ['<rootDir>/src', '<rootDir>'],
|
||||||
"<rootDir>/src",
|
testMatch: ['**/__tests__/**/*.+(ts|tsx|js)', '**/?(*.)+(spec|test).+(ts|tsx|js)'],
|
||||||
"<rootDir>"
|
transform: {
|
||||||
],
|
'^.+\\.(ts|tsx)$': 'ts-jest',
|
||||||
"testMatch": [
|
},
|
||||||
"**/__tests__/**/*.+(ts|tsx|js)",
|
};
|
||||||
"**/?(*.)+(spec|test).+(ts|tsx|js)"
|
|
||||||
],
|
|
||||||
"transform": {
|
|
||||||
"^.+\\.(ts|tsx)$": "ts-jest"
|
|
||||||
},
|
|
||||||
}
|
|
||||||
|
|
|
||||||
26
package-lock.json
generated
26
package-lock.json
generated
|
|
@ -1,12 +1,12 @@
|
||||||
{
|
{
|
||||||
"name": "obsidian-media-db-plugin",
|
"name": "obsidian-media-db-plugin",
|
||||||
"version": "0.3.2",
|
"version": "0.4.1",
|
||||||
"lockfileVersion": 2,
|
"lockfileVersion": 2,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"name": "obsidian-media-db-plugin",
|
"name": "obsidian-media-db-plugin",
|
||||||
"version": "0.3.2",
|
"version": "0.4.1",
|
||||||
"license": "GPL-3.0",
|
"license": "GPL-3.0",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"ts-node": "^10.8.1",
|
"ts-node": "^10.8.1",
|
||||||
|
|
@ -25,6 +25,7 @@
|
||||||
"jest": "^28.1.2",
|
"jest": "^28.1.2",
|
||||||
"jest-fetch-mock": "^3.0.3",
|
"jest-fetch-mock": "^3.0.3",
|
||||||
"obsidian": "latest",
|
"obsidian": "latest",
|
||||||
|
"prettier": "2.7.1",
|
||||||
"svelte": "^3.50.1",
|
"svelte": "^3.50.1",
|
||||||
"svelte-preprocess": "^4.10.7",
|
"svelte-preprocess": "^4.10.7",
|
||||||
"ts-jest": "^28.0.5",
|
"ts-jest": "^28.0.5",
|
||||||
|
|
@ -4353,6 +4354,21 @@
|
||||||
"node": ">= 0.8.0"
|
"node": ">= 0.8.0"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/prettier": {
|
||||||
|
"version": "2.7.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/prettier/-/prettier-2.7.1.tgz",
|
||||||
|
"integrity": "sha512-ujppO+MkdPqoVINuDFDRLClm7D78qbDt0/NR+wp5FqEZOoTNAjPHWj17QRhu7geIHJfcNhRk1XVQmF8Bp3ye+g==",
|
||||||
|
"dev": true,
|
||||||
|
"bin": {
|
||||||
|
"prettier": "bin-prettier.js"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">=10.13.0"
|
||||||
|
},
|
||||||
|
"funding": {
|
||||||
|
"url": "https://github.com/prettier/prettier?sponsor=1"
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/pretty-format": {
|
"node_modules/pretty-format": {
|
||||||
"version": "28.1.1",
|
"version": "28.1.1",
|
||||||
"resolved": "https://registry.npmjs.org/pretty-format/-/pretty-format-28.1.1.tgz",
|
"resolved": "https://registry.npmjs.org/pretty-format/-/pretty-format-28.1.1.tgz",
|
||||||
|
|
@ -8623,6 +8639,12 @@
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"peer": true
|
"peer": true
|
||||||
},
|
},
|
||||||
|
"prettier": {
|
||||||
|
"version": "2.7.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/prettier/-/prettier-2.7.1.tgz",
|
||||||
|
"integrity": "sha512-ujppO+MkdPqoVINuDFDRLClm7D78qbDt0/NR+wp5FqEZOoTNAjPHWj17QRhu7geIHJfcNhRk1XVQmF8Bp3ye+g==",
|
||||||
|
"dev": true
|
||||||
|
},
|
||||||
"pretty-format": {
|
"pretty-format": {
|
||||||
"version": "28.1.1",
|
"version": "28.1.1",
|
||||||
"resolved": "https://registry.npmjs.org/pretty-format/-/pretty-format-28.1.1.tgz",
|
"resolved": "https://registry.npmjs.org/pretty-format/-/pretty-format-28.1.1.tgz",
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,8 @@
|
||||||
"dev": "node esbuild.config.mjs",
|
"dev": "node esbuild.config.mjs",
|
||||||
"build": "tsc -noEmit -skipLibCheck && node esbuild.config.mjs production",
|
"build": "tsc -noEmit -skipLibCheck && node esbuild.config.mjs production",
|
||||||
"version": "node version-bump.mjs && git add manifest.json versions.json",
|
"version": "node version-bump.mjs && git add manifest.json versions.json",
|
||||||
"test": "jest"
|
"test": "jest",
|
||||||
|
"format": "prettier --write ."
|
||||||
},
|
},
|
||||||
"keywords": [],
|
"keywords": [],
|
||||||
"author": "Moritz Jung",
|
"author": "Moritz Jung",
|
||||||
|
|
@ -29,7 +30,8 @@
|
||||||
"svelte-preprocess": "^4.10.7",
|
"svelte-preprocess": "^4.10.7",
|
||||||
"ts-jest": "^28.0.5",
|
"ts-jest": "^28.0.5",
|
||||||
"tslib": "2.3.1",
|
"tslib": "2.3.1",
|
||||||
"typescript": "4.4.4"
|
"typescript": "4.4.4",
|
||||||
|
"prettier": "2.7.1"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"ts-node": "^10.8.1",
|
"ts-node": "^10.8.1",
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
import {APIModel} from './APIModel';
|
import { APIModel } from './APIModel';
|
||||||
import {MediaTypeModel} from '../models/MediaTypeModel';
|
import { MediaTypeModel } from '../models/MediaTypeModel';
|
||||||
|
|
||||||
export class APIManager {
|
export class APIManager {
|
||||||
apis: APIModel[];
|
apis: APIModel[];
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
import {MediaTypeModel} from '../models/MediaTypeModel';
|
import { MediaTypeModel } from '../models/MediaTypeModel';
|
||||||
|
|
||||||
export abstract class APIModel {
|
export abstract class APIModel {
|
||||||
apiName: string;
|
apiName: string;
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,9 @@
|
||||||
import {APIModel} from '../APIModel';
|
import { APIModel } from '../APIModel';
|
||||||
import {MediaTypeModel} from '../../models/MediaTypeModel';
|
import { MediaTypeModel } from '../../models/MediaTypeModel';
|
||||||
import MediaDbPlugin from '../../main';
|
import MediaDbPlugin from '../../main';
|
||||||
import {BoardGameModel} from 'src/models/BoardGameModel';
|
import { BoardGameModel } from 'src/models/BoardGameModel';
|
||||||
import {debugLog} from '../../utils/Utils';
|
import { debugLog } from '../../utils/Utils';
|
||||||
import {requestUrl} from 'obsidian';
|
import { requestUrl } from 'obsidian';
|
||||||
|
|
||||||
export class BoardGameGeekAPI extends APIModel {
|
export class BoardGameGeekAPI extends APIModel {
|
||||||
plugin: MediaDbPlugin;
|
plugin: MediaDbPlugin;
|
||||||
|
|
@ -42,13 +42,15 @@ export class BoardGameGeekAPI extends APIModel {
|
||||||
const title = boardgame.querySelector('name')!.textContent!;
|
const title = boardgame.querySelector('name')!.textContent!;
|
||||||
const year = boardgame.querySelector('yearpublished')?.textContent ?? '';
|
const year = boardgame.querySelector('yearpublished')?.textContent ?? '';
|
||||||
|
|
||||||
ret.push(new BoardGameModel({
|
ret.push(
|
||||||
dataSource: this.apiName,
|
new BoardGameModel({
|
||||||
id,
|
dataSource: this.apiName,
|
||||||
title,
|
id,
|
||||||
englishTitle: title,
|
title,
|
||||||
year,
|
englishTitle: title,
|
||||||
} as BoardGameModel));
|
year,
|
||||||
|
} as BoardGameModel)
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
|
|
@ -97,6 +99,5 @@ export class BoardGameGeekAPI extends APIModel {
|
||||||
} as BoardGameModel);
|
} as BoardGameModel);
|
||||||
|
|
||||||
return model;
|
return model;
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
import {APIModel} from '../APIModel';
|
import { APIModel } from '../APIModel';
|
||||||
import {MediaTypeModel} from '../../models/MediaTypeModel';
|
import { MediaTypeModel } from '../../models/MediaTypeModel';
|
||||||
import MediaDbPlugin from '../../main';
|
import MediaDbPlugin from '../../main';
|
||||||
import {debugLog} from '../../utils/Utils';
|
import { debugLog } from '../../utils/Utils';
|
||||||
|
|
||||||
// WIP
|
// WIP
|
||||||
export class LocGovAPI extends APIModel {
|
export class LocGovAPI extends APIModel {
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,9 @@
|
||||||
import {APIModel} from '../APIModel';
|
import { APIModel } from '../APIModel';
|
||||||
import {MediaTypeModel} from '../../models/MediaTypeModel';
|
import { MediaTypeModel } from '../../models/MediaTypeModel';
|
||||||
import {MovieModel} from '../../models/MovieModel';
|
import { MovieModel } from '../../models/MovieModel';
|
||||||
import MediaDbPlugin from '../../main';
|
import MediaDbPlugin from '../../main';
|
||||||
import {SeriesModel} from '../../models/SeriesModel';
|
import { SeriesModel } from '../../models/SeriesModel';
|
||||||
import {debugLog} from '../../utils/Utils';
|
import { debugLog } from '../../utils/Utils';
|
||||||
|
|
||||||
export class MALAPI extends APIModel {
|
export class MALAPI extends APIModel {
|
||||||
plugin: MediaDbPlugin;
|
plugin: MediaDbPlugin;
|
||||||
|
|
@ -43,33 +43,39 @@ export class MALAPI extends APIModel {
|
||||||
for (const result of data.data) {
|
for (const result of data.data) {
|
||||||
const type = this.typeMappings.get(result.type?.toLowerCase());
|
const type = this.typeMappings.get(result.type?.toLowerCase());
|
||||||
if (type === undefined) {
|
if (type === undefined) {
|
||||||
ret.push(new MovieModel({
|
ret.push(
|
||||||
subType: '',
|
new MovieModel({
|
||||||
title: result.title,
|
subType: '',
|
||||||
englishTitle: result.title_english ?? result.title,
|
title: result.title,
|
||||||
year: result.year ?? result.aired?.prop?.from?.year ?? '',
|
englishTitle: result.title_english ?? result.title,
|
||||||
dataSource: this.apiName,
|
year: result.year ?? result.aired?.prop?.from?.year ?? '',
|
||||||
id: result.mal_id,
|
dataSource: this.apiName,
|
||||||
} as MovieModel));
|
id: result.mal_id,
|
||||||
|
} as MovieModel)
|
||||||
|
);
|
||||||
}
|
}
|
||||||
if (type === 'movie' || type === 'special') {
|
if (type === 'movie' || type === 'special') {
|
||||||
ret.push(new MovieModel({
|
ret.push(
|
||||||
subType: type,
|
new MovieModel({
|
||||||
title: result.title,
|
subType: type,
|
||||||
englishTitle: result.title_english ?? result.title,
|
title: result.title,
|
||||||
year: result.year ?? result.aired?.prop?.from?.year ?? '',
|
englishTitle: result.title_english ?? result.title,
|
||||||
dataSource: this.apiName,
|
year: result.year ?? result.aired?.prop?.from?.year ?? '',
|
||||||
id: result.mal_id,
|
dataSource: this.apiName,
|
||||||
} as MovieModel));
|
id: result.mal_id,
|
||||||
|
} as MovieModel)
|
||||||
|
);
|
||||||
} else if (type === 'series' || type === 'ova') {
|
} else if (type === 'series' || type === 'ova') {
|
||||||
ret.push(new SeriesModel({
|
ret.push(
|
||||||
subType: type,
|
new SeriesModel({
|
||||||
title: result.title,
|
subType: type,
|
||||||
englishTitle: result.title_english ?? result.title,
|
title: result.title,
|
||||||
year: result.year ?? result.aired?.prop?.from?.year ?? '',
|
englishTitle: result.title_english ?? result.title,
|
||||||
dataSource: this.apiName,
|
year: result.year ?? result.aired?.prop?.from?.year ?? '',
|
||||||
id: result.mal_id,
|
dataSource: this.apiName,
|
||||||
} as SeriesModel));
|
id: result.mal_id,
|
||||||
|
} as SeriesModel)
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -108,7 +114,7 @@ export class MALAPI extends APIModel {
|
||||||
image: result.images?.jpg?.image_url ?? '',
|
image: result.images?.jpg?.image_url ?? '',
|
||||||
|
|
||||||
released: true,
|
released: true,
|
||||||
premiere: (new Date(result.aired?.from)).toLocaleDateString() ?? 'unknown',
|
premiere: new Date(result.aired?.from).toLocaleDateString() ?? 'unknown',
|
||||||
|
|
||||||
userData: {
|
userData: {
|
||||||
watched: false,
|
watched: false,
|
||||||
|
|
@ -137,7 +143,7 @@ export class MALAPI extends APIModel {
|
||||||
image: result.images?.jpg?.image_url ?? '',
|
image: result.images?.jpg?.image_url ?? '',
|
||||||
|
|
||||||
released: true,
|
released: true,
|
||||||
premiere: (new Date(result.aired?.from)).toLocaleDateString() ?? 'unknown',
|
premiere: new Date(result.aired?.from).toLocaleDateString() ?? 'unknown',
|
||||||
|
|
||||||
userData: {
|
userData: {
|
||||||
watched: false,
|
watched: false,
|
||||||
|
|
@ -165,8 +171,8 @@ export class MALAPI extends APIModel {
|
||||||
image: result.images?.jpg?.image_url ?? '',
|
image: result.images?.jpg?.image_url ?? '',
|
||||||
|
|
||||||
released: true,
|
released: true,
|
||||||
airedFrom: (new Date(result.aired?.from)).toLocaleDateString() ?? 'unknown',
|
airedFrom: new Date(result.aired?.from).toLocaleDateString() ?? 'unknown',
|
||||||
airedTo: (new Date(result.aired?.to)).toLocaleDateString() ?? 'unknown',
|
airedTo: new Date(result.aired?.to).toLocaleDateString() ?? 'unknown',
|
||||||
airing: result.airing,
|
airing: result.airing,
|
||||||
|
|
||||||
userData: {
|
userData: {
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,9 @@
|
||||||
import {APIModel} from '../APIModel';
|
import { APIModel } from '../APIModel';
|
||||||
import {MediaTypeModel} from '../../models/MediaTypeModel';
|
import { MediaTypeModel } from '../../models/MediaTypeModel';
|
||||||
import MediaDbPlugin from '../../main';
|
import MediaDbPlugin from '../../main';
|
||||||
import {requestUrl} from 'obsidian';
|
import { requestUrl } from 'obsidian';
|
||||||
import {MusicReleaseModel} from '../../models/MusicReleaseModel';
|
import { MusicReleaseModel } from '../../models/MusicReleaseModel';
|
||||||
import {contactEmail, debugLog, mediaDbVersion, pluginName} from '../../utils/Utils';
|
import { contactEmail, debugLog, mediaDbVersion, pluginName } from '../../utils/Utils';
|
||||||
|
|
||||||
export class MusicBrainzAPI extends APIModel {
|
export class MusicBrainzAPI extends APIModel {
|
||||||
plugin: MediaDbPlugin;
|
plugin: MediaDbPlugin;
|
||||||
|
|
@ -41,18 +41,20 @@ export class MusicBrainzAPI extends APIModel {
|
||||||
let ret: MediaTypeModel[] = [];
|
let ret: MediaTypeModel[] = [];
|
||||||
|
|
||||||
for (const result of data['release-groups']) {
|
for (const result of data['release-groups']) {
|
||||||
ret.push(new MusicReleaseModel({
|
ret.push(
|
||||||
type: 'musicRelease',
|
new MusicReleaseModel({
|
||||||
title: result.title,
|
type: 'musicRelease',
|
||||||
englishTitle: result.title,
|
title: result.title,
|
||||||
year: (new Date(result['first-release-date'])).getFullYear().toString(),
|
englishTitle: result.title,
|
||||||
dataSource: this.apiName,
|
year: new Date(result['first-release-date']).getFullYear().toString(),
|
||||||
url: '',
|
dataSource: this.apiName,
|
||||||
id: result.id,
|
url: '',
|
||||||
|
id: result.id,
|
||||||
|
|
||||||
artists: result['artist-credit'].map((a: any) => a.name),
|
artists: result['artist-credit'].map((a: any) => a.name),
|
||||||
subType: result['primary-type'],
|
subType: result['primary-type'],
|
||||||
} as MusicReleaseModel));
|
} as MusicReleaseModel)
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
|
|
@ -81,7 +83,7 @@ export class MusicBrainzAPI extends APIModel {
|
||||||
type: 'musicRelease',
|
type: 'musicRelease',
|
||||||
title: result.title,
|
title: result.title,
|
||||||
englishTitle: result.title,
|
englishTitle: result.title,
|
||||||
year: (new Date(result['first-release-date'])).getFullYear().toString(),
|
year: new Date(result['first-release-date']).getFullYear().toString(),
|
||||||
dataSource: this.apiName,
|
dataSource: this.apiName,
|
||||||
url: '',
|
url: '',
|
||||||
id: result.id,
|
id: result.id,
|
||||||
|
|
|
||||||
|
|
@ -1,10 +1,10 @@
|
||||||
import {APIModel} from '../APIModel';
|
import { APIModel } from '../APIModel';
|
||||||
import {MediaTypeModel} from '../../models/MediaTypeModel';
|
import { MediaTypeModel } from '../../models/MediaTypeModel';
|
||||||
import {MovieModel} from '../../models/MovieModel';
|
import { MovieModel } from '../../models/MovieModel';
|
||||||
import MediaDbPlugin from '../../main';
|
import MediaDbPlugin from '../../main';
|
||||||
import {SeriesModel} from '../../models/SeriesModel';
|
import { SeriesModel } from '../../models/SeriesModel';
|
||||||
import {GameModel} from '../../models/GameModel';
|
import { GameModel } from '../../models/GameModel';
|
||||||
import {debugLog} from '../../utils/Utils';
|
import { debugLog } from '../../utils/Utils';
|
||||||
|
|
||||||
export class OMDbAPI extends APIModel {
|
export class OMDbAPI extends APIModel {
|
||||||
plugin: MediaDbPlugin;
|
plugin: MediaDbPlugin;
|
||||||
|
|
@ -56,32 +56,38 @@ export class OMDbAPI extends APIModel {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (type === 'movie') {
|
if (type === 'movie') {
|
||||||
ret.push(new MovieModel({
|
ret.push(
|
||||||
type: type,
|
new MovieModel({
|
||||||
title: result.Title,
|
type: type,
|
||||||
englishTitle: result.Title,
|
title: result.Title,
|
||||||
year: result.Year,
|
englishTitle: result.Title,
|
||||||
dataSource: this.apiName,
|
year: result.Year,
|
||||||
id: result.imdbID,
|
dataSource: this.apiName,
|
||||||
} as MovieModel));
|
id: result.imdbID,
|
||||||
|
} as MovieModel)
|
||||||
|
);
|
||||||
} else if (type === 'series') {
|
} else if (type === 'series') {
|
||||||
ret.push(new SeriesModel({
|
ret.push(
|
||||||
type: type,
|
new SeriesModel({
|
||||||
title: result.Title,
|
type: type,
|
||||||
englishTitle: result.Title,
|
title: result.Title,
|
||||||
year: result.Year,
|
englishTitle: result.Title,
|
||||||
dataSource: this.apiName,
|
year: result.Year,
|
||||||
id: result.imdbID,
|
dataSource: this.apiName,
|
||||||
} as SeriesModel));
|
id: result.imdbID,
|
||||||
|
} as SeriesModel)
|
||||||
|
);
|
||||||
} else if (type === 'game') {
|
} else if (type === 'game') {
|
||||||
ret.push(new GameModel({
|
ret.push(
|
||||||
type: type,
|
new GameModel({
|
||||||
title: result.Title,
|
type: type,
|
||||||
englishTitle: result.Title,
|
title: result.Title,
|
||||||
year: result.Year,
|
englishTitle: result.Title,
|
||||||
dataSource: this.apiName,
|
year: result.Year,
|
||||||
id: result.imdbID,
|
dataSource: this.apiName,
|
||||||
} as GameModel));
|
id: result.imdbID,
|
||||||
|
} as GameModel)
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -130,7 +136,7 @@ export class OMDbAPI extends APIModel {
|
||||||
image: result.Poster ?? '',
|
image: result.Poster ?? '',
|
||||||
|
|
||||||
released: true,
|
released: true,
|
||||||
premiere: (new Date(result.Released)).toLocaleDateString() ?? 'unknown',
|
premiere: new Date(result.Released).toLocaleDateString() ?? 'unknown',
|
||||||
|
|
||||||
userData: {
|
userData: {
|
||||||
watched: false,
|
watched: false,
|
||||||
|
|
@ -159,7 +165,7 @@ export class OMDbAPI extends APIModel {
|
||||||
|
|
||||||
released: true,
|
released: true,
|
||||||
airing: false,
|
airing: false,
|
||||||
airedFrom: (new Date(result.Released)).toLocaleDateString() ?? 'unknown',
|
airedFrom: new Date(result.Released).toLocaleDateString() ?? 'unknown',
|
||||||
airedTo: 'unknown',
|
airedTo: 'unknown',
|
||||||
|
|
||||||
userData: {
|
userData: {
|
||||||
|
|
@ -185,7 +191,7 @@ export class OMDbAPI extends APIModel {
|
||||||
image: result.Poster ?? '',
|
image: result.Poster ?? '',
|
||||||
|
|
||||||
released: true,
|
released: true,
|
||||||
releaseDate: (new Date(result.Released)).toLocaleDateString() ?? 'unknown',
|
releaseDate: new Date(result.Released).toLocaleDateString() ?? 'unknown',
|
||||||
|
|
||||||
userData: {
|
userData: {
|
||||||
played: false,
|
played: false,
|
||||||
|
|
|
||||||
|
|
@ -1,10 +1,10 @@
|
||||||
import {APIModel} from '../APIModel';
|
import { APIModel } from '../APIModel';
|
||||||
import {MediaTypeModel} from '../../models/MediaTypeModel';
|
import { MediaTypeModel } from '../../models/MediaTypeModel';
|
||||||
import MediaDbPlugin from '../../main';
|
import MediaDbPlugin from '../../main';
|
||||||
import {GameModel} from '../../models/GameModel';
|
import { GameModel } from '../../models/GameModel';
|
||||||
import {debugLog} from '../../utils/Utils';
|
import { debugLog } from '../../utils/Utils';
|
||||||
import {requestUrl} from 'obsidian';
|
import { requestUrl } from 'obsidian';
|
||||||
import {MediaType} from '../../utils/MediaType';
|
import { MediaType } from '../../utils/MediaType';
|
||||||
|
|
||||||
export class SteamAPI extends APIModel {
|
export class SteamAPI extends APIModel {
|
||||||
plugin: MediaDbPlugin;
|
plugin: MediaDbPlugin;
|
||||||
|
|
@ -52,14 +52,16 @@ export class SteamAPI extends APIModel {
|
||||||
let ret: MediaTypeModel[] = [];
|
let ret: MediaTypeModel[] = [];
|
||||||
|
|
||||||
for (const result of filteredData) {
|
for (const result of filteredData) {
|
||||||
ret.push(new GameModel({
|
ret.push(
|
||||||
type: MediaType.Game,
|
new GameModel({
|
||||||
title: result.name,
|
type: MediaType.Game,
|
||||||
englishTitle: result.name,
|
title: result.name,
|
||||||
year: '',
|
englishTitle: result.name,
|
||||||
dataSource: this.apiName,
|
year: '',
|
||||||
id: result.appid,
|
dataSource: this.apiName,
|
||||||
} as GameModel));
|
id: result.appid,
|
||||||
|
} as GameModel)
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
|
|
@ -98,7 +100,7 @@ export class SteamAPI extends APIModel {
|
||||||
type: MediaType.Game,
|
type: MediaType.Game,
|
||||||
title: result.name,
|
title: result.name,
|
||||||
englishTitle: result.name,
|
englishTitle: result.name,
|
||||||
year: (new Date(result.release_date.date)).getFullYear().toString(),
|
year: new Date(result.release_date.date).getFullYear().toString(),
|
||||||
dataSource: this.apiName,
|
dataSource: this.apiName,
|
||||||
url: `https://store.steampowered.com/app/${result.steam_appid}`,
|
url: `https://store.steampowered.com/app/${result.steam_appid}`,
|
||||||
id: result.steam_appid,
|
id: result.steam_appid,
|
||||||
|
|
@ -108,7 +110,7 @@ export class SteamAPI extends APIModel {
|
||||||
image: result.header_image ?? '',
|
image: result.header_image ?? '',
|
||||||
|
|
||||||
released: !result.release_date?.comming_soon,
|
released: !result.release_date?.comming_soon,
|
||||||
releaseDate: (new Date(result.release_date?.date)).toLocaleDateString() ?? 'unknown',
|
releaseDate: new Date(result.release_date?.date).toLocaleDateString() ?? 'unknown',
|
||||||
|
|
||||||
userData: {
|
userData: {
|
||||||
played: false,
|
played: false,
|
||||||
|
|
@ -117,6 +119,5 @@ export class SteamAPI extends APIModel {
|
||||||
} as GameModel);
|
} as GameModel);
|
||||||
|
|
||||||
return model;
|
return model;
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,8 @@
|
||||||
import {APIModel} from '../APIModel';
|
import { APIModel } from '../APIModel';
|
||||||
import {MediaTypeModel} from '../../models/MediaTypeModel';
|
import { MediaTypeModel } from '../../models/MediaTypeModel';
|
||||||
import MediaDbPlugin from '../../main';
|
import MediaDbPlugin from '../../main';
|
||||||
import {WikiModel} from '../../models/WikiModel';
|
import { WikiModel } from '../../models/WikiModel';
|
||||||
import {debugLog} from '../../utils/Utils';
|
import { debugLog } from '../../utils/Utils';
|
||||||
|
|
||||||
export class WikipediaAPI extends APIModel {
|
export class WikipediaAPI extends APIModel {
|
||||||
plugin: MediaDbPlugin;
|
plugin: MediaDbPlugin;
|
||||||
|
|
@ -33,14 +33,16 @@ export class WikipediaAPI extends APIModel {
|
||||||
let ret: MediaTypeModel[] = [];
|
let ret: MediaTypeModel[] = [];
|
||||||
|
|
||||||
for (const result of data.query.search) {
|
for (const result of data.query.search) {
|
||||||
ret.push(new WikiModel({
|
ret.push(
|
||||||
type: 'wiki',
|
new WikiModel({
|
||||||
title: result.title,
|
type: 'wiki',
|
||||||
englishTitle: result.title,
|
title: result.title,
|
||||||
year: '',
|
englishTitle: result.title,
|
||||||
dataSource: this.apiName,
|
year: '',
|
||||||
id: result.pageid,
|
dataSource: this.apiName,
|
||||||
} as WikiModel));
|
id: result.pageid,
|
||||||
|
} as WikiModel)
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
|
|
@ -70,7 +72,7 @@ export class WikipediaAPI extends APIModel {
|
||||||
id: result.pageid,
|
id: result.pageid,
|
||||||
|
|
||||||
wikiUrl: result.fullurl,
|
wikiUrl: result.fullurl,
|
||||||
lastUpdated: (new Date(result.touched)).toLocaleDateString() ?? 'unknown',
|
lastUpdated: new Date(result.touched).toLocaleDateString() ?? 'unknown',
|
||||||
length: result.length,
|
length: result.length,
|
||||||
|
|
||||||
userData: {},
|
userData: {},
|
||||||
|
|
|
||||||
142
src/main.ts
142
src/main.ts
|
|
@ -1,20 +1,20 @@
|
||||||
import {MarkdownView, Notice, parseYaml, Plugin, stringifyYaml, TFile, TFolder} from 'obsidian';
|
import { MarkdownView, Notice, parseYaml, Plugin, stringifyYaml, TFile, TFolder } from 'obsidian';
|
||||||
import {getDefaultSettings, MediaDbPluginSettings, MediaDbSettingTab} from './settings/Settings';
|
import { getDefaultSettings, MediaDbPluginSettings, MediaDbSettingTab } from './settings/Settings';
|
||||||
import {APIManager} from './api/APIManager';
|
import { APIManager } from './api/APIManager';
|
||||||
import {MediaTypeModel} from './models/MediaTypeModel';
|
import { MediaTypeModel } from './models/MediaTypeModel';
|
||||||
import {CreateNoteOptions, dateTimeToString, markdownTable, replaceIllegalFileNameCharactersInString} from './utils/Utils';
|
import { CreateNoteOptions, dateTimeToString, markdownTable, replaceIllegalFileNameCharactersInString } from './utils/Utils';
|
||||||
import {OMDbAPI} from './api/apis/OMDbAPI';
|
import { OMDbAPI } from './api/apis/OMDbAPI';
|
||||||
import {MALAPI} from './api/apis/MALAPI';
|
import { MALAPI } from './api/apis/MALAPI';
|
||||||
import {WikipediaAPI} from './api/apis/WikipediaAPI';
|
import { WikipediaAPI } from './api/apis/WikipediaAPI';
|
||||||
import {MusicBrainzAPI} from './api/apis/MusicBrainzAPI';
|
import { MusicBrainzAPI } from './api/apis/MusicBrainzAPI';
|
||||||
import {MediaTypeManager} from './utils/MediaTypeManager';
|
import { MediaTypeManager } from './utils/MediaTypeManager';
|
||||||
import {SteamAPI} from './api/apis/SteamAPI';
|
import { SteamAPI } from './api/apis/SteamAPI';
|
||||||
import {BoardGameGeekAPI} from './api/apis/BoardGameGeekAPI';
|
import { BoardGameGeekAPI } from './api/apis/BoardGameGeekAPI';
|
||||||
import {PropertyMapper} from './settings/PropertyMapper';
|
import { PropertyMapper } from './settings/PropertyMapper';
|
||||||
import {YAMLConverter} from './utils/YAMLConverter';
|
import { YAMLConverter } from './utils/YAMLConverter';
|
||||||
import {MediaDbFolderImportModal} from './modals/MediaDbFolderImportModal';
|
import { MediaDbFolderImportModal } from './modals/MediaDbFolderImportModal';
|
||||||
import {PropertyMapping, PropertyMappingModel} from './settings/PropertyMapping';
|
import { PropertyMapping, PropertyMappingModel } from './settings/PropertyMapping';
|
||||||
import {ModalHelper, ModalResultCode} from './utils/ModalHelper';
|
import { ModalHelper, ModalResultCode } from './utils/ModalHelper';
|
||||||
|
|
||||||
export default class MediaDbPlugin extends Plugin {
|
export default class MediaDbPlugin extends Plugin {
|
||||||
settings: MediaDbPluginSettings;
|
settings: MediaDbPluginSettings;
|
||||||
|
|
@ -47,20 +47,20 @@ export default class MediaDbPlugin extends Plugin {
|
||||||
this.mediaTypeManager.updateTemplates(this.settings);
|
this.mediaTypeManager.updateTemplates(this.settings);
|
||||||
|
|
||||||
// add icon to the left ribbon
|
// add icon to the left ribbon
|
||||||
const ribbonIconEl = this.addRibbonIcon('database', 'Add new Media DB entry', (evt: MouseEvent) =>
|
const ribbonIconEl = this.addRibbonIcon('database', 'Add new Media DB entry', (evt: MouseEvent) => this.createEntryWithAdvancedSearchModal());
|
||||||
this.createEntryWithAdvancedSearchModal(),
|
|
||||||
);
|
|
||||||
ribbonIconEl.addClass('obsidian-media-db-plugin-ribbon-class');
|
ribbonIconEl.addClass('obsidian-media-db-plugin-ribbon-class');
|
||||||
|
|
||||||
this.registerEvent(this.app.workspace.on('file-menu', (menu, file) => {
|
this.registerEvent(
|
||||||
if (file instanceof TFolder) {
|
this.app.workspace.on('file-menu', (menu, file) => {
|
||||||
menu.addItem(item => {
|
if (file instanceof TFolder) {
|
||||||
item.setTitle('Import folder as Media DB entries')
|
menu.addItem(item => {
|
||||||
.setIcon('database')
|
item.setTitle('Import folder as Media DB entries')
|
||||||
.onClick(() => this.createEntriesFromFolder(file));
|
.setIcon('database')
|
||||||
});
|
.onClick(() => this.createEntriesFromFolder(file));
|
||||||
}
|
});
|
||||||
}));
|
}
|
||||||
|
})
|
||||||
|
);
|
||||||
|
|
||||||
// register command to open search modal
|
// register command to open search modal
|
||||||
this.addCommand({
|
this.addCommand({
|
||||||
|
|
@ -129,8 +129,7 @@ export default class MediaDbPlugin extends Plugin {
|
||||||
* - maybe custom link syntax
|
* - maybe custom link syntax
|
||||||
*/
|
*/
|
||||||
async createLinkWithSearchModal() {
|
async createLinkWithSearchModal() {
|
||||||
|
let apiSearchResults: MediaTypeModel[] = await this.modalHelper.openAdvancedSearchModal({}, async advancedSearchModalData => {
|
||||||
let apiSearchResults: MediaTypeModel[] = await this.modalHelper.openAdvancedSearchModal({}, async (advancedSearchModalData) => {
|
|
||||||
return await this.apiManager.query(advancedSearchModalData.query, advancedSearchModalData.apis);
|
return await this.apiManager.query(advancedSearchModalData.query, advancedSearchModalData.apis);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
@ -138,7 +137,7 @@ export default class MediaDbPlugin extends Plugin {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const selectResults: MediaTypeModel[] = await this.modalHelper.openSelectModal({elements: apiSearchResults, multiSelect: false}, async (selectModalData) => {
|
const selectResults: MediaTypeModel[] = await this.modalHelper.openSelectModal({ elements: apiSearchResults, multiSelect: false }, async selectModalData => {
|
||||||
return await this.queryDetails(selectModalData.selected);
|
return await this.queryDetails(selectModalData.selected);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
@ -158,7 +157,7 @@ export default class MediaDbPlugin extends Plugin {
|
||||||
|
|
||||||
async createEntryWithSearchModal() {
|
async createEntryWithSearchModal() {
|
||||||
let types: string[] = [];
|
let types: string[] = [];
|
||||||
let apiSearchResults: MediaTypeModel[] = await this.modalHelper.openSearchModal({}, async (searchModalData) => {
|
let apiSearchResults: MediaTypeModel[] = await this.modalHelper.openSearchModal({}, async searchModalData => {
|
||||||
types = searchModalData.types;
|
types = searchModalData.types;
|
||||||
const apis = this.apiManager.apis.filter(x => x.hasTypeOverlap(searchModalData.types)).map(x => x.apiName);
|
const apis = this.apiManager.apis.filter(x => x.hasTypeOverlap(searchModalData.types)).map(x => x.apiName);
|
||||||
return await this.apiManager.query(searchModalData.query, apis);
|
return await this.apiManager.query(searchModalData.query, apis);
|
||||||
|
|
@ -176,14 +175,14 @@ export default class MediaDbPlugin extends Plugin {
|
||||||
let proceed: boolean;
|
let proceed: boolean;
|
||||||
|
|
||||||
while (!proceed) {
|
while (!proceed) {
|
||||||
selectResults = await this.modalHelper.openSelectModal({elements: apiSearchResults}, async (selectModalData) => {
|
selectResults = await this.modalHelper.openSelectModal({ elements: apiSearchResults }, async selectModalData => {
|
||||||
return await this.queryDetails(selectModalData.selected);
|
return await this.queryDetails(selectModalData.selected);
|
||||||
});
|
});
|
||||||
if (!selectResults) {
|
if (!selectResults) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
proceed = await this.modalHelper.openPreviewModal({elements: selectResults}, async (previewModalData) => {
|
proceed = await this.modalHelper.openPreviewModal({ elements: selectResults }, async previewModalData => {
|
||||||
return previewModalData.confirmed;
|
return previewModalData.confirmed;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
@ -192,7 +191,7 @@ export default class MediaDbPlugin extends Plugin {
|
||||||
}
|
}
|
||||||
|
|
||||||
async createEntryWithAdvancedSearchModal() {
|
async createEntryWithAdvancedSearchModal() {
|
||||||
let apiSearchResults: MediaTypeModel[] = await this.modalHelper.openAdvancedSearchModal({}, async (advancedSearchModalData) => {
|
let apiSearchResults: MediaTypeModel[] = await this.modalHelper.openAdvancedSearchModal({}, async advancedSearchModalData => {
|
||||||
return await this.apiManager.query(advancedSearchModalData.query, advancedSearchModalData.apis);
|
return await this.apiManager.query(advancedSearchModalData.query, advancedSearchModalData.apis);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
@ -205,14 +204,14 @@ export default class MediaDbPlugin extends Plugin {
|
||||||
let proceed: boolean;
|
let proceed: boolean;
|
||||||
|
|
||||||
while (!proceed) {
|
while (!proceed) {
|
||||||
selectResults = await this.modalHelper.openSelectModal({elements: apiSearchResults}, async (selectModalData) => {
|
selectResults = await this.modalHelper.openSelectModal({ elements: apiSearchResults }, async selectModalData => {
|
||||||
return await this.queryDetails(selectModalData.selected);
|
return await this.queryDetails(selectModalData.selected);
|
||||||
});
|
});
|
||||||
if (!selectResults) {
|
if (!selectResults) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
proceed = await this.modalHelper.openPreviewModal({elements: selectResults}, async (previewModalData) => {
|
proceed = await this.modalHelper.openPreviewModal({ elements: selectResults }, async previewModalData => {
|
||||||
return previewModalData.confirmed;
|
return previewModalData.confirmed;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
@ -225,24 +224,24 @@ export default class MediaDbPlugin extends Plugin {
|
||||||
let proceed: boolean;
|
let proceed: boolean;
|
||||||
|
|
||||||
while (!proceed) {
|
while (!proceed) {
|
||||||
idSearchResult = await this.modalHelper.openIdSearchModal({}, async (idSearchModalData) => {
|
idSearchResult = await this.modalHelper.openIdSearchModal({}, async idSearchModalData => {
|
||||||
return await this.apiManager.queryDetailedInfoById(idSearchModalData.query, idSearchModalData.api);
|
return await this.apiManager.queryDetailedInfoById(idSearchModalData.query, idSearchModalData.api);
|
||||||
});
|
});
|
||||||
if (!idSearchResult) {
|
if (!idSearchResult) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
proceed = await this.modalHelper.openPreviewModal({elements: [idSearchResult]}, async (previewModalData) => {
|
proceed = await this.modalHelper.openPreviewModal({ elements: [idSearchResult] }, async previewModalData => {
|
||||||
return previewModalData.confirmed;
|
return previewModalData.confirmed;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
await this.createMediaDbNoteFromModel(idSearchResult, {attachTemplate: true, openNote: true});
|
await this.createMediaDbNoteFromModel(idSearchResult, { attachTemplate: true, openNote: true });
|
||||||
}
|
}
|
||||||
|
|
||||||
async createMediaDbNotes(models: MediaTypeModel[], attachFile?: TFile): Promise<void> {
|
async createMediaDbNotes(models: MediaTypeModel[], attachFile?: TFile): Promise<void> {
|
||||||
for (const model of models) {
|
for (const model of models) {
|
||||||
await this.createMediaDbNoteFromModel(model, {attachTemplate: true, attachFile: attachFile});
|
await this.createMediaDbNoteFromModel(model, { attachTemplate: true, attachFile: attachFile });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -277,16 +276,16 @@ export default class MediaDbPlugin extends Plugin {
|
||||||
let fileContent = '';
|
let fileContent = '';
|
||||||
const template = options.attachTemplate ? await this.mediaTypeManager.getTemplate(mediaTypeModel, this.app) : '';
|
const template = options.attachTemplate ? await this.mediaTypeManager.getTemplate(mediaTypeModel, this.app) : '';
|
||||||
|
|
||||||
({fileMetadata, fileContent} = await this.attachFile(fileMetadata, fileContent, options.attachFile));
|
({ fileMetadata, fileContent } = await this.attachFile(fileMetadata, fileContent, options.attachFile));
|
||||||
({fileMetadata, fileContent} = await this.attachTemplate(fileMetadata, fileContent, template));
|
({ fileMetadata, fileContent } = await this.attachTemplate(fileMetadata, fileContent, template));
|
||||||
|
|
||||||
fileContent = `---\n${this.settings.useCustomYamlStringifier ? YAMLConverter.toYaml(fileMetadata) : stringifyYaml(fileMetadata)}---\n` + fileContent;
|
fileContent = `---\n${this.settings.useCustomYamlStringifier ? YAMLConverter.toYaml(fileMetadata) : stringifyYaml(fileMetadata)}---\n` + fileContent;
|
||||||
return fileContent;
|
return fileContent;
|
||||||
}
|
}
|
||||||
|
|
||||||
async attachFile(fileMetadata: any, fileContent: string, fileToAttach?: TFile): Promise<{ fileMetadata: any, fileContent: string }> {
|
async attachFile(fileMetadata: any, fileContent: string, fileToAttach?: TFile): Promise<{ fileMetadata: any; fileContent: string }> {
|
||||||
if (!fileToAttach) {
|
if (!fileToAttach) {
|
||||||
return {fileMetadata: fileMetadata, fileContent: fileContent};
|
return { fileMetadata: fileMetadata, fileContent: fileContent };
|
||||||
}
|
}
|
||||||
|
|
||||||
let attachFileMetadata: any = this.getMetadataFromFileCache(fileToAttach);
|
let attachFileMetadata: any = this.getMetadataFromFileCache(fileToAttach);
|
||||||
|
|
@ -298,12 +297,12 @@ export default class MediaDbPlugin extends Plugin {
|
||||||
attachFileContent = attachFileContent.startsWith('\n') ? attachFileContent.substring(1) : attachFileContent;
|
attachFileContent = attachFileContent.startsWith('\n') ? attachFileContent.substring(1) : attachFileContent;
|
||||||
fileContent += attachFileContent;
|
fileContent += attachFileContent;
|
||||||
|
|
||||||
return {fileMetadata: fileMetadata, fileContent: fileContent};
|
return { fileMetadata: fileMetadata, fileContent: fileContent };
|
||||||
}
|
}
|
||||||
|
|
||||||
async attachTemplate(fileMetadata: any, fileContent: string, template: string): Promise<{ fileMetadata: any, fileContent: string }> {
|
async attachTemplate(fileMetadata: any, fileContent: string, template: string): Promise<{ fileMetadata: any; fileContent: string }> {
|
||||||
if (!template) {
|
if (!template) {
|
||||||
return {fileMetadata: fileMetadata, fileContent: fileContent};
|
return { fileMetadata: fileMetadata, fileContent: fileContent };
|
||||||
}
|
}
|
||||||
|
|
||||||
let templateMetadata: any = this.getMetaDataFromFileContent(template);
|
let templateMetadata: any = this.getMetaDataFromFileContent(template);
|
||||||
|
|
@ -313,7 +312,7 @@ export default class MediaDbPlugin extends Plugin {
|
||||||
const attachFileContent = template.replace(regExp, '');
|
const attachFileContent = template.replace(regExp, '');
|
||||||
fileContent += attachFileContent;
|
fileContent += attachFileContent;
|
||||||
|
|
||||||
return {fileMetadata: fileMetadata, fileContent: fileContent};
|
return { fileMetadata: fileMetadata, fileContent: fileContent };
|
||||||
}
|
}
|
||||||
|
|
||||||
getMetaDataFromFileContent(fileContent: string): any {
|
getMetaDataFromFileContent(fileContent: string): any {
|
||||||
|
|
@ -387,7 +386,7 @@ export default class MediaDbPlugin extends Plugin {
|
||||||
console.warn('MDB | no active leaf, not opening newly created note');
|
console.warn('MDB | no active leaf, not opening newly created note');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
await activeLeaf.openFile(targetFile, {state: {mode: 'source'}});
|
await activeLeaf.openFile(targetFile, { state: { mode: 'source' } });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -424,28 +423,27 @@ export default class MediaDbPlugin extends Plugin {
|
||||||
// deletion not happening anymore why is this log statement still here
|
// deletion not happening anymore why is this log statement still here
|
||||||
console.debug('MDB | deleting old entry');
|
console.debug('MDB | deleting old entry');
|
||||||
if (onlyMetadata) {
|
if (onlyMetadata) {
|
||||||
await this.createMediaDbNoteFromModel(newMediaTypeModel, {attachFile: activeFile, folder: activeFile.parent, openNote: true});
|
await this.createMediaDbNoteFromModel(newMediaTypeModel, { attachFile: activeFile, folder: activeFile.parent, openNote: true });
|
||||||
} else {
|
} else {
|
||||||
await this.createMediaDbNoteFromModel(newMediaTypeModel, {attachTemplate: true, folder: activeFile.parent, openNote: true});
|
await this.createMediaDbNoteFromModel(newMediaTypeModel, { attachTemplate: true, folder: activeFile.parent, openNote: true });
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async createEntriesFromFolder(folder: TFolder) {
|
async createEntriesFromFolder(folder: TFolder) {
|
||||||
const erroredFiles: { filePath: string, error: string }[] = [];
|
const erroredFiles: { filePath: string; error: string }[] = [];
|
||||||
let canceled: boolean = false;
|
let canceled: boolean = false;
|
||||||
|
|
||||||
const {selectedAPI, titleFieldName, appendContent} = await new Promise<{ selectedAPI: string, titleFieldName: string, appendContent: boolean }>((resolve, reject) => {
|
const { selectedAPI, titleFieldName, appendContent } = await new Promise<{ selectedAPI: string; titleFieldName: string; appendContent: boolean }>((resolve, reject) => {
|
||||||
new MediaDbFolderImportModal(this.app, this, ((selectedAPI: string, titleFieldName: string, appendContent: boolean) => {
|
new MediaDbFolderImportModal(this.app, this, (selectedAPI: string, titleFieldName: string, appendContent: boolean) => {
|
||||||
resolve({selectedAPI, titleFieldName, appendContent});
|
resolve({ selectedAPI, titleFieldName, appendContent });
|
||||||
})).open();
|
}).open();
|
||||||
});
|
});
|
||||||
|
|
||||||
for (const child of folder.children) {
|
for (const child of folder.children) {
|
||||||
if (child instanceof TFile) {
|
if (child instanceof TFile) {
|
||||||
const file: TFile = child;
|
const file: TFile = child;
|
||||||
if (canceled) {
|
if (canceled) {
|
||||||
erroredFiles.push({filePath: file.path, error: 'user canceled'});
|
erroredFiles.push({ filePath: file.path, error: 'user canceled' });
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -453,7 +451,7 @@ export default class MediaDbPlugin extends Plugin {
|
||||||
|
|
||||||
let title = metadata[titleFieldName];
|
let title = metadata[titleFieldName];
|
||||||
if (!title) {
|
if (!title) {
|
||||||
erroredFiles.push({filePath: file.path, error: `metadata field \'${titleFieldName}\' not found or empty`});
|
erroredFiles.push({ filePath: file.path, error: `metadata field \'${titleFieldName}\' not found or empty` });
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -461,37 +459,37 @@ export default class MediaDbPlugin extends Plugin {
|
||||||
try {
|
try {
|
||||||
results = await this.apiManager.query(title, [selectedAPI]);
|
results = await this.apiManager.query(title, [selectedAPI]);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
erroredFiles.push({filePath: file.path, error: e.toString()});
|
erroredFiles.push({ filePath: file.path, error: e.toString() });
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (!results || results.length === 0) {
|
if (!results || results.length === 0) {
|
||||||
erroredFiles.push({filePath: file.path, error: `no search results`});
|
erroredFiles.push({ filePath: file.path, error: `no search results` });
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
let {selectModalResult, selectModal} = await this.modalHelper.createSelectModal({elements: results, skipButton: true, modalTitle: `Results for \'${title}\'`});
|
let { selectModalResult, selectModal } = await this.modalHelper.createSelectModal({ elements: results, skipButton: true, modalTitle: `Results for \'${title}\'` });
|
||||||
|
|
||||||
if (selectModalResult.code === ModalResultCode.ERROR) {
|
if (selectModalResult.code === ModalResultCode.ERROR) {
|
||||||
erroredFiles.push({filePath: file.path, error: selectModalResult.error.message});
|
erroredFiles.push({ filePath: file.path, error: selectModalResult.error.message });
|
||||||
selectModal.close();
|
selectModal.close();
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (selectModalResult.code === ModalResultCode.CLOSE) {
|
if (selectModalResult.code === ModalResultCode.CLOSE) {
|
||||||
erroredFiles.push({filePath: file.path, error: 'user canceled'});
|
erroredFiles.push({ filePath: file.path, error: 'user canceled' });
|
||||||
selectModal.close();
|
selectModal.close();
|
||||||
canceled = true;
|
canceled = true;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (selectModalResult.code === ModalResultCode.SKIP) {
|
if (selectModalResult.code === ModalResultCode.SKIP) {
|
||||||
erroredFiles.push({filePath: file.path, error: 'user skipped'});
|
erroredFiles.push({ filePath: file.path, error: 'user skipped' });
|
||||||
selectModal.close();
|
selectModal.close();
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (selectModalResult.data.selected.length === 0) {
|
if (selectModalResult.data.selected.length === 0) {
|
||||||
erroredFiles.push({filePath: file.path, error: `no search results selected`});
|
erroredFiles.push({ filePath: file.path, error: `no search results selected` });
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -507,7 +505,7 @@ export default class MediaDbPlugin extends Plugin {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async createErroredFilesReport(erroredFiles: { filePath: string, error: string }[]): Promise<void> {
|
async createErroredFilesReport(erroredFiles: { filePath: string; error: string }[]): Promise<void> {
|
||||||
const title = `bulk import error report ${dateTimeToString(new Date())}`;
|
const title = `bulk import error report ${dateTimeToString(new Date())}`;
|
||||||
const filePath = `${this.settings.folder.replace(/\/$/, '')}/${title}.md`;
|
const filePath = `${this.settings.folder.replace(/\/$/, '')}/${title}.md`;
|
||||||
|
|
||||||
|
|
@ -528,9 +526,11 @@ export default class MediaDbPlugin extends Plugin {
|
||||||
let newPropertyMappings: PropertyMappingModel[] = [];
|
let newPropertyMappings: PropertyMappingModel[] = [];
|
||||||
for (const defaultPropertyMappingModel of defaultSettings.propertyMappingModels) {
|
for (const defaultPropertyMappingModel of defaultSettings.propertyMappingModels) {
|
||||||
let newPropertyMappingModel: PropertyMappingModel = loadedSettings.propertyMappingModels.find(x => x.type === defaultPropertyMappingModel.type);
|
let newPropertyMappingModel: PropertyMappingModel = loadedSettings.propertyMappingModels.find(x => x.type === defaultPropertyMappingModel.type);
|
||||||
if (newPropertyMappingModel === undefined) { // if the propertyMappingModel exists in the default settings but not the loaded settings, add it
|
if (newPropertyMappingModel === undefined) {
|
||||||
|
// if the propertyMappingModel exists in the default settings but not the loaded settings, add it
|
||||||
newPropertyMappings.push(defaultPropertyMappingModel);
|
newPropertyMappings.push(defaultPropertyMappingModel);
|
||||||
} else { // if the propertyMappingModel also exists in the loaded settings, add it from there
|
} else {
|
||||||
|
// if the propertyMappingModel also exists in the loaded settings, add it from there
|
||||||
let newProperties: PropertyMapping[] = [];
|
let newProperties: PropertyMapping[] = [];
|
||||||
|
|
||||||
for (const defaultProperty of defaultPropertyMappingModel.properties) {
|
for (const defaultProperty of defaultPropertyMappingModel.properties) {
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
import {ButtonComponent, Modal, Notice, Setting, TextComponent, ToggleComponent} from 'obsidian';
|
import { ButtonComponent, Modal, Notice, Setting, TextComponent, ToggleComponent } from 'obsidian';
|
||||||
import {MediaTypeModel} from '../models/MediaTypeModel';
|
import { MediaTypeModel } from '../models/MediaTypeModel';
|
||||||
import MediaDbPlugin from '../main';
|
import MediaDbPlugin from '../main';
|
||||||
import {ADVANCED_SEARCH_MODAL_DEFAULT_OPTIONS, AdvancedSearchModalData, AdvancedSearchModalOptions} from '../utils/ModalHelper';
|
import { ADVANCED_SEARCH_MODAL_DEFAULT_OPTIONS, AdvancedSearchModalData, AdvancedSearchModalOptions } from '../utils/ModalHelper';
|
||||||
|
|
||||||
export class MediaDbAdvancedSearchModal extends Modal {
|
export class MediaDbAdvancedSearchModal extends Modal {
|
||||||
plugin: MediaDbPlugin;
|
plugin: MediaDbPlugin;
|
||||||
|
|
@ -9,14 +9,13 @@ export class MediaDbAdvancedSearchModal extends Modal {
|
||||||
query: string;
|
query: string;
|
||||||
isBusy: boolean;
|
isBusy: boolean;
|
||||||
title: string;
|
title: string;
|
||||||
selectedApis: { name: string, selected: boolean }[];
|
selectedApis: { name: string; selected: boolean }[];
|
||||||
|
|
||||||
searchBtn: ButtonComponent;
|
searchBtn: ButtonComponent;
|
||||||
|
|
||||||
submitCallback?: (res: AdvancedSearchModalData) => void;
|
submitCallback?: (res: AdvancedSearchModalData) => void;
|
||||||
closeCallback?: (err?: Error) => void;
|
closeCallback?: (err?: Error) => void;
|
||||||
|
|
||||||
|
|
||||||
constructor(plugin: MediaDbPlugin, advancedSearchModalOptions: AdvancedSearchModalOptions) {
|
constructor(plugin: MediaDbPlugin, advancedSearchModalOptions: AdvancedSearchModalOptions) {
|
||||||
advancedSearchModalOptions = Object.assign({}, ADVANCED_SEARCH_MODAL_DEFAULT_OPTIONS, advancedSearchModalOptions);
|
advancedSearchModalOptions = Object.assign({}, ADVANCED_SEARCH_MODAL_DEFAULT_OPTIONS, advancedSearchModalOptions);
|
||||||
super(plugin.app);
|
super(plugin.app);
|
||||||
|
|
@ -27,7 +26,7 @@ export class MediaDbAdvancedSearchModal extends Modal {
|
||||||
this.query = advancedSearchModalOptions.prefilledSearchString;
|
this.query = advancedSearchModalOptions.prefilledSearchString;
|
||||||
|
|
||||||
for (const api of this.plugin.apiManager.apis) {
|
for (const api of this.plugin.apiManager.apis) {
|
||||||
this.selectedApis.push({name: api.apiName, selected: advancedSearchModalOptions.preselectedAPIs.contains(api.apiName)});
|
this.selectedApis.push({ name: api.apiName, selected: advancedSearchModalOptions.preselectedAPIs.contains(api.apiName) });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -63,14 +62,14 @@ export class MediaDbAdvancedSearchModal extends Modal {
|
||||||
this.searchBtn.setDisabled(false);
|
this.searchBtn.setDisabled(false);
|
||||||
this.searchBtn.setButtonText('Searching...');
|
this.searchBtn.setButtonText('Searching...');
|
||||||
|
|
||||||
this.submitCallback({query: this.query, apis: apis});
|
this.submitCallback({ query: this.query, apis: apis });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
onOpen() {
|
onOpen() {
|
||||||
const {contentEl} = this;
|
const { contentEl } = this;
|
||||||
|
|
||||||
contentEl.createEl('h2', {text: this.title});
|
contentEl.createEl('h2', { text: this.title });
|
||||||
|
|
||||||
const placeholder = 'Search by title';
|
const placeholder = 'Search by title';
|
||||||
const searchComponent = new TextComponent(contentEl);
|
const searchComponent = new TextComponent(contentEl);
|
||||||
|
|
@ -83,29 +82,29 @@ export class MediaDbAdvancedSearchModal extends Modal {
|
||||||
contentEl.appendChild(searchComponent.inputEl);
|
contentEl.appendChild(searchComponent.inputEl);
|
||||||
searchComponent.inputEl.focus();
|
searchComponent.inputEl.focus();
|
||||||
|
|
||||||
contentEl.createDiv({cls: 'media-db-plugin-spacer'});
|
contentEl.createDiv({ cls: 'media-db-plugin-spacer' });
|
||||||
contentEl.createEl('h3', {text: 'APIs to search'});
|
contentEl.createEl('h3', { text: 'APIs to search' });
|
||||||
|
|
||||||
// const apiToggleComponents: Component[] = [];
|
// const apiToggleComponents: Component[] = [];
|
||||||
for (const api of this.plugin.apiManager.apis) {
|
for (const api of this.plugin.apiManager.apis) {
|
||||||
const apiToggleListElementWrapper = contentEl.createEl('div', {cls: 'media-db-plugin-list-wrapper'});
|
const apiToggleListElementWrapper = contentEl.createEl('div', { cls: 'media-db-plugin-list-wrapper' });
|
||||||
|
|
||||||
const apiToggleTextWrapper = apiToggleListElementWrapper.createEl('div', {cls: 'media-db-plugin-list-text-wrapper'});
|
const apiToggleTextWrapper = apiToggleListElementWrapper.createEl('div', { cls: 'media-db-plugin-list-text-wrapper' });
|
||||||
apiToggleTextWrapper.createEl('span', {text: api.apiName, cls: 'media-db-plugin-list-text'});
|
apiToggleTextWrapper.createEl('span', { text: api.apiName, cls: 'media-db-plugin-list-text' });
|
||||||
apiToggleTextWrapper.createEl('small', {text: api.apiDescription, cls: 'media-db-plugin-list-text'});
|
apiToggleTextWrapper.createEl('small', { text: api.apiDescription, cls: 'media-db-plugin-list-text' });
|
||||||
|
|
||||||
const apiToggleComponentWrapper = apiToggleListElementWrapper.createEl('div', {cls: 'media-db-plugin-list-toggle'});
|
const apiToggleComponentWrapper = apiToggleListElementWrapper.createEl('div', { cls: 'media-db-plugin-list-toggle' });
|
||||||
|
|
||||||
const apiToggleComponent = new ToggleComponent(apiToggleComponentWrapper);
|
const apiToggleComponent = new ToggleComponent(apiToggleComponentWrapper);
|
||||||
apiToggleComponent.setTooltip(api.apiName);
|
apiToggleComponent.setTooltip(api.apiName);
|
||||||
apiToggleComponent.setValue(this.selectedApis.find(x => x.name === api.apiName).selected);
|
apiToggleComponent.setValue(this.selectedApis.find(x => x.name === api.apiName).selected);
|
||||||
apiToggleComponent.onChange((value) => {
|
apiToggleComponent.onChange(value => {
|
||||||
this.selectedApis.find(x => x.name === api.apiName).selected = value;
|
this.selectedApis.find(x => x.name === api.apiName).selected = value;
|
||||||
});
|
});
|
||||||
apiToggleComponentWrapper.appendChild(apiToggleComponent.toggleEl);
|
apiToggleComponentWrapper.appendChild(apiToggleComponent.toggleEl);
|
||||||
}
|
}
|
||||||
|
|
||||||
contentEl.createDiv({cls: 'media-db-plugin-spacer'});
|
contentEl.createDiv({ cls: 'media-db-plugin-spacer' });
|
||||||
|
|
||||||
new Setting(contentEl)
|
new Setting(contentEl)
|
||||||
.addButton(btn => {
|
.addButton(btn => {
|
||||||
|
|
@ -126,8 +125,7 @@ export class MediaDbAdvancedSearchModal extends Modal {
|
||||||
|
|
||||||
onClose() {
|
onClose() {
|
||||||
this.closeCallback();
|
this.closeCallback();
|
||||||
const {contentEl} = this;
|
const { contentEl } = this;
|
||||||
contentEl.empty();
|
contentEl.empty();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
import {App, ButtonComponent, DropdownComponent, Modal, Setting, TextComponent, ToggleComponent} from 'obsidian';
|
import { App, ButtonComponent, DropdownComponent, Modal, Setting, TextComponent, ToggleComponent } from 'obsidian';
|
||||||
import MediaDbPlugin from '../main';
|
import MediaDbPlugin from '../main';
|
||||||
|
|
||||||
export class MediaDbFolderImportModal extends Modal {
|
export class MediaDbFolderImportModal extends Modal {
|
||||||
|
|
@ -22,13 +22,13 @@ export class MediaDbFolderImportModal extends Modal {
|
||||||
}
|
}
|
||||||
|
|
||||||
onOpen() {
|
onOpen() {
|
||||||
const {contentEl} = this;
|
const { contentEl } = this;
|
||||||
|
|
||||||
contentEl.createEl('h2', {text: 'Import folder as Media DB entries'});
|
contentEl.createEl('h2', { text: 'Import folder as Media DB entries' });
|
||||||
|
|
||||||
const apiSelectorWrapper = contentEl.createEl('div', {cls: 'media-db-plugin-list-wrapper'});
|
const apiSelectorWrapper = contentEl.createEl('div', { cls: 'media-db-plugin-list-wrapper' });
|
||||||
const apiSelectorTextWrapper = apiSelectorWrapper.createEl('div', {cls: 'media-db-plugin-list-text-wrapper'});
|
const apiSelectorTextWrapper = apiSelectorWrapper.createEl('div', { cls: 'media-db-plugin-list-text-wrapper' });
|
||||||
apiSelectorTextWrapper.createEl('span', {text: 'API to search', cls: 'media-db-plugin-list-text'});
|
apiSelectorTextWrapper.createEl('span', { text: 'API to search', cls: 'media-db-plugin-list-text' });
|
||||||
|
|
||||||
const apiSelectorComponent = new DropdownComponent(apiSelectorWrapper);
|
const apiSelectorComponent = new DropdownComponent(apiSelectorWrapper);
|
||||||
apiSelectorComponent.onChange((value: string) => {
|
apiSelectorComponent.onChange((value: string) => {
|
||||||
|
|
@ -39,41 +39,39 @@ export class MediaDbFolderImportModal extends Modal {
|
||||||
}
|
}
|
||||||
apiSelectorWrapper.appendChild(apiSelectorComponent.selectEl);
|
apiSelectorWrapper.appendChild(apiSelectorComponent.selectEl);
|
||||||
|
|
||||||
|
contentEl.createDiv({ cls: 'media-db-plugin-spacer' });
|
||||||
|
contentEl.createEl('h3', { text: 'Append note content to Media DB entry.' });
|
||||||
|
|
||||||
contentEl.createDiv({cls: 'media-db-plugin-spacer'});
|
const appendContentToggleElementWrapper = contentEl.createEl('div', { cls: 'media-db-plugin-list-wrapper' });
|
||||||
contentEl.createEl('h3', {text: 'Append note content to Media DB entry.'});
|
const appendContentToggleTextWrapper = appendContentToggleElementWrapper.createEl('div', { cls: 'media-db-plugin-list-text-wrapper' });
|
||||||
|
|
||||||
const appendContentToggleElementWrapper = contentEl.createEl('div', {cls: 'media-db-plugin-list-wrapper'});
|
|
||||||
const appendContentToggleTextWrapper = appendContentToggleElementWrapper.createEl('div', {cls: 'media-db-plugin-list-text-wrapper'});
|
|
||||||
appendContentToggleTextWrapper.createEl('span', {
|
appendContentToggleTextWrapper.createEl('span', {
|
||||||
text: 'If this is enabled, the plugin will override metadata fields with the same name.',
|
text: 'If this is enabled, the plugin will override metadata fields with the same name.',
|
||||||
cls: 'media-db-plugin-list-text',
|
cls: 'media-db-plugin-list-text',
|
||||||
});
|
});
|
||||||
|
|
||||||
const appendContentToggleComponentWrapper = appendContentToggleElementWrapper.createEl('div', {cls: 'media-db-plugin-list-toggle'});
|
const appendContentToggleComponentWrapper = appendContentToggleElementWrapper.createEl('div', { cls: 'media-db-plugin-list-toggle' });
|
||||||
|
|
||||||
const appendContentToggle = new ToggleComponent(appendContentToggleElementWrapper);
|
const appendContentToggle = new ToggleComponent(appendContentToggleElementWrapper);
|
||||||
appendContentToggle.setValue(false);
|
appendContentToggle.setValue(false);
|
||||||
appendContentToggle.onChange(value => this.appendContent = value);
|
appendContentToggle.onChange(value => (this.appendContent = value));
|
||||||
appendContentToggleComponentWrapper.appendChild(appendContentToggle.toggleEl);
|
appendContentToggleComponentWrapper.appendChild(appendContentToggle.toggleEl);
|
||||||
|
|
||||||
|
contentEl.createDiv({ cls: 'media-db-plugin-spacer' });
|
||||||
contentEl.createDiv({cls: 'media-db-plugin-spacer'});
|
contentEl.createEl('h3', { text: 'The name of the metadata field that should be used as the title to query.' });
|
||||||
contentEl.createEl('h3', {text: 'The name of the metadata field that should be used as the title to query.'});
|
|
||||||
|
|
||||||
const placeholder = 'title';
|
const placeholder = 'title';
|
||||||
const titleFieldNameComponent = new TextComponent(contentEl);
|
const titleFieldNameComponent = new TextComponent(contentEl);
|
||||||
titleFieldNameComponent.inputEl.style.width = '100%';
|
titleFieldNameComponent.inputEl.style.width = '100%';
|
||||||
titleFieldNameComponent.setPlaceholder(placeholder);
|
titleFieldNameComponent.setPlaceholder(placeholder);
|
||||||
titleFieldNameComponent.onChange(value => this.titleFieldName = value);
|
titleFieldNameComponent.onChange(value => (this.titleFieldName = value));
|
||||||
titleFieldNameComponent.inputEl.addEventListener('keydown', (ke) => {
|
titleFieldNameComponent.inputEl.addEventListener('keydown', ke => {
|
||||||
if (ke.key === 'Enter') {
|
if (ke.key === 'Enter') {
|
||||||
this.submit();
|
this.submit();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
contentEl.appendChild(titleFieldNameComponent.inputEl);
|
contentEl.appendChild(titleFieldNameComponent.inputEl);
|
||||||
|
|
||||||
contentEl.createDiv({cls: 'media-db-plugin-spacer'});
|
contentEl.createDiv({ cls: 'media-db-plugin-spacer' });
|
||||||
|
|
||||||
new Setting(contentEl)
|
new Setting(contentEl)
|
||||||
.addButton(btn => {
|
.addButton(btn => {
|
||||||
|
|
@ -93,7 +91,7 @@ export class MediaDbFolderImportModal extends Modal {
|
||||||
}
|
}
|
||||||
|
|
||||||
onClose() {
|
onClose() {
|
||||||
const {contentEl} = this;
|
const { contentEl } = this;
|
||||||
contentEl.empty();
|
contentEl.empty();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
import {ButtonComponent, DropdownComponent, Modal, Notice, Setting, TextComponent} from 'obsidian';
|
import { ButtonComponent, DropdownComponent, Modal, Notice, Setting, TextComponent } from 'obsidian';
|
||||||
import {MediaTypeModel} from '../models/MediaTypeModel';
|
import { MediaTypeModel } from '../models/MediaTypeModel';
|
||||||
import MediaDbPlugin from '../main';
|
import MediaDbPlugin from '../main';
|
||||||
import {ID_SEARCH_MODAL_DEFAULT_OPTIONS, IdSearchModalData, IdSearchModalOptions} from '../utils/ModalHelper';
|
import { ID_SEARCH_MODAL_DEFAULT_OPTIONS, IdSearchModalData, IdSearchModalOptions } from '../utils/ModalHelper';
|
||||||
|
|
||||||
export class MediaDbIdSearchModal extends Modal {
|
export class MediaDbIdSearchModal extends Modal {
|
||||||
plugin: MediaDbPlugin;
|
plugin: MediaDbPlugin;
|
||||||
|
|
@ -16,7 +16,6 @@ export class MediaDbIdSearchModal extends Modal {
|
||||||
submitCallback?: (res: IdSearchModalData, err?: Error) => void;
|
submitCallback?: (res: IdSearchModalData, err?: Error) => void;
|
||||||
closeCallback?: (err?: Error) => void;
|
closeCallback?: (err?: Error) => void;
|
||||||
|
|
||||||
|
|
||||||
constructor(plugin: MediaDbPlugin, idSearchModalOptions: IdSearchModalOptions) {
|
constructor(plugin: MediaDbPlugin, idSearchModalOptions: IdSearchModalOptions) {
|
||||||
idSearchModalOptions = Object.assign({}, ID_SEARCH_MODAL_DEFAULT_OPTIONS, idSearchModalOptions);
|
idSearchModalOptions = Object.assign({}, ID_SEARCH_MODAL_DEFAULT_OPTIONS, idSearchModalOptions);
|
||||||
super(plugin.app);
|
super(plugin.app);
|
||||||
|
|
@ -56,14 +55,14 @@ export class MediaDbIdSearchModal extends Modal {
|
||||||
this.searchBtn.setDisabled(false);
|
this.searchBtn.setDisabled(false);
|
||||||
this.searchBtn.setButtonText('Searching...');
|
this.searchBtn.setButtonText('Searching...');
|
||||||
|
|
||||||
this.submitCallback({query: this.query, api: this.selectedApi});
|
this.submitCallback({ query: this.query, api: this.selectedApi });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
onOpen() {
|
onOpen() {
|
||||||
const {contentEl} = this;
|
const { contentEl } = this;
|
||||||
|
|
||||||
contentEl.createEl('h2', {text: this.title});
|
contentEl.createEl('h2', { text: this.title });
|
||||||
|
|
||||||
const placeholder = 'Search by id';
|
const placeholder = 'Search by id';
|
||||||
const searchComponent = new TextComponent(contentEl);
|
const searchComponent = new TextComponent(contentEl);
|
||||||
|
|
@ -75,11 +74,11 @@ export class MediaDbIdSearchModal extends Modal {
|
||||||
contentEl.appendChild(searchComponent.inputEl);
|
contentEl.appendChild(searchComponent.inputEl);
|
||||||
searchComponent.inputEl.focus();
|
searchComponent.inputEl.focus();
|
||||||
|
|
||||||
contentEl.createDiv({cls: 'media-db-plugin-spacer'});
|
contentEl.createDiv({ cls: 'media-db-plugin-spacer' });
|
||||||
|
|
||||||
const apiSelectorWrapper = contentEl.createEl('div', {cls: 'media-db-plugin-list-wrapper'});
|
const apiSelectorWrapper = contentEl.createEl('div', { cls: 'media-db-plugin-list-wrapper' });
|
||||||
const apiSelectorTExtWrapper = apiSelectorWrapper.createEl('div', {cls: 'media-db-plugin-list-text-wrapper'});
|
const apiSelectorTExtWrapper = apiSelectorWrapper.createEl('div', { cls: 'media-db-plugin-list-text-wrapper' });
|
||||||
apiSelectorTExtWrapper.createEl('span', {text: 'API to search', cls: 'media-db-plugin-list-text'});
|
apiSelectorTExtWrapper.createEl('span', { text: 'API to search', cls: 'media-db-plugin-list-text' });
|
||||||
|
|
||||||
const apiSelectorComponent = new DropdownComponent(apiSelectorWrapper);
|
const apiSelectorComponent = new DropdownComponent(apiSelectorWrapper);
|
||||||
apiSelectorComponent.onChange((value: string) => {
|
apiSelectorComponent.onChange((value: string) => {
|
||||||
|
|
@ -90,7 +89,7 @@ export class MediaDbIdSearchModal extends Modal {
|
||||||
}
|
}
|
||||||
apiSelectorWrapper.appendChild(apiSelectorComponent.selectEl);
|
apiSelectorWrapper.appendChild(apiSelectorComponent.selectEl);
|
||||||
|
|
||||||
contentEl.createDiv({cls: 'media-db-plugin-spacer'});
|
contentEl.createDiv({ cls: 'media-db-plugin-spacer' });
|
||||||
|
|
||||||
new Setting(contentEl)
|
new Setting(contentEl)
|
||||||
.addButton(btn => {
|
.addButton(btn => {
|
||||||
|
|
@ -111,8 +110,7 @@ export class MediaDbIdSearchModal extends Modal {
|
||||||
|
|
||||||
onClose() {
|
onClose() {
|
||||||
this.closeCallback();
|
this.closeCallback();
|
||||||
const {contentEl} = this;
|
const { contentEl } = this;
|
||||||
contentEl.empty();
|
contentEl.empty();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,8 @@
|
||||||
import {ButtonComponent, MarkdownRenderer, Modal, Setting} from 'obsidian';
|
import { ButtonComponent, MarkdownRenderer, Modal, Setting } from 'obsidian';
|
||||||
import MediaDbPlugin from 'src/main';
|
import MediaDbPlugin from 'src/main';
|
||||||
import {MediaTypeModel} from 'src/models/MediaTypeModel';
|
import { MediaTypeModel } from 'src/models/MediaTypeModel';
|
||||||
import {PREVIEW_MODAL_DEFAULT_OPTIONS, PreviewModalData, PreviewModalOptions} from '../utils/ModalHelper';
|
import { PREVIEW_MODAL_DEFAULT_OPTIONS, PreviewModalData, PreviewModalOptions } from '../utils/ModalHelper';
|
||||||
import {CreateNoteOptions} from '../utils/Utils';
|
import { CreateNoteOptions } from '../utils/Utils';
|
||||||
|
|
||||||
export class MediaDbPreviewModal extends Modal {
|
export class MediaDbPreviewModal extends Modal {
|
||||||
plugin: MediaDbPlugin;
|
plugin: MediaDbPlugin;
|
||||||
|
|
@ -37,15 +37,15 @@ export class MediaDbPreviewModal extends Modal {
|
||||||
}
|
}
|
||||||
|
|
||||||
async preview(): Promise<void> {
|
async preview(): Promise<void> {
|
||||||
let {contentEl} = this;
|
let { contentEl } = this;
|
||||||
contentEl.addClass('media-db-plugin-preview-modal');
|
contentEl.addClass('media-db-plugin-preview-modal');
|
||||||
|
|
||||||
contentEl.createEl('h2', {text: this.title});
|
contentEl.createEl('h2', { text: this.title });
|
||||||
|
|
||||||
const previewWrapper = contentEl.createDiv({cls: 'media-db-plugin-preview-wrapper'});
|
const previewWrapper = contentEl.createDiv({ cls: 'media-db-plugin-preview-wrapper' });
|
||||||
|
|
||||||
for (let result of this.elements) {
|
for (let result of this.elements) {
|
||||||
previewWrapper.createEl('h3', {text: result.englishTitle});
|
previewWrapper.createEl('h3', { text: result.englishTitle });
|
||||||
const fileDiv = previewWrapper.createDiv();
|
const fileDiv = previewWrapper.createDiv();
|
||||||
|
|
||||||
let fileContent = await this.plugin.generateMediaDbNoteContents(result, this.createNoteOptions);
|
let fileContent = await this.plugin.generateMediaDbNoteContents(result, this.createNoteOptions);
|
||||||
|
|
@ -54,7 +54,7 @@ export class MediaDbPreviewModal extends Modal {
|
||||||
MarkdownRenderer.renderMarkdown(fileContent, fileDiv, null, null);
|
MarkdownRenderer.renderMarkdown(fileContent, fileDiv, null, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
contentEl.createDiv({cls: 'media-db-plugin-spacer'});
|
contentEl.createDiv({ cls: 'media-db-plugin-spacer' });
|
||||||
|
|
||||||
const bottomSettingRow = new Setting(contentEl);
|
const bottomSettingRow = new Setting(contentEl);
|
||||||
bottomSettingRow.addButton(btn => {
|
bottomSettingRow.addButton(btn => {
|
||||||
|
|
@ -66,7 +66,7 @@ export class MediaDbPreviewModal extends Modal {
|
||||||
bottomSettingRow.addButton(btn => {
|
bottomSettingRow.addButton(btn => {
|
||||||
btn.setButtonText('Ok');
|
btn.setButtonText('Ok');
|
||||||
btn.setCta();
|
btn.setCta();
|
||||||
btn.onClick(() => this.submitCallback({confirmed: true}));
|
btn.onClick(() => this.submitCallback({ confirmed: true }));
|
||||||
btn.buttonEl.addClass('media-db-plugin-button');
|
btn.buttonEl.addClass('media-db-plugin-button');
|
||||||
this.submitButton = btn;
|
this.submitButton = btn;
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
import {ButtonComponent, Modal, Notice, Setting, TextComponent, ToggleComponent} from 'obsidian';
|
import { ButtonComponent, Modal, Notice, Setting, TextComponent, ToggleComponent } from 'obsidian';
|
||||||
import {MediaTypeModel} from '../models/MediaTypeModel';
|
import { MediaTypeModel } from '../models/MediaTypeModel';
|
||||||
import MediaDbPlugin from '../main';
|
import MediaDbPlugin from '../main';
|
||||||
import {
|
import {
|
||||||
ADVANCED_SEARCH_MODAL_DEFAULT_OPTIONS,
|
ADVANCED_SEARCH_MODAL_DEFAULT_OPTIONS,
|
||||||
|
|
@ -9,8 +9,8 @@ import {
|
||||||
SearchModalData,
|
SearchModalData,
|
||||||
SearchModalOptions,
|
SearchModalOptions,
|
||||||
} from '../utils/ModalHelper';
|
} from '../utils/ModalHelper';
|
||||||
import {MEDIA_TYPES} from '../utils/MediaTypeManager';
|
import { MEDIA_TYPES } from '../utils/MediaTypeManager';
|
||||||
import {unCamelCase} from '../utils/Utils';
|
import { unCamelCase } from '../utils/Utils';
|
||||||
|
|
||||||
export class MediaDbSearchModal extends Modal {
|
export class MediaDbSearchModal extends Modal {
|
||||||
plugin: MediaDbPlugin;
|
plugin: MediaDbPlugin;
|
||||||
|
|
@ -18,14 +18,13 @@ export class MediaDbSearchModal extends Modal {
|
||||||
query: string;
|
query: string;
|
||||||
isBusy: boolean;
|
isBusy: boolean;
|
||||||
title: string;
|
title: string;
|
||||||
selectedTypes: { name: string, selected: boolean }[];
|
selectedTypes: { name: string; selected: boolean }[];
|
||||||
|
|
||||||
searchBtn: ButtonComponent;
|
searchBtn: ButtonComponent;
|
||||||
|
|
||||||
submitCallback?: (res: SearchModalData) => void;
|
submitCallback?: (res: SearchModalData) => void;
|
||||||
closeCallback?: (err?: Error) => void;
|
closeCallback?: (err?: Error) => void;
|
||||||
|
|
||||||
|
|
||||||
constructor(plugin: MediaDbPlugin, searchModalOptions: SearchModalOptions) {
|
constructor(plugin: MediaDbPlugin, searchModalOptions: SearchModalOptions) {
|
||||||
searchModalOptions = Object.assign({}, SEARCH_MODAL_DEFAULT_OPTIONS, searchModalOptions);
|
searchModalOptions = Object.assign({}, SEARCH_MODAL_DEFAULT_OPTIONS, searchModalOptions);
|
||||||
super(plugin.app);
|
super(plugin.app);
|
||||||
|
|
@ -36,7 +35,7 @@ export class MediaDbSearchModal extends Modal {
|
||||||
this.query = searchModalOptions.prefilledSearchString;
|
this.query = searchModalOptions.prefilledSearchString;
|
||||||
|
|
||||||
for (const mediaType of MEDIA_TYPES) {
|
for (const mediaType of MEDIA_TYPES) {
|
||||||
this.selectedTypes.push({name: mediaType, selected: searchModalOptions.preselectedTypes.contains(mediaType)});
|
this.selectedTypes.push({ name: mediaType, selected: searchModalOptions.preselectedTypes.contains(mediaType) });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -72,14 +71,14 @@ export class MediaDbSearchModal extends Modal {
|
||||||
this.searchBtn.setDisabled(false);
|
this.searchBtn.setDisabled(false);
|
||||||
this.searchBtn.setButtonText('Searching...');
|
this.searchBtn.setButtonText('Searching...');
|
||||||
|
|
||||||
this.submitCallback({query: this.query, types: types});
|
this.submitCallback({ query: this.query, types: types });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
onOpen() {
|
onOpen() {
|
||||||
const {contentEl} = this;
|
const { contentEl } = this;
|
||||||
|
|
||||||
contentEl.createEl('h2', {text: this.title});
|
contentEl.createEl('h2', { text: this.title });
|
||||||
|
|
||||||
const placeholder = 'Search by title';
|
const placeholder = 'Search by title';
|
||||||
const searchComponent = new TextComponent(contentEl);
|
const searchComponent = new TextComponent(contentEl);
|
||||||
|
|
@ -92,27 +91,27 @@ export class MediaDbSearchModal extends Modal {
|
||||||
contentEl.appendChild(searchComponent.inputEl);
|
contentEl.appendChild(searchComponent.inputEl);
|
||||||
searchComponent.inputEl.focus();
|
searchComponent.inputEl.focus();
|
||||||
|
|
||||||
contentEl.createDiv({cls: 'media-db-plugin-spacer'});
|
contentEl.createDiv({ cls: 'media-db-plugin-spacer' });
|
||||||
contentEl.createEl('h3', {text: 'APIs to search'});
|
contentEl.createEl('h3', { text: 'APIs to search' });
|
||||||
|
|
||||||
for (const mediaType of MEDIA_TYPES) {
|
for (const mediaType of MEDIA_TYPES) {
|
||||||
const apiToggleListElementWrapper = contentEl.createEl('div', {cls: 'media-db-plugin-list-wrapper'});
|
const apiToggleListElementWrapper = contentEl.createEl('div', { cls: 'media-db-plugin-list-wrapper' });
|
||||||
|
|
||||||
const apiToggleTextWrapper = apiToggleListElementWrapper.createEl('div', {cls: 'media-db-plugin-list-text-wrapper'});
|
const apiToggleTextWrapper = apiToggleListElementWrapper.createEl('div', { cls: 'media-db-plugin-list-text-wrapper' });
|
||||||
apiToggleTextWrapper.createEl('span', {text: unCamelCase(mediaType), cls: 'media-db-plugin-list-text'});
|
apiToggleTextWrapper.createEl('span', { text: unCamelCase(mediaType), cls: 'media-db-plugin-list-text' });
|
||||||
|
|
||||||
const apiToggleComponentWrapper = apiToggleListElementWrapper.createEl('div', {cls: 'media-db-plugin-list-toggle'});
|
const apiToggleComponentWrapper = apiToggleListElementWrapper.createEl('div', { cls: 'media-db-plugin-list-toggle' });
|
||||||
|
|
||||||
const apiToggleComponent = new ToggleComponent(apiToggleComponentWrapper);
|
const apiToggleComponent = new ToggleComponent(apiToggleComponentWrapper);
|
||||||
apiToggleComponent.setTooltip(unCamelCase(mediaType));
|
apiToggleComponent.setTooltip(unCamelCase(mediaType));
|
||||||
apiToggleComponent.setValue(this.selectedTypes.find(x => x.name === mediaType).selected);
|
apiToggleComponent.setValue(this.selectedTypes.find(x => x.name === mediaType).selected);
|
||||||
apiToggleComponent.onChange((value) => {
|
apiToggleComponent.onChange(value => {
|
||||||
this.selectedTypes.find(x => x.name === mediaType).selected = value;
|
this.selectedTypes.find(x => x.name === mediaType).selected = value;
|
||||||
});
|
});
|
||||||
apiToggleComponentWrapper.appendChild(apiToggleComponent.toggleEl);
|
apiToggleComponentWrapper.appendChild(apiToggleComponent.toggleEl);
|
||||||
}
|
}
|
||||||
|
|
||||||
contentEl.createDiv({cls: 'media-db-plugin-spacer'});
|
contentEl.createDiv({ cls: 'media-db-plugin-spacer' });
|
||||||
|
|
||||||
new Setting(contentEl)
|
new Setting(contentEl)
|
||||||
.addButton(btn => {
|
.addButton(btn => {
|
||||||
|
|
@ -133,8 +132,7 @@ export class MediaDbSearchModal extends Modal {
|
||||||
|
|
||||||
onClose() {
|
onClose() {
|
||||||
this.closeCallback();
|
this.closeCallback();
|
||||||
const {contentEl} = this;
|
const { contentEl } = this;
|
||||||
contentEl.empty();
|
contentEl.empty();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
import {MediaTypeModel} from '../models/MediaTypeModel';
|
import { MediaTypeModel } from '../models/MediaTypeModel';
|
||||||
import MediaDbPlugin from '../main';
|
import MediaDbPlugin from '../main';
|
||||||
import {SelectModal} from './SelectModal';
|
import { SelectModal } from './SelectModal';
|
||||||
import {SELECT_MODAL_OPTIONS_DEFAULT, SelectModalData, SelectModalOptions} from '../utils/ModalHelper';
|
import { SELECT_MODAL_OPTIONS_DEFAULT, SelectModalData, SelectModalOptions } from '../utils/ModalHelper';
|
||||||
|
|
||||||
export class MediaDbSearchResultModal extends SelectModal<MediaTypeModel> {
|
export class MediaDbSearchResultModal extends SelectModal<MediaTypeModel> {
|
||||||
plugin: MediaDbPlugin;
|
plugin: MediaDbPlugin;
|
||||||
|
|
@ -13,7 +13,6 @@ export class MediaDbSearchResultModal extends SelectModal<MediaTypeModel> {
|
||||||
closeCallback: (err?: Error) => void;
|
closeCallback: (err?: Error) => void;
|
||||||
skipCallback: () => void;
|
skipCallback: () => void;
|
||||||
|
|
||||||
|
|
||||||
constructor(plugin: MediaDbPlugin, selectModalOptions: SelectModalOptions) {
|
constructor(plugin: MediaDbPlugin, selectModalOptions: SelectModalOptions) {
|
||||||
selectModalOptions = Object.assign({}, SELECT_MODAL_OPTIONS_DEFAULT, selectModalOptions);
|
selectModalOptions = Object.assign({}, SELECT_MODAL_OPTIONS_DEFAULT, selectModalOptions);
|
||||||
super(plugin.app, selectModalOptions.elements, selectModalOptions.multiSelect);
|
super(plugin.app, selectModalOptions.elements, selectModalOptions.multiSelect);
|
||||||
|
|
@ -42,9 +41,9 @@ export class MediaDbSearchResultModal extends SelectModal<MediaTypeModel> {
|
||||||
|
|
||||||
// Renders each suggestion item.
|
// Renders each suggestion item.
|
||||||
renderElement(item: MediaTypeModel, el: HTMLElement) {
|
renderElement(item: MediaTypeModel, el: HTMLElement) {
|
||||||
el.createEl('div', {text: this.plugin.mediaTypeManager.getFileName(item)});
|
el.createEl('div', { text: this.plugin.mediaTypeManager.getFileName(item) });
|
||||||
el.createEl('small', {text: `${item.getSummary()}\n`});
|
el.createEl('small', { text: `${item.getSummary()}\n` });
|
||||||
el.createEl('small', {text: `${item.type.toUpperCase() + (item.subType ? ` (${item.subType})` : '')} from ${item.dataSource}`});
|
el.createEl('small', { text: `${item.type.toUpperCase() + (item.subType ? ` (${item.subType})` : '')} from ${item.dataSource}` });
|
||||||
}
|
}
|
||||||
|
|
||||||
// Perform action on the selected suggestion.
|
// Perform action on the selected suggestion.
|
||||||
|
|
@ -52,7 +51,7 @@ export class MediaDbSearchResultModal extends SelectModal<MediaTypeModel> {
|
||||||
if (!this.busy) {
|
if (!this.busy) {
|
||||||
this.busy = true;
|
this.busy = true;
|
||||||
this.submitButton.setButtonText('Creating entry...');
|
this.submitButton.setButtonText('Creating entry...');
|
||||||
this.submitCallback({selected: this.selectModalElements.filter(x => x.isActive()).map(x => x.value)});
|
this.submitCallback({ selected: this.selectModalElements.filter(x => x.isActive()).map(x => x.value) });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -62,7 +61,6 @@ export class MediaDbSearchResultModal extends SelectModal<MediaTypeModel> {
|
||||||
}
|
}
|
||||||
|
|
||||||
onClose() {
|
onClose() {
|
||||||
|
|
||||||
this.closeCallback();
|
this.closeCallback();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
import {App, ButtonComponent, Modal, Setting} from 'obsidian';
|
import { App, ButtonComponent, Modal, Setting } from 'obsidian';
|
||||||
import {SelectModalElement} from './SelectModalElement';
|
import { SelectModalElement } from './SelectModalElement';
|
||||||
import {mod} from '../utils/Utils';
|
import { mod } from '../utils/Utils';
|
||||||
|
|
||||||
export abstract class SelectModal<T> extends Modal {
|
export abstract class SelectModal<T> extends Modal {
|
||||||
allowMultiSelect: boolean;
|
allowMultiSelect: boolean;
|
||||||
|
|
@ -17,7 +17,6 @@ export abstract class SelectModal<T> extends Modal {
|
||||||
elements: T[];
|
elements: T[];
|
||||||
selectModalElements: SelectModalElement<T>[];
|
selectModalElements: SelectModalElement<T>[];
|
||||||
|
|
||||||
|
|
||||||
protected constructor(app: App, elements: T[], allowMultiSelect: boolean = true) {
|
protected constructor(app: App, elements: T[], allowMultiSelect: boolean = true) {
|
||||||
super(app);
|
super(app);
|
||||||
this.allowMultiSelect = allowMultiSelect;
|
this.allowMultiSelect = allowMultiSelect;
|
||||||
|
|
@ -34,18 +33,18 @@ export abstract class SelectModal<T> extends Modal {
|
||||||
this.elements = elements;
|
this.elements = elements;
|
||||||
this.selectModalElements = [];
|
this.selectModalElements = [];
|
||||||
|
|
||||||
this.scope.register([], 'ArrowUp', (evt) => {
|
this.scope.register([], 'ArrowUp', evt => {
|
||||||
this.highlightUp();
|
this.highlightUp();
|
||||||
evt.preventDefault();
|
evt.preventDefault();
|
||||||
});
|
});
|
||||||
this.scope.register([], 'ArrowDown', (evt) => {
|
this.scope.register([], 'ArrowDown', evt => {
|
||||||
this.highlightDown();
|
this.highlightDown();
|
||||||
evt.preventDefault();
|
evt.preventDefault();
|
||||||
});
|
});
|
||||||
this.scope.register([], 'ArrowRight', () => {
|
this.scope.register([], 'ArrowRight', () => {
|
||||||
this.activateHighlighted();
|
this.activateHighlighted();
|
||||||
});
|
});
|
||||||
this.scope.register([], ' ', (evt) => {
|
this.scope.register([], ' ', evt => {
|
||||||
if (this.elementWrapper && this.elementWrapper === document.activeElement) {
|
if (this.elementWrapper && this.elementWrapper === document.activeElement) {
|
||||||
this.activateHighlighted();
|
this.activateHighlighted();
|
||||||
evt.preventDefault();
|
evt.preventDefault();
|
||||||
|
|
@ -77,13 +76,13 @@ export abstract class SelectModal<T> extends Modal {
|
||||||
}
|
}
|
||||||
|
|
||||||
async onOpen() {
|
async onOpen() {
|
||||||
const {contentEl, titleEl} = this;
|
const { contentEl, titleEl } = this;
|
||||||
|
|
||||||
titleEl.createEl('h2', {text: this.title});
|
titleEl.createEl('h2', { text: this.title });
|
||||||
contentEl.addClass('media-db-plugin-select-modal');
|
contentEl.addClass('media-db-plugin-select-modal');
|
||||||
contentEl.createEl('p', {text: this.description});
|
contentEl.createEl('p', { text: this.description });
|
||||||
|
|
||||||
this.elementWrapper = contentEl.createDiv({cls: 'media-db-plugin-select-wrapper'});
|
this.elementWrapper = contentEl.createDiv({ cls: 'media-db-plugin-select-wrapper' });
|
||||||
this.elementWrapper.tabIndex = 0;
|
this.elementWrapper.tabIndex = 0;
|
||||||
|
|
||||||
let i = 0;
|
let i = 0;
|
||||||
|
|
@ -171,5 +170,4 @@ export abstract class SelectModal<T> extends Modal {
|
||||||
|
|
||||||
return this.selectModalElements.filter(x => x.id === nextId).first();
|
return this.selectModalElements.filter(x => x.id === nextId).first();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
import {SelectModal} from './SelectModal';
|
import { SelectModal } from './SelectModal';
|
||||||
|
|
||||||
export class SelectModalElement<T> {
|
export class SelectModalElement<T> {
|
||||||
selectModal: SelectModal<T>;
|
selectModal: SelectModal<T>;
|
||||||
|
|
@ -21,7 +21,7 @@ export class SelectModalElement<T> {
|
||||||
this.activeClass = 'media-db-plugin-select-element-selected';
|
this.activeClass = 'media-db-plugin-select-element-selected';
|
||||||
this.hoverClass = 'media-db-plugin-select-element-hover';
|
this.hoverClass = 'media-db-plugin-select-element-hover';
|
||||||
|
|
||||||
this.element = parentElement.createDiv({cls: this.cssClass});
|
this.element = parentElement.createDiv({ cls: this.cssClass });
|
||||||
this.element.id = this.getHTMLId();
|
this.element.id = this.getHTMLId();
|
||||||
this.element.on('click', '#' + this.getHTMLId(), () => {
|
this.element.on('click', '#' + this.getHTMLId(), () => {
|
||||||
this.setActive(!this.active);
|
this.setActive(!this.active);
|
||||||
|
|
@ -83,5 +83,4 @@ export class SelectModalElement<T> {
|
||||||
this.element.removeClass(cssClass);
|
this.element.removeClass(cssClass);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,6 @@
|
||||||
import {MediaTypeModel} from './MediaTypeModel';
|
import { MediaTypeModel } from './MediaTypeModel';
|
||||||
import {mediaDbTag, migrateObject} from '../utils/Utils';
|
import { mediaDbTag, migrateObject } from '../utils/Utils';
|
||||||
import {MediaType} from '../utils/MediaType';
|
import { MediaType } from '../utils/MediaType';
|
||||||
|
|
||||||
|
|
||||||
export class BoardGameModel extends MediaTypeModel {
|
export class BoardGameModel extends MediaTypeModel {
|
||||||
genres: string[];
|
genres: string[];
|
||||||
|
|
@ -15,7 +14,6 @@ export class BoardGameModel extends MediaTypeModel {
|
||||||
personalRating: number;
|
personalRating: number;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
constructor(obj: any = {}) {
|
constructor(obj: any = {}) {
|
||||||
super();
|
super();
|
||||||
|
|
||||||
|
|
@ -48,5 +46,4 @@ export class BoardGameModel extends MediaTypeModel {
|
||||||
getSummary(): string {
|
getSummary(): string {
|
||||||
return this.englishTitle + ' (' + this.year + ')';
|
return this.englishTitle + ' (' + this.year + ')';
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,6 @@
|
||||||
import {MediaTypeModel} from './MediaTypeModel';
|
import { MediaTypeModel } from './MediaTypeModel';
|
||||||
import {mediaDbTag, migrateObject} from '../utils/Utils';
|
import { mediaDbTag, migrateObject } from '../utils/Utils';
|
||||||
import {MediaType} from '../utils/MediaType';
|
import { MediaType } from '../utils/MediaType';
|
||||||
|
|
||||||
|
|
||||||
export class GameModel extends MediaTypeModel {
|
export class GameModel extends MediaTypeModel {
|
||||||
genres: string[];
|
genres: string[];
|
||||||
|
|
@ -16,7 +15,6 @@ export class GameModel extends MediaTypeModel {
|
||||||
personalRating: number;
|
personalRating: number;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
constructor(obj: any = {}) {
|
constructor(obj: any = {}) {
|
||||||
super();
|
super();
|
||||||
|
|
||||||
|
|
@ -50,5 +48,4 @@ export class GameModel extends MediaTypeModel {
|
||||||
getSummary(): string {
|
getSummary(): string {
|
||||||
return this.englishTitle + ' (' + this.year + ')';
|
return this.englishTitle + ' (' + this.year + ')';
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
import {MediaType} from '../utils/MediaType';
|
import { MediaType } from '../utils/MediaType';
|
||||||
|
|
||||||
export abstract class MediaTypeModel {
|
export abstract class MediaTypeModel {
|
||||||
type: string;
|
type: string;
|
||||||
|
|
@ -12,7 +12,6 @@ export abstract class MediaTypeModel {
|
||||||
|
|
||||||
userData: object;
|
userData: object;
|
||||||
|
|
||||||
|
|
||||||
protected constructor() {
|
protected constructor() {
|
||||||
this.type = undefined;
|
this.type = undefined;
|
||||||
this.subType = undefined;
|
this.subType = undefined;
|
||||||
|
|
@ -33,7 +32,7 @@ export abstract class MediaTypeModel {
|
||||||
abstract getTags(): string[];
|
abstract getTags(): string[];
|
||||||
|
|
||||||
toMetaDataObject(): object {
|
toMetaDataObject(): object {
|
||||||
return {...this.getWithOutUserData(), ...this.userData, tags: this.getTags().join('/')};
|
return { ...this.getWithOutUserData(), ...this.userData, tags: this.getTags().join('/') };
|
||||||
}
|
}
|
||||||
|
|
||||||
getWithOutUserData(): object {
|
getWithOutUserData(): object {
|
||||||
|
|
@ -41,5 +40,4 @@ export abstract class MediaTypeModel {
|
||||||
delete copy.userData;
|
delete copy.userData;
|
||||||
return copy;
|
return copy;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,6 @@
|
||||||
import {MediaTypeModel} from './MediaTypeModel';
|
import { MediaTypeModel } from './MediaTypeModel';
|
||||||
import {mediaDbTag, migrateObject} from '../utils/Utils';
|
import { mediaDbTag, migrateObject } from '../utils/Utils';
|
||||||
import {MediaType} from '../utils/MediaType';
|
import { MediaType } from '../utils/MediaType';
|
||||||
|
|
||||||
|
|
||||||
export class MovieModel extends MediaTypeModel {
|
export class MovieModel extends MediaTypeModel {
|
||||||
genres: string[];
|
genres: string[];
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,6 @@
|
||||||
import {MediaTypeModel} from './MediaTypeModel';
|
import { MediaTypeModel } from './MediaTypeModel';
|
||||||
import {mediaDbTag, migrateObject} from '../utils/Utils';
|
import { mediaDbTag, migrateObject } from '../utils/Utils';
|
||||||
import {MediaType} from '../utils/MediaType';
|
import { MediaType } from '../utils/MediaType';
|
||||||
|
|
||||||
|
|
||||||
export class MusicReleaseModel extends MediaTypeModel {
|
export class MusicReleaseModel extends MediaTypeModel {
|
||||||
type: string;
|
type: string;
|
||||||
|
|
@ -50,8 +49,7 @@ export class MusicReleaseModel extends MediaTypeModel {
|
||||||
|
|
||||||
getSummary(): string {
|
getSummary(): string {
|
||||||
let summary = this.title + ' (' + this.year + ')';
|
let summary = this.title + ' (' + this.year + ')';
|
||||||
if (this.artists.length > 0)
|
if (this.artists.length > 0) summary += ' - ' + this.artists.join(', ');
|
||||||
summary += ' - ' + this.artists.join(', ');
|
|
||||||
return summary;
|
return summary;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,6 @@
|
||||||
import {MediaTypeModel} from './MediaTypeModel';
|
import { MediaTypeModel } from './MediaTypeModel';
|
||||||
import {mediaDbTag, migrateObject} from '../utils/Utils';
|
import { mediaDbTag, migrateObject } from '../utils/Utils';
|
||||||
import {MediaType} from '../utils/MediaType';
|
import { MediaType } from '../utils/MediaType';
|
||||||
|
|
||||||
|
|
||||||
export class SeriesModel extends MediaTypeModel {
|
export class SeriesModel extends MediaTypeModel {
|
||||||
type: string;
|
type: string;
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,6 @@
|
||||||
import {MediaTypeModel} from './MediaTypeModel';
|
import { MediaTypeModel } from './MediaTypeModel';
|
||||||
import {mediaDbTag, migrateObject} from '../utils/Utils';
|
import { mediaDbTag, migrateObject } from '../utils/Utils';
|
||||||
import {MediaType} from '../utils/MediaType';
|
import { MediaType } from '../utils/MediaType';
|
||||||
|
|
||||||
|
|
||||||
export class WikiModel extends MediaTypeModel {
|
export class WikiModel extends MediaTypeModel {
|
||||||
type: string;
|
type: string;
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
import {PropertyMappingOption} from './PropertyMapping';
|
import { PropertyMappingOption } from './PropertyMapping';
|
||||||
import {MEDIA_TYPES} from '../utils/MediaTypeManager';
|
import { MEDIA_TYPES } from '../utils/MediaTypeManager';
|
||||||
import MediaDbPlugin from '../main';
|
import MediaDbPlugin from '../main';
|
||||||
|
|
||||||
export class PropertyMapper {
|
export class PropertyMapper {
|
||||||
|
|
@ -40,7 +40,6 @@ export class PropertyMapper {
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
newObj[propertyMapping.newProperty] = value;
|
newObj[propertyMapping.newProperty] = value;
|
||||||
} else if (propertyMapping.mapping === PropertyMappingOption.Remove) {
|
} else if (propertyMapping.mapping === PropertyMappingOption.Remove) {
|
||||||
|
|
||||||
} else if (propertyMapping.mapping === PropertyMappingOption.Default) {
|
} else if (propertyMapping.mapping === PropertyMappingOption.Default) {
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
newObj[key] = value;
|
newObj[key] = value;
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
import {containsOnlyLettersAndUnderscores, PropertyMappingNameConflictError, PropertyMappingValidationError} from '../utils/Utils';
|
import { containsOnlyLettersAndUnderscores, PropertyMappingNameConflictError, PropertyMappingValidationError } from '../utils/Utils';
|
||||||
import {MediaType} from '../utils/MediaType';
|
import { MediaType } from '../utils/MediaType';
|
||||||
|
|
||||||
export enum PropertyMappingOption {
|
export enum PropertyMappingOption {
|
||||||
Default = 'default',
|
Default = 'default',
|
||||||
|
|
@ -18,7 +18,7 @@ export class PropertyMappingModel {
|
||||||
this.properties = properties ?? [];
|
this.properties = properties ?? [];
|
||||||
}
|
}
|
||||||
|
|
||||||
validate(): { res: boolean, err?: Error } {
|
validate(): { res: boolean; err?: Error } {
|
||||||
console.debug(`MDB | validated property mappings for ${this.type}`);
|
console.debug(`MDB | validated property mappings for ${this.type}`);
|
||||||
|
|
||||||
// check properties
|
// check properties
|
||||||
|
|
@ -43,7 +43,9 @@ export class PropertyMappingModel {
|
||||||
// two or more properties are mapped to the same property
|
// two or more properties are mapped to the same property
|
||||||
return {
|
return {
|
||||||
res: false,
|
res: false,
|
||||||
err: new PropertyMappingNameConflictError(`Multiple remapped properties (${propertiesWithSameTarget.map(x => x.toString()).toString()}) may not share the same name.`),
|
err: new PropertyMappingNameConflictError(
|
||||||
|
`Multiple remapped properties (${propertiesWithSameTarget.map(x => x.toString()).toString()}) may not share the same name.`
|
||||||
|
),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -93,7 +95,7 @@ export class PropertyMapping {
|
||||||
this.locked = locked ?? false;
|
this.locked = locked ?? false;
|
||||||
}
|
}
|
||||||
|
|
||||||
validate(): { res: boolean, err?: Error } {
|
validate(): { res: boolean; err?: Error } {
|
||||||
// locked property may only be default
|
// locked property may only be default
|
||||||
if (this.locked) {
|
if (this.locked) {
|
||||||
if (this.mapping === PropertyMappingOption.Remove) {
|
if (this.mapping === PropertyMappingOption.Remove) {
|
||||||
|
|
@ -111,10 +113,10 @@ export class PropertyMapping {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.mapping === PropertyMappingOption.Default) {
|
if (this.mapping === PropertyMappingOption.Default) {
|
||||||
return {res: true};
|
return { res: true };
|
||||||
}
|
}
|
||||||
if (this.mapping === PropertyMappingOption.Remove) {
|
if (this.mapping === PropertyMappingOption.Remove) {
|
||||||
return {res: true};
|
return { res: true };
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!this.property || !containsOnlyLettersAndUnderscores(this.property)) {
|
if (!this.property || !containsOnlyLettersAndUnderscores(this.property)) {
|
||||||
|
|
|
||||||
|
|
@ -1,45 +1,42 @@
|
||||||
import {App, Notice, PluginSettingTab, Setting} from 'obsidian';
|
import { App, Notice, PluginSettingTab, Setting } from 'obsidian';
|
||||||
|
|
||||||
import MediaDbPlugin from '../main';
|
import MediaDbPlugin from '../main';
|
||||||
import {FolderSuggest} from './suggesters/FolderSuggest';
|
import { FolderSuggest } from './suggesters/FolderSuggest';
|
||||||
import {FileSuggest} from './suggesters/FileSuggest';
|
import { FileSuggest } from './suggesters/FileSuggest';
|
||||||
import PropertyMappingModelsComponent from './PropertyMappingModelsComponent.svelte';
|
import PropertyMappingModelsComponent from './PropertyMappingModelsComponent.svelte';
|
||||||
import {PropertyMapping, PropertyMappingModel, PropertyMappingOption} from './PropertyMapping';
|
import { PropertyMapping, PropertyMappingModel, PropertyMappingOption } from './PropertyMapping';
|
||||||
import {MEDIA_TYPES} from '../utils/MediaTypeManager';
|
import { MEDIA_TYPES } from '../utils/MediaTypeManager';
|
||||||
import {MediaTypeModel} from '../models/MediaTypeModel';
|
import { MediaTypeModel } from '../models/MediaTypeModel';
|
||||||
|
|
||||||
|
|
||||||
export interface MediaDbPluginSettings {
|
export interface MediaDbPluginSettings {
|
||||||
folder: string,
|
folder: string;
|
||||||
OMDbKey: string,
|
OMDbKey: string;
|
||||||
sfwFilter: boolean,
|
sfwFilter: boolean;
|
||||||
useCustomYamlStringifier: boolean;
|
useCustomYamlStringifier: boolean;
|
||||||
templates: boolean,
|
templates: boolean;
|
||||||
|
|
||||||
|
movieTemplate: string;
|
||||||
|
seriesTemplate: string;
|
||||||
|
gameTemplate: string;
|
||||||
|
wikiTemplate: string;
|
||||||
|
musicReleaseTemplate: string;
|
||||||
|
boardgameTemplate: string;
|
||||||
|
|
||||||
movieTemplate: string,
|
movieFileNameTemplate: string;
|
||||||
seriesTemplate: string,
|
seriesFileNameTemplate: string;
|
||||||
gameTemplate: string,
|
gameFileNameTemplate: string;
|
||||||
wikiTemplate: string,
|
wikiFileNameTemplate: string;
|
||||||
musicReleaseTemplate: string,
|
musicReleaseFileNameTemplate: string;
|
||||||
boardgameTemplate: string,
|
boardgameFileNameTemplate: string;
|
||||||
|
|
||||||
movieFileNameTemplate: string,
|
moviePropertyConversionRules: string;
|
||||||
seriesFileNameTemplate: string,
|
seriesPropertyConversionRules: string;
|
||||||
gameFileNameTemplate: string,
|
gamePropertyConversionRules: string;
|
||||||
wikiFileNameTemplate: string,
|
wikiPropertyConversionRules: string;
|
||||||
musicReleaseFileNameTemplate: string,
|
musicReleasePropertyConversionRules: string;
|
||||||
boardgameFileNameTemplate: string,
|
boardgamePropertyConversionRules: string;
|
||||||
|
|
||||||
moviePropertyConversionRules: string,
|
|
||||||
seriesPropertyConversionRules: string,
|
|
||||||
gamePropertyConversionRules: string,
|
|
||||||
wikiPropertyConversionRules: string,
|
|
||||||
musicReleasePropertyConversionRules: string,
|
|
||||||
boardgamePropertyConversionRules: string,
|
|
||||||
|
|
||||||
propertyMappingModels: PropertyMappingModel[],
|
|
||||||
|
|
||||||
|
propertyMappingModels: PropertyMappingModel[];
|
||||||
}
|
}
|
||||||
|
|
||||||
const DEFAULT_SETTINGS: MediaDbPluginSettings = {
|
const DEFAULT_SETTINGS: MediaDbPluginSettings = {
|
||||||
|
|
@ -89,9 +86,7 @@ export function getDefaultSettings(plugin: MediaDbPlugin): MediaDbPluginSettings
|
||||||
const propertyMappingModel: PropertyMappingModel = new PropertyMappingModel(mediaType);
|
const propertyMappingModel: PropertyMappingModel = new PropertyMappingModel(mediaType);
|
||||||
|
|
||||||
for (const key of Object.keys(metadataObj)) {
|
for (const key of Object.keys(metadataObj)) {
|
||||||
propertyMappingModel.properties.push(
|
propertyMappingModel.properties.push(new PropertyMapping(key, '', PropertyMappingOption.Default, lockedPropertyMappings.contains(key)));
|
||||||
new PropertyMapping(key, '', PropertyMappingOption.Default, lockedPropertyMappings.contains(key)),
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
propertyMappingModels.push(propertyMappingModel);
|
propertyMappingModels.push(propertyMappingModel);
|
||||||
|
|
@ -110,11 +105,11 @@ export class MediaDbSettingTab extends PluginSettingTab {
|
||||||
}
|
}
|
||||||
|
|
||||||
display(): void {
|
display(): void {
|
||||||
const {containerEl} = this;
|
const { containerEl } = this;
|
||||||
|
|
||||||
containerEl.empty();
|
containerEl.empty();
|
||||||
|
|
||||||
containerEl.createEl('h2', {text: 'Media DB Plugin Settings'});
|
containerEl.createEl('h2', { text: 'Media DB Plugin Settings' });
|
||||||
|
|
||||||
new Setting(containerEl)
|
new Setting(containerEl)
|
||||||
.setName('New file location')
|
.setName('New file location')
|
||||||
|
|
@ -145,37 +140,33 @@ export class MediaDbSettingTab extends PluginSettingTab {
|
||||||
.setName('SFW filter')
|
.setName('SFW filter')
|
||||||
.setDesc('Only shows SFW results for APIs that offer filtering.')
|
.setDesc('Only shows SFW results for APIs that offer filtering.')
|
||||||
.addToggle(cb => {
|
.addToggle(cb => {
|
||||||
cb.setValue(this.plugin.settings.sfwFilter)
|
cb.setValue(this.plugin.settings.sfwFilter).onChange(data => {
|
||||||
.onChange(data => {
|
this.plugin.settings.sfwFilter = data;
|
||||||
this.plugin.settings.sfwFilter = data;
|
this.plugin.saveSettings();
|
||||||
this.plugin.saveSettings();
|
});
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
||||||
new Setting(containerEl)
|
new Setting(containerEl)
|
||||||
.setName('YAML formatter')
|
.setName('YAML formatter')
|
||||||
.setDesc('Add optional quotation marks around strings in the metadata block.')
|
.setDesc('Add optional quotation marks around strings in the metadata block.')
|
||||||
.addToggle(cb => {
|
.addToggle(cb => {
|
||||||
cb.setValue(this.plugin.settings.useCustomYamlStringifier)
|
cb.setValue(this.plugin.settings.useCustomYamlStringifier).onChange(data => {
|
||||||
.onChange(data => {
|
this.plugin.settings.useCustomYamlStringifier = data;
|
||||||
this.plugin.settings.useCustomYamlStringifier = data;
|
this.plugin.saveSettings();
|
||||||
this.plugin.saveSettings();
|
});
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
||||||
new Setting(containerEl)
|
new Setting(containerEl)
|
||||||
.setName('Resolve {{ tags }} in templates')
|
.setName('Resolve {{ tags }} in templates')
|
||||||
.setDesc('Whether to resolve {{ tags }} in templates. The spaces inside the curly braces are important.')
|
.setDesc('Whether to resolve {{ tags }} in templates. The spaces inside the curly braces are important.')
|
||||||
.addToggle(cb => {
|
.addToggle(cb => {
|
||||||
cb.setValue(this.plugin.settings.templates)
|
cb.setValue(this.plugin.settings.templates).onChange(data => {
|
||||||
.onChange(data => {
|
this.plugin.settings.templates = data;
|
||||||
this.plugin.settings.templates = data;
|
this.plugin.saveSettings();
|
||||||
this.plugin.saveSettings();
|
});
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
containerEl.createEl('h3', { text: 'Template Settings' });
|
||||||
containerEl.createEl('h3', {text: 'Template Settings'});
|
|
||||||
// region templates
|
// region templates
|
||||||
new Setting(containerEl)
|
new Setting(containerEl)
|
||||||
.setName('Movie template')
|
.setName('Movie template')
|
||||||
|
|
@ -256,7 +247,7 @@ export class MediaDbSettingTab extends PluginSettingTab {
|
||||||
});
|
});
|
||||||
// endregion
|
// endregion
|
||||||
|
|
||||||
containerEl.createEl('h3', {text: 'File Name Settings'});
|
containerEl.createEl('h3', { text: 'File Name Settings' });
|
||||||
// region file name templates
|
// region file name templates
|
||||||
new Setting(containerEl)
|
new Setting(containerEl)
|
||||||
.setName('Movie file name template')
|
.setName('Movie file name template')
|
||||||
|
|
@ -333,7 +324,7 @@ export class MediaDbSettingTab extends PluginSettingTab {
|
||||||
|
|
||||||
// region Property Mappings
|
// region Property Mappings
|
||||||
|
|
||||||
containerEl.createEl('h3', {text: 'Property Mappings'});
|
containerEl.createEl('h3', { text: 'Property Mappings' });
|
||||||
|
|
||||||
let propertyMappingExplanation = containerEl.createEl('div');
|
let propertyMappingExplanation = containerEl.createEl('div');
|
||||||
propertyMappingExplanation.innerHTML = `
|
propertyMappingExplanation.innerHTML = `
|
||||||
|
|
@ -350,7 +341,6 @@ export class MediaDbSettingTab extends PluginSettingTab {
|
||||||
Don't forget to save your changes using the save button for each individual category.
|
Don't forget to save your changes using the save button for each individual category.
|
||||||
</p>`;
|
</p>`;
|
||||||
|
|
||||||
|
|
||||||
new PropertyMappingModelsComponent({
|
new PropertyMappingModelsComponent({
|
||||||
target: this.containerEl,
|
target: this.containerEl,
|
||||||
props: {
|
props: {
|
||||||
|
|
@ -374,7 +364,5 @@ export class MediaDbSettingTab extends PluginSettingTab {
|
||||||
});
|
});
|
||||||
|
|
||||||
// endregion
|
// endregion
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
import {TextInputSuggest} from './Suggest';
|
import { TextInputSuggest } from './Suggest';
|
||||||
import {TAbstractFile, TFile} from 'obsidian';
|
import { TAbstractFile, TFile } from 'obsidian';
|
||||||
|
|
||||||
export class FileSuggest extends TextInputSuggest<TFile> {
|
export class FileSuggest extends TextInputSuggest<TFile> {
|
||||||
getSuggestions(inputStr: string): TFile[] {
|
getSuggestions(inputStr: string): TFile[] {
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
// Credits go to Liam's Periodic Notes Plugin: https://github.com/liamcain/obsidian-periodic-notes
|
// Credits go to Liam's Periodic Notes Plugin: https://github.com/liamcain/obsidian-periodic-notes
|
||||||
|
|
||||||
import {TAbstractFile, TFolder} from 'obsidian';
|
import { TAbstractFile, TFolder } from 'obsidian';
|
||||||
import {TextInputSuggest} from './Suggest';
|
import { TextInputSuggest } from './Suggest';
|
||||||
|
|
||||||
export class FolderSuggest extends TextInputSuggest<TFolder> {
|
export class FolderSuggest extends TextInputSuggest<TFolder> {
|
||||||
getSuggestions(inputStr: string): TFolder[] {
|
getSuggestions(inputStr: string): TFolder[] {
|
||||||
|
|
@ -10,10 +10,7 @@ export class FolderSuggest extends TextInputSuggest<TFolder> {
|
||||||
const lowerCaseInputStr = inputStr.toLowerCase();
|
const lowerCaseInputStr = inputStr.toLowerCase();
|
||||||
|
|
||||||
abstractFiles.forEach((folder: TAbstractFile) => {
|
abstractFiles.forEach((folder: TAbstractFile) => {
|
||||||
if (
|
if (folder instanceof TFolder && folder.path.toLowerCase().contains(lowerCaseInputStr)) {
|
||||||
folder instanceof TFolder &&
|
|
||||||
folder.path.toLowerCase().contains(lowerCaseInputStr)
|
|
||||||
) {
|
|
||||||
folders.push(folder);
|
folders.push(folder);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,8 @@
|
||||||
// Credits go to Liam's Periodic Notes Plugin: https://github.com/liamcain/obsidian-periodic-notes
|
// Credits go to Liam's Periodic Notes Plugin: https://github.com/liamcain/obsidian-periodic-notes
|
||||||
|
|
||||||
import {App, ISuggestOwner, Scope} from 'obsidian';
|
import { App, ISuggestOwner, Scope } from 'obsidian';
|
||||||
import {createPopper, Instance as PopperInstance} from '@popperjs/core';
|
import { createPopper, Instance as PopperInstance } from '@popperjs/core';
|
||||||
import {wrapAround} from 'src/utils/Utils';
|
import { wrapAround } from 'src/utils/Utils';
|
||||||
|
|
||||||
export class Suggest<T> {
|
export class Suggest<T> {
|
||||||
private owner: ISuggestOwner<T>;
|
private owner: ISuggestOwner<T>;
|
||||||
|
|
@ -16,27 +16,23 @@ export class Suggest<T> {
|
||||||
this.containerEl = containerEl;
|
this.containerEl = containerEl;
|
||||||
|
|
||||||
containerEl.on('click', '.suggestion-item', this.onSuggestionClick.bind(this));
|
containerEl.on('click', '.suggestion-item', this.onSuggestionClick.bind(this));
|
||||||
containerEl.on(
|
containerEl.on('mousemove', '.suggestion-item', this.onSuggestionMouseover.bind(this));
|
||||||
'mousemove',
|
|
||||||
'.suggestion-item',
|
|
||||||
this.onSuggestionMouseover.bind(this),
|
|
||||||
);
|
|
||||||
|
|
||||||
scope.register([], 'ArrowUp', (event) => {
|
scope.register([], 'ArrowUp', event => {
|
||||||
if (!event.isComposing) {
|
if (!event.isComposing) {
|
||||||
this.setSelectedItem(this.selectedItem - 1, true);
|
this.setSelectedItem(this.selectedItem - 1, true);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
scope.register([], 'ArrowDown', (event) => {
|
scope.register([], 'ArrowDown', event => {
|
||||||
if (!event.isComposing) {
|
if (!event.isComposing) {
|
||||||
this.setSelectedItem(this.selectedItem + 1, true);
|
this.setSelectedItem(this.selectedItem + 1, true);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
scope.register([], 'Enter', (event) => {
|
scope.register([], 'Enter', event => {
|
||||||
if (!event.isComposing) {
|
if (!event.isComposing) {
|
||||||
this.useSelectedItem(event);
|
this.useSelectedItem(event);
|
||||||
return false;
|
return false;
|
||||||
|
|
@ -61,7 +57,7 @@ export class Suggest<T> {
|
||||||
this.containerEl.empty();
|
this.containerEl.empty();
|
||||||
const suggestionEls: HTMLDivElement[] = [];
|
const suggestionEls: HTMLDivElement[] = [];
|
||||||
|
|
||||||
values.forEach((value) => {
|
values.forEach(value => {
|
||||||
const suggestionEl = this.containerEl.createDiv('suggestion-item');
|
const suggestionEl = this.containerEl.createDiv('suggestion-item');
|
||||||
this.owner.renderSuggestion(value, suggestionEl);
|
this.owner.renderSuggestion(value, suggestionEl);
|
||||||
suggestionEls.push(suggestionEl);
|
suggestionEls.push(suggestionEl);
|
||||||
|
|
@ -145,7 +141,7 @@ export abstract class TextInputSuggest<T> implements ISuggestOwner<T> {
|
||||||
{
|
{
|
||||||
name: 'sameWidth',
|
name: 'sameWidth',
|
||||||
enabled: true,
|
enabled: true,
|
||||||
fn: ({state, instance}) => {
|
fn: ({ state, instance }) => {
|
||||||
// Note: positioning needs to be calculated twice -
|
// Note: positioning needs to be calculated twice -
|
||||||
// first pass - positioning it according to the width of the popper
|
// first pass - positioning it according to the width of the popper
|
||||||
// second pass - position it with the width bound to the reference element
|
// second pass - position it with the width bound to the reference element
|
||||||
|
|
|
||||||
|
|
@ -1,13 +1,13 @@
|
||||||
import fetchMock, {enableFetchMocks} from 'jest-fetch-mock';
|
import fetchMock, { enableFetchMocks } from 'jest-fetch-mock';
|
||||||
import {MediaDbPluginSettings} from 'src/settings/Settings';
|
import { MediaDbPluginSettings } from 'src/settings/Settings';
|
||||||
import {LocGovAPI} from '../api/apis/LocGovAPI';
|
import { LocGovAPI } from '../api/apis/LocGovAPI';
|
||||||
import {MALAPI} from '../api/apis/MALAPI';
|
import { MALAPI } from '../api/apis/MALAPI';
|
||||||
import {MusicBrainzAPI} from '../api/apis/MusicBrainzAPI';
|
import { MusicBrainzAPI } from '../api/apis/MusicBrainzAPI';
|
||||||
import {OMDbAPI} from '../api/apis/OMDbAPI';
|
import { OMDbAPI } from '../api/apis/OMDbAPI';
|
||||||
import {SteamAPI} from '../api/apis/SteamAPI';
|
import { SteamAPI } from '../api/apis/SteamAPI';
|
||||||
import {WikipediaAPI} from '../api/apis/WikipediaAPI';
|
import { WikipediaAPI } from '../api/apis/WikipediaAPI';
|
||||||
import MediaDbPlugin from '../main';
|
import MediaDbPlugin from '../main';
|
||||||
import {setMALResponseMock, setMusicBrainzResponseMock, setOMDbResponseMock, setSteamResponseMock, setWikipediaResponseMock} from './mockHelpers';
|
import { setMALResponseMock, setMusicBrainzResponseMock, setOMDbResponseMock, setSteamResponseMock, setWikipediaResponseMock } from './mockHelpers';
|
||||||
import MALMockMovie from './ResponseMocks/MALMockMovie.json';
|
import MALMockMovie from './ResponseMocks/MALMockMovie.json';
|
||||||
import MusicBrainzResponseMock from './ResponseMocks/MusicBrainzMockResponse.json';
|
import MusicBrainzResponseMock from './ResponseMocks/MusicBrainzMockResponse.json';
|
||||||
import OMDBMockMovie from './ResponseMocks/OMDBMockResponse.json';
|
import OMDBMockMovie from './ResponseMocks/OMDBMockResponse.json';
|
||||||
|
|
@ -17,94 +17,88 @@ import WikipediaMockResponse from './ResponseMocks/WikipediaMockResponse.json';
|
||||||
enableFetchMocks();
|
enableFetchMocks();
|
||||||
export let apiMock: OMDbAPI | MALAPI | LocGovAPI | MusicBrainzAPI | SteamAPI | WikipediaAPI;
|
export let apiMock: OMDbAPI | MALAPI | LocGovAPI | MusicBrainzAPI | SteamAPI | WikipediaAPI;
|
||||||
|
|
||||||
describe.each(
|
describe.each([{ name: OMDbAPI }, { name: MALAPI }, { name: LocGovAPI }, { name: MusicBrainzAPI }, { name: SteamAPI }, { name: WikipediaAPI }])(
|
||||||
[
|
'$name.name',
|
||||||
{name: OMDbAPI},
|
({ name: parameterizedApi }) => {
|
||||||
{name: MALAPI},
|
beforeAll(() => {
|
||||||
{name: LocGovAPI},
|
let settingsMock: MediaDbPluginSettings = {} as MediaDbPluginSettings;
|
||||||
{name: MusicBrainzAPI},
|
let pluginMock = {} as MediaDbPlugin;
|
||||||
{name: SteamAPI},
|
pluginMock.settings = settingsMock;
|
||||||
{name: WikipediaAPI},
|
// TODO: add fake API key?
|
||||||
],
|
apiMock = new parameterizedApi(pluginMock);
|
||||||
)('$name.name', ({name: parameterizedApi}) => {
|
|
||||||
beforeAll(() => {
|
|
||||||
let settingsMock: MediaDbPluginSettings = {} as MediaDbPluginSettings;
|
|
||||||
let pluginMock = {} as MediaDbPlugin;
|
|
||||||
pluginMock.settings = settingsMock;
|
|
||||||
// TODO: add fake API key?
|
|
||||||
apiMock = new parameterizedApi(pluginMock);
|
|
||||||
});
|
|
||||||
|
|
||||||
beforeEach(() => {
|
|
||||||
fetchMock.resetMocks();
|
|
||||||
});
|
|
||||||
|
|
||||||
test('searchByTitle behavior when API returns garbage data', async () => {
|
|
||||||
const garbageResponse = JSON.stringify({
|
|
||||||
data: 'string',
|
|
||||||
});
|
});
|
||||||
fetchMock.mockResponseOnce(garbageResponse);
|
|
||||||
await expect(apiMock.searchByTitle('sample')).resolves.toEqual([]);
|
|
||||||
// }
|
|
||||||
expect(fetch).toHaveBeenCalledTimes(1);
|
|
||||||
});
|
|
||||||
|
|
||||||
test('searchByTitle behavior when requestUrl/fetch returns 401', async () => {
|
beforeEach(() => {
|
||||||
let sampleResponse = {
|
fetchMock.resetMocks();
|
||||||
data: 'string',
|
});
|
||||||
};
|
|
||||||
fetchMock.mockResponse(JSON.stringify(sampleResponse), {status: 401});
|
|
||||||
// TODO: Check API name and fix message
|
|
||||||
// TODO: Externalize string
|
|
||||||
await expect(apiMock.searchByTitle('sample')).rejects.toThrow(`MDB | Received status code ${401} from an API.`);
|
|
||||||
expect(fetchMock).toHaveBeenCalledTimes(1);
|
|
||||||
});
|
|
||||||
|
|
||||||
test('searchByTitle behavior when requestUrl/fetch returns 403', async () => {
|
test('searchByTitle behavior when API returns garbage data', async () => {
|
||||||
let sampleResponse = {
|
const garbageResponse = JSON.stringify({
|
||||||
data: 'string',
|
data: 'string',
|
||||||
};
|
});
|
||||||
fetchMock.mockResponse(JSON.stringify(sampleResponse), {status: 403});
|
fetchMock.mockResponseOnce(garbageResponse);
|
||||||
// TODO: Check API name and fix message
|
await expect(apiMock.searchByTitle('sample')).resolves.toEqual([]);
|
||||||
// TODO: Externalize string/import?
|
// }
|
||||||
await expect(apiMock.searchByTitle('sample')).rejects.toThrow(`MDB | Received status code ${403} from an API.`);
|
expect(fetch).toHaveBeenCalledTimes(1);
|
||||||
expect(fetchMock).toHaveBeenCalledTimes(1);
|
});
|
||||||
});
|
|
||||||
|
|
||||||
test('searchByTitle behavior when requestUrl/fetch returns 200', async () => {
|
test('searchByTitle behavior when requestUrl/fetch returns 401', async () => {
|
||||||
let sampleResponse;
|
let sampleResponse = {
|
||||||
let ret;
|
data: 'string',
|
||||||
switch (parameterizedApi) {
|
};
|
||||||
case OMDbAPI:
|
fetchMock.mockResponse(JSON.stringify(sampleResponse), { status: 401 });
|
||||||
ret = setOMDbResponseMock();
|
// TODO: Check API name and fix message
|
||||||
sampleResponse = OMDBMockMovie;
|
// TODO: Externalize string
|
||||||
break;
|
await expect(apiMock.searchByTitle('sample')).rejects.toThrow(`MDB | Received status code ${401} from an API.`);
|
||||||
case WikipediaAPI:
|
expect(fetchMock).toHaveBeenCalledTimes(1);
|
||||||
ret = setWikipediaResponseMock();
|
});
|
||||||
sampleResponse = WikipediaMockResponse;
|
|
||||||
break;
|
test('searchByTitle behavior when requestUrl/fetch returns 403', async () => {
|
||||||
case MALAPI:
|
let sampleResponse = {
|
||||||
// TODO: MAL needs more tests for different types of content
|
data: 'string',
|
||||||
ret = setMALResponseMock();
|
};
|
||||||
sampleResponse = MALMockMovie;
|
fetchMock.mockResponse(JSON.stringify(sampleResponse), { status: 403 });
|
||||||
case LocGovAPI:
|
// TODO: Check API name and fix message
|
||||||
// TODO: Add soon
|
// TODO: Externalize string/import?
|
||||||
break;
|
await expect(apiMock.searchByTitle('sample')).rejects.toThrow(`MDB | Received status code ${403} from an API.`);
|
||||||
case SteamAPI:
|
expect(fetchMock).toHaveBeenCalledTimes(1);
|
||||||
sampleResponse = SteamAPIResponseMock;
|
});
|
||||||
ret = setSteamResponseMock();
|
|
||||||
break;
|
test('searchByTitle behavior when requestUrl/fetch returns 200', async () => {
|
||||||
case MusicBrainzAPI:
|
let sampleResponse;
|
||||||
sampleResponse = MusicBrainzResponseMock;
|
let ret;
|
||||||
ret = setMusicBrainzResponseMock();
|
switch (parameterizedApi) {
|
||||||
break;
|
case OMDbAPI:
|
||||||
default:
|
ret = setOMDbResponseMock();
|
||||||
throw Error();
|
sampleResponse = OMDBMockMovie;
|
||||||
}
|
break;
|
||||||
fetchMock.mockResponse(JSON.stringify(sampleResponse), {status: 200});
|
case WikipediaAPI:
|
||||||
// TODO: Check API name and fix message
|
ret = setWikipediaResponseMock();
|
||||||
// TODO: Externalize string
|
sampleResponse = WikipediaMockResponse;
|
||||||
await expect(apiMock.searchByTitle('Hooking Season Playtest')).resolves.toEqual(ret);
|
break;
|
||||||
expect(fetchMock).toHaveBeenCalledTimes(1);
|
case MALAPI:
|
||||||
});
|
// TODO: MAL needs more tests for different types of content
|
||||||
});
|
ret = setMALResponseMock();
|
||||||
|
sampleResponse = MALMockMovie;
|
||||||
|
case LocGovAPI:
|
||||||
|
// TODO: Add soon
|
||||||
|
break;
|
||||||
|
case SteamAPI:
|
||||||
|
sampleResponse = SteamAPIResponseMock;
|
||||||
|
ret = setSteamResponseMock();
|
||||||
|
break;
|
||||||
|
case MusicBrainzAPI:
|
||||||
|
sampleResponse = MusicBrainzResponseMock;
|
||||||
|
ret = setMusicBrainzResponseMock();
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
throw Error();
|
||||||
|
}
|
||||||
|
fetchMock.mockResponse(JSON.stringify(sampleResponse), { status: 200 });
|
||||||
|
// TODO: Check API name and fix message
|
||||||
|
// TODO: Externalize string
|
||||||
|
await expect(apiMock.searchByTitle('Hooking Season Playtest')).resolves.toEqual(ret);
|
||||||
|
expect(fetchMock).toHaveBeenCalledTimes(1);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
|
||||||
|
|
@ -1,11 +1,10 @@
|
||||||
import {APIModel} from '../api/APIModel';
|
import { APIModel } from '../api/APIModel';
|
||||||
import {MediaTypeModel} from '../models/MediaTypeModel';
|
import { MediaTypeModel } from '../models/MediaTypeModel';
|
||||||
import MediaDbPlugin from '../main';
|
import MediaDbPlugin from '../main';
|
||||||
|
|
||||||
export class TestAPI extends APIModel {
|
export class TestAPI extends APIModel {
|
||||||
plugin: MediaDbPlugin;
|
plugin: MediaDbPlugin;
|
||||||
|
|
||||||
|
|
||||||
constructor(plugin: MediaDbPlugin) {
|
constructor(plugin: MediaDbPlugin) {
|
||||||
super();
|
super();
|
||||||
|
|
||||||
|
|
@ -16,7 +15,6 @@ export class TestAPI extends APIModel {
|
||||||
this.types = [];
|
this.types = [];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
async getById(id: string): Promise<MediaTypeModel> {
|
async getById(id: string): Promise<MediaTypeModel> {
|
||||||
return undefined;
|
return undefined;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,9 @@
|
||||||
import {GameModel} from '../models/GameModel';
|
import { GameModel } from '../models/GameModel';
|
||||||
import {MovieModel} from '../models/MovieModel';
|
import { MovieModel } from '../models/MovieModel';
|
||||||
import {MusicReleaseModel} from '../models/MusicReleaseModel';
|
import { MusicReleaseModel } from '../models/MusicReleaseModel';
|
||||||
import {WikiModel} from '../models/WikiModel';
|
import { WikiModel } from '../models/WikiModel';
|
||||||
import {MediaType} from '../utils/MediaType';
|
import { MediaType } from '../utils/MediaType';
|
||||||
import {apiMock} from './ParameterizedAPI.test';
|
import { apiMock } from './ParameterizedAPI.test';
|
||||||
import MALMockMovie from './ResponseMocks/MALMockMovie.json';
|
import MALMockMovie from './ResponseMocks/MALMockMovie.json';
|
||||||
import MusicBrainzResponseMock from './ResponseMocks/MusicBrainzMockResponse.json';
|
import MusicBrainzResponseMock from './ResponseMocks/MusicBrainzMockResponse.json';
|
||||||
import OMDBMockMovie from './ResponseMocks/OMDBMockResponse.json';
|
import OMDBMockMovie from './ResponseMocks/OMDBMockResponse.json';
|
||||||
|
|
@ -13,73 +13,83 @@ import WikipediaMockResponse from './ResponseMocks/WikipediaMockResponse.json';
|
||||||
export function setWikipediaResponseMock() {
|
export function setWikipediaResponseMock() {
|
||||||
let ret = [];
|
let ret = [];
|
||||||
let wikiresponse = WikipediaMockResponse.query.search[0];
|
let wikiresponse = WikipediaMockResponse.query.search[0];
|
||||||
ret.push(new WikiModel({
|
ret.push(
|
||||||
type: 'wiki',
|
new WikiModel({
|
||||||
title: wikiresponse.title,
|
type: 'wiki',
|
||||||
englishTitle: wikiresponse.title,
|
title: wikiresponse.title,
|
||||||
year: '',
|
englishTitle: wikiresponse.title,
|
||||||
dataSource: apiMock.apiName,
|
year: '',
|
||||||
id: wikiresponse.pageid,
|
dataSource: apiMock.apiName,
|
||||||
}));
|
id: wikiresponse.pageid,
|
||||||
|
})
|
||||||
|
);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function setOMDbResponseMock() {
|
export function setOMDbResponseMock() {
|
||||||
let ret = [];
|
let ret = [];
|
||||||
let omdbresponse = OMDBMockMovie.Search[0];
|
let omdbresponse = OMDBMockMovie.Search[0];
|
||||||
ret.push(new MovieModel({
|
ret.push(
|
||||||
type: 'wiki',
|
new MovieModel({
|
||||||
title: omdbresponse.Title,
|
type: 'wiki',
|
||||||
englishTitle: omdbresponse.Title,
|
title: omdbresponse.Title,
|
||||||
year: omdbresponse.Year,
|
englishTitle: omdbresponse.Title,
|
||||||
dataSource: apiMock.apiName,
|
year: omdbresponse.Year,
|
||||||
id: omdbresponse.imdbID,
|
dataSource: apiMock.apiName,
|
||||||
}));
|
id: omdbresponse.imdbID,
|
||||||
|
})
|
||||||
|
);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function setMALResponseMock() {
|
export function setMALResponseMock() {
|
||||||
let ret = [];
|
let ret = [];
|
||||||
let result = MALMockMovie.data[0];
|
let result = MALMockMovie.data[0];
|
||||||
ret.push(new MovieModel({
|
ret.push(
|
||||||
type: result.type,
|
new MovieModel({
|
||||||
title: result.title,
|
type: result.type,
|
||||||
englishTitle: result.title_english,
|
title: result.title,
|
||||||
year: result.aired.prop.from.year,
|
englishTitle: result.title_english,
|
||||||
dataSource: apiMock.apiName,
|
year: result.aired.prop.from.year,
|
||||||
id: result.mal_id,
|
dataSource: apiMock.apiName,
|
||||||
}));
|
id: result.mal_id,
|
||||||
|
})
|
||||||
|
);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function setSteamResponseMock() {
|
export function setSteamResponseMock() {
|
||||||
let ret = [];
|
let ret = [];
|
||||||
let steamResponse = SteamAPIResponseMock.applist.apps[0];
|
let steamResponse = SteamAPIResponseMock.applist.apps[0];
|
||||||
ret.push(new GameModel({
|
ret.push(
|
||||||
type: MediaType.Game,
|
new GameModel({
|
||||||
title: steamResponse.name,
|
type: MediaType.Game,
|
||||||
englishTitle: steamResponse.name,
|
title: steamResponse.name,
|
||||||
year: '',
|
englishTitle: steamResponse.name,
|
||||||
dataSource: apiMock.apiName,
|
year: '',
|
||||||
id: steamResponse.appid,
|
dataSource: apiMock.apiName,
|
||||||
}));
|
id: steamResponse.appid,
|
||||||
|
})
|
||||||
|
);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function setMusicBrainzResponseMock() {
|
export function setMusicBrainzResponseMock() {
|
||||||
let ret = [];
|
let ret = [];
|
||||||
let result = MusicBrainzResponseMock['release-groups'][0];
|
let result = MusicBrainzResponseMock['release-groups'][0];
|
||||||
ret.push(new MusicReleaseModel({
|
ret.push(
|
||||||
type: 'musicRelease',
|
new MusicReleaseModel({
|
||||||
title: result.title,
|
type: 'musicRelease',
|
||||||
englishTitle: result.title,
|
title: result.title,
|
||||||
year: (new Date(result['first-release-date'])).getFullYear().toString(),
|
englishTitle: result.title,
|
||||||
dataSource: apiMock.apiName,
|
year: new Date(result['first-release-date']).getFullYear().toString(),
|
||||||
url: '',
|
dataSource: apiMock.apiName,
|
||||||
id: result.id,
|
url: '',
|
||||||
|
id: result.id,
|
||||||
|
|
||||||
artists: result['artist-credit'].map((a: any) => a.name),
|
artists: result['artist-credit'].map((a: any) => a.name),
|
||||||
subType: result['primary-type'],
|
subType: result['primary-type'],
|
||||||
} as MusicReleaseModel));
|
} as MusicReleaseModel)
|
||||||
|
);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
import {containsOnlyLettersAndUnderscores, replaceIllegalFileNameCharactersInString, wrapAround} from '../utils/Utils';
|
import { containsOnlyLettersAndUnderscores, replaceIllegalFileNameCharactersInString, wrapAround } from '../utils/Utils';
|
||||||
|
|
||||||
test('If wrapAround wraps correctly', () => {
|
test('If wrapAround wraps correctly', () => {
|
||||||
expect(wrapAround(100, 5)).toBe(0);
|
expect(wrapAround(100, 5)).toBe(0);
|
||||||
|
|
|
||||||
1185
src/utils/IconList.ts
Normal file
1185
src/utils/IconList.ts
Normal file
File diff suppressed because it is too large
Load diff
|
|
@ -1,14 +1,14 @@
|
||||||
import {MediaDbPluginSettings} from '../settings/Settings';
|
import { MediaDbPluginSettings } from '../settings/Settings';
|
||||||
import {MediaType} from './MediaType';
|
import { MediaType } from './MediaType';
|
||||||
import {MediaTypeModel} from '../models/MediaTypeModel';
|
import { MediaTypeModel } from '../models/MediaTypeModel';
|
||||||
import {replaceTags} from './Utils';
|
import { replaceTags } from './Utils';
|
||||||
import {App, TFile} from 'obsidian';
|
import { App, TFile } from 'obsidian';
|
||||||
import {MovieModel} from '../models/MovieModel';
|
import { MovieModel } from '../models/MovieModel';
|
||||||
import {SeriesModel} from '../models/SeriesModel';
|
import { SeriesModel } from '../models/SeriesModel';
|
||||||
import {GameModel} from '../models/GameModel';
|
import { GameModel } from '../models/GameModel';
|
||||||
import {WikiModel} from '../models/WikiModel';
|
import { WikiModel } from '../models/WikiModel';
|
||||||
import {MusicReleaseModel} from '../models/MusicReleaseModel';
|
import { MusicReleaseModel } from '../models/MusicReleaseModel';
|
||||||
import {BoardGameModel} from '../models/BoardGameModel';
|
import { BoardGameModel } from '../models/BoardGameModel';
|
||||||
|
|
||||||
export const MEDIA_TYPES: MediaType[] = [MediaType.Movie, MediaType.Series, MediaType.Game, MediaType.Wiki, MediaType.MusicRelease, MediaType.BoardGame];
|
export const MEDIA_TYPES: MediaType[] = [MediaType.Movie, MediaType.Series, MediaType.Game, MediaType.Wiki, MediaType.MusicRelease, MediaType.BoardGame];
|
||||||
|
|
||||||
|
|
@ -16,8 +16,7 @@ export class MediaTypeManager {
|
||||||
mediaFileNameTemplateMap: Map<MediaType, string>;
|
mediaFileNameTemplateMap: Map<MediaType, string>;
|
||||||
mediaTemplateMap: Map<MediaType, string>;
|
mediaTemplateMap: Map<MediaType, string>;
|
||||||
|
|
||||||
constructor() {
|
constructor() {}
|
||||||
}
|
|
||||||
|
|
||||||
updateTemplates(settings: MediaDbPluginSettings) {
|
updateTemplates(settings: MediaDbPluginSettings) {
|
||||||
this.mediaFileNameTemplateMap = new Map<MediaType, string>();
|
this.mediaFileNameTemplateMap = new Map<MediaType, string>();
|
||||||
|
|
@ -48,7 +47,10 @@ export class MediaTypeManager {
|
||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
|
|
||||||
const templateFile: TFile = app.vault.getFiles().filter((f: TFile) => f.name === templateFileName).first();
|
const templateFile: TFile = app.vault
|
||||||
|
.getFiles()
|
||||||
|
.filter((f: TFile) => f.name === templateFileName)
|
||||||
|
.first();
|
||||||
|
|
||||||
if (!templateFile) {
|
if (!templateFile) {
|
||||||
return '';
|
return '';
|
||||||
|
|
|
||||||
|
|
@ -1,13 +1,12 @@
|
||||||
import {MediaDbAdvancedSearchModal} from '../modals/MediaDbAdvancedSearchModal';
|
import { MediaDbAdvancedSearchModal } from '../modals/MediaDbAdvancedSearchModal';
|
||||||
import {MediaDbIdSearchModal} from '../modals/MediaDbIdSearchModal';
|
import { MediaDbIdSearchModal } from '../modals/MediaDbIdSearchModal';
|
||||||
import {MediaTypeModel} from '../models/MediaTypeModel';
|
import { MediaTypeModel } from '../models/MediaTypeModel';
|
||||||
import {MediaDbSearchResultModal} from '../modals/MediaDbSearchResultModal';
|
import { MediaDbSearchResultModal } from '../modals/MediaDbSearchResultModal';
|
||||||
import {Notice} from 'obsidian';
|
import { Notice } from 'obsidian';
|
||||||
import MediaDbPlugin from '../main';
|
import MediaDbPlugin from '../main';
|
||||||
import {MediaDbPreviewModal} from 'src/modals/MediaDbPreviewModal';
|
import { MediaDbPreviewModal } from 'src/modals/MediaDbPreviewModal';
|
||||||
import {CreateNoteOptions} from './Utils';
|
import { CreateNoteOptions } from './Utils';
|
||||||
import {MediaDbSearchModal} from '../modals/MediaDbSearchModal';
|
import { MediaDbSearchModal } from '../modals/MediaDbSearchModal';
|
||||||
|
|
||||||
|
|
||||||
export enum ModalResultCode {
|
export enum ModalResultCode {
|
||||||
SUCCESS,
|
SUCCESS,
|
||||||
|
|
@ -22,9 +21,9 @@ export enum ModalResultCode {
|
||||||
* On {@link ModalResultCode.ERROR} this contains a reference to that error.
|
* On {@link ModalResultCode.ERROR} this contains a reference to that error.
|
||||||
*/
|
*/
|
||||||
export interface SearchModalResult {
|
export interface SearchModalResult {
|
||||||
code: ModalResultCode.SUCCESS | ModalResultCode.CLOSE | ModalResultCode.ERROR,
|
code: ModalResultCode.SUCCESS | ModalResultCode.CLOSE | ModalResultCode.ERROR;
|
||||||
data?: SearchModalData,
|
data?: SearchModalData;
|
||||||
error?: Error,
|
error?: Error;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -33,9 +32,9 @@ export interface SearchModalResult {
|
||||||
* On {@link ModalResultCode.ERROR} this contains a reference to that error.
|
* On {@link ModalResultCode.ERROR} this contains a reference to that error.
|
||||||
*/
|
*/
|
||||||
export interface AdvancedSearchModalResult {
|
export interface AdvancedSearchModalResult {
|
||||||
code: ModalResultCode.SUCCESS | ModalResultCode.CLOSE | ModalResultCode.ERROR,
|
code: ModalResultCode.SUCCESS | ModalResultCode.CLOSE | ModalResultCode.ERROR;
|
||||||
data?: AdvancedSearchModalData,
|
data?: AdvancedSearchModalData;
|
||||||
error?: Error,
|
error?: Error;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -44,9 +43,9 @@ export interface AdvancedSearchModalResult {
|
||||||
* On {@link ModalResultCode.ERROR} this contains a reference to that error.
|
* On {@link ModalResultCode.ERROR} this contains a reference to that error.
|
||||||
*/
|
*/
|
||||||
export interface IdSearchModalResult {
|
export interface IdSearchModalResult {
|
||||||
code: ModalResultCode.SUCCESS | ModalResultCode.CLOSE | ModalResultCode.ERROR,
|
code: ModalResultCode.SUCCESS | ModalResultCode.CLOSE | ModalResultCode.ERROR;
|
||||||
data?: IdSearchModalData,
|
data?: IdSearchModalData;
|
||||||
error?: Error,
|
error?: Error;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -55,9 +54,9 @@ export interface IdSearchModalResult {
|
||||||
* On {@link ModalResultCode.ERROR} this contains a reference to that error.
|
* On {@link ModalResultCode.ERROR} this contains a reference to that error.
|
||||||
*/
|
*/
|
||||||
export interface SelectModalResult {
|
export interface SelectModalResult {
|
||||||
code: ModalResultCode.SUCCESS | ModalResultCode.CLOSE | ModalResultCode.SKIP | ModalResultCode.ERROR,
|
code: ModalResultCode.SUCCESS | ModalResultCode.CLOSE | ModalResultCode.SKIP | ModalResultCode.ERROR;
|
||||||
data?: SelectModalData,
|
data?: SelectModalData;
|
||||||
error?: Error,
|
error?: Error;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -66,9 +65,9 @@ export interface SelectModalResult {
|
||||||
* On {@link ModalResultCode.ERROR} this contains a reference to that error.
|
* On {@link ModalResultCode.ERROR} this contains a reference to that error.
|
||||||
*/
|
*/
|
||||||
export interface PreviewModalResult {
|
export interface PreviewModalResult {
|
||||||
code: ModalResultCode.SUCCESS | ModalResultCode.CLOSE | ModalResultCode.ERROR,
|
code: ModalResultCode.SUCCESS | ModalResultCode.CLOSE | ModalResultCode.ERROR;
|
||||||
data?: PreviewModalData,
|
data?: PreviewModalData;
|
||||||
error?: Error,
|
error?: Error;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -77,8 +76,8 @@ export interface PreviewModalResult {
|
||||||
* - types: the selected APIs
|
* - types: the selected APIs
|
||||||
*/
|
*/
|
||||||
export interface SearchModalData {
|
export interface SearchModalData {
|
||||||
query: string,
|
query: string;
|
||||||
types: string[],
|
types: string[];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -87,8 +86,8 @@ export interface SearchModalData {
|
||||||
* - apis: the selected APIs
|
* - apis: the selected APIs
|
||||||
*/
|
*/
|
||||||
export interface AdvancedSearchModalData {
|
export interface AdvancedSearchModalData {
|
||||||
query: string,
|
query: string;
|
||||||
apis: string[],
|
apis: string[];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -97,8 +96,8 @@ export interface AdvancedSearchModalData {
|
||||||
* - apis: the selected APIs
|
* - apis: the selected APIs
|
||||||
*/
|
*/
|
||||||
export interface IdSearchModalData {
|
export interface IdSearchModalData {
|
||||||
query: string,
|
query: string;
|
||||||
api: string,
|
api: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -106,7 +105,7 @@ export interface IdSearchModalData {
|
||||||
* - selected: the selected items
|
* - selected: the selected items
|
||||||
*/
|
*/
|
||||||
export interface SelectModalData {
|
export interface SelectModalData {
|
||||||
selected: MediaTypeModel[],
|
selected: MediaTypeModel[];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -114,7 +113,7 @@ export interface SelectModalData {
|
||||||
* - confirmed: whether the selected element has been confirmed
|
* - confirmed: whether the selected element has been confirmed
|
||||||
*/
|
*/
|
||||||
export interface PreviewModalData {
|
export interface PreviewModalData {
|
||||||
confirmed: boolean,
|
confirmed: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -124,9 +123,9 @@ export interface PreviewModalData {
|
||||||
* - prefilledSearchString: prefilled query
|
* - prefilledSearchString: prefilled query
|
||||||
*/
|
*/
|
||||||
export interface SearchModalOptions {
|
export interface SearchModalOptions {
|
||||||
modalTitle?: string,
|
modalTitle?: string;
|
||||||
preselectedTypes?: string[],
|
preselectedTypes?: string[];
|
||||||
prefilledSearchString?: string,
|
prefilledSearchString?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -136,9 +135,9 @@ export interface SearchModalOptions {
|
||||||
* - prefilledSearchString: prefilled query
|
* - prefilledSearchString: prefilled query
|
||||||
*/
|
*/
|
||||||
export interface AdvancedSearchModalOptions {
|
export interface AdvancedSearchModalOptions {
|
||||||
modalTitle?: string,
|
modalTitle?: string;
|
||||||
preselectedAPIs?: string[],
|
preselectedAPIs?: string[];
|
||||||
prefilledSearchString?: string,
|
prefilledSearchString?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -148,9 +147,9 @@ export interface AdvancedSearchModalOptions {
|
||||||
* - prefilledSearchString: prefilled query
|
* - prefilledSearchString: prefilled query
|
||||||
*/
|
*/
|
||||||
export interface IdSearchModalOptions {
|
export interface IdSearchModalOptions {
|
||||||
modalTitle?: string,
|
modalTitle?: string;
|
||||||
preselectedAPI?: string,
|
preselectedAPI?: string;
|
||||||
prefilledSearchString?: string,
|
prefilledSearchString?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -161,10 +160,10 @@ export interface IdSearchModalOptions {
|
||||||
* - skipButton: whether to add a skip button to the modal
|
* - skipButton: whether to add a skip button to the modal
|
||||||
*/
|
*/
|
||||||
export interface SelectModalOptions {
|
export interface SelectModalOptions {
|
||||||
modalTitle?: string,
|
modalTitle?: string;
|
||||||
elements?: MediaTypeModel[],
|
elements?: MediaTypeModel[];
|
||||||
multiSelect?: boolean,
|
multiSelect?: boolean;
|
||||||
skipButton?: boolean,
|
skipButton?: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -173,9 +172,9 @@ export interface SelectModalOptions {
|
||||||
* - elements: the elements to preview
|
* - elements: the elements to preview
|
||||||
*/
|
*/
|
||||||
export interface PreviewModalOptions {
|
export interface PreviewModalOptions {
|
||||||
modalTitle?: string,
|
modalTitle?: string;
|
||||||
elements?: MediaTypeModel[],
|
elements?: MediaTypeModel[];
|
||||||
createNoteOptions?: CreateNoteOptions,
|
createNoteOptions?: CreateNoteOptions;
|
||||||
}
|
}
|
||||||
|
|
||||||
export const SEARCH_MODAL_DEFAULT_OPTIONS: SearchModalOptions = {
|
export const SEARCH_MODAL_DEFAULT_OPTIONS: SearchModalOptions = {
|
||||||
|
|
@ -206,7 +205,7 @@ export const SELECT_MODAL_OPTIONS_DEFAULT: SelectModalOptions = {
|
||||||
export const PREVIEW_MODAL_DEFAULT_OPTIONS: PreviewModalOptions = {
|
export const PREVIEW_MODAL_DEFAULT_OPTIONS: PreviewModalOptions = {
|
||||||
modalTitle: 'Media DB Preview',
|
modalTitle: 'Media DB Preview',
|
||||||
elements: [],
|
elements: [],
|
||||||
createNoteOptions: {attachTemplate: true},
|
createNoteOptions: { attachTemplate: true },
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -215,7 +214,6 @@ export const PREVIEW_MODAL_DEFAULT_OPTIONS: PreviewModalOptions = {
|
||||||
export class ModalHelper {
|
export class ModalHelper {
|
||||||
plugin: MediaDbPlugin;
|
plugin: MediaDbPlugin;
|
||||||
|
|
||||||
|
|
||||||
constructor(plugin: MediaDbPlugin) {
|
constructor(plugin: MediaDbPlugin) {
|
||||||
this.plugin = plugin;
|
this.plugin = plugin;
|
||||||
}
|
}
|
||||||
|
|
@ -228,20 +226,20 @@ export class ModalHelper {
|
||||||
* @param searchModalOptions the options for the modal, see {@link SEARCH_MODAL_DEFAULT_OPTIONS}
|
* @param searchModalOptions the options for the modal, see {@link SEARCH_MODAL_DEFAULT_OPTIONS}
|
||||||
* @returns the user input or nothing and a reference to the modal.
|
* @returns the user input or nothing and a reference to the modal.
|
||||||
*/
|
*/
|
||||||
async createSearchModal(searchModalOptions: SearchModalOptions): Promise<{ searchModalResult: SearchModalResult, searchModal: MediaDbSearchModal }> {
|
async createSearchModal(searchModalOptions: SearchModalOptions): Promise<{ searchModalResult: SearchModalResult; searchModal: MediaDbSearchModal }> {
|
||||||
const modal = new MediaDbSearchModal(this.plugin, searchModalOptions);
|
const modal = new MediaDbSearchModal(this.plugin, searchModalOptions);
|
||||||
const res: SearchModalResult = await new Promise((resolve, reject) => {
|
const res: SearchModalResult = await new Promise((resolve, reject) => {
|
||||||
modal.setSubmitCallback(res => resolve({code: ModalResultCode.SUCCESS, data: res}));
|
modal.setSubmitCallback(res => resolve({ code: ModalResultCode.SUCCESS, data: res }));
|
||||||
modal.setCloseCallback(err => {
|
modal.setCloseCallback(err => {
|
||||||
if (err) {
|
if (err) {
|
||||||
resolve({code: ModalResultCode.ERROR, error: err});
|
resolve({ code: ModalResultCode.ERROR, error: err });
|
||||||
}
|
}
|
||||||
resolve({code: ModalResultCode.CLOSE});
|
resolve({ code: ModalResultCode.CLOSE });
|
||||||
});
|
});
|
||||||
|
|
||||||
modal.open();
|
modal.open();
|
||||||
});
|
});
|
||||||
return {searchModalResult: res, searchModal: modal};
|
return { searchModalResult: res, searchModal: modal };
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -253,8 +251,8 @@ export class ModalHelper {
|
||||||
* @returns the user input or nothing and a reference to the modal.
|
* @returns the user input or nothing and a reference to the modal.
|
||||||
*/
|
*/
|
||||||
async openSearchModal(searchModalOptions: SearchModalOptions, submitCallback: (searchModalData: SearchModalData) => Promise<MediaTypeModel[]>): Promise<MediaTypeModel[]> {
|
async openSearchModal(searchModalOptions: SearchModalOptions, submitCallback: (searchModalData: SearchModalData) => Promise<MediaTypeModel[]>): Promise<MediaTypeModel[]> {
|
||||||
const {searchModalResult, searchModal} = await this.createSearchModal(searchModalOptions);
|
const { searchModalResult, searchModal } = await this.createSearchModal(searchModalOptions);
|
||||||
console.debug(`MDB | searchModal closed with code ${searchModalResult.code}`)
|
console.debug(`MDB | searchModal closed with code ${searchModalResult.code}`);
|
||||||
|
|
||||||
if (searchModalResult.code === ModalResultCode.ERROR) {
|
if (searchModalResult.code === ModalResultCode.ERROR) {
|
||||||
// there was an error in the modal itself
|
// there was an error in the modal itself
|
||||||
|
|
@ -290,20 +288,22 @@ export class ModalHelper {
|
||||||
* @param advancedSearchModalOptions the options for the modal, see {@link ADVANCED_SEARCH_MODAL_DEFAULT_OPTIONS}
|
* @param advancedSearchModalOptions the options for the modal, see {@link ADVANCED_SEARCH_MODAL_DEFAULT_OPTIONS}
|
||||||
* @returns the user input or nothing and a reference to the modal.
|
* @returns the user input or nothing and a reference to the modal.
|
||||||
*/
|
*/
|
||||||
async createAdvancedSearchModal(advancedSearchModalOptions: AdvancedSearchModalOptions): Promise<{ advancedSearchModalResult: AdvancedSearchModalResult, advancedSearchModal: MediaDbAdvancedSearchModal }> {
|
async createAdvancedSearchModal(
|
||||||
|
advancedSearchModalOptions: AdvancedSearchModalOptions
|
||||||
|
): Promise<{ advancedSearchModalResult: AdvancedSearchModalResult; advancedSearchModal: MediaDbAdvancedSearchModal }> {
|
||||||
const modal = new MediaDbAdvancedSearchModal(this.plugin, advancedSearchModalOptions);
|
const modal = new MediaDbAdvancedSearchModal(this.plugin, advancedSearchModalOptions);
|
||||||
const res: AdvancedSearchModalResult = await new Promise((resolve, reject) => {
|
const res: AdvancedSearchModalResult = await new Promise((resolve, reject) => {
|
||||||
modal.setSubmitCallback(res => resolve({code: ModalResultCode.SUCCESS, data: res}));
|
modal.setSubmitCallback(res => resolve({ code: ModalResultCode.SUCCESS, data: res }));
|
||||||
modal.setCloseCallback(err => {
|
modal.setCloseCallback(err => {
|
||||||
if (err) {
|
if (err) {
|
||||||
resolve({code: ModalResultCode.ERROR, error: err});
|
resolve({ code: ModalResultCode.ERROR, error: err });
|
||||||
}
|
}
|
||||||
resolve({code: ModalResultCode.CLOSE});
|
resolve({ code: ModalResultCode.CLOSE });
|
||||||
});
|
});
|
||||||
|
|
||||||
modal.open();
|
modal.open();
|
||||||
});
|
});
|
||||||
return {advancedSearchModalResult: res, advancedSearchModal: modal};
|
return { advancedSearchModalResult: res, advancedSearchModal: modal };
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -314,9 +314,12 @@ export class ModalHelper {
|
||||||
* @param submitCallback the callback that gets executed after the modal has been submitted, but after it has been closed
|
* @param submitCallback the callback that gets executed after the modal has been submitted, but after it has been closed
|
||||||
* @returns the user input or nothing and a reference to the modal.
|
* @returns the user input or nothing and a reference to the modal.
|
||||||
*/
|
*/
|
||||||
async openAdvancedSearchModal(advancedSearchModalOptions: AdvancedSearchModalOptions, submitCallback: (advancedSearchModalData: AdvancedSearchModalData) => Promise<MediaTypeModel[]>): Promise<MediaTypeModel[]> {
|
async openAdvancedSearchModal(
|
||||||
const {advancedSearchModalResult, advancedSearchModal} = await this.createAdvancedSearchModal(advancedSearchModalOptions);
|
advancedSearchModalOptions: AdvancedSearchModalOptions,
|
||||||
console.debug(`MDB | advencedSearchModal closed with code ${advancedSearchModalResult.code}`)
|
submitCallback: (advancedSearchModalData: AdvancedSearchModalData) => Promise<MediaTypeModel[]>
|
||||||
|
): Promise<MediaTypeModel[]> {
|
||||||
|
const { advancedSearchModalResult, advancedSearchModal } = await this.createAdvancedSearchModal(advancedSearchModalOptions);
|
||||||
|
console.debug(`MDB | advencedSearchModal closed with code ${advancedSearchModalResult.code}`);
|
||||||
|
|
||||||
if (advancedSearchModalResult.code === ModalResultCode.ERROR) {
|
if (advancedSearchModalResult.code === ModalResultCode.ERROR) {
|
||||||
// there was an error in the modal itself
|
// there was an error in the modal itself
|
||||||
|
|
@ -352,20 +355,20 @@ export class ModalHelper {
|
||||||
* @param idSearchModalOptions the options for the modal, see {@link ID_SEARCH_MODAL_DEFAULT_OPTIONS}
|
* @param idSearchModalOptions the options for the modal, see {@link ID_SEARCH_MODAL_DEFAULT_OPTIONS}
|
||||||
* @returns the user input or nothing and a reference to the modal.
|
* @returns the user input or nothing and a reference to the modal.
|
||||||
*/
|
*/
|
||||||
async createIdSearchModal(idSearchModalOptions: IdSearchModalOptions): Promise<{ idSearchModalResult: IdSearchModalResult, idSearchModal: MediaDbIdSearchModal }> {
|
async createIdSearchModal(idSearchModalOptions: IdSearchModalOptions): Promise<{ idSearchModalResult: IdSearchModalResult; idSearchModal: MediaDbIdSearchModal }> {
|
||||||
const modal = new MediaDbIdSearchModal(this.plugin, idSearchModalOptions);
|
const modal = new MediaDbIdSearchModal(this.plugin, idSearchModalOptions);
|
||||||
const res: IdSearchModalResult = await new Promise((resolve, reject) => {
|
const res: IdSearchModalResult = await new Promise((resolve, reject) => {
|
||||||
modal.setSubmitCallback(res => resolve({code: ModalResultCode.SUCCESS, data: res}));
|
modal.setSubmitCallback(res => resolve({ code: ModalResultCode.SUCCESS, data: res }));
|
||||||
modal.setCloseCallback(err => {
|
modal.setCloseCallback(err => {
|
||||||
if (err) {
|
if (err) {
|
||||||
resolve({code: ModalResultCode.ERROR, error: err});
|
resolve({ code: ModalResultCode.ERROR, error: err });
|
||||||
}
|
}
|
||||||
resolve({code: ModalResultCode.CLOSE});
|
resolve({ code: ModalResultCode.CLOSE });
|
||||||
});
|
});
|
||||||
|
|
||||||
modal.open();
|
modal.open();
|
||||||
});
|
});
|
||||||
return {idSearchModalResult: res, idSearchModal: modal};
|
return { idSearchModalResult: res, idSearchModal: modal };
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -376,9 +379,12 @@ export class ModalHelper {
|
||||||
* @param submitCallback the callback that gets executed after the modal has been submitted, but after it has been closed
|
* @param submitCallback the callback that gets executed after the modal has been submitted, but after it has been closed
|
||||||
* @returns the user input or nothing and a reference to the modal.
|
* @returns the user input or nothing and a reference to the modal.
|
||||||
*/
|
*/
|
||||||
async openIdSearchModal(idSearchModalOptions: IdSearchModalOptions, submitCallback: (idSearchModalData: IdSearchModalData) => Promise<MediaTypeModel>): Promise<MediaTypeModel> {
|
async openIdSearchModal(
|
||||||
const {idSearchModalResult, idSearchModal} = await this.createIdSearchModal(idSearchModalOptions);
|
idSearchModalOptions: IdSearchModalOptions,
|
||||||
console.debug(`MDB | idSearchModal closed with code ${idSearchModalResult.code}`)
|
submitCallback: (idSearchModalData: IdSearchModalData) => Promise<MediaTypeModel>
|
||||||
|
): Promise<MediaTypeModel> {
|
||||||
|
const { idSearchModalResult, idSearchModal } = await this.createIdSearchModal(idSearchModalOptions);
|
||||||
|
console.debug(`MDB | idSearchModal closed with code ${idSearchModalResult.code}`);
|
||||||
|
|
||||||
if (idSearchModalResult.code === ModalResultCode.ERROR) {
|
if (idSearchModalResult.code === ModalResultCode.ERROR) {
|
||||||
// there was an error in the modal itself
|
// there was an error in the modal itself
|
||||||
|
|
@ -414,21 +420,21 @@ export class ModalHelper {
|
||||||
* @param selectModalOptions the options for the modal, see {@link SELECT_MODAL_OPTIONS_DEFAULT}
|
* @param selectModalOptions the options for the modal, see {@link SELECT_MODAL_OPTIONS_DEFAULT}
|
||||||
* @returns the user input or nothing and a reference to the modal.
|
* @returns the user input or nothing and a reference to the modal.
|
||||||
*/
|
*/
|
||||||
async createSelectModal(selectModalOptions: SelectModalOptions): Promise<{ selectModalResult: SelectModalResult, selectModal: MediaDbSearchResultModal }> {
|
async createSelectModal(selectModalOptions: SelectModalOptions): Promise<{ selectModalResult: SelectModalResult; selectModal: MediaDbSearchResultModal }> {
|
||||||
const modal = new MediaDbSearchResultModal(this.plugin, selectModalOptions);
|
const modal = new MediaDbSearchResultModal(this.plugin, selectModalOptions);
|
||||||
const res: SelectModalResult = await new Promise((resolve, reject) => {
|
const res: SelectModalResult = await new Promise((resolve, reject) => {
|
||||||
modal.setSubmitCallback(res => resolve({code: ModalResultCode.SUCCESS, data: res}));
|
modal.setSubmitCallback(res => resolve({ code: ModalResultCode.SUCCESS, data: res }));
|
||||||
modal.setSkipCallback(() => resolve({code: ModalResultCode.SKIP}));
|
modal.setSkipCallback(() => resolve({ code: ModalResultCode.SKIP }));
|
||||||
modal.setCloseCallback(err => {
|
modal.setCloseCallback(err => {
|
||||||
if (err) {
|
if (err) {
|
||||||
resolve({code: ModalResultCode.ERROR, error: err});
|
resolve({ code: ModalResultCode.ERROR, error: err });
|
||||||
}
|
}
|
||||||
resolve({code: ModalResultCode.CLOSE});
|
resolve({ code: ModalResultCode.CLOSE });
|
||||||
});
|
});
|
||||||
|
|
||||||
modal.open();
|
modal.open();
|
||||||
});
|
});
|
||||||
return {selectModalResult: res, selectModal: modal};
|
return { selectModalResult: res, selectModal: modal };
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -440,8 +446,8 @@ export class ModalHelper {
|
||||||
* @returns the user input or nothing and a reference to the modal.
|
* @returns the user input or nothing and a reference to the modal.
|
||||||
*/
|
*/
|
||||||
async openSelectModal(selectModalOptions: SelectModalOptions, submitCallback: (selectModalData: SelectModalData) => Promise<MediaTypeModel[]>): Promise<MediaTypeModel[]> {
|
async openSelectModal(selectModalOptions: SelectModalOptions, submitCallback: (selectModalData: SelectModalData) => Promise<MediaTypeModel[]>): Promise<MediaTypeModel[]> {
|
||||||
const {selectModalResult, selectModal} = await this.createSelectModal(selectModalOptions);
|
const { selectModalResult, selectModal } = await this.createSelectModal(selectModalOptions);
|
||||||
console.debug(`MDB | selectModal closed with code ${selectModalResult.code}`)
|
console.debug(`MDB | selectModal closed with code ${selectModalResult.code}`);
|
||||||
|
|
||||||
if (selectModalResult.code === ModalResultCode.ERROR) {
|
if (selectModalResult.code === ModalResultCode.ERROR) {
|
||||||
// there was an error in the modal itself
|
// there was an error in the modal itself
|
||||||
|
|
@ -474,26 +480,26 @@ export class ModalHelper {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async createPreviewModal(previewModalOptions: PreviewModalOptions): Promise<{ previewModalResult: PreviewModalResult, previewModal: MediaDbPreviewModal }> {
|
async createPreviewModal(previewModalOptions: PreviewModalOptions): Promise<{ previewModalResult: PreviewModalResult; previewModal: MediaDbPreviewModal }> {
|
||||||
//todo: handle attachFile for existing files
|
//todo: handle attachFile for existing files
|
||||||
const modal = new MediaDbPreviewModal(this.plugin, previewModalOptions);
|
const modal = new MediaDbPreviewModal(this.plugin, previewModalOptions);
|
||||||
const res: PreviewModalResult = await new Promise((resolve, reject) => {
|
const res: PreviewModalResult = await new Promise((resolve, reject) => {
|
||||||
modal.setSubmitCallback(res => resolve({code: ModalResultCode.SUCCESS, data: res}));
|
modal.setSubmitCallback(res => resolve({ code: ModalResultCode.SUCCESS, data: res }));
|
||||||
modal.setCloseCallback(err => {
|
modal.setCloseCallback(err => {
|
||||||
if (err) {
|
if (err) {
|
||||||
resolve({code: ModalResultCode.ERROR, error: err});
|
resolve({ code: ModalResultCode.ERROR, error: err });
|
||||||
}
|
}
|
||||||
resolve({code: ModalResultCode.CLOSE});
|
resolve({ code: ModalResultCode.CLOSE });
|
||||||
});
|
});
|
||||||
|
|
||||||
modal.open();
|
modal.open();
|
||||||
});
|
});
|
||||||
return {previewModalResult: res, previewModal: modal};
|
return { previewModalResult: res, previewModal: modal };
|
||||||
}
|
}
|
||||||
|
|
||||||
async openPreviewModal(previewModalOptions: PreviewModalOptions, submitCallback: (previewModalData: PreviewModalData) => Promise<boolean>): Promise<boolean> {
|
async openPreviewModal(previewModalOptions: PreviewModalOptions, submitCallback: (previewModalData: PreviewModalData) => Promise<boolean>): Promise<boolean> {
|
||||||
const {previewModalResult, previewModal} = await this.createPreviewModal(previewModalOptions);
|
const { previewModalResult, previewModal } = await this.createPreviewModal(previewModalOptions);
|
||||||
console.debug(`MDB | previewModal closed with code ${previewModalResult.code}`)
|
console.debug(`MDB | previewModal closed with code ${previewModalResult.code}`);
|
||||||
|
|
||||||
if (previewModalResult.code === ModalResultCode.ERROR) {
|
if (previewModalResult.code === ModalResultCode.ERROR) {
|
||||||
// there was an error in the modal itself
|
// there was an error in the modal itself
|
||||||
|
|
@ -521,4 +527,3 @@ export class ModalHelper {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
File diff suppressed because one or more lines are too long
34
styles.css
34
styles.css
|
|
@ -6,19 +6,17 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
.media-db-plugin-list-toggle {
|
.media-db-plugin-list-toggle {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.media-db-plugin-list-text-wrapper {
|
.media-db-plugin-list-text-wrapper {
|
||||||
flex: 1;
|
flex: 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
.media-db-plugin-list-text {
|
.media-db-plugin-list-text {
|
||||||
display: block;
|
display: block;
|
||||||
}
|
}
|
||||||
|
|
||||||
small.media-db-plugin-list-text{
|
small.media-db-plugin-list-text {
|
||||||
color: var(--text-muted);
|
color: var(--text-muted);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -68,33 +66,33 @@ small.media-db-plugin-list-text{
|
||||||
|
|
||||||
/* region property mappings */
|
/* region property mappings */
|
||||||
.media-db-plugin-property-mappings-model-container {
|
.media-db-plugin-property-mappings-model-container {
|
||||||
border: 1px solid var(--background-modifier-border);
|
border: 1px solid var(--background-modifier-border);
|
||||||
border-radius: 5px;
|
border-radius: 5px;
|
||||||
padding: 10px;
|
padding: 10px;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
}
|
}
|
||||||
|
|
||||||
.media-db-plugin-property-mappings-container {
|
.media-db-plugin-property-mappings-container {
|
||||||
margin: 10px 0;
|
margin: 10px 0;
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
gap: 5px;
|
gap: 5px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.media-db-plugin-property-mapping-element {
|
.media-db-plugin-property-mapping-element {
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: row;
|
flex-direction: row;
|
||||||
gap: 10px;
|
gap: 10px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.media-db-plugin-property-mapping-element-property-name-wrapper {
|
.media-db-plugin-property-mapping-element-property-name-wrapper {
|
||||||
min-width: 160px;
|
min-width: 160px;
|
||||||
background: var(--background-modifier-form-field);
|
background: var(--background-modifier-form-field);
|
||||||
padding: 2px 5px;
|
padding: 2px 5px;
|
||||||
border-radius: 5px;
|
border-radius: 5px;
|
||||||
|
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
}
|
}
|
||||||
|
|
||||||
.media-db-plugin-property-mapping-element-property-name {
|
.media-db-plugin-property-mapping-element-property-name {
|
||||||
|
|
@ -106,12 +104,12 @@ small.media-db-plugin-list-text{
|
||||||
}
|
}
|
||||||
|
|
||||||
.media-db-plugin-property-mapping-to {
|
.media-db-plugin-property-mapping-to {
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
}
|
}
|
||||||
|
|
||||||
.media-db-plugin-property-mapping-validation {
|
.media-db-plugin-property-mapping-validation {
|
||||||
color: var(--text-error);
|
color: var(--text-error);
|
||||||
margin-bottom: 5px;
|
margin-bottom: 5px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,10 +1,6 @@
|
||||||
{
|
{
|
||||||
"compilerOptions": {
|
"compilerOptions": {
|
||||||
"types": [
|
"types": ["svelte", "node", "jest"],
|
||||||
"svelte",
|
|
||||||
"node",
|
|
||||||
"jest"
|
|
||||||
],
|
|
||||||
"baseUrl": ".",
|
"baseUrl": ".",
|
||||||
"inlineSourceMap": true,
|
"inlineSourceMap": true,
|
||||||
"inlineSources": true,
|
"inlineSources": true,
|
||||||
|
|
@ -17,14 +13,7 @@
|
||||||
"isolatedModules": true,
|
"isolatedModules": true,
|
||||||
"esModuleInterop": true,
|
"esModuleInterop": true,
|
||||||
"resolveJsonModule": true,
|
"resolveJsonModule": true,
|
||||||
"lib": [
|
"lib": ["DOM", "ES5", "ES6", "ES7"]
|
||||||
"DOM",
|
|
||||||
"ES5",
|
|
||||||
"ES6",
|
|
||||||
"ES7"
|
|
||||||
]
|
|
||||||
},
|
},
|
||||||
"include": [
|
"include": ["**/*.ts"]
|
||||||
"**/*.ts"
|
|
||||||
]
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,14 +1,14 @@
|
||||||
import { readFileSync, writeFileSync } from "fs";
|
import { readFileSync, writeFileSync } from 'fs';
|
||||||
|
|
||||||
const targetVersion = process.env.npm_package_version;
|
const targetVersion = process.env.npm_package_version;
|
||||||
|
|
||||||
// read minAppVersion from manifest.json and bump version to target version
|
// read minAppVersion from manifest.json and bump version to target version
|
||||||
let manifest = JSON.parse(readFileSync("manifest.json", "utf8"));
|
let manifest = JSON.parse(readFileSync('manifest.json', 'utf8'));
|
||||||
const { minAppVersion } = manifest;
|
const { minAppVersion } = manifest;
|
||||||
manifest.version = targetVersion;
|
manifest.version = targetVersion;
|
||||||
writeFileSync("manifest.json", JSON.stringify(manifest, null, "\t"));
|
writeFileSync('manifest.json', JSON.stringify(manifest, null, '\t'));
|
||||||
|
|
||||||
// update versions.json with target version and minAppVersion from manifest.json
|
// update versions.json with target version and minAppVersion from manifest.json
|
||||||
let versions = JSON.parse(readFileSync("versions.json", "utf8"));
|
let versions = JSON.parse(readFileSync('versions.json', 'utf8'));
|
||||||
versions[targetVersion] = minAppVersion;
|
versions[targetVersion] = minAppVersion;
|
||||||
writeFileSync("versions.json", JSON.stringify(versions, null, "\t"));
|
writeFileSync('versions.json', JSON.stringify(versions, null, '\t'));
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue