Refactor packages
Signed-off-by: Nikolaos Karaolidis <nick@karaolidis.com>
This commit is contained in:
37
packages/obsidian/plugins/languagetool/default.nix
Normal file
37
packages/obsidian/plugins/languagetool/default.nix
Normal file
@@ -0,0 +1,37 @@
|
||||
{ pkgs, ... }:
|
||||
# AUTO-UPDATE: nix-update --flake obsidian-plugin-languagetool
|
||||
pkgs.stdenv.mkDerivation rec {
|
||||
pname = "obsidian-plugin-languagetool";
|
||||
version = "0.3.7";
|
||||
|
||||
src = pkgs.fetchFromGitHub {
|
||||
owner = "Clemens-E";
|
||||
repo = "obsidian-languagetool-plugin";
|
||||
rev = version;
|
||||
hash = "sha256-OsdOOrXNoraKuFPqvgn6pj6ZagEbiFCJyQ529eyZXUU=";
|
||||
};
|
||||
|
||||
patches = [
|
||||
./settings-notification.patch
|
||||
./variety-typo.patch
|
||||
];
|
||||
|
||||
offlineCache = pkgs.fetchYarnDeps {
|
||||
yarnLock = src + "/yarn.lock";
|
||||
hash = "sha256-749RGQmg9Mte7TR6k3qP6xcb8+rj/C60LYLbF8j8gNc=";
|
||||
};
|
||||
|
||||
nativeBuildInputs = with pkgs; [
|
||||
nodejs
|
||||
yarnConfigHook
|
||||
yarnBuildHook
|
||||
npmHooks.npmInstallHook
|
||||
];
|
||||
|
||||
installPhase = ''
|
||||
mkdir -p $out
|
||||
cp ./manifest.json $out/manifest.json
|
||||
cp ./main.js $out/main.js
|
||||
cp ./styles.css $out/styles.css
|
||||
'';
|
||||
}
|
@@ -0,0 +1,12 @@
|
||||
diff --git a/src/index.ts b/src/index.ts
|
||||
index 00cccfe..43e6107 100644
|
||||
--- a/src/index.ts
|
||||
+++ b/src/index.ts
|
||||
@@ -42,7 +42,6 @@ export default class LanguageToolPlugin extends Plugin {
|
||||
try {
|
||||
await this.saveSettings();
|
||||
await this.loadSettings();
|
||||
- new Notice('updated LanguageTool Settings, please confirm your server URL in the settings tab', 10000);
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
}
|
149
packages/obsidian/plugins/languagetool/variety-typo.patch
Normal file
149
packages/obsidian/plugins/languagetool/variety-typo.patch
Normal file
@@ -0,0 +1,149 @@
|
||||
diff --git a/src/SettingsTab.ts b/src/SettingsTab.ts
|
||||
index d0d65bb..2a211b0 100644
|
||||
--- a/src/SettingsTab.ts
|
||||
+++ b/src/SettingsTab.ts
|
||||
@@ -33,10 +33,10 @@ export interface LanguageToolPluginSettings {
|
||||
staticLanguage?: string;
|
||||
motherTongue?: string;
|
||||
|
||||
- englishVeriety?: undefined | 'en-US' | 'en-GB' | 'en-CA' | 'en-AU' | 'en-ZA' | 'en-NZ';
|
||||
- germanVeriety?: undefined | 'de-DE' | 'de-AT' | 'de-CH';
|
||||
- portugueseVeriety?: undefined | 'pt-BR' | 'pt-PT' | 'pt-AO' | 'pt-MZ';
|
||||
- catalanVeriety?: undefined | 'ca-ES' | 'ca-ES-valencia';
|
||||
+ englishVariety?: undefined | 'en-US' | 'en-GB' | 'en-CA' | 'en-AU' | 'en-ZA' | 'en-NZ';
|
||||
+ germanVariety?: undefined | 'de-DE' | 'de-AT' | 'de-CH';
|
||||
+ portugueseVariety?: undefined | 'pt-BR' | 'pt-PT' | 'pt-AO' | 'pt-MZ';
|
||||
+ catalanVariety?: undefined | 'ca-ES' | 'ca-ES-valencia';
|
||||
|
||||
pickyMode: boolean;
|
||||
|
||||
@@ -286,13 +286,13 @@ export class LanguageToolSettingsTab extends PluginSettingTab {
|
||||
component.onChange(async value => {
|
||||
this.plugin.settings.staticLanguage = value;
|
||||
if (value !== 'auto') {
|
||||
- this.plugin.settings.englishVeriety = undefined;
|
||||
+ this.plugin.settings.englishVariety = undefined;
|
||||
englishVarietyDropdown?.setValue('default');
|
||||
- this.plugin.settings.germanVeriety = undefined;
|
||||
+ this.plugin.settings.germanVariety = undefined;
|
||||
germanVarietyDropdown?.setValue('default');
|
||||
- this.plugin.settings.portugueseVeriety = undefined;
|
||||
+ this.plugin.settings.portugueseVariety = undefined;
|
||||
portugueseVarietyDropdown?.setValue('default');
|
||||
- this.plugin.settings.catalanVeriety = undefined;
|
||||
+ this.plugin.settings.catalanVariety = undefined;
|
||||
catalanVarietyDropdown?.setValue('default');
|
||||
}
|
||||
await this.plugin.saveSettings();
|
||||
@@ -338,14 +338,14 @@ export class LanguageToolSettingsTab extends PluginSettingTab {
|
||||
'en-ZA': 'English (South Africa)',
|
||||
'en-NZ': 'English (New Zealand)',
|
||||
})
|
||||
- .setValue(this.plugin.settings.englishVeriety ?? 'default')
|
||||
+ .setValue(this.plugin.settings.englishVariety ?? 'default')
|
||||
.onChange(async value => {
|
||||
if (value === 'default') {
|
||||
- this.plugin.settings.englishVeriety = undefined;
|
||||
+ this.plugin.settings.englishVariety = undefined;
|
||||
} else {
|
||||
this.plugin.settings.staticLanguage = 'auto';
|
||||
staticLanguageComponent?.setValue('auto');
|
||||
- this.plugin.settings.englishVeriety = value as 'en-US' | 'en-GB' | 'en-CA' | 'en-AU' | 'en-ZA' | 'en-NZ';
|
||||
+ this.plugin.settings.englishVariety = value as 'en-US' | 'en-GB' | 'en-CA' | 'en-AU' | 'en-ZA' | 'en-NZ';
|
||||
}
|
||||
await this.plugin.saveSettings();
|
||||
});
|
||||
@@ -360,14 +360,14 @@ export class LanguageToolSettingsTab extends PluginSettingTab {
|
||||
'de-CH': 'German (Switzerland)',
|
||||
'de-AT': 'German (Austria)',
|
||||
})
|
||||
- .setValue(this.plugin.settings.germanVeriety ?? 'default')
|
||||
+ .setValue(this.plugin.settings.germanVariety ?? 'default')
|
||||
.onChange(async value => {
|
||||
if (value === 'default') {
|
||||
- this.plugin.settings.germanVeriety = undefined;
|
||||
+ this.plugin.settings.germanVariety = undefined;
|
||||
} else {
|
||||
this.plugin.settings.staticLanguage = 'auto';
|
||||
staticLanguageComponent?.setValue('auto');
|
||||
- this.plugin.settings.germanVeriety = value as 'de-DE' | 'de-CH' | 'de-AT';
|
||||
+ this.plugin.settings.germanVariety = value as 'de-DE' | 'de-CH' | 'de-AT';
|
||||
}
|
||||
await this.plugin.saveSettings();
|
||||
});
|
||||
@@ -383,14 +383,14 @@ export class LanguageToolSettingsTab extends PluginSettingTab {
|
||||
'pt-AO': 'Portuguese (Angola)',
|
||||
'pt-MZ': 'Portuguese (Mozambique)',
|
||||
})
|
||||
- .setValue(this.plugin.settings.portugueseVeriety ?? 'default')
|
||||
+ .setValue(this.plugin.settings.portugueseVariety ?? 'default')
|
||||
.onChange(async value => {
|
||||
if (value === 'default') {
|
||||
- this.plugin.settings.portugueseVeriety = undefined;
|
||||
+ this.plugin.settings.portugueseVariety = undefined;
|
||||
} else {
|
||||
this.plugin.settings.staticLanguage = 'auto';
|
||||
staticLanguageComponent?.setValue('auto');
|
||||
- this.plugin.settings.portugueseVeriety = value as 'pt-BR' | 'pt-PT' | 'pt-AO' | 'pt-MZ';
|
||||
+ this.plugin.settings.portugueseVariety = value as 'pt-BR' | 'pt-PT' | 'pt-AO' | 'pt-MZ';
|
||||
}
|
||||
await this.plugin.saveSettings();
|
||||
});
|
||||
@@ -404,14 +404,14 @@ export class LanguageToolSettingsTab extends PluginSettingTab {
|
||||
'ca-ES': 'Catalan',
|
||||
'ca-ES-valencia': 'Catalan (Valencian)',
|
||||
})
|
||||
- .setValue(this.plugin.settings.catalanVeriety ?? 'default')
|
||||
+ .setValue(this.plugin.settings.catalanVariety ?? 'default')
|
||||
.onChange(async value => {
|
||||
if (value === 'default') {
|
||||
- this.plugin.settings.catalanVeriety = undefined;
|
||||
+ this.plugin.settings.catalanVariety = undefined;
|
||||
} else {
|
||||
this.plugin.settings.staticLanguage = 'auto';
|
||||
staticLanguageComponent?.setValue('auto');
|
||||
- this.plugin.settings.catalanVeriety = value as 'ca-ES' | 'ca-ES-valencia';
|
||||
+ this.plugin.settings.catalanVariety = value as 'ca-ES' | 'ca-ES-valencia';
|
||||
}
|
||||
await this.plugin.saveSettings();
|
||||
});
|
||||
diff --git a/src/api.ts b/src/api.ts
|
||||
index 109984c..4cd1700 100644
|
||||
--- a/src/api.ts
|
||||
+++ b/src/api.ts
|
||||
@@ -58,27 +58,27 @@ export async function getDetectionResult(
|
||||
params.disabledRules = settings.ruleOtherDisabledRules;
|
||||
}
|
||||
|
||||
- if (settings.englishVeriety) {
|
||||
+ if (settings.englishVariety) {
|
||||
params.preferredVariants = `${params.preferredVariants ? `${params.preferredVariants},` : ''}${
|
||||
- settings.englishVeriety
|
||||
+ settings.englishVariety
|
||||
}`;
|
||||
}
|
||||
|
||||
- if (settings.germanVeriety) {
|
||||
+ if (settings.germanVariety) {
|
||||
params.preferredVariants = `${params.preferredVariants ? `${params.preferredVariants},` : ''}${
|
||||
- settings.germanVeriety
|
||||
+ settings.germanVariety
|
||||
}`;
|
||||
}
|
||||
|
||||
- if (settings.portugueseVeriety) {
|
||||
+ if (settings.portugueseVariety) {
|
||||
params.preferredVariants = `${params.preferredVariants ? `${params.preferredVariants},` : ''}${
|
||||
- settings.portugueseVeriety
|
||||
+ settings.portugueseVariety
|
||||
}`;
|
||||
}
|
||||
|
||||
- if (settings.catalanVeriety) {
|
||||
+ if (settings.catalanVariety) {
|
||||
params.preferredVariants = `${params.preferredVariants ? `${params.preferredVariants},` : ''}${
|
||||
- settings.catalanVeriety
|
||||
+ settings.catalanVariety
|
||||
}`;
|
||||
}
|
||||
|
Reference in New Issue
Block a user