Fava setup on a publicly available server

494 views
Skip to first unread message

Konstantin

unread,
Feb 6, 2018, 2:14:49 PM2/6/18
to Beancount
Hi

At the moment I use vim + vim-beancount plugin to manage my ledger file and I also use local fava install to view fancy graphs. I would also like to install fava on a VPS to be able to access these fancy graphs from my phone and maybe enter a transaction or two on the go.

What is the recommended way of two-way syncing of ledger files between my computer and remote VPS?

yegle

unread,
Feb 6, 2018, 2:38:10 PM2/6/18
to Beancount
Personally I use Dropbox to sync the work directory of a git repo and keep bare git repo at a different location.

Use a script like this to setup my environment:

GIT_WORK_TREE=/path/to/Dropbox/synced/work/dir GIT_DIR=/path/to/bare/git/repo zsh


--
You received this message because you are subscribed to the Google Groups "Beancount" group.
To unsubscribe from this group and stop receiving emails from it, send an email to beancount+...@googlegroups.com.
To post to this group, send email to bean...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/beancount/abda316e-0d39-49fc-9b39-4a513bc6bf80%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


--

Oon-Ee Ng

unread,
Feb 7, 2018, 11:08:41 PM2/7/18
to bean...@googlegroups.com
I just sync the beancount files via git and run on my VPS a polling script to pull/push as needed. Also I use fava's plugin capabilities to commit every time an edit happens.

Conflicts happen once in a while, but manually handling those aren't hard.

--
You received this message because you are subscribed to the Google Groups "Beancount" group.
To unsubscribe from this group and stop receiving emails from it, send an email to beancount+unsubscribe@googlegroups.com.

Stefano Zacchiroli

unread,
Feb 8, 2018, 3:50:07 AM2/8/18
to bean...@googlegroups.com
On Thu, Feb 08, 2018 at 12:08:40PM +0800, Oon-Ee Ng wrote:
> Also I use fava's plugin capabilities to commit every time an edit
> happens.

Can you tell us more about this? It's the first time I hear about it,
and it looks interesting to me. Also, given "git commit + git push" is
probably a standard need for many people editing via Fava, would a
"official" plugin for doing this be welcome?

TIA,
Cheers.
--
Stefano Zacchiroli . za...@upsilon.cc . upsilon.cc/zack . . o . . . o . o
Computer Science Professor . CTO Software Heritage . . . . . o . . . o o
Former Debian Project Leader & OSI Board Director . . . o o o . . . o .
« the first rule of tautology club is the first rule of tautology club »

Oon-Ee Ng

unread,
Feb 19, 2018, 8:19:53 PM2/19/18
to bean...@googlegroups.com
On Thu, Feb 8, 2018 at 4:50 PM, Stefano Zacchiroli <za...@upsilon.cc> wrote:
On Thu, Feb 08, 2018 at 12:08:40PM +0800, Oon-Ee Ng wrote:
> Also I use fava's plugin capabilities to commit every time an edit
> happens.

Can you tell us more about this? It's the first time I hear about it,
and it looks interesting to me. Also, given "git commit + git push" is
probably a standard need for many people editing via Fava, would a
"official" plugin for doing this be welcome?

Sorry, haven't been on for a couple of weeks. The plugin is dead simple, and ONLY does commit, as handling push/pull would necessitate manual intervention on conflicts, so I do that using a bash script instead.

The proper name is 'fava extension', and on any recent version of fava you can find documentation about it on the Help page. It seems there's a recent fava-plugins project to collect these[1].

My plugin looks like this:-

import os
import subprocess
from fava.ext import FavaExtensionBase
'''
Example hook for fava.

The hook add_transaction_git_commit will automatically add all files with the
beancount suffix in fava's root folder and commit them with a message based on
the transaction's narration, payee, and date.

To limit external dependencies, this uses the subprocess module (2.4+). Please
read the documentation for that[1], especially if you're considering using
shell=True (probably a bad idea).

'''

class AutoCommit(FavaExtensionBase):
    def _run(self, args):
        cwd = os.path.dirname(self.ledger.beancount_file_path)
        subprocess.call(args, cwd=cwd, stdout=subprocess.DEVNULL)

    def after_write_source(self, path, _):
        message = 'autocommit: file saved'
        self._run(["git", "add", path])
        self._run(["git", "commit", "-m", message])

    def after_insert_metadata(self, *_):
        message = 'autocommit: metadata added'
        self._run(["git", "commit", "-am", message])

    def after_insert_entry(self, entry):
        message = 'autocommit:'
        if entry.narration:
            message += '"{}"'.format(entry.narration)
        if entry.payee:
            if message:
                message += ' paid to "{}"'.format(entry.payee)
            else:
                message = 'Payment to "{}"'.format(entry.payee)
        if message:
            message += ' on {}'.format(entry.date)
        else:
            message += 'entry on {}'.format(entry.date)
        self._run(["git", "commit", "-am", message])

I'm also planning a PR to extend fava's extensions capabilities[2] such that they can modify the transactions themselves, but haven't had time to get round to it (yet). 

Reply all
Reply to author
Forward
0 new messages