mirror of
https://github.com/jrnl-org/jrnl.git
synced 2025-05-17 03:28:31 +02:00
Merge 516b01bb18
into b050f2b030
This commit is contained in:
commit
8e6e426a90
6 changed files with 49 additions and 10 deletions
|
@ -4,6 +4,7 @@ Changelog
|
||||||
|
|
||||||
### 1.7 (December 22, 2013)
|
### 1.7 (December 22, 2013)
|
||||||
|
|
||||||
|
* __1.7.5__ Optional return of colorama (for color on Windows), fixes editing (stops deleting entries instead of editing them), improves Windows documentation.
|
||||||
* __1.7.4__ Gets rid of colorama.
|
* __1.7.4__ Gets rid of colorama.
|
||||||
* __1.7.3__ Touches temporary files before opening them to allow more external editors.
|
* __1.7.3__ Touches temporary files before opening them to allow more external editors.
|
||||||
* __1.7.2__ Dateutil added to requirements.
|
* __1.7.2__ Dateutil added to requirements.
|
||||||
|
|
|
@ -99,3 +99,30 @@ Your ``default`` and your ``food`` journals won't be encrypted, however your ``w
|
||||||
|
|
||||||
Changing ``encrypt`` to a different value will not encrypt or decrypt your journal file, it merely says whether or not your journal `is` encrypted. Hence manually changing this option will most likely result in your journal file being impossible to load.
|
Changing ``encrypt`` to a different value will not encrypt or decrypt your journal file, it merely says whether or not your journal `is` encrypted. Hence manually changing this option will most likely result in your journal file being impossible to load.
|
||||||
|
|
||||||
|
Windows Usage
|
||||||
|
-------------
|
||||||
|
|
||||||
|
A couple of tips to get jrnl working better on Windows:
|
||||||
|
|
||||||
|
To get colored output on Windows, install ``colorama`` ::
|
||||||
|
|
||||||
|
pip install colorama
|
||||||
|
|
||||||
|
The configuration file is typically found at ``C:\Users\[Your Username\.jrnl_conf``. This is just a text file and so can be edited in a text editor (but don't use Notepad, it will mess with the line endings).
|
||||||
|
|
||||||
|
For editing entries, Notepad will technically work, but doesn't play nice with line endings. A good alternative is `Notepad++ <http://notepad-plus-plus.org/>`_. To set Notepad++ as your editor, edit the jrnl config file (``.jrnl_conf``) like this:
|
||||||
|
|
||||||
|
.. code-block:: javascript
|
||||||
|
|
||||||
|
{
|
||||||
|
...
|
||||||
|
"editor": "C:\\Program Files (x86)\\Notepad++\\notepad++.exe -multiInst",
|
||||||
|
}
|
||||||
|
|
||||||
|
The double backslashes are needed so jrnl can read the file path correctly. The ``-multiInst`` option will cause jrnl to open its own Notepad++ windows. When you're done editing an entry in Notepad++, save the file and close the Notepad++ window for jrnl to know you're done editing and record your changes.
|
||||||
|
|
||||||
|
Known Issues
|
||||||
|
~~~~~~~~~~~~
|
||||||
|
|
||||||
|
- The Windows shell prior to Windows 7 has issues with unicode encoding. If you want to use non-ascii characters, change the codepage with ``chcp 1252`` before using `jrnl` (Thanks to Yves Pouplard for solving this!)
|
||||||
|
- _jrnl_ relies on the `PyCrypto` package to encrypt journals, which has some known problems with installing on Windows and within virtual environments.
|
||||||
|
|
|
@ -21,6 +21,11 @@ try:
|
||||||
except ImportError:
|
except ImportError:
|
||||||
crypto_installed = False
|
crypto_installed = False
|
||||||
import hashlib
|
import hashlib
|
||||||
|
try:
|
||||||
|
import colorama
|
||||||
|
colorama.init()
|
||||||
|
except ImportError:
|
||||||
|
colorama = None
|
||||||
import plistlib
|
import plistlib
|
||||||
import pytz
|
import pytz
|
||||||
import uuid
|
import uuid
|
||||||
|
@ -163,11 +168,11 @@ class Journal(object):
|
||||||
for tag in self.search_tags:
|
for tag in self.search_tags:
|
||||||
tagre = re.compile(re.escape(tag), re.IGNORECASE)
|
tagre = re.compile(re.escape(tag), re.IGNORECASE)
|
||||||
pp = re.sub(tagre,
|
pp = re.sub(tagre,
|
||||||
lambda match: util.colorize(match.group(0)),
|
lambda match: util.colorize(match.group(0), colorama),
|
||||||
pp, re.UNICODE)
|
pp, re.UNICODE)
|
||||||
else:
|
else:
|
||||||
pp = re.sub(r"(?u)([{tags}]\w+)".format(tags=self.config['tagsymbols']),
|
pp = re.sub(r"(?u)([{tags}]\w+)".format(tags=self.config['tagsymbols']),
|
||||||
lambda match: util.colorize(match.group(0)),
|
lambda match: util.colorize(match.group(0), colorama),
|
||||||
pp)
|
pp)
|
||||||
return pp
|
return pp
|
||||||
|
|
||||||
|
@ -430,4 +435,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
|
||||||
|
|
||||||
|
|
|
@ -7,10 +7,10 @@ jrnl is a simple journal application for your command line.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
__title__ = 'jrnl'
|
__title__ = 'jrnl'
|
||||||
__version__ = '1.7.4'
|
__version__ = '1.7.5'
|
||||||
__author__ = 'Manuel Ebert'
|
__author__ = 'Manuel Ebert'
|
||||||
__license__ = 'MIT License'
|
__license__ = 'MIT License'
|
||||||
__copyright__ = 'Copyright 2013 Manuel Ebert'
|
__copyright__ = 'Copyright 2013-14 Manuel Ebert'
|
||||||
|
|
||||||
from . import Journal
|
from . import Journal
|
||||||
from . import cli
|
from . import cli
|
||||||
|
|
|
@ -82,6 +82,11 @@ def install_jrnl(config_path='~/.jrnl_config'):
|
||||||
password = None
|
password = None
|
||||||
print("PyCrypto not found. To encrypt your journal, install the PyCrypto package from http://www.pycrypto.org or with 'pip install pycrypto' and run 'jrnl --encrypt'. For now, your journal will be stored in plain text.")
|
print("PyCrypto not found. To encrypt your journal, install the PyCrypto package from http://www.pycrypto.org or with 'pip install pycrypto' and run 'jrnl --encrypt'. For now, your journal will be stored in plain text.")
|
||||||
|
|
||||||
|
# Use highlighting:
|
||||||
|
if os.name == "nt" and not module_exists("colorama"):
|
||||||
|
print("colorama not found. To turn on highlighting, install colorama and set highlight to true in your .jrnl_conf.")
|
||||||
|
default_config['highlight'] = False
|
||||||
|
|
||||||
open(default_config['journals']['default'], 'a').close() # Touch to make sure it's there
|
open(default_config['journals']['default'], 'a').close() # Touch to make sure it's there
|
||||||
|
|
||||||
# Write config to ~/.jrnl_conf
|
# Write config to ~/.jrnl_conf
|
||||||
|
|
12
jrnl/util.py
12
jrnl/util.py
|
@ -126,11 +126,11 @@ def load_and_fix_json(json_path):
|
||||||
|
|
||||||
def get_text_from_editor(config, template=""):
|
def get_text_from_editor(config, template=""):
|
||||||
tmpfile = os.path.join(tempfile.gettempdir(), "jrnl")
|
tmpfile = os.path.join(tempfile.gettempdir(), "jrnl")
|
||||||
|
with open(tmpfile, 'w'):
|
||||||
|
pass
|
||||||
if template:
|
if template:
|
||||||
with codecs.open(tmpfile, 'w', "utf-8") as f:
|
with codecs.open(tmpfile, 'w', "utf-8") as f:
|
||||||
f.write(template)
|
f.write(template)
|
||||||
with open(tmpfile, 'w'):
|
|
||||||
pass
|
|
||||||
subprocess.call(config['editor'].split() + [tmpfile])
|
subprocess.call(config['editor'].split() + [tmpfile])
|
||||||
with codecs.open(tmpfile, "r", "utf-8") as f:
|
with codecs.open(tmpfile, "r", "utf-8") as f:
|
||||||
raw = f.read()
|
raw = f.read()
|
||||||
|
@ -139,7 +139,9 @@ def get_text_from_editor(config, template=""):
|
||||||
prompt('[Nothing saved to file]')
|
prompt('[Nothing saved to file]')
|
||||||
return raw
|
return raw
|
||||||
|
|
||||||
def colorize(string):
|
def colorize(string, colorama=None):
|
||||||
"""Returns the string wrapped in cyan ANSI escape"""
|
"""Returns the string wrapped in cyan ANSI escape"""
|
||||||
return u"\033[36m{}\033[39m".format(string)
|
if os.name == "nt" and not colorama:
|
||||||
|
return string
|
||||||
|
else:
|
||||||
|
return u"\033[36m{}\033[39m".format(string)
|
||||||
|
|
Loading…
Add table
Reference in a new issue