bfh-mensa

1.0.3 • Public • Published

mensa.js

mensa.js is a ready-to-use node.js script which crawls the website of the Bern University of Applied Sciences in order to retrieve today's cantina menu in Biel.

Requirements

  • Node.js (v8+)
  • v10.15.1 is recommended

Installation

First, open your terminal or git bash in order to clone and install this repository into any directory of your choice:

git clone https://github.com/frickerg/mensajs.git
cd mensajs
npm install

Add mensa.js to your terminal

Now this is where the fun begins: Imagine to sit in a lecture and your stomach is growling like crazy. It would be way too distracting from this precious lecture if we had to open up the bfh website and search for the menu.

Since we're programmers, we do everything (or most things) inside a terminal. We will eventually be able to check today's menu with only one simple command!

On Linux

Since you use Linux, I assume that you know what you are doing. Create an alias for the node command in your .bash_profile, .bashrc, .zshrc or other startup scripts:

alias mensajs='node ~/path/to/mensajs/mensa.js'
 
# You can also specify in which language you want to retrieve the menu 
# To retrieve the menu in French, add the --fr argument 
alias mensajs='node ~/path/to/mensajs/mensa.js --fr'

Changes are only available in a new shell session. To make changes immediately available, run source ~/.bashrc (or your shell config file like .zshrc).

The best way however in my opinion, is to always restart your computer after messing with your bash 😉

On Mac OS

On Mac OS, open Finder and navigate to your home directory (named after your username with the house-icon) and show all hidden files with CMD + SHIFT + .

You will now see a file called .bash_profile, open it with a TextEditor of your choice and add your aliases at the end of the file:

alias mensajs='node ~/path/to/mensajs/mensa.js'
alias mensa='mensajs'
 
# You can use whatever you want as an alias, like for very hungry days: 
alias givemefood='node ~/path/to/mensajs/mensa.js'
 
# You can also specify in which language you want to retrieve the menu 
# To retrieve the menu in French, add the --fr argument 
alias mensajs='node ~/path/to/mensajs/mensa.js --fr'

To make the command available from everywhere in the system, DO NOT remove the ~/ prefix at the beginning!

Save the file and close it. Now log out or restart your computer. You can now retrieve today's cantina menu by simply entering the command mensajs (or any other alias defined by yourself) and the script will display today's menu inside of your terminal! 🎉

On Windows

Create a .bat or .cmd file with DOSKEY commands. Be sure to save the file on your C:\ drive and avoid any User sub-directories such as Desktop, Documents, etc. (I usually save it as close to the C:\ root directory as possible or directly inside my own User directory).

Now write this into your newly created file and adapt the path:

@echo off
 
DOSKEY mensajs="node C:\path\to\mensajs\mensa.js"
DOSKEY mensa="mensajs"

You can also specify in which language you want to retrieve the menu. To retrieve the menu in French, add the --fr argument:

DOSKEY mensajs="node C:\path\to\mensajs\mensa.js --fr"

Run regedit and go to HKEY_CURRENT_USER\Software\Microsoft\Command Processor, then choose Add String Value to add a new entry with the name AutoRun and the full path of your .bat/.cmd file.

For example, %USERPROFILE%\alias.cmd, replacing the initial segment of the path with %USERPROFILE% is useful for syncing among multiple machines. This way, every time cmd is run, the aliases are loaded. The path as well as the name of your .bat/.cmd file are completely up to you and within your own responsibility.

After performing all these steps, make sure to restart your computer. The aliases should now be set and you can call the script with the alias you've set within your .bat/.cmd file.

Run it!

After successfully performing all required steps described above, just open a terminal of your choice, type your specified alias command and press enter to get the glorious mensa menu of today!

Who's hungry?

Copyright (c) 2019 Guillaume Fricker

Contributors Hall of Fame

Gabriel Hess (@hessg1):

  • Fixed a breaking error after the layout of the website had changed
  • Implemented the "Mardi Francophone", an important tradition at the I4MI

Versions

Current Tags

VersionDownloads (Last 7 Days)Tag
1.0.36latest

Version History

VersionDownloads (Last 7 Days)Published
1.0.36

Package Sidebar

Install

npm i bfh-mensa

Weekly Downloads

3

Version

1.0.3

License

MIT

Unpacked Size

411 kB

Total Files

7

Last publish

Collaborators

  • hessg1