diff --git a/.gitignore b/.gitignore index 6974d9a..886130e 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,4 @@ config.json *.kdev4 +*.kate-swp +*.swp diff --git a/example-config.json b/example-config.json index af4b0ed..fcbfd8e 100644 --- a/example-config.json +++ b/example-config.json @@ -1,4 +1,8 @@ { "token":"access token here, don't share this with anyone", - "instance":"https://example.com" + "instance":"example.com", + "visibility":"unlisted", + + "gopher":"example.com", + "phlog_format":0 } diff --git a/tootgopher.py b/tootgopher.py index 54497e3..b2c8a27 100755 --- a/tootgopher.py +++ b/tootgopher.py @@ -16,10 +16,27 @@ def gen_masto_obj(config_data: dict) -> Mastodon: ) return m +# generate phlog URLs for linking in the post +def gen_url(config_data: dict, phlog_file: str) -> dict: + base_path = f"{config_data['gopher']}/{config_data['phlog_format']}/{phlog_file}" + gopher_url = f"gopher://{base_path}" + proxy_url = f"https://{config_data['proxy']}/{base_path}" + urls = {'gopher':gopher_url, 'proxy':proxy_url} + return urls + def main(): + # TODO: handle command line switches to override defaults config_data = load_config() m = gen_masto_obj(config_data) - m.toot('Test toot please ignore') + + phlog_file = 'test.txt' + urls = gen_url(config_data, phlog_file) + + # TODO: Spawn $EDITOR, content warnings + text = "Test post, please ignore" + post = f"{text}\n\nGopher: {urls['gopher']}\nHTML Proxy: {urls['proxy']}" + + m.status_post(post, visibility=config_data['visibility']) if __name__ == '__main__': main()