Skip to content
This repository was archived by the owner on Aug 25, 2025. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added .DS_Store
Binary file not shown.
27 changes: 16 additions & 11 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,20 @@
module.exports = {
root: true,
parser: "@typescript-eslint/parser",
plugins: ["@typescript-eslint"],
extends: ["eslint:recommended", "plugin:@typescript-eslint/recommended"],
rules: {
"@typescript-eslint/no-unused-vars": [
2,
{ args: "all", argsIgnorePattern: "^_" },
],
"no-useless-escape": "off",
"@typescript-eslint/no-explicit-any": "off",
"@typescript-eslint/ban-ts-comment": "off",
parser: '@typescript-eslint/parser',
plugins: [
'@typescript-eslint'
],
extends: [
'eslint:recommended',
'plugin:@typescript-eslint/recommended',
'plugin:@typescript-eslint/recommended-requiring-type-checking'
],
parserOptions: {
project: './tsconfig.json'
},
rules: {
'@typescript-eslint/no-unused-vars': ['error', { argsIgnorePattern: '^_' }],
'@typescript-eslint/ban-ts-comment': 'warn',
'@typescript-eslint/no-explicit-any': 'warn'
}
};
19 changes: 19 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Changelog

## [Unreleased]
### Added
- Magazine view improvements with consistent card sizing and better image handling (@sidneyer)
- Right-aligned image display with text wrapping in item modal (@sidneyer)
- Enhanced typography and spacing throughout the UI (@sidneyer)

### Changed
- Standardized on magazine view as the only view option (@sidneyer)
- Simplified settings interface by removing display style options (@sidneyer)

### Fixed
- Note creation functionality (@sidneyer)
- Template variable handling (@sidneyer)
- Improved error handling (@sidneyer)

## [1.2.2] - 2022-06-27
- Previous release notes would go here...
14 changes: 10 additions & 4 deletions esbuild.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ const copyManifest = {
},
};

esbuild.build({
const ctx = await esbuild.context({
banner: {
js: banner,
},
Expand All @@ -65,10 +65,16 @@ esbuild.build({
preprocess: sveltePreprocess()
}), copyManifest, copyMinifiedCSS],
format: 'cjs',
watch: !prod,
target: 'es2016',
target: 'es2020',
logLevel: "info",
sourcemap: prod ? false : 'inline',
treeShaking: true,
outfile: 'build/main.js',
}).catch(() => process.exit(1));
});

