GithubHelp home page GithubHelp logo

joe-achim / liberapay.com Goto Github PK

View Code? Open in Web Editor NEW

This project forked from liberapay/liberapay.com

0.0 0.0 0.0 27.58 MB

Recurrent donations platform

Home Page: https://liberapay.com/

Shell 0.93% Makefile 0.76% Python 69.24% JavaScript 8.06% PLpgSQL 4.92% SQLPL 0.17% CSS 7.73% HTML 8.20%

liberapay.com's Introduction

Liberapay

Build Status Weblate Donate

Liberapay is a recurrent donations platform.

It's a fork of Gittip/Gratipay, see this post for the differences between the two.

Contact

You have a question? Come ask us in the salon or in the IRC channel #liberapay on Freenode.

Contributing to the translations

We use Weblate for translations

If you have questions about translating Liberapay, you can ask them in the translation thread of the salon.

Contributing to the code

Introduction

Liberapay is a fork of Gratipay, so it uses the web micro-framework Aspen, which is based on filesystem routing and simplates. Don't worry, it's quite simple. For example to make Liberapay return a Hello $user, your id is $userid message for requests to the URL /$user/hello, you only need to create the file www/%username/hello.spt with this inside:

from liberapay.utils import get_participant
[---]
participant = get_participant(state)
[---] text/html
{{ _("Hello {0}, your id is {1}", request.path['username'], participant.id) }}

As illustrated by the last line our default template engine is Jinja.

The _ function attempts to translate the message into the user's language and escapes the variables properly (it knows that it's generating a message for an HTML page).

The python code inside simplates is only for request-specific logic, common backend code is in the liberapay/ directory.

Installation

Firstly, make sure you have the following dependencies installed:

Then run:

make env

Now you need to give yourself superuser postgres powers (if it hasn't been done already), and create two databases:

su postgres -c "createuser --superuser $(whoami)"

createdb liberapay
createdb liberapay_tests

If you need a deeper understanding take a look at the Database Roles and Managing Databases sections of PostgreSQL's documentation.

Then you can set up the DB:

make schema

Configuration

Environment variables are used for configuration, the default values are in defaults.env and tests/test.env. You can override them in local.env and tests/local.env respectively.

Running

Once you've installed everything and set up the database, you can run the app:

make run

It should now be accessible at http://localhost:8339/.

You can create some fake users to make it look more like the real site:

make data

SQL

The python code interacts with the database by sending raw SQL queries through the postgres.py library.

The official PostgreSQL documentation is your friend when dealing with SQL, especially the sections "The SQL Language" and "SQL Commands".

The DB schema is in sql/schema.sql, but don't modify that file directly, instead put the changes in sql/branch.sql. During deployment that script will be run on the production DB and the changes will be merged into sql/schema.sql. That process is semi-automated by release.sh.

CSS and JavaScript

For our styles we use SASS and Bootstrap 3. Stylesheets are in the style/ directory and our JavaScript code is in js/. Our policy for both is to have as little as possible of them: the website should be almost entirely usable without JS, and our CSS should leverage Bootstrap as much as possible instead of containing lots of custom rules that would become a burden to maintain.

We compile Bootstrap ourselves from the SASS source in the style/bootstrap/ directory. We do that to be able to easily customize it by changing values in style/variables.scss. Modifying the files in style/bootstrap/ is probably not a good idea.

Testing Build Status

The easiest way to run the test suite is:

make test

That recreates the test DB's schema and runs all the tests. To speed things up you can also use the following commands:

  • make pytest only runs the python tests without recreating the test DB
  • make pytest-re does the same but only runs the tests that failed in the previous run

Tinkering with payments

We depend on MangoPay for payments. If you want to modify that part of the code you'll need the MangoPay API documentation.

Modifying python dependencies

We use pip's Hash-Checking Mode to protect ourselves from dependency tampering. Thus when adding or upgrading a dependency the new hashes need to computed and put in the requirements file. For that you can use hashin:

pip install hashin
hashin package==x.y -r requirements_base.txt -p 2.7 -p 3.6
# note: we have several requirements files, use the right one

If for some reason you need to rehash all requirements, run make rehash-requirements.

Deploying the app

Liberapay is currently hosted on AWS (Ireland).

To deploy the app simply run release.sh, it'll guide you through it. Of course you need to be given access first.

Setting up a development environment using Docker

If you don't want to install directly dependencies on your machine, you can spin up a development environment easily, assuming you have Docker and docker-compose installed:

# build the local container
docker-compose build

# initialize the database
docker-compose run web bash recreate-schema.sh

# populate the database with fake data
docker-compose run web python -m liberapay.utils.fake_data

# launch the database and the web server
# the application should be available on http://localhost:8339
docker-compose up

You can also run tests in the DOcker environment:

docker-compose -f docker/tests.yml run tests

All arguments are passed to the underlying py.test command, so you can use -x for failing fast or --ff to retry failed tests first:

docker-compose -f docker/tests.yml run tests -x --ff

License

CC0 Public Domain Dedication

liberapay.com's People

Contributors

chadwhitacre avatar changaco avatar seanlinsley avatar zwn avatar rohitpaulk avatar clone1018 avatar rummik avatar wyze avatar joonas avatar oakes avatar eswat avatar techtonik avatar sim6 avatar bruceadams avatar nijel avatar patcon avatar revi avatar jelv avatar jorgesumle avatar joeyespo avatar joealcorn avatar simon-weber avatar cakey avatar galuszkak avatar jeromegn avatar mvdkleijn avatar kaguillera avatar sigmavirus24 avatar mushketyk avatar martindelille avatar

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.