Skip to content

Commit

Permalink
drop docker, make python package
Browse files Browse the repository at this point in the history
* anything docker-related belongs in docker.webref, not in ppf.webref
  => dropped
* organize code as a python package
  • Loading branch information
adrianschlatter committed Dec 17, 2023
1 parent bc99cbb commit 6da881e
Show file tree
Hide file tree
Showing 18 changed files with 264 additions and 163 deletions.
9 changes: 0 additions & 9 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,19 +1,10 @@
# to avoid leaking credentials to github:
sqldatabasename
sqlpassword
sqlserver
sqlusername
secrets/
docker-compose.yml
hash_password.py

# to avoid leaking references to github:
references
references/

# because this relates to my personal config:
config/www.webref.conf

# general things to ignore:
build/
dist/
Expand Down
19 changes: 0 additions & 19 deletions Dockerfile

This file was deleted.

2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Copyright (c) 2021 Adrian Schlatter
Copyright (c) 2021-2023 Adrian Schlatter

Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
Expand Down
6 changes: 6 additions & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
exclude .gitignore
exclude MANIFEST.in
exclude tox.ini

recursive-exclude .github *
recursive-exclude tests *
50 changes: 0 additions & 50 deletions config/httpd.conf

This file was deleted.

4 changes: 0 additions & 4 deletions config/webref.wsgi

This file was deleted.

22 changes: 0 additions & 22 deletions docker-compose_templ.yml

This file was deleted.

61 changes: 34 additions & 27 deletions docs/README.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
# WebRef
# ppf.webref

WebRef is a web interface to a [JabRef SQL database](https://docs.jabref.org/collaborative-work/sqldatabase).
ppf.webref is a web app providing an interface to a [JabRef SQL
database](https://docs.jabref.org/collaborative-work/sqldatabase).
It allows you to access your references from anywhere in the world and from
any device with a web browser. You do not need to install Java, you
do not need to install an app. Any non-archaic phone, tablet, PC, Mac, or
Raspberry Pi will do.

Create a JabRef database (using your normal JabRef) and configure WebRef
Create a JabRef database (using your normal JabRef) and configure ppf.webref
to point to this database. Voila: Your references just became accessible
worldwide.

Note: WebRef provides *read-only* access to your library. To add, edit, or
Note: ppf.webref provides *read-only* access to your library. To add, edit, or
delete entries from your library, you still need a standard JabRef installation
somewhere.

Expand All @@ -21,33 +22,39 @@ somewhere.

## Installation

You need:
Prerequisite: You need JabRef to create, edit, and extend your library.

* JabRef: To create, edit, and extend your library
* Docker: To create and run docker images
Install ppf.webref:

```shell
pip install ppf.webref
```

Then, tell ppf.webref about your database by adding a section as follows to
`~/.config/ppf.webref/ppf.webref.conf` (create it if it does not exist):

Steps:
```
[database]
server = <server>:<port>
databasename = <name of your jabref database>
username = <username ppf.webref should use to access db>
password = <password ppf.webref should use to access db>
```

Finally, run

```shell
flask --app ppf.webref run
```

* Clone this repo
* Create a suitable docker-compose.yml (use
[docker-compose_templ.yml](../docker-compose_templ.yml) as a starting point)
* Create the following text files (assuming you did not change the paths
from the template docker-compose.yml):
- ./secrets/sqlusername: Username used to access your JabRef database
- ./secrets/sqlpassword: Password for that username
- ./secrets/sqlserver: The sql server holding your JabRef database
- ./secrets/sqldatabasename: The name of your JabRef database
* Run ```docker-compose up```
* Point your webbrowser to localhost:7000 (or where you configured your
WebRef to be)
and point your webbrowser to http://localhost:5000.

This will start WebRef on your local machine which is nice for testing.
To get the most out of WebRef, you will probably want to
run this docker image on a web server.
This will start ppf.webref on your local machine which is nice for testing.
To get the most out of ppf.webref, you will probably want to run ppf.webref on
a web server.

As we have not created any users yet, we can't login. To create
users, open your JabRef database (the one named in ./secrets/sqldatabasename)
users, open your JabRef database (the one named in the config file above)
and run this sql-code (make sure you don't have a table with this name
already):

Expand All @@ -61,9 +68,9 @@ create table user (
)
```

Now we have a user table but no users in it, yet. Let's find a password and hash
it with the following python code (of course, we replace the dummy password
with your own password beforehand):
Now we have a user table but no users in it, yet. Let's find a password and
hash it with the following python code (of course, we replace the dummy
password with your own password beforehand):

```
import bcrypt
Expand Down
99 changes: 99 additions & 0 deletions docs/README_pypi.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
# ppf.webref

ppf.webref is a web app providing an interface to a [JabRef SQL
database](https://docs.jabref.org/collaborative-work/sqldatabase).
It allows you to access your references from anywhere in the world and from
any device with a web browser. You do not need to install Java, you
do not need to install an app. Any non-archaic phone, tablet, PC, Mac, or
Raspberry Pi will do.

Create a JabRef database (using your normal JabRef) and configure ppf.webref
to point to this database. Voila: Your references just became accessible
worldwide.

Note: ppf.webref provides *read-only* access to your library. To add, edit, or
delete entries from your library, you still need a standard JabRef installation
somewhere.


## Installation

Prerequisite: You need JabRef to create, edit, and extend your library.

Install ppf.webref:

```shell
pip install ppf.webref
```

Then, tell ppf.webref about your database by adding a section as follows to
`~/.config/ppf.webref/ppf.webref.conf` (create it if it does not exist):

```
[database]
server = <server>:<port>
databasename = <name of your jabref database>
username = <username ppf.webref should use to access db>
password = <password ppf.webref should use to access db>
```

Finally, run

```shell
flask --app ppf.webref run
```

and point your webbrowser to http://localhost:5000.

This will start ppf.webref on your local machine which is nice for testing.
To get the most out of ppf.webref, you will probably want to run ppf.webref on
a web server.

As we have not created any users yet, we can't login. To create
users, open your JabRef database (the one named in the config file above)
and run this sql-code (make sure you don't have a table with this name
already):

```
create table user (
id INT auto_increment,
username varchar(20) character set utf8 not null,
password char(80) character set ascii not null,
primary key (id),
unique(username)
)
```

Now we have a user table but no users in it, yet. Let's find a password and
hash it with the following python code (of course, we replace the dummy
password with your own password beforehand):

```
import bcrypt
password = 'This is my password'
bytes = password.encode('utf-8')
salt = bcrypt.gensalt()
print(bcrypt.hashpw(bytes, salt))
```

The output looks something like this:

```
b'$2b$12$1royHRBq6o/mbDdO7LjR8eaThWYErI6HLLdn7MBfajtpRLlwWSJ8m'
```

Now add your user to the user table in you JabRef database using this sql-code
(again, replace "webref" with your username and the password hash with the
hash you generated above):

```
insert into user (username, password)
values (
"webref",
"$2b$12$1royHRBq6o/mbDdO7LjR8eaThWYErI6HLLdn7MBfajtpRLlwWSJ8m"
);
```

Now we are ready to go.
21 changes: 0 additions & 21 deletions requirements.txt

This file was deleted.

Loading

0 comments on commit 6da881e

Please sign in to comment.