if (prod) {
await ctx.rebuild();
await ctx.dispose();
} else {
await ctx.watch();
}
23 changes: 16 additions & 7 deletions jest.config.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,18 @@
module.exports = {
transform: {"\\.ts$": ['ts-jest']},
collectCoverage: true,
testEnvironment: "jsdom",
moduleDirectories: ["node_modules", "src", "test"],
coverageReporters: ["lcov", "text", "teamcity"],
testResultsProcessor: "jest-teamcity-reporter",
testMatch: ["**/test/**/*.test.ts"]
transform: {
'^.+\\.ts$': 'ts-jest',
'^.+\\.svelte$': ['svelte-jester', { preprocess: true }]
},
moduleFileExtensions: ['js', 'ts', 'svelte'],
testEnvironment: 'jsdom',
setupFilesAfterEnv: ['<rootDir>/test/setup.ts'],
moduleNameMapper: {
'^src/(.*)$': '<rootDir>/src/$1'
},
collectCoverageFrom: ['src/**/*.{ts,svelte}'],
testPathIgnorePatterns: [
'/node_modules/',
'/build/',
'/src/l10n/locales/'
]
};
4 changes: 2 additions & 2 deletions manifest.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"id": "rss-reader",
"name": "RSS Reader",
"version": "1.2.2",
"minAppVersion": "0.13.33",
"version": "1.3.0",
"minAppVersion": "1.4.0",
"description": "Read RSS Feeds from within obsidian",
"author": "Johannes Theiner",
"authorUrl": "https://github.com/joethei",
Expand Down
78 changes: 41 additions & 37 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,53 +15,57 @@
"author": "Johannes Theiner",
"license": "GPL-3.0",
"devDependencies": {
"@types/lodash.groupby": "^4.6.6",
"@types/lodash.keyby": "^4.6.6",
"@types/lodash.mergewith": "^4.6.6",
"@types/lodash.sortby": "^4.7.6",
"@types/lodash.values": "^4.3.6",
"@types/mocha": "^9.0.0",
"@types/node": "^14.14.37",
"@typescript-eslint/eslint-plugin": "^4.33.0",
"@typescript-eslint/parser": "^4.33.0",
"@testing-library/jest-dom": "^6.6.3",
"@types/jest": "^29.5.14",
"@types/lodash.groupby": "^4.6.9",
"@types/lodash.keyby": "^4.6.9",
"@types/lodash.mergewith": "^4.6.9",
"@types/lodash.sortby": "^4.7.9",
"@types/lodash.values": "^4.3.9",
"@types/node": "^20.17.50",
"@types/pako": "^2.0.3",
"@typescript-eslint/eslint-plugin": "^7.1.0",
"@typescript-eslint/parser": "^7.1.0",
"autoprefixer": "^10.4.17",
"builtin-modules": "^3.3.0",
"esbuild": "0.13.15",
"esbuild-svelte": "^0.6.0",
"eslint": "^7.32.0",
"isomorphic-fetch": "3.0.0",
"jest": "27.5.1",
"jest-teamcity-reporter": "0.9.0",
"jsdom": "^19.0.0",
"cssnano": "^6.0.3",
"cssnano-preset-default": "^6.0.3",
"esbuild": "^0.20.1",
"esbuild-svelte": "^0.8.0",
"eslint": "^8.57.0",
"isomorphic-fetch": "^3.0.0",
"jest": "^29.7.0",
"jest-environment-jsdom": "^29.7.0",
"jest-teamcity-reporter": "^0.9.0",
"jsdom": "^24.0.0",
"pako": "^2.1.0",
"postcss": "^8.4.35",
"process": "^0.11.10",
"stylelint": "^14.1.0",
"ts-jest": "27.1.4",
"tslib": "^2.3.1",
"tslint": "^6.1.3",
"typescript": "^4.2.4",
"sass": "1.53.0",
"stylelint-scss": "4.3.0",
"stylelint-config-standard": "26.0.0",
"stylelint-config-standard-scss": "5.0.0",
"postcss": "8.4.14",
"autoprefixer": "10.4.7",
"cssnano": "5.1.12",
"cssnano-preset-default": "5.2.12",
"svelte-preprocess": "^4.9.8"
"sass": "^1.71.1",
"stylelint": "^16.2.1",
"stylelint-config-standard": "^36.0.0",
"stylelint-config-standard-scss": "^13.0.0",
"stylelint-scss": "^6.1.0",
"svelte-jester": "^5.0.0",
"svelte-preprocess": "^5.1.3",
"ts-jest": "^29.1.2",
"tslib": "^2.6.2",
"typescript": "^5.3.3"
},
"dependencies": {
"@popperjs/core": "^2.10.2",
"@types/nunjucks": "^3.2.1",
"@popperjs/core": "^2.11.8",
"@types/nunjucks": "^3.2.6",
"@vanakat/plugin-api": "0.1.0",
"jsdom-global": "^3.0.2",
"lodash.groupby": "^4.6.0",
"lodash.keyby": "^4.6.0",
"lodash.mergewith": "^4.6.2",
"lodash.sortby": "^4.7.0",
"lodash.values": "^4.3.0",
"nunjucks": "3.2.3",
"obsidian": "0.16.3",
"svelte": "^3.43.1",
"ts-md5": "^1.2.10",
"ts-node": "^10.4.0"
"nunjucks": "^3.2.4",
"obsidian": "^1.4.11",
"svelte": "^4.2.12",
"ts-md5": "^1.3.1",
"ts-node": "^10.9.2"
}
}
Binary file added src/.DS_Store
Binary file not shown.
106 changes: 55 additions & 51 deletions src/functions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import {
normalizePath,
Notice,
TextComponent,
MarkdownPreviewRenderer, moment, View, TextFileView
MarkdownPreviewRenderer, moment as momentType, View, TextFileView
} from "obsidian";
import {TextInputPrompt} from "./modals/TextInputPrompt";
import {FILE_NAME_REGEX} from "./consts";
Expand All @@ -13,65 +13,80 @@ import t from "./l10n/locale";
import {Item} from "./providers/Item";

