2 Commits
Author SHA1 Message Date
oqyude 23cf742569 license and fixup 2026-07-11 03:05:42 +03:00
oqyude 2dec5660f6 ru + en lang 2026-07-11 02:54:10 +03:00
9 changed files with 161 additions and 109 deletions
-63
View File
@@ -1,63 +0,0 @@
name: Draft Release
on:
push:
branches: [master]
jobs:
draft:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 20
- run: npm ci
- run: npm run build
- run: zip -j zeroq-qol-modules.zip main.js manifest.json styles.css
- name: Create or update draft release
env:
GITEA_TOKEN: ${{ secrets.GITEA_TOKEN }}
run: |
set -e
API="${GITHUB_SERVER_URL}/api/v1/repos/${GITHUB_REPOSITORY}"
TAG="latest-build"
SHA="${GITHUB_SHA}"
EXISTING=$(curl -s -H "Authorization: token ${GITEA_TOKEN}" \
"${API}/releases" \
| jq '.[] | select(.tag_name == "'"${TAG}"'" and .draft == true) | .id')
if [ -z "$EXISTING" ]; then
echo "Creating new draft release..."
RESP=$(curl -s -X POST -H "Authorization: token ${GITEA_TOKEN}" \
-H "Content-Type: application/json" \
-d '{
"tag_name": "'"${TAG}"'",
"name": "Latest Build from master",
"body": "Автоматическая сборка из ветки `master`.\n\nКоммит: '"${SHA}"'",
"draft": true,
"prerelease": true
}' "${API}/releases")
RELEASE_ID=$(echo "$RESP" | jq -r '.id')
else
echo "Updating existing draft release (id: ${EXISTING})..."
RELEASE_ID=$EXISTING
curl -s -X PATCH -H "Authorization: token ${GITEA_TOKEN}" \
-H "Content-Type: application/json" \
-d '{
"body": "Автоматическая сборка из ветки `master`.\n\nКоммит: '"${SHA}"'"
}' "${API}/releases/${RELEASE_ID}"
ASSETS=$(curl -s -H "Authorization: token ${GITEA_TOKEN}" \
"${API}/releases/${RELEASE_ID}/assets" | jq -r '.[].id')
for AID in $ASSETS; do
curl -s -X DELETE -H "Authorization: token ${GITEA_TOKEN}" \
"${API}/releases/${RELEASE_ID}/assets/${AID}"
done
fi
echo "Uploading artifact..."
curl -s -X POST -H "Authorization: token ${GITEA_TOKEN}" \
-F "attachment=@zeroq-qol-modules.zip" \
"${API}/releases/${RELEASE_ID}/assets"
echo "Done."
+21
View File
@@ -0,0 +1,21 @@
MIT License
Copyright (c) 2026
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
+57 -32
View File
@@ -2,35 +2,71 @@
Модульный плагин для **Obsidian** с набором QoL-функций, которые можно включать и отключать в настройках.
## Установка
Modular **Obsidian** plugin with toggleable QoL modules in settings.
## Установка / Installation
1. Скачайте `main.js`, `manifest.json` и `styles.css` из [релизов](https://github.com/your/repo/releases)
2. Поместите их в папку `.obsidian/plugins/zeroq-qol-modules/` вашего хранилища
3. В Obsidian: **Настройки****Community plugins****Включить**
4. Активируйте плагин **ZeroQ QoL Modules**
## Модули
## Язык / Language
| Модуль | Описание |
|--------|----------|
| **Attachment Clean Paste** | Заменяет `![[вложение]]` на `[[вложение|имя]]` при вставке/перетаскивании файлов с указанными расширениями |
Язык плагина синхронизируется с **языком интерфейса Obsidian** (Settings → About → Language).
- Obsidian на русском → плагин на русском
- Obsidian на другом языке → плагин на английском
The plugin language syncs with **Obsidian's UI language** setting.
- Obsidian in English → plugin in English
- Obsidian in any other language → falls back to English
## Модули / Modules
- **Attachment Clean Paste** — Заменяет `![[embed]]` на `[[path/file|name]]` для файлов с указанными расширениями при вставке/перетаскивании
Каждый модуль включается/отключается в настройках плагина.
## Разработка
## Разработка / Development
### Добавление нового модуля
### Архитектура / Architecture
```
src/
├── main.ts # точка входа, Plugin class
├── settings.ts # общая панель настроек
├── types.ts # базовые типы
├── locales/
│ ├── en.ts # тип Locale + EN-словарь
│ ├── ru.ts # RU-словарь
│ └── index.ts # авто-определение языка
└── modules/
├── index.ts # реестр модулей (статический импорт)
├── base-module.ts # абстрактный класс модуля
└── attachment-clean-paste/
└── index.ts # реализация модуля
```
**Принцип работы:**
- `main.ts` загружает настройки, итерирует `MODULES` и вызывает `onload()` для включённых
- Каждый модуль через `registerCleanup()` регистрирует функции очистки, которые вызываются при выключении модуля или выгрузке плагина
- В настройках отображаются все модули с чекбоксами вкл/выкл
### Добавление нового модуля / Adding a module
1. Создайте папку `src/modules/my-module/`
2. Создайте класс, унаследованный от `BaseModule`:
```typescript
import { BaseModule } from '../base-module';
import { locale } from '../../locales';
export class MyModule extends BaseModule {
id = 'my-module';
name = 'My Module';
description = 'Описание модуля';
name = locale.modules['my-module'].name;
description = locale.modules['my-module'].description;
get defaultSettings() {
return { /* настройки по умолчанию */ };
@@ -46,7 +82,8 @@ export class MyModule extends BaseModule {
}
```
3. Зарегистрируйте модуль в `src/modules/index.ts`:
3. Добавьте переводы в `src/locales/en.ts` и `src/locales/ru.ts`
4. Зарегистрируйте модуль в `src/modules/index.ts`:
```typescript
import { MyModule } from './my-module';
@@ -57,34 +94,22 @@ export const MODULES: QoLModule[] = [
];
```
4. Если модулю нужна своя вкладка настроек — создайте `PluginSettingTab` и добавьте её через `plugin.addSettingTab()` в `onload`
### Добавление нового языка / Adding a language
### Сборка
1. Создайте `src/locales/de.ts` со структурой `Locale`
2. Импортируйте и добавьте в словарь в `src/locales/index.ts`:
```typescript
import { de } from './de';
const locales: Record<string, Locale> = { en, ru, de };
```
### Сборка / Build
```bash
npm run build # production-сборка
npm run dev # dev-сборка с sourcemap
```
### Архитектура
```
src/
├── main.ts # точка входа, Plugin class
├── settings.ts # общая панель настроек
├── types.ts # базовые типы
└── modules/
├── index.ts # реестр модулей (статический импорт)
├── base-module.ts # абстрактный класс модуля
└── attachment-clean-paste/
└── index.ts # реализация модуля
```
**Принцип работы:**
- `main.ts` загружает настройки, итерирует `MODULES` и вызывает `onload()` для включённых
- Каждый модуль через `registerCleanup()` регистрирует функции отчистки, которые вызываются при выключении модуля или выгрузке плагина
- В настройках отображаются все модули с чекбоксами вкл/выкл
## Лицензия
## Лицензия / License
MIT
+36
View File
@@ -0,0 +1,36 @@
export interface Locale {
settings: {
title: string;
description: string;
};
modules: {
'attachment-clean-paste': {
name: string;
description: string;
descriptionShort: string;
extensionsLabel: string;
extensionsDesc: string;
extensionsPlaceholder: string;
};
};
}
export const en: Locale = {
settings: {
title: 'ZeroQ QoL Modules',
description: 'Enable or disable modules as you wish.',
},
modules: {
'attachment-clean-paste': {
name: 'Attachment Clean Paste',
description:
'Replaces ![[embed]] with [[path/file|name]] for configured file extensions on paste/drop',
descriptionShort:
'Replaces ![[embed]] with [[path/file|name]] for specified file extensions.',
extensionsLabel: 'File extensions',
extensionsDesc:
'Comma-separated extensions (e.g.: png, jpg, pdf, mp3). Files with these extensions will be inserted as [[path/file|name]] instead of ![[path/file]].',
extensionsPlaceholder: 'png, jpg, jpeg, gif, svg, webp, pdf',
},
},
};
+12
View File
@@ -0,0 +1,12 @@
import { en, Locale } from './en';
import { ru } from './ru';
const locales: Record<string, Locale> = { en, ru };
function detectLocale(): Locale {
const lang = (document.documentElement.lang || 'en').slice(0, 2);
return locales[lang] || en;
}
export const locale = detectLocale();
export type { Locale };
+21
View File
@@ -0,0 +1,21 @@
import { Locale } from './en';
export const ru: Locale = {
settings: {
title: 'ZeroQ QoL Modules',
description: 'Включайте и отключайте модули по своему усмотрению.',
},
modules: {
'attachment-clean-paste': {
name: 'Attachment Clean Paste',
description:
'Заменяет ![[вложение]] на [[вложение|имя]] для указанных расширений при вставке/перетаскивании',
descriptionShort:
'Заменяет ![[вложение]] на [[вложение|имя]] для указанных расширений.',
extensionsLabel: 'Расширения файлов',
extensionsDesc:
'Расширения через запятую (например: png, jpg, pdf, mp3). Файлы с этими расширениями будут вставляться как [[path/file|name]] вместо ![[path/file]].',
extensionsPlaceholder: 'png, jpg, jpeg, gif, svg, webp, pdf',
},
},
};
+10 -10
View File
@@ -10,6 +10,7 @@ import {
} from 'obsidian';
import type ZeroQoLModulesPlugin from '../../main';
import { BaseModule } from '../base-module';
import { locale } from '../../locales';
const MODULE_ID = 'attachment-clean-paste';
@@ -19,9 +20,8 @@ interface AttachmentCleanPasteSettings {
export class AttachmentCleanPasteModule extends BaseModule {
id = MODULE_ID;
name = 'Attachment Clean Paste';
description =
'Заменяет ![[вложение]] на [[вложение|имя]] для указанных расширений при вставке/перетаскивании';
name = locale.modules['attachment-clean-paste'].name;
description = locale.modules['attachment-clean-paste'].description;
private app: App;
@@ -170,9 +170,11 @@ class AttachmentCleanPasteSettingTab extends PluginSettingTab {
const { containerEl } = this;
containerEl.empty();
containerEl.createEl('h2', { text: 'Attachment Clean Paste' });
const loc = locale.modules['attachment-clean-paste'];
containerEl.createEl('h2', { text: loc.name });
containerEl.createEl('p', {
text: 'Заменяет ![[вложение]] на [[вложение|имя]] для указанных расширений.',
text: loc.descriptionShort,
attr: { style: 'color: var(--text-muted); margin-bottom: 20px;' },
});
@@ -181,13 +183,11 @@ class AttachmentCleanPasteSettingTab extends PluginSettingTab {
| undefined;
new Setting(containerEl)
.setName('Расширения файлов')
.setDesc(
'Расширения через запятую (например: png, jpg, pdf, mp3). Файлы с этими расширениями будут вставляться как [[path/file|name]] вместо ![[path/file]].',
)
.setName(loc.extensionsLabel)
.setDesc(loc.extensionsDesc)
.addTextArea((textarea) => {
textarea
.setPlaceholder('png, jpg, jpeg, gif, svg, webp, pdf')
.setPlaceholder(loc.extensionsPlaceholder)
.setValue(rawSettings?.extensions ?? '')
.onChange(async (value) => {
if (this.plugin.settings.modules[this.moduleId]) {
+3 -2
View File
@@ -2,6 +2,7 @@ import { App, PluginSettingTab, Setting } from 'obsidian';
import type ZeroQoLModulesPlugin from './main';
import { MODULES } from './modules';
import { ZeroQSettings } from './types';
import { locale } from './locales';
const MODULE_DEFAULTS = MODULES.reduce(
(acc, mod) => {
@@ -37,9 +38,9 @@ export class ZeroQSettingTab extends PluginSettingTab {
const { containerEl } = this;
containerEl.empty();
containerEl.createEl('h1', { text: 'ZeroQ QoL Modules' });
containerEl.createEl('h1', { text: locale.settings.title });
containerEl.createEl('p', {
text: 'Включайте и отключайте модули по своему усмотрению.',
text: locale.settings.description,
attr: { style: 'color: var(--text-muted); margin-bottom: 20px;' },
});
+1 -2
View File
@@ -1,13 +1,12 @@
{
"compilerOptions": {
"baseUrl": ".",
"inlineSourceMap": true,
"inlineSources": true,
"module": "ESNext",
"target": "ES6",
"allowJs": true,
"noImplicitAny": true,
"moduleResolution": "node",
"moduleResolution": "bundler",
"importHelpers": true,
"lib": ["DOM", "ES5", "ES6", "ES7"],
"allowSyntheticDefaultImports": true,