Generate headings for favourite-bar from content

Fixes #105
This commit is contained in:
Gregor Kleen 2018-07-07 22:16:22 +02:00
parent 16a60e8c65
commit 353245c65f
3 changed files with 26 additions and 16 deletions

View File

@ -10,6 +10,8 @@ DeRegUntil: Abmeldungen bis
SummerTerm year@Integer: Sommersemester #{display year} SummerTerm year@Integer: Sommersemester #{display year}
WinterTerm year@Integer: Wintersemester #{display year}/#{display $ succ year} WinterTerm year@Integer: Wintersemester #{display year}/#{display $ succ year}
SummerTermShort year@Integer: SoSe #{display year}
WinterTermShort year@Integer: WiSe #{display year}/#{display $ succ year}
PSLimitNonPositive: “pagesize” muss größer als null sein PSLimitNonPositive: “pagesize” muss größer als null sein
Page n@Int64: #{display n} Page n@Int64: #{display n}

View File

@ -487,6 +487,10 @@ instance Yesod UniWorX where
actFav = List.intersect (snd3 <$> favourites) crumbs actFav = List.intersect (snd3 <$> favourites) crumbs
highRs = if null actFav then crumbs else actFav highRs = if null actFav then crumbs else actFav
in \r -> r `elem` highRs in \r -> r `elem` highRs
favouriteTerms :: [TermIdentifier]
favouriteTerms = Set.toDescList $ foldMap (\(Course{..}, _, _) -> Set.singleton $ unTermKey courseTerm) favourites
favouriteTerm :: TermIdentifier -> [(Course, Route UniWorX, [MenuTypes])]
favouriteTerm tid = filter (\(Course{..}, _, _) -> unTermKey courseTerm == tid) favourites
-- We break up the default layout into two components: -- We break up the default layout into two components:
-- default-layout is the contents of the body tag, and -- default-layout is the contents of the body tag, and

View File

@ -2,19 +2,23 @@ $newline never
<aside .main__aside> <aside .main__aside>
<div .asidenav> <div .asidenav>
<div .asidenav__box> <div .asidenav__box>
<h3 .asidenav__box-title> $forall tid@TermIdentifier{..} <- favouriteTerms
$# TODO: this has to come from favourites somehow. Show favourites from older terms? <h3 .asidenav__box-title>
WiSe 17/18 $case season
<ul .asidenav__list> $of Winter
$forall (Course{..}, courseRoute, pageActions) <- favourites _{MsgWinterTermShort year}
<li .asidenav__list-item :highlight courseRoute:.asidenav__list-item--active> $of Summer
<a .asidenav__link-wrapper href=@{courseRoute}> _{MsgSummerTermShort year}
<div .asidenav__link-shorthand>#{courseShorthand} <ul .asidenav__list>
<div .asidenav__link-label>#{courseName} $forall (Course{..}, courseRoute, pageActions) <- favouriteTerm tid
<ul .asidenav__nested-list> <li .asidenav__list-item :highlight courseRoute:.asidenav__list-item--active>
$forall action <- pageActions <a .asidenav__link-wrapper href=@{courseRoute}>
$case action <div .asidenav__link-shorthand>#{courseShorthand}
$of PageActionPrime (MenuItem{..}) <div .asidenav__link-label>#{courseName}
<li .asidenav__nested-list-item> <ul .asidenav__nested-list>
<a .asidenav__link-wrapper href=@{menuItemRoute}>#{menuItemLabel} $forall action <- pageActions
$of _ $case action
$of PageActionPrime (MenuItem{..})
<li .asidenav__nested-list-item>
<a .asidenav__link-wrapper href=@{menuItemRoute}>#{menuItemLabel}
$of _