Skip to content

Commit d611243

Browse files
committed
Update
1 parent 5ed9db3 commit d611243

20 files changed

+1155
-1099
lines changed

DEVELOPMENT.md

+11-11
Original file line numberDiff line numberDiff line change
@@ -4,24 +4,24 @@
44
- Set up a Python2
55
[virtualenv](http://python-guide-pt-br.readthedocs.io/en/latest/dev/virtualenvs/)
66
to manage Python dependencies
7-
- Source your virtualenv
8-
- Run `pip install -r requirements.txt` to install all dependencies
7+
- Source your virtualenv
8+
- Run `pip install -r requirements.txt` to install all dependencies
99
- Install [PostgreSQL](https://www.postgresql.org/download/) to run a database locally
1010
- If you're using Mac, install *Postgres.app* from
11-
[here](https://www.postgresql.org/download/)
12-
- Set three environment variables:
11+
[here](https://www.postgresql.org/download/)
12+
- Set three environment variables:
1313
- `DATABASE_URL` points to the URL of a development database,
1414
which has to be set up using Postgres on your system. A sample `DATABASE_URL`
15-
could look like `postgres://username:password@localhost/cog`.
16-
- `QUILL` is the URL to your Quill instance for auth.
17-
- `SECRET` needs to be the same JWT secret used in your Quill instance.
18-
- Run `python initialize.py`
15+
could look like `postgres://username:password@localhost/cog`.
16+
- `QUILL` is the URL to your Quill instance for auth.
17+
- `SECRET` needs to be the same JWT secret used in your Quill instance.
18+
- Run `python initialize.py`
1919
- This initializes the database - run it if you make any changes to the models and
2020
are fine with overwriting data.
2121

22-
## Running
23-
- Run `make run`
22+
## Running
23+
- Run `make run`
2424
- The site will be visible at `localhost:8000`
2525

26-
## Tests
26+
## Tests
2727
- Run `make test` to run all tests

Dockerfile

100644100755
+2-3
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,9 @@ ARG APP_PATH=/hardware-checkout
55
WORKDIR $APP_PATH
66

77
ADD requirements.txt $APP_PATH
8-
RUN pip install -r requirements.txt
8+
RUN pip install -r requirements.txt -i https://pypi.tuna.tsinghua.edu.cn/simple
99

1010
ADD . $APP_PATH
1111

1212
EXPOSE 8000
13-
CMD ["gunicorn", "--bind", ":8000", "-k", "geventwebsocket.gunicorn.workers.GeventWebSocketWorker", "hardwarecheckout:app"]
14-
13+
CMD ["gunicorn", "--bind", ":8000", "-k", "eventlet", "hardwarecheckout:app"]

README.md

+134-134
Original file line numberDiff line numberDiff line change
@@ -1,134 +1,134 @@
1-
# Cog
2-
3-
**This project is forked from [techx/cog](https://github.com/techx/cog), which is a hardware checkout system for hackathons.**
4-
5-
It is written in Python 2, based on the framework of [Python Flask](http://flask.pocoo.org/) and enabled by [Gunicorn](http://gunicorn.org/) as a WSGI HTTP Server
6-
7-
This README.md is written by [shuye02](https://www.github.com/shuye02).
8-
You can go to [here](https://github.com/techx/cog/blob/master/README.md) for the original README.md of this project.
9-
10-
## Features
11-
12-
You can refer to the [original README.md](https://github.com/techx/cog/blob/master/README.md) from the [original project](https://github.com/techx/cog/).
13-
14-
## Deployment
15-
16-
#### Dependencies list
17-
18-
- python2
19-
- python2-pip
20-
- python2-virtualenv (optional, but *recommended*)
21-
- PostgreSQL
22-
- some other python libraries (refer to [requirements.txt](/requirements.txt))
23-
24-
#### Installing dependencies
25-
26-
1. Install python2, python2-pip
27-
`Depends on your Linux distro, please refer to your distro wiki`
28-
2. Install python2-virtualenv
29-
`$ pip install virtualenv`
30-
3. Setup python 2 virtual environment (optional, but *recommended*)
31-
`$ virtualenv venv`
32-
4. Source your virtual environment
33-
`$ source venv/bin/activate`
34-
5. Install dependent Python libraries
35-
`(venv) $ pip install -r requirements.txt`
36-
6. You can then leave your virtual env by typing `deactivate`
37-
7. Install PostgreSQL and start it
38-
You can refer to the [Arch Linux wiki](https://wiki.archlinux.org/index.php/PostgreSQL#Installing_PostgreSQL) for the **Installation** and **Intial Configuration** of PostgreSQL
39-
40-
##### An example of PostgreSQL Initial Configuration
41-
```sh
42-
# Switch to PostgreSQL admin account
43-
$ sudo -u postgres -i
44-
45-
# Add your username
46-
[postgres]$ createuser --interactive
47-
[postgres]$ exit
48-
49-
# Create your database
50-
$ createdb myDatabaseName -U username
51-
# the [-U username] parameter can be omitted if the database user has the same name as your Linux user
52-
```
53-
54-
> **Note**:
55-
The database username is recommended to be your Linux username, since PostgreSQL uses a [peer authentication](https://www.postgresql.org/docs/current/static/auth-methods.html#AUTH-PEER) technique to map between Linux and database usernames.
56-
So, if you create a PostgreSQL user with the same name as your Linux username, it allows you to access the PostgreSQL database shell without having to specify a user to login (which makes it quite convenient).
57-
58-
And you may want to check whether your database are accessible or not.
59-
```sh
60-
$ psql -d myDatabaseName
61-
=> \?
62-
=> \q (or CTRL+d)
63-
```
64-
65-
#### Configuration
66-
67-
##### Customize for your own hackathon
68-
69-
You can go to [config.py](/hardwarecheckout/config.py) to edit the following settings:
70-
* Your Hackathon name (*default to "Hack.init()"*)
71-
* Toggle Submission Settings
72-
* Proposal for lottery items
73-
* Multiple submissions for the same item
74-
* etc.
75-
* Toggle Item Display
76-
* Info texts shown at the index page
77-
78-
In addition, you can change the default [favicon.png](/hardwarecheckout/static/favicon.png) of your website and the [default picture](/hardwarecheckout/static/images/default.png) for your hardware items.
79-
80-
> **Note**:
81-
If you have installed the dependent python libraries in your virtual environment, you need to source the virtual environment before running the following commands.
82-
And you may want to run the following commands in a [Linux Screen terminal](https://www.gnu.org/software/screen/manual/screen.html).
83-
Especially when you are running cog in a vps, so that you can use `screen -r` command to retrieve the terminal from different login sessions.
84-
85-
##### Environment Variables
86-
87-
You **need** to set the following environment variables before getting your cog running
88-
* `DATABASE_URL`: the PostgreSQL database URL
89-
It should be in the form of `postgres://[user[:password]@][netloc][:port][/dbname][?param1=value1&...]`.
90-
*An example `DATABASE_URL` may look like `postgres://username@localhost/cog`*
91-
* `QUILL`: the URL to your [Quill](https://github.com/techx/quill) instance for auth.
92-
*An example `QUILL` may look like `http://localhost:3000/`*
93-
* `SECRET`: it needs to be exactly the **same** JWT secret set in your QUILL configurations.
94-
95-
#### Running
96-
97-
* Run `python initialize.py`.
98-
This initializes the database — run it if you make any changes to the models and
99-
are fine with overwriting data.
100-
* Run `make run`.
101-
The site is now listening at `0.0.0.0:8000`
102-
> **Note**:
103-
You can change the listening address and port in [Makefile](/Makefile)
104-
For example, you may want to listen only `127.0.0.1:8000` and have nginx forward to this port.
105-
106-
## Directory Architectures
107-
*TO-DO*
108-
109-
## Customizations
110-
*This part is cited directly from the [original README.md](https://github.com/techx/cog/blob/master/README.md) of the original project.*
111-
112-
#### Adding Hardware via [Google Sheets](https://www.google.com/sheets/about/)
113-
114-
While you can add individual items one-by-one, we recommend creating a
115-
spreadsheet with all your items and importing this into Cog in one go.
116-
Currently, the only supported way to do this is via Google Sheets. An example
117-
Cog inventory sheet can be found
118-
[here](https://docs.google.com/spreadsheets/d/1ZCHa_F3i0vyoZtjJNyNhBg-flRBs-DUIT1GtKC26P14/edit#gid=0).
119-
120-
To import from a Google Sheet, simply turn on view-only sharing and paste the main URL (not the sharing URL) into Cog after clicking 'Import Google Sheet' on the main inventory page.
121-
122-
> **Note**:
123-
You may need to set up a proxy to have access to Google Sheets depending on your network environment.
124-
125-
#### Customizing Branding
126-
127-
Cog uses the [Semantic UI](https://semantic-ui.com/) framework for styling.
128-
Branding can easily be customized using Semantic UI
129-
[themes](https://semantic-ui.com/usage/theming.html).
130-
131-
While Cog mostly uses default Semantic UI styling, a minimal amount of custom
132-
CSS lives in `hardwarecheckout/static/sass/app.scss`. In order to rebuild the
133-
CSS when the Sass is changed, install [Sass](https://sass-lang.com/) and run
134-
`sass --watch sass:css` in the `/static` directory.
1+
# Cog
2+
3+
**This project is forked from [techx/cog](https://github.com/techx/cog), which is a hardware checkout system for hackathons.**
4+
5+
It is written in Python 2, based on the framework of [Python Flask](http://flask.pocoo.org/) and enabled by [Gunicorn](http://gunicorn.org/) as a WSGI HTTP Server
6+
7+
This README.md is written by [shuye02](https://www.github.com/shuye02).
8+
You can go to [here](https://github.com/techx/cog/blob/master/README.md) for the original README.md of this project.
9+
10+
## Features
11+
12+
You can refer to the [original README.md](https://github.com/techx/cog/blob/master/README.md) from the [original project](https://github.com/techx/cog/).
13+
14+
## Deployment
15+
16+
#### Dependencies list
17+
18+
- python2
19+
- python2-pip
20+
- python2-virtualenv (optional, but *recommended*)
21+
- PostgreSQL
22+
- some other python libraries (refer to [requirements.txt](/requirements.txt))
23+
24+
#### Installing dependencies
25+
26+
1. Install python2, python2-pip
27+
`Depends on your Linux distro, please refer to your distro wiki`
28+
2. Install python2-virtualenv
29+
`$ pip install virtualenv`
30+
3. Setup python 2 virtual environment (optional, but *recommended*)
31+
`$ virtualenv venv`
32+
4. Source your virtual environment
33+
`$ source venv/bin/activate`
34+
5. Install dependent Python libraries
35+
`(venv) $ pip install -r requirements.txt`
36+
6. You can then leave your virtual env by typing `deactivate`
37+
7. Install PostgreSQL and start it
38+
You can refer to the [Arch Linux wiki](https://wiki.archlinux.org/index.php/PostgreSQL#Installing_PostgreSQL) for the **Installation** and **Intial Configuration** of PostgreSQL
39+
40+
##### An example of PostgreSQL Initial Configuration
41+
```sh
42+
# Switch to PostgreSQL admin account
43+
$ sudo -u postgres -i
44+
45+
# Add your username
46+
[postgres]$ createuser --interactive
47+
[postgres]$ exit
48+
49+
# Create your database
50+
$ createdb myDatabaseName -U username
51+
# the [-U username] parameter can be omitted if the database user has the same name as your Linux user
52+
```
53+
54+
> **Note**:
55+
The database username is recommended to be your Linux username, since PostgreSQL uses a [peer authentication](https://www.postgresql.org/docs/current/static/auth-methods.html#AUTH-PEER) technique to map between Linux and database usernames.
56+
So, if you create a PostgreSQL user with the same name as your Linux username, it allows you to access the PostgreSQL database shell without having to specify a user to login (which makes it quite convenient).
57+
58+
And you may want to check whether your database are accessible or not.
59+
```sh
60+
$ psql -d myDatabaseName
61+
=> \?
62+
=> \q (or CTRL+d)
63+
```
64+
65+
#### Configuration
66+
67+
##### Customize for your own hackathon
68+
69+
You can go to [config.py](/hardwarecheckout/config.py) to edit the following settings:
70+
* Your Hackathon name (*default to "Hack.init()"*)
71+
* Toggle Submission Settings
72+
* Proposal for lottery items
73+
* Multiple submissions for the same item
74+
* etc.
75+
* Toggle Item Display
76+
* Info texts shown at the index page
77+
78+
In addition, you can change the default [favicon.png](/hardwarecheckout/static/favicon.png) of your website and the [default picture](/hardwarecheckout/static/images/default.png) for your hardware items.
79+
80+
> **Note**:
81+
If you have installed the dependent python libraries in your virtual environment, you need to source the virtual environment before running the following commands.
82+
And you may want to run the following commands in a [Linux Screen terminal](https://www.gnu.org/software/screen/manual/screen.html).
83+
Especially when you are running cog in a vps, so that you can use `screen -r` command to retrieve the terminal from different login sessions.
84+
85+
##### Environment Variables
86+
87+
You **need** to set the following environment variables before getting your cog running
88+
* `DATABASE_URL`: the PostgreSQL database URL
89+
It should be in the form of `postgres://[user[:password]@][netloc][:port][/dbname][?param1=value1&...]`.
90+
*An example `DATABASE_URL` may look like `postgres://username@localhost/cog`*
91+
* `QUILL`: the URL to your [Quill](https://github.com/techx/quill) instance for auth.
92+
*An example `QUILL` may look like `http://localhost:3000/`*
93+
* `SECRET`: it needs to be exactly the **same** JWT secret set in your QUILL configurations.
94+
95+
#### Running
96+
97+
* Run `python initialize.py`.
98+
This initializes the database — run it if you make any changes to the models and
99+
are fine with overwriting data.
100+
* Run `make run`.
101+
The site is now listening at `0.0.0.0:8000`
102+
> **Note**:
103+
You can change the listening address and port in [Makefile](/Makefile)
104+
For example, you may want to listen only `127.0.0.1:8000` and have nginx forward to this port.
105+
106+
## Directory Architectures
107+
*TO-DO*
108+
109+
## Customizations
110+
*This part is cited directly from the [original README.md](https://github.com/techx/cog/blob/master/README.md) of the original project.*
111+
112+
#### Adding Hardware via [Google Sheets](https://www.google.com/sheets/about/)
113+
114+
While you can add individual items one-by-one, we recommend creating a
115+
spreadsheet with all your items and importing this into Cog in one go.
116+
Currently, the only supported way to do this is via Google Sheets. An example
117+
Cog inventory sheet can be found
118+
[here](https://docs.google.com/spreadsheets/d/1ZCHa_F3i0vyoZtjJNyNhBg-flRBs-DUIT1GtKC26P14/edit#gid=0).
119+
120+
To import from a Google Sheet, simply turn on view-only sharing and paste the main URL (not the sharing URL) into Cog after clicking 'Import Google Sheet' on the main inventory page.
121+
122+
> **Note**:
123+
You may need to set up a proxy to have access to Google Sheets depending on your network environment.
124+
125+
#### Customizing Branding
126+
127+
Cog uses the [Semantic UI](https://semantic-ui.com/) framework for styling.
128+
Branding can easily be customized using Semantic UI
129+
[themes](https://semantic-ui.com/usage/theming.html).
130+
131+
While Cog mostly uses default Semantic UI styling, a minimal amount of custom
132+
CSS lives in `hardwarecheckout/static/sass/app.scss`. In order to rebuild the
133+
CSS when the Sass is changed, install [Sass](https://sass-lang.com/) and run
134+
`sass --watch sass:css` in the `/static` directory.

0 commit comments

Comments
 (0)