Skip to content

JuliusR/sharedlists

 
 

Repository files navigation

Sharedlists

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

This app is used in conjunction with foodsoft.

Setup

There are mutliple way how to setup Sharedlists:

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. The tasks you want to run:

rails sync_ftp_files --silent > /dev/null

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 rails 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 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 initial creating and saving the supplier after Send to.

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

MAILER_DOMAIN=example.com
MAILER_PREFIX=sharedlists+

# optional, default values are shown
SMTP_SERVER_PORT=2525
SMTP_SERVER_HOST=127.0.0.1

Your MTA needs to transport all incomming mails to the internal mail server. With Postfix create a new transport file /etc/postfix/transport_sharedlists with the following content:

/^sharedlists\+[0-9]*\.([0-9A-Z])*@example\.com$/  smtp:[127.0.0.1]:2525

As you can see we are using the MAILER_PREFIX to filter incomming mails and redirect them.

After that add the new transport to the Postfix configuration at /etc/postfix/main.cf:

recipient_delimiter = +
transport_maps = pcre:/etc/postfix/transport_sharedlists

About

Manage and update shared article databases for Foodsoft.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Ruby 78.7%
  • Haml 11.4%
  • HTML 4.4%
  • Dockerfile 1.6%
  • JavaScript 1.6%
  • CSS 0.9%
  • Other 1.4%