Skip to content

Commit

Permalink
WIP: disable NextCloud provider for now
Browse files Browse the repository at this point in the history
  • Loading branch information
joethei committed Jul 15, 2023
1 parent 5a9c676 commit b7566fb
Show file tree
Hide file tree
Showing 11 changed files with 33 additions and 30 deletions.
5 changes: 2 additions & 3 deletions src/l10n/locale.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,8 @@ const localeMap: { [k: string]: Partial<typeof en> } = {
fr,
es,
test,
fr,
pt
it
pt,
it,
da
};

Expand Down
10 changes: 6 additions & 4 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ export default class RssReaderPlugin extends Plugin {
this.providers = new Providers(this);

this.providers.register(new LocalFeedProvider(this));
this.providers.register(new NextcloudFeedProvider(this));
//this.providers.register(new NextcloudFeedProvider(this));

this.addCommand({
id: "rss-open",
Expand Down Expand Up @@ -83,14 +83,16 @@ export default class RssReaderPlugin extends Plugin {
callback: async () => {
const input = new TextInputPrompt(this.app, "URL", "URL", "", "", t("open"));
await input.openAndGetValue(async (text) => {
const items = await getFeedItems({name: "", folder: "", url: text.getValue()});
if (!items || items.items.length === 0) {
const provider = await this.providers.getById('local') as LocalFeedProvider;
const feed = await provider.feedFromUrl(text.getValue());
const items = feed.items();
if (!items || items.length === 0) {
input.setValidationError(text, t("invalid_feed"));
return;
}

input.close();
new ArticleSuggestModal(this, items.items).open();
new ArticleSuggestModal(this, items).open();
});
}
});
Expand Down
5 changes: 2 additions & 3 deletions src/modals/ArticleSuggestModal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,8 @@ import {ItemModal} from "./ItemModal";
import {Item} from "../providers/Item";

export class ArticleSuggestModal extends SuggestModal<Item> {

plugin: RssReaderPlugin;
items: Item[];
protected readonly plugin: RssReaderPlugin;
protected readonly items: Item[];

constructor(plugin: RssReaderPlugin, items: Item[]) {
super(plugin.app);
Expand Down
1 change: 0 additions & 1 deletion src/modals/BaseModal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import {AbstractTextComponent, Modal} from "obsidian";

export class BaseModal extends Modal {


//taken from github.com/valentine195/obsidian-admonition
setValidationError(input: AbstractTextComponent<any>, message?: string) : void {
input.inputEl.addClass("is-invalid");
Expand Down
4 changes: 0 additions & 4 deletions src/providers/Article.ts

This file was deleted.

2 changes: 0 additions & 2 deletions src/providers/Item.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,6 @@ export interface Item {
markCreated(created: boolean): void;
language(): string | undefined;
highlights(): string[];
description(): string;
folder(): string;
feed(): string;
language(): string | undefined;
}
10 changes: 7 additions & 3 deletions src/providers/Providers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,15 @@ export class Providers {
return this.providers;
}

getCurrent() : FeedProvider {
return this.providers.filter(provider => provider.id() === this.plugin.settings.provider).first();
getCurrent(): FeedProvider {
return this.getById(this.plugin.settings.provider);
}

register(provider: FeedProvider) : void {
getById(id: string): FeedProvider {
return this.providers.filter(provider => provider.id() === id).first();
}

register(provider: FeedProvider): void {
this.providers.push(provider);
}

Expand Down
14 changes: 12 additions & 2 deletions src/providers/local/LocalFeedProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,16 @@ export class LocalFeedProvider implements FeedProvider {
return result;
}

async feedFromUrl(url: string): Promise<Feed> {
const feed = {
name: '',
url,
folder: '',
}
const content = await getFeedItems(feed);
return new LocalFeed(content);
}

async filteredFolders(): Promise<Folder[]> {
return [];
}
Expand All @@ -50,7 +60,7 @@ export class LocalFeedProvider implements FeedProvider {
const feeds = await this.feeds();
const grouped = groupBy(feeds, item => item.folderName());

for(const key of Object.keys(grouped)) {
for (const key of Object.keys(grouped)) {
const folderContent = grouped[key];
result.push(new LocalFolder(key, folderContent));
}
Expand All @@ -65,7 +75,7 @@ export class LocalFeedProvider implements FeedProvider {
return [];
}

settings(containerEl: HTMLDivElement) : SettingsSection {
settings(containerEl: HTMLDivElement): SettingsSection {
return new LocalFeedSettings(this.plugin, containerEl);
}

Expand Down
7 changes: 2 additions & 5 deletions src/settings/ProviderSettings.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import {SettingsSection} from "./SettingsSection";
import {Setting} from "obsidian";
import t from "../l10n/locale";

export class ProviderSettings extends SettingsSection {
Expand All @@ -11,7 +10,7 @@ export class ProviderSettings extends SettingsSection {
display(): void {
this.contentEl.empty();

new Setting(this.contentEl)
/* new Setting(this.contentEl)
.setName(t("provider"))
.addDropdown(dropdown => {
for (const feedProvider of this.plugin.providers.getAll()) {
Expand All @@ -24,9 +23,7 @@ export class ProviderSettings extends SettingsSection {
await this.plugin.saveSettings();
this.display();
})
});

this.contentEl.createEl("hr", {cls: "rss-divider"});
});*/

const providerEl = this.contentEl.createDiv();

Expand Down
1 change: 0 additions & 1 deletion src/settings/SettingsTab.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import {
PluginSettingTab,
} from "obsidian";
import RssReaderPlugin from "../main";
import t from "../l10n/locale";
import {HotkeySettings} from "./HotkeySettings";
import {ProviderSettings} from "./ProviderSettings";
import {FileCreationSettings} from "./FileCreationSettings";
Expand Down
4 changes: 2 additions & 2 deletions src/settings/suggest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,8 @@ export abstract class TextInputSuggest<T> implements ISuggestOwner<T> {
protected inputEl: HTMLInputElement | HTMLTextAreaElement;

private popper: PopperInstance;
private scope: Scope;
private suggestEl: HTMLElement;
private readonly scope: Scope;
private readonly suggestEl: HTMLElement;
private suggest: Suggest<T>;

constructor(app: App, inputEl: HTMLInputElement | HTMLTextAreaElement) {
Expand Down

0 comments on commit b7566fb

Please sign in to comment.