Documentation
¶
Overview ¶
Package stwmmensa provides tools to get the menu for Studentenwerk Muenchen canteens
Index ¶
- Constants
- func FormatLIS(dishes []Dish, date time.Time, outfile string)
- func FormatValid(format string) bool
- func FormatXML(dishes []Dish, date time.Time, outfile string)
- func GermanMonth(m time.Month) string
- func GermanWeekday(w time.Weekday) string
- func GetDate(now time.Time) time.Time
- func LocationValid(id string) bool
- func UpdateMenuFile(location string, format string, outfile string)
- func WriteOutput(menu Menu, format string, outfile string)
- type Dish
- type Menu
- type XMLDish
- Bugs
Constants ¶
const NextDayAfter = 14
NextDayAfter is the threshold value which is used to determine, whether todays menu or tomorrows menu shall be fetched. If the processed time is equal to or greater than NextDayAfter:00 the next day is chosen. For example if NextDayAfter == 14 the next day will be chosen starting from 2PM.
Variables ¶
This section is empty.
Functions ¶
func FormatLIS ¶
FormatLIS writes a HTML snippet containing the menu to the file outfile. The menu consists of a title containing the date which was given as input and a list of the Dish objects contained in dishes.
The output will look somethin like this:
<h1> <span> class="mensa-title">Mensa</span> <span> class="mensa-date">Donnerstag 01. Juni 2017"</span> </h1> <div class="mensa-box"> <div class="mensa-item"> <span class="mensa-name">Tagesgericht 1</span> <span class="mensa-value">Kartoffeleintopf mit Majoran</span> </div> <div class="mensa-item"> <span class="mensa-name">Tagesgericht 2</span> <span class="mensa-value">Prager Bratwurst (R,S)(2,3,8)</span> </div> <div class="mensa-item"> <span class="mensa-name">Aktionsessen 5</span> <span class="mensa-value">Rindergeschnetzeltes Stroganoff (GQB) (R)(2,9)</span> </div> <div class="mensa-item"> <span class="mensa-name">Self-Service</span> <span class="mensa-value">Fusilli mit Rucola-Pesto</span> </div> <div class="mensa-item"> <span class="mensa-name">Self-Service</span> <span class="mensa-value">Bio-Penne mit Bio-Tomaten-Frischkäse-Sauce</span> </div> <div class="mensa-item"> <span class="mensa-name">Self-Service</span> <span class="mensa-value">Kartoffeleintopf mit Majoran</span> </div> </div>
This is not valid HTML for standalone use. However this is exactly the format needed to include the menu on the infoscreen running at the kitchen of http://www.lis.ei.tum.de
func FormatValid ¶
FormatValid checks, whether the string format is either "xml" or "lis", which are the two supported output formats
func FormatXML ¶
FormatXML writes a XML formatted menu to the file outfile. The menu consists of a title containing the date which was given as input and a list of the Dish objects contained in dishes.
The output will be formatted like this:
<menu title="Mensa am Donnerstag den 01.06."> <dish name="Kartoffeleintopf mit Majoran" category="Tagesgericht 1"></dish> <dish name="Prager Bratwurst (R,S)(2,3,8)" category="Tagesgericht 2"></dish> <dish name="Rindergeschnetzeltes Stroganoff (GQB) (R)(2,9)" category="Aktionsessen 5"></dish> <dish name="Fusilli mit Rucola-Pesto" category="Self-Service"></dish> <dish name="Bio-Penne mit Bio-Tomaten-Frischkäse-Sauce" category="Self-Service"></dish> <dish name="Kartoffeleintopf mit Majoran" category="Self-Service"></dish> </menu>
func GermanMonth ¶
GermanMonth returns the german name for a time.Month
func GermanWeekday ¶
GermanWeekday returns the german name for a time.Weekday
func GetDate ¶
GetDate returns the date for which we want to show the canteen menu based on the time now. If now.Weekday() is either Saturday or Sunday the following monday will be returned by adding 48 resp. 24 hours to now. For monday through friday now itself will be returned if it is before NextDayAfter PM. If now is after NextDayAfter PM, the following day (for friday the following monday) will be returned by adding 24 hours (72 hours for friday) to now.
func LocationValid ¶
LocationValid checks whether string id is a valid STWM canteen ID
func UpdateMenuFile ¶
UpdateMenuFile updates (or creates) the file "outfile" with the current menu for canteen with id "location" formatted in the "format" style.
func WriteOutput ¶
WriteOutput calls either FormatLIS if format=="lis" or FormatXML in all other cases. These methods will then write to outfile.
Types ¶
type Dish ¶
Dish is used to store name and category of a dish
func GetDishes ¶
GetDishes uses goquery https://github.com/PuerkitoBio/goquery to extract dishes from the Studentenwerk München canteen menu webpage located at url and returns a (possibly empty) list of Dish objects.
The output should contain only main dishes. However due to the cluttered classification by the Studentenwerk, there might still be sides/desserts which are not handled correctly. All declarations (e.g. (v) for "dish is vegan") are stripped from the dish names.
type Menu ¶
Menu consists of date, canteen location id and a list of dishes
func FetchMenu ¶
FetchMenu fetches the menu for the canteen identified by location and the day of date from the Studentenwerk München website.
The URL is composed in the format:
http://www.studentenwerk-muenchen.de/mensa/speiseplan/speiseplan_2017-05-31_421_-de.html
The return value will be a (possibly empty) list of dishes.
Notes ¶
Bugs ¶
there is no handling of holidays