Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ __pycache__/
npm-debug.log
node_modules/
.vscode/settings.json
*.pyc
131 changes: 131 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,131 @@
# PolyForm Noncommercial License 1.0.0

<https://polyformproject.org/licenses/noncommercial/1.0.0>

## Acceptance

In order to get any license under these terms, you must agree
to them as both strict obligations and conditions to all
your licenses.

## Copyright License

The licensor grants you a copyright license for the
software to do everything you might do with the software
that would otherwise infringe the licensor's copyright
in it for any permitted purpose. However, you may
only distribute the software according to [Distribution
License](#distribution-license) and make changes or new works
based on the software according to [Changes and New Works
License](#changes-and-new-works-license).

## Distribution License

The licensor grants you an additional copyright license
to distribute copies of the software. Your license
to distribute covers distributing the software with
changes and new works permitted by [Changes and New Works
License](#changes-and-new-works-license).

## Notices

You must ensure that anyone who gets a copy of any part of
the software from you also gets a copy of these terms or the
URL for them above, as well as copies of any plain-text lines
beginning with `Required Notice:` that the licensor provided
with the software. For example:

> Required Notice: Copyright TripSit (Callum Macdonald) 2022

## Changes and New Works License

The licensor grants you an additional copyright license to
make changes and new works based on the software for any
permitted purpose.

## Patent License

The licensor grants you a patent license for the software that
covers patent claims the licensor can license, or becomes able
to license, that you would infringe by using the software.

## Noncommercial Purposes

Any noncommercial purpose is a permitted purpose.

## Personal Uses

Personal use for research, experiment, and testing for
the benefit of public knowledge, personal study, private
entertainment, hobby projects, amateur pursuits, or religious
observance, without any anticipated commercial application,
is use for a permitted purpose.

## Noncommercial Organizations

Use by any charitable organization, educational institution,
public research organization, public safety or health
organization, environmental protection organization,
or government institution is use for a permitted purpose
regardless of the source of funding or obligations resulting
from the funding.

## Fair Use

You may have "fair use" rights for the software under the
law. These terms do not limit them.

## No Other Rights

These terms do not allow you to sublicense or transfer any of
your licenses to anyone else, or prevent the licensor from
granting licenses to anyone else. These terms do not imply
any other licenses.

## Patent Defense

If you make any written claim that the software infringes or
contributes to infringement of any patent, your patent license
for the software granted under these terms ends immediately. If
your company makes such a claim, your patent license ends
immediately for work on behalf of your company.

## Violations

The first time you are notified in writing that you have
violated any of these terms, or done anything with the software
not covered by your licenses, your licenses can nonetheless
continue if you come into full compliance with these terms,
and take practical steps to correct past violations, within
32 days of receiving notice. Otherwise, all your licenses
end immediately.

## No Liability

***As far as the law allows, the software comes as is, without
any warranty or condition, and the licensor will not be liable
to you for any damages arising out of these terms or the use
or nature of the software, under any kind of legal claim.***

## Definitions

The **licensor** is the individual or entity offering these
terms, and the **software** is the software the licensor makes
available under these terms.

**You** refers to the individual or entity agreeing to these
terms.

**Your company** is any legal entity, sole proprietorship,
or other kind of organization that you work for, plus all
organizations that have control over, are under the control of,
or are under common control with that organization. **Control**
means ownership of substantially all the assets of an entity,
or the power to direct its management and policies by vote,
contract, or otherwise. Control can be direct or indirect.

**Your licenses** are all the licenses granted to you for the
software under these terms.

**Use** means anything you do with the software requiring one
of your licenses.
41 changes: 38 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,18 @@
# combogen

Combogen is an application that generates drug combo charts as PNG and PDF files to help users know the results and safety of drug combinations.

This repository does not contain the raw combination data, it is a simple image/PDF generator. The data is fetched from the [TripSit/drugs](https://github.com/TripSit/drugs) repository ([drugs.json](https://github.com/TripSit/drugs/blob/main/drugs.json)).

Output example (uses historamical data, not up to date):
![Example output](https://wiki.tripsit.me/images/3/3a/Combo_2.png)

## Dependencies
- Install [Python 3](https://www.python.org), [Node.js](https://nodejs.org), and [npm](https://www.npmjs.com).
- Afterwards make sure `python` (or `python3`), `node`, `npm` are in your `PATH`.
- Install required python modules: `pip3 install requests jinja2`
- Afterwards make sure `python` (or `python3`), `node`, `npm`, `pip` are in your `PATH`.
- Move into the project directory using `cd`
- Create a virtual environment: `python3 -m venv venv`
- Install the required Python packages: `./venv/bin/pip3 install -r requirements.txt`

### Google Chrome
Some of the used npm packages may want to use Google Chrome or Chromium. If you need to install it depends on your operating system. It's not needed on macOS 13.4. for example.
Expand All @@ -15,7 +26,7 @@ After installing Chrome, make sure `google-chrome` or `chrome` are in your `PATH
- `git clone` this repo
- `cd` to the project dir
- Run `npm install`
- Run `python -m combogen` (or `python3 -m combogen`)
- Run `./venv/bin/python3 -m combogen`

## How to configure
- Edit **config.json**
Expand All @@ -25,3 +36,27 @@ After installing Chrome, make sure `google-chrome` or `chrome` are in your `PATH
- Run the script (see above)
- PNGs are located in output/png/
- PDFs are located in output/pdf/

## Troubleshooting common issues

### Result shows NXDRUG instead of real info

This means that the drug is not defined in the source json that the app uses to generate the chart.
The drug was most likely renamed/changed by accident in the [source data](https://github.com/TripSit/drugs/blob/main/drugs.json) or this project.
Check the lastest commit in the project to see if there was any breaking change made.
Please report the issue on our [Discord](https://discord.gg/tripsit).
You can use an older version of [drugs.json](https://github.com/TripSit/drugs/blob/main/drugs.json) as a temporary fix, simply edit the source in `config.json`.

## Contibuting

The easiest way to contribute is to translate the chart into your language.
You may find the translation data in the `combogen/translations/` directory.
Please use common (not complex) language and drug names to make the chart easily understandable by everyone.

## Licensing

Big thanks to everyone who contributed—this project wouldn’t be what it is without your help!

---

This project is licensed under the **PolyForm Noncommercial License**. Here is a (non legally binding TL;DR, find the full licence in the `LICENSE` file): *You can use, modify, and share this project freely **for noncommercial purposes only**. Any commercial use requires a separate license. Use by any charitable organization, educational institution, public research organization, public safety or health organization, environmental protection organization, or government institution is considered a permitted purpose **regardless of funding sources**. The project is provided **as-is**, with no warranties, and you must include this license if you redistribute it.*
3 changes: 3 additions & 0 deletions combogen/ChartGenerator.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ def generate(self, lang):
status_msg = "Version {} — ".format(self._config.version)
status_msg += "Generated on {} at {} UTC".format(time_generated.strftime("%d %b %Y"),
time_generated.strftime("%H:%M"))

if self._db._data_update_time is not Ellipsis: # Check if we even have the last update time
status_msg += f" — Data as of {self._db._data_update_time.strftime("%d %b %Y")}"

return template.render(status=status_msg, lang=lang, db=self._db, cfg=self._config)

Expand Down
18 changes: 17 additions & 1 deletion combogen/DrugDatabase.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,27 @@
import requests
import json
from collections import OrderedDict
from datetime import datetime


class DrugDatabase(object):
def __init__(self, config):
self._combos = requests.get(config.url).json()

# Uses the config.url to find the last repository commit to use it's time
# as the last update of the combo data
# is Ellipsis if the config.url is not a GitHub raw link
# the result is used in the result page footer
try:
self._data_update_time = datetime.fromisoformat(requests.get(
f"https://api.github.com/repos/{'/'.join(config.url.split('/')[3:5])}/commits?path=drugs.json&page=1&per_page=1"
).json()[0]['commit']['committer']['date'])
except requests.RequestException as e:
print("""Failed to get time of the last source data update
The source URL (in config.url) is most likely not a file link stored on GitHub.
You can safely ignore this error or read the README for troubleshooting information.
Error message: """, e)
self._data_update_time = Ellipsis

self._config = config
self._drug_groups = []
self.load_groups()
Expand Down
4 changes: 2 additions & 2 deletions combogen/templates/combo-chart-full.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<head>
<meta charset="UTF-8">
<title>{{ title }}</title>
<link rel='stylesheet' href='https://fonts.googleapis.com/css?family=Open+Sans:400,600,700' type='text/css'>
<link rel='stylesheet' href='https://fonts.googleapis.com/css?family=Open+Sans:400,600,700&subset=latin,latin-ext,cyrillic' type='text/css'>
<link rel="stylesheet" href="https://use.typekit.net/ucr7myw.css">
<link rel="stylesheet" href="{{ cfg.rel_resources_path }}/css/font-awesome.min.css">
<link rel="stylesheet" href="{{ cfg.rel_resources_path }}/css/style.css">
Expand Down Expand Up @@ -31,4 +31,4 @@ <h3>{{ cfg.translate(lang, "support") }}</h3>
</footer>
</div>
</body>
</html>
</html>
5 changes: 4 additions & 1 deletion combogen/templates/legend.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,7 @@
<div class="legend-card decrease">{{ fa_label("Low Risk & Decrease") }}</div>
</div>

<span id="status">{{ status }}</span>
<div id="status">{{ status }}
<br>Work licence &mdash; CC BY-NC-SA 4.0 (creativecommons.org/licenses/by-nc-sa/4.0)
<br>Source available &mdash; github.com/TripSit/combogen
</div>
2 changes: 1 addition & 1 deletion config.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"url": "https://github.com/TripSit/drugs/blob/main/combos.json",
"url": "https://raw.githubusercontent.com/TripSit/drugs/refs/heads/main/combos.json",
"version": "5.0.0",
"tableOrder": [
[
Expand Down
2 changes: 2 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
jinja2
requests
2 changes: 1 addition & 1 deletion resources/css/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -260,4 +260,4 @@ footer #disclaimer {
/* right: 8%; */
top: 0;
font-size: 24pt;
}
}