Skip to content

Commit c9246b2

Browse files
author
Charles Feval
committed
Todo exporter
Implement #28
1 parent dc80383 commit c9246b2

File tree

7 files changed

+748
-78
lines changed

7 files changed

+748
-78
lines changed

.github/workflows/release.yml

Lines changed: 74 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -1,82 +1,82 @@
11
name: Build obsidian plugin
22

33
on:
4-
push:
5-
# Sequence of patterns matched against refs/tags
6-
tags:
7-
- "*" # Push events to matching any tag format, i.e. 1.0, 20.15.10
4+
push:
5+
# Sequence of patterns matched against refs/tags
6+
tags:
7+
- "*" # Push events to matching any tag format, i.e. 1.0, 20.15.10
88

99
env:
10-
PLUGIN_NAME: obsidian-pw # Change this to the name of your plugin-id folder
10+
PLUGIN_NAME: obsidian-pw # Change this to the name of your plugin-id folder
1111

1212
jobs:
13-
build:
14-
runs-on: ubuntu-latest
13+
build:
14+
runs-on: ubuntu-latest
1515

16-
steps:
17-
- uses: actions/checkout@v2
18-
- name: Use Node.js
19-
uses: actions/setup-node@v1
20-
with:
21-
node-version: "14.x" # You might need to adjust this value to your own version
22-
- name: Build
23-
id: build
24-
run: |
25-
yarn
26-
yarn run build --if-present
27-
mkdir ${{ env.PLUGIN_NAME }}
28-
cp main.js manifest.json styles.css ${{ env.PLUGIN_NAME }}
29-
zip -r ${{ env.PLUGIN_NAME }}.zip ${{ env.PLUGIN_NAME }}
30-
ls
31-
echo "::set-output name=tag_name::$(git tag --sort version:refname | tail -n 1)"
32-
- name: Create Release
33-
id: create_release
34-
uses: actions/create-release@v1
35-
env:
36-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
37-
VERSION: ${{ github.ref }}
38-
with:
39-
tag_name: ${{ github.ref }}
40-
release_name: ${{ github.ref }}
41-
draft: false
42-
prerelease: false
43-
- name: Upload zip file
44-
id: upload-zip
45-
uses: actions/upload-release-asset@v1
46-
env:
47-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
48-
with:
49-
upload_url: ${{ steps.create_release.outputs.upload_url }}
50-
asset_path: ./${{ env.PLUGIN_NAME }}.zip
51-
asset_name: ${{ env.PLUGIN_NAME }}-${{ steps.build.outputs.tag_name }}.zip
52-
asset_content_type: application/zip
53-
- name: Upload main.js
54-
id: upload-main
55-
uses: actions/upload-release-asset@v1
56-
env:
57-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
58-
with:
59-
upload_url: ${{ steps.create_release.outputs.upload_url }}
60-
asset_path: ./main.js
61-
asset_name: main.js
62-
asset_content_type: text/javascript
63-
- name: Upload manifest.json
64-
id: upload-manifest
65-
uses: actions/upload-release-asset@v1
66-
env:
67-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
68-
with:
69-
upload_url: ${{ steps.create_release.outputs.upload_url }}
70-
asset_path: ./manifest.json
71-
asset_name: manifest.json
72-
asset_content_type: application/json
73-
- name: Upload styles.css
74-
id: upload-css
75-
uses: actions/upload-release-asset@v1
76-
env:
77-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
78-
with:
79-
upload_url: ${{ steps.create_release.outputs.upload_url }}
80-
asset_path: ./styles.css
81-
asset_name: styles.css
82-
asset_content_type: text/css
16+
steps:
17+
- uses: actions/checkout@v2
18+
- name: Use Node.js
19+
uses: actions/setup-node@v1
20+
with:
21+
node-version: "18.x" # You might need to adjust this value to your own version
22+
- name: Build
23+
id: build
24+
run: |
25+
yarn
26+
yarn run build --if-present
27+
mkdir ${{ env.PLUGIN_NAME }}
28+
cp main.js manifest.json styles.css ${{ env.PLUGIN_NAME }}
29+
zip -r ${{ env.PLUGIN_NAME }}.zip ${{ env.PLUGIN_NAME }}
30+
ls
31+
echo "::set-output name=tag_name::$(git tag --sort version:refname | tail -n 1)"
32+
- name: Create Release
33+
id: create_release
34+
uses: actions/create-release@v1
35+
env:
36+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
37+
VERSION: ${{ github.ref }}
38+
with:
39+
tag_name: ${{ github.ref }}
40+
release_name: ${{ github.ref }}
41+
draft: false
42+
prerelease: false
43+
- name: Upload zip file
44+
id: upload-zip
45+
uses: actions/upload-release-asset@v1
46+
env:
47+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
48+
with:
49+
upload_url: ${{ steps.create_release.outputs.upload_url }}
50+
asset_path: ./${{ env.PLUGIN_NAME }}.zip
51+
asset_name: ${{ env.PLUGIN_NAME }}-${{ steps.build.outputs.tag_name }}.zip
52+
asset_content_type: application/zip
53+
- name: Upload main.js
54+
id: upload-main
55+
uses: actions/upload-release-asset@v1
56+
env:
57+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
58+
with:
59+
upload_url: ${{ steps.create_release.outputs.upload_url }}
60+
asset_path: ./main.js
61+
asset_name: main.js
62+
asset_content_type: text/javascript
63+
- name: Upload manifest.json
64+
id: upload-manifest
65+
uses: actions/upload-release-asset@v1
66+
env:
67+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
68+
with:
69+
upload_url: ${{ steps.create_release.outputs.upload_url }}
70+
asset_path: ./manifest.json
71+
asset_name: manifest.json
72+
asset_content_type: application/json
73+
- name: Upload styles.css
74+
id: upload-css
75+
uses: actions/upload-release-asset@v1
76+
env:
77+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
78+
with:
79+
upload_url: ${{ steps.create_release.outputs.upload_url }}
80+
asset_path: ./styles.css
81+
asset_name: styles.css
82+
asset_content_type: text/css

