Giter Club home page Giter Club logo

jgclark / noteplan-tools Goto Github PK

View Code? Open in Web Editor NEW
26.0 26.0 6.0 6.16 MB

This Ruby script adds functionality to the [NotePlan app](https://noteplan.co/). Particularly when run frequently, this provides a more flexible system for repeating tasks, allows for due dates to be expressed as offsets which allows for templates, and moves or files items from Daily files to Note files. It incorporates an ealier script to 'clean' or tidy up NotePlan's data files.

Ruby 100.00%

noteplan-tools's Issues

Rewritten /Calendar items being placed in /Notes

Found the commonality for the files that are getting moved -

Regex on line 106 doesn't take into account the new .md extension for files. Later on, in rewrite_files (line 666), any rewritten daily note gets moved to Notes if you're using the .md extension.

# Now make a title for this file:
**if @filename =~ /\d{8}\.txt/**
  # for Calendar file, use the date from filename
  @title = @filename[0..7]
  @is_calendar = true
else
  # otherwise use first line (but take off heading characters at the start and starting and ending whitespace)
  tempTitle = @lines[0].gsub(/^#+\s*/, '')
  @title = tempTitle.gsub(/\s+$/, '')
  @is_calendar = false
end

end

Make insertion point smarter

When npTools files (moves) items from daily notes, it currently:

  • inserts at HEADER_LINE (for notes)
  • appends (for daily notes).

This action is about making the filing location smarter.

For daily notes I propose:

  • at the end of a section that starts with a user-specified heading (e.g. "Tasks")
  • otherwise at the end of the first run of lines (terminated by a blank line)

For non-daily notes I propose:

  • at the end of a section that starts with a user-specified heading (e.g. "Inbox")
  • after a formal YAML frontmatter section and before first heading
  • after an informal frontmatter section etc. (defined to be after consecutive lines starting with a # or after a second --- or first ... line or after Attribute:: or tag:: lines).

Remove empty calendar files

I've discovered many empty calendar files, probably as a result of adding and removing repeating tasks.
These empty ones could be removed.

Add a repeating tasks mechanism

NotePlan 2 does have a way of getting tasks to repeat, but it's not obvious to use, and difficult to update.

I propose adding my own using @repeat(interval) on tasks, that gets activated when a task is completed. It would work in one of two ways:

  1. When interval is of the form +2w it will duplicate the task for 2 weeks' after the date is was completed.
  2. When interval is of the form 2w it will duplicate the task for 2 weeks after the date the task was last due. If this can't be determined, then default to the first option.

Valid intervals are [0-9][dwmqy].

Creation of new events

Extend to allow creation of new events in Apple Calendar when the #create_event tag is used on a line (task, comment or heading). It would use the existing timeblocking syntax (either at 8[-11][AM|PM] or 3:00[-4:00][AM|PM]) but doesn't just show time on the NotePlan calendar, but make a proper event.

For example, this would allow for meeting events to be listed in a daily note, and also created in the calendar, for example:

### Project X Meeting #create_event 10-11am

In combination with the date offset patterns above, it further allows scheduling preparation time days or hours before events, for example:

### Project X Meeting #create_event 10-11am
* write agenda {-5d} #create_event 9:00-9:30

Blank meeting header at EOF not removed

Going to try to find some time to look at this one myself, but figured I should get it on the radar.

A meeting header (from my icalBuddy script) at EOF isn't removed if that meeting doesn't result in any notes.

Use separate file for settings

If a user has made settings changes by tweaking the variables at the top of npTools.rb they are lost when installing a new version. I should move the settings out to a separate JSON file, to avoid this step.

Bug in move_calendar_to_notes

For file including

* [ ] Weekly waste collections in Basingstoke and Deane are set to resume from Monday 17 August [[Admin (Home)]] >2020-08-16

This --moreverbose output:

Cleaning file id 0 20200723
  remove_empty_tasks ...
  remove_empty_trailing_lines ...
  - removed 1 empty lines
  remove_tags_dates ...
  process_repeats ...
  move_calendar_to_notes ...
  - found note link [[Admin (Home)]] in task on line 3 of 4
  - starting task analysis at line 3 with indent '' (0)
Traceback (most recent call last):
	3: from /Users/jonathan/bin/npTools:760:in `<main>'
	2: from /Users/jonathan/bin/npTools:760:in `each'
	1: from /Users/jonathan/bin/npTools:766:in `block in <main>'
/Users/jonathan/bin/npTools:236:in `move_calendar_to_notes': undefined method `scan' for nil:NilClass (NoMethodError)

Don't Archive Tasks Automatically – Option

I like to use the ## Done section sporadically. It'd be nice if there was an option flag to disable this. I have the piece of code that needs to be changed, but I'm not 100% familiar with Ruby to add an option.

  • Add option conditional around lines 283-420

Support files with .md extensions

The NP developer said (Reddit, 18.8.2020) that it's planned to add support for .md file extensions not just .txt. Therefore my scripts need to support this as well.

Not moving items to notes in sub-folders

It's now failing to move items to notes which are now in sub-folders.
Raises a related question: how does NP know which sub-folder is implied if there are multiple notes with the same [[Title]] in a reference?

Extend repeat to allow weekdays

Following recent discussion in the NotePlan Discord, we felt it would be good to extend npTools' repeat mechanism to include weekdays (b) not just days (d).

NB: For now this will not include any attempt to understand or implement bank or public holidays. At least in the UK, I'm not aware of any way to calculate these holidays; they are set by a group of people and then disseminated.

Moving subheads and contents when archiving

Need to make Archiving smart to move subheads and their contents as well - Or is the better archiving now introduced in v2.4.4 enough?

Some earlier jottings:

# Spec for subheads etc.
# Read all into a more detailed data structure and then write out?
#  - Title line
#  - 1 or 2 metadata lines, starting with #tag or Aim:
#  - open section
#    - (opt) Heading line
#      - (opt) Sub-heading
#        - (opt) Task
#        - indented lines of comment or bullet or just text
#  - done section ('#[#] Done') -- to include cancelled, unlike NP built-in behaviour
#    - as above

Don't Remove Scheduled Text From Completed Tasks – Option

I found that in order to see a running list of completed tasks in the Filters, I have to keep the scheduled text on the completed tasks. It'd be nice if there was an option flag to disable this. I have the piece of code that needs to be changed, but I'm not 100% familiar with Ruby to add an option.

  • Add option conditional around lines 136-140

Remove empty header lines and empty header sections

Also remove:

  1. empty header lines (i.e. has #s but no non-whitespace)
  2. empty header sections (i.e. no content after this header and before header of same or higher level (fewer #s))

This is at the request of @BMStroh on the Discord forum for NotePlan 3.

Make work with CloudKit storage

NotePlan from v3.0 can use CloudKit for storage, not just iCloud Drive or Dropbox. Need to update this script to allow for CloudKit.

Create event not working in 12-hour settings

In other user testing it turns out the create event doesn't work if the "Languages & Region" setting is set to 12-Hour not 24-Hour time. In further testing of the AppleScript, it seems that date-time strings ending "12:34 am" or "12:34PM" (etc.) work in either context but strings ending "12:34:00" (as it does so far) or "12:34" only works with 24-hour setting.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.