export async function createNewNote(plugin: RssReaderPlugin, item: Item): Promise<void> {
console.log("creating new note");
const activeFile = plugin.app.workspace.getActiveFile();
let dir = plugin.app.fileManager.getNewFileParent(activeFile ? activeFile.path : "").path;
try {
console.log("Creating new note from item:", item.title());
const activeFile = plugin.app.workspace.getActiveFile();
let dir = plugin.app.fileManager.getNewFileParent(activeFile ? activeFile.path : "").path;

if (plugin.settings.saveLocation === "custom") {
dir = plugin.settings.saveLocationFolder;
}
if (plugin.settings.saveLocation === "custom") {
dir = plugin.settings.saveLocationFolder;
}

let filename = applyTemplate(plugin, item, plugin.settings.defaultFilename);
//make sure there are no slashes in the title.
filename = filename.replace(/[\/\\:]/g, ' ');
let filename = applyTemplate(plugin, item, plugin.settings.defaultFilename);
//make sure there are no slashes in the title.
filename = filename.replace(/[\/\\:]/g, ' ');

if (plugin.settings.askForFilename) {
const inputPrompt = new TextInputPrompt(plugin.app, t("specify_name"), t("cannot_contain") + " * \" \\ / < > : | ?", filename, filename);
await inputPrompt
.openAndGetValue(async (text: TextComponent) => {
if (plugin.settings.askForFilename) {
const inputPrompt = new TextInputPrompt(
plugin.app,
t("specify_name"),
t("cannot_contain") + " * \" \\ / < > : | ?",
filename,
filename
);

await inputPrompt.openAndGetValue(async (text: TextComponent) => {
const value = text.getValue();
if (value.match(FILE_NAME_REGEX)) {
inputPrompt.setValidationError(text, t("invalid_filename"));
return;
}
const filePath = normalizePath([dir, `${value}.md`].join('/'));

if (isInVault(filePath)) {
if (await plugin.app.vault.adapter.exists(filePath)) {
inputPrompt.setValidationError(text, t("note_exists"));
return;
}
inputPrompt.close();
await createNewFile(plugin, item, filePath, value);
});
} else {
const replacedTitle = filename.replace(FILE_NAME_REGEX, '');
const filePath = normalizePath([dir, `${replacedTitle}.md`].join('/'));
await createNewFile(plugin, item, filePath, item.title());
} else {
const replacedTitle = filename.replace(FILE_NAME_REGEX, '');
const filePath = normalizePath([dir, `${replacedTitle}.md`].join('/'));
await createNewFile(plugin, item, filePath, filename);
}
} catch (error) {
console.error('Error creating new note:', error);
new Notice('Error creating new note: ' + error.message);
}


}

async function createNewFile(plugin: RssReaderPlugin, item: Item, path: string, title: string) {
if (isInVault(path)) {
new Notice(t("note_exists"));
return;
}

const appliedTemplate = applyTemplate(plugin, item, plugin.settings.template, title);
try {
if (await plugin.app.vault.adapter.exists(path)) {
new Notice(t("note_exists"));
return;
}

const file = await plugin.app.vault.create(path, appliedTemplate);
await plugin.app.workspace.getLeaf('tab').openFile(file, {
state: {mode: 'edit'},
});
const appliedTemplate = applyTemplate(plugin, item, plugin.settings.template, title);
const file = await plugin.app.vault.create(path, appliedTemplate);

const leaf = plugin.app.workspace.getLeaf('tab');
if (leaf) {
await leaf.openFile(file, {
state: { mode: 'source' },
});
}

item.markCreated(true);
const items = plugin.settings.items;
await plugin.writeFeedContent(() => {
return items;
});
await item.markCreated(true);
const items = plugin.settings.items;
await plugin.writeFeedContent(() => items);

new Notice(t("created_note"));
new Notice(t("created_note"));
} catch (error) {
console.error('Error in createNewFile:', error);
new Notice('Error creating file: ' + error.message);
}
}

export async function pasteToNote(plugin: RssReaderPlugin, item: Item): Promise<void> {
Expand Down Expand Up @@ -102,6 +117,7 @@ export async function pasteToNote(plugin: RssReaderPlugin, item: Item): Promise<
}

function applyTemplate(plugin: RssReaderPlugin, item: Item, template: string, filename?: string): string {
const moment = (window as any).moment;
let result = template.replace(/{{title}}/g, item.title());
result = result.replace(/{{link}}/g, item.url());
result = result.replace(/{{author}}/g, item.author());
Expand All @@ -111,7 +127,7 @@ function applyTemplate(plugin: RssReaderPlugin, item: Item, template: string, fi
result = result.replace(/{{feed}}/g, item.feed());
result = result.replace(/{{folder}}/g, item.folder());
result = result.replace(/{{description}}/g, item.description());
result = result.replace(/{{media}}/g, item.enclosureLink);
result = result.replace(/{{media}}/g, item.enclosureLink());

result = result.replace(/({{published:).*(}})/g, function (k) {
const value = k.split(":")[1];
Expand Down Expand Up @@ -140,8 +156,6 @@ function applyTemplate(plugin: RssReaderPlugin, item: Item, template: string, fi
result = result.replace(/{{tags}}/g, item.tags().join(", "));
result = result.replace(/{{#tags}}/g, item.tags().map(i => '#' + i).join(", "));



result = result.replace(/{{highlights}}/g, item.highlights().map(value => {
//remove wallabag.xml - from the start of a highlight
return "- " + rssToMd(plugin, removeFormatting(value).replace(/^(-+)/, ""))
Expand All @@ -160,24 +174,14 @@ function applyTemplate(plugin: RssReaderPlugin, item: Item, template: string, fi
result = result.replace(/{{filename}}/g, filename);
}


let content = rssToMd(plugin, item.body());

item.highlights().forEach(highlight => {
const mdHighlight = htmlToMarkdown(highlight);
content = content.replace(mdHighlight, "==" + mdHighlight + "==");


});
/*
fixes #48
replacing $ with $$$, because that is a special regex character:
https://developer.mozilla.org/en-US/docs/web/javascript/reference/global_objects/string/replace#specifying_a_string_as_a_parameter
solution taken from: https://stackoverflow.com/a/22612228/5589264
*/
content = content.replace(/\$/g, "$$$");


content = content.replace(/\$/g, "$$$");
result = result.replace(/{{content}}/g, content);

return result;
Expand Down
Binary file added src/l10n/.DS_Store
Binary file not shown.
Loading