Giter Site home page Giter Site logo

paper-to-git's Introduction

Paper to Git Build Status

This project aims to sync documents between Dropbox Paper and any local Git repository. Why? Because apart from all other features that Paper has, it is an excellent in-browser markdown editor.

This is an effort to create and automate Paper->Github Pages workflow, where I can create and publish my blog posts by writing them in dropbox paper and automatically fetching it from there and publishing it in Github Pages.

Current State: This project is currently in its very initial stages and nothing is guaranteed to work. I will update this as the project moves forward.

Install

To install, try out the following commands:

$ pip install papergit

Usage

Web Interface

Paper-to-Git comes with a neat little Web Frontend written in Flask. You can run that by using:

$ paper-git serve

If this is your first time, you will have to authorize usage of your dropbox account. See more on that below.

Commandline

You can run paper-git --help in the console to print out the help text.

The first time you use paper-git, it will create a var directory in the current working directory. This directory will hold the important files and database related to paper-git.

On the first run of any commnad, like paper-git list will run the authorization workflow for you to allow paper-git access to your Dropbox account. Not that even if you allow, I cannot access anything in your account as the authorization token is stored locally only on your machine.

The flow looks something like this:

$ paper-git list
1. Go to: https://www.dropbox.com/oauth2/authorize?client_id=<client_id>&response_type=code
2. Click "Allow" (you might have to log in first).
3. Copy the authorization code.
Enter the authorization code here: <authorization code>

This will store your authorization token in the user configuration file at var/etc/paper-git.cfg.

If you want this configuration to persist from anywhere, just copy var/etc/paper-git.cfg to /etc/paper-git.cfg.

After this, you can run update command to pull the list of all the docs:

$ paper-git update

Note that update command doesn't pull changes in the already exsting docs in the database. To update an existing document in the database try:

$ paper-git update <doc-id>

You can list all the docs in the database using:

$ paper-git list --docs

or you can list all the folders using:

$ paper-git list --folder

You can also add a Sync object to a tie together a path in a git repo to a Paper Folder so that they can be synchronized automatically.

$ paper-git add --repo <path/to/git/repo/root/> --path <path/in/git/repo> --folder <paper-folder-name>

Note that the <paper-folder-name> in the above command is case-insensitive. Once you replace all the variables and the above command runs successfully, you have added a new rule to sync the documents.

After you have add a new rule, now you can publish your documents to their respective. publish command will copy the downloaded files to their new destination along with some added metadata that most common static site generators expect.

While the addition of metadata can be turned off if needed, it is turned on by defualt for now.

$ paper-git publish <doc-id>

Note that this will only work for changes that have already been pulled down using the update command.

You can play paper-git using an interactive shell by using the shell command:

$ paper-git shell

This will a start an interactive ipython shell with an initialized config object.

In [1]: config
Out[1]: <paper_to_git.config.config.BaseConfig at 0x7f2ca4cd6cc0>

In [2]: config.db
Out[2]: <paper_to_git.database.BaseDatabase at 0x7f2ca4cd64a8>

You can play with the models and interact with the database:

In [3]: from paper_to_git.models import PaperDoc

In [4]: for doc in PaperDoc.select():
   ...:     print(doc)
   ...:
1: Document <1>
2: Document <2>
3: Document <3>

You can also force sync of a Doc, which you have changed:

In [5]: doc = PaperDoc.get_by_paper_id('<paper_doc_id>')

In [6]: doc.get_changes()
Update revision for doc <Doc> from 54 to 69

License:

This project is licensed under Apache License 2.0. Please see the LICENSE file for a complete copy of license.

paper-to-git's People

Contributors

jiteshpabla avatar maxking avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

paper-to-git's Issues

Help Command

$paper_git --help
$paper_to_git --help

The above two shell commands are not working. May be you need to update the README.md file of the project and Clarify how to use this project.

image

Sync images

Figure out a way to sync images from Paper to Git. It might need additional work to put images in the correct static location.

Allow tags

It should not be very difficult to support tags. Right now, only date and name is added as metadata to each post.

In figure, maybe we can use hashtags in Paper Docs and convert them to tags in the document?

