|
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