manifest.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"author": "Charles Feval",
55
"description": "Track your tasks across all the notes in your workspace. Organize your day. Plan your work",
66
"authorUrl": "https://fev.al",
7-
"version": "1.5.1",
7+
"version": "1.6.0",
88
"minAppVersion": "1.0.0",
99
"isDesktopOnly": false
1010
}

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "obsidian-pw",
3-
"version": "1.5.1",
3+
"version": "1.6.0",
44
"description": "This is a sample plugin for Obsidian (https://obsidian.md)",
55
"main": "main.js",
66
"scripts": {

src/Views/ReportExportModal.ts

Lines changed: 111 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
1+
import { App, Modal, Setting } from "obsidian";
2+
import { DateTime } from "luxon";
3+
import { TodoItem, TodoStatus } from "../domain/TodoItem";
4+
import { TFile } from "obsidian";
5+
6+
export interface ExportConfig {
7+
startDate: DateTime | null;
8+
endDate: DateTime | null;
9+
includeTasksWithNoDates: boolean;
10+
includeNotes: boolean;
11+
}
12+
13+
export class ReportExportModal extends Modal {
14+
private config: ExportConfig;
15+
private onSubmit: (config: ExportConfig) => void;
16+
17+
constructor(
18+
app: App,
19+
allTodos: TodoItem<TFile>[],
20+
initialConfig: ExportConfig,
21+
onSubmit: (config: ExportConfig) => void
22+
) {
23+
super(app);
24+
this.config = { ...initialConfig };
25+
this.onSubmit = onSubmit;
26+
}
27+
28+
onOpen() {
29+
const { contentEl } = this;
30+
contentEl.addClass("pw-export-modal");
31+
32+
contentEl.createEl("h2", { text: "Export Report" });
33+
34+
// Date Range Settings
35+
new Setting(contentEl)
36+
.setName("Start Date")
37+
.setDesc("Beginning of report period")
38+
.addText((text) =>
39+
text
40+
.setValue(
41+
this.config.startDate
42+
? this.config.startDate.toISODate() || ""
43+
: ""
44+
)
45+
.setPlaceholder("YYYY-MM-DD")
46+
.onChange(async (value) => {
47+
this.config.startDate = value
48+
? DateTime.fromISO(value)
49+
: null;
50+
})
51+
);
52+
53+
new Setting(contentEl)
54+
.setName("End Date")
55+
.setDesc("End of report period")
56+
.addText((text) =>
57+
text
58+
.setValue(
59+
this.config.endDate
60+
? this.config.endDate.toISODate() || ""
61+
: ""
62+
)
63+
.setPlaceholder("YYYY-MM-DD")
64+
.onChange(async (value) => {
65+
this.config.endDate = value
66+
? DateTime.fromISO(value)
67+
: null;
68+
})
69+
);
70+
71+
// Include tasks with no dates
72+
new Setting(contentEl)
73+
.setName("Include Tasks with No Dates")
74+
.setDesc(
75+
"Include tasks that don't have due dates or completion dates"
76+
)
77+
.addToggle((toggle) =>
78+
toggle
79+
.setValue(this.config.includeTasksWithNoDates)
80+
.onChange((value) => {
81+
this.config.includeTasksWithNoDates = value;
82+
})
83+
);
84+
85+
// Include notes
86+
new Setting(contentEl)
87+
.setName("Include Notes")
88+
.setDesc("Include subtasks and notes")
89+
.addToggle((toggle) =>
90+
toggle.setValue(this.config.includeNotes).onChange((value) => {
91+
this.config.includeNotes = value;
92+
})
93+
);
94+
95+
// Submit button
96+
new Setting(contentEl).addButton((button) =>
97+
button
98+
.setButtonText("Export to Clipboard")
99+
.setCta()
100+
.onClick(() => {
101+
this.onSubmit(this.config);
102+
this.close();
103+
})
104+
);
105+
}
106+
107+
onClose() {
108+
const { contentEl } = this;
109+
contentEl.empty();
110+
}
111+
}

0 commit comments

Comments
 (0)