summaryrefslogtreecommitdiff
path: root/README.md
blob: 4cc406249d99ef6a8f53d548d6921ffa16a43269 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
# The VNDB.org Source Code

## Quick and dirty setup using Docker

Setup:

```
  docker build -t vndb .
```

Run (will run on the foreground):

```
  docker run -ti --name vndb -p 3000:3000 -v "`pwd`":/var/www --rm vndb
```

If you need another terminal into the container while it's running:

```
  docker exec -ti vndb su -l devuser  # development shell (files are at /var/www)
  docker exec -ti vndb psql -U vndb   # postgres shell
```

To start Multi, the optional application server:

```
  docker exec -ti vndb su -l devuser -c 'make -C /var/www multi-restart'
```

It will run in the background for as long as the container is alive. Logs are
written to `data/log/multi.log`.

The PostgreSQL database will be stored in `data/docker-pg/` and the uploaded
files in `static/{ch,cv,sf,st}`. If you want to restart with a clean slate, you
can stop the container and run:

```
  # Might want to make a backup of these dirs first if you have any interesting data.
  rm -rf data/docker-pg static/{ch,cv,sf,st}
```


## Requirements (when not using Docker)

Global requirements:

- Linux, or an OS that resembles Linux. Chances are VNDB won't run on Windows.
- PostgreSQL 10 (older versions may work)
- Perl 5.24+
- Elm 0.19

**Perl modules** (core modules are not listed):

General:
- Crypt::ScryptKDF
- Crypt::URandom
- DBD::Pg
- DBI
- Image::Magick
- JSON::XS
- PerlIO::gzip

util/vndb.pl (the web backend):
- Algorithm::Diff::XS
- SQL::Interp
- Text::MultiMarkdown
- TUWF
- HTTP::Server::Simple

util/multi.pl (application server, optional):
- AnyEvent
- AnyEvent::Pg
- AnyEvent::IRC
- XML::Parser
- graphviz (/usr/bin/dot is used by default)


## Manual setup

- Make sure all the required dependencies (see above) are installed. Hint: See
  the Docker file for Ubuntu commands. For non-root setup: Use cpanm & local::lib.
- Run the build system:

```
  make
```

- Setup a PostgreSQL server and make sure you can login with some admin user
- Initialize the VNDB database (assuming 'postgres' is a superuser):

```
  # Create the database & roles
  psql -U postgres -f util/sql/superuser_init.sql

  # Set a password for each database role:
  echo "ALTER ROLE vndb       LOGIN PASSWORD 'pwd1'" | psql -U postgres
  echo "ALTER ROLE vndb_site  LOGIN PASSWORD 'pwd2'" | psql -U postgres
  echo "ALTER ROLE vndb_multi LOGIN PASSWORD 'pwd3'" | psql -U postgres

  # OPTION 1: Create an empty database:
  psql -U vndb -f util/sql/all.sql

  # OPTION 2: Import the development database (https://vndb.org/d8#3):
  curl -L https://dl.vndb.org/dump/vndb-dev-latest.tar.gz | tar -xzf-
  psql -U vndb -f dump.sql
  rm dump.sql
```

- Update `data/conf.pl` with the proper credentials for *vndb_site* and
  *vndb_multi*.
- Now simply run:

```
  util/vndb-dev-server.pl
```

- (Optional) To start Multi, the application server:

```
  make multi-restart
```


# Rewrites, rewrites, rewrites

The VNDB website is currently (like every project beyond a certain age) in a
transitional state of rewrites. There are three "versions" and coding styles
across this repository:

**Version 2**

This is the code that powers the actual website. It lives in `lib/VNDB/` and
has `util/vndb.pl` as entry point. Front-end assets are in `data/js/`,
`data/style.css`, `data/icons/`, `static/f/` and `static/s/`.

**Version 2-rw**

This is a (newly started) backend rewrite of version 2. It lives in
`lib/VNWeb/`. Individual parts of the website are gradually being moved into
this new coding style and structure. Version 2 and 2-rw run side-by-side in the
same process and share a common route table and database connection, so the
entry point is still `util/vndb.pl`. The primary goal of this rewrite is to
make use of the clearer version 3 structure and to slowly migrate the brittle
frontend Javascript parts to Elm and JSON APIs.

**Version 3**

This is (or was) an attempt at a full rewrite of the entire website, both
backend and frontend. It lives in `lib/VN3/` and uses `util/vndb3.pl` as entry
point. Its frontend assets live inside `css3/`, `elm3/` and `static/v3/`. Most
of the ideas from version 3 will be gradually backported into version 2-rw.
Version 3 also comes with a completely different and much better layout, which
I hope will also be integrated in version 2-rw at some point. Version 3 is not
actively maintained at this point and is more of a playground for the new
layout.

To run version 3 instead of 2:

```
  # When not using Docker
  util/vndb-dev-server.pl 3
  
  # Or when using Docker, start the container as follows:
  docker run -ti --name vndb -p 3000:3000 -v "`pwd`":/var/www --rm vndb /var/www/util/docker-init.sh 3
```

**Non-rewrites**

Some parts of this repository are not affected by these rewrites. These include
the database structure, most of the scripts in `util/`, some common modules
spread across `lib/` and Multi, which resides in `lib/Multi/`. That's not to
say these are *final* or *stable*, but they're largely independent from the
website code.


# License

GNU AGPL, see COPYING file for details.