3 Commits

Author SHA1 Message Date
92baf351a5 Merge branch 'allow-specifying-listening-host' 2022-03-12 02:06:32 +01:00
9e7c2c5a49 Merge branch 'privatization-fixes' 2022-03-12 02:06:18 +01:00
f598c3056d Allow setting the host parameter
In order to run in a Docker container, it is necessary to listen on all interfaces (`0.0.0.0`).
So make it possible to set the host.

Fixes #1

Signed-off-by: Jacob Kiers <code@kiers.eu>
2022-03-12 00:50:21 +01:00
2 changed files with 14 additions and 24 deletions

View File

@@ -84,7 +84,7 @@ class ListenCommand(CliCommand):
@classmethod @classmethod
def setup_arguments(cls, parser: argparse.ArgumentParser) -> None: def setup_arguments(cls, parser: argparse.ArgumentParser) -> None:
parser.add_argument( parser.add_argument(
"--host", "-h", "--host",
metavar="HOST", metavar="HOST",
help="Host to listen on.", help="Host to listen on.",
default=str(cm().listen_host or "127.0.0.1"), default=str(cm().listen_host or "127.0.0.1"),

View File

@@ -360,7 +360,7 @@ def _private_people_replacement_table(
@tzk_builder @tzk_builder
def replace_private_people(initialer: Callable[[str], str] = None, replace_link_text = False) -> None: def replace_private_people(initialer: Callable[[str], str] = None, replace_text = False) -> None:
""" """
Replace the names of people who are not marked Public with their initials. Replace the names of people who are not marked Public with their initials.
@@ -378,26 +378,16 @@ def replace_private_people(initialer: Callable[[str], str] = None, replace_link_
(e.g., MsJaneDoe becomes J.D.). The links point to the tiddler ``PrivatePerson``, (e.g., MsJaneDoe becomes J.D.). The links point to the tiddler ``PrivatePerson``,
which explains this process. which explains this process.
:param initialer: If you don't like the way that initials :param initialer: If you don't like the way that initials
are generated from tiddler filenames by default, are generated from tiddler filenames by default,
you can customize it by passing a callable you can customize it by passing a callable
that takes one string argument that takes one string argument
(a tiddler filename without the full path, e.g., ``MsJaneDoe.tid``) (a tiddler filename without the full path, e.g., ``MsJaneDoe.tid``)
and returns a string to be considered the "initials" of that person. and returns a string to be considered the "initials" of that person.
:param replace_link_text: If you have links in the form :param replace_text: If you have links in the form ``[[John|MrJohnDoe]]``, then enabling
``So then [[John said|MrJohnDoe]] something about this``, this option ensures that the link text `John` is also replaced with
then enabling this option ensures that the link is fully the initials.
replaced with
``So then [[J.D.|PrivatePerson]] something about this``.
This means that when using this feature, having the
link text also be meaningful after redaction is important.
.. warning ::
Using this link replacement feature does not redact everything, just the link
(and the link text with `replace_link_text` enabled). So *do not* rely on it
for redacting everything. Making a tiddler public still needs consideration and
tooling is there to help, not to replace your own judgment.
""" """
assert 'public_wiki_folder' in build_state assert 'public_wiki_folder' in build_state
@@ -415,7 +405,7 @@ def replace_private_people(initialer: Callable[[str], str] = None, replace_link_
if '|' + replace_person + ']]' in lines[i]: if '|' + replace_person + ']]' in lines[i]:
# link with the person as the target only; # link with the person as the target only;
# beware that you might have put something private in the text # beware that you might have put something private in the text
if replace_link_text: if replace_text:
# with this option, the initials are also # with this option, the initials are also
# put in the text, solving the warning before # put in the text, solving the warning before
end = lines[i].find('|' + replace_person + ']]') end = lines[i].find('|' + replace_person + ']]')
@@ -425,8 +415,8 @@ def replace_private_people(initialer: Callable[[str], str] = None, replace_link_
lines[i] = lines[i].replace(search, replace) lines[i] = lines[i].replace(search, replace)
else: else:
lines[i] = lines[i].replace(replace_person, 'PrivatePerson') lines[i] = line.replace(replace_person, 'PrivatePerson')
elif '[[' + replace_person + ']]' in lines[i]: elif '[[' + replace_person + ']]' in line:
# link with the person as the target and text # link with the person as the target and text
lines[i] = lines[i].replace( lines[i] = lines[i].replace(
replace_person, replace_person,