Skip to content

Commit

Permalink
Remove duplicated code and fix issue with template
Browse files Browse the repository at this point in the history
  • Loading branch information
akopdev committed May 6, 2024
1 parent 5bf1ca6 commit 7e82951
Show file tree
Hide file tree
Showing 39 changed files with 334 additions and 136 deletions.
Empty file modified .editorconfig
100644 → 100755
Empty file.
Empty file modified .eslintignore
100644 → 100755
Empty file.
Empty file modified .eslintrc
100644 → 100755
Empty file.
Empty file modified .github/FUNDING.yml
100644 → 100755
Empty file.
Empty file modified .github/workflows/release.yml
100644 → 100755
Empty file.
Empty file modified .gitignore
100644 → 100755
Empty file.
Empty file modified .npmrc
100644 → 100755
Empty file.
Empty file modified LICENSE
100644 → 100755
Empty file.
8 changes: 7 additions & 1 deletion Makefile
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,17 @@
help:
@grep -oE '^#.[a-zA-Z0-9]+:.*?@ .*$$' $(MAKEFILE_LIST) | tr -d '#' |\
awk 'BEGIN {FS = ":.*?@ "}; {printf " make%-10s%s\n", $$1, $$2}'

# -------------------------------------------------------------------------------------------------
# init: @ Install the project dependencies
# -------------------------------------------------------------------------------------------------
init:
@test -d node_modules || @npm install

# -------------------------------------------------------------------------------------------------
# start: @ Run the development server
# -------------------------------------------------------------------------------------------------
start:
start: init
@npm run dev

# -------------------------------------------------------------------------------------------------
Expand Down
Empty file modified README.md
100644 → 100755
Empty file.
Empty file modified cover.png
100644 → 100755
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions docs/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Documentation
=============

- [Most common BibTeX Types](bibtex-types.md)
216 changes: 216 additions & 0 deletions docs/bibtex-types.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,216 @@
Basic BibTeX entry types
========================

A list of the 14 basic BibTeX entry types with descriptions and examples.

## 1. Article

An article from a journal or magazine.

```bibtex
@article{CitekeyNewArticle,
author = "A. Einstein",
title = "On the Electrodynamics of Moving Bodies",
journal = "Annalen der Physik",
year = 1905,
volume = "17",
number = "10",
pages = "891--921",
}
```

## 2. Book

A book with an explicit publisher.

```bibtex
@book{CitekeyNewBook,
author = "Isaac Newton",
title = "The Principia: Mathematical Principles of Natural Philosophy",
publisher = "University of California Press",
address = "Berkeley, CA",
year = 1999
}
```

## 3. Booklet

A work that is printed and bound, but without a named publisher or sponsoring institution.

```bibtex
@booklet{CitekeyNewBooklet,
title = "Guide to the Alpine Flora",
author = "Elisabeth Schmitt",
howpublished = "Available at the Bern Tourism Office",
month = aug,
year = 2018
}
```

## 4. InBook

A part of a book, which may be a chapter (or section or whatever) and/or a range of pages.

```bibtex
@inbook{CitekeyNewInbook,
author = "Neil deGrasse Tyson",
title = "The Cosmic Perspective",
booktitle = "Astrophysics for People in a Hurry",
year = "2017",
publisher = "W. W. Norton & Company",
address = "New York, NY",
pages = "12--45"
}
```

## 5. InCollection

A part of a book having its own title. For example, a chapter in a collection of essays.

```bibtex
@incollection{CitekeyNewIncollection,
author = "Mary Shelley",
editor = "John Smith and Joan Doe",
title = "Reanimating Life",
booktitle = "Gothic Tales",
year = 2020,
publisher = "Fictional University Press",
address = "London, UK",
pages = "101--120"
}
```

## 6. InProceedings

An article in a conference proceedings.

```bibtex
@inproceedings{CitekeyNewInproceedings,
author = "Ada Lovelace",
title = "Early Computations: An Analytical Engine",
booktitle = "Proceedings of the 10th International Conference on History of Computing",
series = "HistComp",
year = 2009,
pages = "67--75",
publisher = "IEEE",
address = "Boston, MA"
}
```

## 7. Manual

Technical documentation.

```bibtex
@manual{CitekeyNewManual,
title = "User Guide for Quantum Computing",
author = "Quantum Computing Association",
organization = "International Society for Quantum Information",
address = "Geneva, Switzerland",
year = 2022
}
```

## 8. Masters thesis

A Master's thesis.

```bibtex
@mastersthesis{CitekeyNewMastersthesis,
author = "Diana Prince",
title = "Ancient Mythologies and Modern Narratives",
school = "University of Athens",
year = 2010,
address = "Athens, Greece",
month = oct
}
```

## 9. Misc

Use this type when nothing else fits. Frequently used for web pages.

```bibtex
@misc{CitekeyNewMisc,
title = "Exploration of Mars: A Decade of Rovers",
author = "European Space Agency",
howpublished = "\url{https://www.esa.int/marsrover}",
year = 2020,
note = "Accessed: 2023-01-15"
}
```

## 10. PhdThesis

A thesis written for the PhD level degree.