Web Frontend throws exception: TemplateNotFound index.html

Web Frontend tracebacks with template error on accessing http://127.0.0.1:5000/

  • I installed paper-to-git on my Ubuntu 18.04 system (Python 3.6.5).
  • Created a env using pipenv
  • Started web frontend
  • Tried accessing it from browser
(paper-JfzL-Txt) [shon@laptop:~/paper] $ paper-git serve
 * Serving Flask app "papergit.server" (lazy loading)
 * Environment: production
   WARNING: Do not use the development server in a production environment.
   Use a production WSGI server instead.
 * Debug mode: off
 * Running on http://127.0.0.1:5000/ (Press CTRL+C to quit)
[2018-09-18 11:35:48,605] ERROR in app: Exception on / [GET]
Traceback (most recent call last):
  File "/home/shon/.local/share/virtualenvs/paper-JfzL-Txt/lib/python3.6/site-packages/flask/app.py", line 2292, in wsgi_app
    response = self.full_dispatch_request()
  File "/home/shon/.local/share/virtualenvs/paper-JfzL-Txt/lib/python3.6/site-packages/flask/app.py", line 1815, in full_dispatch_request
    rv = self.handle_user_exception(e)
  File "/home/shon/.local/share/virtualenvs/paper-JfzL-Txt/lib/python3.6/site-packages/flask/app.py", line 1718, in handle_user_exception
    reraise(exc_type, exc_value, tb)
  File "/home/shon/.local/share/virtualenvs/paper-JfzL-Txt/lib/python3.6/site-packages/flask/_compat.py", line 35, in reraise
    raise value
  File "/home/shon/.local/share/virtualenvs/paper-JfzL-Txt/lib/python3.6/site-packages/flask/app.py", line 1813, in full_dispatch_request
    rv = self.dispatch_request()
  File "/home/shon/.local/share/virtualenvs/paper-JfzL-Txt/lib/python3.6/site-packages/flask/app.py", line 1799, in dispatch_request
    return self.view_functions[rule.endpoint](**req.view_args)
  File "/home/shon/.local/share/virtualenvs/paper-JfzL-Txt/lib/python3.6/site-packages/papergit/server.py", line 26, in index
    folders=PaperFolder.select())
  File "/home/shon/.local/share/virtualenvs/paper-JfzL-Txt/lib/python3.6/site-packages/flask/templating.py", line 134, in render_template
    return _render(ctx.app.jinja_env.get_or_select_template(template_name_or_list),
  File "/home/shon/.local/share/virtualenvs/paper-JfzL-Txt/lib/python3.6/site-packages/jinja2/environment.py", line 869, in get_or_select_template
    return self.get_template(template_name_or_list, parent, globals)
  File "/home/shon/.local/share/virtualenvs/paper-JfzL-Txt/lib/python3.6/site-packages/jinja2/environment.py", line 830, in get_template
    return self._load_template(name, self.make_globals(globals))
  File "/home/shon/.local/share/virtualenvs/paper-JfzL-Txt/lib/python3.6/site-packages/jinja2/environment.py", line 804, in _load_template
    template = self.loader.load(self, name, globals)
  File "/home/shon/.local/share/virtualenvs/paper-JfzL-Txt/lib/python3.6/site-packages/jinja2/loaders.py", line 113, in load
    source, filename, uptodate = self.get_source(environment, name)
  File "/home/shon/.local/share/virtualenvs/paper-JfzL-Txt/lib/python3.6/site-packages/flask/templating.py", line 58, in get_source
    return self._get_source_fast(environment, template)
  File "/home/shon/.local/share/virtualenvs/paper-JfzL-Txt/lib/python3.6/site-packages/flask/templating.py", line 86, in _get_source_fast
    raise TemplateNotFound(template)
jinja2.exceptions.TemplateNotFound: index.html
127.0.0.1 - - [18/Sep/2018 11:35:48] "GET / HTTP/1.1" 500 -
127.0.0.1 - - [18/Sep/2018 11:35:48] "GET /favicon.ico HTTP/1.1" 404 -

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.