-
Notifications
You must be signed in to change notification settings - Fork 60
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' of https://github.com/NotePlan/plugins
- Loading branch information
Showing
45 changed files
with
639 additions
and
360 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# cd.FormattedDateTime Changelog | ||
|
||
## About cd.FormattedDateTime Plugin | ||
|
||
Example Plugin to demonstrate how to integrate np.Templating Plugin into a standard NotePlan Plugin | ||
|
||
See Plugin [README](https://github.com/NotePlan/plugins/blob/main/cd.FormattedDateTime/README.md) for details on available commands and use case. | ||
|
||
## [0.0.1] - 2022-02-22 (mikeerickson) | ||
|
||
### Added | ||
Initial Release | ||
|
||
## Changelog | ||
|
||
All notable changes to this project will be documented in this file. | ||
|
||
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), | ||
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). | ||
|
||
## Plugin Versioning Uses Semver | ||
|
||
All NotePlan plugins follow `semver` versioning. For details, please refer to [semver website](https://semver.org/) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# FormattedDateTime | ||
***** | ||
#### Demonstration using extended method | ||
<%= myFormattedDateTime({format: '%A, %B %d, %Y'}) %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
# FormattedDateTime Noteplan Plugin | ||
Example NotePlan Plugin demonstration how to integrate np.Templating | ||
|
||
## License | ||
|
||
Copyright © 2022 Mike Erickson | ||
Released under the MIT license | ||
|
||
## Credits | ||
|
||
**FormattedDateTime for NotePlan** written by **Mike Erickson** | ||
|
||
E-Mail: [[email protected]](mailto:[email protected]) | ||
|
||
Support: [https://github.com/NotePlan/plugins/issues](https://github.com/NotePlan/plugins/issues) | ||
|
||
Twitter: [@codedungeon](http://twitter.com/codedungeon) | ||
|
||
Website: [codedungeon.io](http://codedungeon.io) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
{ | ||
"macOS.minVersion": "10.13.0", | ||
"noteplan.minAppVersion": "3.4.1", | ||
"plugin.id": "cd.FormattedDateTime", | ||
"plugin.name": "🧩 FormattedDateTime", | ||
"plugin.version": "0.0.1", | ||
"plugin.description": "Sample Templating Plugin", | ||
"plugin.author": "codedungeon", | ||
"plugin.dependencies": [], | ||
"plugin.script": "script.js", | ||
"plugin.url": "https://github.com/NotePlan/plugins/blob/main/cd.FormattedDateTime/README.md", | ||
"plugin.commands": [ | ||
{ | ||
"name": "xx:formattedDateTime", | ||
"description": "Display Formatted Date Time", | ||
"jsFunction": "templateFormattedDateTime", | ||
"alias": [] | ||
} | ||
], | ||
"plugin.settings": [ | ||
{ | ||
"type": "heading", | ||
"title": "FormattedDateTime Settings" | ||
}, | ||
{ | ||
"key": "version", | ||
"type": "hidden", | ||
"description": "FormattedDateTime Settings Version" | ||
}, | ||
{ | ||
"key": "format", | ||
"title": "Format", | ||
"type": "string", | ||
"description": "Date Time Format", | ||
"default": "%A, %B %d, %Y" | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
// @flow | ||
// NOTE: Strip out all the comments if you want to just read the code (hopefully pretty self explanatory) | ||
|
||
import pluginJson from '../plugin.json' | ||
|
||
// import np.Templating Library | ||
import NPTemplating from 'NPTemplating' | ||
|
||
import { formattedDateTimeTemplate } from '@plugins/dwertheimer.DateAutomations/src/dateFunctions' | ||
// import { getSetting } from '@helpers/NPconfiguration' | ||
|
||
import { updateSettingData } from '@helpers/NPconfiguration' | ||
import { log, logError } from '@helpers/dev' | ||
|
||
export async function templateFormattedDateTime(): Promise<void> { | ||
try { | ||
// NOTE: this is only here to initialize settings since the plugin was never installed | ||
await updateSettingData(pluginJson) | ||
|
||
const templateObj = { | ||
methods: { | ||
myFormattedDateTime: async (params: any = {}) => { | ||
// this is only looking in current plugin settings file, more generic method coming in getSetting | ||
const defaultFormat: string = DataStore.settings.format | ||
|
||
// build format string passed to `formattedDateTimeTemplate` | ||
const format: string = params && params.hasOwnProperty('format') ? params.format : defaultFormat | ||
|
||
// NOTE: np.Templating actually passes an as it is defined in template, unlike existing templating passes things as a string | ||
// create string version of format block which `formattedDateTimeTemplate` expects | ||
const formatString: string = `{format: ${format}}` | ||
|
||
// call existing `formattedDateTimeTemplate` from `./dwertheimer.DateAutomations/src/dateFunctions` | ||
return formattedDateTimeTemplate(formatString) | ||
}, | ||
}, | ||
} | ||
|
||
// Assumes a template with name `FormattedDateTime` exists | ||
// see `FormattedDateTime.md` in plugin root for sample | ||
const result: string = (await NPTemplating.renderTemplate('FormattedDateTime', templateObj)) || '' | ||
|
||
Editor.insertTextAtCursor(result) | ||
} catch (error) { | ||
logError(pluginJson, `templateFormattedDateTime :: ${error}`) | ||
} | ||
} | ||
|
||
export async function onUpdateOrInstall(): Promise<void> { | ||
updateSettingData(pluginJson) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.