```bibtex
@phdthesis{CitekeyNewPhdthesis,
author = "Charles Babbage",
title = "Development of the Analytical Engine",
school = "University of Cambridge",
address = "Cambridge, UK",
year = 1834,
month = dec
}
```

## 11. Proceedings

The proceedings of a conference.

```bibtex
@proceedings{CitekeyNewProceedings,
editor = "George Boole and Augusta Ada King",
title = "Proceedings of the 24th International Conference on Logic and Mathematics",
series = "Advanced Studies in Pure Mathematics",
volume = "101",
publisher = "Mathematical Society Press",
address = "Edinburgh, Scotland",
year = 2021
}
```

## 12. TechReport

A report published by a school or other institution, usually numbered within a series.

```bibtex
@techreport{CitekeyNewTechreport,
title = "Advancements in Renewable Energy Technologies",
author = "International Energy Agency",
institution = "IEA",
month = "January",
year = 2020,
number = "IEA-TR-2020-01"
address = "Paris, France"
```

## 13. Unpublished

A document having an author and title, but not formally published.

```bibtex
@unpublished{CitekeyNewUnpublished,
author = "Marie Curie",
title = "The Discovery of Radium",
note = "Unpublished manuscript",
year = 1902,
month = nov
}
```

## 14. Conference

A conference paper.

```bibtex
@conference{CitekeyNewConference,
author = "Alan Turing",
title = "Computing Machinery and Intelligence",
booktitle = "Proceedings of the 1st International Conference on Artificial Intelligence",
year = 1956,
month = aug,
address = "Dartmouth College, Hanover, NH"
}
```
Empty file modified esbuild.config.mjs
100644 → 100755
Empty file.
4 changes: 2 additions & 2 deletions manifest.json
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
{
"id": "bibtex-manager",
"name": "BibTeX Manager",
"version": "0.8.7",
"version": "0.8.8",
"minAppVersion": "0.15.0",
"description": "Obsidian plug-in that simplifies the process of managing academic references by enabling the creation of literature notes from a BibTeX entry, displaying formatted reference lists, and generating citations instantly.",
"description": "Create a literature notes from a BibTeX entries.",
"author": "Akop Kesheshyan",
"authorUrl": "https://github.com/akopdev",
"isDesktopOnly": false
Expand Down
1 change: 0 additions & 1 deletion package-lock.json
100644 → 100755

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Empty file modified package.json
100644 → 100755
Empty file.
Empty file modified src/components/core/index.ts
100644 → 100755
Empty file.
Empty file modified src/components/index.ts
100644 → 100755
Empty file.
66 changes: 56 additions & 10 deletions src/components/modals/base.ts
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
import { App, Modal, Notice, TFile, TFolder } from "obsidian";
import { Settings } from "../settings";
import { App, Modal, Notice, TFile, TFolder, Setting } from "obsidian";
import { BibTeXTypes, Settings } from "../settings";
import { Citation } from "../../modules";
import { Entry } from "@retorquere/bibtex-parser/grammar";

export class BaseModal extends Modal {
bibtex: string;
template: string;
settings: Settings;
title: string;

constructor(app: App, settings: Settings) {
super(app);
Expand Down Expand Up @@ -59,15 +60,13 @@ export class BaseModal extends Modal {
}

getFileParent() {
if (!this.settings.useDefaultFolder) {
let folder = this.settings.customFolder;
let folder = this.settings.customFolder;
// if custom folder is set, use it otherwise use the current file's folder
if (folder) {
const abstractFile = this.app.vault.getAbstractFileByPath(folder);
if (abstractFile && "children" in (abstractFile as TFolder)) {
return abstractFile as TFolder;
} else {
new Notice(`Error opening folder '${folder}'!`);
throw new Error(`Could not open the folder at '${folder}'`);
}
if (abstractFile instanceof TFolder) {
return abstractFile;
}
}

let lastFile = this.app.workspace.getActiveFile();
Expand Down Expand Up @@ -95,6 +94,53 @@ export class BaseModal extends Modal {
}
return `${newFilePath}/${fileName}`;
}

async onOpen() {
const { contentEl } = this;

contentEl.createEl("h2", { text: `${this.title} a note` });

new Setting(contentEl)
.addTextArea((text) => {
text.setPlaceholder(
"Paste the content of your BibTeX file",
).onChange((value) => {
this.bibtex = value;
});
text.inputEl.addClass("bibtex-manager-template");
})
.setClass("bibtex-manager-template-container");

new Setting(contentEl).setName("Apply template").addDropdown((cb) => {
cb.addOption("", "Auto detect");
BibTeXTypes.forEach((type) => cb.addOption(type, type));

cb.onChange((value) => {
this.template = value || "";
});
});

new Setting(contentEl)
.addButton((btn) => {
btn.setButtonText("Cancel").onClick(() => {
this.close();
});
})
.addButton((btn) =>
btn
.setButtonText(this.title)
.setCta()
.onClick(() => {
this.close();
this.onSubmit(this.bibtex);
}),
);
}

onSubmit(bibtex: string) {
throw new Error("Method not implemented.");
}

onClose() {
const { contentEl } = this;
contentEl.empty();
Expand Down
Loading

0 comments on commit 7e82951

Please sign in to comment.