No description
Find a file
2021-12-21 08:45:42 +01:00
app Add interface to create and update user accounts 2021-12-19 04:13:05 +01:00
bin initial commit (rails new sharedlists) 2021-12-18 10:31:37 +01:00
config simplify routes 2021-12-21 08:45:42 +01:00
db add unique index on Users#email 2021-12-21 08:45:42 +01:00
lib Rename tasks files to their actual task name 2021-12-18 16:05:55 +01:00
log initial commit (rails new sharedlists) 2021-12-18 10:31:37 +01:00
public initial commit (rails new sharedlists) 2021-12-18 10:31:37 +01:00
storage initial commit (rails new sharedlists) 2021-12-18 10:31:37 +01:00
test initial commit (rails new sharedlists) 2021-12-18 10:31:37 +01:00
tmp initial commit (rails new sharedlists) 2021-12-18 10:31:37 +01:00
vendor initial commit (rails new sharedlists) 2021-12-18 10:31:37 +01:00
.browserslistrc initial commit (rails new sharedlists) 2021-12-18 10:31:37 +01:00
.dockerignore Add Docker files, Update rails commands 2021-12-18 11:25:31 +01:00
.gitattributes initial commit (rails new sharedlists) 2021-12-18 10:31:37 +01:00
.gitignore add public/packs to .gitignore 2021-12-21 08:45:42 +01:00
.ruby-version initial commit (rails new sharedlists) 2021-12-18 10:31:37 +01:00
babel.config.js initial commit (rails new sharedlists) 2021-12-18 10:31:37 +01:00
config.ru initial commit (rails new sharedlists) 2021-12-18 10:31:37 +01:00
docker-compose.yml prefer '-b 0.0.0.0' over '--bind 0.0.0.0' (docker-compose.yml) 2021-12-18 18:52:14 +01:00
docker-entrypoint.sh Add Docker files, Update rails commands 2021-12-18 11:25:31 +01:00
Dockerfile set Dockerfile's base image to ruby:2.7.5 2021-12-18 18:52:14 +01:00
Dockerfile.development fix GEM_PATH and PATH in Dockerfile.development 2021-12-21 08:45:41 +01:00
Gemfile Add more necessary gems, define versions, remove comments 2021-12-18 17:48:56 +01:00
Gemfile.lock Add more necessary gems, define versions, remove comments 2021-12-18 17:48:56 +01:00
LICENSE Add Licence file 2021-12-18 11:24:54 +01:00
package.json add jquery (via webpack) 2021-12-18 14:36:15 +01:00
postcss.config.js initial commit (rails new sharedlists) 2021-12-18 10:31:37 +01:00
proc-start Add Docker files, Update rails commands 2021-12-18 11:25:31 +01:00
Procfile Add Docker files, Update rails commands 2021-12-18 11:25:31 +01:00
Rakefile initial commit (rails new sharedlists) 2021-12-18 10:31:37 +01:00
README.md copy README.md from old sharedlists 2021-12-18 16:13:53 +01:00
yarn.lock add jquery (via webpack) 2021-12-18 14:36:15 +01:00

Sharedlists

Docker Status

Sharedlists is a simple rails driven database for managing multiple product lists of various suppliers.

This app is used in conjunction with foodsoft. Recommended Ruby version is 2.3 (note that 2.4 does not work).

Development

Setup

Copy config/database.yml.SAMPLE to config/database.yml and

docker-compose run --rm app bundle
docker-compose run --rm app rake db:setup

Run

docker-compose up

Creating a user

To access sharedlists, you'll need to create a user (and I guess you want admin access).

docker-compose run --rm app rails c
> u = User.new(email: 'admin@example.com', password: 'secret')
> u.admin = true
> u.save!
> exit

Production

Either fetch the image, or build it:

docker pull sharedlists:latest
# or
docker build --tag sharedlists:latest --rm .

Then set environment variables SECRET_TOKEN and DATABASE_URL and run:

docker run --name sharedlists_web \
  -e SECRET_TOKEN -e DATABASE_URL -e RAILS_FORCE_SSL=false \
  sharedlists:latest

To run cronjobs, start another instance:

docker run --name sharedlists_cron \
  -e SECRET_TOKEN -e DATABASE_URL \
  sharedlists:latest  ./proc-start cron

If you want to process incoming mails, add another instance like the previous, substituting mail for cron.

To put this all together, you may want to wrap this in docker-compose. See the foodcoops.net setup for a real-world example.

Connecting Foodsoft

To use shared suppliers from this sharedlists instance from within Foodsoft, you need to configure the shared_lists option in its config/app_config.yml. Don't forget to grant the Foodsoft database user SELECT access on sharedlists' suppliers and articles tables.

Updating articles

Articles in the database can be updated regularly. There are currently two options to do this automatically.

FTP

Some suppliers distribute article lists via FTP. You can use the rake task called sync_ftp_files in order to download and parse those article lists. First, you need to enable FTP synchronization for a certain supplier by activating the checkbox Synchronize FTP files. Fill out all corresponding form fields. In particular, make sure to adjust the file filter (regular expression) such that it matches the files of interest; non-matching files are ignored. The two supported file formats and sensible choices for a corresponding file filter are shown in the following table.

file format example file filter
BNN3 \A(?:[.]/)?PL.{0,6}[.]BNN\z
foodsoft \A(?:[.]/)?.+[.]csv\z

Once you have the sync_ftp_files task working, you may wish to setup a cronjob using whenever.

Email

Some suppliers send a regular email with an article list in the attachment. For this, an email server needs to be run using the rake task mail:smtp_server. On production, you may want to run this on localhost on an unprivileged port, with a proper MTA in front that does message routing.

To enable this for a certain supplier, tick the checkbox Update articles by email. Then select a file format to use for importing, and the supplier's email address from which the email is sent. If you only want to import for mails with a subject that contains a certain text (e.g. Articles in week), fill in the subject field as well.

What email address does the supplier need to send to? Users will find this after saving the supplier after Send to.

This needs setting up of the environment variable MAILER_DOMAIN, on which you receive the emails. It is allowed to prefix the address, you may want to set the prefix in MAILER_PREFIX. This is useful when you're running an email server in front to route mails.