mirror of
https://github.com/jrnl-org/jrnl.git
synced 2025-05-10 16:48:31 +02:00
Merge pull request #143 from maebert/dayone-tag-search
Adds the tag symbol to day one entries on load
This commit is contained in:
commit
c93174f4f4
2 changed files with 16 additions and 7 deletions
|
@ -33,8 +33,8 @@ Feature: DayOne Ingetration
|
||||||
When we run "jrnl --tags"
|
When we run "jrnl --tags"
|
||||||
Then the output should be
|
Then the output should be
|
||||||
"""
|
"""
|
||||||
work : 1
|
@work : 1
|
||||||
play : 1
|
@play : 1
|
||||||
"""
|
"""
|
||||||
|
|
||||||
Scenario: Saving tags from a DayOne Journal
|
Scenario: Saving tags from a DayOne Journal
|
||||||
|
@ -43,6 +43,14 @@ Feature: DayOne Ingetration
|
||||||
and we run "jrnl --tags"
|
and we run "jrnl --tags"
|
||||||
Then the output should be
|
Then the output should be
|
||||||
"""
|
"""
|
||||||
work : 2
|
@work : 2
|
||||||
play : 1
|
@play : 1
|
||||||
|
"""
|
||||||
|
|
||||||
|
Scenario: Filtering by tags from a DayOne Journal
|
||||||
|
Given we use the config "dayone.json"
|
||||||
|
When we run "jrnl @work"
|
||||||
|
Then the output should be
|
||||||
|
"""
|
||||||
|
2013-05-17 11:39 This entry has tags!
|
||||||
"""
|
"""
|
||||||
|
|
|
@ -25,6 +25,7 @@ import pytz
|
||||||
import uuid
|
import uuid
|
||||||
import tzlocal
|
import tzlocal
|
||||||
|
|
||||||
|
|
||||||
class Journal(object):
|
class Journal(object):
|
||||||
def __init__(self, name='default', **kwargs):
|
def __init__(self, name='default', **kwargs):
|
||||||
self.config = {
|
self.config = {
|
||||||
|
@ -318,6 +319,7 @@ class Journal(object):
|
||||||
entry.modified = not any(entry == old_entry for old_entry in self.entries)
|
entry.modified = not any(entry == old_entry for old_entry in self.entries)
|
||||||
self.entries = mod_entries
|
self.entries = mod_entries
|
||||||
|
|
||||||
|
|
||||||
class DayOne(Journal):
|
class DayOne(Journal):
|
||||||
"""A special Journal handling DayOne files"""
|
"""A special Journal handling DayOne files"""
|
||||||
def __init__(self, **kwargs):
|
def __init__(self, **kwargs):
|
||||||
|
@ -342,7 +344,7 @@ class DayOne(Journal):
|
||||||
title, body = (raw[:sep.end()], raw[sep.end():]) if sep else (raw, "")
|
title, body = (raw[:sep.end()], raw[sep.end():]) if sep else (raw, "")
|
||||||
entry = Entry.Entry(self, date, title, body, starred=dict_entry["Starred"])
|
entry = Entry.Entry(self, date, title, body, starred=dict_entry["Starred"])
|
||||||
entry.uuid = dict_entry["UUID"]
|
entry.uuid = dict_entry["UUID"]
|
||||||
entry.tags = dict_entry.get("Tags", [])
|
entry.tags = [self.config['tagsymbols'][0] + tag for tag in dict_entry.get("Tags", [])]
|
||||||
self.entries.append(entry)
|
self.entries.append(entry)
|
||||||
self.sort()
|
self.sort()
|
||||||
|
|
||||||
|
@ -353,7 +355,7 @@ class DayOne(Journal):
|
||||||
if not hasattr(entry, "uuid"):
|
if not hasattr(entry, "uuid"):
|
||||||
entry.uuid = uuid.uuid1().hex
|
entry.uuid = uuid.uuid1().hex
|
||||||
utc_time = datetime.utcfromtimestamp(time.mktime(entry.date.timetuple()))
|
utc_time = datetime.utcfromtimestamp(time.mktime(entry.date.timetuple()))
|
||||||
filename = os.path.join(self.config['journal'], "entries", entry.uuid+".doentry")
|
filename = os.path.join(self.config['journal'], "entries", entry.uuid + ".doentry")
|
||||||
entry_plist = {
|
entry_plist = {
|
||||||
'Creation Date': utc_time,
|
'Creation Date': utc_time,
|
||||||
'Starred': entry.starred if hasattr(entry, 'starred') else False,
|
'Starred': entry.starred if hasattr(entry, 'starred') else False,
|
||||||
|
@ -430,4 +432,3 @@ class DayOne(Journal):
|
||||||
self._deleted_entries = [e for e in self.entries if e.uuid not in edited_uuids]
|
self._deleted_entries = [e for e in self.entries if e.uuid not in edited_uuids]
|
||||||
self.entries[:] = [e for e in self.entries if e.uuid in edited_uuids]
|
self.entries[:] = [e for e in self.entries if e.uuid in edited_uuids]
|
||||||
return entries
|
return entries
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue