Skip to content

Commit

Permalink
Minor updates
Browse files Browse the repository at this point in the history
- updated README
- removed Archive and Delete from menu as they have not been implemented yet
- added options to display when using the list: date last modified, folder, and fullpath.
  • Loading branch information
fk128 committed Dec 20, 2014
1 parent ad89354 commit 8c5dede
Show file tree
Hide file tree
Showing 5 changed files with 62 additions and 15 deletions.
6 changes: 3 additions & 3 deletions Main.sublime-menu
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,9 @@
{ "caption": "Index", "command": "notes_buffer"},
{ "caption": "-" , "id": "note" },
{ "caption": "Change Color…", "command": "note_change_color"},
{ "caption": "Archive…", "command": "note_archive"},
{ "caption": "Delete…", "command": "note_remove"},
{ "caption": "Rename…", "command": "note_rename"},
// { "caption": "Archive…", "command": "note_archive"},
// { "caption": "Delete…", "command": "note_remove"},
{ "caption": "Rename…", "command": "notes_rename"},
{ "caption": "-" , "id": "end" }
]
}
Expand Down
7 changes: 6 additions & 1 deletion Notes.sublime-settings
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,10 @@
"enable_yaml": false,
"note_save_extension": "note",
"note_file_extensions": ["md","note"],
"note_yaml" : ["categories"]
"note_yaml" : ["categories"],
"list_options" : {
"display_modified_date": true,
"display_folder": false,
"display_full_path": false
}
}
15 changes: 14 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,24 @@ Open command palette and search for `Note: Change Color…`. it will give you a
Color of the note is remembered by PlainNotes and whenever you open that file, PlainNotes will set the color-scheme automatically.

#### Change note file extension
You can change the note file extension in settings. To do so, go to `Preferences -> Package Settings -> PlainNotes -> Settings - User` and modify `"note_save_extension":`
You can change the note file extension in settings. To do so, go to `Preferences -> Package Settings -> PlainNotes -> Settings - User` and modify `"note_save_extension":`. The default note type is `.note` which has the possibility of setting different note colors and some special markup.

### Add yaml front matter to notes
go to `Preferences -> Package Settings -> PlainNotes -> Settings - User` and modify `"enable_yaml"`

By default, the following yaml is added:
```
title:
date:
tags:
```

to add more yaml you can add them in the settings by modifying `note_yaml:`:

```
"note_yaml" : ["categories"]
```

## License

Copyright 2014 [Allen Bargi](https://twitter.com/aziz). Licensed under the MIT License
Expand Down
5 changes: 5 additions & 0 deletions lib/helpers.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Helper functions

def return_sublist(main_list, indices ):
sublist = [[item[i] for i in indices] for item in main_list]
return sublist
44 changes: 34 additions & 10 deletions notes.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import sublime, sublime_plugin
import os, fnmatch, re, time
import helpers

from gzip import GzipFile
from pickle import load, dump
Expand All @@ -15,11 +16,31 @@ def file_id(path):
class NotesListCommand(sublime_plugin.ApplicationCommand):

def run(self):
root = os.path.normpath(os.path.expanduser(settings().get("root")))
window = sublime.active_window()
self.notes_dir = os.path.expanduser(root)
self.file_list = self.find_notes(root)
window.show_quick_panel([f[0] for f in self.file_list], self.open_note)
root = os.path.normpath(os.path.expanduser(settings().get("root")))
window = sublime.active_window()
self.notes_dir = os.path.expanduser(root)
self.file_list = self.find_notes(root)

# list display options
try:
display_modified_date = settings().get("list_options").get("display_modified_date")
display_folder = settings().get("list_options").get("display_folder")
display_full_path = settings().get("list_options").get("display_full_path")
except:
display_modified_date = True
display_folder = True
display_full_path = False

indices = [0]
if display_modified_date == True:
indices.append(3)
if display_folder == True:
indices.append(2)
if display_full_path == True:
indices.append(1)

window.show_quick_panel( helpers.return_sublist(self.file_list, indices ), self.open_note)


def find_notes(self, root):
note_files = []
Expand All @@ -32,12 +53,15 @@ def find_notes(self, root):
tag = path.replace(root, '').replace(os.path.sep, '')
if not tag == '':
tag = tag + ': '
note_files.append((re.sub('\.' + ext + '$', '', tag + title),
modified_str = time.strftime("Last modified: %d/%m/%Y %H:%M", time.gmtime(os.path.getmtime(os.path.join(path, name))));
#created_str = time.strftime("Created: %d/%m/%Y %H:%M", time.gmtime(os.path.getctime(os.path.join(path, name))));
note_files.append([re.sub('\.' + ext + '$', '', tag + title),
os.path.join(path, name),
os.path.getmtime(os.path.join(path, name)),
tag
))
note_files.sort(key=lambda item: item[2], reverse=True)
tag,
modified_str
])

note_files.sort(key=lambda item: os.path.getmtime(item[1]), reverse=True)
return note_files

def open_note(self, index):
Expand Down

0 comments on commit 8c5dede

Please sign in to comment.