New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add 'title' command. #203

Merged
merged 3 commits into from May 2, 2016

Conversation

2 participants
@tohojo
Contributor

tohojo commented Apr 27, 2016

I found myself wanting a quick way to add simple titles to lots of images. Rather than writing a separate script I thought that just adding a new command to sigal itself might be easier. Do you think this is worth including in upstream sigal? In that case I can add test cases and documentation for it, but wanted to see if you'd want to take it at all first...

Add 'title' command.
This adds a 'title' command to make it easier to add titles to images.
It basically takes an image filename and a title, and will write a
corresponding .md file with the Title attribute.

Signed-off-by: Toke Høiland-Jørgensen <toke@toke.dk>
@saimn

This comment has been minimized.

Owner

saimn commented Apr 28, 2016

It can be useful so +1 but maybe a bit more generic, to allow writing several key/value pairs at once ? Then we also need a more generic name ;)

@main.command()
@argument('image')
@argument('title')
@option('-f', '--force', default=False, is_flag=True,

This comment has been minimized.

@saimn

saimn Apr 28, 2016

Owner

I would prefer overwrite to force, more explicit on what it does.

@saimn

This comment has been minimized.

Owner

saimn commented Apr 28, 2016

It could be useful for albums as well.

@tohojo

This comment has been minimized.

Contributor

tohojo commented May 1, 2016

Something like this?

@option('-o', '--overwrite', default=False, is_flag=True,
help='Overwrite existing .md file')
def set_meta(target, keys, overwrite=False):
"""Write image title to corresponding .md file.

This comment has been minimized.

@saimn

saimn May 1, 2016

Owner

Docstring needs to be updated, mention that target can be a directory or a media file.

with open(descfile, "w") as fp:
for i in range(len(keys)//2):
k,v = keys[i*2:(i+1)*2]
fp.write("{}: {}\n".format(k.capitalize(), v))

This comment has been minimized.

@saimn

saimn May 1, 2016

Owner

Maybe a print with the name of the file that has been written can be useful for users ?

@saimn

This comment has been minimized.

Owner

saimn commented May 1, 2016

Much better, thanks :)
Could you also add a test (in test_cli.py) ?

@tohojo

This comment has been minimized.

Contributor

tohojo commented May 1, 2016

Yup, can do; just wanted to check with you that the interface is acceptable ;)

tohojo added some commits May 1, 2016

Turn 'title' command into a more generic 'set_meta' command.
This can set an arbitrary number of meta keys and also supports creating
meta files for directories (i.e. index.md files).

Signed-off-by: Toke Høiland-Jørgensen <toke@toke.dk>
Add test for set_meta command.
Signed-off-by: Toke Høiland-Jørgensen <toke@toke.dk>

@tohojo tohojo force-pushed the tohojo:title-command branch from b824b14 to e6519d1 May 1, 2016

@tohojo

This comment has been minimized.

Contributor

tohojo commented May 1, 2016

And there's the test :)

@saimn saimn merged commit 929f612 into saimn:master May 2, 2016

1 check passed

continuous-integration/travis-ci/pr The Travis CI build passed
Details
@saimn

This comment has been minimized.

Owner

saimn commented May 2, 2016

👍

@saimn saimn added this to the 1.2.0 milestone May 2, 2016

@tohojo tohojo deleted the tohojo:title-command branch May 2, 2016

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment